mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 11:35:42 -06:00
Accept new LKG (LKGd via gulp)
This commit is contained in:
parent
e0ffe05f02
commit
c98166ccc7
1195
lib/tsc.js
1195
lib/tsc.js
File diff suppressed because it is too large
Load Diff
27037
lib/tsserver.js
27037
lib/tsserver.js
File diff suppressed because one or more lines are too long
565
lib/tsserverlibrary.d.ts
vendored
565
lib/tsserverlibrary.d.ts
vendored
File diff suppressed because it is too large
Load Diff
27010
lib/tsserverlibrary.js
27010
lib/tsserverlibrary.js
File diff suppressed because one or more lines are too long
18
lib/typescript.d.ts
vendored
18
lib/typescript.d.ts
vendored
@ -919,7 +919,7 @@ declare namespace ts {
|
||||
type ModuleBody = ModuleBlock | ModuleDeclaration;
|
||||
interface ModuleDeclaration extends DeclarationStatement {
|
||||
name: Identifier | LiteralExpression;
|
||||
body: ModuleBlock | ModuleDeclaration;
|
||||
body?: ModuleBlock | ModuleDeclaration;
|
||||
}
|
||||
interface ModuleBlock extends Node, Statement {
|
||||
statements: NodeArray<Statement>;
|
||||
@ -1575,6 +1575,8 @@ declare namespace ts {
|
||||
target?: ScriptTarget;
|
||||
traceResolution?: boolean;
|
||||
types?: string[];
|
||||
/** Paths used to used to compute primary types search locations */
|
||||
typeRoots?: string[];
|
||||
typesSearchPaths?: string[];
|
||||
[option: string]: CompilerOptionsValue | undefined;
|
||||
}
|
||||
@ -1672,6 +1674,7 @@ declare namespace ts {
|
||||
getDefaultTypeDirectiveNames?(rootPath: string): string[];
|
||||
writeFile: WriteFileCallback;
|
||||
getCurrentDirectory(): string;
|
||||
getDirectories(path: string): string[];
|
||||
getCanonicalFileName(fileName: string): string;
|
||||
useCaseSensitiveFileNames(): boolean;
|
||||
getNewLine(): string;
|
||||
@ -1821,6 +1824,7 @@ declare namespace ts {
|
||||
function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile;
|
||||
}
|
||||
declare namespace ts {
|
||||
/** The version of the TypeScript compiler release */
|
||||
const version: string;
|
||||
function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean): string;
|
||||
function resolveTripleslashReference(moduleName: string, containingFile: string): string;
|
||||
@ -1836,7 +1840,15 @@ declare namespace ts {
|
||||
function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost;
|
||||
function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[];
|
||||
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
|
||||
function getDefaultTypeDirectiveNames(options: CompilerOptions, rootFiles: string[], host: CompilerHost): string[];
|
||||
/**
|
||||
* Given a set of options and a set of root files, returns the set of type directive names
|
||||
* that should be included for this program automatically.
|
||||
* This list could either come from the config file,
|
||||
* or from enumerating the types root + initial secondary types lookup location.
|
||||
* More type directives might appear in the program later as a result of loading actual source files;
|
||||
* this list is only the set of defaults that are implicitly included.
|
||||
*/
|
||||
function getAutomaticTypeDirectiveNames(options: CompilerOptions, rootFiles: string[], host: CompilerHost): string[];
|
||||
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program;
|
||||
}
|
||||
declare namespace ts {
|
||||
@ -1978,6 +1990,7 @@ declare namespace ts {
|
||||
resolveModuleNames?(moduleNames: string[], containingFile: string): ResolvedModule[];
|
||||
resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[];
|
||||
directoryExists?(directoryName: string): boolean;
|
||||
getDirectories?(directoryName: string): string[];
|
||||
}
|
||||
interface LanguageService {
|
||||
cleanupSemanticCache(): void;
|
||||
@ -2068,6 +2081,7 @@ declare namespace ts {
|
||||
textSpan: TextSpan;
|
||||
fileName: string;
|
||||
isWriteAccess: boolean;
|
||||
isDefinition: boolean;
|
||||
}
|
||||
interface DocumentHighlights {
|
||||
fileName: string;
|
||||
|
||||
@ -1,18 +1,3 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
@ -2425,7 +2410,6 @@ var ts;
|
||||
Line_terminator_not_permitted_before_arrow: { code: 1200, category: ts.DiagnosticCategory.Error, key: "Line_terminator_not_permitted_before_arrow_1200", message: "Line terminator not permitted before arrow." },
|
||||
Import_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: { code: 1202, category: ts.DiagnosticCategory.Error, key: "Import_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_import_Asteri_1202", message: "Import assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead." },
|
||||
Export_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_export_default_or_another_module_format_instead: { code: 1203, category: ts.DiagnosticCategory.Error, key: "Export_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_export_defaul_1203", message: "Export assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'export default' or another module format instead." },
|
||||
Cannot_compile_modules_into_es2015_when_targeting_ES5_or_lower: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_modules_into_es2015_when_targeting_ES5_or_lower_1204", message: "Cannot compile modules into 'es2015' when targeting 'ES5' or lower." },
|
||||
Decorators_are_not_valid_here: { code: 1206, category: ts.DiagnosticCategory.Error, key: "Decorators_are_not_valid_here_1206", message: "Decorators are not valid here." },
|
||||
Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { code: 1207, category: ts.DiagnosticCategory.Error, key: "Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name_1207", message: "Decorators cannot be applied to multiple get/set accessors of the same name." },
|
||||
Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided: { code: 1208, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided_1208", message: "Cannot compile namespaces when the '--isolatedModules' flag is provided." },
|
||||
@ -2750,6 +2734,7 @@ var ts;
|
||||
The_this_types_of_each_signature_are_incompatible: { code: 2685, category: ts.DiagnosticCategory.Error, key: "The_this_types_of_each_signature_are_incompatible_2685", message: "The 'this' types of each signature are incompatible." },
|
||||
Identifier_0_must_be_imported_from_a_module: { code: 2686, category: ts.DiagnosticCategory.Error, key: "Identifier_0_must_be_imported_from_a_module_2686", message: "Identifier '{0}' must be imported from a module" },
|
||||
All_declarations_of_0_must_have_identical_modifiers: { code: 2687, category: ts.DiagnosticCategory.Error, key: "All_declarations_of_0_must_have_identical_modifiers_2687", message: "All declarations of '{0}' must have identical modifiers." },
|
||||
Cannot_find_type_definition_file_for_0: { code: 2688, category: ts.DiagnosticCategory.Error, key: "Cannot_find_type_definition_file_for_0_2688", message: "Cannot find type definition file for '{0}'." },
|
||||
Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import_declaration_0_is_using_private_name_1_4000", message: "Import declaration '{0}' is using private name '{1}'." },
|
||||
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", message: "Type parameter '{0}' of exported class has or is using private name '{1}'." },
|
||||
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", message: "Type parameter '{0}' of exported interface has or is using private name '{1}'." },
|
||||
@ -4985,6 +4970,11 @@ var ts;
|
||||
(node.name.kind === 9 /* StringLiteral */ || isGlobalScopeAugmentation(node));
|
||||
}
|
||||
ts.isAmbientModule = isAmbientModule;
|
||||
function isShorthandAmbientModule(node) {
|
||||
// The only kind of module that can be missing a body is a shorthand ambient module.
|
||||
return node.kind === 225 /* ModuleDeclaration */ && (!node.body);
|
||||
}
|
||||
ts.isShorthandAmbientModule = isShorthandAmbientModule;
|
||||
function isBlockScopedContainerTopLevel(node) {
|
||||
return node.kind === 256 /* SourceFile */ ||
|
||||
node.kind === 225 /* ModuleDeclaration */ ||
|
||||
@ -5417,6 +5407,7 @@ var ts;
|
||||
case 157 /* ConstructorType */:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
ts.isFunctionLikeKind = isFunctionLikeKind;
|
||||
function introducesArgumentsExoticObject(node) {
|
||||
@ -5839,6 +5830,18 @@ var ts;
|
||||
return charCode === 39 /* singleQuote */ || charCode === 34 /* doubleQuote */;
|
||||
}
|
||||
ts.isSingleOrDoubleQuote = isSingleOrDoubleQuote;
|
||||
/**
|
||||
* Returns true if the node is a variable declaration whose initializer is a function expression.
|
||||
* This function does not test if the node is in a JavaScript file or not.
|
||||
*/
|
||||
function isDeclarationOfFunctionExpression(s) {
|
||||
if (s.valueDeclaration && s.valueDeclaration.kind === 218 /* VariableDeclaration */) {
|
||||
var declaration = s.valueDeclaration;
|
||||
return declaration.initializer && declaration.initializer.kind === 179 /* FunctionExpression */;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
ts.isDeclarationOfFunctionExpression = isDeclarationOfFunctionExpression;
|
||||
/// Given a BinaryExpression, returns SpecialPropertyAssignmentKind for the various kinds of property
|
||||
/// assignments we treat as special in the binder
|
||||
function getSpecialPropertyAssignmentKind(expression) {
|
||||
@ -12250,7 +12253,12 @@ var ts;
|
||||
else {
|
||||
node.name = parseLiteralNode(/*internName*/ true);
|
||||
}
|
||||
node.body = parseModuleBlock();
|
||||
if (token === 15 /* OpenBraceToken */) {
|
||||
node.body = parseModuleBlock();
|
||||
}
|
||||
else {
|
||||
parseSemicolon();
|
||||
}
|
||||
return finishNode(node);
|
||||
}
|
||||
function parseModuleDeclaration(fullStart, decorators, modifiers) {
|
||||
@ -13752,7 +13760,8 @@ var ts;
|
||||
return state_1;
|
||||
}
|
||||
else if (node.kind === 225 /* ModuleDeclaration */) {
|
||||
return getModuleInstanceState(node.body);
|
||||
var body = node.body;
|
||||
return body ? getModuleInstanceState(body) : 1 /* Instantiated */;
|
||||
}
|
||||
else {
|
||||
return 1 /* Instantiated */;
|
||||
@ -14262,10 +14271,11 @@ var ts;
|
||||
case 31 /* ExclamationEqualsToken */:
|
||||
case 32 /* EqualsEqualsEqualsToken */:
|
||||
case 33 /* ExclamationEqualsEqualsToken */:
|
||||
if (isNarrowingExpression(expr.left) && (expr.right.kind === 93 /* NullKeyword */ || expr.right.kind === 69 /* Identifier */)) {
|
||||
if ((isNarrowingExpression(expr.left) && (expr.right.kind === 93 /* NullKeyword */ || expr.right.kind === 69 /* Identifier */)) ||
|
||||
(isNarrowingExpression(expr.right) && (expr.left.kind === 93 /* NullKeyword */ || expr.left.kind === 69 /* Identifier */))) {
|
||||
return true;
|
||||
}
|
||||
if (expr.left.kind === 182 /* TypeOfExpression */ && isNarrowingExpression(expr.left.expression) && expr.right.kind === 9 /* StringLiteral */) {
|
||||
if (isTypeOfNarrowingBinaryExpression(expr)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -14276,6 +14286,19 @@ var ts;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function isTypeOfNarrowingBinaryExpression(expr) {
|
||||
var typeOf;
|
||||
if (expr.left.kind === 9 /* StringLiteral */) {
|
||||
typeOf = expr.right;
|
||||
}
|
||||
else if (expr.right.kind === 9 /* StringLiteral */) {
|
||||
typeOf = expr.left;
|
||||
}
|
||||
else {
|
||||
typeOf = undefined;
|
||||
}
|
||||
return typeOf && typeOf.kind === 182 /* TypeOfExpression */ && isNarrowingExpression(typeOf.expression);
|
||||
}
|
||||
function createBranchLabel() {
|
||||
return {
|
||||
flags: 4 /* BranchLabel */,
|
||||
@ -14855,7 +14878,7 @@ var ts;
|
||||
}
|
||||
function hasExportDeclarations(node) {
|
||||
var body = node.kind === 256 /* SourceFile */ ? node : node.body;
|
||||
if (body.kind === 256 /* SourceFile */ || body.kind === 226 /* ModuleBlock */) {
|
||||
if (body && (body.kind === 256 /* SourceFile */ || body.kind === 226 /* ModuleBlock */)) {
|
||||
for (var _i = 0, _a = body.statements; _i < _a.length; _i++) {
|
||||
var stat = _a[_i];
|
||||
if (stat.kind === 236 /* ExportDeclaration */ || stat.kind === 235 /* ExportAssignment */) {
|
||||
@ -15471,7 +15494,7 @@ var ts;
|
||||
constructorFunction.parent = classPrototype;
|
||||
classPrototype.parent = leftSideOfAssignment;
|
||||
var funcSymbol = container.locals[constructorFunction.text];
|
||||
if (!funcSymbol || !(funcSymbol.flags & 16 /* Function */)) {
|
||||
if (!funcSymbol || !(funcSymbol.flags & 16 /* Function */ || ts.isDeclarationOfFunctionExpression(funcSymbol))) {
|
||||
return;
|
||||
}
|
||||
// Set up the members collection if it doesn't exist already
|
||||
@ -16579,9 +16602,11 @@ var ts;
|
||||
function getTargetOfImportClause(node) {
|
||||
var moduleSymbol = resolveExternalModuleName(node, node.parent.moduleSpecifier);
|
||||
if (moduleSymbol) {
|
||||
var exportDefaultSymbol = moduleSymbol.exports["export="] ?
|
||||
getPropertyOfType(getTypeOfSymbol(moduleSymbol.exports["export="]), "default") :
|
||||
resolveSymbol(moduleSymbol.exports["default"]);
|
||||
var exportDefaultSymbol = ts.isShorthandAmbientModule(moduleSymbol.valueDeclaration) ?
|
||||
moduleSymbol :
|
||||
moduleSymbol.exports["export="] ?
|
||||
getPropertyOfType(getTypeOfSymbol(moduleSymbol.exports["export="]), "default") :
|
||||
resolveSymbol(moduleSymbol.exports["default"]);
|
||||
if (!exportDefaultSymbol && !allowSyntheticDefaultImports) {
|
||||
error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol));
|
||||
}
|
||||
@ -16650,6 +16675,9 @@ var ts;
|
||||
if (targetSymbol) {
|
||||
var name_10 = specifier.propertyName || specifier.name;
|
||||
if (name_10.text) {
|
||||
if (ts.isShorthandAmbientModule(moduleSymbol.valueDeclaration)) {
|
||||
return moduleSymbol;
|
||||
}
|
||||
var symbolFromVariable = void 0;
|
||||
// First check if module was specified with "export=". If so, get the member from the resolved type
|
||||
if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports["export="]) {
|
||||
@ -18600,9 +18628,14 @@ var ts;
|
||||
function getTypeOfFuncClassEnumModule(symbol) {
|
||||
var links = getSymbolLinks(symbol);
|
||||
if (!links.type) {
|
||||
var type = createObjectType(65536 /* Anonymous */, symbol);
|
||||
links.type = strictNullChecks && symbol.flags & 536870912 /* Optional */ ?
|
||||
addTypeKind(type, 32 /* Undefined */) : type;
|
||||
if (symbol.valueDeclaration.kind === 225 /* ModuleDeclaration */ && ts.isShorthandAmbientModule(symbol.valueDeclaration)) {
|
||||
links.type = anyType;
|
||||
}
|
||||
else {
|
||||
var type = createObjectType(65536 /* Anonymous */, symbol);
|
||||
links.type = strictNullChecks && symbol.flags & 536870912 /* Optional */ ?
|
||||
addTypeKind(type, 32 /* Undefined */) : type;
|
||||
}
|
||||
}
|
||||
return links.type;
|
||||
}
|
||||
@ -22903,10 +22936,11 @@ var ts;
|
||||
case 31 /* ExclamationEqualsToken */:
|
||||
case 32 /* EqualsEqualsEqualsToken */:
|
||||
case 33 /* ExclamationEqualsEqualsToken */:
|
||||
if (isNullOrUndefinedLiteral(expr.right)) {
|
||||
if (isNullOrUndefinedLiteral(expr.left) || isNullOrUndefinedLiteral(expr.right)) {
|
||||
return narrowTypeByNullCheck(type, expr, assumeTrue);
|
||||
}
|
||||
if (expr.left.kind === 182 /* TypeOfExpression */ && expr.right.kind === 9 /* StringLiteral */) {
|
||||
if (expr.left.kind === 182 /* TypeOfExpression */ && expr.right.kind === 9 /* StringLiteral */ ||
|
||||
expr.left.kind === 9 /* StringLiteral */ && expr.right.kind === 182 /* TypeOfExpression */) {
|
||||
return narrowTypeByTypeof(type, expr, assumeTrue);
|
||||
}
|
||||
break;
|
||||
@ -22918,18 +22952,20 @@ var ts;
|
||||
return type;
|
||||
}
|
||||
function narrowTypeByNullCheck(type, expr, assumeTrue) {
|
||||
// We have '==', '!=', '===', or '!==' operator with 'null' or 'undefined' on the right
|
||||
// We have '==', '!=', '===', or '!==' operator with 'null' or 'undefined' on one side
|
||||
var operator = expr.operatorToken.kind;
|
||||
var nullLike = isNullOrUndefinedLiteral(expr.left) ? expr.left : expr.right;
|
||||
var narrowed = isNullOrUndefinedLiteral(expr.left) ? expr.right : expr.left;
|
||||
if (operator === 31 /* ExclamationEqualsToken */ || operator === 33 /* ExclamationEqualsEqualsToken */) {
|
||||
assumeTrue = !assumeTrue;
|
||||
}
|
||||
if (!strictNullChecks || !isMatchingReference(reference, getReferenceFromExpression(expr.left))) {
|
||||
if (!strictNullChecks || !isMatchingReference(reference, getReferenceFromExpression(narrowed))) {
|
||||
return type;
|
||||
}
|
||||
var doubleEquals = operator === 30 /* EqualsEqualsToken */ || operator === 31 /* ExclamationEqualsToken */;
|
||||
var facts = doubleEquals ?
|
||||
assumeTrue ? 65536 /* EQUndefinedOrNull */ : 524288 /* NEUndefinedOrNull */ :
|
||||
expr.right.kind === 93 /* NullKeyword */ ?
|
||||
nullLike.kind === 93 /* NullKeyword */ ?
|
||||
assumeTrue ? 32768 /* EQNull */ : 262144 /* NENull */ :
|
||||
assumeTrue ? 16384 /* EQUndefined */ : 131072 /* NEUndefined */;
|
||||
return getTypeWithFacts(type, facts);
|
||||
@ -22937,12 +22973,12 @@ var ts;
|
||||
function narrowTypeByTypeof(type, expr, assumeTrue) {
|
||||
// We have '==', '!=', '====', or !==' operator with 'typeof xxx' on the left
|
||||
// and string literal on the right
|
||||
var left = getReferenceFromExpression(expr.left.expression);
|
||||
var right = expr.right;
|
||||
if (!isMatchingReference(reference, left)) {
|
||||
var narrowed = getReferenceFromExpression((expr.left.kind === 182 /* TypeOfExpression */ ? expr.left : expr.right).expression);
|
||||
var literal = (expr.right.kind === 9 /* StringLiteral */ ? expr.right : expr.left);
|
||||
if (!isMatchingReference(reference, narrowed)) {
|
||||
// For a reference of the form 'x.y', a 'typeof x === ...' type guard resets the
|
||||
// narrowed type of 'y' to its declared type.
|
||||
if (containsMatchingReference(reference, left)) {
|
||||
if (containsMatchingReference(reference, narrowed)) {
|
||||
return declaredType;
|
||||
}
|
||||
return type;
|
||||
@ -22955,14 +22991,14 @@ var ts;
|
||||
// We narrow a non-union type to an exact primitive type if the non-union type
|
||||
// is a supertype of that primtive type. For example, type 'any' can be narrowed
|
||||
// to one of the primitive types.
|
||||
var targetType = ts.getProperty(typeofTypesByName, right.text);
|
||||
var targetType = ts.getProperty(typeofTypesByName, literal.text);
|
||||
if (targetType && isTypeSubtypeOf(targetType, type)) {
|
||||
return targetType;
|
||||
}
|
||||
}
|
||||
var facts = assumeTrue ?
|
||||
ts.getProperty(typeofEQFacts, right.text) || 64 /* TypeofEQHostObject */ :
|
||||
ts.getProperty(typeofNEFacts, right.text) || 8192 /* TypeofNEHostObject */;
|
||||
ts.getProperty(typeofEQFacts, literal.text) || 64 /* TypeofEQHostObject */ :
|
||||
ts.getProperty(typeofNEFacts, literal.text) || 8192 /* TypeofNEHostObject */;
|
||||
return getTypeWithFacts(type, facts);
|
||||
}
|
||||
function narrowTypeByInstanceof(type, expr, assumeTrue) {
|
||||
@ -26126,8 +26162,12 @@ var ts;
|
||||
// When resolved signature is a call signature (and not a construct signature) the result type is any, unless
|
||||
// the declaring function had members created through 'x.prototype.y = expr' or 'this.y = expr' psuedodeclarations
|
||||
// in a JS file
|
||||
var funcSymbol = checkExpression(node.expression).symbol;
|
||||
if (funcSymbol && funcSymbol.members && (funcSymbol.flags & 16 /* Function */)) {
|
||||
// Note:JS inferred classes might come from a variable declaration instead of a function declaration.
|
||||
// In this case, using getResolvedSymbol directly is required to avoid losing the members from the declaration.
|
||||
var funcSymbol = node.expression.kind === 69 /* Identifier */ ?
|
||||
getResolvedSymbol(node.expression) :
|
||||
checkExpression(node.expression).symbol;
|
||||
if (funcSymbol && funcSymbol.members && (funcSymbol.flags & 16 /* Function */ || ts.isDeclarationOfFunctionExpression(funcSymbol))) {
|
||||
return getInferredClassType(funcSymbol);
|
||||
}
|
||||
else if (compilerOptions.noImplicitAny) {
|
||||
@ -30189,7 +30229,7 @@ var ts;
|
||||
// - augmentation for a global scope is always applied
|
||||
// - augmentation for some external module is applied if symbol for augmentation is merged (it was combined with target module).
|
||||
var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 33554432 /* Merged */);
|
||||
if (checkBody) {
|
||||
if (checkBody && node.body) {
|
||||
// body of ambient external module is always a module block
|
||||
for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) {
|
||||
var statement = _a[_i];
|
||||
@ -30217,7 +30257,13 @@ var ts;
|
||||
}
|
||||
}
|
||||
}
|
||||
checkSourceElement(node.body);
|
||||
if (compilerOptions.noImplicitAny && !node.body) {
|
||||
// Ambient shorthand module is an implicit any
|
||||
reportImplicitAnyError(node, anyType);
|
||||
}
|
||||
if (node.body) {
|
||||
checkSourceElement(node.body);
|
||||
}
|
||||
}
|
||||
function checkModuleAugmentationElement(node, isGlobalAugmentation) {
|
||||
switch (node.kind) {
|
||||
@ -33812,21 +33858,26 @@ var ts;
|
||||
writeTextOfNode(currentText, node.name);
|
||||
}
|
||||
}
|
||||
while (node.body.kind !== 226 /* ModuleBlock */) {
|
||||
while (node.body && node.body.kind !== 226 /* ModuleBlock */) {
|
||||
node = node.body;
|
||||
write(".");
|
||||
writeTextOfNode(currentText, node.name);
|
||||
}
|
||||
var prevEnclosingDeclaration = enclosingDeclaration;
|
||||
enclosingDeclaration = node;
|
||||
write(" {");
|
||||
writeLine();
|
||||
increaseIndent();
|
||||
emitLines(node.body.statements);
|
||||
decreaseIndent();
|
||||
write("}");
|
||||
writeLine();
|
||||
enclosingDeclaration = prevEnclosingDeclaration;
|
||||
if (node.body) {
|
||||
enclosingDeclaration = node;
|
||||
write(" {");
|
||||
writeLine();
|
||||
increaseIndent();
|
||||
emitLines(node.body.statements);
|
||||
decreaseIndent();
|
||||
write("}");
|
||||
writeLine();
|
||||
enclosingDeclaration = prevEnclosingDeclaration;
|
||||
}
|
||||
else {
|
||||
write(";");
|
||||
}
|
||||
}
|
||||
function writeTypeAliasDeclaration(node) {
|
||||
var prevEnclosingDeclaration = enclosingDeclaration;
|
||||
@ -36457,9 +36508,9 @@ var ts;
|
||||
emit(node.initializer);
|
||||
}
|
||||
// Return true if identifier resolves to an exported member of a namespace
|
||||
function isNamespaceExportReference(node) {
|
||||
function isExportReference(node) {
|
||||
var container = resolver.getReferencedExportContainer(node);
|
||||
return container && container.kind !== 256 /* SourceFile */;
|
||||
return !!container;
|
||||
}
|
||||
// Return true if identifier resolves to an imported identifier
|
||||
function isImportedReference(node) {
|
||||
@ -36490,10 +36541,10 @@ var ts;
|
||||
// const foo_1 = require('./foo');
|
||||
// exports.baz = { foo: foo_1.foo };
|
||||
//
|
||||
if (languageVersion < 2 /* ES6 */ || (modulekind !== ts.ModuleKind.ES6 && isImportedReference(node.name)) || isNamespaceExportReference(node.name)) {
|
||||
if (languageVersion < 2 /* ES6 */ || (modulekind !== ts.ModuleKind.ES6 && isImportedReference(node.name)) || isExportReference(node.name)) {
|
||||
// Emit identifier as an identifier
|
||||
write(": ");
|
||||
emit(node.name);
|
||||
emitExpressionIdentifier(node.name);
|
||||
}
|
||||
if (languageVersion >= 2 /* ES6 */ && node.objectAssignmentInitializer) {
|
||||
write(" = ");
|
||||
@ -39556,7 +39607,11 @@ var ts;
|
||||
}
|
||||
}
|
||||
function emitClassLikeDeclarationBelowES6(node) {
|
||||
var isES6ExportedClass = isES6ExportedDeclaration(node);
|
||||
if (node.kind === 221 /* ClassDeclaration */) {
|
||||
if (isES6ExportedClass && !(node.flags & 512 /* Default */)) {
|
||||
write("export ");
|
||||
}
|
||||
// source file level classes in system modules are hoisted so 'var's for them are already defined
|
||||
if (!shouldHoistDeclarationInSystemJsModule(node)) {
|
||||
write("var ");
|
||||
@ -39621,9 +39676,15 @@ var ts;
|
||||
write(";");
|
||||
}
|
||||
emitEnd(node);
|
||||
if (node.kind === 221 /* ClassDeclaration */) {
|
||||
if (node.kind === 221 /* ClassDeclaration */ && !isES6ExportedClass) {
|
||||
emitExportMemberAssignment(node);
|
||||
}
|
||||
else if (isES6ExportedClass && (node.flags & 512 /* Default */)) {
|
||||
writeLine();
|
||||
write("export default ");
|
||||
emitDeclarationName(node);
|
||||
write(";");
|
||||
}
|
||||
}
|
||||
function emitClassMemberPrefix(node, member) {
|
||||
emitDeclarationName(node);
|
||||
@ -40000,10 +40061,10 @@ var ts;
|
||||
}
|
||||
if (parameters[i].dotDotDotToken) {
|
||||
var parameterType = parameters[i].type;
|
||||
if (parameterType.kind === 160 /* ArrayType */) {
|
||||
if (parameterType && parameterType.kind === 160 /* ArrayType */) {
|
||||
parameterType = parameterType.elementType;
|
||||
}
|
||||
else if (parameterType.kind === 155 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) {
|
||||
else if (parameterType && parameterType.kind === 155 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) {
|
||||
parameterType = parameterType.typeArguments[0];
|
||||
}
|
||||
else {
|
||||
@ -40021,9 +40082,15 @@ var ts;
|
||||
}
|
||||
/** Serializes the return type of function. Used by the __metadata decorator for a method. */
|
||||
function emitSerializedReturnTypeOfNode(node) {
|
||||
if (node && ts.isFunctionLike(node) && node.type) {
|
||||
emitSerializedTypeNode(node.type);
|
||||
return;
|
||||
if (node && ts.isFunctionLike(node)) {
|
||||
if (node.type) {
|
||||
emitSerializedTypeNode(node.type);
|
||||
return;
|
||||
}
|
||||
else if (ts.isAsyncFunctionLike(node)) {
|
||||
write("Promise");
|
||||
return;
|
||||
}
|
||||
}
|
||||
write("void 0");
|
||||
}
|
||||
@ -40162,7 +40229,7 @@ var ts;
|
||||
}
|
||||
}
|
||||
function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) {
|
||||
if (moduleDeclaration.body.kind === 225 /* ModuleDeclaration */) {
|
||||
if (moduleDeclaration.body && moduleDeclaration.body.kind === 225 /* ModuleDeclaration */) {
|
||||
var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body);
|
||||
return recursiveInnerModule || moduleDeclaration.body;
|
||||
}
|
||||
@ -40204,6 +40271,7 @@ var ts;
|
||||
write(getGeneratedNameForNode(node));
|
||||
emitEnd(node.name);
|
||||
write(") ");
|
||||
ts.Debug.assert(node.body !== undefined); // node.body must exist, as this is a non-ambient module
|
||||
if (node.body.kind === 226 /* ModuleBlock */) {
|
||||
var saveConvertedLoopState = convertedLoopState;
|
||||
var saveTempFlags = tempFlags;
|
||||
@ -41998,13 +42066,9 @@ var ts;
|
||||
/* @internal */ ts.ioReadTime = 0;
|
||||
/* @internal */ ts.ioWriteTime = 0;
|
||||
/** The version of the TypeScript compiler release */
|
||||
var emptyArray = [];
|
||||
var defaultLibrarySearchPaths = [
|
||||
"types/",
|
||||
"node_modules/",
|
||||
"node_modules/@types/",
|
||||
];
|
||||
ts.version = "1.9.0";
|
||||
var emptyArray = [];
|
||||
var defaultTypeRoots = ["node_modules/@types"];
|
||||
function findConfigFile(searchPath, fileExists) {
|
||||
while (true) {
|
||||
var fileName = ts.combinePaths(searchPath, "tsconfig.json");
|
||||
@ -42144,6 +42208,10 @@ var ts;
|
||||
return undefined;
|
||||
}
|
||||
var typeReferenceExtensions = [".d.ts"];
|
||||
function getEffectiveTypeRoots(options, host) {
|
||||
return options.typeRoots ||
|
||||
defaultTypeRoots.map(function (d) { return ts.combinePaths(options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : host.getCurrentDirectory(), d); });
|
||||
}
|
||||
/**
|
||||
* @param {string | undefined} containingFile - file that contains type reference directive, can be undefined if containing file is unknown.
|
||||
* This is possible in case if resolution is performed for directives specified via 'types' parameter. In this case initial path for secondary lookups
|
||||
@ -42157,37 +42225,35 @@ var ts;
|
||||
skipTsx: true,
|
||||
traceEnabled: traceEnabled
|
||||
};
|
||||
// use typesRoot and fallback to directory that contains tsconfig or current directory if typesRoot is not set
|
||||
var rootDir = options.typesRoot || (options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : (host.getCurrentDirectory && host.getCurrentDirectory()));
|
||||
var typeRoots = getEffectiveTypeRoots(options, host);
|
||||
if (traceEnabled) {
|
||||
if (containingFile === undefined) {
|
||||
if (rootDir === undefined) {
|
||||
if (typeRoots === undefined) {
|
||||
trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set, typeReferenceDirectiveName);
|
||||
}
|
||||
else {
|
||||
trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1, typeReferenceDirectiveName, rootDir);
|
||||
trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1, typeReferenceDirectiveName, typeRoots);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (rootDir === undefined) {
|
||||
if (typeRoots === undefined) {
|
||||
trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set, typeReferenceDirectiveName, containingFile);
|
||||
}
|
||||
else {
|
||||
trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_2, typeReferenceDirectiveName, containingFile, rootDir);
|
||||
trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_2, typeReferenceDirectiveName, containingFile, typeRoots);
|
||||
}
|
||||
}
|
||||
}
|
||||
var failedLookupLocations = [];
|
||||
// Check primary library paths
|
||||
if (rootDir !== undefined) {
|
||||
var effectivePrimarySearchPaths = options.typesSearchPaths || defaultLibrarySearchPaths;
|
||||
for (var _i = 0, effectivePrimarySearchPaths_1 = effectivePrimarySearchPaths; _i < effectivePrimarySearchPaths_1.length; _i++) {
|
||||
var searchPath = effectivePrimarySearchPaths_1[_i];
|
||||
var primaryPath = ts.combinePaths(rootDir, searchPath);
|
||||
if (traceEnabled) {
|
||||
trace(host, ts.Diagnostics.Resolving_with_primary_search_path_0, primaryPath);
|
||||
}
|
||||
var candidate = ts.combinePaths(primaryPath, typeReferenceDirectiveName);
|
||||
if (typeRoots.length) {
|
||||
if (traceEnabled) {
|
||||
trace(host, ts.Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", "));
|
||||
}
|
||||
var primarySearchPaths = typeRoots;
|
||||
for (var _i = 0, primarySearchPaths_1 = primarySearchPaths; _i < primarySearchPaths_1.length; _i++) {
|
||||
var typeRoot = primarySearchPaths_1[_i];
|
||||
var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName);
|
||||
var candidateDirectory = ts.getDirectoryPath(candidate);
|
||||
var resolvedFile_1 = loadNodeModuleFromDirectory(typeReferenceExtensions, candidate, failedLookupLocations, !directoryProbablyExists(candidateDirectory, host), moduleResolutionState);
|
||||
if (resolvedFile_1) {
|
||||
@ -42211,9 +42277,6 @@ var ts;
|
||||
if (containingFile) {
|
||||
initialLocationForSecondaryLookup = ts.getDirectoryPath(containingFile);
|
||||
}
|
||||
else {
|
||||
initialLocationForSecondaryLookup = rootDir;
|
||||
}
|
||||
if (initialLocationForSecondaryLookup !== undefined) {
|
||||
// check secondary locations
|
||||
if (traceEnabled) {
|
||||
@ -42808,25 +42871,12 @@ var ts;
|
||||
}
|
||||
}
|
||||
}
|
||||
function getDefaultTypeDirectiveNames(rootPath) {
|
||||
var localTypes = ts.combinePaths(rootPath, "types");
|
||||
var npmTypes = ts.combinePaths(rootPath, "node_modules/@types");
|
||||
var result = [];
|
||||
if (ts.sys.directoryExists(localTypes)) {
|
||||
result = result.concat(ts.sys.getDirectories(localTypes));
|
||||
}
|
||||
if (ts.sys.directoryExists(npmTypes)) {
|
||||
result = result.concat(ts.sys.getDirectories(npmTypes));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function getDefaultLibLocation() {
|
||||
return ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath()));
|
||||
}
|
||||
var newLine = ts.getNewLineCharacter(options);
|
||||
var realpath = ts.sys.realpath && (function (path) { return ts.sys.realpath(path); });
|
||||
return {
|
||||
getDefaultTypeDirectiveNames: getDefaultTypeDirectiveNames,
|
||||
getSourceFile: getSourceFile,
|
||||
getDefaultLibLocation: getDefaultLibLocation,
|
||||
getDefaultLibFileName: function (options) { return ts.combinePaths(getDefaultLibLocation(), ts.getDefaultLibFileName(options)); },
|
||||
@ -42839,6 +42889,7 @@ var ts;
|
||||
readFile: function (fileName) { return ts.sys.readFile(fileName); },
|
||||
trace: function (s) { return ts.sys.write(s + newLine); },
|
||||
directoryExists: function (directoryName) { return ts.sys.directoryExists(directoryName); },
|
||||
getDirectories: function (path) { return ts.sys.getDirectories(path); },
|
||||
realpath: realpath
|
||||
};
|
||||
}
|
||||
@ -42894,21 +42945,36 @@ var ts;
|
||||
}
|
||||
return resolutions;
|
||||
}
|
||||
function getDefaultTypeDirectiveNames(options, rootFiles, host) {
|
||||
function getInferredTypesRoot(options, rootFiles, host) {
|
||||
return computeCommonSourceDirectoryOfFilenames(rootFiles, host.getCurrentDirectory(), function (f) { return host.getCanonicalFileName(f); });
|
||||
}
|
||||
/**
|
||||
* Given a set of options and a set of root files, returns the set of type directive names
|
||||
* that should be included for this program automatically.
|
||||
* This list could either come from the config file,
|
||||
* or from enumerating the types root + initial secondary types lookup location.
|
||||
* More type directives might appear in the program later as a result of loading actual source files;
|
||||
* this list is only the set of defaults that are implicitly included.
|
||||
*/
|
||||
function getAutomaticTypeDirectiveNames(options, rootFiles, host) {
|
||||
// Use explicit type list from tsconfig.json
|
||||
if (options.types) {
|
||||
return options.types;
|
||||
}
|
||||
// or load all types from the automatic type import fields
|
||||
if (host && host.getDefaultTypeDirectiveNames) {
|
||||
var commonRoot = computeCommonSourceDirectoryOfFilenames(rootFiles, host.getCurrentDirectory(), function (f) { return host.getCanonicalFileName(f); });
|
||||
if (commonRoot) {
|
||||
return host.getDefaultTypeDirectiveNames(commonRoot);
|
||||
// Walk the primary type lookup locations
|
||||
var result = [];
|
||||
if (host.directoryExists && host.getDirectories) {
|
||||
var typeRoots = getEffectiveTypeRoots(options, host);
|
||||
for (var _i = 0, typeRoots_1 = typeRoots; _i < typeRoots_1.length; _i++) {
|
||||
var root = typeRoots_1[_i];
|
||||
if (host.directoryExists(root)) {
|
||||
result = result.concat(host.getDirectories(root));
|
||||
}
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
return result;
|
||||
}
|
||||
ts.getDefaultTypeDirectiveNames = getDefaultTypeDirectiveNames;
|
||||
ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames;
|
||||
function createProgram(rootNames, options, host, oldProgram) {
|
||||
var program;
|
||||
var files = [];
|
||||
@ -42948,10 +43014,12 @@ var ts;
|
||||
var filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? ts.createFileMap(function (fileName) { return fileName.toLowerCase(); }) : undefined;
|
||||
if (!tryReuseStructureFromOldProgram()) {
|
||||
ts.forEach(rootNames, function (name) { return processRootFile(name, /*isDefaultLib*/ false); });
|
||||
// load type declarations specified via 'types' argument
|
||||
var typeReferences = getDefaultTypeDirectiveNames(options, rootNames, host);
|
||||
// load type declarations specified via 'types' argument or implicitly from types/ and node_modules/@types folders
|
||||
var typeReferences = getAutomaticTypeDirectiveNames(options, rootNames, host);
|
||||
if (typeReferences) {
|
||||
var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, /*containingFile*/ undefined);
|
||||
var inferredRoot = getInferredTypesRoot(options, rootNames, host);
|
||||
var containingFilename = ts.combinePaths(inferredRoot, "__inferred type names__.ts");
|
||||
var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename);
|
||||
for (var i = 0; i < typeReferences.length; i++) {
|
||||
processTypeReferenceDirective(typeReferences[i], resolutions[i]);
|
||||
}
|
||||
@ -43048,10 +43116,9 @@ var ts;
|
||||
(oldOptions.jsx !== options.jsx) ||
|
||||
(oldOptions.allowJs !== options.allowJs) ||
|
||||
(oldOptions.rootDir !== options.rootDir) ||
|
||||
(oldOptions.typesSearchPaths !== options.typesSearchPaths) ||
|
||||
(oldOptions.configFilePath !== options.configFilePath) ||
|
||||
(oldOptions.baseUrl !== options.baseUrl) ||
|
||||
(oldOptions.typesRoot !== options.typesRoot) ||
|
||||
!ts.arrayIsEqualTo(oldOptions.typeRoots, oldOptions.typeRoots) ||
|
||||
!ts.arrayIsEqualTo(oldOptions.rootDirs, options.rootDirs) ||
|
||||
!ts.mapIsEqualTo(oldOptions.paths, options.paths)) {
|
||||
return false;
|
||||
@ -43530,10 +43597,13 @@ var ts;
|
||||
// This type of declaration is permitted only in the global module.
|
||||
// The StringLiteral must specify a top - level external module name.
|
||||
// Relative external module names are not permitted
|
||||
// NOTE: body of ambient module is always a module block
|
||||
for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) {
|
||||
var statement = _a[_i];
|
||||
collectModuleReferences(statement, /*inAmbientModule*/ true);
|
||||
// NOTE: body of ambient module is always a module block, if it exists
|
||||
var body = node.body;
|
||||
if (body) {
|
||||
for (var _i = 0, _a = body.statements; _i < _a.length; _i++) {
|
||||
var statement = _a[_i];
|
||||
collectModuleReferences(statement, /*inAmbientModule*/ true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -43696,7 +43766,7 @@ var ts;
|
||||
}
|
||||
}
|
||||
else {
|
||||
fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Cannot_find_name_0, typeReferenceDirective));
|
||||
fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective));
|
||||
}
|
||||
if (saveResolution) {
|
||||
resolvedTypeReferenceDirectives[typeReferenceDirective] = resolvedTypeReferenceDirective;
|
||||
@ -43868,10 +43938,6 @@ var ts;
|
||||
var span = ts.getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator);
|
||||
programDiagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_use_imports_exports_or_module_augmentations_when_module_is_none));
|
||||
}
|
||||
// Cannot specify module gen target of es6 when below es6
|
||||
if (options.module === ts.ModuleKind.ES6 && languageVersion < 2 /* ES6 */) {
|
||||
programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_es2015_when_targeting_ES5_or_lower));
|
||||
}
|
||||
// Cannot specify module gen that isn't amd or system with --out
|
||||
if (outFile) {
|
||||
if (options.module && !(options.module === ts.ModuleKind.AMD || options.module === ts.ModuleKind.System)) {
|
||||
@ -44278,8 +44344,13 @@ var ts;
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "typesRoot",
|
||||
type: "string"
|
||||
name: "typeRoots",
|
||||
type: "list",
|
||||
element: {
|
||||
name: "typeRoots",
|
||||
type: "string",
|
||||
isFilePath: true
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "types",
|
||||
@ -44418,7 +44489,15 @@ var ts;
|
||||
ts.parseCustomTypeOption = parseCustomTypeOption;
|
||||
/* @internal */
|
||||
function parseListTypeOption(opt, value, errors) {
|
||||
var values = trimString((value || "")).split(",");
|
||||
if (value === void 0) { value = ""; }
|
||||
value = trimString(value);
|
||||
if (ts.startsWith(value, "-")) {
|
||||
return undefined;
|
||||
}
|
||||
if (value === "") {
|
||||
return [];
|
||||
}
|
||||
var values = value.split(",");
|
||||
switch (opt.element.type) {
|
||||
case "number":
|
||||
return ts.map(values, parseInt);
|
||||
@ -44478,8 +44557,11 @@ var ts;
|
||||
i++;
|
||||
break;
|
||||
case "list":
|
||||
options[opt.name] = parseListTypeOption(opt, args[i], errors);
|
||||
i++;
|
||||
var result = parseListTypeOption(opt, args[i], errors);
|
||||
options[opt.name] = result || [];
|
||||
if (result) {
|
||||
i++;
|
||||
}
|
||||
break;
|
||||
// If not a primitive, the possible types are specified in what is effectively a map of options.
|
||||
default:
|
||||
@ -45263,7 +45345,10 @@ var ts;
|
||||
case 225 /* ModuleDeclaration */:
|
||||
var moduleDeclaration = node;
|
||||
topLevelNodes.push(node);
|
||||
addTopLevelNodes(getInnermostModule(moduleDeclaration).body.statements, topLevelNodes);
|
||||
var inner = getInnermostModule(moduleDeclaration);
|
||||
if (inner.body) {
|
||||
addTopLevelNodes(inner.body.statements, topLevelNodes);
|
||||
}
|
||||
break;
|
||||
case 220 /* FunctionDeclaration */:
|
||||
var functionDeclaration = node;
|
||||
@ -45480,7 +45565,8 @@ var ts;
|
||||
return undefined;
|
||||
function createModuleItem(node) {
|
||||
var moduleName = getModuleName(node);
|
||||
var childItems = getItemsWorker(getChildNodes(getInnermostModule(node).body.statements), createChildItem);
|
||||
var body = getInnermostModule(node).body;
|
||||
var childItems = body ? getItemsWorker(getChildNodes(body.statements), createChildItem) : [];
|
||||
return getNavigationBarItem(moduleName, ts.ScriptElementKind.moduleElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node));
|
||||
}
|
||||
function createFunctionItem(node) {
|
||||
@ -45568,7 +45654,7 @@ var ts;
|
||||
return ts.filter(node.members, function (member) { return !ts.hasDynamicName(member); });
|
||||
}
|
||||
function getInnermostModule(node) {
|
||||
while (node.body.kind === 225 /* ModuleDeclaration */) {
|
||||
while (node.body && node.body.kind === 225 /* ModuleDeclaration */) {
|
||||
node = node.body;
|
||||
}
|
||||
return node;
|
||||
@ -50961,7 +51047,7 @@ var ts;
|
||||
addCommentParts(declaration.parent, sourceFileOfDeclaration, getCleanedParamJsDocComment);
|
||||
}
|
||||
// If this is left side of dotted module declaration, there is no doc comments associated with this node
|
||||
if (declaration.kind === 225 /* ModuleDeclaration */ && declaration.body.kind === 225 /* ModuleDeclaration */) {
|
||||
if (declaration.kind === 225 /* ModuleDeclaration */ && declaration.body && declaration.body.kind === 225 /* ModuleDeclaration */) {
|
||||
return;
|
||||
}
|
||||
if ((declaration.kind === 179 /* FunctionExpression */ || declaration.kind === 180 /* ArrowFunction */) &&
|
||||
@ -51797,11 +51883,11 @@ var ts;
|
||||
sourceFile.version = version;
|
||||
sourceFile.scriptSnapshot = scriptSnapshot;
|
||||
}
|
||||
var commandLineOptions_stringToEnum;
|
||||
var commandLineOptionsStringToEnum;
|
||||
/** JS users may pass in string values for enum compiler options (such as ModuleKind), so convert. */
|
||||
function fixupCompilerOptions(options, diagnostics) {
|
||||
// Lazily create this value to fix module loading errors.
|
||||
commandLineOptions_stringToEnum = commandLineOptions_stringToEnum || ts.filter(ts.optionDeclarations, function (o) {
|
||||
commandLineOptionsStringToEnum = commandLineOptionsStringToEnum || ts.filter(ts.optionDeclarations, function (o) {
|
||||
return typeof o.type === "object" && !ts.forEachValue(o.type, function (v) { return typeof v !== "number"; });
|
||||
});
|
||||
options = ts.clone(options);
|
||||
@ -51822,8 +51908,8 @@ var ts;
|
||||
}
|
||||
}
|
||||
};
|
||||
for (var _i = 0, commandLineOptions_stringToEnum_1 = commandLineOptions_stringToEnum; _i < commandLineOptions_stringToEnum_1.length; _i++) {
|
||||
var opt = commandLineOptions_stringToEnum_1[_i];
|
||||
for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) {
|
||||
var opt = commandLineOptionsStringToEnum_1[_i];
|
||||
_loop_2(opt);
|
||||
}
|
||||
return options;
|
||||
@ -51882,7 +51968,8 @@ var ts;
|
||||
getNewLine: function () { return newLine; },
|
||||
fileExists: function (fileName) { return fileName === inputFileName; },
|
||||
readFile: function (fileName) { return ""; },
|
||||
directoryExists: function (directoryExists) { return true; }
|
||||
directoryExists: function (directoryExists) { return true; },
|
||||
getDirectories: function (path) { return []; }
|
||||
};
|
||||
var program = ts.createProgram([inputFileName], options, compilerHost);
|
||||
if (transpileOptions.reportDiagnostics) {
|
||||
@ -51970,7 +52057,7 @@ var ts;
|
||||
var buckets = {};
|
||||
var getCanonicalFileName = ts.createGetCanonicalFileName(!!useCaseSensitiveFileNames);
|
||||
function getKeyForCompilationSettings(settings) {
|
||||
return ("_" + settings.target + "|" + settings.module + "|" + settings.noResolve + "|" + settings.jsx + "|" + settings.allowJs + "|" + settings.baseUrl + "|" + settings.typesRoot + "|" + settings.typesSearchPaths + "|" + JSON.stringify(settings.rootDirs) + "|" + JSON.stringify(settings.paths));
|
||||
return ("_" + settings.target + "|" + settings.module + "|" + settings.noResolve + "|" + settings.jsx + "|" + settings.allowJs + "|" + settings.baseUrl + "|" + JSON.stringify(settings.typeRoots) + "|" + JSON.stringify(settings.rootDirs) + "|" + JSON.stringify(settings.paths));
|
||||
}
|
||||
function getBucketForCompilationSettings(key, createIfMissing) {
|
||||
var bucket = ts.lookUp(buckets, key);
|
||||
@ -52739,8 +52826,10 @@ var ts;
|
||||
return entry && entry.scriptSnapshot.getText(0, entry.scriptSnapshot.getLength());
|
||||
},
|
||||
directoryExists: function (directoryName) {
|
||||
ts.Debug.assert(!host.resolveModuleNames || !host.resolveTypeReferenceDirectives);
|
||||
return ts.directoryProbablyExists(directoryName, host);
|
||||
},
|
||||
getDirectories: function (path) {
|
||||
return host.getDirectories ? host.getDirectories(path) : [];
|
||||
}
|
||||
};
|
||||
if (host.trace) {
|
||||
@ -53716,7 +53805,7 @@ var ts;
|
||||
}
|
||||
if (!uniqueNames[name_41]) {
|
||||
uniqueNames[name_41] = name_41;
|
||||
var displayName = getCompletionEntryDisplayName(name_41, target, /*performCharacterChecks*/ true);
|
||||
var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_41), target, /*performCharacterChecks*/ true);
|
||||
if (displayName) {
|
||||
var entry = {
|
||||
name: displayName,
|
||||
@ -55136,7 +55225,8 @@ var ts;
|
||||
result.push({
|
||||
fileName: entry.fileName,
|
||||
textSpan: highlightSpan.textSpan,
|
||||
isWriteAccess: highlightSpan.kind === HighlightSpanKind.writtenReference
|
||||
isWriteAccess: highlightSpan.kind === HighlightSpanKind.writtenReference,
|
||||
isDefinition: false
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -55486,7 +55576,8 @@ var ts;
|
||||
references: [{
|
||||
fileName: sourceFile.fileName,
|
||||
textSpan: ts.createTextSpan(position, searchText.length),
|
||||
isWriteAccess: false
|
||||
isWriteAccess: false,
|
||||
isDefinition: false
|
||||
}]
|
||||
});
|
||||
}
|
||||
@ -55964,7 +56055,8 @@ var ts;
|
||||
return {
|
||||
fileName: node.getSourceFile().fileName,
|
||||
textSpan: ts.createTextSpanFromBounds(start, end),
|
||||
isWriteAccess: isWriteAccess(node)
|
||||
isWriteAccess: isWriteAccess(node),
|
||||
isDefinition: ts.isDeclarationName(node) || ts.isLiteralComputedPropertyDeclarationName(node)
|
||||
};
|
||||
}
|
||||
/** A node is considered a writeAccess iff it is a name of a declaration or a target of an assignment */
|
||||
@ -58987,4 +59079,6 @@ var TypeScript;
|
||||
// TODO: it should be moved into a namespace though.
|
||||
/* @internal */
|
||||
var toolsVersion = "1.9";
|
||||
/* tslint:enable:no-unused-variable */
|
||||
/* tslint:enable:no-unused-variable */
|
||||
|
||||
//# sourceMappingURL=typescriptServices.js.map
|
||||
|
||||
18
lib/typescriptServices.d.ts
vendored
18
lib/typescriptServices.d.ts
vendored
@ -919,7 +919,7 @@ declare namespace ts {
|
||||
type ModuleBody = ModuleBlock | ModuleDeclaration;
|
||||
interface ModuleDeclaration extends DeclarationStatement {
|
||||
name: Identifier | LiteralExpression;
|
||||
body: ModuleBlock | ModuleDeclaration;
|
||||
body?: ModuleBlock | ModuleDeclaration;
|
||||
}
|
||||
interface ModuleBlock extends Node, Statement {
|
||||
statements: NodeArray<Statement>;
|
||||
@ -1575,6 +1575,8 @@ declare namespace ts {
|
||||
target?: ScriptTarget;
|
||||
traceResolution?: boolean;
|
||||
types?: string[];
|
||||
/** Paths used to used to compute primary types search locations */
|
||||
typeRoots?: string[];
|
||||
typesSearchPaths?: string[];
|
||||
[option: string]: CompilerOptionsValue | undefined;
|
||||
}
|
||||
@ -1672,6 +1674,7 @@ declare namespace ts {
|
||||
getDefaultTypeDirectiveNames?(rootPath: string): string[];
|
||||
writeFile: WriteFileCallback;
|
||||
getCurrentDirectory(): string;
|
||||
getDirectories(path: string): string[];
|
||||
getCanonicalFileName(fileName: string): string;
|
||||
useCaseSensitiveFileNames(): boolean;
|
||||
getNewLine(): string;
|
||||
@ -1821,6 +1824,7 @@ declare namespace ts {
|
||||
function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile;
|
||||
}
|
||||
declare namespace ts {
|
||||
/** The version of the TypeScript compiler release */
|
||||
const version: string;
|
||||
function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean): string;
|
||||
function resolveTripleslashReference(moduleName: string, containingFile: string): string;
|
||||
@ -1836,7 +1840,15 @@ declare namespace ts {
|
||||
function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost;
|
||||
function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[];
|
||||
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
|
||||
function getDefaultTypeDirectiveNames(options: CompilerOptions, rootFiles: string[], host: CompilerHost): string[];
|
||||
/**
|
||||
* Given a set of options and a set of root files, returns the set of type directive names
|
||||
* that should be included for this program automatically.
|
||||
* This list could either come from the config file,
|
||||
* or from enumerating the types root + initial secondary types lookup location.
|
||||
* More type directives might appear in the program later as a result of loading actual source files;
|
||||
* this list is only the set of defaults that are implicitly included.
|
||||
*/
|
||||
function getAutomaticTypeDirectiveNames(options: CompilerOptions, rootFiles: string[], host: CompilerHost): string[];
|
||||
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program;
|
||||
}
|
||||
declare namespace ts {
|
||||
@ -1978,6 +1990,7 @@ declare namespace ts {
|
||||
resolveModuleNames?(moduleNames: string[], containingFile: string): ResolvedModule[];
|
||||
resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[];
|
||||
directoryExists?(directoryName: string): boolean;
|
||||
getDirectories?(directoryName: string): string[];
|
||||
}
|
||||
interface LanguageService {
|
||||
cleanupSemanticCache(): void;
|
||||
@ -2068,6 +2081,7 @@ declare namespace ts {
|
||||
textSpan: TextSpan;
|
||||
fileName: string;
|
||||
isWriteAccess: boolean;
|
||||
isDefinition: boolean;
|
||||
}
|
||||
interface DocumentHighlights {
|
||||
fileName: string;
|
||||
|
||||
@ -1,18 +1,3 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
@ -2425,7 +2410,6 @@ var ts;
|
||||
Line_terminator_not_permitted_before_arrow: { code: 1200, category: ts.DiagnosticCategory.Error, key: "Line_terminator_not_permitted_before_arrow_1200", message: "Line terminator not permitted before arrow." },
|
||||
Import_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: { code: 1202, category: ts.DiagnosticCategory.Error, key: "Import_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_import_Asteri_1202", message: "Import assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead." },
|
||||
Export_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_export_default_or_another_module_format_instead: { code: 1203, category: ts.DiagnosticCategory.Error, key: "Export_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_export_defaul_1203", message: "Export assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'export default' or another module format instead." },
|
||||
Cannot_compile_modules_into_es2015_when_targeting_ES5_or_lower: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_modules_into_es2015_when_targeting_ES5_or_lower_1204", message: "Cannot compile modules into 'es2015' when targeting 'ES5' or lower." },
|
||||
Decorators_are_not_valid_here: { code: 1206, category: ts.DiagnosticCategory.Error, key: "Decorators_are_not_valid_here_1206", message: "Decorators are not valid here." },
|
||||
Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { code: 1207, category: ts.DiagnosticCategory.Error, key: "Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name_1207", message: "Decorators cannot be applied to multiple get/set accessors of the same name." },
|
||||
Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided: { code: 1208, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided_1208", message: "Cannot compile namespaces when the '--isolatedModules' flag is provided." },
|
||||
@ -2750,6 +2734,7 @@ var ts;
|
||||
The_this_types_of_each_signature_are_incompatible: { code: 2685, category: ts.DiagnosticCategory.Error, key: "The_this_types_of_each_signature_are_incompatible_2685", message: "The 'this' types of each signature are incompatible." },
|
||||
Identifier_0_must_be_imported_from_a_module: { code: 2686, category: ts.DiagnosticCategory.Error, key: "Identifier_0_must_be_imported_from_a_module_2686", message: "Identifier '{0}' must be imported from a module" },
|
||||
All_declarations_of_0_must_have_identical_modifiers: { code: 2687, category: ts.DiagnosticCategory.Error, key: "All_declarations_of_0_must_have_identical_modifiers_2687", message: "All declarations of '{0}' must have identical modifiers." },
|
||||
Cannot_find_type_definition_file_for_0: { code: 2688, category: ts.DiagnosticCategory.Error, key: "Cannot_find_type_definition_file_for_0_2688", message: "Cannot find type definition file for '{0}'." },
|
||||
Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import_declaration_0_is_using_private_name_1_4000", message: "Import declaration '{0}' is using private name '{1}'." },
|
||||
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", message: "Type parameter '{0}' of exported class has or is using private name '{1}'." },
|
||||
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", message: "Type parameter '{0}' of exported interface has or is using private name '{1}'." },
|
||||
@ -4985,6 +4970,11 @@ var ts;
|
||||
(node.name.kind === 9 /* StringLiteral */ || isGlobalScopeAugmentation(node));
|
||||
}
|
||||
ts.isAmbientModule = isAmbientModule;
|
||||
function isShorthandAmbientModule(node) {
|
||||
// The only kind of module that can be missing a body is a shorthand ambient module.
|
||||
return node.kind === 225 /* ModuleDeclaration */ && (!node.body);
|
||||
}
|
||||
ts.isShorthandAmbientModule = isShorthandAmbientModule;
|
||||
function isBlockScopedContainerTopLevel(node) {
|
||||
return node.kind === 256 /* SourceFile */ ||
|
||||
node.kind === 225 /* ModuleDeclaration */ ||
|
||||
@ -5417,6 +5407,7 @@ var ts;
|
||||
case 157 /* ConstructorType */:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
ts.isFunctionLikeKind = isFunctionLikeKind;
|
||||
function introducesArgumentsExoticObject(node) {
|
||||
@ -5839,6 +5830,18 @@ var ts;
|
||||
return charCode === 39 /* singleQuote */ || charCode === 34 /* doubleQuote */;
|
||||
}
|
||||
ts.isSingleOrDoubleQuote = isSingleOrDoubleQuote;
|
||||
/**
|
||||
* Returns true if the node is a variable declaration whose initializer is a function expression.
|
||||
* This function does not test if the node is in a JavaScript file or not.
|
||||
*/
|
||||
function isDeclarationOfFunctionExpression(s) {
|
||||
if (s.valueDeclaration && s.valueDeclaration.kind === 218 /* VariableDeclaration */) {
|
||||
var declaration = s.valueDeclaration;
|
||||
return declaration.initializer && declaration.initializer.kind === 179 /* FunctionExpression */;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
ts.isDeclarationOfFunctionExpression = isDeclarationOfFunctionExpression;
|
||||
/// Given a BinaryExpression, returns SpecialPropertyAssignmentKind for the various kinds of property
|
||||
/// assignments we treat as special in the binder
|
||||
function getSpecialPropertyAssignmentKind(expression) {
|
||||
@ -12250,7 +12253,12 @@ var ts;
|
||||
else {
|
||||
node.name = parseLiteralNode(/*internName*/ true);
|
||||
}
|
||||
node.body = parseModuleBlock();
|
||||
if (token === 15 /* OpenBraceToken */) {
|
||||
node.body = parseModuleBlock();
|
||||
}
|
||||
else {
|
||||
parseSemicolon();
|
||||
}
|
||||
return finishNode(node);
|
||||
}
|
||||
function parseModuleDeclaration(fullStart, decorators, modifiers) {
|
||||
@ -13752,7 +13760,8 @@ var ts;
|
||||
return state_1;
|
||||
}
|
||||
else if (node.kind === 225 /* ModuleDeclaration */) {
|
||||
return getModuleInstanceState(node.body);
|
||||
var body = node.body;
|
||||
return body ? getModuleInstanceState(body) : 1 /* Instantiated */;
|
||||
}
|
||||
else {
|
||||
return 1 /* Instantiated */;
|
||||
@ -14262,10 +14271,11 @@ var ts;
|
||||
case 31 /* ExclamationEqualsToken */:
|
||||
case 32 /* EqualsEqualsEqualsToken */:
|
||||
case 33 /* ExclamationEqualsEqualsToken */:
|
||||
if (isNarrowingExpression(expr.left) && (expr.right.kind === 93 /* NullKeyword */ || expr.right.kind === 69 /* Identifier */)) {
|
||||
if ((isNarrowingExpression(expr.left) && (expr.right.kind === 93 /* NullKeyword */ || expr.right.kind === 69 /* Identifier */)) ||
|
||||
(isNarrowingExpression(expr.right) && (expr.left.kind === 93 /* NullKeyword */ || expr.left.kind === 69 /* Identifier */))) {
|
||||
return true;
|
||||
}
|
||||
if (expr.left.kind === 182 /* TypeOfExpression */ && isNarrowingExpression(expr.left.expression) && expr.right.kind === 9 /* StringLiteral */) {
|
||||
if (isTypeOfNarrowingBinaryExpression(expr)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -14276,6 +14286,19 @@ var ts;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function isTypeOfNarrowingBinaryExpression(expr) {
|
||||
var typeOf;
|
||||
if (expr.left.kind === 9 /* StringLiteral */) {
|
||||
typeOf = expr.right;
|
||||
}
|
||||
else if (expr.right.kind === 9 /* StringLiteral */) {
|
||||
typeOf = expr.left;
|
||||
}
|
||||
else {
|
||||
typeOf = undefined;
|
||||
}
|
||||
return typeOf && typeOf.kind === 182 /* TypeOfExpression */ && isNarrowingExpression(typeOf.expression);
|
||||
}
|
||||
function createBranchLabel() {
|
||||
return {
|
||||
flags: 4 /* BranchLabel */,
|
||||
@ -14855,7 +14878,7 @@ var ts;
|
||||
}
|
||||
function hasExportDeclarations(node) {
|
||||
var body = node.kind === 256 /* SourceFile */ ? node : node.body;
|
||||
if (body.kind === 256 /* SourceFile */ || body.kind === 226 /* ModuleBlock */) {
|
||||
if (body && (body.kind === 256 /* SourceFile */ || body.kind === 226 /* ModuleBlock */)) {
|
||||
for (var _i = 0, _a = body.statements; _i < _a.length; _i++) {
|
||||
var stat = _a[_i];
|
||||
if (stat.kind === 236 /* ExportDeclaration */ || stat.kind === 235 /* ExportAssignment */) {
|
||||
@ -15471,7 +15494,7 @@ var ts;
|
||||
constructorFunction.parent = classPrototype;
|
||||
classPrototype.parent = leftSideOfAssignment;
|
||||
var funcSymbol = container.locals[constructorFunction.text];
|
||||
if (!funcSymbol || !(funcSymbol.flags & 16 /* Function */)) {
|
||||
if (!funcSymbol || !(funcSymbol.flags & 16 /* Function */ || ts.isDeclarationOfFunctionExpression(funcSymbol))) {
|
||||
return;
|
||||
}
|
||||
// Set up the members collection if it doesn't exist already
|
||||
@ -16579,9 +16602,11 @@ var ts;
|
||||
function getTargetOfImportClause(node) {
|
||||
var moduleSymbol = resolveExternalModuleName(node, node.parent.moduleSpecifier);
|
||||
if (moduleSymbol) {
|
||||
var exportDefaultSymbol = moduleSymbol.exports["export="] ?
|
||||
getPropertyOfType(getTypeOfSymbol(moduleSymbol.exports["export="]), "default") :
|
||||
resolveSymbol(moduleSymbol.exports["default"]);
|
||||
var exportDefaultSymbol = ts.isShorthandAmbientModule(moduleSymbol.valueDeclaration) ?
|
||||
moduleSymbol :
|
||||
moduleSymbol.exports["export="] ?
|
||||
getPropertyOfType(getTypeOfSymbol(moduleSymbol.exports["export="]), "default") :
|
||||
resolveSymbol(moduleSymbol.exports["default"]);
|
||||
if (!exportDefaultSymbol && !allowSyntheticDefaultImports) {
|
||||
error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol));
|
||||
}
|
||||
@ -16650,6 +16675,9 @@ var ts;
|
||||
if (targetSymbol) {
|
||||
var name_10 = specifier.propertyName || specifier.name;
|
||||
if (name_10.text) {
|
||||
if (ts.isShorthandAmbientModule(moduleSymbol.valueDeclaration)) {
|
||||
return moduleSymbol;
|
||||
}
|
||||
var symbolFromVariable = void 0;
|
||||
// First check if module was specified with "export=". If so, get the member from the resolved type
|
||||
if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports["export="]) {
|
||||
@ -18600,9 +18628,14 @@ var ts;
|
||||
function getTypeOfFuncClassEnumModule(symbol) {
|
||||
var links = getSymbolLinks(symbol);
|
||||
if (!links.type) {
|
||||
var type = createObjectType(65536 /* Anonymous */, symbol);
|
||||
links.type = strictNullChecks && symbol.flags & 536870912 /* Optional */ ?
|
||||
addTypeKind(type, 32 /* Undefined */) : type;
|
||||
if (symbol.valueDeclaration.kind === 225 /* ModuleDeclaration */ && ts.isShorthandAmbientModule(symbol.valueDeclaration)) {
|
||||
links.type = anyType;
|
||||
}
|
||||
else {
|
||||
var type = createObjectType(65536 /* Anonymous */, symbol);
|
||||
links.type = strictNullChecks && symbol.flags & 536870912 /* Optional */ ?
|
||||
addTypeKind(type, 32 /* Undefined */) : type;
|
||||
}
|
||||
}
|
||||
return links.type;
|
||||
}
|
||||
@ -22903,10 +22936,11 @@ var ts;
|
||||
case 31 /* ExclamationEqualsToken */:
|
||||
case 32 /* EqualsEqualsEqualsToken */:
|
||||
case 33 /* ExclamationEqualsEqualsToken */:
|
||||
if (isNullOrUndefinedLiteral(expr.right)) {
|
||||
if (isNullOrUndefinedLiteral(expr.left) || isNullOrUndefinedLiteral(expr.right)) {
|
||||
return narrowTypeByNullCheck(type, expr, assumeTrue);
|
||||
}
|
||||
if (expr.left.kind === 182 /* TypeOfExpression */ && expr.right.kind === 9 /* StringLiteral */) {
|
||||
if (expr.left.kind === 182 /* TypeOfExpression */ && expr.right.kind === 9 /* StringLiteral */ ||
|
||||
expr.left.kind === 9 /* StringLiteral */ && expr.right.kind === 182 /* TypeOfExpression */) {
|
||||
return narrowTypeByTypeof(type, expr, assumeTrue);
|
||||
}
|
||||
break;
|
||||
@ -22918,18 +22952,20 @@ var ts;
|
||||
return type;
|
||||
}
|
||||
function narrowTypeByNullCheck(type, expr, assumeTrue) {
|
||||
// We have '==', '!=', '===', or '!==' operator with 'null' or 'undefined' on the right
|
||||
// We have '==', '!=', '===', or '!==' operator with 'null' or 'undefined' on one side
|
||||
var operator = expr.operatorToken.kind;
|
||||
var nullLike = isNullOrUndefinedLiteral(expr.left) ? expr.left : expr.right;
|
||||
var narrowed = isNullOrUndefinedLiteral(expr.left) ? expr.right : expr.left;
|
||||
if (operator === 31 /* ExclamationEqualsToken */ || operator === 33 /* ExclamationEqualsEqualsToken */) {
|
||||
assumeTrue = !assumeTrue;
|
||||
}
|
||||
if (!strictNullChecks || !isMatchingReference(reference, getReferenceFromExpression(expr.left))) {
|
||||
if (!strictNullChecks || !isMatchingReference(reference, getReferenceFromExpression(narrowed))) {
|
||||
return type;
|
||||
}
|
||||
var doubleEquals = operator === 30 /* EqualsEqualsToken */ || operator === 31 /* ExclamationEqualsToken */;
|
||||
var facts = doubleEquals ?
|
||||
assumeTrue ? 65536 /* EQUndefinedOrNull */ : 524288 /* NEUndefinedOrNull */ :
|
||||
expr.right.kind === 93 /* NullKeyword */ ?
|
||||
nullLike.kind === 93 /* NullKeyword */ ?
|
||||
assumeTrue ? 32768 /* EQNull */ : 262144 /* NENull */ :
|
||||
assumeTrue ? 16384 /* EQUndefined */ : 131072 /* NEUndefined */;
|
||||
return getTypeWithFacts(type, facts);
|
||||
@ -22937,12 +22973,12 @@ var ts;
|
||||
function narrowTypeByTypeof(type, expr, assumeTrue) {
|
||||
// We have '==', '!=', '====', or !==' operator with 'typeof xxx' on the left
|
||||
// and string literal on the right
|
||||
var left = getReferenceFromExpression(expr.left.expression);
|
||||
var right = expr.right;
|
||||
if (!isMatchingReference(reference, left)) {
|
||||
var narrowed = getReferenceFromExpression((expr.left.kind === 182 /* TypeOfExpression */ ? expr.left : expr.right).expression);
|
||||
var literal = (expr.right.kind === 9 /* StringLiteral */ ? expr.right : expr.left);
|
||||
if (!isMatchingReference(reference, narrowed)) {
|
||||
// For a reference of the form 'x.y', a 'typeof x === ...' type guard resets the
|
||||
// narrowed type of 'y' to its declared type.
|
||||
if (containsMatchingReference(reference, left)) {
|
||||
if (containsMatchingReference(reference, narrowed)) {
|
||||
return declaredType;
|
||||
}
|
||||
return type;
|
||||
@ -22955,14 +22991,14 @@ var ts;
|
||||
// We narrow a non-union type to an exact primitive type if the non-union type
|
||||
// is a supertype of that primtive type. For example, type 'any' can be narrowed
|
||||
// to one of the primitive types.
|
||||
var targetType = ts.getProperty(typeofTypesByName, right.text);
|
||||
var targetType = ts.getProperty(typeofTypesByName, literal.text);
|
||||
if (targetType && isTypeSubtypeOf(targetType, type)) {
|
||||
return targetType;
|
||||
}
|
||||
}
|
||||
var facts = assumeTrue ?
|
||||
ts.getProperty(typeofEQFacts, right.text) || 64 /* TypeofEQHostObject */ :
|
||||
ts.getProperty(typeofNEFacts, right.text) || 8192 /* TypeofNEHostObject */;
|
||||
ts.getProperty(typeofEQFacts, literal.text) || 64 /* TypeofEQHostObject */ :
|
||||
ts.getProperty(typeofNEFacts, literal.text) || 8192 /* TypeofNEHostObject */;
|
||||
return getTypeWithFacts(type, facts);
|
||||
}
|
||||
function narrowTypeByInstanceof(type, expr, assumeTrue) {
|
||||
@ -26126,8 +26162,12 @@ var ts;
|
||||
// When resolved signature is a call signature (and not a construct signature) the result type is any, unless
|
||||
// the declaring function had members created through 'x.prototype.y = expr' or 'this.y = expr' psuedodeclarations
|
||||
// in a JS file
|
||||
var funcSymbol = checkExpression(node.expression).symbol;
|
||||
if (funcSymbol && funcSymbol.members && (funcSymbol.flags & 16 /* Function */)) {
|
||||
// Note:JS inferred classes might come from a variable declaration instead of a function declaration.
|
||||
// In this case, using getResolvedSymbol directly is required to avoid losing the members from the declaration.
|
||||
var funcSymbol = node.expression.kind === 69 /* Identifier */ ?
|
||||
getResolvedSymbol(node.expression) :
|
||||
checkExpression(node.expression).symbol;
|
||||
if (funcSymbol && funcSymbol.members && (funcSymbol.flags & 16 /* Function */ || ts.isDeclarationOfFunctionExpression(funcSymbol))) {
|
||||
return getInferredClassType(funcSymbol);
|
||||
}
|
||||
else if (compilerOptions.noImplicitAny) {
|
||||
@ -30189,7 +30229,7 @@ var ts;
|
||||
// - augmentation for a global scope is always applied
|
||||
// - augmentation for some external module is applied if symbol for augmentation is merged (it was combined with target module).
|
||||
var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 33554432 /* Merged */);
|
||||
if (checkBody) {
|
||||
if (checkBody && node.body) {
|
||||
// body of ambient external module is always a module block
|
||||
for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) {
|
||||
var statement = _a[_i];
|
||||
@ -30217,7 +30257,13 @@ var ts;
|
||||
}
|
||||
}
|
||||
}
|
||||
checkSourceElement(node.body);
|
||||
if (compilerOptions.noImplicitAny && !node.body) {
|
||||
// Ambient shorthand module is an implicit any
|
||||
reportImplicitAnyError(node, anyType);
|
||||
}
|
||||
if (node.body) {
|
||||
checkSourceElement(node.body);
|
||||
}
|
||||
}
|
||||
function checkModuleAugmentationElement(node, isGlobalAugmentation) {
|
||||
switch (node.kind) {
|
||||
@ -33812,21 +33858,26 @@ var ts;
|
||||
writeTextOfNode(currentText, node.name);
|
||||
}
|
||||
}
|
||||
while (node.body.kind !== 226 /* ModuleBlock */) {
|
||||
while (node.body && node.body.kind !== 226 /* ModuleBlock */) {
|
||||
node = node.body;
|
||||
write(".");
|
||||
writeTextOfNode(currentText, node.name);
|
||||
}
|
||||
var prevEnclosingDeclaration = enclosingDeclaration;
|
||||
enclosingDeclaration = node;
|
||||
write(" {");
|
||||
writeLine();
|
||||
increaseIndent();
|
||||
emitLines(node.body.statements);
|
||||
decreaseIndent();
|
||||
write("}");
|
||||
writeLine();
|
||||
enclosingDeclaration = prevEnclosingDeclaration;
|
||||
if (node.body) {
|
||||
enclosingDeclaration = node;
|
||||
write(" {");
|
||||
writeLine();
|
||||
increaseIndent();
|
||||
emitLines(node.body.statements);
|
||||
decreaseIndent();
|
||||
write("}");
|
||||
writeLine();
|
||||
enclosingDeclaration = prevEnclosingDeclaration;
|
||||
}
|
||||
else {
|
||||
write(";");
|
||||
}
|
||||
}
|
||||
function writeTypeAliasDeclaration(node) {
|
||||
var prevEnclosingDeclaration = enclosingDeclaration;
|
||||
@ -36457,9 +36508,9 @@ var ts;
|
||||
emit(node.initializer);
|
||||
}
|
||||
// Return true if identifier resolves to an exported member of a namespace
|
||||
function isNamespaceExportReference(node) {
|
||||
function isExportReference(node) {
|
||||
var container = resolver.getReferencedExportContainer(node);
|
||||
return container && container.kind !== 256 /* SourceFile */;
|
||||
return !!container;
|
||||
}
|
||||
// Return true if identifier resolves to an imported identifier
|
||||
function isImportedReference(node) {
|
||||
@ -36490,10 +36541,10 @@ var ts;
|
||||
// const foo_1 = require('./foo');
|
||||
// exports.baz = { foo: foo_1.foo };
|
||||
//
|
||||
if (languageVersion < 2 /* ES6 */ || (modulekind !== ts.ModuleKind.ES6 && isImportedReference(node.name)) || isNamespaceExportReference(node.name)) {
|
||||
if (languageVersion < 2 /* ES6 */ || (modulekind !== ts.ModuleKind.ES6 && isImportedReference(node.name)) || isExportReference(node.name)) {
|
||||
// Emit identifier as an identifier
|
||||
write(": ");
|
||||
emit(node.name);
|
||||
emitExpressionIdentifier(node.name);
|
||||
}
|
||||
if (languageVersion >= 2 /* ES6 */ && node.objectAssignmentInitializer) {
|
||||
write(" = ");
|
||||
@ -39556,7 +39607,11 @@ var ts;
|
||||
}
|
||||
}
|
||||
function emitClassLikeDeclarationBelowES6(node) {
|
||||
var isES6ExportedClass = isES6ExportedDeclaration(node);
|
||||
if (node.kind === 221 /* ClassDeclaration */) {
|
||||
if (isES6ExportedClass && !(node.flags & 512 /* Default */)) {
|
||||
write("export ");
|
||||
}
|
||||
// source file level classes in system modules are hoisted so 'var's for them are already defined
|
||||
if (!shouldHoistDeclarationInSystemJsModule(node)) {
|
||||
write("var ");
|
||||
@ -39621,9 +39676,15 @@ var ts;
|
||||
write(";");
|
||||
}
|
||||
emitEnd(node);
|
||||
if (node.kind === 221 /* ClassDeclaration */) {
|
||||
if (node.kind === 221 /* ClassDeclaration */ && !isES6ExportedClass) {
|
||||
emitExportMemberAssignment(node);
|
||||
}
|
||||
else if (isES6ExportedClass && (node.flags & 512 /* Default */)) {
|
||||
writeLine();
|
||||
write("export default ");
|
||||
emitDeclarationName(node);
|
||||
write(";");
|
||||
}
|
||||
}
|
||||
function emitClassMemberPrefix(node, member) {
|
||||
emitDeclarationName(node);
|
||||
@ -40000,10 +40061,10 @@ var ts;
|
||||
}
|
||||
if (parameters[i].dotDotDotToken) {
|
||||
var parameterType = parameters[i].type;
|
||||
if (parameterType.kind === 160 /* ArrayType */) {
|
||||
if (parameterType && parameterType.kind === 160 /* ArrayType */) {
|
||||
parameterType = parameterType.elementType;
|
||||
}
|
||||
else if (parameterType.kind === 155 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) {
|
||||
else if (parameterType && parameterType.kind === 155 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) {
|
||||
parameterType = parameterType.typeArguments[0];
|
||||
}
|
||||
else {
|
||||
@ -40021,9 +40082,15 @@ var ts;
|
||||
}
|
||||
/** Serializes the return type of function. Used by the __metadata decorator for a method. */
|
||||
function emitSerializedReturnTypeOfNode(node) {
|
||||
if (node && ts.isFunctionLike(node) && node.type) {
|
||||
emitSerializedTypeNode(node.type);
|
||||
return;
|
||||
if (node && ts.isFunctionLike(node)) {
|
||||
if (node.type) {
|
||||
emitSerializedTypeNode(node.type);
|
||||
return;
|
||||
}
|
||||
else if (ts.isAsyncFunctionLike(node)) {
|
||||
write("Promise");
|
||||
return;
|
||||
}
|
||||
}
|
||||
write("void 0");
|
||||
}
|
||||
@ -40162,7 +40229,7 @@ var ts;
|
||||
}
|
||||
}
|
||||
function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) {
|
||||
if (moduleDeclaration.body.kind === 225 /* ModuleDeclaration */) {
|
||||
if (moduleDeclaration.body && moduleDeclaration.body.kind === 225 /* ModuleDeclaration */) {
|
||||
var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body);
|
||||
return recursiveInnerModule || moduleDeclaration.body;
|
||||
}
|
||||
@ -40204,6 +40271,7 @@ var ts;
|
||||
write(getGeneratedNameForNode(node));
|
||||
emitEnd(node.name);
|
||||
write(") ");
|
||||
ts.Debug.assert(node.body !== undefined); // node.body must exist, as this is a non-ambient module
|
||||
if (node.body.kind === 226 /* ModuleBlock */) {
|
||||
var saveConvertedLoopState = convertedLoopState;
|
||||
var saveTempFlags = tempFlags;
|
||||
@ -41998,13 +42066,9 @@ var ts;
|
||||
/* @internal */ ts.ioReadTime = 0;
|
||||
/* @internal */ ts.ioWriteTime = 0;
|
||||
/** The version of the TypeScript compiler release */
|
||||
var emptyArray = [];
|
||||
var defaultLibrarySearchPaths = [
|
||||
"types/",
|
||||
"node_modules/",
|
||||
"node_modules/@types/",
|
||||
];
|
||||
ts.version = "1.9.0";
|
||||
var emptyArray = [];
|
||||
var defaultTypeRoots = ["node_modules/@types"];
|
||||
function findConfigFile(searchPath, fileExists) {
|
||||
while (true) {
|
||||
var fileName = ts.combinePaths(searchPath, "tsconfig.json");
|
||||
@ -42144,6 +42208,10 @@ var ts;
|
||||
return undefined;
|
||||
}
|
||||
var typeReferenceExtensions = [".d.ts"];
|
||||
function getEffectiveTypeRoots(options, host) {
|
||||
return options.typeRoots ||
|
||||
defaultTypeRoots.map(function (d) { return ts.combinePaths(options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : host.getCurrentDirectory(), d); });
|
||||
}
|
||||
/**
|
||||
* @param {string | undefined} containingFile - file that contains type reference directive, can be undefined if containing file is unknown.
|
||||
* This is possible in case if resolution is performed for directives specified via 'types' parameter. In this case initial path for secondary lookups
|
||||
@ -42157,37 +42225,35 @@ var ts;
|
||||
skipTsx: true,
|
||||
traceEnabled: traceEnabled
|
||||
};
|
||||
// use typesRoot and fallback to directory that contains tsconfig or current directory if typesRoot is not set
|
||||
var rootDir = options.typesRoot || (options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : (host.getCurrentDirectory && host.getCurrentDirectory()));
|
||||
var typeRoots = getEffectiveTypeRoots(options, host);
|
||||
if (traceEnabled) {
|
||||
if (containingFile === undefined) {
|
||||
if (rootDir === undefined) {
|
||||
if (typeRoots === undefined) {
|
||||
trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set, typeReferenceDirectiveName);
|
||||
}
|
||||
else {
|
||||
trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1, typeReferenceDirectiveName, rootDir);
|
||||
trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1, typeReferenceDirectiveName, typeRoots);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (rootDir === undefined) {
|
||||
if (typeRoots === undefined) {
|
||||
trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set, typeReferenceDirectiveName, containingFile);
|
||||
}
|
||||
else {
|
||||
trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_2, typeReferenceDirectiveName, containingFile, rootDir);
|
||||
trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_2, typeReferenceDirectiveName, containingFile, typeRoots);
|
||||
}
|
||||
}
|
||||
}
|
||||
var failedLookupLocations = [];
|
||||
// Check primary library paths
|
||||
if (rootDir !== undefined) {
|
||||
var effectivePrimarySearchPaths = options.typesSearchPaths || defaultLibrarySearchPaths;
|
||||
for (var _i = 0, effectivePrimarySearchPaths_1 = effectivePrimarySearchPaths; _i < effectivePrimarySearchPaths_1.length; _i++) {
|
||||
var searchPath = effectivePrimarySearchPaths_1[_i];
|
||||
var primaryPath = ts.combinePaths(rootDir, searchPath);
|
||||
if (traceEnabled) {
|
||||
trace(host, ts.Diagnostics.Resolving_with_primary_search_path_0, primaryPath);
|
||||
}
|
||||
var candidate = ts.combinePaths(primaryPath, typeReferenceDirectiveName);
|
||||
if (typeRoots.length) {
|
||||
if (traceEnabled) {
|
||||
trace(host, ts.Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", "));
|
||||
}
|
||||
var primarySearchPaths = typeRoots;
|
||||
for (var _i = 0, primarySearchPaths_1 = primarySearchPaths; _i < primarySearchPaths_1.length; _i++) {
|
||||
var typeRoot = primarySearchPaths_1[_i];
|
||||
var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName);
|
||||
var candidateDirectory = ts.getDirectoryPath(candidate);
|
||||
var resolvedFile_1 = loadNodeModuleFromDirectory(typeReferenceExtensions, candidate, failedLookupLocations, !directoryProbablyExists(candidateDirectory, host), moduleResolutionState);
|
||||
if (resolvedFile_1) {
|
||||
@ -42211,9 +42277,6 @@ var ts;
|
||||
if (containingFile) {
|
||||
initialLocationForSecondaryLookup = ts.getDirectoryPath(containingFile);
|
||||
}
|
||||
else {
|
||||
initialLocationForSecondaryLookup = rootDir;
|
||||
}
|
||||
if (initialLocationForSecondaryLookup !== undefined) {
|
||||
// check secondary locations
|
||||
if (traceEnabled) {
|
||||
@ -42808,25 +42871,12 @@ var ts;
|
||||
}
|
||||
}
|
||||
}
|
||||
function getDefaultTypeDirectiveNames(rootPath) {
|
||||
var localTypes = ts.combinePaths(rootPath, "types");
|
||||
var npmTypes = ts.combinePaths(rootPath, "node_modules/@types");
|
||||
var result = [];
|
||||
if (ts.sys.directoryExists(localTypes)) {
|
||||
result = result.concat(ts.sys.getDirectories(localTypes));
|
||||
}
|
||||
if (ts.sys.directoryExists(npmTypes)) {
|
||||
result = result.concat(ts.sys.getDirectories(npmTypes));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function getDefaultLibLocation() {
|
||||
return ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath()));
|
||||
}
|
||||
var newLine = ts.getNewLineCharacter(options);
|
||||
var realpath = ts.sys.realpath && (function (path) { return ts.sys.realpath(path); });
|
||||
return {
|
||||
getDefaultTypeDirectiveNames: getDefaultTypeDirectiveNames,
|
||||
getSourceFile: getSourceFile,
|
||||
getDefaultLibLocation: getDefaultLibLocation,
|
||||
getDefaultLibFileName: function (options) { return ts.combinePaths(getDefaultLibLocation(), ts.getDefaultLibFileName(options)); },
|
||||
@ -42839,6 +42889,7 @@ var ts;
|
||||
readFile: function (fileName) { return ts.sys.readFile(fileName); },
|
||||
trace: function (s) { return ts.sys.write(s + newLine); },
|
||||
directoryExists: function (directoryName) { return ts.sys.directoryExists(directoryName); },
|
||||
getDirectories: function (path) { return ts.sys.getDirectories(path); },
|
||||
realpath: realpath
|
||||
};
|
||||
}
|
||||
@ -42894,21 +42945,36 @@ var ts;
|
||||
}
|
||||
return resolutions;
|
||||
}
|
||||
function getDefaultTypeDirectiveNames(options, rootFiles, host) {
|
||||
function getInferredTypesRoot(options, rootFiles, host) {
|
||||
return computeCommonSourceDirectoryOfFilenames(rootFiles, host.getCurrentDirectory(), function (f) { return host.getCanonicalFileName(f); });
|
||||
}
|
||||
/**
|
||||
* Given a set of options and a set of root files, returns the set of type directive names
|
||||
* that should be included for this program automatically.
|
||||
* This list could either come from the config file,
|
||||
* or from enumerating the types root + initial secondary types lookup location.
|
||||
* More type directives might appear in the program later as a result of loading actual source files;
|
||||
* this list is only the set of defaults that are implicitly included.
|
||||
*/
|
||||
function getAutomaticTypeDirectiveNames(options, rootFiles, host) {
|
||||
// Use explicit type list from tsconfig.json
|
||||
if (options.types) {
|
||||
return options.types;
|
||||
}
|
||||
// or load all types from the automatic type import fields
|
||||
if (host && host.getDefaultTypeDirectiveNames) {
|
||||
var commonRoot = computeCommonSourceDirectoryOfFilenames(rootFiles, host.getCurrentDirectory(), function (f) { return host.getCanonicalFileName(f); });
|
||||
if (commonRoot) {
|
||||
return host.getDefaultTypeDirectiveNames(commonRoot);
|
||||
// Walk the primary type lookup locations
|
||||
var result = [];
|
||||
if (host.directoryExists && host.getDirectories) {
|
||||
var typeRoots = getEffectiveTypeRoots(options, host);
|
||||
for (var _i = 0, typeRoots_1 = typeRoots; _i < typeRoots_1.length; _i++) {
|
||||
var root = typeRoots_1[_i];
|
||||
if (host.directoryExists(root)) {
|
||||
result = result.concat(host.getDirectories(root));
|
||||
}
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
return result;
|
||||
}
|
||||
ts.getDefaultTypeDirectiveNames = getDefaultTypeDirectiveNames;
|
||||
ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames;
|
||||
function createProgram(rootNames, options, host, oldProgram) {
|
||||
var program;
|
||||
var files = [];
|
||||
@ -42948,10 +43014,12 @@ var ts;
|
||||
var filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? ts.createFileMap(function (fileName) { return fileName.toLowerCase(); }) : undefined;
|
||||
if (!tryReuseStructureFromOldProgram()) {
|
||||
ts.forEach(rootNames, function (name) { return processRootFile(name, /*isDefaultLib*/ false); });
|
||||
// load type declarations specified via 'types' argument
|
||||
var typeReferences = getDefaultTypeDirectiveNames(options, rootNames, host);
|
||||
// load type declarations specified via 'types' argument or implicitly from types/ and node_modules/@types folders
|
||||
var typeReferences = getAutomaticTypeDirectiveNames(options, rootNames, host);
|
||||
if (typeReferences) {
|
||||
var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, /*containingFile*/ undefined);
|
||||
var inferredRoot = getInferredTypesRoot(options, rootNames, host);
|
||||
var containingFilename = ts.combinePaths(inferredRoot, "__inferred type names__.ts");
|
||||
var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename);
|
||||
for (var i = 0; i < typeReferences.length; i++) {
|
||||
processTypeReferenceDirective(typeReferences[i], resolutions[i]);
|
||||
}
|
||||
@ -43048,10 +43116,9 @@ var ts;
|
||||
(oldOptions.jsx !== options.jsx) ||
|
||||
(oldOptions.allowJs !== options.allowJs) ||
|
||||
(oldOptions.rootDir !== options.rootDir) ||
|
||||
(oldOptions.typesSearchPaths !== options.typesSearchPaths) ||
|
||||
(oldOptions.configFilePath !== options.configFilePath) ||
|
||||
(oldOptions.baseUrl !== options.baseUrl) ||
|
||||
(oldOptions.typesRoot !== options.typesRoot) ||
|
||||
!ts.arrayIsEqualTo(oldOptions.typeRoots, oldOptions.typeRoots) ||
|
||||
!ts.arrayIsEqualTo(oldOptions.rootDirs, options.rootDirs) ||
|
||||
!ts.mapIsEqualTo(oldOptions.paths, options.paths)) {
|
||||
return false;
|
||||
@ -43530,10 +43597,13 @@ var ts;
|
||||
// This type of declaration is permitted only in the global module.
|
||||
// The StringLiteral must specify a top - level external module name.
|
||||
// Relative external module names are not permitted
|
||||
// NOTE: body of ambient module is always a module block
|
||||
for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) {
|
||||
var statement = _a[_i];
|
||||
collectModuleReferences(statement, /*inAmbientModule*/ true);
|
||||
// NOTE: body of ambient module is always a module block, if it exists
|
||||
var body = node.body;
|
||||
if (body) {
|
||||
for (var _i = 0, _a = body.statements; _i < _a.length; _i++) {
|
||||
var statement = _a[_i];
|
||||
collectModuleReferences(statement, /*inAmbientModule*/ true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -43696,7 +43766,7 @@ var ts;
|
||||
}
|
||||
}
|
||||
else {
|
||||
fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Cannot_find_name_0, typeReferenceDirective));
|
||||
fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective));
|
||||
}
|
||||
if (saveResolution) {
|
||||
resolvedTypeReferenceDirectives[typeReferenceDirective] = resolvedTypeReferenceDirective;
|
||||
@ -43868,10 +43938,6 @@ var ts;
|
||||
var span = ts.getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator);
|
||||
programDiagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_use_imports_exports_or_module_augmentations_when_module_is_none));
|
||||
}
|
||||
// Cannot specify module gen target of es6 when below es6
|
||||
if (options.module === ts.ModuleKind.ES6 && languageVersion < 2 /* ES6 */) {
|
||||
programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_es2015_when_targeting_ES5_or_lower));
|
||||
}
|
||||
// Cannot specify module gen that isn't amd or system with --out
|
||||
if (outFile) {
|
||||
if (options.module && !(options.module === ts.ModuleKind.AMD || options.module === ts.ModuleKind.System)) {
|
||||
@ -44278,8 +44344,13 @@ var ts;
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "typesRoot",
|
||||
type: "string"
|
||||
name: "typeRoots",
|
||||
type: "list",
|
||||
element: {
|
||||
name: "typeRoots",
|
||||
type: "string",
|
||||
isFilePath: true
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "types",
|
||||
@ -44418,7 +44489,15 @@ var ts;
|
||||
ts.parseCustomTypeOption = parseCustomTypeOption;
|
||||
/* @internal */
|
||||
function parseListTypeOption(opt, value, errors) {
|
||||
var values = trimString((value || "")).split(",");
|
||||
if (value === void 0) { value = ""; }
|
||||
value = trimString(value);
|
||||
if (ts.startsWith(value, "-")) {
|
||||
return undefined;
|
||||
}
|
||||
if (value === "") {
|
||||
return [];
|
||||
}
|
||||
var values = value.split(",");
|
||||
switch (opt.element.type) {
|
||||
case "number":
|
||||
return ts.map(values, parseInt);
|
||||
@ -44478,8 +44557,11 @@ var ts;
|
||||
i++;
|
||||
break;
|
||||
case "list":
|
||||
options[opt.name] = parseListTypeOption(opt, args[i], errors);
|
||||
i++;
|
||||
var result = parseListTypeOption(opt, args[i], errors);
|
||||
options[opt.name] = result || [];
|
||||
if (result) {
|
||||
i++;
|
||||
}
|
||||
break;
|
||||
// If not a primitive, the possible types are specified in what is effectively a map of options.
|
||||
default:
|
||||
@ -45263,7 +45345,10 @@ var ts;
|
||||
case 225 /* ModuleDeclaration */:
|
||||
var moduleDeclaration = node;
|
||||
topLevelNodes.push(node);
|
||||
addTopLevelNodes(getInnermostModule(moduleDeclaration).body.statements, topLevelNodes);
|
||||
var inner = getInnermostModule(moduleDeclaration);
|
||||
if (inner.body) {
|
||||
addTopLevelNodes(inner.body.statements, topLevelNodes);
|
||||
}
|
||||
break;
|
||||
case 220 /* FunctionDeclaration */:
|
||||
var functionDeclaration = node;
|
||||
@ -45480,7 +45565,8 @@ var ts;
|
||||
return undefined;
|
||||
function createModuleItem(node) {
|
||||
var moduleName = getModuleName(node);
|
||||
var childItems = getItemsWorker(getChildNodes(getInnermostModule(node).body.statements), createChildItem);
|
||||
var body = getInnermostModule(node).body;
|
||||
var childItems = body ? getItemsWorker(getChildNodes(body.statements), createChildItem) : [];
|
||||
return getNavigationBarItem(moduleName, ts.ScriptElementKind.moduleElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node));
|
||||
}
|
||||
function createFunctionItem(node) {
|
||||
@ -45568,7 +45654,7 @@ var ts;
|
||||
return ts.filter(node.members, function (member) { return !ts.hasDynamicName(member); });
|
||||
}
|
||||
function getInnermostModule(node) {
|
||||
while (node.body.kind === 225 /* ModuleDeclaration */) {
|
||||
while (node.body && node.body.kind === 225 /* ModuleDeclaration */) {
|
||||
node = node.body;
|
||||
}
|
||||
return node;
|
||||
@ -50961,7 +51047,7 @@ var ts;
|
||||
addCommentParts(declaration.parent, sourceFileOfDeclaration, getCleanedParamJsDocComment);
|
||||
}
|
||||
// If this is left side of dotted module declaration, there is no doc comments associated with this node
|
||||
if (declaration.kind === 225 /* ModuleDeclaration */ && declaration.body.kind === 225 /* ModuleDeclaration */) {
|
||||
if (declaration.kind === 225 /* ModuleDeclaration */ && declaration.body && declaration.body.kind === 225 /* ModuleDeclaration */) {
|
||||
return;
|
||||
}
|
||||
if ((declaration.kind === 179 /* FunctionExpression */ || declaration.kind === 180 /* ArrowFunction */) &&
|
||||
@ -51797,11 +51883,11 @@ var ts;
|
||||
sourceFile.version = version;
|
||||
sourceFile.scriptSnapshot = scriptSnapshot;
|
||||
}
|
||||
var commandLineOptions_stringToEnum;
|
||||
var commandLineOptionsStringToEnum;
|
||||
/** JS users may pass in string values for enum compiler options (such as ModuleKind), so convert. */
|
||||
function fixupCompilerOptions(options, diagnostics) {
|
||||
// Lazily create this value to fix module loading errors.
|
||||
commandLineOptions_stringToEnum = commandLineOptions_stringToEnum || ts.filter(ts.optionDeclarations, function (o) {
|
||||
commandLineOptionsStringToEnum = commandLineOptionsStringToEnum || ts.filter(ts.optionDeclarations, function (o) {
|
||||
return typeof o.type === "object" && !ts.forEachValue(o.type, function (v) { return typeof v !== "number"; });
|
||||
});
|
||||
options = ts.clone(options);
|
||||
@ -51822,8 +51908,8 @@ var ts;
|
||||
}
|
||||
}
|
||||
};
|
||||
for (var _i = 0, commandLineOptions_stringToEnum_1 = commandLineOptions_stringToEnum; _i < commandLineOptions_stringToEnum_1.length; _i++) {
|
||||
var opt = commandLineOptions_stringToEnum_1[_i];
|
||||
for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) {
|
||||
var opt = commandLineOptionsStringToEnum_1[_i];
|
||||
_loop_2(opt);
|
||||
}
|
||||
return options;
|
||||
@ -51882,7 +51968,8 @@ var ts;
|
||||
getNewLine: function () { return newLine; },
|
||||
fileExists: function (fileName) { return fileName === inputFileName; },
|
||||
readFile: function (fileName) { return ""; },
|
||||
directoryExists: function (directoryExists) { return true; }
|
||||
directoryExists: function (directoryExists) { return true; },
|
||||
getDirectories: function (path) { return []; }
|
||||
};
|
||||
var program = ts.createProgram([inputFileName], options, compilerHost);
|
||||
if (transpileOptions.reportDiagnostics) {
|
||||
@ -51970,7 +52057,7 @@ var ts;
|
||||
var buckets = {};
|
||||
var getCanonicalFileName = ts.createGetCanonicalFileName(!!useCaseSensitiveFileNames);
|
||||
function getKeyForCompilationSettings(settings) {
|
||||
return ("_" + settings.target + "|" + settings.module + "|" + settings.noResolve + "|" + settings.jsx + "|" + settings.allowJs + "|" + settings.baseUrl + "|" + settings.typesRoot + "|" + settings.typesSearchPaths + "|" + JSON.stringify(settings.rootDirs) + "|" + JSON.stringify(settings.paths));
|
||||
return ("_" + settings.target + "|" + settings.module + "|" + settings.noResolve + "|" + settings.jsx + "|" + settings.allowJs + "|" + settings.baseUrl + "|" + JSON.stringify(settings.typeRoots) + "|" + JSON.stringify(settings.rootDirs) + "|" + JSON.stringify(settings.paths));
|
||||
}
|
||||
function getBucketForCompilationSettings(key, createIfMissing) {
|
||||
var bucket = ts.lookUp(buckets, key);
|
||||
@ -52739,8 +52826,10 @@ var ts;
|
||||
return entry && entry.scriptSnapshot.getText(0, entry.scriptSnapshot.getLength());
|
||||
},
|
||||
directoryExists: function (directoryName) {
|
||||
ts.Debug.assert(!host.resolveModuleNames || !host.resolveTypeReferenceDirectives);
|
||||
return ts.directoryProbablyExists(directoryName, host);
|
||||
},
|
||||
getDirectories: function (path) {
|
||||
return host.getDirectories ? host.getDirectories(path) : [];
|
||||
}
|
||||
};
|
||||
if (host.trace) {
|
||||
@ -53716,7 +53805,7 @@ var ts;
|
||||
}
|
||||
if (!uniqueNames[name_41]) {
|
||||
uniqueNames[name_41] = name_41;
|
||||
var displayName = getCompletionEntryDisplayName(name_41, target, /*performCharacterChecks*/ true);
|
||||
var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_41), target, /*performCharacterChecks*/ true);
|
||||
if (displayName) {
|
||||
var entry = {
|
||||
name: displayName,
|
||||
@ -55136,7 +55225,8 @@ var ts;
|
||||
result.push({
|
||||
fileName: entry.fileName,
|
||||
textSpan: highlightSpan.textSpan,
|
||||
isWriteAccess: highlightSpan.kind === HighlightSpanKind.writtenReference
|
||||
isWriteAccess: highlightSpan.kind === HighlightSpanKind.writtenReference,
|
||||
isDefinition: false
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -55486,7 +55576,8 @@ var ts;
|
||||
references: [{
|
||||
fileName: sourceFile.fileName,
|
||||
textSpan: ts.createTextSpan(position, searchText.length),
|
||||
isWriteAccess: false
|
||||
isWriteAccess: false,
|
||||
isDefinition: false
|
||||
}]
|
||||
});
|
||||
}
|
||||
@ -55964,7 +56055,8 @@ var ts;
|
||||
return {
|
||||
fileName: node.getSourceFile().fileName,
|
||||
textSpan: ts.createTextSpanFromBounds(start, end),
|
||||
isWriteAccess: isWriteAccess(node)
|
||||
isWriteAccess: isWriteAccess(node),
|
||||
isDefinition: ts.isDeclarationName(node) || ts.isLiteralComputedPropertyDeclarationName(node)
|
||||
};
|
||||
}
|
||||
/** A node is considered a writeAccess iff it is a name of a declaration or a target of an assignment */
|
||||
@ -58987,4 +59079,6 @@ var TypeScript;
|
||||
// TODO: it should be moved into a namespace though.
|
||||
/* @internal */
|
||||
var toolsVersion = "1.9";
|
||||
/* tslint:enable:no-unused-variable */
|
||||
/* tslint:enable:no-unused-variable */
|
||||
|
||||
//# sourceMappingURL=typescriptServices.js.map
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user