From ba1dc9e3034a8f3e202d30cc11ca0387edf58693 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Fri, 1 Mar 2019 13:30:08 -0800 Subject: [PATCH] Update LKG with the branch build --- lib/enu/diagnosticMessages.generated.json.lcg | 54 + lib/tsc.js | 2080 ++++++--- lib/tsserver.js | 3862 ++++++++++++----- lib/tsserverlibrary.d.ts | 135 +- lib/tsserverlibrary.js | 2411 ++++++---- lib/typescript.d.ts | 133 +- lib/typescript.js | 2411 ++++++---- lib/typescriptServices.d.ts | 133 +- lib/typescriptServices.js | 2411 ++++++---- lib/typingsInstaller.js | 2249 +++++++--- 10 files changed, 11306 insertions(+), 4573 deletions(-) diff --git a/lib/enu/diagnosticMessages.generated.json.lcg b/lib/enu/diagnosticMessages.generated.json.lcg index 17f927a74f3..c57359fdf6c 100644 --- a/lib/enu/diagnosticMessages.generated.json.lcg +++ b/lib/enu/diagnosticMessages.generated.json.lcg @@ -339,6 +339,18 @@ + + + + + + + + + + + + @@ -1641,6 +1653,12 @@ + + + + + + @@ -1671,6 +1689,12 @@ + + + + + + @@ -1869,6 +1893,12 @@ + + + + + + @@ -2421,6 +2451,12 @@ + + + + + + @@ -4485,6 +4521,12 @@ + + + + + + @@ -5343,6 +5385,12 @@ + + + + + + @@ -6465,6 +6513,12 @@ + + + + + + diff --git a/lib/tsc.js b/lib/tsc.js index e75a1ea50ba..58e8a8e72cd 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -4072,6 +4072,15 @@ var ts; Option_build_must_be_the_first_command_line_argument: diag(6369, ts.DiagnosticCategory.Error, "Option_build_must_be_the_first_command_line_argument_6369", "Option '--build' must be the first command line argument."), Options_0_and_1_cannot_be_combined: diag(6370, ts.DiagnosticCategory.Error, "Options_0_and_1_cannot_be_combined_6370", "Options '{0}' and '{1}' cannot be combined."), Updating_unchanged_output_timestamps_of_project_0: diag(6371, ts.DiagnosticCategory.Message, "Updating_unchanged_output_timestamps_of_project_0_6371", "Updating unchanged output timestamps of project '{0}'..."), + Project_0_is_out_of_date_because_output_of_its_dependency_1_has_changed: diag(6372, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_output_of_its_dependency_1_has_changed_6372", "Project '{0}' is out of date because output of its dependency '{1}' has changed"), + Updating_output_of_project_0: diag(6373, ts.DiagnosticCategory.Message, "Updating_output_of_project_0_6373", "Updating output of project '{0}'..."), + A_non_dry_build_would_update_timestamps_for_output_of_project_0: diag(6374, ts.DiagnosticCategory.Message, "A_non_dry_build_would_update_timestamps_for_output_of_project_0_6374", "A non-dry build would update timestamps for output of project '{0}'"), + A_non_dry_build_would_update_output_of_project_0: diag(6375, ts.DiagnosticCategory.Message, "A_non_dry_build_would_update_output_of_project_0_6375", "A non-dry build would update output of project '{0}'"), + Cannot_update_output_of_project_0_because_there_was_error_reading_file_1: diag(6376, ts.DiagnosticCategory.Message, "Cannot_update_output_of_project_0_because_there_was_error_reading_file_1_6376", "Cannot update output of project '{0}' because there was error reading file '{1}'"), + Cannot_write_file_0_because_it_will_overwrite_tsbuildinfo_file_generated_by_referenced_project_1: diag(6377, ts.DiagnosticCategory.Error, "Cannot_write_file_0_because_it_will_overwrite_tsbuildinfo_file_generated_by_referenced_project_1_6377", "Cannot write file '{0}' because it will overwrite '.tsbuildinfo' file generated by referenced project '{1}'"), + Enable_incremental_compilation: diag(6378, ts.DiagnosticCategory.Message, "Enable_incremental_compilation_6378", "Enable incremental compilation"), + Composite_projects_may_not_disable_incremental_compilation: diag(6379, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_incremental_compilation_6379", "Composite projects may not disable incremental compilation."), + Specify_file_to_store_incremental_compilation_information: diag(6380, ts.DiagnosticCategory.Message, "Specify_file_to_store_incremental_compilation_information_6380", "Specify file to store incremental compilation information"), The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: diag(6500, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1_6500", "The expected type comes from property '{0}' which is declared here on type '{1}'"), The_expected_type_comes_from_this_index_signature: diag(6501, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_this_index_signature_6501", "The expected type comes from this index signature."), The_expected_type_comes_from_the_return_type_of_this_signature: diag(6502, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_the_return_type_of_this_signature_6502", "The expected type comes from the return type of this signature."), @@ -4686,11 +4695,13 @@ var ts; ts.Debug.assert(pos === 0); return shebangTriviaRegex.test(text); } + ts.isShebangTrivia = isShebangTrivia; function scanShebangTrivia(text, pos) { var shebang = shebangTriviaRegex.exec(text)[0]; pos = pos + shebang.length; return pos; } + ts.scanShebangTrivia = scanShebangTrivia; function iterateCommentRanges(reduce, text, pos, trailing, cb, state, initial) { var pendingPos; var pendingEnd; @@ -6287,7 +6298,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 279) { + while (node && node.kind !== 284) { node = node.parent; } return node; @@ -6392,7 +6403,7 @@ var ts; if (includeJsDoc && ts.hasJSDocNodes(node)) { return getTokenPosOfNode(node.jsDoc[0]); } - if (node.kind === 306 && node._children.length > 0) { + if (node.kind === 311 && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); @@ -6411,7 +6422,7 @@ var ts; } ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; function isJSDocTypeExpressionOrChild(node) { - return node.kind === 283 || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); + return node.kind === 288 || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); } function getTextOfNodeFromSourceText(sourceText, node, includeTrivia) { if (includeTrivia === void 0) { includeTrivia = false; } @@ -6514,7 +6525,7 @@ var ts; return node && node.kind === 244 && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 279 || + return node.kind === 284 || node.kind === 244 || ts.isFunctionLike(node); } @@ -6529,7 +6540,7 @@ var ts; ts.isExternalModuleAugmentation = isExternalModuleAugmentation; function isModuleAugmentationExternal(node) { switch (node.parent.kind) { - case 279: + case 284: return ts.isExternalModule(node.parent); case 245: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); @@ -6547,7 +6558,7 @@ var ts; ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { - case 279: + case 284: case 246: case 274: case 244: @@ -6570,9 +6581,9 @@ var ts; ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 297: - case 304: - case 293: + case 302: + case 309: + case 298: return true; default: ts.assertType(node); @@ -6588,12 +6599,12 @@ var ts; case 162: case 165: case 166: - case 289: + case 294: case 240: case 209: case 241: case 242: - case 303: + case 308: case 239: case 156: case 157: @@ -6731,7 +6742,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 279: + case 284: var pos_1 = ts.skipTrivia(sourceFile.text, 0, false); if (pos_1 === sourceFile.text.length) { return ts.createTextSpan(0, 0); @@ -6888,7 +6899,7 @@ var ts; return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); case 150: return node === parent.constraint; - case 303: + case 308: return node === parent.constraint; case 154: case 153: @@ -7132,7 +7143,7 @@ var ts; } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 279); + ts.Debug.assert(node.kind !== 284); while (true) { node = node.parent; if (!node) { @@ -7171,7 +7182,7 @@ var ts; case 161: case 162: case 243: - case 279: + case 284: return node; } } @@ -7813,7 +7824,7 @@ var ts; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 304 || node.kind === 297; + return node.kind === 309 || node.kind === 302; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -7949,7 +7960,7 @@ var ts; ts.hasRestParameter = hasRestParameter; function isRestParameter(node) { var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type; - return node.dotDotDotToken !== undefined || !!type && type.kind === 290; + return node.dotDotDotToken !== undefined || !!type && type.kind === 295; } ts.isRestParameter = isRestParameter; function getAssignmentTargetKind(node) { @@ -8376,7 +8387,7 @@ var ts; || kind === 158 || kind === 159 || kind === 244 - || kind === 279; + || kind === 284; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -8448,7 +8459,7 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 309: + case 314: return 0; case 208: return 1; @@ -8749,6 +8760,9 @@ var ts; lineStart = true; } } + function getTextPosWithWriteLine() { + return lineStart ? output.length : (output.length + newLine.length); + } reset(); return { write: write, @@ -8777,7 +8791,8 @@ var ts; writeStringLiteral: write, writeSymbol: function (s, _) { return write(s); }, writeTrailingSemicolon: write, - writeComment: write + writeComment: write, + getTextPosWithWriteLine: getTextPosWithWriteLine }; } ts.createTextWriter = createTextWriter; @@ -9042,7 +9057,7 @@ var ts; } ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations; function isNonTypeAliasTemplate(tag) { - return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 291 && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 296 && tag.parent.tags.some(isJSDocTypeAlias)); } function getEffectiveSetAccessorTypeAnnotationNode(node) { var parameter = getSetAccessorValueParameter(node); @@ -9873,19 +9888,29 @@ var ts; || kind === 96 || kind === 132 || kind === 211 - || kind === 284 - || kind === 285 - || kind === 286 - || kind === 287 - || kind === 288 || kind === 289 - || kind === 290; + || kind === 290 + || kind === 291 + || kind === 292 + || kind === 293 + || kind === 294 + || kind === 295; } ts.isTypeNodeKind = isTypeNodeKind; function isAccessExpression(node) { return node.kind === 189 || node.kind === 190; } ts.isAccessExpression = isAccessExpression; + function isBundleFileTextLike(section) { + switch (section.kind) { + case "text": + case "internal": + return true; + default: + return false; + } + } + ts.isBundleFileTextLike = isBundleFileTextLike; })(ts || (ts = {})); (function (ts) { function getDefaultLibFileName(options) { @@ -10219,8 +10244,8 @@ var ts; switch (declaration.kind) { case 72: return declaration; - case 305: - case 299: { + case 310: + case 304: { var name = declaration.name; if (name.kind === 148) { return name.right; @@ -10244,7 +10269,7 @@ var ts; return undefined; } } - case 304: + case 309: return getNameOfJSDocTypedef(declaration); case 254: { var expression = declaration.expression; @@ -10386,7 +10411,7 @@ var ts; return ts.emptyArray; } if (ts.isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 291); + ts.Debug.assert(node.parent.kind === 296); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } if (node.typeParameters) { @@ -10648,7 +10673,7 @@ var ts; } ts.isParenthesizedExpression = isParenthesizedExpression; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 308) { + while (node.kind === 313) { node = node.expression; } return node; @@ -10987,113 +11012,133 @@ var ts; } ts.isEnumMember = isEnumMember; function isSourceFile(node) { - return node.kind === 279; + return node.kind === 284; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 280; + return node.kind === 285; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 281; + return node.kind === 286; } ts.isUnparsedSource = isUnparsedSource; + function isUnparsedPrepend(node) { + return node.kind === 280; + } + ts.isUnparsedPrepend = isUnparsedPrepend; + function isUnparsedTextLike(node) { + switch (node.kind) { + case 281: + case 282: + return true; + default: + return false; + } + } + ts.isUnparsedTextLike = isUnparsedTextLike; + function isUnparsedNode(node) { + return isUnparsedTextLike(node) || + node.kind === 279 || + node.kind === 283; + } + ts.isUnparsedNode = isUnparsedNode; function isJSDocTypeExpression(node) { - return node.kind === 283; + return node.kind === 288; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocAllType(node) { - return node.kind === 284; + return node.kind === 289; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 285; + return node.kind === 290; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 286; + return node.kind === 291; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 287; + return node.kind === 292; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 288; + return node.kind === 293; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 289; + return node.kind === 294; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 290; + return node.kind === 295; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDoc(node) { - return node.kind === 291; + return node.kind === 296; } ts.isJSDoc = isJSDoc; function isJSDocAugmentsTag(node) { - return node.kind === 295; + return node.kind === 300; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocClassTag(node) { - return node.kind === 296; + return node.kind === 301; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocEnumTag(node) { - return node.kind === 298; + return node.kind === 303; } ts.isJSDocEnumTag = isJSDocEnumTag; function isJSDocThisTag(node) { - return node.kind === 301; + return node.kind === 306; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocParameterTag(node) { - return node.kind === 299; + return node.kind === 304; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 300; + return node.kind === 305; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocTypeTag(node) { - return node.kind === 302; + return node.kind === 307; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 303; + return node.kind === 308; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 304; + return node.kind === 309; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocPropertyTag(node) { - return node.kind === 305; + return node.kind === 310; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocPropertyLikeTag(node) { - return node.kind === 305 || node.kind === 299; + return node.kind === 310 || node.kind === 304; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; function isJSDocTypeLiteral(node) { - return node.kind === 292; + return node.kind === 297; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocCallbackTag(node) { - return node.kind === 297; + return node.kind === 302; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocSignature(node) { - return node.kind === 293; + return node.kind === 298; } ts.isJSDocSignature = isJSDocSignature; })(ts || (ts = {})); (function (ts) { function isSyntaxList(n) { - return n.kind === 306; + return n.kind === 311; } ts.isSyntaxList = isSyntaxList; function isNode(node) { @@ -11223,11 +11268,11 @@ var ts; switch (kind) { case 155: case 160: - case 293: + case 298: case 161: case 162: case 165: - case 289: + case 294: case 166: return true; default: @@ -11478,8 +11523,8 @@ var ts; case 208: case 212: case 210: - case 309: - case 308: + case 314: + case 313: return true; default: return isUnaryExpressionKind(kind); @@ -11492,11 +11537,11 @@ var ts; } ts.isAssertionExpression = isAssertionExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 308; + return node.kind === 313; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isNotEmittedStatement(node) { - return node.kind === 307; + return node.kind === 312; } ts.isNotEmittedStatement = isNotEmittedStatement; function isNotEmittedOrPartiallyEmittedNode(node) { @@ -11596,9 +11641,9 @@ var ts; || kind === 242 || kind === 150 || kind === 237 - || kind === 304 - || kind === 297 - || kind === 305; + || kind === 309 + || kind === 302 + || kind === 310; } function isDeclarationStatementKind(kind) { return kind === 239 @@ -11633,13 +11678,13 @@ var ts; || kind === 219 || kind === 224 || kind === 231 - || kind === 307 - || kind === 311 - || kind === 310; + || kind === 312 + || kind === 316 + || kind === 315; } function isDeclaration(node) { if (node.kind === 150) { - return node.parent.kind !== 303 || ts.isInJSFile(node); + return (node.parent && node.parent.kind !== 308) || ts.isInJSFile(node); } return isDeclarationKind(node.kind); } @@ -11717,15 +11762,15 @@ var ts; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; function isJSDocNode(node) { - return node.kind >= 283 && node.kind <= 305; + return node.kind >= 288 && node.kind <= 310; } ts.isJSDocNode = isJSDocNode; function isJSDocCommentContainingNode(node) { - return node.kind === 291 || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 296 || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); } ts.isJSDocCommentContainingNode = isJSDocCommentContainingNode; function isJSDocTag(node) { - return node.kind >= 294 && node.kind <= 305; + return node.kind >= 299 && node.kind <= 310; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { @@ -12027,6 +12072,10 @@ var ts; return !!(compilerOptions.declaration || compilerOptions.composite); } ts.getEmitDeclarations = getEmitDeclarations; + function isIncrementalCompilation(options) { + return !!(options.incremental || options.composite); + } + ts.isIncrementalCompilation = isIncrementalCompilation; function getStrictOptionValue(compilerOptions, flag) { return compilerOptions[flag] === undefined ? !!compilerOptions.strict : !!compilerOptions[flag]; } @@ -13080,7 +13129,7 @@ var ts; var IdentifierConstructor; var SourceFileConstructor; function createNode(kind, pos, end) { - if (kind === 279) { + if (kind === 284) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else if (kind === 72) { @@ -13317,7 +13366,7 @@ var ts; case 218: case 245: return visitNodes(cbNode, cbNodes, node.statements); - case 279: + case 284: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); case 219: @@ -13466,7 +13515,7 @@ var ts; return visitNode(cbNode, node.expression); case 258: return visitNodes(cbNode, cbNodes, node.decorators); - case 309: + case 314: return visitNodes(cbNode, cbNodes, node.elements); case 260: return visitNode(cbNode, node.openingElement) || @@ -13495,60 +13544,60 @@ var ts; return visitNode(cbNode, node.tagName); case 171: case 172: - case 283: - case 287: - case 286: case 288: - case 290: + case 292: + case 291: + case 293: + case 295: return visitNode(cbNode, node.type); - case 289: + case 294: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 291: + case 296: return visitNodes(cbNode, cbNodes, node.tags); - case 299: - case 305: + case 304: + case 310: return visitNode(cbNode, node.tagName) || (node.isNameFirst ? visitNode(cbNode, node.name) || visitNode(cbNode, node.typeExpression) : visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name)); - case 295: + case 300: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.class); - case 303: + case 308: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.constraint) || visitNodes(cbNode, cbNodes, node.typeParameters); - case 304: + case 309: return visitNode(cbNode, node.tagName) || (node.typeExpression && - node.typeExpression.kind === 283 + node.typeExpression.kind === 288 ? visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) : visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression)); - case 297: + case 302: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); - case 300: - case 302: - case 301: - case 298: + case 305: + case 307: + case 306: + case 303: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.typeExpression); - case 293: + case 298: return ts.forEach(node.typeParameters, cbNode) || ts.forEach(node.parameters, cbNode) || visitNode(cbNode, node.type); - case 292: + case 297: return ts.forEach(node.jsDocPropertyTags, cbNode); - case 294: - case 296: + case 299: + case 301: return visitNode(cbNode, node.tagName); - case 308: + case 313: return visitNode(cbNode, node.expression); } } @@ -13799,7 +13848,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile) { - var sourceFile = new SourceFileConstructor(279, 0, sourceText.length); + var sourceFile = new SourceFileConstructor(284, 0, sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -14746,9 +14795,9 @@ var ts; return finishNode(node); } function parseJSDocAllType(postFixEquals) { - var result = createNode(284); + var result = createNode(289); if (postFixEquals) { - return createPostfixType(288, result); + return createPostfixType(293, result); } else { nextToken(); @@ -14756,7 +14805,7 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(287); + var result = createNode(292); nextToken(); result.type = parseNonArrayType(); return finishNode(result); @@ -14770,18 +14819,18 @@ var ts; token() === 30 || token() === 59 || token() === 50) { - var result = createNode(285, pos); + var result = createNode(290, pos); return finishNode(result); } else { - var result = createNode(286, pos); + var result = createNode(291, pos); result.type = parseType(); return finishNode(result); } } function parseJSDocFunctionType() { if (lookAhead(nextTokenIsOpenParen)) { - var result = createNodeWithJSDoc(289); + var result = createNodeWithJSDoc(294); nextToken(); fillSignature(57, 4 | 32, result); return finishNode(result); @@ -14805,12 +14854,12 @@ var ts; var type = parseTypeOrTypePredicate(); scanner.setInJSDocType(false); if (dotdotdot) { - var variadic = createNode(290, dotdotdot.pos); + var variadic = createNode(295, dotdotdot.pos); variadic.type = type; type = finishNode(variadic); } if (token() === 59) { - return createPostfixType(288, type); + return createPostfixType(293, type); } return type; } @@ -15104,7 +15153,7 @@ var ts; return finishNode(node); } var type = parseType(); - if (!(contextFlags & 2097152) && type.kind === 286 && type.pos === type.type.pos) { + if (!(contextFlags & 2097152) && type.kind === 291 && type.pos === type.type.pos) { type.kind = 171; } return type; @@ -15288,13 +15337,13 @@ var ts; while (!scanner.hasPrecedingLineBreak()) { switch (token()) { case 52: - type = createPostfixType(287, type); + type = createPostfixType(292, type); break; case 56: if (!(contextFlags & 2097152) && lookAhead(nextTokenIsStartOfType)) { return type; } - type = createPostfixType(286, type); + type = createPostfixType(291, type); break; case 22: parseExpected(22); @@ -17622,7 +17671,7 @@ var ts; } JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; function parseJSDocTypeExpression(mayOmitBraces) { - var result = createNode(283); + var result = createNode(288); var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18); result.type = doInsideOfContext(2097152, parseJSDocType); if (!mayOmitBraces || hasBrace) { @@ -17759,7 +17808,7 @@ var ts; } } function createJSDocComment() { - var result = createNode(291, start); + var result = createNode(296, start); result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -17918,7 +17967,7 @@ var ts; return comments.length === 0 ? undefined : comments.join(""); } function parseUnknownTag(start, tagName) { - var result = createNode(294, start); + var result = createNode(299, start); result.tagName = tagName; return finishNode(result); } @@ -17974,8 +18023,8 @@ var ts; typeExpression = tryParseTypeExpression(); } var result = target === 1 ? - createNode(305, start) : - createNode(299, start); + createNode(310, start) : + createNode(304, start); var comment = parseTagComments(indent + scanner.getStartPos() - start); var nestedTypeLiteral = target !== 4 && parseNestedTypeLiteral(typeExpression, name, target, indent); if (nestedTypeLiteral) { @@ -17992,18 +18041,18 @@ var ts; } function parseNestedTypeLiteral(typeExpression, name, target, indent) { if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) { - var typeLiteralExpression = createNode(283, scanner.getTokenPos()); + var typeLiteralExpression = createNode(288, scanner.getTokenPos()); var child = void 0; var jsdocTypeLiteral = void 0; var start_2 = scanner.getStartPos(); var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) { - if (child.kind === 299 || child.kind === 305) { + if (child.kind === 304 || child.kind === 310) { children = ts.append(children, child); } } if (children) { - jsdocTypeLiteral = createNode(292, start_2); + jsdocTypeLiteral = createNode(297, start_2); jsdocTypeLiteral.jsDocPropertyTags = children; if (typeExpression.type.kind === 169) { jsdocTypeLiteral.isArrayType = true; @@ -18014,25 +18063,25 @@ var ts; } } function parseReturnTag(start, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 300; })) { + if (ts.forEach(tags, function (t) { return t.kind === 305; })) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(300, start); + var result = createNode(305, start); result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); } function parseTypeTag(start, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 302; })) { + if (ts.forEach(tags, function (t) { return t.kind === 307; })) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(302, start); + var result = createNode(307, start); result.tagName = tagName; result.typeExpression = parseJSDocTypeExpression(true); return finishNode(result); } function parseAugmentsTag(start, tagName) { - var result = createNode(295, start); + var result = createNode(300, start); result.tagName = tagName; result.class = parseExpressionWithTypeArgumentsForAugments(); return finishNode(result); @@ -18059,19 +18108,19 @@ var ts; return node; } function parseClassTag(start, tagName) { - var tag = createNode(296, start); + var tag = createNode(301, start); tag.tagName = tagName; return finishNode(tag); } function parseThisTag(start, tagName) { - var tag = createNode(301, start); + var tag = createNode(306, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(true); skipWhitespace(); return finishNode(tag); } function parseEnumTag(start, tagName) { - var tag = createNode(298, start); + var tag = createNode(303, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(true); skipWhitespace(); @@ -18080,7 +18129,7 @@ var ts; function parseTypedefTag(start, tagName, indent) { var typeExpression = tryParseTypeExpression(); skipWhitespaceOrAsterisk(); - var typedefTag = createNode(304, start); + var typedefTag = createNode(309, start); typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(); typedefTag.name = getJSDocTypeAliasName(typedefTag.fullName); @@ -18094,9 +18143,9 @@ var ts; var childTypeTag = void 0; while (child = tryParse(function () { return parseChildPropertyTag(indent); })) { if (!jsdocTypeLiteral) { - jsdocTypeLiteral = createNode(292, start); + jsdocTypeLiteral = createNode(297, start); } - if (child.kind === 302) { + if (child.kind === 307) { if (childTypeTag) { break; } @@ -18141,14 +18190,14 @@ var ts; return typeNameOrNamespaceName; } function parseCallbackTag(start, tagName, indent) { - var callbackTag = createNode(297, start); + var callbackTag = createNode(302, start); callbackTag.tagName = tagName; callbackTag.fullName = parseJSDocTypeNameWithNamespace(); callbackTag.name = getJSDocTypeAliasName(callbackTag.fullName); skipWhitespace(); callbackTag.comment = parseTagComments(indent); var child; - var jsdocSignature = createNode(293, start); + var jsdocSignature = createNode(298, start); jsdocSignature.parameters = []; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4, indent); })) { jsdocSignature.parameters = ts.append(jsdocSignature.parameters, child); @@ -18156,7 +18205,7 @@ var ts; var returnTag = tryParse(function () { if (parseOptionalJsdoc(58)) { var tag = parseTag(indent); - if (tag && tag.kind === 300) { + if (tag && tag.kind === 305) { return tag; } } @@ -18201,7 +18250,7 @@ var ts; case 58: if (canParseTag) { var child = tryParseChildTag(target, indent); - if (child && (child.kind === 299 || child.kind === 305) && + if (child && (child.kind === 304 || child.kind === 310) && target !== 4 && name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; @@ -18270,7 +18319,7 @@ var ts; skipWhitespace(); typeParameters.push(typeParameter); } while (parseOptionalJsdoc(27)); - var result = createNode(303, start); + var result = createNode(308, start); result.tagName = tagName; result.constraint = constraint; result.typeParameters = createNodeArray(typeParameters, typeParametersPos); @@ -19126,6 +19175,22 @@ var ts; category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Enable_project_compilation, }, + { + name: "incremental", + type: "boolean", + isTSConfigOnly: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Enable_incremental_compilation, + }, + { + name: "tsBuildInfoFile", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.FILE, + isTSConfigOnly: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Specify_file_to_store_incremental_compilation_information, + }, { name: "removeComments", type: "boolean", @@ -22309,7 +22374,7 @@ var ts; return "__constructor"; case 165: case 160: - case 293: + case 298: return "__call"; case 166: case 161: @@ -22318,7 +22383,7 @@ var ts; return "__index"; case 255: return "__export"; - case 279: + case 284: return "export="; case 204: if (ts.getAssignmentDeclarationKind(node) === 2) { @@ -22326,10 +22391,10 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 289: + case 294: return (ts.isJSDocConstructSignature(node) ? "__new" : "__call"); case 151: - ts.Debug.assert(node.parent.kind === 289, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); + ts.Debug.assert(node.parent.kind === 294, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); var functionType = node.parent; var index = functionType.parameters.indexOf(node); return "arg" + index; @@ -22481,7 +22546,7 @@ var ts; if (hasExplicitReturn) node.flags |= 256; } - if (node.kind === 279) { + if (node.kind === 284) { node.flags |= emitFlags; } if (currentReturnTarget) { @@ -22625,11 +22690,11 @@ var ts; case 191: bindCallExpressionFlow(node); break; - case 304: - case 297: + case 309: + case 302: bindJSDocTypeAlias(node); break; - case 279: { + case 284: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; @@ -23269,7 +23334,7 @@ var ts; case 243: case 188: case 168: - case 292: + case 297: case 268: return 1; case 241: @@ -23278,7 +23343,7 @@ var ts; case 242: case 181: return 1 | 32; - case 279: + case 284: return 1 | 4 | 32; case 156: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { @@ -23290,8 +23355,8 @@ var ts; case 158: case 159: case 160: - case 293: - case 289: + case 298: + case 294: case 165: case 161: case 162: @@ -23325,7 +23390,7 @@ var ts; switch (container.kind) { case 244: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 279: + case 284: return declareSourceFileMember(node, symbolFlags, symbolExcludes); case 209: case 240: @@ -23333,7 +23398,7 @@ var ts; case 243: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); case 168: - case 292: + case 297: case 188: case 241: case 268: @@ -23342,7 +23407,7 @@ var ts; case 166: case 160: case 161: - case 293: + case 298: case 162: case 156: case 155: @@ -23352,9 +23417,9 @@ var ts; case 239: case 196: case 197: - case 289: - case 304: - case 297: + case 294: + case 309: + case 302: case 242: case 181: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); @@ -23371,8 +23436,8 @@ var ts; : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 279 ? node : node.body; - if (body && (body.kind === 279 || body.kind === 245)) { + var body = node.kind === 284 ? node : node.body; + if (body && (body.kind === 284 || body.kind === 245)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; if (stat.kind === 255 || stat.kind === 254) { @@ -23482,7 +23547,7 @@ var ts; case 244: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 279: + case 284: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -23599,7 +23664,7 @@ var ts; } function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2) { - if (blockScopeContainer.kind !== 279 && + if (blockScopeContainer.kind !== 284 && blockScopeContainer.kind !== 244 && !ts.isFunctionLike(blockScopeContainer)) { var errorSpan = ts.getErrorSpanForNode(file, node); @@ -23828,12 +23893,12 @@ var ts; case 159: return bindPropertyOrMethodOrAccessor(node, 65536, 67187647); case 165: - case 289: - case 293: + case 294: + case 298: case 166: return bindFunctionOrConstructorType(node); case 168: - case 292: + case 297: case 181: return bindAnonymousTypeWorker(node); case 188: @@ -23888,7 +23953,7 @@ var ts; return bindExportDeclaration(node); case 254: return bindExportAssignment(node); - case 279: + case 284: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); case 218: @@ -23897,21 +23962,21 @@ var ts; } case 245: return updateStrictModeStatementList(node.statements); - case 299: - if (node.parent.kind === 293) { + case 304: + if (node.parent.kind === 298) { return bindParameter(node); } - if (node.parent.kind !== 292) { + if (node.parent.kind !== 297) { break; } - case 305: + case 310: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 288 ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 293 ? 4 | 16777216 : 4; return declareSymbolAndAddToSymbolTable(propTag, flags, 0); - case 304: - case 297: + case 309: + case 302: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -24062,7 +24127,7 @@ var ts; var symbolTable = ts.hasModifier(thisContainer, 32) ? containingClass.symbol.exports : containingClass.symbol.members; declareSymbol(symbolTable, containingClass.symbol, node, 4, 0, true); break; - case 279: + case 284: if (thisContainer.commonJsModuleIndicator) { declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 | 1048576, 0); } @@ -24078,7 +24143,7 @@ var ts; if (node.expression.kind === 100) { bindThisPropertyAssignment(node); } - else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 279) { + else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 284) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -24107,7 +24172,7 @@ var ts; } function bindObjectDefinePropertyAssignment(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]); - var isToplevel = node.parent.parent.kind === 279; + var isToplevel = node.parent.parent.kind === 284; namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, false); bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, false); } @@ -24163,8 +24228,8 @@ var ts; function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty) { var namespaceSymbol = lookupSymbolForPropertyAccess(name); var isToplevel = ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 279 - : propertyAccess.parent.parent.kind === 279; + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 284 + : propertyAccess.parent.parent.kind === 284; namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty); bindPotentiallyNewExpandoMemberToNamespace(propertyAccess, namespaceSymbol, isPrototypeProperty); } @@ -24271,7 +24336,7 @@ var ts; } } function bindParameter(node) { - if (node.kind === 299 && container.kind !== 293) { + if (node.kind === 304 && container.kind !== 298) { return; } if (inStrictMode && !(node.flags & 4194304)) { @@ -24883,7 +24948,7 @@ var ts; break; case 194: case 212: - case 308: + case 313: transformFlags |= 3; excludeFlags = 536872257; break; @@ -25053,7 +25118,7 @@ var ts; transformFlags |= 192; } break; - case 279: + case 284: if (subtreeFlags & 16384) { transformFlags |= 192; } @@ -25125,7 +25190,7 @@ var ts; return 637666625; case 194: case 212: - case 308: + case 313: case 195: case 98: return 536872257; @@ -26112,7 +26177,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); } function isGlobalSourceFile(node) { - return node.kind === 279 && !ts.isExternalOrCommonJsModule(node); + return node.kind === 284 && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -26242,7 +26307,7 @@ var ts; if (result = lookup(location.locals, name, meaning)) { var useResult = true; if (ts.isFunctionLike(location) && lastLocation && lastLocation !== location.body) { - if (meaning & result.flags & 67897832 && lastLocation.kind !== 291) { + if (meaning & result.flags & 67897832 && lastLocation.kind !== 296) { useResult = result.flags & 262144 ? lastLocation === location.type || lastLocation.kind === 151 || @@ -26275,13 +26340,13 @@ var ts; } } switch (location.kind) { - case 279: + case 284: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; case 244: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 279 || ts.isAmbientModule(location)) { + if (location.kind === 284 || ts.isAmbientModule(location)) { if (result = moduleExports.get("default")) { var localSymbol = ts.getLocalSymbolForExportDefault(result); if (localSymbol && (result.flags & meaning) && localSymbol.escapedName === name) { @@ -26398,8 +26463,8 @@ var ts; location = location.parent; } break; - case 304: - case 297: + case 309: + case 302: location = ts.getJSDocHost(location); break; } @@ -26414,7 +26479,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 279); + ts.Debug.assert(lastLocation.kind === 284); if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) { return lastLocation.symbol; } @@ -27168,7 +27233,7 @@ var ts; function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias) { var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!(symbol.flags & (1536 | 3)) && !ts.getDeclarationOfKind(symbol, 279)) { + if (!(symbol.flags & (1536 | 3)) && !ts.getDeclarationOfKind(symbol, 284)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; @@ -27497,7 +27562,7 @@ var ts; } } switch (location.kind) { - case 279: + case 284: if (!ts.isExternalOrCommonJsModule(location)) { break; } @@ -27685,10 +27750,10 @@ var ts; return node && getSymbolOfNode(node); } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 279 && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 284 && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 279 && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 284 && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -28121,7 +28186,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 279 || declaration.parent.kind === 245; + return declaration.parent.kind === 284 || declaration.parent.kind === 245; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return (!!(context.flags & 4096) || (context.visitedTypes && context.visitedTypes.has(typeId))) && @@ -28489,7 +28554,7 @@ var ts; function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) { var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 151); if (!parameterDeclaration && !isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 299); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 304); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { @@ -28631,7 +28696,7 @@ var ts; return top; } function getSpecifierForModuleSymbol(symbol, context) { - var file = ts.getDeclarationOfKind(symbol, 279); + var file = ts.getDeclarationOfKind(symbol, 284); if (file && file.moduleName !== undefined) { return file.moduleName; } @@ -28874,7 +28939,7 @@ var ts; ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 279 || ts.isAmbientModule(location); + return location.kind === 284 || ts.isAmbientModule(location); } function getNameOfSymbolFromNameType(symbol, context) { var nameType = symbol.nameType; @@ -28940,8 +29005,8 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 297: - case 304: + case 302: + case 309: return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent)); case 186: return isDeclarationVisible(node.parent.parent); @@ -28962,7 +29027,7 @@ var ts; } var parent = getDeclarationContainer(node); if (!(ts.getCombinedModifierFlags(node) & 1) && - !(node.kind !== 248 && parent.kind !== 279 && parent.flags & 4194304)) { + !(node.kind !== 248 && parent.kind !== 284 && parent.flags & 4194304)) { return isGlobalSourceFile(parent); } return isDeclarationVisible(parent); @@ -28996,7 +29061,7 @@ var ts; case 253: return false; case 150: - case 279: + case 284: case 247: return true; case 254: @@ -29975,15 +30040,15 @@ var ts; case 155: case 165: case 166: - case 289: + case 294: case 239: case 156: case 196: case 197: case 242: - case 303: - case 304: - case 297: + case 308: + case 309: + case 302: case 181: case 175: var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); @@ -31683,10 +31748,10 @@ var ts; return result; } function isJSDocOptionalParameter(node) { - return ts.isInJSFile(node) && (node.type && node.type.kind === 288 + return ts.isInJSFile(node) && (node.type && node.type.kind === 293 || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 288; + return isBracketed || !!typeExpression && typeExpression.type.kind === 293; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -31719,7 +31784,7 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 288; + return isBracketed || !!typeExpression && typeExpression.type.kind === 293; } function createIdentifierTypePredicate(parameterName, parameterIndex, type) { return { kind: 1, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; @@ -32382,7 +32447,7 @@ var ts; } function getConstrainedTypeVariable(typeVariable, node) { var constraints; - while (node && !ts.isStatement(node) && node.kind !== 291) { + while (node && !ts.isStatement(node) && node.kind !== 296) { var parent = node.parent; if (parent.kind === 175 && node === parent.trueType) { var constraint = getImpliedConstraint(typeVariable, parent.checkType, parent.extendsType); @@ -33804,8 +33869,8 @@ var ts; function getTypeFromTypeNode(node) { switch (node.kind) { case 120: - case 284: - case 285: + case 289: + case 290: return anyType; case 143: return unknownType; @@ -33852,23 +33917,23 @@ var ts; return getTypeFromUnionTypeNode(node); case 174: return getTypeFromIntersectionTypeNode(node); - case 286: + case 291: return getTypeFromJSDocNullableTypeNode(node); - case 288: + case 293: return addOptionality(getTypeFromTypeNode(node.type)); case 177: case 172: - case 287: - case 283: + case 292: + case 288: return getTypeFromTypeNode(node.type); - case 290: + case 295: return getTypeFromJSDocVariadicType(node); case 165: case 166: case 168: - case 292: - case 289: - case 293: + case 297: + case 294: + case 298: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); case 179: return getTypeFromTypeOperatorNode(node); @@ -36798,7 +36863,7 @@ var ts; return; } break; - case 289: + case 294: error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; case 239: @@ -38788,7 +38853,7 @@ var ts; return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || node.kind === 245 || - node.kind === 279 || + node.kind === 284 || node.kind === 154; }); } @@ -38889,7 +38954,7 @@ var ts; } else if (declaration.kind === 209) { var container = ts.getThisContainer(node, false); - while (container.kind !== 279) { + while (container.kind !== 284) { if (container.parent === declaration) { if (container.kind === 154 && ts.hasModifier(container, 32)) { getNodeLinks(declaration).flags |= 16777216; @@ -39237,7 +39302,7 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 289) { + if (jsdocType && jsdocType.kind === 294) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -44281,7 +44346,7 @@ var ts; checkAsyncFunctionReturnType(node, returnTypeNode); } } - if (node.kind !== 162 && node.kind !== 289) { + if (node.kind !== 162 && node.kind !== 294) { registerForUnusedIdentifiersCheck(node); } } @@ -44940,8 +45005,8 @@ var ts; switch (d.kind) { case 241: case 242: - case 304: - case 297: + case 309: + case 302: return 2; case 244: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 @@ -44950,7 +45015,7 @@ var ts; case 240: case 243: return 2 | 1; - case 279: + case 284: return 2 | 1 | 4; case 254: if (!ts.isEntityNameExpression(d.expression)) { @@ -45422,7 +45487,7 @@ var ts; checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 279: + case 284: case 244: case 218: case 246: @@ -45750,7 +45815,7 @@ var ts; return; } var parent = getDeclarationContainer(node); - if (parent.kind === 279 && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 284 && ts.isExternalOrCommonJsModule(parent)) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } @@ -45762,7 +45827,7 @@ var ts; return; } var parent = getDeclarationContainer(node); - if (parent.kind === 279 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024) { + if (parent.kind === 284 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } @@ -45790,7 +45855,7 @@ var ts; (container.kind === 218 && ts.isFunctionLike(container.parent) || container.kind === 245 || container.kind === 244 || - container.kind === 279); + container.kind === 284); if (!namesShareScope) { var name = symbolToString(localDeclarationSymbol); error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name, name); @@ -47338,7 +47403,7 @@ var ts; return false; } var inAmbientExternalModule = node.parent.kind === 245 && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 279 && !inAmbientExternalModule) { + if (node.parent.kind !== 284 && !inAmbientExternalModule) { error(moduleName, node.kind === 255 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); @@ -47449,7 +47514,7 @@ var ts; var inAmbientExternalModule = node.parent.kind === 245 && ts.isAmbientModule(node.parent.parent); var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 245 && !node.moduleSpecifier && node.flags & 4194304; - if (node.parent.kind !== 279 && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + if (node.parent.kind !== 284 && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -47465,7 +47530,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 279 || node.parent.kind === 245 || node.parent.kind === 244; + var isInAppropriateContext = node.parent.kind === 284 || node.parent.kind === 245 || node.parent.kind === 244; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -47491,7 +47556,7 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { return; } - var container = node.parent.kind === 279 ? node.parent : node.parent.parent; + var container = node.parent.kind === 284 ? node.parent : node.parent.parent; if (container.kind === 244 && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); @@ -47650,31 +47715,31 @@ var ts; return checkInferType(node); case 183: return checkImportType(node); - case 295: + case 300: return checkJSDocAugmentsTag(node); - case 304: - case 297: - return checkJSDocTypeAliasTag(node); - case 303: - return checkJSDocTemplateTag(node); + case 309: case 302: + return checkJSDocTypeAliasTag(node); + case 308: + return checkJSDocTemplateTag(node); + case 307: return checkJSDocTypeTag(node); - case 299: + case 304: return checkJSDocParameterTag(node); - case 289: + case 294: checkJSDocFunctionType(node); - case 287: - case 286: - case 284: - case 285: case 292: + case 291: + case 289: + case 290: + case 297: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 290: + case 295: checkJSDocVariadicType(node); return; - case 283: + case 288: return checkSourceElement(node.type); case 180: return checkIndexedAccessType(node); @@ -47947,7 +48012,7 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 279: + case 284: if (!ts.isExternalOrCommonJsModule(location)) break; case 244: @@ -48141,10 +48206,10 @@ var ts; return entityNameSymbol; } } - if (entityName.parent.kind === 299) { + if (entityName.parent.kind === 304) { return ts.getParameterSymbolFromJSDoc(entityName.parent); } - if (entityName.parent.kind === 150 && entityName.parent.parent.kind === 303) { + if (entityName.parent.kind === 150 && entityName.parent.parent.kind === 308) { ts.Debug.assert(!ts.isInJSFile(entityName)); var typeParameter = ts.getTypeParameterFromJsDoc(entityName.parent); return typeParameter && typeParameter.symbol; @@ -48184,7 +48249,7 @@ var ts; return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 279) { + if (node.kind === 284) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; @@ -48467,7 +48532,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 && parentSymbol_1.valueDeclaration.kind === 279) { + if (parentSymbol_1.flags & 512 && parentSymbol_1.valueDeclaration.kind === 284) { var symbolFile = parentSymbol_1.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); var symbolIsUmdExport = symbolFile !== referenceFile; @@ -48556,7 +48621,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 279 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 284 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -48942,7 +49007,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 279 && current.flags & 512) { + if (current.valueDeclaration && current.valueDeclaration.kind === 284 && current.flags & 512) { return false; } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { @@ -48974,7 +49039,7 @@ var ts; if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 279); + return ts.getDeclarationOfKind(moduleSymbol, 284); } function initializeTypeChecker() { for (var _i = 0, _a = host.getSourceFiles(); _i < _a.length; _i++) { @@ -49187,7 +49252,7 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 245 || node.parent.kind === 279) { + else if (node.parent.kind === 245 || node.parent.kind === 284) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128) { @@ -49210,7 +49275,7 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 245 || node.parent.kind === 279) { + else if (node.parent.kind === 245 || node.parent.kind === 284) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } else if (node.kind === 151) { @@ -49254,7 +49319,7 @@ var ts; flags |= 1; break; case 80: - var container = node.parent.kind === 279 ? node.parent : node.parent.parent; + var container = node.parent.kind === 284 ? node.parent : node.parent.parent; if (container.kind === 244 && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } @@ -49373,7 +49438,7 @@ var ts; case 151: return false; default: - if (node.parent.kind === 245 || node.parent.kind === 279) { + if (node.parent.kind === 245 || node.parent.kind === 284) { return false; } switch (node.kind) { @@ -50222,7 +50287,7 @@ var ts; if (!links.hasReportedStatementInAmbientContext && ts.isFunctionLike(node.parent)) { return getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); } - if (node.parent.kind === 218 || node.parent.kind === 245 || node.parent.kind === 279) { + if (node.parent.kind === 218 || node.parent.kind === 245 || node.parent.kind === 284) { var links_2 = getNodeLinks(node.parent); if (!links_2.hasReportedStatementInAmbientContext) { return links_2.hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.Statements_are_not_allowed_in_ambient_contexts); @@ -52231,27 +52296,27 @@ var ts; } ts.updateExternalModuleReference = updateExternalModuleReference; function createJSDocTypeExpression(type) { - var node = createSynthesizedNode(283); + var node = createSynthesizedNode(288); node.type = type; return node; } ts.createJSDocTypeExpression = createJSDocTypeExpression; function createJSDocTypeTag(typeExpression, comment) { - var tag = createJSDocTag(302, "type"); + var tag = createJSDocTag(307, "type"); tag.typeExpression = typeExpression; tag.comment = comment; return tag; } ts.createJSDocTypeTag = createJSDocTypeTag; function createJSDocReturnTag(typeExpression, comment) { - var tag = createJSDocTag(300, "returns"); + var tag = createJSDocTag(305, "returns"); tag.typeExpression = typeExpression; tag.comment = comment; return tag; } ts.createJSDocReturnTag = createJSDocReturnTag; function createJSDocParamTag(name, isBracketed, typeExpression, comment) { - var tag = createJSDocTag(299, "param"); + var tag = createJSDocTag(304, "param"); tag.typeExpression = typeExpression; tag.name = name; tag.isBracketed = isBracketed; @@ -52260,7 +52325,7 @@ var ts; } ts.createJSDocParamTag = createJSDocParamTag; function createJSDocComment(comment, tags) { - var node = createSynthesizedNode(291); + var node = createSynthesizedNode(296); node.comment = comment; node.tags = tags; return node; @@ -52513,7 +52578,7 @@ var ts; (typeReferences !== undefined && node.typeReferenceDirectives !== typeReferences) || (libReferences !== undefined && node.libReferenceDirectives !== libReferences) || (hasNoDefaultLib !== undefined && node.hasNoDefaultLib !== hasNoDefaultLib)) { - var updated = createSynthesizedNode(279); + var updated = createSynthesizedNode(284); updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; @@ -52587,28 +52652,28 @@ var ts; } ts.getMutableClone = getMutableClone; function createNotEmittedStatement(original) { - var node = createSynthesizedNode(307); + var node = createSynthesizedNode(312); node.original = original; setTextRange(node, original); return node; } ts.createNotEmittedStatement = createNotEmittedStatement; function createEndOfDeclarationMarker(original) { - var node = createSynthesizedNode(311); + var node = createSynthesizedNode(316); node.emitNode = {}; node.original = original; return node; } ts.createEndOfDeclarationMarker = createEndOfDeclarationMarker; function createMergeDeclarationMarker(original) { - var node = createSynthesizedNode(310); + var node = createSynthesizedNode(315); node.emitNode = {}; node.original = original; return node; } ts.createMergeDeclarationMarker = createMergeDeclarationMarker; function createPartiallyEmittedExpression(expression, original) { - var node = createSynthesizedNode(308); + var node = createSynthesizedNode(313); node.expression = expression; node.original = original; setTextRange(node, original); @@ -52624,7 +52689,7 @@ var ts; ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; function flattenCommaElements(node) { if (ts.nodeIsSynthesized(node) && !ts.isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) { - if (node.kind === 309) { + if (node.kind === 314) { return node.elements; } if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27) { @@ -52634,7 +52699,7 @@ var ts; return node; } function createCommaList(elements) { - var node = createSynthesizedNode(309); + var node = createSynthesizedNode(314); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); return node; } @@ -52647,33 +52712,195 @@ var ts; ts.updateCommaList = updateCommaList; function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = ts.createNode(280); + var node = ts.createNode(285); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; } ts.createBundle = createBundle; - function createUnparsedSourceFile(textOrInputFiles, mapPathOrType, map) { - var node = ts.createNode(281); + var allUnscopedEmitHelpers; + function getAllUnscopedEmitHelpers() { + return allUnscopedEmitHelpers || (allUnscopedEmitHelpers = ts.arrayToMap([ + ts.valuesHelper, + ts.readHelper, + ts.spreadHelper, + ts.restHelper, + ts.decorateHelper, + ts.metadataHelper, + ts.paramHelper, + ts.awaiterHelper, + ts.assignHelper, + ts.awaitHelper, + ts.asyncGeneratorHelper, + ts.asyncDelegator, + ts.asyncValues, + ts.extendsHelper, + ts.templateObjectHelper, + ts.generatorHelper, + ts.importStarHelper, + ts.importDefaultHelper + ], function (helper) { return helper.name; })); + } + function createUnparsedSource() { + var node = ts.createNode(286); + node.prologues = ts.emptyArray; + node.referencedFiles = ts.emptyArray; + node.libReferenceDirectives = ts.emptyArray; + node.getLineAndCharacterOfPosition = function (pos) { return ts.getLineAndCharacterOfPosition(node, pos); }; + return node; + } + function createUnparsedSourceFile(textOrInputFiles, mapPathOrType, mapTextOrStripInternal) { + var node = createUnparsedSource(); + var stripInternal; + var bundleFileInfo; if (!ts.isString(textOrInputFiles)) { ts.Debug.assert(mapPathOrType === "js" || mapPathOrType === "dts"); - node.fileName = mapPathOrType === "js" ? textOrInputFiles.javascriptPath : textOrInputFiles.declarationPath; + node.fileName = (mapPathOrType === "js" ? textOrInputFiles.javascriptPath : textOrInputFiles.declarationPath) || ""; node.sourceMapPath = mapPathOrType === "js" ? textOrInputFiles.javascriptMapPath : textOrInputFiles.declarationMapPath; Object.defineProperties(node, { text: { get: function () { return mapPathOrType === "js" ? textOrInputFiles.javascriptText : textOrInputFiles.declarationText; } }, sourceMapText: { get: function () { return mapPathOrType === "js" ? textOrInputFiles.javascriptMapText : textOrInputFiles.declarationMapText; } }, }); + if (textOrInputFiles.buildInfo && textOrInputFiles.buildInfo.bundle) { + node.oldFileOfCurrentEmit = textOrInputFiles.oldFileOfCurrentEmit; + ts.Debug.assert(mapTextOrStripInternal === undefined || typeof mapTextOrStripInternal === "boolean"); + stripInternal = mapTextOrStripInternal; + bundleFileInfo = mapPathOrType === "js" ? textOrInputFiles.buildInfo.bundle.js : textOrInputFiles.buildInfo.bundle.dts; + if (node.oldFileOfCurrentEmit) { + parseOldFileOfCurrentEmit(node, ts.Debug.assertDefined(bundleFileInfo)); + return node; + } + } } else { + node.fileName = ""; node.text = textOrInputFiles; node.sourceMapPath = mapPathOrType; - node.sourceMapText = map; + node.sourceMapText = mapTextOrStripInternal; } + ts.Debug.assert(!node.oldFileOfCurrentEmit); + parseUnparsedSourceFile(node, bundleFileInfo, stripInternal); return node; } ts.createUnparsedSourceFile = createUnparsedSourceFile; - function createInputFiles(javascriptTextOrReadFileText, declarationTextOrJavascriptPath, javascriptMapPath, javascriptMapTextOrDeclarationPath, declarationMapPath, declarationMapText) { - var node = ts.createNode(282); + function parseUnparsedSourceFile(node, bundleFileInfo, stripInternal) { + var prologues; + var helpers; + var referencedFiles; + var typeReferenceDirectives; + var libReferenceDirectives; + var texts; + for (var _i = 0, _a = bundleFileInfo ? bundleFileInfo.sections : ts.emptyArray; _i < _a.length; _i++) { + var section = _a[_i]; + switch (section.kind) { + case "prologue": + (prologues || (prologues = [])).push(createUnparsedNode(section, node)); + break; + case "emitHelpers": + (helpers || (helpers = [])).push(getAllUnscopedEmitHelpers().get(section.data)); + break; + case "no-default-lib": + node.hasNoDefaultLib = true; + break; + case "reference": + (referencedFiles || (referencedFiles = [])).push({ pos: -1, end: -1, fileName: section.data }); + break; + case "type": + (typeReferenceDirectives || (typeReferenceDirectives = [])).push(section.data); + break; + case "lib": + (libReferenceDirectives || (libReferenceDirectives = [])).push({ pos: -1, end: -1, fileName: section.data }); + break; + case "prepend": + var prependNode = createUnparsedNode(section, node); + var prependTexts = void 0; + for (var _b = 0, _c = section.texts; _b < _c.length; _b++) { + var text = _c[_b]; + if (!stripInternal || text.kind !== "internal") { + (prependTexts || (prependTexts = [])).push(createUnparsedNode(text, node)); + } + } + prependNode.texts = prependTexts || ts.emptyArray; + (texts || (texts = [])).push(prependNode); + break; + case "internal": + if (stripInternal) + break; + case "text": + (texts || (texts = [])).push(createUnparsedNode(section, node)); + break; + default: + ts.Debug.assertNever(section); + } + } + node.prologues = prologues || ts.emptyArray; + node.helpers = helpers; + node.referencedFiles = referencedFiles || ts.emptyArray; + node.typeReferenceDirectives = typeReferenceDirectives; + node.libReferenceDirectives = libReferenceDirectives || ts.emptyArray; + node.texts = texts || [createUnparsedNode({ kind: "text", pos: 0, end: node.text.length }, node)]; + } + function parseOldFileOfCurrentEmit(node, bundleFileInfo) { + ts.Debug.assert(!!node.oldFileOfCurrentEmit); + var texts; + var syntheticReferences; + for (var _i = 0, _a = bundleFileInfo.sections; _i < _a.length; _i++) { + var section = _a[_i]; + switch (section.kind) { + case "internal": + case "text": + (texts || (texts = [])).push(createUnparsedNode(section, node)); + break; + case "no-default-lib": + case "reference": + case "type": + case "lib": + (syntheticReferences || (syntheticReferences = [])).push(createUnparsedSyntheticReference(section, node)); + break; + case "prologue": + case "emitHelpers": + case "prepend": + break; + default: + ts.Debug.assertNever(section); + } + } + node.texts = texts || ts.emptyArray; + node.helpers = ts.map(bundleFileInfo.sources && bundleFileInfo.sources.helpers, function (name) { return getAllUnscopedEmitHelpers().get(name); }); + node.syntheticReferences = syntheticReferences; + return node; + } + function mapBundleFileSectionKindToSyntaxKind(kind) { + switch (kind) { + case "prologue": return 279; + case "prepend": return 280; + case "internal": return 282; + case "text": return 281; + case "emitHelpers": + case "no-default-lib": + case "reference": + case "type": + case "lib": + return ts.Debug.fail("BundleFileSectionKind: " + kind + " not yet mapped to SyntaxKind"); + default: + return ts.Debug.assertNever(kind); + } + } + function createUnparsedNode(section, parent) { + var node = ts.createNode(mapBundleFileSectionKindToSyntaxKind(section.kind), section.pos, section.end); + node.parent = parent; + node.data = section.data; + return node; + } + function createUnparsedSyntheticReference(section, parent) { + var node = ts.createNode(283, section.pos, section.end); + node.parent = parent; + node.data = section.data; + node.section = section; + return node; + } + function createInputFiles(javascriptTextOrReadFileText, declarationTextOrJavascriptPath, javascriptMapPath, javascriptMapTextOrDeclarationPath, declarationMapPath, declarationMapTextOrBuildInfoPath, javascriptPath, declarationPath, buildInfoPath, buildInfo, oldFileOfCurrentEmit) { + var node = ts.createNode(287); if (!ts.isString(javascriptTextOrReadFileText)) { var cache_1 = ts.createMap(); var textGetter_1 = function (path) { @@ -52690,15 +52917,25 @@ var ts; var result = textGetter_1(path); return result !== undefined ? result : "/* Input file " + path + " was missing */\r\n"; }; + var buildInfo_1; + var getBuildInfo_1 = function (getText) { + if (buildInfo_1 === undefined) { + var result = getText(); + buildInfo_1 = result !== undefined ? JSON.parse(result) : false; + } + return buildInfo_1 || undefined; + }; node.javascriptPath = declarationTextOrJavascriptPath; node.javascriptMapPath = javascriptMapPath; node.declarationPath = ts.Debug.assertDefined(javascriptMapTextOrDeclarationPath); node.declarationMapPath = declarationMapPath; + node.buildInfoPath = declarationMapTextOrBuildInfoPath; Object.defineProperties(node, { javascriptText: { get: function () { return definedTextGetter_1(declarationTextOrJavascriptPath); } }, javascriptMapText: { get: function () { return textGetter_1(javascriptMapPath); } }, declarationText: { get: function () { return definedTextGetter_1(ts.Debug.assertDefined(javascriptMapTextOrDeclarationPath)); } }, - declarationMapText: { get: function () { return textGetter_1(declarationMapPath); } } + declarationMapText: { get: function () { return textGetter_1(declarationMapPath); } }, + buildInfo: { get: function () { return getBuildInfo_1(function () { return textGetter_1(declarationMapTextOrBuildInfoPath); }); } } }); } else { @@ -52707,7 +52944,12 @@ var ts; node.javascriptMapText = javascriptMapTextOrDeclarationPath; node.declarationText = declarationTextOrJavascriptPath; node.declarationMapPath = declarationMapPath; - node.declarationMapText = declarationMapText; + node.declarationMapText = declarationMapTextOrBuildInfoPath; + node.javascriptPath = javascriptPath; + node.declarationPath = declarationPath, + node.buildInfoPath = buildInfoPath; + node.buildInfo = buildInfo; + node.oldFileOfCurrentEmit = oldFileOfCurrentEmit; } return node; } @@ -52811,7 +53053,7 @@ var ts; function getOrCreateEmitNode(node) { if (!node.emitNode) { if (ts.isParseTreeNode(node)) { - if (node.kind === 279) { + if (node.kind === 284) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(ts.getParseTreeNode(ts.getSourceFileOfNode(node))); @@ -53184,36 +53426,36 @@ var ts; return ts.setEmitFlags(ts.createIdentifier(name), 4096 | 2); } ts.getHelperName = getHelperName; - var valuesHelper = { + ts.valuesHelper = { name: "typescript:values", scoped: false, text: "\n var __values = (this && this.__values) || function (o) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator], i = 0;\n if (m) return m.call(o);\n return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n };" }; function createValuesHelper(context, expression, location) { - context.requestEmitHelper(valuesHelper); + context.requestEmitHelper(ts.valuesHelper); return ts.setTextRange(ts.createCall(getHelperName("__values"), undefined, [expression]), location); } ts.createValuesHelper = createValuesHelper; - var readHelper = { + ts.readHelper = { name: "typescript:read", scoped: false, text: "\n var __read = (this && this.__read) || function (o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n };" }; function createReadHelper(context, iteratorRecord, count, location) { - context.requestEmitHelper(readHelper); + context.requestEmitHelper(ts.readHelper); return ts.setTextRange(ts.createCall(getHelperName("__read"), undefined, count !== undefined ? [iteratorRecord, ts.createLiteral(count)] : [iteratorRecord]), location); } ts.createReadHelper = createReadHelper; - var spreadHelper = { + ts.spreadHelper = { name: "typescript:spread", scoped: false, text: "\n var __spread = (this && this.__spread) || function () {\n for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));\n return ar;\n };" }; function createSpreadHelper(context, argumentList, location) { - context.requestEmitHelper(readHelper); - context.requestEmitHelper(spreadHelper); + context.requestEmitHelper(ts.readHelper); + context.requestEmitHelper(ts.spreadHelper); return ts.setTextRange(ts.createCall(getHelperName("__spread"), undefined, argumentList), location); } ts.createSpreadHelper = createSpreadHelper; @@ -53817,7 +54059,7 @@ var ts; case 190: case 189: case 213: - case 308: + case 313: node = node.expression; continue; } @@ -53833,7 +54075,7 @@ var ts; ts.parenthesizeConciseBody = parenthesizeConciseBody; function isCommaSequence(node) { return node.kind === 204 && node.operatorToken.kind === 27 || - node.kind === 309; + node.kind === 314; } ts.isCommaSequence = isCommaSequence; function isOuterExpression(node, kinds) { @@ -53845,7 +54087,7 @@ var ts; case 212: case 213: return (kinds & 2) !== 0; - case 308: + case 313: return (kinds & 4) !== 0; } return false; @@ -53882,7 +54124,7 @@ var ts; case 194: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); case 212: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); case 213: return ts.updateNonNullExpression(outerExpression, expression); - case 308: return ts.updatePartiallyEmittedExpression(outerExpression, expression); + case 313: return ts.updatePartiallyEmittedExpression(outerExpression, expression); } } function isIgnorableParen(node) { @@ -54515,11 +54757,11 @@ var ts; return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); case 278: return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 279: + case 284: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); - case 308: + case 313: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 309: + case 314: return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: return node; @@ -54557,7 +54799,7 @@ var ts; case 220: case 210: case 236: - case 307: + case 312: break; case 148: result = reduceNode(node.left, cbNode, result); @@ -54919,13 +55161,13 @@ var ts; result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 279: + case 284: result = reduceNodes(node.statements, cbNodes, result); break; - case 308: + case 313: result = reduceNode(node.expression, cbNode, result); break; - case 309: + case 314: result = reduceNodes(node.elements, cbNodes, result); break; default: @@ -55171,7 +55413,7 @@ var ts; } exit(); } - function appendSourceMap(generatedLine, generatedCharacter, map, sourceMapPath) { + function appendSourceMap(generatedLine, generatedCharacter, map, sourceMapPath, start, end) { var _a; ts.Debug.assert(generatedLine >= pendingGeneratedLine, "generatedLine cannot backtrack"); ts.Debug.assert(generatedCharacter >= 0, "generatedCharacter cannot be negative"); @@ -55180,6 +55422,14 @@ var ts; var nameIndexToNewNameIndexMap; var mappingIterator = decodeMappings(map.mappings); for (var _b = mappingIterator.next(), raw = _b.value, done = _b.done; !done; _a = mappingIterator.next(), raw = _a.value, done = _a.done, _a) { + if (end && (raw.generatedLine > end.line || + (raw.generatedLine === end.line && raw.generatedCharacter > end.character))) { + break; + } + if (start && (raw.generatedLine < start.line || + (start.line === raw.generatedLine && raw.generatedCharacter < start.character))) { + continue; + } var newSourceIndex = void 0; var newSourceLine = void 0; var newSourceCharacter = void 0; @@ -55206,8 +55456,10 @@ var ts; } } } - var newGeneratedLine = raw.generatedLine + generatedLine; - var newGeneratedCharacter = raw.generatedLine === 0 ? raw.generatedCharacter + generatedCharacter : raw.generatedCharacter; + var rawGeneratedLine = raw.generatedLine - (start ? start.line : 0); + var newGeneratedLine = rawGeneratedLine + generatedLine; + var rawGeneratedCharacter = start && start.line === raw.generatedLine ? raw.generatedCharacter - start.character : raw.generatedCharacter; + var newGeneratedCharacter = rawGeneratedLine === 0 ? rawGeneratedCharacter + generatedCharacter : rawGeneratedCharacter; addMapping(newGeneratedLine, newGeneratedCharacter, newSourceIndex, newSourceLine, newSourceCharacter, newNameIndex); } exit(); @@ -55654,7 +55906,7 @@ var ts; function chainBundle(transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 279 ? transformSourceFile(node) : transformBundle(node); + return node.kind === 284 ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return ts.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -56168,13 +56420,13 @@ var ts; function makeAssignmentElement(name) { return name; } - var restHelper = { + ts.restHelper = { name: "typescript:rest", scoped: false, text: "\n var __rest = (this && this.__rest) || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)\n t[p[i]] = s[p[i]];\n return t;\n };" }; function createRestCall(context, value, elements, computedTempVariables, location) { - context.requestEmitHelper(restHelper); + context.requestEmitHelper(ts.restHelper); var propertyNames = []; var computedTempVariableOffset = 0; for (var i = 0; i < elements.length - 1; i++) { @@ -56224,14 +56476,14 @@ var ts; var pendingExpressions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 280) { + if (node.kind === 285) { return transformBundle(node); } return transformSourceFile(node); } function transformBundle(node) { return ts.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 282) { + if (prepend.kind === 287) { return ts.createUnparsedSourceFile(prepend, "js"); } return prepend; @@ -56262,7 +56514,7 @@ var ts; } function onBeforeVisitNode(node) { switch (node.kind) { - case 279: + case 284: case 246: case 245: case 218: @@ -57546,7 +57798,7 @@ var ts; function addVarForEnumOrModuleDeclaration(statements, node) { var statement = ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ ts.createVariableDeclaration(ts.getLocalName(node, false, true)) - ], currentLexicalScope.kind === 279 ? 0 : 1)); + ], currentLexicalScope.kind === 284 ? 0 : 1)); ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { @@ -57887,7 +58139,7 @@ var ts; function trySubstituteNamespaceExportedName(node) { if (enabledSubstitutions & applicableSubstitutions && !ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var container = resolver.getReferencedExportContainer(node, false); - if (container && container.kind !== 279) { + if (container && container.kind !== 284) { var substitute = (applicableSubstitutions & 2 && container.kind === 244) || (applicableSubstitutions & 8 && container.kind === 243); if (substitute) { @@ -57936,36 +58188,36 @@ var ts; argumentsArray.push(descriptor); } } - context.requestEmitHelper(decorateHelper); + context.requestEmitHelper(ts.decorateHelper); return ts.setTextRange(ts.createCall(ts.getHelperName("__decorate"), undefined, argumentsArray), location); } - var decorateHelper = { + ts.decorateHelper = { name: "typescript:decorate", scoped: false, priority: 2, text: "\n var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n };" }; function createMetadataHelper(context, metadataKey, metadataValue) { - context.requestEmitHelper(metadataHelper); + context.requestEmitHelper(ts.metadataHelper); return ts.createCall(ts.getHelperName("__metadata"), undefined, [ ts.createLiteral(metadataKey), metadataValue ]); } - var metadataHelper = { + ts.metadataHelper = { name: "typescript:metadata", scoped: false, priority: 3, text: "\n var __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n };" }; function createParamHelper(context, expression, parameterOffset, location) { - context.requestEmitHelper(paramHelper); + context.requestEmitHelper(ts.paramHelper); return ts.setTextRange(ts.createCall(ts.getHelperName("__param"), undefined, [ ts.createLiteral(parameterOffset), expression ]), location); } - var paramHelper = { + ts.paramHelper = { name: "typescript:param", scoped: false, priority: 4, @@ -58389,14 +58641,14 @@ var ts; ], 2)); } ts.createSuperAccessVariableStatement = createSuperAccessVariableStatement; - var awaiterHelper = { + ts.awaiterHelper = { name: "typescript:awaiter", scoped: false, priority: 5, text: "\n var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n };" }; function createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, body) { - context.requestEmitHelper(awaiterHelper); + context.requestEmitHelper(ts.awaiterHelper); var generatorFunc = ts.createFunctionExpression(undefined, ts.createToken(40), undefined, undefined, [], undefined, body); (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 | 524288; return ts.createCall(ts.getHelperName("__awaiter"), undefined, [ @@ -58928,7 +59180,7 @@ var ts; } } ts.transformES2018 = transformES2018; - var assignHelper = { + ts.assignHelper = { name: "typescript:assign", scoped: false, priority: 1, @@ -58938,27 +59190,27 @@ var ts; if (context.getCompilerOptions().target >= 2) { return ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "assign"), undefined, attributesSegments); } - context.requestEmitHelper(assignHelper); + context.requestEmitHelper(ts.assignHelper); return ts.createCall(ts.getHelperName("__assign"), undefined, attributesSegments); } ts.createAssignHelper = createAssignHelper; - var awaitHelper = { + ts.awaitHelper = { name: "typescript:await", scoped: false, text: "\n var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }" }; function createAwaitHelper(context, expression) { - context.requestEmitHelper(awaitHelper); + context.requestEmitHelper(ts.awaitHelper); return ts.createCall(ts.getHelperName("__await"), undefined, [expression]); } - var asyncGeneratorHelper = { + ts.asyncGeneratorHelper = { name: "typescript:asyncGenerator", scoped: false, text: "\n var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n };" }; function createAsyncGeneratorHelper(context, generatorFunc) { - context.requestEmitHelper(awaitHelper); - context.requestEmitHelper(asyncGeneratorHelper); + context.requestEmitHelper(ts.awaitHelper); + context.requestEmitHelper(ts.asyncGeneratorHelper); (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144; return ts.createCall(ts.getHelperName("__asyncGenerator"), undefined, [ ts.createThis(), @@ -58966,23 +59218,23 @@ var ts; generatorFunc ]); } - var asyncDelegator = { + ts.asyncDelegator = { name: "typescript:asyncDelegator", scoped: false, text: "\n var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {\n var i, p;\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\n };" }; function createAsyncDelegatorHelper(context, expression, location) { - context.requestEmitHelper(awaitHelper); - context.requestEmitHelper(asyncDelegator); + context.requestEmitHelper(ts.awaitHelper); + context.requestEmitHelper(ts.asyncDelegator); return ts.setTextRange(ts.createCall(ts.getHelperName("__asyncDelegator"), undefined, [expression]), location); } - var asyncValues = { + ts.asyncValues = { name: "typescript:asyncValues", scoped: false, text: "\n var __asyncValues = (this && this.__asyncValues) || function (o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator], i;\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\n };" }; function createAsyncValuesHelper(context, expression, location) { - context.requestEmitHelper(asyncValues); + context.requestEmitHelper(ts.asyncValues); return ts.setTextRange(ts.createCall(ts.getHelperName("__asyncValues"), undefined, [expression]), location); } })(ts || (ts = {})); @@ -61562,26 +61814,26 @@ var ts; } ts.transformES2015 = transformES2015; function createExtendsHelper(context, name) { - context.requestEmitHelper(extendsHelper); + context.requestEmitHelper(ts.extendsHelper); return ts.createCall(ts.getHelperName("__extends"), undefined, [ name, ts.createFileLevelUniqueName("_super") ]); } function createTemplateObjectHelper(context, cooked, raw) { - context.requestEmitHelper(templateObjectHelper); + context.requestEmitHelper(ts.templateObjectHelper); return ts.createCall(ts.getHelperName("__makeTemplateObject"), undefined, [ cooked, raw ]); } - var extendsHelper = { + ts.extendsHelper = { name: "typescript:extends", scoped: false, priority: 0, text: "\n var __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n })();" }; - var templateObjectHelper = { + ts.templateObjectHelper = { name: "typescript:makeTemplateObject", scoped: false, priority: 0, @@ -63280,10 +63532,10 @@ var ts; } ts.transformGenerators = transformGenerators; function createGeneratorHelper(context, body) { - context.requestEmitHelper(generatorHelper); + context.requestEmitHelper(ts.generatorHelper); return ts.createCall(ts.getHelperName("__generator"), undefined, [ts.createThis(), body]); } - var generatorHelper = { + ts.generatorHelper = { name: "typescript:generator", scoped: false, priority: 6, @@ -63315,7 +63567,7 @@ var ts; context.enableSubstitution(202); context.enableSubstitution(203); context.enableSubstitution(276); - context.enableEmitNotification(279); + context.enableEmitNotification(284); var moduleInfoMap = []; var deferredExports = []; var currentSourceFile; @@ -63520,9 +63772,9 @@ var ts; return visitFunctionDeclaration(node); case 240: return visitClassDeclaration(node); - case 310: + case 315: return visitMergeDeclarationMarker(node); - case 311: + case 316: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); @@ -63640,7 +63892,7 @@ var ts; } var promise = ts.createNew(ts.createIdentifier("Promise"), undefined, [func]); if (compilerOptions.esModuleInterop) { - context.requestEmitHelper(importStarHelper); + context.requestEmitHelper(ts.importStarHelper); return ts.createCall(ts.createPropertyAccess(promise, ts.createIdentifier("then")), undefined, [ts.getHelperName("__importStar")]); } return promise; @@ -63649,7 +63901,7 @@ var ts; var promiseResolveCall = ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Promise"), "resolve"), undefined, []); var requireCall = ts.createCall(ts.createIdentifier("require"), undefined, arg ? [arg] : []); if (compilerOptions.esModuleInterop) { - context.requestEmitHelper(importStarHelper); + context.requestEmitHelper(ts.importStarHelper); requireCall = ts.createCall(ts.getHelperName("__importStar"), undefined, [requireCall]); } var func; @@ -63669,11 +63921,11 @@ var ts; return innerExpr; } if (ts.getImportNeedsImportStarHelper(node)) { - context.requestEmitHelper(importStarHelper); + context.requestEmitHelper(ts.importStarHelper); return ts.createCall(ts.getHelperName("__importStar"), undefined, [innerExpr]); } if (ts.getImportNeedsImportDefaultHelper(node)) { - context.requestEmitHelper(importDefaultHelper); + context.requestEmitHelper(ts.importDefaultHelper); return ts.createCall(ts.getHelperName("__importDefault"), undefined, [innerExpr]); } return innerExpr; @@ -64022,7 +64274,7 @@ var ts; return node; } function onEmitNode(hint, node, emitCallback) { - if (node.kind === 279) { + if (node.kind === 284) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -64082,7 +64334,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 279) { + if (exportContainer && exportContainer.kind === 284) { return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), node); } var importDeclaration = resolver.getReferencedImportDeclaration(node); @@ -64166,12 +64418,12 @@ var ts; scoped: true, text: "\n var __syncRequire = typeof module === \"object\" && typeof module.exports === \"object\";" }; - var importStarHelper = { + ts.importStarHelper = { name: "typescript:commonjsimportstar", scoped: false, text: "\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\n result[\"default\"] = mod;\n return result;\n};" }; - var importDefaultHelper = { + ts.importDefaultHelper = { name: "typescript:commonjsimportdefault", scoped: false, text: "\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};" @@ -64193,7 +64445,7 @@ var ts; context.enableSubstitution(204); context.enableSubstitution(202); context.enableSubstitution(203); - context.enableEmitNotification(279); + context.enableEmitNotification(284); var moduleInfoMap = []; var deferredExports = []; var exportFunctionsMap = []; @@ -64528,7 +64780,7 @@ var ts; } function shouldHoistVariableDeclarationList(node) { return (ts.getEmitFlags(node) & 2097152) === 0 - && (enclosingBlockScopedContainer.kind === 279 + && (enclosingBlockScopedContainer.kind === 284 || (ts.getOriginalNode(node).flags & 3) === 0); } function transformInitializedVariable(node, isExportedDeclaration) { @@ -64726,9 +64978,9 @@ var ts; return visitCatchClause(node); case 218: return visitBlock(node); - case 310: + case 315: return visitMergeDeclarationMarker(node); - case 311: + case 316: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -64865,7 +65117,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 279; + return container !== undefined && container.kind === 284; } else { return false; @@ -64880,7 +65132,7 @@ var ts; return node; } function onEmitNode(hint, node, emitCallback) { - if (node.kind === 279) { + if (node.kind === 284) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -65017,7 +65269,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, false); - if (exportContainer && exportContainer.kind === 279) { + if (exportContainer && exportContainer.kind === 284) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -65045,7 +65297,7 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(279); + context.enableEmitNotification(284); context.enableSubstitution(72); var currentSourceFile; return ts.chainBundle(transformSourceFile); @@ -65515,6 +65767,15 @@ var ts; return result.diagnostics; } ts.getDeclarationDiagnostics = getDeclarationDiagnostics; + function isInternalDeclaration(node, currentSourceFile) { + var parseTreeNode = ts.getParseTreeNode(node); + var leadingCommentRanges = parseTreeNode && ts.getLeadingCommentRangesOfNode(parseTreeNode, currentSourceFile); + return !!ts.forEach(leadingCommentRanges, function (range) { + var comment = currentSourceFile.text.substring(range.pos, range.end); + return ts.stringContains(comment, "@internal"); + }); + } + ts.isInternalDeclaration = isInternalDeclaration; var declarationEmitNodeBuilderFlags = 1024 | 2048 | 4096 | @@ -65632,10 +65893,10 @@ var ts; } } function transformRoot(node) { - if (node.kind === 279 && (node.isDeclarationFile || ts.isSourceFileJS(node))) { + if (node.kind === 284 && (node.isDeclarationFile || ts.isSourceFileJS(node))) { return node; } - if (node.kind === 280) { + if (node.kind === 285) { isBundledEmit = true; refs = ts.createMap(); libs = ts.createMap(); @@ -65665,9 +65926,15 @@ var ts; var updated = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); return ts.updateSourceFileNode(sourceFile, transformAndReplaceLatePaintedStatements(updated), true, [], [], false, []); }), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 282) { - return ts.createUnparsedSourceFile(prepend, "dts"); + if (prepend.kind === 287) { + var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal); + hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib; + collectReferences(sourceFile, refs); + recordTypeReferenceDirectivesIfNecessary(sourceFile.typeReferenceDirectives); + collectLibs(sourceFile, libs); + return sourceFile; } + return prepend; })); bundle.syntheticFileReferences = []; bundle.syntheticTypeReferences = getFileReferencesForUsedTypeReferences(); @@ -65754,7 +66021,7 @@ var ts; } } function collectReferences(sourceFile, ret) { - if (noResolve || ts.isSourceFileJS(sourceFile)) + if (noResolve || (!ts.isUnparsedSource(sourceFile) && ts.isSourceFileJS(sourceFile))) return ret; ts.forEach(sourceFile.referencedFiles, function (f) { var elem = ts.tryResolveScriptReference(host, sourceFile, f); @@ -66408,18 +66675,8 @@ var ts; } errorNameNode = undefined; } - function hasInternalAnnotation(range) { - var comment = currentSourceFile.text.substring(range.pos, range.end); - return ts.stringContains(comment, "@internal"); - } function shouldStripInternal(node) { - if (stripInternal && node) { - var leadingCommentRanges = ts.getLeadingCommentRangesOfNode(ts.getParseTreeNode(node), currentSourceFile); - if (ts.forEach(leadingCommentRanges, hasInternalAnnotation)) { - return true; - } - } - return false; + return !!stripInternal && !!node && isInternalDeclaration(node, currentSourceFile); } function isScopeMarker(node) { return ts.isExportAssignment(node) || ts.isExportDeclaration(node); @@ -66441,7 +66698,7 @@ var ts; function ensureModifierFlags(node, privateDeclaration) { var mask = 3071 ^ (4 | 256); var additions = (needsDeclare && !isAlwaysType(node)) ? 2 : 0; - var parentIsFile = node.parent.kind === 279; + var parentIsFile = node.parent.kind === 284; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= ((privateDeclaration || (isBundledEmit && parentIsFile) || hasScopeMarker(node.parent) ? 0 : 1) | 2); additions = 0; @@ -66629,7 +66886,7 @@ var ts; } ts.noEmitNotification = noEmitNotification; function transformNodes(resolver, host, options, nodes, transformers, allowDtsFiles) { - var enabledSyntaxKindFeatures = new Array(312); + var enabledSyntaxKindFeatures = new Array(317); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentVariableDeclarationsStack = []; @@ -66830,16 +67087,20 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - var infoExtension = ".tsbundleinfo"; var brackets = createBracketsMap(); var syntheticParent = { pos: -1, end: -1 }; - function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, emitOnlyDtsFiles) { + function isBuildInfoFile(file) { + return ts.fileExtensionIs(file, ".tsbuildinfo"); + } + ts.isBuildInfoFile = isBuildInfoFile; + function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, emitOnlyDtsFiles, onlyBuildInfo, includeBuildInfo) { if (emitOnlyDtsFiles === void 0) { emitOnlyDtsFiles = false; } var sourceFiles = ts.isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : ts.getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile); var options = host.getCompilerOptions(); if (options.outFile || options.out) { - if (sourceFiles.length) { - var bundle = ts.createBundle(sourceFiles, host.getPrependNodes()); + var prepends = host.getPrependNodes(); + if (sourceFiles.length || prepends.length) { + var bundle = ts.createBundle(sourceFiles, prepends); var result = action(getOutputPathsFor(bundle, host, emitOnlyDtsFiles), bundle); if (result) { return result; @@ -66847,29 +67108,58 @@ var ts; } } else { - for (var _a = 0, sourceFiles_1 = sourceFiles; _a < sourceFiles_1.length; _a++) { - var sourceFile = sourceFiles_1[_a]; - var result = action(getOutputPathsFor(sourceFile, host, emitOnlyDtsFiles), sourceFile); - if (result) { - return result; + if (!onlyBuildInfo) { + for (var _a = 0, sourceFiles_1 = sourceFiles; _a < sourceFiles_1.length; _a++) { + var sourceFile = sourceFiles_1[_a]; + var result = action(getOutputPathsFor(sourceFile, host, emitOnlyDtsFiles), sourceFile); + if (result) { + return result; + } } } + if (includeBuildInfo) { + var buildInfoPath = getOutputPathForBuildInfo(host.getCompilerOptions()); + if (buildInfoPath) + return action({ buildInfoPath: buildInfoPath }, undefined); + } } } ts.forEachEmittedFile = forEachEmittedFile; + function getOutputPathForBuildInfo(options) { + var configFile = options.configFilePath; + if (!configFile || !ts.isIncrementalCompilation(options)) + return undefined; + if (options.tsBuildInfoFile) + return options.tsBuildInfoFile; + var outPath = options.outFile || options.out; + var buildInfoExtensionLess; + if (outPath) { + buildInfoExtensionLess = ts.removeFileExtension(outPath); + } + else { + var configFileExtensionLess = ts.removeFileExtension(configFile); + buildInfoExtensionLess = options.outDir ? + options.rootDir ? + ts.resolvePath(options.outDir, ts.getRelativePathFromDirectory(options.rootDir, configFileExtensionLess, true)) : + ts.combinePaths(options.outDir, ts.getBaseFileName(configFileExtensionLess)) : + configFileExtensionLess; + } + return buildInfoExtensionLess + ".tsbuildinfo"; + } + ts.getOutputPathForBuildInfo = getOutputPathForBuildInfo; function getOutputPathsForBundle(options, forceDtsPaths) { var outPath = options.outFile || options.out; var jsFilePath = options.emitDeclarationOnly ? undefined : outPath; var sourceMapFilePath = jsFilePath && getSourceMapFilePath(jsFilePath, options); var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.removeFileExtension(outPath) + ".d.ts" : undefined; var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; - var bundleInfoPath = options.references && jsFilePath ? (ts.removeFileExtension(jsFilePath) + infoExtension) : undefined; - return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, bundleInfoPath: bundleInfoPath }; + var buildInfoPath = getOutputPathForBuildInfo(options); + return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: buildInfoPath }; } ts.getOutputPathsForBundle = getOutputPathsForBundle; function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 280) { + if (sourceFile.kind === 285) { return getOutputPathsForBundle(options, forceDtsPaths); } else { @@ -66881,19 +67171,13 @@ var ts; var isJs = ts.isSourceFileJS(sourceFile); var declarationFilePath = ((forceDtsPaths || ts.getEmitDeclarations(options)) && !isJs) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; - return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, bundleInfoPath: undefined }; + return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: undefined }; } } ts.getOutputPathsFor = getOutputPathsFor; function getSourceMapFilePath(jsFilePath, options) { return (options.sourceMap && !options.inlineSourceMap) ? jsFilePath + ".map" : undefined; } - function createDefaultBundleInfo() { - return { - originalOffset: -1, - totalLength: -1 - }; - } function getOutputExtension(sourceFile, options) { if (ts.isJsonSourceFile(sourceFile)) { return ".json"; @@ -66911,7 +67195,7 @@ var ts; return ".js"; } ts.getOutputExtension = getOutputExtension; - function emitFiles(resolver, host, targetSourceFile, emitOnlyDtsFiles, transformers, declarationTransformers) { + function emitFiles(resolver, host, targetSourceFile, emitOnlyDtsFiles, transformers, declarationTransformers, onlyBuildInfo) { var compilerOptions = host.getCompilerOptions(); var sourceMapDataList = (compilerOptions.sourceMap || compilerOptions.inlineSourceMap || ts.getAreDeclarationMapsEnabled(compilerOptions)) ? [] : undefined; var emittedFilesList = compilerOptions.listEmittedFiles ? [] : undefined; @@ -66919,11 +67203,11 @@ var ts; var newLine = ts.getNewLineCharacter(compilerOptions, function () { return host.getNewLine(); }); var writer = ts.createTextWriter(newLine); var _a = ts.performance.createTimer("printTime", "beforePrint", "afterPrint"), enter = _a.enter, exit = _a.exit; - var bundleInfo = createDefaultBundleInfo(); + var bundleBuildInfo; var emitSkipped = false; var exportedModulesFromDeclarationEmit; enter(); - forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), emitOnlyDtsFiles); + forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), emitOnlyDtsFiles, onlyBuildInfo, !targetSourceFile); exit(); return { emitSkipped: emitSkipped, @@ -66933,9 +67217,16 @@ var ts; exportedModulesFromDeclarationEmit: exportedModulesFromDeclarationEmit }; function emitSourceFileOrBundle(_a, sourceFileOrBundle) { - var jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, bundleInfoPath = _a.bundleInfoPath; - emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, bundleInfoPath); + var jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath; + if (buildInfoPath && sourceFileOrBundle && ts.isBundle(sourceFileOrBundle)) { + bundleBuildInfo = { + commonSourceDirectory: host.getCommonSourceDirectory(), + sourceFiles: sourceFileOrBundle.sourceFiles.map(function (file) { return file.fileName; }) + }; + } + emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath); emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath); + emitBuildInfo(bundleBuildInfo, buildInfoPath); if (!emitSkipped && emittedFilesList) { if (!emitOnlyDtsFiles) { if (jsFilePath) { @@ -66944,8 +67235,8 @@ var ts; if (sourceMapFilePath) { emittedFilesList.push(sourceMapFilePath); } - if (bundleInfoPath) { - emittedFilesList.push(bundleInfoPath); + if (buildInfoPath) { + emittedFilesList.push(buildInfoPath); } } if (declarationFilePath) { @@ -66956,8 +67247,20 @@ var ts; } } } - function emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, bundleInfoPath) { - if (emitOnlyDtsFiles || !jsFilePath) { + function emitBuildInfo(bundle, buildInfoPath) { + if (!buildInfoPath || targetSourceFile || emitSkipped) + return; + var program = host.getProgramBuildInfo(); + if (!bundle && !program) + return; + if (host.isEmitBlocked(buildInfoPath) || compilerOptions.noEmit) { + emitSkipped = true; + return; + } + ts.writeFile(host, emitterDiagnostics, buildInfoPath, getBuildInfoText({ bundle: bundle, program: program }), false); + } + function emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath) { + if (!sourceFileOrBundle || emitOnlyDtsFiles || !jsFilePath) { return; } if ((jsFilePath && host.isEmitBlocked(jsFilePath)) || compilerOptions.noEmit) { @@ -66975,6 +67278,7 @@ var ts; inlineSourceMap: compilerOptions.inlineSourceMap, inlineSources: compilerOptions.inlineSources, extendedDiagnostics: compilerOptions.extendedDiagnostics, + writeBundleFileInfo: !!bundleBuildInfo }; var printer = createPrinter(printerOptions, { hasGlobalName: resolver.hasGlobalName, @@ -66982,11 +67286,13 @@ var ts; substituteNode: transform.substituteNode, }); ts.Debug.assert(transform.transformed.length === 1, "Should only see one output from the transform"); - printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform.transformed[0], bundleInfoPath, printer, compilerOptions); + printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform.transformed[0], printer, compilerOptions); transform.dispose(); + if (bundleBuildInfo) + bundleBuildInfo.js = printer.bundleFileInfo; } function emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath) { - if (!(declarationFilePath && !ts.isInJSFile(sourceFileOrBundle))) { + if (!sourceFileOrBundle || !(declarationFilePath && !ts.isInJSFile(sourceFileOrBundle))) { return; } var sourceFiles = ts.isSourceFile(sourceFileOrBundle) ? [sourceFileOrBundle] : sourceFileOrBundle.sourceFiles; @@ -67012,6 +67318,8 @@ var ts; inlineSourceMap: compilerOptions.inlineSourceMap, extendedDiagnostics: compilerOptions.extendedDiagnostics, onlyPrintJsDocStyle: true, + writeBundleFileInfo: !!bundleBuildInfo, + recordInternalSection: !!bundleBuildInfo }; var declarationPrinter = createPrinter(printerOptions, { hasGlobalName: resolver.hasGlobalName, @@ -67022,18 +67330,20 @@ var ts; emitSkipped = emitSkipped || declBlocked; if (!declBlocked || emitOnlyDtsFiles) { ts.Debug.assert(declarationTransform.transformed.length === 1, "Should only see one output from the decl transform"); - printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], undefined, declarationPrinter, { + printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], declarationPrinter, { sourceMap: compilerOptions.declarationMap, sourceRoot: compilerOptions.sourceRoot, mapRoot: compilerOptions.mapRoot, extendedDiagnostics: compilerOptions.extendedDiagnostics, }); - if (emitOnlyDtsFiles && declarationTransform.transformed[0].kind === 279) { + if (emitOnlyDtsFiles && declarationTransform.transformed[0].kind === 284) { var sourceFile = declarationTransform.transformed[0]; exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit; } } declarationTransform.dispose(); + if (bundleBuildInfo) + bundleBuildInfo.dts = declarationPrinter.bundleFileInfo; } function collectLinkedAliases(node) { if (ts.isExportAssignment(node)) { @@ -67048,16 +67358,16 @@ var ts; } ts.forEachChild(node, collectLinkedAliases); } - function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, bundleInfoPath, printer, mapOptions) { - var bundle = sourceFileOrBundle.kind === 280 ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 279 ? sourceFileOrBundle : undefined; + function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) { + var bundle = sourceFileOrBundle.kind === 285 ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 284 ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; var sourceMapGenerator; if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) { sourceMapGenerator = ts.createSourceMapGenerator(host, ts.getBaseFileName(ts.normalizeSlashes(jsFilePath)), getSourceRoot(mapOptions), getSourceMapDirectory(mapOptions, jsFilePath, sourceFile), mapOptions); } if (bundle) { - printer.writeBundle(bundle, bundleInfo, writer, sourceMapGenerator); + printer.writeBundle(bundle, writer, sourceMapGenerator); } else { printer.writeFile(sourceFile, writer, sourceMapGenerator); @@ -67084,16 +67394,11 @@ var ts; writer.writeLine(); } ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles); - if (bundleInfoPath) { - bundleInfo.totalLength = writer.getTextPos(); - ts.writeFile(host, emitterDiagnostics, bundleInfoPath, JSON.stringify(bundleInfo, undefined, 2), false); - } writer.clear(); - bundleInfo = createDefaultBundleInfo(); } function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) { return (mapOptions.sourceMap || mapOptions.inlineSourceMap) - && (sourceFileOrBundle.kind !== 279 || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json")); + && (sourceFileOrBundle.kind !== 284 || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json")); } function getSourceRoot(mapOptions) { var sourceRoot = ts.normalizeSlashes(mapOptions.sourceRoot || ""); @@ -67138,6 +67443,152 @@ var ts; } } ts.emitFiles = emitFiles; + function getBuildInfoText(buildInfo) { + return JSON.stringify(buildInfo, undefined, 2); + } + ts.getBuildInfoText = getBuildInfoText; + ts.notImplementedResolver = { + hasGlobalName: ts.notImplemented, + getReferencedExportContainer: ts.notImplemented, + getReferencedImportDeclaration: ts.notImplemented, + getReferencedDeclarationWithCollidingName: ts.notImplemented, + isDeclarationWithCollidingName: ts.notImplemented, + isValueAliasDeclaration: ts.notImplemented, + isReferencedAliasDeclaration: ts.notImplemented, + isTopLevelValueImportEqualsWithEntityName: ts.notImplemented, + getNodeCheckFlags: ts.notImplemented, + isDeclarationVisible: ts.notImplemented, + isLateBound: function (_node) { return false; }, + collectLinkedAliases: ts.notImplemented, + isImplementationOfOverload: ts.notImplemented, + isRequiredInitializedParameter: ts.notImplemented, + isOptionalUninitializedParameterProperty: ts.notImplemented, + isExpandoFunctionDeclaration: ts.notImplemented, + getPropertiesOfContainerFunction: ts.notImplemented, + createTypeOfDeclaration: ts.notImplemented, + createReturnTypeOfSignatureDeclaration: ts.notImplemented, + createTypeOfExpression: ts.notImplemented, + createLiteralConstValue: ts.notImplemented, + isSymbolAccessible: ts.notImplemented, + isEntityNameVisible: ts.notImplemented, + getConstantValue: ts.notImplemented, + getReferencedValueDeclaration: ts.notImplemented, + getTypeReferenceSerializationKind: ts.notImplemented, + isOptionalParameter: ts.notImplemented, + moduleExportsSomeValue: ts.notImplemented, + isArgumentsLocalBinding: ts.notImplemented, + getExternalModuleFileFromDeclaration: ts.notImplemented, + getTypeReferenceDirectivesForEntityName: ts.notImplemented, + getTypeReferenceDirectivesForSymbol: ts.notImplemented, + isLiteralConstDeclaration: ts.notImplemented, + getJsxFactoryEntity: ts.notImplemented, + getAllAccessorDeclarations: ts.notImplemented, + getSymbolOfExternalModuleSpecifier: ts.notImplemented, + isBindingCapturedByNode: ts.notImplemented, + }; + function createSourceFilesFromBundleBuildInfo(bundle) { + var sourceFiles = bundle.sourceFiles.map(function (fileName) { + var sourceFile = ts.createNode(284, 0, 0); + sourceFile.fileName = fileName; + sourceFile.text = ""; + sourceFile.statements = ts.createNodeArray(); + return sourceFile; + }); + var jsBundle = ts.Debug.assertDefined(bundle.js); + ts.forEach(jsBundle.sources && jsBundle.sources.prologues, function (prologueInfo) { + var sourceFile = sourceFiles[prologueInfo.file]; + sourceFile.text = prologueInfo.text; + sourceFile.end = prologueInfo.text.length; + sourceFile.statements = ts.createNodeArray(prologueInfo.directives.map(function (directive) { + var statement = ts.createNode(221, directive.pos, directive.end); + statement.expression = ts.createNode(10, directive.expression.pos, directive.expression.end); + statement.expression.text = directive.expression.text; + return statement; + })); + }); + return sourceFiles; + } + function emitUsingBuildInfo(config, host, getCommandLine) { + var _a = getOutputPathsForBundle(config.options, false), buildInfoPath = _a.buildInfoPath, jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath; + var buildInfoText = host.readFile(ts.Debug.assertDefined(buildInfoPath)); + if (!buildInfoText) + return buildInfoPath; + var jsFileText = host.readFile(ts.Debug.assertDefined(jsFilePath)); + if (!jsFileText) + return jsFilePath; + var sourceMapText = sourceMapFilePath && host.readFile(sourceMapFilePath); + if ((sourceMapFilePath && !sourceMapText) || config.options.inlineSourceMap) + return sourceMapFilePath || "inline sourcemap decoding"; + var declarationText = declarationFilePath && host.readFile(declarationFilePath); + if (declarationFilePath && !declarationText) + return declarationFilePath; + var declarationMapText = declarationMapPath && host.readFile(declarationMapPath); + if ((declarationMapPath && !declarationMapText) || config.options.inlineSourceMap) + return declarationMapPath || "inline sourcemap decoding"; + var buildInfo = JSON.parse(buildInfoText); + if (!buildInfo.bundle || !buildInfo.bundle.js || (declarationText && !buildInfo.bundle.dts)) + return buildInfoPath; + var ownPrependInput = ts.createInputFiles(jsFileText, declarationText, sourceMapFilePath, sourceMapText, declarationMapPath, declarationMapText, jsFilePath, declarationFilePath, buildInfoPath, buildInfo, true); + var outputFiles = []; + var prependNodes = ts.createPrependNodes(config.projectReferences, getCommandLine, function (f) { return host.readFile(f); }); + var sourceFilesForJsEmit = createSourceFilesFromBundleBuildInfo(buildInfo.bundle); + var emitHost = { + getPrependNodes: ts.memoize(function () { return prependNodes.concat([ownPrependInput]); }), + getCanonicalFileName: host.getCanonicalFileName, + getCommonSourceDirectory: function () { return buildInfo.bundle.commonSourceDirectory; }, + getCompilerOptions: function () { return config.options; }, + getCurrentDirectory: function () { return host.getCurrentDirectory(); }, + getNewLine: function () { return host.getNewLine(); }, + getSourceFile: function () { return undefined; }, + getSourceFileByPath: function () { return undefined; }, + getSourceFiles: function () { return sourceFilesForJsEmit; }, + getLibFileFromReference: ts.notImplemented, + isSourceFileFromExternalLibrary: ts.returnFalse, + writeFile: function (name, text, writeByteOrderMark) { + switch (name) { + case jsFilePath: + if (jsFileText === text) + return; + break; + case sourceMapFilePath: + if (sourceMapText === text) + return; + break; + case buildInfoPath: + var newBuildInfo = JSON.parse(text); + newBuildInfo.program = buildInfo.program; + var _a = buildInfo.bundle, js = _a.js, dts = _a.dts, sourceFiles = _a.sourceFiles; + newBuildInfo.bundle.js.sources = js.sources; + if (dts) { + newBuildInfo.bundle.dts.sources = dts.sources; + } + newBuildInfo.bundle.sourceFiles = sourceFiles; + outputFiles.push({ name: name, text: getBuildInfoText(newBuildInfo), writeByteOrderMark: writeByteOrderMark }); + return; + case declarationFilePath: + if (declarationText === text) + return; + break; + case declarationMapPath: + if (declarationMapText === text) + return; + break; + default: + ts.Debug.assertNever(name); + } + outputFiles.push({ name: name, text: text, writeByteOrderMark: writeByteOrderMark }); + }, + isEmitBlocked: ts.returnFalse, + readFile: function (f) { return host.readFile(f); }, + fileExists: function (f) { return host.fileExists(f); }, + directoryExists: host.directoryExists && (function (f) { return host.directoryExists(f); }), + useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, + getProgramBuildInfo: function () { return undefined; } + }; + emitFiles(ts.notImplementedResolver, emitHost, undefined, false, ts.getTransformers(config.options)); + return outputFiles; + } + ts.emitUsingBuildInfo = emitUsingBuildInfo; function createPrinter(printerOptions, handlers) { if (printerOptions === void 0) { printerOptions = {}; } if (handlers === void 0) { handlers = {}; } @@ -67158,6 +67609,10 @@ var ts; var ownWriter; var write = writeBase; var isOwnFileEmit; + var bundleFileInfo = printerOptions.writeBundleFileInfo ? { sections: [] } : undefined; + var recordInternalSection = printerOptions.recordInternalSection; + var sourceFileTextPos = 0; + var sourceFileTextKind = "text"; var sourceMapsDisabled = true; var sourceMapGenerator; var sourceMapSource; @@ -67179,7 +67634,8 @@ var ts; writeNode: writeNode, writeList: writeList, writeFile: writeFile, - writeBundle: writeBundle + writeBundle: writeBundle, + bundleFileInfo: bundleFileInfo }; function printNode(hint, node, sourceFile) { switch (hint) { @@ -67194,9 +67650,9 @@ var ts; break; } switch (node.kind) { - case 279: return printFile(node); - case 280: return printBundle(node); - case 281: return printUnparsedSource(node); + case 284: return printFile(node); + case 285: return printBundle(node); + case 286: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -67206,7 +67662,7 @@ var ts; return endPrint(); } function printBundle(bundle) { - writeBundle(bundle, undefined, beginPrint(), undefined); + writeBundle(bundle, beginPrint(), undefined); return endPrint(); } function printFile(sourceFile) { @@ -67234,7 +67690,49 @@ var ts; reset(); writer = previousWriter; } - function writeBundle(bundle, bundleInfo, output, sourceMapGenerator) { + function getTextPosWithWriteLine() { + return writer.getTextPosWithWriteLine ? writer.getTextPosWithWriteLine() : writer.getTextPos(); + } + function updateOrPushBundleFileTextLike(pos, end, kind) { + var last = ts.lastOrUndefined(bundleFileInfo.sections); + if (last && last.kind === kind) { + last.end = end; + } + else { + bundleFileInfo.sections.push({ pos: pos, end: end, kind: kind }); + } + } + function recordBundleFileInternalSectionStart(node) { + if (recordInternalSection && + bundleFileInfo && + currentSourceFile && + (ts.isDeclaration(node) || ts.isVariableStatement(node)) && + ts.isInternalDeclaration(node, currentSourceFile) && + sourceFileTextKind !== "internal") { + var prevSourceFileTextKind = sourceFileTextKind; + recordBundleFileTextLikeSection(writer.getTextPos()); + sourceFileTextPos = getTextPosWithWriteLine(); + sourceFileTextKind = "internal"; + return prevSourceFileTextKind; + } + return undefined; + } + function recordBundleFileInternalSectionEnd(prevSourceFileTextKind) { + if (prevSourceFileTextKind) { + recordBundleFileTextLikeSection(writer.getTextPos()); + sourceFileTextPos = getTextPosWithWriteLine(); + sourceFileTextKind = prevSourceFileTextKind; + } + } + function recordBundleFileTextLikeSection(end) { + if (sourceFileTextPos < end) { + updateOrPushBundleFileTextLike(sourceFileTextPos, end, sourceFileTextKind); + return true; + } + return false; + } + function writeBundle(bundle, output, sourceMapGenerator) { + var _a; isOwnFileEmit = false; var previousWriter = writer; setWriter(output, sourceMapGenerator); @@ -67242,18 +67740,47 @@ var ts; emitPrologueDirectivesIfNeeded(bundle); emitHelpers(bundle); emitSyntheticTripleSlashReferencesIfNeeded(bundle); - for (var _a = 0, _b = bundle.prepends; _a < _b.length; _a++) { - var prepend = _b[_a]; + for (var _b = 0, _c = bundle.prepends; _b < _c.length; _b++) { + var prepend = _c[_b]; writeLine(); + var pos = writer.getTextPos(); + var savedSections = bundleFileInfo && bundleFileInfo.sections; + if (savedSections) + bundleFileInfo.sections = []; print(4, prepend, undefined); + if (bundleFileInfo) { + var newSections = bundleFileInfo.sections; + bundleFileInfo.sections = savedSections; + if (prepend.oldFileOfCurrentEmit) + (_a = bundleFileInfo.sections).push.apply(_a, newSections); + else { + newSections.forEach(function (section) { return ts.Debug.assert(ts.isBundleFileTextLike(section)); }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prepend", data: prepend.fileName, texts: newSections }); + } + } } - if (bundleInfo) { - bundleInfo.originalOffset = writer.getTextPos(); - } - for (var _c = 0, _d = bundle.sourceFiles; _c < _d.length; _c++) { - var sourceFile = _d[_c]; + sourceFileTextPos = getTextPosWithWriteLine(); + for (var _d = 0, _e = bundle.sourceFiles; _d < _e.length; _d++) { + var sourceFile = _e[_d]; print(0, sourceFile, sourceFile); } + if (bundleFileInfo && bundle.sourceFiles.length) { + var end = writer.getTextPos(); + if (recordBundleFileTextLikeSection(end)) { + var prologues = getPrologueDirectivesFromBundledSourceFiles(bundle); + if (prologues) { + if (!bundleFileInfo.sources) + bundleFileInfo.sources = {}; + bundleFileInfo.sources.prologues = prologues; + } + var helpers = getHelpersFromBundledSourceFiles(bundle); + if (helpers) { + if (!bundleFileInfo.sources) + bundleFileInfo.sources = {}; + bundleFileInfo.sources.helpers = helpers; + } + } + } reset(); writer = previousWriter; } @@ -67323,8 +67850,10 @@ var ts; function emit(node) { if (node === undefined) return; + var prevSourceFileTextKind = recordBundleFileInternalSectionStart(node); var pipelinePhase = getPipelinePhase(0, node); pipelinePhase(4, node); + recordBundleFileInternalSectionEnd(prevSourceFileTextKind); } function emitIdentifierName(node) { if (node === undefined) @@ -67349,11 +67878,11 @@ var ts; return pipelineEmitWithSubstitution; } case 2: - if (!commentsDisabled && node.kind !== 279) { + if (!commentsDisabled && node.kind !== 284) { return pipelineEmitWithComments; } case 3: - if (!sourceMapsDisabled && node.kind !== 279 && !ts.isInJsonFile(node)) { + if (!sourceMapsDisabled && node.kind !== 284 && !ts.isInJsonFile(node)) { return pipelineEmitWithSourceMap; } case 4: @@ -67388,8 +67917,16 @@ var ts; case 16: case 17: return emitLiteral(node); + case 286: + case 280: + return emitUnparsedSourceOrPrepend(node); + case 279: + return writeUnparsedNode(node); case 281: - return emitUnparsedSource(node); + case 282: + return emitUnparsedTextLike(node); + case 283: + return emitUnparsedSyntheticReference(node); case 72: return emitIdentifier(node); case 148: @@ -67427,7 +67964,7 @@ var ts; return emitTypeReference(node); case 165: return emitFunctionType(node); - case 289: + case 294: return emitJSDocFunctionType(node); case 166: return emitConstructorType(node); @@ -67465,20 +68002,20 @@ var ts; return emitLiteralType(node); case 183: return emitImportTypeNode(node); - case 284: + case 289: writePunctuation("*"); return; - case 285: + case 290: writePunctuation("?"); return; - case 286: + case 291: return emitJSDocNullableType(node); - case 287: + case 292: return emitJSDocNonNullableType(node); - case 288: + case 293: return emitJSDocOptionalType(node); case 172: - case 290: + case 295: return emitRestOrJSDocVariadicType(node); case 184: return emitObjectBindingPattern(node); @@ -67606,30 +68143,30 @@ var ts; return emitSpreadAssignment(node); case 278: return emitEnumMember(node); - case 299: - case 305: - return emitJSDocPropertyLikeTag(node); - case 300: - case 302: - case 301: - case 298: - return emitJSDocSimpleTypedTag(node); - case 295: - return emitJSDocAugmentsTag(node); - case 303: - return emitJSDocTemplateTag(node); case 304: + case 310: + return emitJSDocPropertyLikeTag(node); + case 305: + case 307: + case 306: + case 303: + return emitJSDocSimpleTypedTag(node); + case 300: + return emitJSDocAugmentsTag(node); + case 308: + return emitJSDocTemplateTag(node); + case 309: return emitJSDocTypedefTag(node); - case 297: + case 302: return emitJSDocCallbackTag(node); - case 293: + case 298: return emitJSDocSignature(node); - case 292: + case 297: return emitJSDocTypeLiteral(node); - case 296: - case 294: + case 301: + case 299: return emitJSDocSimpleTag(node); - case 291: + case 296: return emitJSDoc(node); } if (ts.isExpression(node)) { @@ -67721,9 +68258,9 @@ var ts; return emitJsxSelfClosingElement(node); case 264: return emitJsxFragment(node); - case 308: + case 313: return emitPartiallyEmittedExpression(node); - case 309: + case 314: return emitCommaList(node); } } @@ -67739,22 +68276,45 @@ var ts; var pipelinePhase = getNextPipelinePhase(1, node); pipelinePhase(hint, substituteNode(hint, node)); } + function getHelpersFromBundledSourceFiles(bundle) { + var result; + if (moduleKind === ts.ModuleKind.None || printerOptions.noEmitHelpers) { + return undefined; + } + var bundledHelpers = ts.createMap(); + for (var _a = 0, _b = bundle.sourceFiles; _a < _b.length; _a++) { + var sourceFile = _b[_a]; + var shouldSkip = ts.getExternalHelpersModuleName(sourceFile) !== undefined; + var helpers = getSortedEmitHelpers(sourceFile); + if (!helpers) + continue; + for (var _c = 0, helpers_3 = helpers; _c < helpers_3.length; _c++) { + var helper = helpers_3[_c]; + if (!helper.scoped && !shouldSkip && !bundledHelpers.get(helper.name)) { + bundledHelpers.set(helper.name, true); + (result || (result = [])).push(helper.name); + } + } + } + return result; + } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 280 ? node : undefined; + var bundle = node.kind === 285 ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } - var numNodes = bundle ? bundle.sourceFiles.length : 1; + var numPrepends = bundle ? bundle.prepends.length : 0; + var numNodes = bundle ? bundle.sourceFiles.length + numPrepends : 1; for (var i = 0; i < numNodes; i++) { - var currentNode = bundle ? bundle.sourceFiles[i] : node; - var sourceFile = ts.isSourceFile(currentNode) ? currentNode : currentSourceFile; - var shouldSkip = printerOptions.noEmitHelpers || ts.getExternalHelpersModuleName(sourceFile) !== undefined; - var shouldBundle = ts.isSourceFile(currentNode) && !isOwnFileEmit; - var helpers = ts.getEmitHelpers(currentNode); + var currentNode = bundle ? i < numPrepends ? bundle.prepends[i] : bundle.sourceFiles[i - numPrepends] : node; + var sourceFile = ts.isSourceFile(currentNode) ? currentNode : ts.isUnparsedSource(currentNode) ? undefined : currentSourceFile; + var shouldSkip = printerOptions.noEmitHelpers || (!!sourceFile && ts.getExternalHelpersModuleName(sourceFile) !== undefined); + var shouldBundle = (ts.isSourceFile(currentNode) || ts.isUnparsedSource(currentNode)) && !isOwnFileEmit; + var helpers = ts.isUnparsedSource(currentNode) ? currentNode.helpers : getSortedEmitHelpers(currentNode); if (helpers) { - for (var _a = 0, _b = ts.stableSort(helpers, ts.compareEmitHelpers); _a < _b.length; _a++) { - var helper = _b[_a]; + for (var _a = 0, helpers_4 = helpers; _a < helpers_4.length; _a++) { + var helper = helpers_4[_a]; if (!helper.scoped) { if (shouldSkip) continue; @@ -67768,18 +68328,25 @@ var ts; else if (bundle) { continue; } + var pos = getTextPosWithWriteLine(); if (typeof helper.text === "string") { writeLines(helper.text); } else { writeLines(helper.text(makeFileLevelOptimisticUniqueName)); } + if (bundleFileInfo) + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "emitHelpers", data: helper.name }); helpersEmitted = true; } } } return helpersEmitted; } + function getSortedEmitHelpers(node) { + var helpers = ts.getEmitHelpers(node); + return helpers && ts.stableSort(helpers, ts.compareEmitHelpers); + } function emitNumericOrBigIntLiteral(node) { emitLiteral(node); } @@ -67793,8 +68360,34 @@ var ts; writeStringLiteral(text); } } - function emitUnparsedSource(unparsed) { - writer.rawWrite(unparsed.text); + function emitUnparsedSourceOrPrepend(unparsed) { + for (var _a = 0, _b = unparsed.texts; _a < _b.length; _a++) { + var text = _b[_a]; + writeLine(); + emit(text); + } + } + function writeUnparsedNode(unparsed) { + writer.rawWrite(unparsed.parent.text.substring(unparsed.pos, unparsed.end)); + } + function emitUnparsedTextLike(unparsed) { + var pos = getTextPosWithWriteLine(); + writeUnparsedNode(unparsed); + if (bundleFileInfo) { + updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 281 ? + "text" : + "internal"); + } + } + function emitUnparsedSyntheticReference(unparsed) { + var pos = getTextPosWithWriteLine(); + writeUnparsedNode(unparsed); + if (bundleFileInfo) { + var section = ts.clone(unparsed.section); + section.pos = pos; + section.end = writer.getTextPos(); + bundleFileInfo.sections.push(section); + } } function emitIdentifier(node) { var writeText = node.symbol ? writeSymbol : write; @@ -67840,7 +68433,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 289 && !node.name) { + if (node.parent && node.parent.kind === 294 && !node.name) { emit(node.type); } else { @@ -68666,7 +69259,7 @@ var ts; emitBlockFunctionBodyWorker(body, true); } function emitBlockFunctionBodyWorker(body, emitBlockFunctionBodyOnSingleLine) { - var statementOffset = emitPrologueDirectives(body.statements, true); + var statementOffset = emitPrologueDirectives(body.statements); var pos = writer.getTextPos(); emitHelpers(body); if (statementOffset === 0 && pos === writer.getTextPos() && emitBlockFunctionBodyOnSingleLine) { @@ -69044,7 +69637,7 @@ var ts; } } if (node.tags) { - if (node.tags.length === 1 && node.tags[0].kind === 302 && !node.comment) { + if (node.tags.length === 1 && node.tags[0].kind === 307 && !node.comment) { writeSpace(); emit(node.tags[0]); } @@ -69078,7 +69671,7 @@ var ts; function emitJSDocTypedefTag(tag) { emitJSDocTagName(tag.tagName); if (tag.typeExpression) { - if (tag.typeExpression.kind === 283) { + if (tag.typeExpression.kind === 288) { emitJSDocTypeExpression(tag.typeExpression); } else { @@ -69097,7 +69690,7 @@ var ts; emit(tag.fullName); } emitJSDocComment(tag.comment); - if (tag.typeExpression && tag.typeExpression.kind === 292) { + if (tag.typeExpression && tag.typeExpression.kind === 297) { emitJSDocTypeLiteral(tag.typeExpression); } } @@ -69179,6 +69772,16 @@ var ts; } function emitSyntheticTripleSlashReferencesIfNeeded(node) { emitTripleSlashDirectives(!!node.hasNoDefaultLib, node.syntheticFileReferences || [], node.syntheticTypeReferences || [], node.syntheticLibReferences || []); + for (var _a = 0, _b = node.prepends; _a < _b.length; _a++) { + var prepend = _b[_a]; + if (ts.isUnparsedSource(prepend) && prepend.syntheticReferences) { + for (var _c = 0, _d = prepend.syntheticReferences; _c < _d.length; _c++) { + var ref = _d[_c]; + emit(ref); + writeLine(); + } + } + } } function emitTripleSlashDirectivesIfNeeded(node) { if (node.isDeclarationFile) @@ -69186,7 +69789,10 @@ var ts; } function emitTripleSlashDirectives(hasNoDefaultLib, files, types, libs) { if (hasNoDefaultLib) { + var pos = writer.getTextPos(); writeComment("/// "); + if (bundleFileInfo) + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "no-default-lib" }); writeLine(); } if (currentSourceFile && currentSourceFile.moduleName) { @@ -69207,17 +69813,26 @@ var ts; } for (var _c = 0, files_1 = files; _c < files_1.length; _c++) { var directive = files_1[_c]; + var pos = writer.getTextPos(); writeComment("/// "); + if (bundleFileInfo) + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference", data: directive.fileName }); writeLine(); } for (var _d = 0, types_19 = types; _d < types_19.length; _d++) { var directive = types_19[_d]; + var pos = writer.getTextPos(); writeComment("/// "); + if (bundleFileInfo) + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "type", data: directive.fileName }); writeLine(); } for (var _e = 0, libs_1 = libs; _e < libs_1.length; _e++) { var directive = libs_1[_e]; + var pos = writer.getTextPos(); writeComment("/// "); + if (bundleFileInfo) + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "lib", data: directive.fileName }); writeLine(); } } @@ -69237,16 +69852,22 @@ var ts; function emitCommaList(node) { emitExpressionList(node, node.elements, 528); } - function emitPrologueDirectives(statements, startWithNewLine, seenPrologueDirectives) { + function emitPrologueDirectives(statements, sourceFile, seenPrologueDirectives) { + var needsToSetSourceFile = !!sourceFile; for (var i = 0; i < statements.length; i++) { var statement = statements[i]; if (ts.isPrologueDirective(statement)) { var shouldEmitPrologueDirective = seenPrologueDirectives ? !seenPrologueDirectives.has(statement.expression.text) : true; if (shouldEmitPrologueDirective) { - if (startWithNewLine || i > 0) { - writeLine(); + if (needsToSetSourceFile) { + needsToSetSourceFile = false; + setSourceFile(sourceFile); } + writeLine(); + var pos = writer.getTextPos(); emit(statement); + if (bundleFileInfo) + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue", data: statement.expression.text }); if (seenPrologueDirectives) { seenPrologueDirectives.set(statement.expression.text, true); } @@ -69258,23 +69879,70 @@ var ts; } return statements.length; } + function emitUnparsedPrologues(prologues, seenPrologueDirectives) { + for (var _a = 0, prologues_1 = prologues; _a < prologues_1.length; _a++) { + var prologue = prologues_1[_a]; + if (!seenPrologueDirectives.has(prologue.data)) { + writeLine(); + var pos = writer.getTextPos(); + emit(prologue); + if (bundleFileInfo) + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue", data: prologue.data }); + if (seenPrologueDirectives) { + seenPrologueDirectives.set(prologue.data, true); + } + } + } + } function emitPrologueDirectivesIfNeeded(sourceFileOrBundle) { if (ts.isSourceFile(sourceFileOrBundle)) { - setSourceFile(sourceFileOrBundle); - emitPrologueDirectives(sourceFileOrBundle.statements); + emitPrologueDirectives(sourceFileOrBundle.statements, sourceFileOrBundle); } else { var seenPrologueDirectives = ts.createMap(); - for (var _a = 0, _b = sourceFileOrBundle.sourceFiles; _a < _b.length; _a++) { - var sourceFile = _b[_a]; - setSourceFile(sourceFile); - emitPrologueDirectives(sourceFile.statements, true, seenPrologueDirectives); + for (var _a = 0, _b = sourceFileOrBundle.prepends; _a < _b.length; _a++) { + var prepend = _b[_a]; + emitUnparsedPrologues(prepend.prologues, seenPrologueDirectives); + } + for (var _c = 0, _d = sourceFileOrBundle.sourceFiles; _c < _d.length; _c++) { + var sourceFile = _d[_c]; + emitPrologueDirectives(sourceFile.statements, sourceFile, seenPrologueDirectives); } setSourceFile(undefined); } } + function getPrologueDirectivesFromBundledSourceFiles(bundle) { + var seenPrologueDirectives = ts.createMap(); + var prologues; + for (var index = 0; index < bundle.sourceFiles.length; index++) { + var sourceFile = bundle.sourceFiles[index]; + var directives = void 0; + var end = 0; + for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { + var statement = _b[_a]; + if (!ts.isPrologueDirective(statement)) + break; + if (seenPrologueDirectives.has(statement.expression.text)) + continue; + seenPrologueDirectives.set(statement.expression.text, true); + (directives || (directives = [])).push({ + pos: statement.pos, + end: statement.end, + expression: { + pos: statement.expression.pos, + end: statement.expression.end, + text: statement.expression.text + } + }); + end = end < statement.end ? statement.end : end; + } + if (directives) + (prologues || (prologues = [])).push({ file: index, text: sourceFile.text.substring(0, end), directives: directives }); + } + return prologues; + } function emitShebangIfNeeded(sourceFileOrBundle) { - if (ts.isSourceFile(sourceFileOrBundle)) { + if (ts.isSourceFile(sourceFileOrBundle) || ts.isUnparsedSource(sourceFileOrBundle)) { var shebang = ts.getShebang(sourceFileOrBundle.text); if (shebang) { writeComment(shebang); @@ -69283,10 +69951,17 @@ var ts; } } else { - for (var _a = 0, _b = sourceFileOrBundle.sourceFiles; _a < _b.length; _a++) { - var sourceFile = _b[_a]; + for (var _a = 0, _b = sourceFileOrBundle.prepends; _a < _b.length; _a++) { + var prepend = _b[_a]; + ts.Debug.assertNode(prepend, ts.isUnparsedSource); + if (emitShebangIfNeeded(prepend)) { + return true; + } + } + for (var _c = 0, _d = sourceFileOrBundle.sourceFiles; _c < _d.length; _c++) { + var sourceFile = _d[_c]; if (emitShebangIfNeeded(sourceFile)) { - break; + return true; } } } @@ -69481,6 +70156,7 @@ var ts; increaseIndent(); } var previousSibling = void 0; + var previousSourceFileTextKind = void 0; var shouldDecreaseIndentAfterEmit = false; for (var i = 0; i < count; i++) { var child = children[start + i]; @@ -69493,6 +70169,7 @@ var ts; emitLeadingCommentsOfPosition(previousSibling.end); } writeDelimiter(format); + recordBundleFileInternalSectionEnd(previousSourceFileTextKind); if (shouldWriteSeparatingLineTerminator(previousSibling, child, format)) { if ((format & (3 | 128)) === 0) { increaseIndent(); @@ -69505,6 +70182,7 @@ var ts; writeSpace(); } } + previousSourceFileTextKind = recordBundleFileInternalSectionStart(child); if (shouldEmitInterveningComments) { if (emitTrailingCommentsOfPosition) { var commentRange = ts.getCommentRange(child); @@ -69531,6 +70209,7 @@ var ts; if (format & 128) { decreaseIndent(); } + recordBundleFileInternalSectionEnd(previousSourceFileTextKind); if (shouldWriteClosingLineTerminator(parentNode, children, format)) { writeLine(); } @@ -69629,7 +70308,6 @@ var ts; if (line.length) { writeLine(); write(line); - writer.rawWrite(newLine); } } } @@ -70074,7 +70752,7 @@ var ts; hasWrittenComment = false; var emitFlags = ts.getEmitFlags(node); var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end; - var isEmittedNode = node.kind !== 307; + var isEmittedNode = node.kind !== 312; var skipLeadingComments = pos < 0 || (emitFlags & 512) !== 0 || node.kind === 11; var skipTrailingComments = end < 0 || (emitFlags & 1024) !== 0 || node.kind === 11; var savedContainerPos = containerPos; @@ -70302,19 +70980,28 @@ var ts; function isTripleSlashComment(commentPos, commentEnd) { return ts.isRecognizedTripleSlashComment(currentSourceFile.text, commentPos, commentEnd); } + function getParsedSourceMap(node) { + if (node.parsedSourceMap === undefined && node.sourceMapText !== undefined) { + node.parsedSourceMap = ts.tryParseRawSourceMap(node.sourceMapText) || false; + } + return node.parsedSourceMap || undefined; + } function pipelineEmitWithSourceMap(hint, node) { var pipelinePhase = getNextPipelinePhase(3, node); - if (ts.isUnparsedSource(node) && node.sourceMapText !== undefined) { - var parsed = ts.tryParseRawSourceMap(node.sourceMapText); - if (parsed) { - sourceMapGenerator.appendSourceMap(writer.getLine(), writer.getColumn(), parsed, node.sourceMapPath); + if (ts.isUnparsedSource(node) || ts.isUnparsedPrepend(node)) { + pipelinePhase(hint, node); + } + else if (ts.isUnparsedNode(node)) { + var parsed = getParsedSourceMap(node.parent); + if (parsed && sourceMapGenerator) { + sourceMapGenerator.appendSourceMap(writer.getLine(), writer.getColumn(), parsed, node.parent.sourceMapPath, node.parent.getLineAndCharacterOfPosition(node.pos), node.parent.getLineAndCharacterOfPosition(node.end)); } pipelinePhase(hint, node); } else { var _a = ts.getSourceMapRange(node), pos = _a.pos, end = _a.end, _b = _a.source, source = _b === void 0 ? sourceMapSource : _b; var emitFlags = ts.getEmitFlags(node); - if (node.kind !== 307 + if (node.kind !== 312 && (emitFlags & 16) === 0 && pos >= 0) { emitSourcePos(source, skipSourceTrivia(source, pos)); @@ -70327,7 +71014,7 @@ var ts; else { pipelinePhase(hint, node); } - if (node.kind !== 307 + if (node.kind !== 312 && (emitFlags & 32) === 0 && end >= 0) { emitSourcePos(source, end); @@ -70901,7 +71588,7 @@ var ts; var value = readFileCache.get(key); if (value !== undefined) return value !== false ? value : undefined; - if (!ts.fileExtensionIs(fileName, ".json")) { + if (!ts.fileExtensionIs(fileName, ".json") && !ts.isBuildInfoFile(fileName)) { return originalReadFile.call(host, fileName); } return setReadFileCache(key, fileName); @@ -70931,7 +71618,7 @@ var ts; var key = toPath(fileName); fileExistsCache.delete(key); var value = readFileCache.get(key); - if (value && value !== data) { + if (value !== undefined && value !== data) { readFileCache.delete(key); sourceFileCache.delete(key); } @@ -71414,7 +72101,8 @@ var ts; getProjectReferenceRedirect: getProjectReferenceRedirect, getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, getResolvedProjectReferenceByPath: getResolvedProjectReferenceByPath, - forEachResolvedProjectReference: forEachResolvedProjectReference + forEachResolvedProjectReference: forEachResolvedProjectReference, + emitBuildInfo: emitBuildInfo }; verifyCompilerOptions(); ts.performance.mark("afterProgram"); @@ -71747,7 +72435,15 @@ var ts; if (ts.contains(missingFilePaths, path)) return false; return host.fileExists(f); - } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {}), { useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); } }); + } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {}), { useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, getProgramBuildInfo: function () { return program.getProgramBuildInfo && program.getProgramBuildInfo(); } }); + } + function emitBuildInfo(writeFileCallback) { + ts.Debug.assert(!options.out && !options.outFile); + ts.performance.mark("beforeEmit"); + var emitResult = ts.emitFiles(ts.notImplementedResolver, getEmitHost(writeFileCallback), undefined, false, undefined, undefined, true); + ts.performance.mark("afterEmit"); + ts.performance.measure("Emit", "beforeEmit", "afterEmit"); + return emitResult; } function getResolvedProjectReferences() { return resolvedProjectReferences; @@ -71756,27 +72452,11 @@ var ts; return projectReferences; } function getPrependNodes() { - if (!projectReferences) { - return ts.emptyArray; - } - var nodes = []; - for (var i = 0; i < projectReferences.length; i++) { - var ref = projectReferences[i]; - var resolvedRefOpts = resolvedProjectReferences[i].commandLine; - if (ref.prepend && resolvedRefOpts && resolvedRefOpts.options) { - var out = resolvedRefOpts.options.outFile || resolvedRefOpts.options.out; - if (!out) - continue; - var _a = ts.getOutputPathsForBundle(resolvedRefOpts.options, true), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath; - var node = ts.createInputFiles(function (fileName) { - var path = toPath(fileName); - var sourceFile = getSourceFileByPath(path); - return sourceFile ? sourceFile.text : filesByName.has(path) ? undefined : host.readFile(path); - }, jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath); - nodes.push(node); - } - } - return nodes; + return createPrependNodes(projectReferences, function (_ref, index) { return resolvedProjectReferences[index].commandLine; }, function (fileName) { + var path = toPath(fileName); + var sourceFile = getSourceFileByPath(path); + return sourceFile ? sourceFile.text : filesByName.has(path) ? undefined : host.readFile(path); + }); } function isSourceFileFromExternalLibrary(file) { return !!sourceFilesFoundSearchingNodeModules.get(file.path); @@ -72732,6 +73412,14 @@ var ts; if (options.declaration === false) { createDiagnosticForOptionName(ts.Diagnostics.Composite_projects_may_not_disable_declaration_emit, "declaration"); } + if (options.incremental === false) { + createDiagnosticForOptionName(ts.Diagnostics.Composite_projects_may_not_disable_incremental_compilation, "declaration"); + } + } + if (options.tsBuildInfoFile) { + if (!ts.isIncrementalCompilation(options)) { + createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "tsBuildInfoFile", "incremental", "composite"); + } } verifyProjectReferences(); if (options.composite) { @@ -72911,6 +73599,7 @@ var ts; } } function verifyProjectReferences() { + var buildInfoPath = !options.noEmit && !options.suppressOutputPathCheck ? ts.getOutputPathForBuildInfo(options) : undefined; forEachProjectReference(projectReferences, resolvedProjectReferences, function (resolvedRef, index, parent) { var ref = (parent ? parent.commandLine.projectReferences : projectReferences)[index]; var parentFile = parent && parent.sourceFile; @@ -72936,6 +73625,10 @@ var ts; createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_prepend_project_0_because_it_does_not_have_outFile_set, ref.path); } } + if (!parent && buildInfoPath && buildInfoPath === ts.getOutputPathForBuildInfo(options)) { + createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_write_file_0_because_it_will_overwrite_tsbuildinfo_file_generated_by_referenced_project_1, buildInfoPath, ref.path); + hasEmitBlockingDiagnostics.set(toPath(buildInfoPath), true); + } }); } function createDiagnosticForOptionPathKeyValue(key, valueIndex, message, arg0, arg1, arg2) { @@ -73079,6 +73772,25 @@ var ts; }; } ts.parseConfigHostFromCompilerHostLike = parseConfigHostFromCompilerHostLike; + function createPrependNodes(projectReferences, getCommandLine, readFile) { + if (!projectReferences) + return ts.emptyArray; + var nodes; + for (var i = 0; i < projectReferences.length; i++) { + var ref = projectReferences[i]; + var resolvedRefOpts = getCommandLine(ref, i); + if (ref.prepend && resolvedRefOpts && resolvedRefOpts.options) { + var out = resolvedRefOpts.options.outFile || resolvedRefOpts.options.out; + if (!out) + continue; + var _a = ts.getOutputPathsForBundle(resolvedRefOpts.options, true), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath; + var node = ts.createInputFiles(readFile, jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, buildInfoPath); + (nodes || (nodes = [])).push(node); + } + } + return nodes || ts.emptyArray; + } + ts.createPrependNodes = createPrependNodes; function resolveProjectReferencePath(hostOrRef, ref) { var passedInRef = ref ? ref : hostOrRef; return ts.resolveConfigFileProjectName(passedInRef.path); @@ -73500,10 +74212,13 @@ var ts; var affectedSignatures = oldState.currentAffectedFilesSignatures; ts.Debug.assert(!oldState.affectedFiles && (!affectedSignatures || !affectedSignatures.size), "Cannot reuse if only few affected files of currentChangedFile were iterated"); } + var changedFilesSet = oldState.changedFilesSet; if (canCopySemanticDiagnostics) { - ts.Debug.assert(!ts.forEachKey(oldState.changedFilesSet, function (path) { return oldState.semanticDiagnosticsPerFile.has(path); }), "Semantic diagnostics shouldnt be available for changed files"); + ts.Debug.assert(!changedFilesSet || !ts.forEachKey(changedFilesSet, function (path) { return oldState.semanticDiagnosticsPerFile.has(path); }), "Semantic diagnostics shouldnt be available for changed files"); + } + if (changedFilesSet) { + ts.copyEntries(changedFilesSet, state.changedFilesSet); } - ts.copyEntries(oldState.changedFilesSet, state.changedFilesSet); if (!compilerOptions.outFile && !compilerOptions.out && oldState.affectedFilesPendingEmit) { state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit; state.affectedFilesPendingEmitIndex = oldState.affectedFilesPendingEmitIndex; @@ -73541,6 +74256,17 @@ var ts; } } }); + if (oldCompilerOptions && + (oldCompilerOptions.outDir !== compilerOptions.outDir || + oldCompilerOptions.declarationDir !== compilerOptions.declarationDir || + (oldCompilerOptions.outFile || oldCompilerOptions.out) !== (compilerOptions.outFile || compilerOptions.out))) { + state.affectedFilesPendingEmit = ts.concatenate(state.affectedFilesPendingEmit, newProgram.getSourceFiles().map(function (f) { return f.path; })); + if (state.affectedFilesPendingEmitIndex === undefined) { + state.affectedFilesPendingEmitIndex = 0; + } + ts.Debug.assert(state.seenAffectedFiles === undefined); + state.seenAffectedFiles = ts.createMap(); + } return state; } function releaseCache(state) { @@ -73704,8 +74430,11 @@ var ts; state.semanticDiagnosticsPerFile.delete(path); return !state.semanticDiagnosticsFromOldState.size; } - function doneWithAffectedFile(state, affected, isPendingEmit) { - if (affected === state.program) { + function doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit) { + if (isBuildInfoEmit) { + state.emittedBuildInfo = true; + } + else if (affected === state.program) { state.changedFilesSet.clear(); state.programEmitComplete = true; } @@ -73719,8 +74448,8 @@ var ts; } } } - function toAffectedFileResult(state, result, affected, isPendingEmit) { - doneWithAffectedFile(state, affected, isPendingEmit); + function toAffectedFileResult(state, result, affected, isPendingEmit, isBuildInfoEmit) { + doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit); return { result: result, affected: affected }; } function getSemanticDiagnosticsOfFile(state, sourceFile, cancellationToken) { @@ -73737,6 +74466,40 @@ var ts; } return diagnostics; } + function getProgramBuildInfo(state) { + if (state.compilerOptions.outFile || state.compilerOptions.out) + return undefined; + var fileInfos = {}; + state.fileInfos.forEach(function (value, key) { + var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key); + fileInfos[key] = signature === undefined ? value : { version: value.version, signature: signature }; + }); + var result = { fileInfos: fileInfos, options: state.compilerOptions }; + if (state.referencedMap) { + var referencedMap_1 = {}; + state.referencedMap.forEach(function (value, key) { + referencedMap_1[key] = ts.arrayFrom(value.keys()); + }); + result.referencedMap = referencedMap_1; + } + if (state.exportedModulesMap) { + var exportedModulesMap_1 = {}; + state.exportedModulesMap.forEach(function (value, key) { + var newValue = state.currentAffectedFilesExportedModulesMap && state.currentAffectedFilesExportedModulesMap.get(key); + if (newValue === undefined) + exportedModulesMap_1[key] = ts.arrayFrom(value.keys()); + else if (newValue) + exportedModulesMap_1[key] = ts.arrayFrom(newValue.keys()); + }); + result.exportedModulesMap = exportedModulesMap_1; + } + if (state.semanticDiagnosticsPerFile) { + var semanticDiagnosticsPerFile_1 = []; + state.semanticDiagnosticsPerFile.forEach(function (_value, key) { return semanticDiagnosticsPerFile_1.push(key); }); + result.semanticDiagnosticsPerFile = semanticDiagnosticsPerFile_1; + } + return result; + } var BuilderProgramKind; (function (BuilderProgramKind) { BuilderProgramKind[BuilderProgramKind["SemanticDiagnosticsBuilderProgram"] = 0] = "SemanticDiagnosticsBuilderProgram"; @@ -73786,6 +74549,7 @@ var ts; var computeHash = host.createHash || ts.generateDjb2Hash; var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState); var backupState; + newProgram.getProgramBuildInfo = function () { return result.getProgramBuildInfo(); }; newProgram = undefined; oldProgram = undefined; oldState = undefined; @@ -73806,6 +74570,7 @@ var ts; releaseCache(state); backupState = undefined; }; + result.getProgramBuildInfo = function () { return getProgramBuildInfo(state); }; if (kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram) { result.getSemanticDiagnosticsOfNextAffectedFile = getSemanticDiagnosticsOfNextAffectedFile; } @@ -73823,7 +74588,11 @@ var ts; if (!state.compilerOptions.out && !state.compilerOptions.outFile) { affected = getNextAffectedFilePendingEmit(state); if (!affected) { - return undefined; + if (state.emittedBuildInfo) { + return undefined; + } + var affected_1 = ts.Debug.assertDefined(state.program); + return toAffectedFileResult(state, affected_1.emitBuildInfo(writeFile || host.writeFile, cancellationToken), affected_1, false, true); } isPendingEmitFile = true; } @@ -73915,6 +74684,51 @@ var ts; } } ts.createBuilderProgram = createBuilderProgram; + function getMapOfReferencedSet(mapLike) { + if (!mapLike) + return undefined; + var map = ts.createMap(); + for (var key in mapLike) { + if (ts.hasProperty(mapLike, key)) { + map.set(key, ts.arrayToSet(mapLike[key])); + } + } + return map; + } + function createBuildProgramUsingProgramBuildInfo(program) { + var fileInfos = ts.createMapFromTemplate(program.fileInfos); + var state = { + fileInfos: fileInfos, + compilerOptions: program.options, + referencedMap: getMapOfReferencedSet(program.referencedMap), + exportedModulesMap: getMapOfReferencedSet(program.exportedModulesMap), + semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && ts.arrayToMap(program.semanticDiagnosticsPerFile, ts.identity, function () { return ts.emptyArray; }) + }; + return { + getState: function () { return state; }, + backupState: ts.noop, + restoreState: ts.noop, + getProgram: ts.notImplemented, + getProgramOrUndefined: function () { return undefined; }, + releaseProgram: ts.noop, + getCompilerOptions: function () { return state.compilerOptions; }, + getSourceFile: ts.notImplemented, + getSourceFiles: ts.notImplemented, + getOptionsDiagnostics: ts.notImplemented, + getGlobalDiagnostics: ts.notImplemented, + getConfigFileParsingDiagnostics: ts.notImplemented, + getSyntacticDiagnostics: ts.notImplemented, + getDeclarationDiagnostics: ts.notImplemented, + getSemanticDiagnostics: ts.notImplemented, + emit: ts.notImplemented, + getAllDependencies: ts.notImplemented, + getCurrentDirectory: ts.notImplemented, + emitNextAffectedFile: ts.notImplemented, + getSemanticDiagnosticsOfNextAffectedFile: ts.notImplemented, + getProgramBuildInfo: ts.notImplemented + }; + } + ts.createBuildProgramUsingProgramBuildInfo = createBuildProgramUsingProgramBuildInfo; function createRedirectedBuilderProgram(state, configFileParsingDiagnostics) { return { getState: ts.notImplemented, @@ -73934,7 +74748,8 @@ var ts; getSemanticDiagnostics: function (sourceFile, cancellationToken) { return getProgram().getSemanticDiagnostics(sourceFile, cancellationToken); }, emit: function (sourceFile, writeFile, cancellationToken, emitOnlyDts, customTransformers) { return getProgram().emit(sourceFile, writeFile, cancellationToken, emitOnlyDts, customTransformers); }, getAllDependencies: ts.notImplemented, - getCurrentDirectory: function () { return getProgram().getCurrentDirectory(); } + getCurrentDirectory: function () { return getProgram().getCurrentDirectory(); }, + getProgramBuildInfo: function () { return undefined; } }; function getProgram() { return ts.Debug.assertDefined(state.program); @@ -74826,6 +75641,8 @@ var ts; case ".jsx": case ".json": return ext; + case ".tsbuildinfo": + return ts.Debug.fail("Extension " + ".tsbuildinfo" + " is unsupported:: FileName:: " + fileName); default: return ts.Debug.assertNever(ext); } @@ -75074,14 +75891,14 @@ var ts; writeFile: function (path, data, writeByteOrderMark) { return system.writeFile(path, data, writeByteOrderMark); }, onCachedDirectoryStructureHostCreate: function (cacheHost) { return host = cacheHost || system; }, createHash: ts.maybeBind(system, system.createHash), - createProgram: createProgram + createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram }; } ts.createProgramHost = createProgramHost; function createWatchCompilerHost(system, createProgram, reportDiagnostic, reportWatchStatus) { if (system === void 0) { system = ts.sys; } var writeFileName = function (s) { return system.write(s + system.newLine); }; - var result = createProgramHost(system, createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram); + var result = createProgramHost(system, createProgram); ts.copyProperties(result, createWatchHost(system, reportWatchStatus)); result.afterProgramCreate = function (builderProgram) { var compilerOptions = builderProgram.getCompilerOptions(); @@ -75500,13 +76317,14 @@ var ts; UpToDateStatusType[UpToDateStatusType["Unbuildable"] = 0] = "Unbuildable"; UpToDateStatusType[UpToDateStatusType["UpToDate"] = 1] = "UpToDate"; UpToDateStatusType[UpToDateStatusType["UpToDateWithUpstreamTypes"] = 2] = "UpToDateWithUpstreamTypes"; - UpToDateStatusType[UpToDateStatusType["OutputMissing"] = 3] = "OutputMissing"; - UpToDateStatusType[UpToDateStatusType["OutOfDateWithSelf"] = 4] = "OutOfDateWithSelf"; - UpToDateStatusType[UpToDateStatusType["OutOfDateWithUpstream"] = 5] = "OutOfDateWithUpstream"; - UpToDateStatusType[UpToDateStatusType["UpstreamOutOfDate"] = 6] = "UpstreamOutOfDate"; - UpToDateStatusType[UpToDateStatusType["UpstreamBlocked"] = 7] = "UpstreamBlocked"; - UpToDateStatusType[UpToDateStatusType["ComputingUpstream"] = 8] = "ComputingUpstream"; - UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 9] = "ContainerOnly"; + UpToDateStatusType[UpToDateStatusType["OutOfDateWithPrepend"] = 3] = "OutOfDateWithPrepend"; + UpToDateStatusType[UpToDateStatusType["OutputMissing"] = 4] = "OutputMissing"; + UpToDateStatusType[UpToDateStatusType["OutOfDateWithSelf"] = 5] = "OutOfDateWithSelf"; + UpToDateStatusType[UpToDateStatusType["OutOfDateWithUpstream"] = 6] = "OutOfDateWithUpstream"; + UpToDateStatusType[UpToDateStatusType["UpstreamOutOfDate"] = 7] = "UpstreamOutOfDate"; + UpToDateStatusType[UpToDateStatusType["UpstreamBlocked"] = 8] = "UpstreamBlocked"; + UpToDateStatusType[UpToDateStatusType["ComputingUpstream"] = 9] = "ComputingUpstream"; + UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 10] = "ContainerOnly"; })(UpToDateStatusType = ts.UpToDateStatusType || (ts.UpToDateStatusType = {})); function createFileMap(toPath) { var lookup = ts.createMap(); @@ -75585,24 +76403,18 @@ var ts; } return outputs; } - function getOutFileOutputs(project) { - var out = project.options.outFile || project.options.out; - if (!out) { - return ts.Debug.fail("outFile must be set"); - } + function getOutFileOutputs(project, ignoreBuildInfo) { + ts.Debug.assert(!!project.options.outFile || !!project.options.out, "outFile must be set"); + var _a = ts.getOutputPathsForBundle(project.options, false), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath; var outputs = []; - outputs.push(out); - if (project.options.sourceMap) { - outputs.push(out + ".map"); - } - if (ts.getEmitDeclarations(project.options)) { - var dts = ts.changeExtension(out, ".d.ts"); - outputs.push(dts); - if (project.options.declarationMap) { - outputs.push(dts + ".map"); - } - } - return outputs; + var addOutput = function (path) { return path && (outputs || (outputs = [])).push(path); }; + addOutput(jsFilePath); + addOutput(sourceMapFilePath); + addOutput(declarationFilePath); + addOutput(declarationMapPath); + if (!ignoreBuildInfo) + addOutput(buildInfoPath); + return outputs || ts.emptyArray; } function rootDirOfOptions(opts, configFileName) { return opts.rootDir || ts.getDirectoryPath(configFileName); @@ -75632,14 +76444,14 @@ var ts; } function createSolutionBuilderHost(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus, reportErrorSummary) { if (system === void 0) { system = ts.sys; } - var host = createSolutionBuilderHostBase(system, createProgram || ts.createAbstractBuilder, reportDiagnostic, reportSolutionBuilderStatus); + var host = createSolutionBuilderHostBase(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus); host.reportErrorSummary = reportErrorSummary; return host; } ts.createSolutionBuilderHost = createSolutionBuilderHost; function createSolutionBuilderWithWatchHost(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus, reportWatchStatus) { if (system === void 0) { system = ts.sys; } - var host = createSolutionBuilderHostBase(system, createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram, reportDiagnostic, reportSolutionBuilderStatus); + var host = createSolutionBuilderHostBase(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus); var watchHost = ts.createWatchHost(system, reportWatchStatus); ts.copyProperties(host, watchHost); return host; @@ -75670,7 +76482,17 @@ var ts; var compilerHost = ts.createCompilerHostFromProgramHost(host, function () { return projectCompilerOptions; }); var originalGetSourceFile = compilerHost.getSourceFile; var computeHash = host.createHash || ts.generateDjb2Hash; - updateGetSourceFile(); + compilerHost.getSourceFile = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var result = originalGetSourceFile.call.apply(originalGetSourceFile, [compilerHost].concat(args)); + if (result) { + result.version = computeHash.call(host, result.text); + } + return result; + }; var builderPrograms = createFileMap(toPath); var diagnostics = createFileMap(toPath); var projectPendingBuild = createFileMap(toPath); @@ -75720,29 +76542,6 @@ var ts; ts.clearMap(allWatchedInputFiles, function (inputFileWatches) { return ts.clearMap(inputFileWatches, ts.closeFileWatcher); }); ts.clearMap(allWatchedConfigFiles, ts.closeFileWatcher); builderPrograms.clear(); - updateGetSourceFile(); - } - function updateGetSourceFile() { - if (options.watch) { - if (compilerHost.getSourceFile === originalGetSourceFile) { - compilerHost.getSourceFile = function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - var result = originalGetSourceFile.call.apply(originalGetSourceFile, [compilerHost].concat(args)); - if (result && options.watch) { - result.version = computeHash.call(host, result.text); - } - return result; - }; - } - } - else { - if (compilerHost.getSourceFile !== originalGetSourceFile) { - compilerHost.getSourceFile = originalGetSourceFile; - } - } } function isParsedCommandLine(entry) { return !!entry.options; @@ -75953,20 +76752,22 @@ var ts; upstreamProjectName: ref.path }; } - if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) { - continue; + if (!missingOutputFileName) { + if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) { + continue; + } + if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) { + pseudoUpToDate = true; + upstreamChangedProject = ref.path; + continue; + } + ts.Debug.assert(oldestOutputFileName !== undefined, "Should have an oldest output filename here"); + return { + type: UpToDateStatusType.OutOfDateWithUpstream, + outOfDateOutputFileName: oldestOutputFileName, + newerProjectName: ref.path + }; } - if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) { - pseudoUpToDate = true; - upstreamChangedProject = ref.path; - continue; - } - ts.Debug.assert(oldestOutputFileName !== undefined, "Should have an oldest output filename here"); - return { - type: UpToDateStatusType.OutOfDateWithUpstream, - outOfDateOutputFileName: oldestOutputFileName, - newerProjectName: ref.path - }; } } if (missingOutputFileName !== undefined) { @@ -75984,7 +76785,7 @@ var ts; } if (usesPrepend && pseudoUpToDate) { return { - type: UpToDateStatusType.OutOfDateWithUpstream, + type: UpToDateStatusType.OutOfDateWithPrepend, outOfDateOutputFileName: oldestOutputFileName, newerProjectName: upstreamChangedProject }; @@ -76111,7 +76912,9 @@ var ts; updateOutputTimestamps(proj); return; } - var buildResult = buildSingleProject(resolved); + var buildResult = status.type === UpToDateStatusType.OutOfDateWithPrepend ? + updateBundle(resolved) : + buildSingleProject(resolved); if (buildResult & BuildResultFlags.AnyErrors) return; var _a = getGlobalDependencyGraph(), referencingProjectsMap = _a.referencingProjectsMap, buildQueue = _a.buildQueue; @@ -76123,17 +76926,26 @@ var ts; var prepend = referencingProjects.getValue(project); if (prepend !== undefined) { var status_1 = projectStatus.getValue(project); - if (prepend || !(buildResult & BuildResultFlags.DeclarationOutputUnchanged)) { - if (status_1 && (status_1.type === UpToDateStatusType.UpToDate || status_1.type === UpToDateStatusType.UpToDateWithUpstreamTypes)) { + if (!(buildResult & BuildResultFlags.DeclarationOutputUnchanged)) { + if (status_1 && (status_1.type === UpToDateStatusType.UpToDate || status_1.type === UpToDateStatusType.UpToDateWithUpstreamTypes || status_1.type === UpToDateStatusType.OutOfDateWithPrepend)) { projectStatus.setValue(project, { type: UpToDateStatusType.OutOfDateWithUpstream, - outOfDateOutputFileName: status_1.oldestOutputFileName, + outOfDateOutputFileName: status_1.type === UpToDateStatusType.OutOfDateWithPrepend ? status_1.outOfDateOutputFileName : status_1.oldestOutputFileName, newerProjectName: resolved }); } } else if (status_1 && status_1.type === UpToDateStatusType.UpToDate) { - status_1.type = UpToDateStatusType.UpToDateWithUpstreamTypes; + if (prepend) { + projectStatus.setValue(project, { + type: UpToDateStatusType.OutOfDateWithPrepend, + outOfDateOutputFileName: status_1.oldestOutputFileName, + newerProjectName: resolved + }); + } + else { + status_1.type = UpToDateStatusType.UpToDateWithUpstreamTypes; + } } addProjToQueue(project); } @@ -76186,8 +76998,7 @@ var ts; } if (options.verbose) reportStatus(ts.Diagnostics.Building_project_0, proj); - var resultFlags = BuildResultFlags.None; - resultFlags |= BuildResultFlags.DeclarationOutputUnchanged; + var resultFlags = BuildResultFlags.DeclarationOutputUnchanged; var configFile = parseConfigFile(proj); if (!configFile) { resultFlags |= BuildResultFlags.ConfigFileErrors; @@ -76200,8 +77011,7 @@ var ts; return BuildResultFlags.None; } projectCompilerOptions = configFile.options; - var program = host.createProgram(configFile.fileNames, configFile.options, compilerHost, builderPrograms.getValue(proj), configFile.errors, configFile.projectReferences); - projectCompilerOptions = baseCompilerOptions; + var program = host.createProgram(configFile.fileNames, configFile.options, compilerHost, getOldProgram(proj, configFile), configFile.errors, configFile.projectReferences); var syntaxDiagnostics = program.getConfigFileParsingDiagnostics().concat(program.getOptionsDiagnostics(), program.getGlobalDiagnostics(), program.getSyntacticDiagnostics()); if (syntaxDiagnostics.length) { return buildErrors(syntaxDiagnostics, BuildResultFlags.SyntaxErrors, "Syntactic"); @@ -76255,12 +77065,14 @@ var ts; diagnostics.removeKey(proj); projectStatus.setValue(proj, status); afterProgramCreate(proj, program); + projectCompilerOptions = baseCompilerOptions; return resultFlags; function buildErrors(diagnostics, errorFlags, errorType) { resultFlags |= errorFlags; reportAndStoreErrors(proj, diagnostics); projectStatus.setValue(proj, { type: UpToDateStatusType.Unbuildable, reason: errorType + " errors" }); afterProgramCreate(proj, program); + projectCompilerOptions = baseCompilerOptions; return resultFlags; } } @@ -76273,9 +77085,62 @@ var ts; builderPrograms.setValue(proj, program); } } + function getOldProgram(proj, parsed) { + var value = builderPrograms.getValue(proj); + if (value) + return value; + var buildInfoPath = ts.getOutputPathForBuildInfo(parsed.options); + if (!buildInfoPath) + return undefined; + var content = readFileWithCache(buildInfoPath); + if (!content) + return undefined; + var buildInfo = JSON.parse(content); + return buildInfo.program && ts.createBuildProgramUsingProgramBuildInfo(buildInfo.program); + } + function updateBundle(proj) { + if (options.dry) { + reportStatus(ts.Diagnostics.A_non_dry_build_would_update_output_of_project_0, proj); + return BuildResultFlags.Success; + } + if (options.verbose) + reportStatus(ts.Diagnostics.Updating_output_of_project_0, proj); + var config = ts.Debug.assertDefined(parseConfigFile(proj)); + projectCompilerOptions = config.options; + var outputFiles = ts.emitUsingBuildInfo(config, compilerHost, function (ref) { return parseConfigFile(resolveProjectName(ref.path)); }); + if (ts.isString(outputFiles)) { + reportStatus(ts.Diagnostics.Cannot_update_output_of_project_0_because_there_was_error_reading_file_1, proj, relName(outputFiles)); + return buildSingleProject(proj); + } + ts.Debug.assert(!!outputFiles.length); + var emitterDiagnostics = ts.createDiagnosticCollection(); + var emittedOutputs = createFileMap(toPath); + outputFiles.forEach(function (_a) { + var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark; + emittedOutputs.setValue(name, true); + ts.writeFile(compilerHost, emitterDiagnostics, name, text, writeByteOrderMark); + }); + var emitDiagnostics = emitterDiagnostics.getDiagnostics(); + if (emitDiagnostics.length) { + reportAndStoreErrors(proj, emitDiagnostics); + projectStatus.setValue(proj, { type: UpToDateStatusType.Unbuildable, reason: "Emit errors" }); + projectCompilerOptions = baseCompilerOptions; + return BuildResultFlags.DeclarationOutputUnchanged | BuildResultFlags.EmitErrors; + } + var newestDeclarationFileContentChangedTime = updateOutputTimestampsWorker(config, minimumDate, ts.Diagnostics.Updating_unchanged_output_timestamps_of_project_0, emittedOutputs); + var status = { + type: UpToDateStatusType.UpToDate, + newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTime, + oldestOutputFileName: outputFiles[0].name + }; + diagnostics.removeKey(proj); + projectStatus.setValue(proj, status); + projectCompilerOptions = baseCompilerOptions; + return BuildResultFlags.DeclarationOutputUnchanged; + } function updateOutputTimestamps(proj) { if (options.dry) { - return reportStatus(ts.Diagnostics.A_non_dry_build_would_build_project_0, proj.options.configFilePath); + return reportStatus(ts.Diagnostics.A_non_dry_build_would_update_timestamps_for_output_of_project_0, proj.options.configFilePath); } var priorNewestUpdateTime = updateOutputTimestampsWorker(proj, minimumDate, ts.Diagnostics.Updating_output_timestamps_of_project_0); projectStatus.setValue(proj.options.configFilePath, { type: UpToDateStatusType.UpToDate, newestDeclarationFileContentChangedTime: priorNewestUpdateTime }); @@ -76393,7 +77258,9 @@ var ts; reportAndStoreErrors(next, errors); continue; } - var buildResult = buildSingleProject(next); + var buildResult = status.type === UpToDateStatusType.OutOfDateWithPrepend && !options.force ? + updateBundle(next) : + buildSingleProject(next); anyFailed = anyFailed || !!(buildResult & BuildResultFlags.AnyErrors); } reportErrorSummary(); @@ -76449,6 +77316,9 @@ var ts; var inputFile = _a[_i]; outputs.push.apply(outputs, getOutputFileNames(inputFile, project)); } + var buildInfoPath = ts.getOutputPathForBuildInfo(project.options); + if (buildInfoPath) + outputs.push(buildInfoPath); return outputs; } } @@ -76479,6 +77349,8 @@ var ts; return formatMessage(ts.Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, relName(configFileName), relName(status.newestInputFileName || ""), relName(status.oldestOutputFileName || "")); } break; + case UpToDateStatusType.OutOfDateWithPrepend: + return formatMessage(ts.Diagnostics.Project_0_is_out_of_date_because_output_of_its_dependency_1_has_changed, relName(configFileName), relName(status.newerProjectName)); case UpToDateStatusType.UpToDateWithUpstreamTypes: return formatMessage(ts.Diagnostics.Project_0_is_up_to_date_with_d_ts_files_from_its_dependencies, relName(configFileName)); case UpToDateStatusType.UpstreamOutOfDate: diff --git a/lib/tsserver.js b/lib/tsserver.js index d1c60ba72d5..aaffee4365f 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -2880,47 +2880,53 @@ var ts; SyntaxKind[SyntaxKind["SpreadAssignment"] = 277] = "SpreadAssignment"; // Enum SyntaxKind[SyntaxKind["EnumMember"] = 278] = "EnumMember"; + // Unparsed + SyntaxKind[SyntaxKind["UnparsedPrologue"] = 279] = "UnparsedPrologue"; + SyntaxKind[SyntaxKind["UnparsedPrepend"] = 280] = "UnparsedPrepend"; + SyntaxKind[SyntaxKind["UnparsedText"] = 281] = "UnparsedText"; + SyntaxKind[SyntaxKind["UnparsedInternalText"] = 282] = "UnparsedInternalText"; + SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 283] = "UnparsedSyntheticReference"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 279] = "SourceFile"; - SyntaxKind[SyntaxKind["Bundle"] = 280] = "Bundle"; - SyntaxKind[SyntaxKind["UnparsedSource"] = 281] = "UnparsedSource"; - SyntaxKind[SyntaxKind["InputFiles"] = 282] = "InputFiles"; + SyntaxKind[SyntaxKind["SourceFile"] = 284] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 285] = "Bundle"; + SyntaxKind[SyntaxKind["UnparsedSource"] = 286] = "UnparsedSource"; + SyntaxKind[SyntaxKind["InputFiles"] = 287] = "InputFiles"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 283] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 288] = "JSDocTypeExpression"; // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 284] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 289] = "JSDocAllType"; // The ? type - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 285] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 286] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 287] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 288] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 289] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 290] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 291] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 292] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocSignature"] = 293] = "JSDocSignature"; - SyntaxKind[SyntaxKind["JSDocTag"] = 294] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 295] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocClassTag"] = 296] = "JSDocClassTag"; - SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 297] = "JSDocCallbackTag"; - SyntaxKind[SyntaxKind["JSDocEnumTag"] = 298] = "JSDocEnumTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 299] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 300] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocThisTag"] = 301] = "JSDocThisTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 302] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 303] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 304] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 305] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 290] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 291] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 292] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 293] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 294] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 295] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 296] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 297] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocSignature"] = 298] = "JSDocSignature"; + SyntaxKind[SyntaxKind["JSDocTag"] = 299] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 300] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocClassTag"] = 301] = "JSDocClassTag"; + SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 302] = "JSDocCallbackTag"; + SyntaxKind[SyntaxKind["JSDocEnumTag"] = 303] = "JSDocEnumTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 304] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 305] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocThisTag"] = 306] = "JSDocThisTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 307] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 308] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 309] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 310] = "JSDocPropertyTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 306] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 311] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 307] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 308] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["CommaListExpression"] = 309] = "CommaListExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 310] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 311] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 312] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 313] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["CommaListExpression"] = 314] = "CommaListExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 315] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 316] = "EndOfDeclarationMarker"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 312] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 317] = "Count"; // Markers SyntaxKind[SyntaxKind["FirstAssignment"] = 59] = "FirstAssignment"; SyntaxKind[SyntaxKind["LastAssignment"] = 71] = "LastAssignment"; @@ -2947,10 +2953,10 @@ var ts; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 28] = "FirstBinaryOperator"; SyntaxKind[SyntaxKind["LastBinaryOperator"] = 71] = "LastBinaryOperator"; SyntaxKind[SyntaxKind["FirstNode"] = 148] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 283] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 305] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 294] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 305] = "LastJSDocTagNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 288] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 310] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 299] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 310] = "LastJSDocTagNode"; /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 118] = "FirstContextualKeyword"; /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 147] = "LastContextualKeyword"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); @@ -3827,6 +3833,7 @@ var ts; Extension["Js"] = ".js"; Extension["Jsx"] = ".jsx"; Extension["Json"] = ".json"; + Extension["TsBuildInfo"] = ".tsbuildinfo"; })(Extension = ts.Extension || (ts.Extension = {})); /* @internal */ var TransformFlags; @@ -3984,6 +3991,20 @@ var ts; EmitHint[EmitHint["Unspecified"] = 4] = "Unspecified"; EmitHint[EmitHint["EmbeddedStatement"] = 5] = "EmbeddedStatement"; })(EmitHint = ts.EmitHint || (ts.EmitHint = {})); + /*@internal*/ + var BundleFileSectionKind; + (function (BundleFileSectionKind) { + BundleFileSectionKind["Prologue"] = "prologue"; + BundleFileSectionKind["EmitHelpers"] = "emitHelpers"; + BundleFileSectionKind["NoDefaultLib"] = "no-default-lib"; + BundleFileSectionKind["Reference"] = "reference"; + BundleFileSectionKind["Type"] = "type"; + BundleFileSectionKind["Lib"] = "lib"; + BundleFileSectionKind["Prepend"] = "prepend"; + BundleFileSectionKind["Text"] = "text"; + BundleFileSectionKind["Internal"] = "internal"; + // comments? + })(BundleFileSectionKind = ts.BundleFileSectionKind || (ts.BundleFileSectionKind = {})); var ListFormat; (function (ListFormat) { ListFormat[ListFormat["None"] = 0] = "None"; @@ -6113,6 +6134,15 @@ var ts; Option_build_must_be_the_first_command_line_argument: diag(6369, ts.DiagnosticCategory.Error, "Option_build_must_be_the_first_command_line_argument_6369", "Option '--build' must be the first command line argument."), Options_0_and_1_cannot_be_combined: diag(6370, ts.DiagnosticCategory.Error, "Options_0_and_1_cannot_be_combined_6370", "Options '{0}' and '{1}' cannot be combined."), Updating_unchanged_output_timestamps_of_project_0: diag(6371, ts.DiagnosticCategory.Message, "Updating_unchanged_output_timestamps_of_project_0_6371", "Updating unchanged output timestamps of project '{0}'..."), + Project_0_is_out_of_date_because_output_of_its_dependency_1_has_changed: diag(6372, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_output_of_its_dependency_1_has_changed_6372", "Project '{0}' is out of date because output of its dependency '{1}' has changed"), + Updating_output_of_project_0: diag(6373, ts.DiagnosticCategory.Message, "Updating_output_of_project_0_6373", "Updating output of project '{0}'..."), + A_non_dry_build_would_update_timestamps_for_output_of_project_0: diag(6374, ts.DiagnosticCategory.Message, "A_non_dry_build_would_update_timestamps_for_output_of_project_0_6374", "A non-dry build would update timestamps for output of project '{0}'"), + A_non_dry_build_would_update_output_of_project_0: diag(6375, ts.DiagnosticCategory.Message, "A_non_dry_build_would_update_output_of_project_0_6375", "A non-dry build would update output of project '{0}'"), + Cannot_update_output_of_project_0_because_there_was_error_reading_file_1: diag(6376, ts.DiagnosticCategory.Message, "Cannot_update_output_of_project_0_because_there_was_error_reading_file_1_6376", "Cannot update output of project '{0}' because there was error reading file '{1}'"), + Cannot_write_file_0_because_it_will_overwrite_tsbuildinfo_file_generated_by_referenced_project_1: diag(6377, ts.DiagnosticCategory.Error, "Cannot_write_file_0_because_it_will_overwrite_tsbuildinfo_file_generated_by_referenced_project_1_6377", "Cannot write file '{0}' because it will overwrite '.tsbuildinfo' file generated by referenced project '{1}'"), + Enable_incremental_compilation: diag(6378, ts.DiagnosticCategory.Message, "Enable_incremental_compilation_6378", "Enable incremental compilation"), + Composite_projects_may_not_disable_incremental_compilation: diag(6379, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_incremental_compilation_6379", "Composite projects may not disable incremental compilation."), + Specify_file_to_store_incremental_compilation_information: diag(6380, ts.DiagnosticCategory.Message, "Specify_file_to_store_incremental_compilation_information_6380", "Specify file to store incremental compilation information"), The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: diag(6500, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1_6500", "The expected type comes from property '{0}' which is declared here on type '{1}'"), The_expected_type_comes_from_this_index_signature: diag(6501, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_this_index_signature_6501", "The expected type comes from this index signature."), The_expected_type_comes_from_the_return_type_of_this_signature: diag(6502, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_the_return_type_of_this_signature_6502", "The expected type comes from the return type of this signature."), @@ -6816,16 +6846,20 @@ var ts; return pos; } var shebangTriviaRegex = /^#!.*/; + /*@internal*/ function isShebangTrivia(text, pos) { // Shebangs check must only be done at the start of the file ts.Debug.assert(pos === 0); return shebangTriviaRegex.test(text); } + ts.isShebangTrivia = isShebangTrivia; + /*@internal*/ function scanShebangTrivia(text, pos) { var shebang = shebangTriviaRegex.exec(text)[0]; pos = pos + shebang.length; return pos; } + ts.scanShebangTrivia = scanShebangTrivia; /** * Invokes a callback for each comment range following the provided position. * @@ -8535,7 +8569,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 279 /* SourceFile */) { + while (node && node.kind !== 284 /* SourceFile */) { node = node.parent; } return node; @@ -8681,7 +8715,7 @@ var ts; // the syntax list itself considers them as normal trivia. Therefore if we simply skip // trivia for the list, we may have skipped the JSDocComment as well. So we should process its // first child to determine the actual position of its first token. - if (node.kind === 306 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 311 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); @@ -8700,7 +8734,7 @@ var ts; } ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; function isJSDocTypeExpressionOrChild(node) { - return node.kind === 283 /* JSDocTypeExpression */ || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); + return node.kind === 288 /* JSDocTypeExpression */ || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); } function getTextOfNodeFromSourceText(sourceText, node, includeTrivia) { if (includeTrivia === void 0) { includeTrivia = false; } @@ -8827,7 +8861,7 @@ var ts; return node && node.kind === 244 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 279 /* SourceFile */ || + return node.kind === 284 /* SourceFile */ || node.kind === 244 /* ModuleDeclaration */ || ts.isFunctionLike(node); } @@ -8845,7 +8879,7 @@ var ts; // - defined in the top level scope and source file is an external module // - defined inside ambient module declaration located in the top level scope and source file not an external module switch (node.parent.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: return ts.isExternalModule(node.parent); case 245 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); @@ -8863,7 +8897,7 @@ var ts; ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: case 246 /* CaseBlock */: case 274 /* CatchClause */: case 244 /* ModuleDeclaration */: @@ -8888,9 +8922,9 @@ var ts; ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 297 /* JSDocCallbackTag */: - case 304 /* JSDocTypedefTag */: - case 293 /* JSDocSignature */: + case 302 /* JSDocCallbackTag */: + case 309 /* JSDocTypedefTag */: + case 298 /* JSDocSignature */: return true; default: ts.assertType(node); @@ -8906,12 +8940,12 @@ var ts; case 162 /* IndexSignature */: case 165 /* FunctionType */: case 166 /* ConstructorType */: - case 289 /* JSDocFunctionType */: + case 294 /* JSDocFunctionType */: case 240 /* ClassDeclaration */: case 209 /* ClassExpression */: case 241 /* InterfaceDeclaration */: case 242 /* TypeAliasDeclaration */: - case 303 /* JSDocTemplateTag */: + case 308 /* JSDocTemplateTag */: case 239 /* FunctionDeclaration */: case 156 /* MethodDeclaration */: case 157 /* Constructor */: @@ -9056,7 +9090,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: var pos_1 = ts.skipTrivia(sourceFile.text, 0, /*stopAfterLineBreak*/ false); if (pos_1 === sourceFile.text.length) { // file is empty - return span for the beginning of the file @@ -9231,7 +9265,7 @@ var ts; return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); case 150 /* TypeParameter */: return node === parent.constraint; - case 303 /* JSDocTemplateTag */: + case 308 /* JSDocTemplateTag */: return node === parent.constraint; case 154 /* PropertyDeclaration */: case 153 /* PropertySignature */: @@ -9491,7 +9525,7 @@ var ts; } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 279 /* SourceFile */); + ts.Debug.assert(node.kind !== 284 /* SourceFile */); while (true) { node = node.parent; if (!node) { @@ -9545,7 +9579,7 @@ var ts; case 161 /* ConstructSignature */: case 162 /* IndexSignature */: case 243 /* EnumDeclaration */: - case 279 /* SourceFile */: + case 284 /* SourceFile */: return node; } } @@ -10253,7 +10287,7 @@ var ts; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 304 /* JSDocTypedefTag */ || node.kind === 297 /* JSDocCallbackTag */; + return node.kind === 309 /* JSDocTypedefTag */ || node.kind === 302 /* JSDocCallbackTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -10397,7 +10431,7 @@ var ts; ts.hasRestParameter = hasRestParameter; function isRestParameter(node) { var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type; - return node.dotDotDotToken !== undefined || !!type && type.kind === 290 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 295 /* JSDocVariadicType */; } ts.isRestParameter = isRestParameter; var AssignmentKind; @@ -10882,7 +10916,7 @@ var ts; || kind === 158 /* GetAccessor */ || kind === 159 /* SetAccessor */ || kind === 244 /* ModuleDeclaration */ - || kind === 279 /* SourceFile */; + || kind === 284 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -10959,7 +10993,7 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 309 /* CommaListExpression */: + case 314 /* CommaListExpression */: return 0; case 208 /* SpreadElement */: return 1; @@ -11277,6 +11311,9 @@ var ts; lineStart = true; } } + function getTextPosWithWriteLine() { + return lineStart ? output.length : (output.length + newLine.length); + } reset(); return { write: write, @@ -11305,7 +11342,8 @@ var ts; writeStringLiteral: write, writeSymbol: function (s, _) { return write(s); }, writeTrailingSemicolon: write, - writeComment: write + writeComment: write, + getTextPosWithWriteLine: getTextPosWithWriteLine }; } ts.createTextWriter = createTextWriter; @@ -11596,7 +11634,7 @@ var ts; ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations; /** template tags are only available when a typedef isn't already using them */ function isNonTypeAliasTemplate(tag) { - return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 291 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 296 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node @@ -12568,19 +12606,29 @@ var ts; || kind === 96 /* NullKeyword */ || kind === 132 /* NeverKeyword */ || kind === 211 /* ExpressionWithTypeArguments */ - || kind === 284 /* JSDocAllType */ - || kind === 285 /* JSDocUnknownType */ - || kind === 286 /* JSDocNullableType */ - || kind === 287 /* JSDocNonNullableType */ - || kind === 288 /* JSDocOptionalType */ - || kind === 289 /* JSDocFunctionType */ - || kind === 290 /* JSDocVariadicType */; + || kind === 289 /* JSDocAllType */ + || kind === 290 /* JSDocUnknownType */ + || kind === 291 /* JSDocNullableType */ + || kind === 292 /* JSDocNonNullableType */ + || kind === 293 /* JSDocOptionalType */ + || kind === 294 /* JSDocFunctionType */ + || kind === 295 /* JSDocVariadicType */; } ts.isTypeNodeKind = isTypeNodeKind; function isAccessExpression(node) { return node.kind === 189 /* PropertyAccessExpression */ || node.kind === 190 /* ElementAccessExpression */; } ts.isAccessExpression = isAccessExpression; + function isBundleFileTextLike(section) { + switch (section.kind) { + case "text" /* Text */: + case "internal" /* Internal */: + return true; + default: + return false; + } + } + ts.isBundleFileTextLike = isBundleFileTextLike; })(ts || (ts = {})); (function (ts) { function getDefaultLibFileName(options) { @@ -13042,8 +13090,8 @@ var ts; switch (declaration.kind) { case 72 /* Identifier */: return declaration; - case 305 /* JSDocPropertyTag */: - case 299 /* JSDocParameterTag */: { + case 310 /* JSDocPropertyTag */: + case 304 /* JSDocParameterTag */: { var name = declaration.name; if (name.kind === 148 /* QualifiedName */) { return name.right; @@ -13067,7 +13115,7 @@ var ts; return undefined; } } - case 304 /* JSDocTypedefTag */: + case 309 /* JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); case 254 /* ExportAssignment */: { var expression = declaration.expression; @@ -13271,7 +13319,7 @@ var ts; return ts.emptyArray; } if (ts.isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 291 /* JSDocComment */); + ts.Debug.assert(node.parent.kind === 296 /* JSDocComment */); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } if (node.typeParameters) { @@ -13543,7 +13591,7 @@ var ts; } ts.isParenthesizedExpression = isParenthesizedExpression; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 308 /* PartiallyEmittedExpression */) { + while (node.kind === 313 /* PartiallyEmittedExpression */) { node = node.expression; } return node; @@ -13890,108 +13938,128 @@ var ts; ts.isEnumMember = isEnumMember; // Top-level nodes function isSourceFile(node) { - return node.kind === 279 /* SourceFile */; + return node.kind === 284 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 280 /* Bundle */; + return node.kind === 285 /* Bundle */; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 281 /* UnparsedSource */; + return node.kind === 286 /* UnparsedSource */; } ts.isUnparsedSource = isUnparsedSource; + function isUnparsedPrepend(node) { + return node.kind === 280 /* UnparsedPrepend */; + } + ts.isUnparsedPrepend = isUnparsedPrepend; + function isUnparsedTextLike(node) { + switch (node.kind) { + case 281 /* UnparsedText */: + case 282 /* UnparsedInternalText */: + return true; + default: + return false; + } + } + ts.isUnparsedTextLike = isUnparsedTextLike; + function isUnparsedNode(node) { + return isUnparsedTextLike(node) || + node.kind === 279 /* UnparsedPrologue */ || + node.kind === 283 /* UnparsedSyntheticReference */; + } + ts.isUnparsedNode = isUnparsedNode; // JSDoc function isJSDocTypeExpression(node) { - return node.kind === 283 /* JSDocTypeExpression */; + return node.kind === 288 /* JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocAllType(node) { - return node.kind === 284 /* JSDocAllType */; + return node.kind === 289 /* JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 285 /* JSDocUnknownType */; + return node.kind === 290 /* JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 286 /* JSDocNullableType */; + return node.kind === 291 /* JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 287 /* JSDocNonNullableType */; + return node.kind === 292 /* JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 288 /* JSDocOptionalType */; + return node.kind === 293 /* JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 289 /* JSDocFunctionType */; + return node.kind === 294 /* JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 290 /* JSDocVariadicType */; + return node.kind === 295 /* JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDoc(node) { - return node.kind === 291 /* JSDocComment */; + return node.kind === 296 /* JSDocComment */; } ts.isJSDoc = isJSDoc; function isJSDocAugmentsTag(node) { - return node.kind === 295 /* JSDocAugmentsTag */; + return node.kind === 300 /* JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocClassTag(node) { - return node.kind === 296 /* JSDocClassTag */; + return node.kind === 301 /* JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocEnumTag(node) { - return node.kind === 298 /* JSDocEnumTag */; + return node.kind === 303 /* JSDocEnumTag */; } ts.isJSDocEnumTag = isJSDocEnumTag; function isJSDocThisTag(node) { - return node.kind === 301 /* JSDocThisTag */; + return node.kind === 306 /* JSDocThisTag */; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocParameterTag(node) { - return node.kind === 299 /* JSDocParameterTag */; + return node.kind === 304 /* JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 300 /* JSDocReturnTag */; + return node.kind === 305 /* JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocTypeTag(node) { - return node.kind === 302 /* JSDocTypeTag */; + return node.kind === 307 /* JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 303 /* JSDocTemplateTag */; + return node.kind === 308 /* JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 304 /* JSDocTypedefTag */; + return node.kind === 309 /* JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocPropertyTag(node) { - return node.kind === 305 /* JSDocPropertyTag */; + return node.kind === 310 /* JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocPropertyLikeTag(node) { - return node.kind === 305 /* JSDocPropertyTag */ || node.kind === 299 /* JSDocParameterTag */; + return node.kind === 310 /* JSDocPropertyTag */ || node.kind === 304 /* JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; function isJSDocTypeLiteral(node) { - return node.kind === 292 /* JSDocTypeLiteral */; + return node.kind === 297 /* JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocCallbackTag(node) { - return node.kind === 297 /* JSDocCallbackTag */; + return node.kind === 302 /* JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocSignature(node) { - return node.kind === 293 /* JSDocSignature */; + return node.kind === 298 /* JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; })(ts || (ts = {})); @@ -14002,7 +14070,7 @@ var ts; (function (ts) { /* @internal */ function isSyntaxList(n) { - return n.kind === 306 /* SyntaxList */; + return n.kind === 311 /* SyntaxList */; } ts.isSyntaxList = isSyntaxList; /* @internal */ @@ -14154,11 +14222,11 @@ var ts; switch (kind) { case 155 /* MethodSignature */: case 160 /* CallSignature */: - case 293 /* JSDocSignature */: + case 298 /* JSDocSignature */: case 161 /* ConstructSignature */: case 162 /* IndexSignature */: case 165 /* FunctionType */: - case 289 /* JSDocFunctionType */: + case 294 /* JSDocFunctionType */: case 166 /* ConstructorType */: return true; default: @@ -14449,8 +14517,8 @@ var ts; case 208 /* SpreadElement */: case 212 /* AsExpression */: case 210 /* OmittedExpression */: - case 309 /* CommaListExpression */: - case 308 /* PartiallyEmittedExpression */: + case 314 /* CommaListExpression */: + case 313 /* PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -14464,12 +14532,12 @@ var ts; ts.isAssertionExpression = isAssertionExpression; /* @internal */ function isPartiallyEmittedExpression(node) { - return node.kind === 308 /* PartiallyEmittedExpression */; + return node.kind === 313 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; /* @internal */ function isNotEmittedStatement(node) { - return node.kind === 307 /* NotEmittedStatement */; + return node.kind === 312 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ @@ -14580,9 +14648,9 @@ var ts; || kind === 242 /* TypeAliasDeclaration */ || kind === 150 /* TypeParameter */ || kind === 237 /* VariableDeclaration */ - || kind === 304 /* JSDocTypedefTag */ - || kind === 297 /* JSDocCallbackTag */ - || kind === 305 /* JSDocPropertyTag */; + || kind === 309 /* JSDocTypedefTag */ + || kind === 302 /* JSDocCallbackTag */ + || kind === 310 /* JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { return kind === 239 /* FunctionDeclaration */ @@ -14617,14 +14685,14 @@ var ts; || kind === 219 /* VariableStatement */ || kind === 224 /* WhileStatement */ || kind === 231 /* WithStatement */ - || kind === 307 /* NotEmittedStatement */ - || kind === 311 /* EndOfDeclarationMarker */ - || kind === 310 /* MergeDeclarationMarker */; + || kind === 312 /* NotEmittedStatement */ + || kind === 316 /* EndOfDeclarationMarker */ + || kind === 315 /* MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { if (node.kind === 150 /* TypeParameter */) { - return node.parent.kind !== 303 /* JSDocTemplateTag */ || ts.isInJSFile(node); + return (node.parent && node.parent.kind !== 308 /* JSDocTemplateTag */) || ts.isInJSFile(node); } return isDeclarationKind(node.kind); } @@ -14719,18 +14787,18 @@ var ts; /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 283 /* FirstJSDocNode */ && node.kind <= 305 /* LastJSDocNode */; + return node.kind >= 288 /* FirstJSDocNode */ && node.kind <= 310 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 291 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 296 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); } ts.isJSDocCommentContainingNode = isJSDocCommentContainingNode; // TODO: determine what this does before making it public. /* @internal */ function isJSDocTag(node) { - return node.kind >= 294 /* FirstJSDocTagNode */ && node.kind <= 305 /* LastJSDocTagNode */; + return node.kind >= 299 /* FirstJSDocTagNode */ && node.kind <= 310 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { @@ -15047,6 +15115,10 @@ var ts; return !!(compilerOptions.declaration || compilerOptions.composite); } ts.getEmitDeclarations = getEmitDeclarations; + function isIncrementalCompilation(options) { + return !!(options.incremental || options.composite); + } + ts.isIncrementalCompilation = isIncrementalCompilation; function getStrictOptionValue(compilerOptions, flag) { return compilerOptions[flag] === undefined ? !!compilerOptions.strict : !!compilerOptions[flag]; } @@ -16331,7 +16403,7 @@ var ts; var SourceFileConstructor; // tslint:enable variable-name function createNode(kind, pos, end) { - if (kind === 279 /* SourceFile */) { + if (kind === 284 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else if (kind === 72 /* Identifier */) { @@ -16582,7 +16654,7 @@ var ts; case 218 /* Block */: case 245 /* ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 279 /* SourceFile */: + case 284 /* SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); case 219 /* VariableStatement */: @@ -16731,7 +16803,7 @@ var ts; return visitNode(cbNode, node.expression); case 258 /* MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators); - case 309 /* CommaListExpression */: + case 314 /* CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); case 260 /* JsxElement */: return visitNode(cbNode, node.openingElement) || @@ -16760,60 +16832,60 @@ var ts; return visitNode(cbNode, node.tagName); case 171 /* OptionalType */: case 172 /* RestType */: - case 283 /* JSDocTypeExpression */: - case 287 /* JSDocNonNullableType */: - case 286 /* JSDocNullableType */: - case 288 /* JSDocOptionalType */: - case 290 /* JSDocVariadicType */: + case 288 /* JSDocTypeExpression */: + case 292 /* JSDocNonNullableType */: + case 291 /* JSDocNullableType */: + case 293 /* JSDocOptionalType */: + case 295 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 289 /* JSDocFunctionType */: + case 294 /* JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 291 /* JSDocComment */: + case 296 /* JSDocComment */: return visitNodes(cbNode, cbNodes, node.tags); - case 299 /* JSDocParameterTag */: - case 305 /* JSDocPropertyTag */: + case 304 /* JSDocParameterTag */: + case 310 /* JSDocPropertyTag */: return visitNode(cbNode, node.tagName) || (node.isNameFirst ? visitNode(cbNode, node.name) || visitNode(cbNode, node.typeExpression) : visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name)); - case 295 /* JSDocAugmentsTag */: + case 300 /* JSDocAugmentsTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.class); - case 303 /* JSDocTemplateTag */: + case 308 /* JSDocTemplateTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.constraint) || visitNodes(cbNode, cbNodes, node.typeParameters); - case 304 /* JSDocTypedefTag */: + case 309 /* JSDocTypedefTag */: return visitNode(cbNode, node.tagName) || (node.typeExpression && - node.typeExpression.kind === 283 /* JSDocTypeExpression */ + node.typeExpression.kind === 288 /* JSDocTypeExpression */ ? visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) : visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression)); - case 297 /* JSDocCallbackTag */: + case 302 /* JSDocCallbackTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); - case 300 /* JSDocReturnTag */: - case 302 /* JSDocTypeTag */: - case 301 /* JSDocThisTag */: - case 298 /* JSDocEnumTag */: + case 305 /* JSDocReturnTag */: + case 307 /* JSDocTypeTag */: + case 306 /* JSDocThisTag */: + case 303 /* JSDocEnumTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.typeExpression); - case 293 /* JSDocSignature */: + case 298 /* JSDocSignature */: return ts.forEach(node.typeParameters, cbNode) || ts.forEach(node.parameters, cbNode) || visitNode(cbNode, node.type); - case 292 /* JSDocTypeLiteral */: + case 297 /* JSDocTypeLiteral */: return ts.forEach(node.jsDocPropertyTags, cbNode); - case 294 /* JSDocTag */: - case 296 /* JSDocClassTag */: + case 299 /* JSDocTag */: + case 301 /* JSDocClassTag */: return visitNode(cbNode, node.tagName); - case 308 /* PartiallyEmittedExpression */: + case 313 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -17187,7 +17259,7 @@ var ts; function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile) { // code from createNode is inlined here so createNode won't have to deal with special case of creating source files // this is quite rare comparing to other nodes and createNode should be as fast as possible - var sourceFile = new SourceFileConstructor(279 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); + var sourceFile = new SourceFileConstructor(284 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -18387,9 +18459,9 @@ var ts; return finishNode(node); } function parseJSDocAllType(postFixEquals) { - var result = createNode(284 /* JSDocAllType */); + var result = createNode(289 /* JSDocAllType */); if (postFixEquals) { - return createPostfixType(288 /* JSDocOptionalType */, result); + return createPostfixType(293 /* JSDocOptionalType */, result); } else { nextToken(); @@ -18397,7 +18469,7 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(287 /* JSDocNonNullableType */); + var result = createNode(292 /* JSDocNonNullableType */); nextToken(); result.type = parseNonArrayType(); return finishNode(result); @@ -18421,18 +18493,18 @@ var ts; token() === 30 /* GreaterThanToken */ || token() === 59 /* EqualsToken */ || token() === 50 /* BarToken */) { - var result = createNode(285 /* JSDocUnknownType */, pos); + var result = createNode(290 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(286 /* JSDocNullableType */, pos); + var result = createNode(291 /* JSDocNullableType */, pos); result.type = parseType(); return finishNode(result); } } function parseJSDocFunctionType() { if (lookAhead(nextTokenIsOpenParen)) { - var result = createNodeWithJSDoc(289 /* JSDocFunctionType */); + var result = createNodeWithJSDoc(294 /* JSDocFunctionType */); nextToken(); fillSignature(57 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result); return finishNode(result); @@ -18456,12 +18528,12 @@ var ts; var type = parseTypeOrTypePredicate(); scanner.setInJSDocType(false); if (dotdotdot) { - var variadic = createNode(290 /* JSDocVariadicType */, dotdotdot.pos); + var variadic = createNode(295 /* JSDocVariadicType */, dotdotdot.pos); variadic.type = type; type = finishNode(variadic); } if (token() === 59 /* EqualsToken */) { - return createPostfixType(288 /* JSDocOptionalType */, type); + return createPostfixType(293 /* JSDocOptionalType */, type); } return type; } @@ -18833,7 +18905,7 @@ var ts; return finishNode(node); } var type = parseType(); - if (!(contextFlags & 2097152 /* JSDoc */) && type.kind === 286 /* JSDocNullableType */ && type.pos === type.type.pos) { + if (!(contextFlags & 2097152 /* JSDoc */) && type.kind === 291 /* JSDocNullableType */ && type.pos === type.type.pos) { type.kind = 171 /* OptionalType */; } return type; @@ -19020,14 +19092,14 @@ var ts; while (!scanner.hasPrecedingLineBreak()) { switch (token()) { case 52 /* ExclamationToken */: - type = createPostfixType(287 /* JSDocNonNullableType */, type); + type = createPostfixType(292 /* JSDocNonNullableType */, type); break; case 56 /* QuestionToken */: // If not in JSDoc and next token is start of a type we have a conditional type if (!(contextFlags & 2097152 /* JSDoc */) && lookAhead(nextTokenIsStartOfType)) { return type; } - type = createPostfixType(286 /* JSDocNullableType */, type); + type = createPostfixType(291 /* JSDocNullableType */, type); break; case 22 /* OpenBracketToken */: parseExpected(22 /* OpenBracketToken */); @@ -21964,7 +22036,7 @@ var ts; JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; // Parses out a JSDoc type expression. function parseJSDocTypeExpression(mayOmitBraces) { - var result = createNode(283 /* JSDocTypeExpression */); + var result = createNode(288 /* JSDocTypeExpression */); var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* OpenBraceToken */); result.type = doInsideOfContext(2097152 /* JSDoc */, parseJSDocType); if (!mayOmitBraces || hasBrace) { @@ -22127,7 +22199,7 @@ var ts; } } function createJSDocComment() { - var result = createNode(291 /* JSDocComment */, start); + var result = createNode(296 /* JSDocComment */, start); result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -22294,7 +22366,7 @@ var ts; return comments.length === 0 ? undefined : comments.join(""); } function parseUnknownTag(start, tagName) { - var result = createNode(294 /* JSDocTag */, start); + var result = createNode(299 /* JSDocTag */, start); result.tagName = tagName; return finishNode(result); } @@ -22353,8 +22425,8 @@ var ts; typeExpression = tryParseTypeExpression(); } var result = target === 1 /* Property */ ? - createNode(305 /* JSDocPropertyTag */, start) : - createNode(299 /* JSDocParameterTag */, start); + createNode(310 /* JSDocPropertyTag */, start) : + createNode(304 /* JSDocParameterTag */, start); var comment = parseTagComments(indent + scanner.getStartPos() - start); var nestedTypeLiteral = target !== 4 /* CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target, indent); if (nestedTypeLiteral) { @@ -22371,18 +22443,18 @@ var ts; } function parseNestedTypeLiteral(typeExpression, name, target, indent) { if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) { - var typeLiteralExpression = createNode(283 /* JSDocTypeExpression */, scanner.getTokenPos()); + var typeLiteralExpression = createNode(288 /* JSDocTypeExpression */, scanner.getTokenPos()); var child = void 0; var jsdocTypeLiteral = void 0; var start_2 = scanner.getStartPos(); var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) { - if (child.kind === 299 /* JSDocParameterTag */ || child.kind === 305 /* JSDocPropertyTag */) { + if (child.kind === 304 /* JSDocParameterTag */ || child.kind === 310 /* JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - jsdocTypeLiteral = createNode(292 /* JSDocTypeLiteral */, start_2); + jsdocTypeLiteral = createNode(297 /* JSDocTypeLiteral */, start_2); jsdocTypeLiteral.jsDocPropertyTags = children; if (typeExpression.type.kind === 169 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; @@ -22393,25 +22465,25 @@ var ts; } } function parseReturnTag(start, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 300 /* JSDocReturnTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 305 /* JSDocReturnTag */; })) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(300 /* JSDocReturnTag */, start); + var result = createNode(305 /* JSDocReturnTag */, start); result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); } function parseTypeTag(start, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 302 /* JSDocTypeTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 307 /* JSDocTypeTag */; })) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(302 /* JSDocTypeTag */, start); + var result = createNode(307 /* JSDocTypeTag */, start); result.tagName = tagName; result.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); return finishNode(result); } function parseAugmentsTag(start, tagName) { - var result = createNode(295 /* JSDocAugmentsTag */, start); + var result = createNode(300 /* JSDocAugmentsTag */, start); result.tagName = tagName; result.class = parseExpressionWithTypeArgumentsForAugments(); return finishNode(result); @@ -22438,19 +22510,19 @@ var ts; return node; } function parseClassTag(start, tagName) { - var tag = createNode(296 /* JSDocClassTag */, start); + var tag = createNode(301 /* JSDocClassTag */, start); tag.tagName = tagName; return finishNode(tag); } function parseThisTag(start, tagName) { - var tag = createNode(301 /* JSDocThisTag */, start); + var tag = createNode(306 /* JSDocThisTag */, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); return finishNode(tag); } function parseEnumTag(start, tagName) { - var tag = createNode(298 /* JSDocEnumTag */, start); + var tag = createNode(303 /* JSDocEnumTag */, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); @@ -22459,7 +22531,7 @@ var ts; function parseTypedefTag(start, tagName, indent) { var typeExpression = tryParseTypeExpression(); skipWhitespaceOrAsterisk(); - var typedefTag = createNode(304 /* JSDocTypedefTag */, start); + var typedefTag = createNode(309 /* JSDocTypedefTag */, start); typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(); typedefTag.name = getJSDocTypeAliasName(typedefTag.fullName); @@ -22473,9 +22545,9 @@ var ts; var childTypeTag = void 0; while (child = tryParse(function () { return parseChildPropertyTag(indent); })) { if (!jsdocTypeLiteral) { - jsdocTypeLiteral = createNode(292 /* JSDocTypeLiteral */, start); + jsdocTypeLiteral = createNode(297 /* JSDocTypeLiteral */, start); } - if (child.kind === 302 /* JSDocTypeTag */) { + if (child.kind === 307 /* JSDocTypeTag */) { if (childTypeTag) { break; } @@ -22521,14 +22593,14 @@ var ts; return typeNameOrNamespaceName; } function parseCallbackTag(start, tagName, indent) { - var callbackTag = createNode(297 /* JSDocCallbackTag */, start); + var callbackTag = createNode(302 /* JSDocCallbackTag */, start); callbackTag.tagName = tagName; callbackTag.fullName = parseJSDocTypeNameWithNamespace(); callbackTag.name = getJSDocTypeAliasName(callbackTag.fullName); skipWhitespace(); callbackTag.comment = parseTagComments(indent); var child; - var jsdocSignature = createNode(293 /* JSDocSignature */, start); + var jsdocSignature = createNode(298 /* JSDocSignature */, start); jsdocSignature.parameters = []; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* CallbackParameter */, indent); })) { jsdocSignature.parameters = ts.append(jsdocSignature.parameters, child); @@ -22536,7 +22608,7 @@ var ts; var returnTag = tryParse(function () { if (parseOptionalJsdoc(58 /* AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 300 /* JSDocReturnTag */) { + if (tag && tag.kind === 305 /* JSDocReturnTag */) { return tag; } } @@ -22581,7 +22653,7 @@ var ts; case 58 /* AtToken */: if (canParseTag) { var child = tryParseChildTag(target, indent); - if (child && (child.kind === 299 /* JSDocParameterTag */ || child.kind === 305 /* JSDocPropertyTag */) && + if (child && (child.kind === 304 /* JSDocParameterTag */ || child.kind === 310 /* JSDocPropertyTag */) && target !== 4 /* CallbackParameter */ && name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; @@ -22651,7 +22723,7 @@ var ts; skipWhitespace(); typeParameters.push(typeParameter); } while (parseOptionalJsdoc(27 /* CommaToken */)); - var result = createNode(303 /* JSDocTemplateTag */, start); + var result = createNode(308 /* JSDocTemplateTag */, start); result.tagName = tagName; result.constraint = constraint; result.typeParameters = createNodeArray(typeParameters, typeParametersPos); @@ -23737,6 +23809,22 @@ var ts; category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Enable_project_compilation, }, + { + name: "incremental", + type: "boolean", + isTSConfigOnly: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Enable_incremental_compilation, + }, + { + name: "tsBuildInfoFile", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.FILE, + isTSConfigOnly: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Specify_file_to_store_incremental_compilation_information, + }, { name: "removeComments", type: "boolean", @@ -27455,7 +27543,7 @@ var ts; return "__constructor" /* Constructor */; case 165 /* FunctionType */: case 160 /* CallSignature */: - case 293 /* JSDocSignature */: + case 298 /* JSDocSignature */: return "__call" /* Call */; case 166 /* ConstructorType */: case 161 /* ConstructSignature */: @@ -27464,7 +27552,7 @@ var ts; return "__index" /* Index */; case 255 /* ExportDeclaration */: return "__export" /* ExportStar */; - case 279 /* SourceFile */: + case 284 /* SourceFile */: // json file should behave as // module.exports = ... return "export=" /* ExportEquals */; @@ -27475,12 +27563,12 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 289 /* JSDocFunctionType */: + case 294 /* JSDocFunctionType */: return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); case 151 /* Parameter */: // Parameters with names are handled at the top of this function. Parameters // without names can only come from JSDocFunctionTypes. - ts.Debug.assert(node.parent.kind === 289 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); + ts.Debug.assert(node.parent.kind === 294 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); var functionType = node.parent; var index = functionType.parameters.indexOf(node); return "arg" + index; @@ -27719,7 +27807,7 @@ var ts; if (hasExplicitReturn) node.flags |= 256 /* HasExplicitReturn */; } - if (node.kind === 279 /* SourceFile */) { + if (node.kind === 284 /* SourceFile */) { node.flags |= emitFlags; } if (currentReturnTarget) { @@ -27863,12 +27951,12 @@ var ts; case 191 /* CallExpression */: bindCallExpressionFlow(node); break; - case 304 /* JSDocTypedefTag */: - case 297 /* JSDocCallbackTag */: + case 309 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: bindJSDocTypeAlias(node); break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 279 /* SourceFile */: { + case 284 /* SourceFile */: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; @@ -28555,7 +28643,7 @@ var ts; case 243 /* EnumDeclaration */: case 188 /* ObjectLiteralExpression */: case 168 /* TypeLiteral */: - case 292 /* JSDocTypeLiteral */: + case 297 /* JSDocTypeLiteral */: case 268 /* JsxAttributes */: return 1 /* IsContainer */; case 241 /* InterfaceDeclaration */: @@ -28564,7 +28652,7 @@ var ts; case 242 /* TypeAliasDeclaration */: case 181 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 279 /* SourceFile */: + case 284 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; case 156 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { @@ -28577,8 +28665,8 @@ var ts; case 158 /* GetAccessor */: case 159 /* SetAccessor */: case 160 /* CallSignature */: - case 293 /* JSDocSignature */: - case 289 /* JSDocFunctionType */: + case 298 /* JSDocSignature */: + case 294 /* JSDocFunctionType */: case 165 /* FunctionType */: case 161 /* ConstructSignature */: case 162 /* IndexSignature */: @@ -28632,7 +28720,7 @@ var ts; // handlers to take care of declaring these child members. case 244 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 279 /* SourceFile */: + case 284 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); case 209 /* ClassExpression */: case 240 /* ClassDeclaration */: @@ -28640,7 +28728,7 @@ var ts; case 243 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); case 168 /* TypeLiteral */: - case 292 /* JSDocTypeLiteral */: + case 297 /* JSDocTypeLiteral */: case 188 /* ObjectLiteralExpression */: case 241 /* InterfaceDeclaration */: case 268 /* JsxAttributes */: @@ -28654,7 +28742,7 @@ var ts; case 166 /* ConstructorType */: case 160 /* CallSignature */: case 161 /* ConstructSignature */: - case 293 /* JSDocSignature */: + case 298 /* JSDocSignature */: case 162 /* IndexSignature */: case 156 /* MethodDeclaration */: case 155 /* MethodSignature */: @@ -28664,9 +28752,9 @@ var ts; case 239 /* FunctionDeclaration */: case 196 /* FunctionExpression */: case 197 /* ArrowFunction */: - case 289 /* JSDocFunctionType */: - case 304 /* JSDocTypedefTag */: - case 297 /* JSDocCallbackTag */: + case 294 /* JSDocFunctionType */: + case 309 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: case 242 /* TypeAliasDeclaration */: case 181 /* MappedType */: // All the children of these container types are never visible through another @@ -28689,8 +28777,8 @@ var ts; : declareSymbol(file.locals, /*parent*/ undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 279 /* SourceFile */ ? node : node.body; - if (body && (body.kind === 279 /* SourceFile */ || body.kind === 245 /* ModuleBlock */)) { + var body = node.kind === 284 /* SourceFile */ ? node : node.body; + if (body && (body.kind === 284 /* SourceFile */ || body.kind === 245 /* ModuleBlock */)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; if (stat.kind === 255 /* ExportDeclaration */ || stat.kind === 254 /* ExportAssignment */) { @@ -28824,7 +28912,7 @@ var ts; case 244 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 279 /* SourceFile */: + case 284 /* SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -28962,7 +29050,7 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 279 /* SourceFile */ && + if (blockScopeContainer.kind !== 284 /* SourceFile */ && blockScopeContainer.kind !== 244 /* ModuleDeclaration */ && !ts.isFunctionLike(blockScopeContainer)) { // We check first if the name is inside class declaration or class expression; if so give explicit message @@ -29237,12 +29325,12 @@ var ts; case 159 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 67187647 /* SetAccessorExcludes */); case 165 /* FunctionType */: - case 289 /* JSDocFunctionType */: - case 293 /* JSDocSignature */: + case 294 /* JSDocFunctionType */: + case 298 /* JSDocSignature */: case 166 /* ConstructorType */: return bindFunctionOrConstructorType(node); case 168 /* TypeLiteral */: - case 292 /* JSDocTypeLiteral */: + case 297 /* JSDocTypeLiteral */: case 181 /* MappedType */: return bindAnonymousTypeWorker(node); case 188 /* ObjectLiteralExpression */: @@ -29301,7 +29389,7 @@ var ts; return bindExportDeclaration(node); case 254 /* ExportAssignment */: return bindExportAssignment(node); - case 279 /* SourceFile */: + case 284 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); case 218 /* Block */: @@ -29311,22 +29399,22 @@ var ts; // falls through case 245 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 299 /* JSDocParameterTag */: - if (node.parent.kind === 293 /* JSDocSignature */) { + case 304 /* JSDocParameterTag */: + if (node.parent.kind === 298 /* JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 292 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 297 /* JSDocTypeLiteral */) { break; } // falls through - case 305 /* JSDocPropertyTag */: + case 310 /* JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 288 /* JSDocOptionalType */ ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 293 /* JSDocOptionalType */ ? 4 /* Property */ | 16777216 /* Optional */ : 4 /* Property */; return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 304 /* JSDocTypedefTag */: - case 297 /* JSDocCallbackTag */: + case 309 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -29498,7 +29586,7 @@ var ts; var symbolTable = ts.hasModifier(thisContainer, 32 /* Static */) ? containingClass.symbol.exports : containingClass.symbol.members; declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */, 0 /* None */, /*isReplaceableByMethod*/ true); break; - case 279 /* SourceFile */: + case 284 /* SourceFile */: // this.property = assignment in a source file -- declare symbol in exports for a module, in locals for a script if (thisContainer.commonJsModuleIndicator) { declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 /* Property */ | 1048576 /* ExportValue */, 0 /* None */); @@ -29515,7 +29603,7 @@ var ts; if (node.expression.kind === 100 /* ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 279 /* SourceFile */) { + else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 284 /* SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -29552,7 +29640,7 @@ var ts; } function bindObjectDefinePropertyAssignment(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]); - var isToplevel = node.parent.parent.kind === 279 /* SourceFile */; + var isToplevel = node.parent.parent.kind === 284 /* SourceFile */; namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false); bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ false); } @@ -29619,8 +29707,8 @@ var ts; function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty) { var namespaceSymbol = lookupSymbolForPropertyAccess(name); var isToplevel = ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 279 /* SourceFile */ - : propertyAccess.parent.parent.kind === 279 /* SourceFile */; + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 284 /* SourceFile */ + : propertyAccess.parent.parent.kind === 284 /* SourceFile */; namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty); bindPotentiallyNewExpandoMemberToNamespace(propertyAccess, namespaceSymbol, isPrototypeProperty); } @@ -29758,7 +29846,7 @@ var ts; } } function bindParameter(node) { - if (node.kind === 299 /* JSDocParameterTag */ && container.kind !== 293 /* JSDocSignature */) { + if (node.kind === 304 /* JSDocParameterTag */ && container.kind !== 298 /* JSDocSignature */) { return; } if (inStrictMode && !(node.flags & 4194304 /* Ambient */)) { @@ -30501,7 +30589,7 @@ var ts; break; case 194 /* TypeAssertionExpression */: case 212 /* AsExpression */: - case 308 /* PartiallyEmittedExpression */: + case 313 /* PartiallyEmittedExpression */: // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; excludeFlags = 536872257 /* OuterExpressionExcludes */; @@ -30702,7 +30790,7 @@ var ts; transformFlags |= 192 /* AssertES2015 */; } break; - case 279 /* SourceFile */: + case 284 /* SourceFile */: if (subtreeFlags & 16384 /* ContainsCapturedLexicalThis */) { transformFlags |= 192 /* AssertES2015 */; } @@ -30782,7 +30870,7 @@ var ts; return 637666625 /* BindingPatternExcludes */; case 194 /* TypeAssertionExpression */: case 212 /* AsExpression */: - case 308 /* PartiallyEmittedExpression */: + case 313 /* PartiallyEmittedExpression */: case 195 /* ParenthesizedExpression */: case 98 /* SuperKeyword */: return 536872257 /* OuterExpressionExcludes */; @@ -31959,7 +32047,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); } function isGlobalSourceFile(node) { - return node.kind === 279 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 284 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -32133,7 +32221,7 @@ var ts; // - parameters are only in the scope of function body // This restriction does not apply to JSDoc comment types because they are parented // at a higher level than type parameters would normally be - if (meaning & result.flags & 67897832 /* Type */ && lastLocation.kind !== 291 /* JSDocComment */) { + if (meaning & result.flags & 67897832 /* Type */ && lastLocation.kind !== 296 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || @@ -32175,14 +32263,14 @@ var ts; } } switch (location.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through case 244 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 279 /* SourceFile */ || ts.isAmbientModule(location)) { + if (location.kind === 284 /* SourceFile */ || ts.isAmbientModule(location)) { // It's an external module. First see if the module has an export default and if the local // name of that export default matches. if (result = moduleExports.get("default" /* Default */)) { @@ -32354,8 +32442,8 @@ var ts; location = location.parent; } break; - case 304 /* JSDocTypedefTag */: - case 297 /* JSDocCallbackTag */: + case 309 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: // js type aliases do not resolve names from their host, so skip past it location = ts.getJSDocHost(location); break; @@ -32374,7 +32462,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 279 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 284 /* SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) { return lastLocation.symbol; } @@ -33230,7 +33318,7 @@ var ts; function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias) { var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 279 /* SourceFile */)) { + if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 284 /* SourceFile */)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; @@ -33581,7 +33669,7 @@ var ts; } } switch (location.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } @@ -33821,10 +33909,10 @@ var ts; return node && getSymbolOfNode(node); } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 279 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 284 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 279 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 284 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -34281,7 +34369,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 279 /* SourceFile */ || declaration.parent.kind === 245 /* ModuleBlock */; + return declaration.parent.kind === 284 /* SourceFile */ || declaration.parent.kind === 245 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -34666,7 +34754,7 @@ var ts; function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) { var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 151 /* Parameter */); if (!parameterDeclaration && !isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 299 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 304 /* JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { @@ -34824,7 +34912,7 @@ var ts; return top; } function getSpecifierForModuleSymbol(symbol, context) { - var file = ts.getDeclarationOfKind(symbol, 279 /* SourceFile */); + var file = ts.getDeclarationOfKind(symbol, 284 /* SourceFile */); if (file && file.moduleName !== undefined) { // Use the amd name if it is available return file.moduleName; @@ -35077,7 +35165,7 @@ var ts; ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 279 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 284 /* SourceFile */ || ts.isAmbientModule(location); } function getNameOfSymbolFromNameType(symbol, context) { var nameType = symbol.nameType; @@ -35154,8 +35242,8 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 297 /* JSDocCallbackTag */: - case 304 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: + case 309 /* JSDocTypedefTag */: // Top-level jsdoc type aliases are considered exported // First parent is comment node, second is hosting declaration or token; we only care about those tokens or declarations whose parent is a source file return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent)); @@ -35182,7 +35270,7 @@ var ts; var parent = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) if (!(ts.getCombinedModifierFlags(node) & 1 /* Export */) && - !(node.kind !== 248 /* ImportEqualsDeclaration */ && parent.kind !== 279 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { + !(node.kind !== 248 /* ImportEqualsDeclaration */ && parent.kind !== 284 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible @@ -35224,7 +35312,7 @@ var ts; // Type parameters are always visible case 150 /* TypeParameter */: // Source file and namespace export are always visible - case 279 /* SourceFile */: + case 284 /* SourceFile */: case 247 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module @@ -36334,15 +36422,15 @@ var ts; case 155 /* MethodSignature */: case 165 /* FunctionType */: case 166 /* ConstructorType */: - case 289 /* JSDocFunctionType */: + case 294 /* JSDocFunctionType */: case 239 /* FunctionDeclaration */: case 156 /* MethodDeclaration */: case 196 /* FunctionExpression */: case 197 /* ArrowFunction */: case 242 /* TypeAliasDeclaration */: - case 303 /* JSDocTemplateTag */: - case 304 /* JSDocTypedefTag */: - case 297 /* JSDocCallbackTag */: + case 308 /* JSDocTemplateTag */: + case 309 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: case 181 /* MappedType */: case 175 /* ConditionalType */: var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); @@ -38334,10 +38422,10 @@ var ts; function isJSDocOptionalParameter(node) { return ts.isInJSFile(node) && ( // node.type should only be a JSDocOptionalType when node is a parameter of a JSDocFunctionType - node.type && node.type.kind === 288 /* JSDocOptionalType */ + node.type && node.type.kind === 293 /* JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 288 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 293 /* JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -38371,7 +38459,7 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 288 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 293 /* JSDocOptionalType */; } function createIdentifierTypePredicate(parameterName, parameterIndex, type) { return { kind: 1 /* Identifier */, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; @@ -39111,7 +39199,7 @@ var ts; } function getConstrainedTypeVariable(typeVariable, node) { var constraints; - while (node && !ts.isStatement(node) && node.kind !== 291 /* JSDocComment */) { + while (node && !ts.isStatement(node) && node.kind !== 296 /* JSDocComment */) { var parent = node.parent; if (parent.kind === 175 /* ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(typeVariable, parent.checkType, parent.extendsType); @@ -40684,8 +40772,8 @@ var ts; function getTypeFromTypeNode(node) { switch (node.kind) { case 120 /* AnyKeyword */: - case 284 /* JSDocAllType */: - case 285 /* JSDocUnknownType */: + case 289 /* JSDocAllType */: + case 290 /* JSDocUnknownType */: return anyType; case 143 /* UnknownKeyword */: return unknownType; @@ -40732,23 +40820,23 @@ var ts; return getTypeFromUnionTypeNode(node); case 174 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 286 /* JSDocNullableType */: + case 291 /* JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 288 /* JSDocOptionalType */: + case 293 /* JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); case 177 /* ParenthesizedType */: case 172 /* RestType */: - case 287 /* JSDocNonNullableType */: - case 283 /* JSDocTypeExpression */: + case 292 /* JSDocNonNullableType */: + case 288 /* JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 290 /* JSDocVariadicType */: + case 295 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); case 165 /* FunctionType */: case 166 /* ConstructorType */: case 168 /* TypeLiteral */: - case 292 /* JSDocTypeLiteral */: - case 289 /* JSDocFunctionType */: - case 293 /* JSDocSignature */: + case 297 /* JSDocTypeLiteral */: + case 294 /* JSDocFunctionType */: + case 298 /* JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); case 179 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); @@ -44109,7 +44197,7 @@ var ts; return; } break; - case 289 /* JSDocFunctionType */: + case 294 /* JSDocFunctionType */: error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; case 239 /* FunctionDeclaration */: @@ -46390,7 +46478,7 @@ var ts; return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || node.kind === 245 /* ModuleBlock */ || - node.kind === 279 /* SourceFile */ || + node.kind === 284 /* SourceFile */ || node.kind === 154 /* PropertyDeclaration */; }); } @@ -46511,7 +46599,7 @@ var ts; // to the constructor in the initializer, we will need to substitute that // binding with an alias as the class name is not in scope. var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); - while (container.kind !== 279 /* SourceFile */) { + while (container.kind !== 284 /* SourceFile */) { if (container.parent === declaration) { if (container.kind === 154 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; @@ -46934,7 +47022,7 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 289 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 294 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -52936,7 +53024,7 @@ var ts; checkAsyncFunctionReturnType(node, returnTypeNode); } } - if (node.kind !== 162 /* IndexSignature */ && node.kind !== 289 /* JSDocFunctionType */) { + if (node.kind !== 162 /* IndexSignature */ && node.kind !== 294 /* JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } @@ -53692,8 +53780,8 @@ var ts; case 241 /* InterfaceDeclaration */: case 242 /* TypeAliasDeclaration */: // A jsdoc typedef and callback are, by definition, type aliases - case 304 /* JSDocTypedefTag */: - case 297 /* JSDocCallbackTag */: + case 309 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: return 2 /* ExportType */; case 244 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ @@ -53702,7 +53790,7 @@ var ts; case 240 /* ClassDeclaration */: case 243 /* EnumDeclaration */: return 2 /* ExportType */ | 1 /* ExportValue */; - case 279 /* SourceFile */: + case 284 /* SourceFile */: return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; case 254 /* ExportAssignment */: // Export assigned entity name expressions act as aliases and should fall through, otherwise they export values @@ -54343,7 +54431,7 @@ var ts; checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 279 /* SourceFile */: + case 284 /* SourceFile */: case 244 /* ModuleDeclaration */: case 218 /* Block */: case 246 /* CaseBlock */: @@ -54690,7 +54778,7 @@ var ts; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 279 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 284 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -54705,7 +54793,7 @@ var ts; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 279 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { + if (parent.kind === 284 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { // If the declaration happens to be in external module, report error that Promise is a reserved identifier. error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -54762,7 +54850,7 @@ var ts; (container.kind === 218 /* Block */ && ts.isFunctionLike(container.parent) || container.kind === 245 /* ModuleBlock */ || container.kind === 244 /* ModuleDeclaration */ || - container.kind === 279 /* SourceFile */); + container.kind === 284 /* SourceFile */); // here we know that function scoped variable is shadowed by block scoped one // if they are defined in the same scope - binder has already reported redeclaration error // otherwise if variable has an initializer - show error that initialization will fail @@ -56612,7 +56700,7 @@ var ts; return false; } var inAmbientExternalModule = node.parent.kind === 245 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 279 /* SourceFile */ && !inAmbientExternalModule) { + if (node.parent.kind !== 284 /* SourceFile */ && !inAmbientExternalModule) { error(moduleName, node.kind === 255 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); @@ -56743,7 +56831,7 @@ var ts; var inAmbientExternalModule = node.parent.kind === 245 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 245 /* ModuleBlock */ && !node.moduleSpecifier && node.flags & 4194304 /* Ambient */; - if (node.parent.kind !== 279 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + if (node.parent.kind !== 284 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -56760,7 +56848,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 279 /* SourceFile */ || node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 244 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 284 /* SourceFile */ || node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 244 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -56789,7 +56877,7 @@ var ts; // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 279 /* SourceFile */ ? node.parent : node.parent.parent; + var container = node.parent.kind === 284 /* SourceFile */ ? node.parent : node.parent.parent; if (container.kind === 244 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); @@ -56959,32 +57047,32 @@ var ts; return checkInferType(node); case 183 /* ImportType */: return checkImportType(node); - case 295 /* JSDocAugmentsTag */: + case 300 /* JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 304 /* JSDocTypedefTag */: - case 297 /* JSDocCallbackTag */: + case 309 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: return checkJSDocTypeAliasTag(node); - case 303 /* JSDocTemplateTag */: + case 308 /* JSDocTemplateTag */: return checkJSDocTemplateTag(node); - case 302 /* JSDocTypeTag */: + case 307 /* JSDocTypeTag */: return checkJSDocTypeTag(node); - case 299 /* JSDocParameterTag */: + case 304 /* JSDocParameterTag */: return checkJSDocParameterTag(node); - case 289 /* JSDocFunctionType */: + case 294 /* JSDocFunctionType */: checkJSDocFunctionType(node); // falls through - case 287 /* JSDocNonNullableType */: - case 286 /* JSDocNullableType */: - case 284 /* JSDocAllType */: - case 285 /* JSDocUnknownType */: - case 292 /* JSDocTypeLiteral */: + case 292 /* JSDocNonNullableType */: + case 291 /* JSDocNullableType */: + case 289 /* JSDocAllType */: + case 290 /* JSDocUnknownType */: + case 297 /* JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 290 /* JSDocVariadicType */: + case 295 /* JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 283 /* JSDocTypeExpression */: + case 288 /* JSDocTypeExpression */: return checkSourceElement(node.type); case 180 /* IndexedAccessType */: return checkIndexedAccessType(node); @@ -57292,7 +57380,7 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; // falls through @@ -57511,10 +57599,10 @@ var ts; return entityNameSymbol; } } - if (entityName.parent.kind === 299 /* JSDocParameterTag */) { + if (entityName.parent.kind === 304 /* JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(entityName.parent); } - if (entityName.parent.kind === 150 /* TypeParameter */ && entityName.parent.parent.kind === 303 /* JSDocTemplateTag */) { + if (entityName.parent.kind === 150 /* TypeParameter */ && entityName.parent.parent.kind === 308 /* JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJSFile(entityName)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(entityName.parent); return typeParameter && typeParameter.symbol; @@ -57556,7 +57644,7 @@ var ts; return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 279 /* SourceFile */) { + if (node.kind === 284 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; @@ -57898,7 +57986,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 279 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 284 /* SourceFile */) { var symbolFile = parentSymbol_1.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); // If `node` accesses an export and that export isn't in the same file, then symbol is a namespace export, so return undefined. @@ -58013,7 +58101,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 279 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 284 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -58442,7 +58530,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 279 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 284 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -58475,7 +58563,7 @@ var ts; if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 279 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 284 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -58707,7 +58795,7 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 279 /* SourceFile */) { + else if (node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 284 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128 /* Abstract */) { @@ -58730,7 +58818,7 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 279 /* SourceFile */) { + else if (node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 284 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } else if (node.kind === 151 /* Parameter */) { @@ -58775,7 +58863,7 @@ var ts; flags |= 1 /* Export */; break; case 80 /* DefaultKeyword */: - var container = node.parent.kind === 279 /* SourceFile */ ? node.parent : node.parent.parent; + var container = node.parent.kind === 284 /* SourceFile */ ? node.parent : node.parent.parent; if (container.kind === 244 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } @@ -58898,7 +58986,7 @@ var ts; case 151 /* Parameter */: return false; default: - if (node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 279 /* SourceFile */) { + if (node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 284 /* SourceFile */) { return false; } switch (node.kind) { @@ -59821,7 +59909,7 @@ var ts; // to prevent noisiness. So use a bit on the block to indicate if // this has already been reported, and don't report if it has. // - if (node.parent.kind === 218 /* Block */ || node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 279 /* SourceFile */) { + if (node.parent.kind === 218 /* Block */ || node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 284 /* SourceFile */) { var links_2 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_2.hasReportedStatementInAmbientContext) { @@ -61875,14 +61963,14 @@ var ts; // JSDoc /* @internal */ function createJSDocTypeExpression(type) { - var node = createSynthesizedNode(283 /* JSDocTypeExpression */); + var node = createSynthesizedNode(288 /* JSDocTypeExpression */); node.type = type; return node; } ts.createJSDocTypeExpression = createJSDocTypeExpression; /* @internal */ function createJSDocTypeTag(typeExpression, comment) { - var tag = createJSDocTag(302 /* JSDocTypeTag */, "type"); + var tag = createJSDocTag(307 /* JSDocTypeTag */, "type"); tag.typeExpression = typeExpression; tag.comment = comment; return tag; @@ -61890,7 +61978,7 @@ var ts; ts.createJSDocTypeTag = createJSDocTypeTag; /* @internal */ function createJSDocReturnTag(typeExpression, comment) { - var tag = createJSDocTag(300 /* JSDocReturnTag */, "returns"); + var tag = createJSDocTag(305 /* JSDocReturnTag */, "returns"); tag.typeExpression = typeExpression; tag.comment = comment; return tag; @@ -61898,7 +61986,7 @@ var ts; ts.createJSDocReturnTag = createJSDocReturnTag; /* @internal */ function createJSDocParamTag(name, isBracketed, typeExpression, comment) { - var tag = createJSDocTag(299 /* JSDocParameterTag */, "param"); + var tag = createJSDocTag(304 /* JSDocParameterTag */, "param"); tag.typeExpression = typeExpression; tag.name = name; tag.isBracketed = isBracketed; @@ -61908,7 +61996,7 @@ var ts; ts.createJSDocParamTag = createJSDocParamTag; /* @internal */ function createJSDocComment(comment, tags) { - var node = createSynthesizedNode(291 /* JSDocComment */); + var node = createSynthesizedNode(296 /* JSDocComment */); node.comment = comment; node.tags = tags; return node; @@ -62167,7 +62255,7 @@ var ts; (typeReferences !== undefined && node.typeReferenceDirectives !== typeReferences) || (libReferences !== undefined && node.libReferenceDirectives !== libReferences) || (hasNoDefaultLib !== undefined && node.hasNoDefaultLib !== hasNoDefaultLib)) { - var updated = createSynthesizedNode(279 /* SourceFile */); + var updated = createSynthesizedNode(284 /* SourceFile */); updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; @@ -62251,7 +62339,7 @@ var ts; * @param original The original statement. */ function createNotEmittedStatement(original) { - var node = createSynthesizedNode(307 /* NotEmittedStatement */); + var node = createSynthesizedNode(312 /* NotEmittedStatement */); node.original = original; setTextRange(node, original); return node; @@ -62263,7 +62351,7 @@ var ts; */ /* @internal */ function createEndOfDeclarationMarker(original) { - var node = createSynthesizedNode(311 /* EndOfDeclarationMarker */); + var node = createSynthesizedNode(316 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -62275,7 +62363,7 @@ var ts; */ /* @internal */ function createMergeDeclarationMarker(original) { - var node = createSynthesizedNode(310 /* MergeDeclarationMarker */); + var node = createSynthesizedNode(315 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -62290,7 +62378,7 @@ var ts; * @param location The location for the expression. Defaults to the positions from "original" if provided. */ function createPartiallyEmittedExpression(expression, original) { - var node = createSynthesizedNode(308 /* PartiallyEmittedExpression */); + var node = createSynthesizedNode(313 /* PartiallyEmittedExpression */); node.expression = expression; node.original = original; setTextRange(node, original); @@ -62306,7 +62394,7 @@ var ts; ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; function flattenCommaElements(node) { if (ts.nodeIsSynthesized(node) && !ts.isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) { - if (node.kind === 309 /* CommaListExpression */) { + if (node.kind === 314 /* CommaListExpression */) { return node.elements; } if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27 /* CommaToken */) { @@ -62316,7 +62404,7 @@ var ts; return node; } function createCommaList(elements) { - var node = createSynthesizedNode(309 /* CommaListExpression */); + var node = createSynthesizedNode(314 /* CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); return node; } @@ -62329,33 +62417,197 @@ var ts; ts.updateCommaList = updateCommaList; function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = ts.createNode(280 /* Bundle */); + var node = ts.createNode(285 /* Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; } ts.createBundle = createBundle; - function createUnparsedSourceFile(textOrInputFiles, mapPathOrType, map) { - var node = ts.createNode(281 /* UnparsedSource */); + var allUnscopedEmitHelpers; + function getAllUnscopedEmitHelpers() { + return allUnscopedEmitHelpers || (allUnscopedEmitHelpers = ts.arrayToMap([ + ts.valuesHelper, + ts.readHelper, + ts.spreadHelper, + ts.restHelper, + ts.decorateHelper, + ts.metadataHelper, + ts.paramHelper, + ts.awaiterHelper, + ts.assignHelper, + ts.awaitHelper, + ts.asyncGeneratorHelper, + ts.asyncDelegator, + ts.asyncValues, + ts.extendsHelper, + ts.templateObjectHelper, + ts.generatorHelper, + ts.importStarHelper, + ts.importDefaultHelper + ], function (helper) { return helper.name; })); + } + function createUnparsedSource() { + var node = ts.createNode(286 /* UnparsedSource */); + node.prologues = ts.emptyArray; + node.referencedFiles = ts.emptyArray; + node.libReferenceDirectives = ts.emptyArray; + node.getLineAndCharacterOfPosition = function (pos) { return ts.getLineAndCharacterOfPosition(node, pos); }; + return node; + } + function createUnparsedSourceFile(textOrInputFiles, mapPathOrType, mapTextOrStripInternal) { + var node = createUnparsedSource(); + var stripInternal; + var bundleFileInfo; if (!ts.isString(textOrInputFiles)) { ts.Debug.assert(mapPathOrType === "js" || mapPathOrType === "dts"); - node.fileName = mapPathOrType === "js" ? textOrInputFiles.javascriptPath : textOrInputFiles.declarationPath; + node.fileName = (mapPathOrType === "js" ? textOrInputFiles.javascriptPath : textOrInputFiles.declarationPath) || ""; node.sourceMapPath = mapPathOrType === "js" ? textOrInputFiles.javascriptMapPath : textOrInputFiles.declarationMapPath; Object.defineProperties(node, { text: { get: function () { return mapPathOrType === "js" ? textOrInputFiles.javascriptText : textOrInputFiles.declarationText; } }, sourceMapText: { get: function () { return mapPathOrType === "js" ? textOrInputFiles.javascriptMapText : textOrInputFiles.declarationMapText; } }, }); + if (textOrInputFiles.buildInfo && textOrInputFiles.buildInfo.bundle) { + node.oldFileOfCurrentEmit = textOrInputFiles.oldFileOfCurrentEmit; + ts.Debug.assert(mapTextOrStripInternal === undefined || typeof mapTextOrStripInternal === "boolean"); + stripInternal = mapTextOrStripInternal; + bundleFileInfo = mapPathOrType === "js" ? textOrInputFiles.buildInfo.bundle.js : textOrInputFiles.buildInfo.bundle.dts; + if (node.oldFileOfCurrentEmit) { + parseOldFileOfCurrentEmit(node, ts.Debug.assertDefined(bundleFileInfo)); + return node; + } + } } else { + node.fileName = ""; node.text = textOrInputFiles; node.sourceMapPath = mapPathOrType; - node.sourceMapText = map; + node.sourceMapText = mapTextOrStripInternal; } + ts.Debug.assert(!node.oldFileOfCurrentEmit); + parseUnparsedSourceFile(node, bundleFileInfo, stripInternal); return node; } ts.createUnparsedSourceFile = createUnparsedSourceFile; - function createInputFiles(javascriptTextOrReadFileText, declarationTextOrJavascriptPath, javascriptMapPath, javascriptMapTextOrDeclarationPath, declarationMapPath, declarationMapText) { - var node = ts.createNode(282 /* InputFiles */); + function parseUnparsedSourceFile(node, bundleFileInfo, stripInternal) { + var prologues; + var helpers; + var referencedFiles; + var typeReferenceDirectives; + var libReferenceDirectives; + var texts; + for (var _i = 0, _a = bundleFileInfo ? bundleFileInfo.sections : ts.emptyArray; _i < _a.length; _i++) { + var section = _a[_i]; + switch (section.kind) { + case "prologue" /* Prologue */: + (prologues || (prologues = [])).push(createUnparsedNode(section, node)); + break; + case "emitHelpers" /* EmitHelpers */: + (helpers || (helpers = [])).push(getAllUnscopedEmitHelpers().get(section.data)); + break; + case "no-default-lib" /* NoDefaultLib */: + node.hasNoDefaultLib = true; + break; + case "reference" /* Reference */: + (referencedFiles || (referencedFiles = [])).push({ pos: -1, end: -1, fileName: section.data }); + break; + case "type" /* Type */: + (typeReferenceDirectives || (typeReferenceDirectives = [])).push(section.data); + break; + case "lib" /* Lib */: + (libReferenceDirectives || (libReferenceDirectives = [])).push({ pos: -1, end: -1, fileName: section.data }); + break; + case "prepend" /* Prepend */: + var prependNode = createUnparsedNode(section, node); + var prependTexts = void 0; + for (var _b = 0, _c = section.texts; _b < _c.length; _b++) { + var text = _c[_b]; + if (!stripInternal || text.kind !== "internal" /* Internal */) { + (prependTexts || (prependTexts = [])).push(createUnparsedNode(text, node)); + } + } + prependNode.texts = prependTexts || ts.emptyArray; + (texts || (texts = [])).push(prependNode); + break; + case "internal" /* Internal */: + if (stripInternal) + break; + // falls through + case "text" /* Text */: + (texts || (texts = [])).push(createUnparsedNode(section, node)); + break; + default: + ts.Debug.assertNever(section); + } + } + node.prologues = prologues || ts.emptyArray; + node.helpers = helpers; + node.referencedFiles = referencedFiles || ts.emptyArray; + node.typeReferenceDirectives = typeReferenceDirectives; + node.libReferenceDirectives = libReferenceDirectives || ts.emptyArray; + node.texts = texts || [createUnparsedNode({ kind: "text" /* Text */, pos: 0, end: node.text.length }, node)]; + } + function parseOldFileOfCurrentEmit(node, bundleFileInfo) { + ts.Debug.assert(!!node.oldFileOfCurrentEmit); + var texts; + var syntheticReferences; + for (var _i = 0, _a = bundleFileInfo.sections; _i < _a.length; _i++) { + var section = _a[_i]; + switch (section.kind) { + case "internal" /* Internal */: + case "text" /* Text */: + (texts || (texts = [])).push(createUnparsedNode(section, node)); + break; + case "no-default-lib" /* NoDefaultLib */: + case "reference" /* Reference */: + case "type" /* Type */: + case "lib" /* Lib */: + (syntheticReferences || (syntheticReferences = [])).push(createUnparsedSyntheticReference(section, node)); + break; + // Ignore + case "prologue" /* Prologue */: + case "emitHelpers" /* EmitHelpers */: + case "prepend" /* Prepend */: + break; + default: + ts.Debug.assertNever(section); + } + } + node.texts = texts || ts.emptyArray; + node.helpers = ts.map(bundleFileInfo.sources && bundleFileInfo.sources.helpers, function (name) { return getAllUnscopedEmitHelpers().get(name); }); + node.syntheticReferences = syntheticReferences; + return node; + } + function mapBundleFileSectionKindToSyntaxKind(kind) { + switch (kind) { + case "prologue" /* Prologue */: return 279 /* UnparsedPrologue */; + case "prepend" /* Prepend */: return 280 /* UnparsedPrepend */; + case "internal" /* Internal */: return 282 /* UnparsedInternalText */; + case "text" /* Text */: return 281 /* UnparsedText */; + case "emitHelpers" /* EmitHelpers */: + case "no-default-lib" /* NoDefaultLib */: + case "reference" /* Reference */: + case "type" /* Type */: + case "lib" /* Lib */: + return ts.Debug.fail("BundleFileSectionKind: " + kind + " not yet mapped to SyntaxKind"); + default: + return ts.Debug.assertNever(kind); + } + } + function createUnparsedNode(section, parent) { + var node = ts.createNode(mapBundleFileSectionKindToSyntaxKind(section.kind), section.pos, section.end); + node.parent = parent; + node.data = section.data; + return node; + } + function createUnparsedSyntheticReference(section, parent) { + var node = ts.createNode(283 /* UnparsedSyntheticReference */, section.pos, section.end); + node.parent = parent; + node.data = section.data; + node.section = section; + return node; + } + function createInputFiles(javascriptTextOrReadFileText, declarationTextOrJavascriptPath, javascriptMapPath, javascriptMapTextOrDeclarationPath, declarationMapPath, declarationMapTextOrBuildInfoPath, javascriptPath, declarationPath, buildInfoPath, buildInfo, oldFileOfCurrentEmit) { + var node = ts.createNode(287 /* InputFiles */); if (!ts.isString(javascriptTextOrReadFileText)) { var cache_1 = ts.createMap(); var textGetter_1 = function (path) { @@ -62372,15 +62624,25 @@ var ts; var result = textGetter_1(path); return result !== undefined ? result : "/* Input file " + path + " was missing */\r\n"; }; + var buildInfo_1; + var getBuildInfo_1 = function (getText) { + if (buildInfo_1 === undefined) { + var result = getText(); + buildInfo_1 = result !== undefined ? JSON.parse(result) : false; + } + return buildInfo_1 || undefined; + }; node.javascriptPath = declarationTextOrJavascriptPath; node.javascriptMapPath = javascriptMapPath; node.declarationPath = ts.Debug.assertDefined(javascriptMapTextOrDeclarationPath); node.declarationMapPath = declarationMapPath; + node.buildInfoPath = declarationMapTextOrBuildInfoPath; Object.defineProperties(node, { javascriptText: { get: function () { return definedTextGetter_1(declarationTextOrJavascriptPath); } }, javascriptMapText: { get: function () { return textGetter_1(javascriptMapPath); } }, declarationText: { get: function () { return definedTextGetter_1(ts.Debug.assertDefined(javascriptMapTextOrDeclarationPath)); } }, - declarationMapText: { get: function () { return textGetter_1(declarationMapPath); } } // TODO:: if there is inline sourceMap in dtsFile, use that + declarationMapText: { get: function () { return textGetter_1(declarationMapPath); } }, + buildInfo: { get: function () { return getBuildInfo_1(function () { return textGetter_1(declarationMapTextOrBuildInfoPath); }); } } }); } else { @@ -62389,7 +62651,12 @@ var ts; node.javascriptMapText = javascriptMapTextOrDeclarationPath; node.declarationText = declarationTextOrJavascriptPath; node.declarationMapPath = declarationMapPath; - node.declarationMapText = declarationMapText; + node.declarationMapText = declarationMapTextOrBuildInfoPath; + node.javascriptPath = javascriptPath; + node.declarationPath = declarationPath, + node.buildInfoPath = buildInfoPath; + node.buildInfo = buildInfo; + node.oldFileOfCurrentEmit = oldFileOfCurrentEmit; } return node; } @@ -62527,7 +62794,7 @@ var ts; // To avoid holding onto transformation artifacts, we keep track of any // parse tree node we are annotating. This allows us to clean them up after // all transformations have completed. - if (node.kind === 279 /* SourceFile */) { + if (node.kind === 284 /* SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(ts.getParseTreeNode(ts.getSourceFileOfNode(node))); @@ -62973,38 +63240,38 @@ var ts; return ts.setEmitFlags(ts.createIdentifier(name), 4096 /* HelperName */ | 2 /* AdviseOnEmitNode */); } ts.getHelperName = getHelperName; - var valuesHelper = { + ts.valuesHelper = { name: "typescript:values", scoped: false, text: "\n var __values = (this && this.__values) || function (o) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator], i = 0;\n if (m) return m.call(o);\n return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n };" }; function createValuesHelper(context, expression, location) { - context.requestEmitHelper(valuesHelper); + context.requestEmitHelper(ts.valuesHelper); return ts.setTextRange(ts.createCall(getHelperName("__values"), /*typeArguments*/ undefined, [expression]), location); } ts.createValuesHelper = createValuesHelper; - var readHelper = { + ts.readHelper = { name: "typescript:read", scoped: false, text: "\n var __read = (this && this.__read) || function (o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n };" }; function createReadHelper(context, iteratorRecord, count, location) { - context.requestEmitHelper(readHelper); + context.requestEmitHelper(ts.readHelper); return ts.setTextRange(ts.createCall(getHelperName("__read"), /*typeArguments*/ undefined, count !== undefined ? [iteratorRecord, ts.createLiteral(count)] : [iteratorRecord]), location); } ts.createReadHelper = createReadHelper; - var spreadHelper = { + ts.spreadHelper = { name: "typescript:spread", scoped: false, text: "\n var __spread = (this && this.__spread) || function () {\n for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));\n return ar;\n };" }; function createSpreadHelper(context, argumentList, location) { - context.requestEmitHelper(readHelper); - context.requestEmitHelper(spreadHelper); + context.requestEmitHelper(ts.readHelper); + context.requestEmitHelper(ts.spreadHelper); return ts.setTextRange(ts.createCall(getHelperName("__spread"), /*typeArguments*/ undefined, argumentList), location); } @@ -63850,7 +64117,7 @@ var ts; case 190 /* ElementAccessExpression */: case 189 /* PropertyAccessExpression */: case 213 /* NonNullExpression */: - case 308 /* PartiallyEmittedExpression */: + case 313 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -63866,7 +64133,7 @@ var ts; ts.parenthesizeConciseBody = parenthesizeConciseBody; function isCommaSequence(node) { return node.kind === 204 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || - node.kind === 309 /* CommaListExpression */; + node.kind === 314 /* CommaListExpression */; } ts.isCommaSequence = isCommaSequence; var OuterExpressionKinds; @@ -63885,7 +64152,7 @@ var ts; case 212 /* AsExpression */: case 213 /* NonNullExpression */: return (kinds & 2 /* Assertions */) !== 0; - case 308 /* PartiallyEmittedExpression */: + case 313 /* PartiallyEmittedExpression */: return (kinds & 4 /* PartiallyEmittedExpressions */) !== 0; } return false; @@ -63922,7 +64189,7 @@ var ts; case 194 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); case 212 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); case 213 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); - case 308 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); + case 313 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -64714,12 +64981,12 @@ var ts; case 278 /* EnumMember */: return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); // Top-level nodes - case 279 /* SourceFile */: + case 284 /* SourceFile */: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 308 /* PartiallyEmittedExpression */: + case 313 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 309 /* CommaListExpression */: + case 314 /* CommaListExpression */: return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: // No need to visit nodes with no children. @@ -64775,7 +65042,7 @@ var ts; case 220 /* EmptyStatement */: case 210 /* OmittedExpression */: case 236 /* DebuggerStatement */: - case 307 /* NotEmittedStatement */: + case 312 /* NotEmittedStatement */: // No need to visit nodes with no children. break; // Names @@ -65152,14 +65419,14 @@ var ts; result = reduceNode(node.initializer, cbNode, result); break; // Top-level nodes - case 279 /* SourceFile */: + case 284 /* SourceFile */: result = reduceNodes(node.statements, cbNodes, result); break; // Transformation nodes - case 308 /* PartiallyEmittedExpression */: + case 313 /* PartiallyEmittedExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 309 /* CommaListExpression */: + case 314 /* CommaListExpression */: result = reduceNodes(node.elements, cbNodes, result); break; default: @@ -65440,7 +65707,7 @@ var ts; } exit(); } - function appendSourceMap(generatedLine, generatedCharacter, map, sourceMapPath) { + function appendSourceMap(generatedLine, generatedCharacter, map, sourceMapPath, start, end) { var _a; ts.Debug.assert(generatedLine >= pendingGeneratedLine, "generatedLine cannot backtrack"); ts.Debug.assert(generatedCharacter >= 0, "generatedCharacter cannot be negative"); @@ -65450,6 +65717,14 @@ var ts; var nameIndexToNewNameIndexMap; var mappingIterator = decodeMappings(map.mappings); for (var _b = mappingIterator.next(), raw = _b.value, done = _b.done; !done; _a = mappingIterator.next(), raw = _a.value, done = _a.done, _a) { + if (end && (raw.generatedLine > end.line || + (raw.generatedLine === end.line && raw.generatedCharacter > end.character))) { + break; + } + if (start && (raw.generatedLine < start.line || + (start.line === raw.generatedLine && raw.generatedCharacter < start.character))) { + continue; + } // Then reencode all the updated mappings into the overall map var newSourceIndex = void 0; var newSourceLine = void 0; @@ -65478,8 +65753,10 @@ var ts; } } } - var newGeneratedLine = raw.generatedLine + generatedLine; - var newGeneratedCharacter = raw.generatedLine === 0 ? raw.generatedCharacter + generatedCharacter : raw.generatedCharacter; + var rawGeneratedLine = raw.generatedLine - (start ? start.line : 0); + var newGeneratedLine = rawGeneratedLine + generatedLine; + var rawGeneratedCharacter = start && start.line === raw.generatedLine ? raw.generatedCharacter - start.character : raw.generatedCharacter; + var newGeneratedCharacter = rawGeneratedLine === 0 ? rawGeneratedCharacter + generatedCharacter : rawGeneratedCharacter; addMapping(newGeneratedLine, newGeneratedCharacter, newSourceIndex, newSourceLine, newSourceCharacter, newNameIndex); } exit(); @@ -65962,7 +66239,7 @@ var ts; function chainBundle(transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 279 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 284 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return ts.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -66623,7 +66900,7 @@ var ts; function makeAssignmentElement(name) { return name; } - var restHelper = { + ts.restHelper = { name: "typescript:rest", scoped: false, text: "\n var __rest = (this && this.__rest) || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)\n t[p[i]] = s[p[i]];\n return t;\n };" @@ -66632,7 +66909,7 @@ var ts; * `{ a, b, ...p } = o`, create `p = __rest(o, ["a", "b"]);` */ function createRestCall(context, value, elements, computedTempVariables, location) { - context.requestEmitHelper(restHelper); + context.requestEmitHelper(ts.restHelper); var propertyNames = []; var computedTempVariableOffset = 0; for (var i = 0; i < elements.length - 1; i++) { @@ -66733,14 +67010,14 @@ var ts; var pendingExpressions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 280 /* Bundle */) { + if (node.kind === 285 /* Bundle */) { return transformBundle(node); } return transformSourceFile(node); } function transformBundle(node) { return ts.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 282 /* InputFiles */) { + if (prepend.kind === 287 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend, "js"); } return prepend; @@ -66789,7 +67066,7 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: case 246 /* CaseBlock */: case 245 /* ModuleBlock */: case 218 /* Block */: @@ -69020,7 +69297,7 @@ var ts; // enums in any other scope are emitted as a `let` declaration. var statement = ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ ts.createVariableDeclaration(ts.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true)) - ], currentLexicalScope.kind === 279 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentLexicalScope.kind === 284 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { @@ -69585,7 +69862,7 @@ var ts; // If we are nested within a namespace declaration, we may need to qualifiy // an identifier that is exported from a merged namespace. var container = resolver.getReferencedExportContainer(node, /*prefixLocals*/ false); - if (container && container.kind !== 279 /* SourceFile */) { + if (container && container.kind !== 284 /* SourceFile */) { var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 244 /* ModuleDeclaration */) || (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 243 /* EnumDeclaration */); if (substitute) { @@ -69636,39 +69913,39 @@ var ts; argumentsArray.push(descriptor); } } - context.requestEmitHelper(decorateHelper); + context.requestEmitHelper(ts.decorateHelper); return ts.setTextRange(ts.createCall(ts.getHelperName("__decorate"), /*typeArguments*/ undefined, argumentsArray), location); } - var decorateHelper = { + ts.decorateHelper = { name: "typescript:decorate", scoped: false, priority: 2, text: "\n var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n };" }; function createMetadataHelper(context, metadataKey, metadataValue) { - context.requestEmitHelper(metadataHelper); + context.requestEmitHelper(ts.metadataHelper); return ts.createCall(ts.getHelperName("__metadata"), /*typeArguments*/ undefined, [ ts.createLiteral(metadataKey), metadataValue ]); } - var metadataHelper = { + ts.metadataHelper = { name: "typescript:metadata", scoped: false, priority: 3, text: "\n var __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n };" }; function createParamHelper(context, expression, parameterOffset, location) { - context.requestEmitHelper(paramHelper); + context.requestEmitHelper(ts.paramHelper); return ts.setTextRange(ts.createCall(ts.getHelperName("__param"), /*typeArguments*/ undefined, [ ts.createLiteral(parameterOffset), expression ]), location); } - var paramHelper = { + ts.paramHelper = { name: "typescript:param", scoped: false, priority: 4, @@ -70219,14 +70496,14 @@ var ts; ], 2 /* Const */)); } ts.createSuperAccessVariableStatement = createSuperAccessVariableStatement; - var awaiterHelper = { + ts.awaiterHelper = { name: "typescript:awaiter", scoped: false, priority: 5, text: "\n var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n };" }; function createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, body) { - context.requestEmitHelper(awaiterHelper); + context.requestEmitHelper(ts.awaiterHelper); var generatorFunc = ts.createFunctionExpression( /*modifiers*/ undefined, ts.createToken(40 /* AsteriskToken */), /*name*/ undefined, @@ -70858,7 +71135,7 @@ var ts; } } ts.transformES2018 = transformES2018; - var assignHelper = { + ts.assignHelper = { name: "typescript:assign", scoped: false, priority: 1, @@ -70869,28 +71146,28 @@ var ts; return ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "assign"), /*typeArguments*/ undefined, attributesSegments); } - context.requestEmitHelper(assignHelper); + context.requestEmitHelper(ts.assignHelper); return ts.createCall(ts.getHelperName("__assign"), /*typeArguments*/ undefined, attributesSegments); } ts.createAssignHelper = createAssignHelper; - var awaitHelper = { + ts.awaitHelper = { name: "typescript:await", scoped: false, text: "\n var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }" }; function createAwaitHelper(context, expression) { - context.requestEmitHelper(awaitHelper); + context.requestEmitHelper(ts.awaitHelper); return ts.createCall(ts.getHelperName("__await"), /*typeArguments*/ undefined, [expression]); } - var asyncGeneratorHelper = { + ts.asyncGeneratorHelper = { name: "typescript:asyncGenerator", scoped: false, text: "\n var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n };" }; function createAsyncGeneratorHelper(context, generatorFunc) { - context.requestEmitHelper(awaitHelper); - context.requestEmitHelper(asyncGeneratorHelper); + context.requestEmitHelper(ts.awaitHelper); + context.requestEmitHelper(ts.asyncGeneratorHelper); // Mark this node as originally an async function (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* AsyncFunctionBody */; return ts.createCall(ts.getHelperName("__asyncGenerator"), @@ -70900,24 +71177,24 @@ var ts; generatorFunc ]); } - var asyncDelegator = { + ts.asyncDelegator = { name: "typescript:asyncDelegator", scoped: false, text: "\n var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {\n var i, p;\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\n };" }; function createAsyncDelegatorHelper(context, expression, location) { - context.requestEmitHelper(awaitHelper); - context.requestEmitHelper(asyncDelegator); + context.requestEmitHelper(ts.awaitHelper); + context.requestEmitHelper(ts.asyncDelegator); return ts.setTextRange(ts.createCall(ts.getHelperName("__asyncDelegator"), /*typeArguments*/ undefined, [expression]), location); } - var asyncValues = { + ts.asyncValues = { name: "typescript:asyncValues", scoped: false, text: "\n var __asyncValues = (this && this.__asyncValues) || function (o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator], i;\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\n };" }; function createAsyncValuesHelper(context, expression, location) { - context.requestEmitHelper(asyncValues); + context.requestEmitHelper(ts.asyncValues); return ts.setTextRange(ts.createCall(ts.getHelperName("__asyncValues"), /*typeArguments*/ undefined, [expression]), location); } @@ -74729,7 +75006,7 @@ var ts; } ts.transformES2015 = transformES2015; function createExtendsHelper(context, name) { - context.requestEmitHelper(extendsHelper); + context.requestEmitHelper(ts.extendsHelper); return ts.createCall(ts.getHelperName("__extends"), /*typeArguments*/ undefined, [ name, @@ -74737,20 +75014,20 @@ var ts; ]); } function createTemplateObjectHelper(context, cooked, raw) { - context.requestEmitHelper(templateObjectHelper); + context.requestEmitHelper(ts.templateObjectHelper); return ts.createCall(ts.getHelperName("__makeTemplateObject"), /*typeArguments*/ undefined, [ cooked, raw ]); } - var extendsHelper = { + ts.extendsHelper = { name: "typescript:extends", scoped: false, priority: 0, text: "\n var __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n })();" }; - var templateObjectHelper = { + ts.templateObjectHelper = { name: "typescript:makeTemplateObject", scoped: false, priority: 0, @@ -77444,7 +77721,7 @@ var ts; } ts.transformGenerators = transformGenerators; function createGeneratorHelper(context, body) { - context.requestEmitHelper(generatorHelper); + context.requestEmitHelper(ts.generatorHelper); return ts.createCall(ts.getHelperName("__generator"), /*typeArguments*/ undefined, [ts.createThis(), body]); } @@ -77507,7 +77784,7 @@ var ts; // entering a finally block. // // For examples of how these are used, see the comments in ./transformers/generators.ts - var generatorHelper = { + ts.generatorHelper = { name: "typescript:generator", scoped: false, priority: 6, @@ -77540,7 +77817,7 @@ var ts; context.enableSubstitution(202 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. context.enableSubstitution(203 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. context.enableSubstitution(276 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(279 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableEmitNotification(284 /* SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var currentSourceFile; // The current file. @@ -77882,9 +78159,9 @@ var ts; return visitFunctionDeclaration(node); case 240 /* ClassDeclaration */: return visitClassDeclaration(node); - case 310 /* MergeDeclarationMarker */: + case 315 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 311 /* EndOfDeclarationMarker */: + case 316 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); @@ -78042,7 +78319,7 @@ var ts; } var promise = ts.createNew(ts.createIdentifier("Promise"), /*typeArguments*/ undefined, [func]); if (compilerOptions.esModuleInterop) { - context.requestEmitHelper(importStarHelper); + context.requestEmitHelper(ts.importStarHelper); return ts.createCall(ts.createPropertyAccess(promise, ts.createIdentifier("then")), /*typeArguments*/ undefined, [ts.getHelperName("__importStar")]); } return promise; @@ -78056,7 +78333,7 @@ var ts; var promiseResolveCall = ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Promise"), "resolve"), /*typeArguments*/ undefined, /*argumentsArray*/ []); var requireCall = ts.createCall(ts.createIdentifier("require"), /*typeArguments*/ undefined, arg ? [arg] : []); if (compilerOptions.esModuleInterop) { - context.requestEmitHelper(importStarHelper); + context.requestEmitHelper(ts.importStarHelper); requireCall = ts.createCall(ts.getHelperName("__importStar"), /*typeArguments*/ undefined, [requireCall]); } var func; @@ -78090,11 +78367,11 @@ var ts; return innerExpr; } if (ts.getImportNeedsImportStarHelper(node)) { - context.requestEmitHelper(importStarHelper); + context.requestEmitHelper(ts.importStarHelper); return ts.createCall(ts.getHelperName("__importStar"), /*typeArguments*/ undefined, [innerExpr]); } if (ts.getImportNeedsImportDefaultHelper(node)) { - context.requestEmitHelper(importDefaultHelper); + context.requestEmitHelper(ts.importDefaultHelper); return ts.createCall(ts.getHelperName("__importDefault"), /*typeArguments*/ undefined, [innerExpr]); } return innerExpr; @@ -78663,7 +78940,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 279 /* SourceFile */) { + if (node.kind === 284 /* SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -78751,7 +79028,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 279 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 284 /* SourceFile */) { return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), /*location*/ node); } @@ -78877,13 +79154,13 @@ var ts; text: "\n var __syncRequire = typeof module === \"object\" && typeof module.exports === \"object\";" }; // emit helper for `import * as Name from "foo"` - var importStarHelper = { + ts.importStarHelper = { name: "typescript:commonjsimportstar", scoped: false, text: "\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\n result[\"default\"] = mod;\n return result;\n};" }; // emit helper for `import Name from "foo"` - var importDefaultHelper = { + ts.importDefaultHelper = { name: "typescript:commonjsimportdefault", scoped: false, text: "\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};" @@ -78906,7 +79183,7 @@ var ts; context.enableSubstitution(204 /* BinaryExpression */); // Substitutes assignments to exported symbols. context.enableSubstitution(202 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. context.enableSubstitution(203 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableEmitNotification(279 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableEmitNotification(284 /* SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var exportFunctionsMap = []; // The export function associated with a source file. @@ -79476,7 +79753,7 @@ var ts; function shouldHoistVariableDeclarationList(node) { // hoist only non-block scoped declarations or block scoped declarations parented by source file return (ts.getEmitFlags(node) & 2097152 /* NoHoisting */) === 0 - && (enclosingBlockScopedContainer.kind === 279 /* SourceFile */ + && (enclosingBlockScopedContainer.kind === 284 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -79819,9 +80096,9 @@ var ts; return visitCatchClause(node); case 218 /* Block */: return visitBlock(node); - case 310 /* MergeDeclarationMarker */: + case 315 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 311 /* EndOfDeclarationMarker */: + case 316 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -80069,7 +80346,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 279 /* SourceFile */; + return container !== undefined && container.kind === 284 /* SourceFile */; } else { return false; @@ -80102,7 +80379,7 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 279 /* SourceFile */) { + if (node.kind === 284 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -80311,7 +80588,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 279 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 284 /* SourceFile */) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -80350,7 +80627,7 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(279 /* SourceFile */); + context.enableEmitNotification(284 /* SourceFile */); context.enableSubstitution(72 /* Identifier */); var currentSourceFile; return ts.chainBundle(transformSourceFile); @@ -80863,6 +81140,15 @@ var ts; return result.diagnostics; } ts.getDeclarationDiagnostics = getDeclarationDiagnostics; + function isInternalDeclaration(node, currentSourceFile) { + var parseTreeNode = ts.getParseTreeNode(node); + var leadingCommentRanges = parseTreeNode && ts.getLeadingCommentRangesOfNode(parseTreeNode, currentSourceFile); + return !!ts.forEach(leadingCommentRanges, function (range) { + var comment = currentSourceFile.text.substring(range.pos, range.end); + return ts.stringContains(comment, "@internal"); + }); + } + ts.isInternalDeclaration = isInternalDeclaration; var declarationEmitNodeBuilderFlags = 1024 /* MultilineObjectLiterals */ | 2048 /* WriteClassExpressionAsTypeLiteral */ | 4096 /* UseTypeOfFunction */ | @@ -80991,10 +81277,10 @@ var ts; } } function transformRoot(node) { - if (node.kind === 279 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJS(node))) { + if (node.kind === 284 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJS(node))) { return node; } - if (node.kind === 280 /* Bundle */) { + if (node.kind === 285 /* Bundle */) { isBundledEmit = true; refs = ts.createMap(); libs = ts.createMap(); @@ -81024,9 +81310,15 @@ var ts; var updated = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); return ts.updateSourceFileNode(sourceFile, transformAndReplaceLatePaintedStatements(updated), /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); }), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 282 /* InputFiles */) { - return ts.createUnparsedSourceFile(prepend, "dts"); + if (prepend.kind === 287 /* InputFiles */) { + var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal); + hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib; + collectReferences(sourceFile, refs); + recordTypeReferenceDirectivesIfNecessary(sourceFile.typeReferenceDirectives); + collectLibs(sourceFile, libs); + return sourceFile; } + return prepend; })); bundle.syntheticFileReferences = []; bundle.syntheticTypeReferences = getFileReferencesForUsedTypeReferences(); @@ -81118,7 +81410,7 @@ var ts; } } function collectReferences(sourceFile, ret) { - if (noResolve || ts.isSourceFileJS(sourceFile)) + if (noResolve || (!ts.isUnparsedSource(sourceFile) && ts.isSourceFileJS(sourceFile))) return ret; ts.forEach(sourceFile.referencedFiles, function (f) { var elem = ts.tryResolveScriptReference(host, sourceFile, f); @@ -81846,18 +82138,8 @@ var ts; } errorNameNode = undefined; } - function hasInternalAnnotation(range) { - var comment = currentSourceFile.text.substring(range.pos, range.end); - return ts.stringContains(comment, "@internal"); - } function shouldStripInternal(node) { - if (stripInternal && node) { - var leadingCommentRanges = ts.getLeadingCommentRangesOfNode(ts.getParseTreeNode(node), currentSourceFile); - if (ts.forEach(leadingCommentRanges, hasInternalAnnotation)) { - return true; - } - } - return false; + return !!stripInternal && !!node && isInternalDeclaration(node, currentSourceFile); } function isScopeMarker(node) { return ts.isExportAssignment(node) || ts.isExportDeclaration(node); @@ -81879,7 +82161,7 @@ var ts; function ensureModifierFlags(node, privateDeclaration) { var mask = 3071 /* All */ ^ (4 /* Public */ | 256 /* Async */); // No async modifiers in declaration files var additions = (needsDeclare && !isAlwaysType(node)) ? 2 /* Ambient */ : 0 /* None */; - var parentIsFile = node.parent.kind === 279 /* SourceFile */; + var parentIsFile = node.parent.kind === 284 /* SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= ((privateDeclaration || (isBundledEmit && parentIsFile) || hasScopeMarker(node.parent) ? 0 : 1 /* Export */) | 2 /* Ambient */); additions = 0 /* None */; @@ -82096,7 +82378,7 @@ var ts; * @param allowDtsFiles A value indicating whether to allow the transformation of .d.ts files. */ function transformNodes(resolver, host, options, nodes, transformers, allowDtsFiles) { - var enabledSyntaxKindFeatures = new Array(312 /* Count */); + var enabledSyntaxKindFeatures = new Array(317 /* Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentVariableDeclarationsStack = []; @@ -82356,10 +82638,14 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - var infoExtension = ".tsbundleinfo"; var brackets = createBracketsMap(); var syntheticParent = { pos: -1, end: -1 }; /*@internal*/ + function isBuildInfoFile(file) { + return ts.fileExtensionIs(file, ".tsbuildinfo" /* TsBuildInfo */); + } + ts.isBuildInfoFile = isBuildInfoFile; + /*@internal*/ /** * Iterates over the source files that are expected to have an emit output. * @@ -82369,13 +82655,14 @@ var ts; * If an array, the full list of source files to emit. * Else, calls `getSourceFilesToEmit` with the (optional) target source file to determine the list of source files to emit. */ - function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, emitOnlyDtsFiles) { + function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, emitOnlyDtsFiles, onlyBuildInfo, includeBuildInfo) { if (emitOnlyDtsFiles === void 0) { emitOnlyDtsFiles = false; } var sourceFiles = ts.isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : ts.getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile); var options = host.getCompilerOptions(); if (options.outFile || options.out) { - if (sourceFiles.length) { - var bundle = ts.createBundle(sourceFiles, host.getPrependNodes()); + var prepends = host.getPrependNodes(); + if (sourceFiles.length || prepends.length) { + var bundle = ts.createBundle(sourceFiles, prepends); var result = action(getOutputPathsFor(bundle, host, emitOnlyDtsFiles), bundle); if (result) { return result; @@ -82383,31 +82670,61 @@ var ts; } } else { - for (var _a = 0, sourceFiles_1 = sourceFiles; _a < sourceFiles_1.length; _a++) { - var sourceFile = sourceFiles_1[_a]; - var result = action(getOutputPathsFor(sourceFile, host, emitOnlyDtsFiles), sourceFile); - if (result) { - return result; + if (!onlyBuildInfo) { + for (var _a = 0, sourceFiles_1 = sourceFiles; _a < sourceFiles_1.length; _a++) { + var sourceFile = sourceFiles_1[_a]; + var result = action(getOutputPathsFor(sourceFile, host, emitOnlyDtsFiles), sourceFile); + if (result) { + return result; + } } } + if (includeBuildInfo) { + var buildInfoPath = getOutputPathForBuildInfo(host.getCompilerOptions()); + if (buildInfoPath) + return action({ buildInfoPath: buildInfoPath }, /*sourceFileOrBundle*/ undefined); + } } } ts.forEachEmittedFile = forEachEmittedFile; /*@internal*/ + function getOutputPathForBuildInfo(options) { + var configFile = options.configFilePath; + if (!configFile || !ts.isIncrementalCompilation(options)) + return undefined; + if (options.tsBuildInfoFile) + return options.tsBuildInfoFile; + var outPath = options.outFile || options.out; + var buildInfoExtensionLess; + if (outPath) { + buildInfoExtensionLess = ts.removeFileExtension(outPath); + } + else { + var configFileExtensionLess = ts.removeFileExtension(configFile); + buildInfoExtensionLess = options.outDir ? + options.rootDir ? + ts.resolvePath(options.outDir, ts.getRelativePathFromDirectory(options.rootDir, configFileExtensionLess, /*ignoreCase*/ true)) : + ts.combinePaths(options.outDir, ts.getBaseFileName(configFileExtensionLess)) : + configFileExtensionLess; + } + return buildInfoExtensionLess + ".tsbuildinfo" /* TsBuildInfo */; + } + ts.getOutputPathForBuildInfo = getOutputPathForBuildInfo; + /*@internal*/ function getOutputPathsForBundle(options, forceDtsPaths) { var outPath = options.outFile || options.out; var jsFilePath = options.emitDeclarationOnly ? undefined : outPath; var sourceMapFilePath = jsFilePath && getSourceMapFilePath(jsFilePath, options); var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.removeFileExtension(outPath) + ".d.ts" /* Dts */ : undefined; var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; - var bundleInfoPath = options.references && jsFilePath ? (ts.removeFileExtension(jsFilePath) + infoExtension) : undefined; - return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, bundleInfoPath: bundleInfoPath }; + var buildInfoPath = getOutputPathForBuildInfo(options); + return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: buildInfoPath }; } ts.getOutputPathsForBundle = getOutputPathsForBundle; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 280 /* Bundle */) { + if (sourceFile.kind === 285 /* Bundle */) { return getOutputPathsForBundle(options, forceDtsPaths); } else { @@ -82421,19 +82738,13 @@ var ts; var isJs = ts.isSourceFileJS(sourceFile); var declarationFilePath = ((forceDtsPaths || ts.getEmitDeclarations(options)) && !isJs) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; - return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, bundleInfoPath: undefined }; + return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: undefined }; } } ts.getOutputPathsFor = getOutputPathsFor; function getSourceMapFilePath(jsFilePath, options) { return (options.sourceMap && !options.inlineSourceMap) ? jsFilePath + ".map" : undefined; } - function createDefaultBundleInfo() { - return { - originalOffset: -1, - totalLength: -1 - }; - } // JavaScript files are always LanguageVariant.JSX, as JSX syntax is allowed in .js files also. // So for JavaScript files, '.jsx' is only emitted if the input was '.jsx', and JsxEmit.Preserve. // For TypeScript, the only time to emit with a '.jsx' extension, is on JSX input, and JsxEmit.Preserve @@ -82458,7 +82769,7 @@ var ts; ts.getOutputExtension = getOutputExtension; /*@internal*/ // targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature - function emitFiles(resolver, host, targetSourceFile, emitOnlyDtsFiles, transformers, declarationTransformers) { + function emitFiles(resolver, host, targetSourceFile, emitOnlyDtsFiles, transformers, declarationTransformers, onlyBuildInfo) { var compilerOptions = host.getCompilerOptions(); var sourceMapDataList = (compilerOptions.sourceMap || compilerOptions.inlineSourceMap || ts.getAreDeclarationMapsEnabled(compilerOptions)) ? [] : undefined; var emittedFilesList = compilerOptions.listEmittedFiles ? [] : undefined; @@ -82466,12 +82777,12 @@ var ts; var newLine = ts.getNewLineCharacter(compilerOptions, function () { return host.getNewLine(); }); var writer = ts.createTextWriter(newLine); var _a = ts.performance.createTimer("printTime", "beforePrint", "afterPrint"), enter = _a.enter, exit = _a.exit; - var bundleInfo = createDefaultBundleInfo(); + var bundleBuildInfo; var emitSkipped = false; var exportedModulesFromDeclarationEmit; // Emit each output file enter(); - forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), emitOnlyDtsFiles); + forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), emitOnlyDtsFiles, onlyBuildInfo, !targetSourceFile); exit(); return { emitSkipped: emitSkipped, @@ -82481,9 +82792,16 @@ var ts; exportedModulesFromDeclarationEmit: exportedModulesFromDeclarationEmit }; function emitSourceFileOrBundle(_a, sourceFileOrBundle) { - var jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, bundleInfoPath = _a.bundleInfoPath; - emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, bundleInfoPath); + var jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath; + if (buildInfoPath && sourceFileOrBundle && ts.isBundle(sourceFileOrBundle)) { + bundleBuildInfo = { + commonSourceDirectory: host.getCommonSourceDirectory(), + sourceFiles: sourceFileOrBundle.sourceFiles.map(function (file) { return file.fileName; }) + }; + } + emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath); emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath); + emitBuildInfo(bundleBuildInfo, buildInfoPath); if (!emitSkipped && emittedFilesList) { if (!emitOnlyDtsFiles) { if (jsFilePath) { @@ -82492,8 +82810,8 @@ var ts; if (sourceMapFilePath) { emittedFilesList.push(sourceMapFilePath); } - if (bundleInfoPath) { - emittedFilesList.push(bundleInfoPath); + if (buildInfoPath) { + emittedFilesList.push(buildInfoPath); } } if (declarationFilePath) { @@ -82504,8 +82822,21 @@ var ts; } } } - function emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, bundleInfoPath) { - if (emitOnlyDtsFiles || !jsFilePath) { + function emitBuildInfo(bundle, buildInfoPath) { + // Write build information if applicable + if (!buildInfoPath || targetSourceFile || emitSkipped) + return; + var program = host.getProgramBuildInfo(); + if (!bundle && !program) + return; + if (host.isEmitBlocked(buildInfoPath) || compilerOptions.noEmit) { + emitSkipped = true; + return; + } + ts.writeFile(host, emitterDiagnostics, buildInfoPath, getBuildInfoText({ bundle: bundle, program: program }), /*writeByteOrderMark*/ false); + } + function emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath) { + if (!sourceFileOrBundle || emitOnlyDtsFiles || !jsFilePath) { return; } // Make sure not to write js file and source map file if any of them cannot be written @@ -82525,6 +82856,7 @@ var ts; inlineSourceMap: compilerOptions.inlineSourceMap, inlineSources: compilerOptions.inlineSources, extendedDiagnostics: compilerOptions.extendedDiagnostics, + writeBundleFileInfo: !!bundleBuildInfo }; // Create a printer to print the nodes var printer = createPrinter(printerOptions, { @@ -82535,12 +82867,14 @@ var ts; substituteNode: transform.substituteNode, }); ts.Debug.assert(transform.transformed.length === 1, "Should only see one output from the transform"); - printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform.transformed[0], bundleInfoPath, printer, compilerOptions); + printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform.transformed[0], printer, compilerOptions); // Clean up emit nodes on parse tree transform.dispose(); + if (bundleBuildInfo) + bundleBuildInfo.js = printer.bundleFileInfo; } function emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath) { - if (!(declarationFilePath && !ts.isInJSFile(sourceFileOrBundle))) { + if (!sourceFileOrBundle || !(declarationFilePath && !ts.isInJSFile(sourceFileOrBundle))) { return; } var sourceFiles = ts.isSourceFile(sourceFileOrBundle) ? [sourceFileOrBundle] : sourceFileOrBundle.sourceFiles; @@ -82569,6 +82903,8 @@ var ts; inlineSourceMap: compilerOptions.inlineSourceMap, extendedDiagnostics: compilerOptions.extendedDiagnostics, onlyPrintJsDocStyle: true, + writeBundleFileInfo: !!bundleBuildInfo, + recordInternalSection: !!bundleBuildInfo }; var declarationPrinter = createPrinter(printerOptions, { // resolver hooks @@ -82581,18 +82917,20 @@ var ts; emitSkipped = emitSkipped || declBlocked; if (!declBlocked || emitOnlyDtsFiles) { ts.Debug.assert(declarationTransform.transformed.length === 1, "Should only see one output from the decl transform"); - printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], /* bundleInfopath*/ undefined, declarationPrinter, { + printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], declarationPrinter, { sourceMap: compilerOptions.declarationMap, sourceRoot: compilerOptions.sourceRoot, mapRoot: compilerOptions.mapRoot, extendedDiagnostics: compilerOptions.extendedDiagnostics, }); - if (emitOnlyDtsFiles && declarationTransform.transformed[0].kind === 279 /* SourceFile */) { + if (emitOnlyDtsFiles && declarationTransform.transformed[0].kind === 284 /* SourceFile */) { var sourceFile = declarationTransform.transformed[0]; exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit; } } declarationTransform.dispose(); + if (bundleBuildInfo) + bundleBuildInfo.dts = declarationPrinter.bundleFileInfo; } function collectLinkedAliases(node) { if (ts.isExportAssignment(node)) { @@ -82607,16 +82945,16 @@ var ts; } ts.forEachChild(node, collectLinkedAliases); } - function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, bundleInfoPath, printer, mapOptions) { - var bundle = sourceFileOrBundle.kind === 280 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 279 /* SourceFile */ ? sourceFileOrBundle : undefined; + function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) { + var bundle = sourceFileOrBundle.kind === 285 /* Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 284 /* SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; var sourceMapGenerator; if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) { sourceMapGenerator = ts.createSourceMapGenerator(host, ts.getBaseFileName(ts.normalizeSlashes(jsFilePath)), getSourceRoot(mapOptions), getSourceMapDirectory(mapOptions, jsFilePath, sourceFile), mapOptions); } if (bundle) { - printer.writeBundle(bundle, bundleInfo, writer, sourceMapGenerator); + printer.writeBundle(bundle, writer, sourceMapGenerator); } else { printer.writeFile(sourceFile, writer, sourceMapGenerator); @@ -82645,18 +82983,12 @@ var ts; } // Write the output file ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles); - // Write bundled offset information if applicable - if (bundleInfoPath) { - bundleInfo.totalLength = writer.getTextPos(); - ts.writeFile(host, emitterDiagnostics, bundleInfoPath, JSON.stringify(bundleInfo, undefined, 2), /*writeByteOrderMark*/ false); - } // Reset state writer.clear(); - bundleInfo = createDefaultBundleInfo(); } function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) { return (mapOptions.sourceMap || mapOptions.inlineSourceMap) - && (sourceFileOrBundle.kind !== 279 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); + && (sourceFileOrBundle.kind !== 284 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); } function getSourceRoot(mapOptions) { // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the @@ -82713,6 +83045,161 @@ var ts; } } ts.emitFiles = emitFiles; + /*@internal*/ + function getBuildInfoText(buildInfo) { + return JSON.stringify(buildInfo, undefined, 2); + } + ts.getBuildInfoText = getBuildInfoText; + /*@internal*/ + ts.notImplementedResolver = { + hasGlobalName: ts.notImplemented, + getReferencedExportContainer: ts.notImplemented, + getReferencedImportDeclaration: ts.notImplemented, + getReferencedDeclarationWithCollidingName: ts.notImplemented, + isDeclarationWithCollidingName: ts.notImplemented, + isValueAliasDeclaration: ts.notImplemented, + isReferencedAliasDeclaration: ts.notImplemented, + isTopLevelValueImportEqualsWithEntityName: ts.notImplemented, + getNodeCheckFlags: ts.notImplemented, + isDeclarationVisible: ts.notImplemented, + isLateBound: function (_node) { return false; }, + collectLinkedAliases: ts.notImplemented, + isImplementationOfOverload: ts.notImplemented, + isRequiredInitializedParameter: ts.notImplemented, + isOptionalUninitializedParameterProperty: ts.notImplemented, + isExpandoFunctionDeclaration: ts.notImplemented, + getPropertiesOfContainerFunction: ts.notImplemented, + createTypeOfDeclaration: ts.notImplemented, + createReturnTypeOfSignatureDeclaration: ts.notImplemented, + createTypeOfExpression: ts.notImplemented, + createLiteralConstValue: ts.notImplemented, + isSymbolAccessible: ts.notImplemented, + isEntityNameVisible: ts.notImplemented, + // Returns the constant value this property access resolves to: notImplemented, or 'undefined' for a non-constant + getConstantValue: ts.notImplemented, + getReferencedValueDeclaration: ts.notImplemented, + getTypeReferenceSerializationKind: ts.notImplemented, + isOptionalParameter: ts.notImplemented, + moduleExportsSomeValue: ts.notImplemented, + isArgumentsLocalBinding: ts.notImplemented, + getExternalModuleFileFromDeclaration: ts.notImplemented, + getTypeReferenceDirectivesForEntityName: ts.notImplemented, + getTypeReferenceDirectivesForSymbol: ts.notImplemented, + isLiteralConstDeclaration: ts.notImplemented, + getJsxFactoryEntity: ts.notImplemented, + getAllAccessorDeclarations: ts.notImplemented, + getSymbolOfExternalModuleSpecifier: ts.notImplemented, + isBindingCapturedByNode: ts.notImplemented, + }; + function createSourceFilesFromBundleBuildInfo(bundle) { + var sourceFiles = bundle.sourceFiles.map(function (fileName) { + var sourceFile = ts.createNode(284 /* SourceFile */, 0, 0); + sourceFile.fileName = fileName; + sourceFile.text = ""; + sourceFile.statements = ts.createNodeArray(); + return sourceFile; + }); + var jsBundle = ts.Debug.assertDefined(bundle.js); + ts.forEach(jsBundle.sources && jsBundle.sources.prologues, function (prologueInfo) { + var sourceFile = sourceFiles[prologueInfo.file]; + sourceFile.text = prologueInfo.text; + sourceFile.end = prologueInfo.text.length; + sourceFile.statements = ts.createNodeArray(prologueInfo.directives.map(function (directive) { + var statement = ts.createNode(221 /* ExpressionStatement */, directive.pos, directive.end); + statement.expression = ts.createNode(10 /* StringLiteral */, directive.expression.pos, directive.expression.end); + statement.expression.text = directive.expression.text; + return statement; + })); + }); + return sourceFiles; + } + /*@internal*/ + function emitUsingBuildInfo(config, host, getCommandLine) { + var _a = getOutputPathsForBundle(config.options, /*forceDtsPaths*/ false), buildInfoPath = _a.buildInfoPath, jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath; + var buildInfoText = host.readFile(ts.Debug.assertDefined(buildInfoPath)); + if (!buildInfoText) + return buildInfoPath; + var jsFileText = host.readFile(ts.Debug.assertDefined(jsFilePath)); + if (!jsFileText) + return jsFilePath; + var sourceMapText = sourceMapFilePath && host.readFile(sourceMapFilePath); + // error if no source map or for now if inline sourcemap + if ((sourceMapFilePath && !sourceMapText) || config.options.inlineSourceMap) + return sourceMapFilePath || "inline sourcemap decoding"; + // read declaration text + var declarationText = declarationFilePath && host.readFile(declarationFilePath); + if (declarationFilePath && !declarationText) + return declarationFilePath; + var declarationMapText = declarationMapPath && host.readFile(declarationMapPath); + // error if no source map or for now if inline sourcemap + if ((declarationMapPath && !declarationMapText) || config.options.inlineSourceMap) + return declarationMapPath || "inline sourcemap decoding"; + var buildInfo = JSON.parse(buildInfoText); + if (!buildInfo.bundle || !buildInfo.bundle.js || (declarationText && !buildInfo.bundle.dts)) + return buildInfoPath; + var ownPrependInput = ts.createInputFiles(jsFileText, declarationText, sourceMapFilePath, sourceMapText, declarationMapPath, declarationMapText, jsFilePath, declarationFilePath, buildInfoPath, buildInfo, + /*onlyOwnText*/ true); + var outputFiles = []; + var prependNodes = ts.createPrependNodes(config.projectReferences, getCommandLine, function (f) { return host.readFile(f); }); + var sourceFilesForJsEmit = createSourceFilesFromBundleBuildInfo(buildInfo.bundle); + var emitHost = { + getPrependNodes: ts.memoize(function () { return prependNodes.concat([ownPrependInput]); }), + getCanonicalFileName: host.getCanonicalFileName, + getCommonSourceDirectory: function () { return buildInfo.bundle.commonSourceDirectory; }, + getCompilerOptions: function () { return config.options; }, + getCurrentDirectory: function () { return host.getCurrentDirectory(); }, + getNewLine: function () { return host.getNewLine(); }, + getSourceFile: function () { return undefined; }, + getSourceFileByPath: function () { return undefined; }, + getSourceFiles: function () { return sourceFilesForJsEmit; }, + getLibFileFromReference: ts.notImplemented, + isSourceFileFromExternalLibrary: ts.returnFalse, + writeFile: function (name, text, writeByteOrderMark) { + switch (name) { + case jsFilePath: + if (jsFileText === text) + return; + break; + case sourceMapFilePath: + if (sourceMapText === text) + return; + break; + case buildInfoPath: + var newBuildInfo = JSON.parse(text); + newBuildInfo.program = buildInfo.program; + // Update sourceFileInfo + var _a = buildInfo.bundle, js = _a.js, dts = _a.dts, sourceFiles = _a.sourceFiles; + newBuildInfo.bundle.js.sources = js.sources; + if (dts) { + newBuildInfo.bundle.dts.sources = dts.sources; + } + newBuildInfo.bundle.sourceFiles = sourceFiles; + outputFiles.push({ name: name, text: getBuildInfoText(newBuildInfo), writeByteOrderMark: writeByteOrderMark }); + return; + case declarationFilePath: + if (declarationText === text) + return; + break; + case declarationMapPath: + if (declarationMapText === text) + return; + break; + default: + ts.Debug.assertNever(name); + } + outputFiles.push({ name: name, text: text, writeByteOrderMark: writeByteOrderMark }); + }, + isEmitBlocked: ts.returnFalse, + readFile: function (f) { return host.readFile(f); }, + fileExists: function (f) { return host.fileExists(f); }, + directoryExists: host.directoryExists && (function (f) { return host.directoryExists(f); }), + useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, + getProgramBuildInfo: function () { return undefined; } + }; + emitFiles(ts.notImplementedResolver, emitHost, /*targetSourceFile*/ undefined, /*emitOnlyDtsFiles*/ false, ts.getTransformers(config.options)); + return outputFiles; + } + ts.emitUsingBuildInfo = emitUsingBuildInfo; var PipelinePhase; (function (PipelinePhase) { PipelinePhase[PipelinePhase["Notification"] = 0] = "Notification"; @@ -82741,6 +83228,10 @@ var ts; var ownWriter; // Reusable `EmitTextWriter` for basic printing. var write = writeBase; var isOwnFileEmit; + var bundleFileInfo = printerOptions.writeBundleFileInfo ? { sections: [] } : undefined; + var recordInternalSection = printerOptions.recordInternalSection; + var sourceFileTextPos = 0; + var sourceFileTextKind = "text" /* Text */; // Source Maps var sourceMapsDisabled = true; var sourceMapGenerator; @@ -82766,7 +83257,8 @@ var ts; writeNode: writeNode, writeList: writeList, writeFile: writeFile, - writeBundle: writeBundle + writeBundle: writeBundle, + bundleFileInfo: bundleFileInfo }; function printNode(hint, node, sourceFile) { switch (hint) { @@ -82781,9 +83273,9 @@ var ts; break; } switch (node.kind) { - case 279 /* SourceFile */: return printFile(node); - case 280 /* Bundle */: return printBundle(node); - case 281 /* UnparsedSource */: return printUnparsedSource(node); + case 284 /* SourceFile */: return printFile(node); + case 285 /* Bundle */: return printBundle(node); + case 286 /* UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -82793,7 +83285,7 @@ var ts; return endPrint(); } function printBundle(bundle) { - writeBundle(bundle, /*bundleInfo*/ undefined, beginPrint(), /*sourceMapEmitter*/ undefined); + writeBundle(bundle, beginPrint(), /*sourceMapEmitter*/ undefined); return endPrint(); } function printFile(sourceFile) { @@ -82821,7 +83313,49 @@ var ts; reset(); writer = previousWriter; } - function writeBundle(bundle, bundleInfo, output, sourceMapGenerator) { + function getTextPosWithWriteLine() { + return writer.getTextPosWithWriteLine ? writer.getTextPosWithWriteLine() : writer.getTextPos(); + } + function updateOrPushBundleFileTextLike(pos, end, kind) { + var last = ts.lastOrUndefined(bundleFileInfo.sections); + if (last && last.kind === kind) { + last.end = end; + } + else { + bundleFileInfo.sections.push({ pos: pos, end: end, kind: kind }); + } + } + function recordBundleFileInternalSectionStart(node) { + if (recordInternalSection && + bundleFileInfo && + currentSourceFile && + (ts.isDeclaration(node) || ts.isVariableStatement(node)) && + ts.isInternalDeclaration(node, currentSourceFile) && + sourceFileTextKind !== "internal" /* Internal */) { + var prevSourceFileTextKind = sourceFileTextKind; + recordBundleFileTextLikeSection(writer.getTextPos()); + sourceFileTextPos = getTextPosWithWriteLine(); + sourceFileTextKind = "internal" /* Internal */; + return prevSourceFileTextKind; + } + return undefined; + } + function recordBundleFileInternalSectionEnd(prevSourceFileTextKind) { + if (prevSourceFileTextKind) { + recordBundleFileTextLikeSection(writer.getTextPos()); + sourceFileTextPos = getTextPosWithWriteLine(); + sourceFileTextKind = prevSourceFileTextKind; + } + } + function recordBundleFileTextLikeSection(end) { + if (sourceFileTextPos < end) { + updateOrPushBundleFileTextLike(sourceFileTextPos, end, sourceFileTextKind); + return true; + } + return false; + } + function writeBundle(bundle, output, sourceMapGenerator) { + var _a; isOwnFileEmit = false; var previousWriter = writer; setWriter(output, sourceMapGenerator); @@ -82829,18 +83363,49 @@ var ts; emitPrologueDirectivesIfNeeded(bundle); emitHelpers(bundle); emitSyntheticTripleSlashReferencesIfNeeded(bundle); - for (var _a = 0, _b = bundle.prepends; _a < _b.length; _a++) { - var prepend = _b[_a]; + for (var _b = 0, _c = bundle.prepends; _b < _c.length; _b++) { + var prepend = _c[_b]; writeLine(); + var pos = writer.getTextPos(); + var savedSections = bundleFileInfo && bundleFileInfo.sections; + if (savedSections) + bundleFileInfo.sections = []; print(4 /* Unspecified */, prepend, /*sourceFile*/ undefined); + if (bundleFileInfo) { + var newSections = bundleFileInfo.sections; + bundleFileInfo.sections = savedSections; + if (prepend.oldFileOfCurrentEmit) + (_a = bundleFileInfo.sections).push.apply(_a, newSections); + else { + newSections.forEach(function (section) { return ts.Debug.assert(ts.isBundleFileTextLike(section)); }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prepend" /* Prepend */, data: prepend.fileName, texts: newSections }); + } + } } - if (bundleInfo) { - bundleInfo.originalOffset = writer.getTextPos(); - } - for (var _c = 0, _d = bundle.sourceFiles; _c < _d.length; _c++) { - var sourceFile = _d[_c]; + sourceFileTextPos = getTextPosWithWriteLine(); + for (var _d = 0, _e = bundle.sourceFiles; _d < _e.length; _d++) { + var sourceFile = _e[_d]; print(0 /* SourceFile */, sourceFile, sourceFile); } + if (bundleFileInfo && bundle.sourceFiles.length) { + var end = writer.getTextPos(); + if (recordBundleFileTextLikeSection(end)) { + // Store prologues + var prologues = getPrologueDirectivesFromBundledSourceFiles(bundle); + if (prologues) { + if (!bundleFileInfo.sources) + bundleFileInfo.sources = {}; + bundleFileInfo.sources.prologues = prologues; + } + // Store helpes + var helpers = getHelpersFromBundledSourceFiles(bundle); + if (helpers) { + if (!bundleFileInfo.sources) + bundleFileInfo.sources = {}; + bundleFileInfo.sources.helpers = helpers; + } + } + } reset(); writer = previousWriter; } @@ -82910,8 +83475,10 @@ var ts; function emit(node) { if (node === undefined) return; + var prevSourceFileTextKind = recordBundleFileInternalSectionStart(node); var pipelinePhase = getPipelinePhase(0 /* Notification */, node); pipelinePhase(4 /* Unspecified */, node); + recordBundleFileInternalSectionEnd(prevSourceFileTextKind); } function emitIdentifierName(node) { if (node === undefined) @@ -82938,12 +83505,12 @@ var ts; } // falls through case 2 /* Comments */: - if (!commentsDisabled && node.kind !== 279 /* SourceFile */) { + if (!commentsDisabled && node.kind !== 284 /* SourceFile */) { return pipelineEmitWithComments; } // falls through case 3 /* SourceMaps */: - if (!sourceMapsDisabled && node.kind !== 279 /* SourceFile */ && !ts.isInJsonFile(node)) { + if (!sourceMapsDisabled && node.kind !== 284 /* SourceFile */ && !ts.isInJsonFile(node)) { return pipelineEmitWithSourceMap; } // falls through @@ -82980,8 +83547,16 @@ var ts; case 16 /* TemplateMiddle */: case 17 /* TemplateTail */: return emitLiteral(node); - case 281 /* UnparsedSource */: - return emitUnparsedSource(node); + case 286 /* UnparsedSource */: + case 280 /* UnparsedPrepend */: + return emitUnparsedSourceOrPrepend(node); + case 279 /* UnparsedPrologue */: + return writeUnparsedNode(node); + case 281 /* UnparsedText */: + case 282 /* UnparsedInternalText */: + return emitUnparsedTextLike(node); + case 283 /* UnparsedSyntheticReference */: + return emitUnparsedSyntheticReference(node); // Identifiers case 72 /* Identifier */: return emitIdentifier(node); @@ -83025,7 +83600,7 @@ var ts; return emitTypeReference(node); case 165 /* FunctionType */: return emitFunctionType(node); - case 289 /* JSDocFunctionType */: + case 294 /* JSDocFunctionType */: return emitJSDocFunctionType(node); case 166 /* ConstructorType */: return emitConstructorType(node); @@ -83063,20 +83638,20 @@ var ts; return emitLiteralType(node); case 183 /* ImportType */: return emitImportTypeNode(node); - case 284 /* JSDocAllType */: + case 289 /* JSDocAllType */: writePunctuation("*"); return; - case 285 /* JSDocUnknownType */: + case 290 /* JSDocUnknownType */: writePunctuation("?"); return; - case 286 /* JSDocNullableType */: + case 291 /* JSDocNullableType */: return emitJSDocNullableType(node); - case 287 /* JSDocNonNullableType */: + case 292 /* JSDocNonNullableType */: return emitJSDocNonNullableType(node); - case 288 /* JSDocOptionalType */: + case 293 /* JSDocOptionalType */: return emitJSDocOptionalType(node); case 172 /* RestType */: - case 290 /* JSDocVariadicType */: + case 295 /* JSDocVariadicType */: return emitRestOrJSDocVariadicType(node); // Binding patterns case 184 /* ObjectBindingPattern */: @@ -83214,30 +83789,30 @@ var ts; case 278 /* EnumMember */: return emitEnumMember(node); // JSDoc nodes (only used in codefixes currently) - case 299 /* JSDocParameterTag */: - case 305 /* JSDocPropertyTag */: + case 304 /* JSDocParameterTag */: + case 310 /* JSDocPropertyTag */: return emitJSDocPropertyLikeTag(node); - case 300 /* JSDocReturnTag */: - case 302 /* JSDocTypeTag */: - case 301 /* JSDocThisTag */: - case 298 /* JSDocEnumTag */: + case 305 /* JSDocReturnTag */: + case 307 /* JSDocTypeTag */: + case 306 /* JSDocThisTag */: + case 303 /* JSDocEnumTag */: return emitJSDocSimpleTypedTag(node); - case 295 /* JSDocAugmentsTag */: + case 300 /* JSDocAugmentsTag */: return emitJSDocAugmentsTag(node); - case 303 /* JSDocTemplateTag */: + case 308 /* JSDocTemplateTag */: return emitJSDocTemplateTag(node); - case 304 /* JSDocTypedefTag */: + case 309 /* JSDocTypedefTag */: return emitJSDocTypedefTag(node); - case 297 /* JSDocCallbackTag */: + case 302 /* JSDocCallbackTag */: return emitJSDocCallbackTag(node); - case 293 /* JSDocSignature */: + case 298 /* JSDocSignature */: return emitJSDocSignature(node); - case 292 /* JSDocTypeLiteral */: + case 297 /* JSDocTypeLiteral */: return emitJSDocTypeLiteral(node); - case 296 /* JSDocClassTag */: - case 294 /* JSDocTag */: + case 301 /* JSDocClassTag */: + case 299 /* JSDocTag */: return emitJSDocSimpleTag(node); - case 291 /* JSDocComment */: + case 296 /* JSDocComment */: return emitJSDoc(node); // Transformation nodes (ignored) } @@ -83336,9 +83911,9 @@ var ts; case 264 /* JsxFragment */: return emitJsxFragment(node); // Transformation nodes - case 308 /* PartiallyEmittedExpression */: + case 313 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 309 /* CommaListExpression */: + case 314 /* CommaListExpression */: return emitCommaList(node); } } @@ -83354,22 +83929,45 @@ var ts; var pipelinePhase = getNextPipelinePhase(1 /* Substitution */, node); pipelinePhase(hint, substituteNode(hint, node)); } + function getHelpersFromBundledSourceFiles(bundle) { + var result; + if (moduleKind === ts.ModuleKind.None || printerOptions.noEmitHelpers) { + return undefined; + } + var bundledHelpers = ts.createMap(); + for (var _a = 0, _b = bundle.sourceFiles; _a < _b.length; _a++) { + var sourceFile = _b[_a]; + var shouldSkip = ts.getExternalHelpersModuleName(sourceFile) !== undefined; + var helpers = getSortedEmitHelpers(sourceFile); + if (!helpers) + continue; + for (var _c = 0, helpers_3 = helpers; _c < helpers_3.length; _c++) { + var helper = helpers_3[_c]; + if (!helper.scoped && !shouldSkip && !bundledHelpers.get(helper.name)) { + bundledHelpers.set(helper.name, true); + (result || (result = [])).push(helper.name); + } + } + } + return result; + } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 280 /* Bundle */ ? node : undefined; + var bundle = node.kind === 285 /* Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } - var numNodes = bundle ? bundle.sourceFiles.length : 1; + var numPrepends = bundle ? bundle.prepends.length : 0; + var numNodes = bundle ? bundle.sourceFiles.length + numPrepends : 1; for (var i = 0; i < numNodes; i++) { - var currentNode = bundle ? bundle.sourceFiles[i] : node; - var sourceFile = ts.isSourceFile(currentNode) ? currentNode : currentSourceFile; - var shouldSkip = printerOptions.noEmitHelpers || ts.getExternalHelpersModuleName(sourceFile) !== undefined; - var shouldBundle = ts.isSourceFile(currentNode) && !isOwnFileEmit; - var helpers = ts.getEmitHelpers(currentNode); + var currentNode = bundle ? i < numPrepends ? bundle.prepends[i] : bundle.sourceFiles[i - numPrepends] : node; + var sourceFile = ts.isSourceFile(currentNode) ? currentNode : ts.isUnparsedSource(currentNode) ? undefined : currentSourceFile; + var shouldSkip = printerOptions.noEmitHelpers || (!!sourceFile && ts.getExternalHelpersModuleName(sourceFile) !== undefined); + var shouldBundle = (ts.isSourceFile(currentNode) || ts.isUnparsedSource(currentNode)) && !isOwnFileEmit; + var helpers = ts.isUnparsedSource(currentNode) ? currentNode.helpers : getSortedEmitHelpers(currentNode); if (helpers) { - for (var _a = 0, _b = ts.stableSort(helpers, ts.compareEmitHelpers); _a < _b.length; _a++) { - var helper = _b[_a]; + for (var _a = 0, helpers_4 = helpers; _a < helpers_4.length; _a++) { + var helper = helpers_4[_a]; if (!helper.scoped) { // Skip the helper if it can be skipped and the noEmitHelpers compiler // option is set, or if it can be imported and the importHelpers compiler @@ -83389,18 +83987,25 @@ var ts; // Skip the helper if it is scoped and we are emitting bundled helpers continue; } + var pos = getTextPosWithWriteLine(); if (typeof helper.text === "string") { writeLines(helper.text); } else { writeLines(helper.text(makeFileLevelOptimisticUniqueName)); } + if (bundleFileInfo) + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "emitHelpers" /* EmitHelpers */, data: helper.name }); helpersEmitted = true; } } } return helpersEmitted; } + function getSortedEmitHelpers(node) { + var helpers = ts.getEmitHelpers(node); + return helpers && ts.stableSort(helpers, ts.compareEmitHelpers); + } // // Literals/Pseudo-literals // @@ -83427,8 +84032,42 @@ var ts; } } // SyntaxKind.UnparsedSource - function emitUnparsedSource(unparsed) { - writer.rawWrite(unparsed.text); + // SyntaxKind.UnparsedPrepend + function emitUnparsedSourceOrPrepend(unparsed) { + for (var _a = 0, _b = unparsed.texts; _a < _b.length; _a++) { + var text = _b[_a]; + writeLine(); + emit(text); + } + } + // SyntaxKind.UnparsedPrologue + // SyntaxKind.UnparsedText + // SyntaxKind.UnparsedInternal + // SyntaxKind.UnparsedSyntheticReference + function writeUnparsedNode(unparsed) { + writer.rawWrite(unparsed.parent.text.substring(unparsed.pos, unparsed.end)); + } + // SyntaxKind.UnparsedText + // SyntaxKind.UnparsedInternal + function emitUnparsedTextLike(unparsed) { + var pos = getTextPosWithWriteLine(); + writeUnparsedNode(unparsed); + if (bundleFileInfo) { + updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 281 /* UnparsedText */ ? + "text" /* Text */ : + "internal" /* Internal */); + } + } + // SyntaxKind.UnparsedSyntheticReference + function emitUnparsedSyntheticReference(unparsed) { + var pos = getTextPosWithWriteLine(); + writeUnparsedNode(unparsed); + if (bundleFileInfo) { + var section = ts.clone(unparsed.section); + section.pos = pos; + section.end = writer.getTextPos(); + bundleFileInfo.sections.push(section); + } } // // Identifiers @@ -83483,7 +84122,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 289 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 294 /* JSDocFunctionType */ && !node.name) { emit(node.type); } else { @@ -84363,7 +85002,7 @@ var ts; } function emitBlockFunctionBodyWorker(body, emitBlockFunctionBodyOnSingleLine) { // Emit all the prologue directives (like "use strict"). - var statementOffset = emitPrologueDirectives(body.statements, /*startWithNewLine*/ true); + var statementOffset = emitPrologueDirectives(body.statements); var pos = writer.getTextPos(); emitHelpers(body); if (statementOffset === 0 && pos === writer.getTextPos() && emitBlockFunctionBodyOnSingleLine) { @@ -84768,7 +85407,7 @@ var ts; } } if (node.tags) { - if (node.tags.length === 1 && node.tags[0].kind === 302 /* JSDocTypeTag */ && !node.comment) { + if (node.tags.length === 1 && node.tags[0].kind === 307 /* JSDocTypeTag */ && !node.comment) { writeSpace(); emit(node.tags[0]); } @@ -84802,7 +85441,7 @@ var ts; function emitJSDocTypedefTag(tag) { emitJSDocTagName(tag.tagName); if (tag.typeExpression) { - if (tag.typeExpression.kind === 283 /* JSDocTypeExpression */) { + if (tag.typeExpression.kind === 288 /* JSDocTypeExpression */) { emitJSDocTypeExpression(tag.typeExpression); } else { @@ -84821,7 +85460,7 @@ var ts; emit(tag.fullName); } emitJSDocComment(tag.comment); - if (tag.typeExpression && tag.typeExpression.kind === 292 /* JSDocTypeLiteral */) { + if (tag.typeExpression && tag.typeExpression.kind === 297 /* JSDocTypeLiteral */) { emitJSDocTypeLiteral(tag.typeExpression); } } @@ -84908,6 +85547,16 @@ var ts; } function emitSyntheticTripleSlashReferencesIfNeeded(node) { emitTripleSlashDirectives(!!node.hasNoDefaultLib, node.syntheticFileReferences || [], node.syntheticTypeReferences || [], node.syntheticLibReferences || []); + for (var _a = 0, _b = node.prepends; _a < _b.length; _a++) { + var prepend = _b[_a]; + if (ts.isUnparsedSource(prepend) && prepend.syntheticReferences) { + for (var _c = 0, _d = prepend.syntheticReferences; _c < _d.length; _c++) { + var ref = _d[_c]; + emit(ref); + writeLine(); + } + } + } } function emitTripleSlashDirectivesIfNeeded(node) { if (node.isDeclarationFile) @@ -84915,7 +85564,10 @@ var ts; } function emitTripleSlashDirectives(hasNoDefaultLib, files, types, libs) { if (hasNoDefaultLib) { + var pos = writer.getTextPos(); writeComment("/// "); + if (bundleFileInfo) + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "no-default-lib" /* NoDefaultLib */ }); writeLine(); } if (currentSourceFile && currentSourceFile.moduleName) { @@ -84936,17 +85588,26 @@ var ts; } for (var _c = 0, files_1 = files; _c < files_1.length; _c++) { var directive = files_1[_c]; + var pos = writer.getTextPos(); writeComment("/// "); + if (bundleFileInfo) + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference" /* Reference */, data: directive.fileName }); writeLine(); } for (var _d = 0, types_19 = types; _d < types_19.length; _d++) { var directive = types_19[_d]; + var pos = writer.getTextPos(); writeComment("/// "); + if (bundleFileInfo) + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "type" /* Type */, data: directive.fileName }); writeLine(); } for (var _e = 0, libs_1 = libs; _e < libs_1.length; _e++) { var directive = libs_1[_e]; + var pos = writer.getTextPos(); writeComment("/// "); + if (bundleFileInfo) + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "lib" /* Lib */, data: directive.fileName }); writeLine(); } } @@ -84971,16 +85632,22 @@ var ts; * Emits any prologue directives at the start of a Statement list, returning the * number of prologue directives written to the output. */ - function emitPrologueDirectives(statements, startWithNewLine, seenPrologueDirectives) { + function emitPrologueDirectives(statements, sourceFile, seenPrologueDirectives) { + var needsToSetSourceFile = !!sourceFile; for (var i = 0; i < statements.length; i++) { var statement = statements[i]; if (ts.isPrologueDirective(statement)) { var shouldEmitPrologueDirective = seenPrologueDirectives ? !seenPrologueDirectives.has(statement.expression.text) : true; if (shouldEmitPrologueDirective) { - if (startWithNewLine || i > 0) { - writeLine(); + if (needsToSetSourceFile) { + needsToSetSourceFile = false; + setSourceFile(sourceFile); } + writeLine(); + var pos = writer.getTextPos(); emit(statement); + if (bundleFileInfo) + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* Prologue */, data: statement.expression.text }); if (seenPrologueDirectives) { seenPrologueDirectives.set(statement.expression.text, true); } @@ -84993,23 +85660,70 @@ var ts; } return statements.length; } + function emitUnparsedPrologues(prologues, seenPrologueDirectives) { + for (var _a = 0, prologues_1 = prologues; _a < prologues_1.length; _a++) { + var prologue = prologues_1[_a]; + if (!seenPrologueDirectives.has(prologue.data)) { + writeLine(); + var pos = writer.getTextPos(); + emit(prologue); + if (bundleFileInfo) + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* Prologue */, data: prologue.data }); + if (seenPrologueDirectives) { + seenPrologueDirectives.set(prologue.data, true); + } + } + } + } function emitPrologueDirectivesIfNeeded(sourceFileOrBundle) { if (ts.isSourceFile(sourceFileOrBundle)) { - setSourceFile(sourceFileOrBundle); - emitPrologueDirectives(sourceFileOrBundle.statements); + emitPrologueDirectives(sourceFileOrBundle.statements, sourceFileOrBundle); } else { var seenPrologueDirectives = ts.createMap(); - for (var _a = 0, _b = sourceFileOrBundle.sourceFiles; _a < _b.length; _a++) { - var sourceFile = _b[_a]; - setSourceFile(sourceFile); - emitPrologueDirectives(sourceFile.statements, /*startWithNewLine*/ true, seenPrologueDirectives); + for (var _a = 0, _b = sourceFileOrBundle.prepends; _a < _b.length; _a++) { + var prepend = _b[_a]; + emitUnparsedPrologues(prepend.prologues, seenPrologueDirectives); + } + for (var _c = 0, _d = sourceFileOrBundle.sourceFiles; _c < _d.length; _c++) { + var sourceFile = _d[_c]; + emitPrologueDirectives(sourceFile.statements, sourceFile, seenPrologueDirectives); } setSourceFile(undefined); } } + function getPrologueDirectivesFromBundledSourceFiles(bundle) { + var seenPrologueDirectives = ts.createMap(); + var prologues; + for (var index = 0; index < bundle.sourceFiles.length; index++) { + var sourceFile = bundle.sourceFiles[index]; + var directives = void 0; + var end = 0; + for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { + var statement = _b[_a]; + if (!ts.isPrologueDirective(statement)) + break; + if (seenPrologueDirectives.has(statement.expression.text)) + continue; + seenPrologueDirectives.set(statement.expression.text, true); + (directives || (directives = [])).push({ + pos: statement.pos, + end: statement.end, + expression: { + pos: statement.expression.pos, + end: statement.expression.end, + text: statement.expression.text + } + }); + end = end < statement.end ? statement.end : end; + } + if (directives) + (prologues || (prologues = [])).push({ file: index, text: sourceFile.text.substring(0, end), directives: directives }); + } + return prologues; + } function emitShebangIfNeeded(sourceFileOrBundle) { - if (ts.isSourceFile(sourceFileOrBundle)) { + if (ts.isSourceFile(sourceFileOrBundle) || ts.isUnparsedSource(sourceFileOrBundle)) { var shebang = ts.getShebang(sourceFileOrBundle.text); if (shebang) { writeComment(shebang); @@ -85018,11 +85732,18 @@ var ts; } } else { - for (var _a = 0, _b = sourceFileOrBundle.sourceFiles; _a < _b.length; _a++) { - var sourceFile = _b[_a]; + for (var _a = 0, _b = sourceFileOrBundle.prepends; _a < _b.length; _a++) { + var prepend = _b[_a]; + ts.Debug.assertNode(prepend, ts.isUnparsedSource); + if (emitShebangIfNeeded(prepend)) { + return true; + } + } + for (var _c = 0, _d = sourceFileOrBundle.sourceFiles; _c < _d.length; _c++) { + var sourceFile = _d[_c]; // Emit only the first encountered shebang if (emitShebangIfNeeded(sourceFile)) { - break; + return true; } } } @@ -85225,6 +85946,7 @@ var ts; } // Emit each child. var previousSibling = void 0; + var previousSourceFileTextKind = void 0; var shouldDecreaseIndentAfterEmit = false; for (var i = 0; i < count; i++) { var child = children[start + i]; @@ -85245,6 +85967,7 @@ var ts; emitLeadingCommentsOfPosition(previousSibling.end); } writeDelimiter(format); + recordBundleFileInternalSectionEnd(previousSourceFileTextKind); // Write either a line terminator or whitespace to separate the elements. if (shouldWriteSeparatingLineTerminator(previousSibling, child, format)) { // If a synthesized node in a single-line list starts on a new @@ -85261,6 +85984,7 @@ var ts; } } // Emit this child. + previousSourceFileTextKind = recordBundleFileInternalSectionStart(child); if (shouldEmitInterveningComments) { if (emitTrailingCommentsOfPosition) { var commentRange = ts.getCommentRange(child); @@ -85295,6 +86019,7 @@ var ts; if (format & 128 /* Indented */) { decreaseIndent(); } + recordBundleFileInternalSectionEnd(previousSourceFileTextKind); // Write the closing line terminator or closing whitespace. if (shouldWriteClosingLineTerminator(parentNode, children, format)) { writeLine(); @@ -85396,7 +86121,6 @@ var ts; if (line.length) { writeLine(); write(line); - writer.rawWrite(newLine); } } } @@ -85910,7 +86634,7 @@ var ts; hasWrittenComment = false; var emitFlags = ts.getEmitFlags(node); var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end; - var isEmittedNode = node.kind !== 307 /* NotEmittedStatement */; + var isEmittedNode = node.kind !== 312 /* NotEmittedStatement */; // We have to explicitly check that the node is JsxText because if the compilerOptions.jsx is "preserve" we will not do any transformation. // It is expensive to walk entire tree just to set one kind of node to have no comments. var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0 || node.kind === 11 /* JsxText */; @@ -86170,19 +86894,28 @@ var ts; return ts.isRecognizedTripleSlashComment(currentSourceFile.text, commentPos, commentEnd); } // Source Maps + function getParsedSourceMap(node) { + if (node.parsedSourceMap === undefined && node.sourceMapText !== undefined) { + node.parsedSourceMap = ts.tryParseRawSourceMap(node.sourceMapText) || false; + } + return node.parsedSourceMap || undefined; + } function pipelineEmitWithSourceMap(hint, node) { var pipelinePhase = getNextPipelinePhase(3 /* SourceMaps */, node); - if (ts.isUnparsedSource(node) && node.sourceMapText !== undefined) { - var parsed = ts.tryParseRawSourceMap(node.sourceMapText); - if (parsed) { - sourceMapGenerator.appendSourceMap(writer.getLine(), writer.getColumn(), parsed, node.sourceMapPath); + if (ts.isUnparsedSource(node) || ts.isUnparsedPrepend(node)) { + pipelinePhase(hint, node); + } + else if (ts.isUnparsedNode(node)) { + var parsed = getParsedSourceMap(node.parent); + if (parsed && sourceMapGenerator) { + sourceMapGenerator.appendSourceMap(writer.getLine(), writer.getColumn(), parsed, node.parent.sourceMapPath, node.parent.getLineAndCharacterOfPosition(node.pos), node.parent.getLineAndCharacterOfPosition(node.end)); } pipelinePhase(hint, node); } else { var _a = ts.getSourceMapRange(node), pos = _a.pos, end = _a.end, _b = _a.source, source = _b === void 0 ? sourceMapSource : _b; var emitFlags = ts.getEmitFlags(node); - if (node.kind !== 307 /* NotEmittedStatement */ + if (node.kind !== 312 /* NotEmittedStatement */ && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 && pos >= 0) { emitSourcePos(source, skipSourceTrivia(source, pos)); @@ -86195,7 +86928,7 @@ var ts; else { pipelinePhase(hint, node); } - if (node.kind !== 307 /* NotEmittedStatement */ + if (node.kind !== 312 /* NotEmittedStatement */ && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 && end >= 0) { emitSourcePos(source, end); @@ -86843,7 +87576,8 @@ var ts; var value = readFileCache.get(key); if (value !== undefined) return value !== false ? value : undefined; // could be .d.ts from output - if (!ts.fileExtensionIs(fileName, ".json" /* Json */)) { + // Cache json or buildInfo + if (!ts.fileExtensionIs(fileName, ".json" /* Json */) && !ts.isBuildInfoFile(fileName)) { return originalReadFile.call(host, fileName); } return setReadFileCache(key, fileName); @@ -86874,7 +87608,7 @@ var ts; var key = toPath(fileName); fileExistsCache.delete(key); var value = readFileCache.get(key); - if (value && value !== data) { + if (value !== undefined && value !== data) { readFileCache.delete(key); sourceFileCache.delete(key); } @@ -87429,7 +88163,8 @@ var ts; getProjectReferenceRedirect: getProjectReferenceRedirect, getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, getResolvedProjectReferenceByPath: getResolvedProjectReferenceByPath, - forEachResolvedProjectReference: forEachResolvedProjectReference + forEachResolvedProjectReference: forEachResolvedProjectReference, + emitBuildInfo: emitBuildInfo }; verifyCompilerOptions(); ts.performance.mark("afterProgram"); @@ -87856,7 +88591,20 @@ var ts; return false; // Before falling back to the host return host.fileExists(f); - } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {}), { useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); } }); + } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {}), { useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, getProgramBuildInfo: function () { return program.getProgramBuildInfo && program.getProgramBuildInfo(); } }); + } + function emitBuildInfo(writeFileCallback) { + ts.Debug.assert(!options.out && !options.outFile); + ts.performance.mark("beforeEmit"); + var emitResult = ts.emitFiles(ts.notImplementedResolver, getEmitHost(writeFileCallback), + /*targetSourceFile*/ undefined, + /*emitOnlyDtsFiles*/ false, + /*transformers*/ undefined, + /*declaraitonTransformers*/ undefined, + /*onlyBuildInfo*/ true); + ts.performance.mark("afterEmit"); + ts.performance.measure("Emit", "beforeEmit", "afterEmit"); + return emitResult; } function getResolvedProjectReferences() { return resolvedProjectReferences; @@ -87865,28 +88613,11 @@ var ts; return projectReferences; } function getPrependNodes() { - if (!projectReferences) { - return ts.emptyArray; - } - var nodes = []; - for (var i = 0; i < projectReferences.length; i++) { - var ref = projectReferences[i]; - var resolvedRefOpts = resolvedProjectReferences[i].commandLine; - if (ref.prepend && resolvedRefOpts && resolvedRefOpts.options) { - var out = resolvedRefOpts.options.outFile || resolvedRefOpts.options.out; - // Upstream project didn't have outFile set -- skip (error will have been issued earlier) - if (!out) - continue; - var _a = ts.getOutputPathsForBundle(resolvedRefOpts.options, /*forceDtsPaths*/ true), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath; - var node = ts.createInputFiles(function (fileName) { - var path = toPath(fileName); - var sourceFile = getSourceFileByPath(path); - return sourceFile ? sourceFile.text : filesByName.has(path) ? undefined : host.readFile(path); - }, jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath); - nodes.push(node); - } - } - return nodes; + return createPrependNodes(projectReferences, function (_ref, index) { return resolvedProjectReferences[index].commandLine; }, function (fileName) { + var path = toPath(fileName); + var sourceFile = getSourceFileByPath(path); + return sourceFile ? sourceFile.text : filesByName.has(path) ? undefined : host.readFile(path); + }); } function isSourceFileFromExternalLibrary(file) { return !!sourceFilesFoundSearchingNodeModules.get(file.path); @@ -87958,8 +88689,7 @@ var ts; var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile, cancellationToken); ts.performance.mark("beforeEmit"); var transformers = emitOnlyDtsFiles ? [] : ts.getTransformers(options, customTransformers); - var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, // TODO: GH#18217 - emitOnlyDtsFiles, transformers, customTransformers && customTransformers.afterDeclarations); + var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, emitOnlyDtsFiles, transformers, customTransformers && customTransformers.afterDeclarations); ts.performance.mark("afterEmit"); ts.performance.measure("Emit", "beforeEmit", "afterEmit"); return emitResult; @@ -88961,6 +89691,14 @@ var ts; if (options.declaration === false) { createDiagnosticForOptionName(ts.Diagnostics.Composite_projects_may_not_disable_declaration_emit, "declaration"); } + if (options.incremental === false) { + createDiagnosticForOptionName(ts.Diagnostics.Composite_projects_may_not_disable_incremental_compilation, "declaration"); + } + } + if (options.tsBuildInfoFile) { + if (!ts.isIncrementalCompilation(options)) { + createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "tsBuildInfoFile", "incremental", "composite"); + } } verifyProjectReferences(); // List of collected files is complete; validate exhautiveness if this is a project with a file list @@ -89155,6 +89893,7 @@ var ts; } } function verifyProjectReferences() { + var buildInfoPath = !options.noEmit && !options.suppressOutputPathCheck ? ts.getOutputPathForBuildInfo(options) : undefined; forEachProjectReference(projectReferences, resolvedProjectReferences, function (resolvedRef, index, parent) { var ref = (parent ? parent.commandLine.projectReferences : projectReferences)[index]; var parentFile = parent && parent.sourceFile; @@ -89181,6 +89920,10 @@ var ts; createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_prepend_project_0_because_it_does_not_have_outFile_set, ref.path); } } + if (!parent && buildInfoPath && buildInfoPath === ts.getOutputPathForBuildInfo(options)) { + createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_write_file_0_because_it_will_overwrite_tsbuildinfo_file_generated_by_referenced_project_1, buildInfoPath, ref.path); + hasEmitBlockingDiagnostics.set(toPath(buildInfoPath), true); + } }); } function createDiagnosticForOptionPathKeyValue(key, valueIndex, message, arg0, arg1, arg2) { @@ -89330,6 +90073,27 @@ var ts; }; } ts.parseConfigHostFromCompilerHostLike = parseConfigHostFromCompilerHostLike; + /* @internal */ + function createPrependNodes(projectReferences, getCommandLine, readFile) { + if (!projectReferences) + return ts.emptyArray; + var nodes; + for (var i = 0; i < projectReferences.length; i++) { + var ref = projectReferences[i]; + var resolvedRefOpts = getCommandLine(ref, i); + if (ref.prepend && resolvedRefOpts && resolvedRefOpts.options) { + var out = resolvedRefOpts.options.outFile || resolvedRefOpts.options.out; + // Upstream project didn't have outFile set -- skip (error will have been issued earlier) + if (!out) + continue; + var _a = ts.getOutputPathsForBundle(resolvedRefOpts.options, /*forceDtsPaths*/ true), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath; + var node = ts.createInputFiles(readFile, jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, buildInfoPath); + (nodes || (nodes = [])).push(node); + } + } + return nodes || ts.emptyArray; + } + ts.createPrependNodes = createPrependNodes; function resolveProjectReferencePath(hostOrRef, ref) { var passedInRef = ref ? ref : hostOrRef; return ts.resolveConfigFileProjectName(passedInRef.path); @@ -89873,11 +90637,14 @@ var ts; var affectedSignatures = oldState.currentAffectedFilesSignatures; ts.Debug.assert(!oldState.affectedFiles && (!affectedSignatures || !affectedSignatures.size), "Cannot reuse if only few affected files of currentChangedFile were iterated"); } + var changedFilesSet = oldState.changedFilesSet; if (canCopySemanticDiagnostics) { - ts.Debug.assert(!ts.forEachKey(oldState.changedFilesSet, function (path) { return oldState.semanticDiagnosticsPerFile.has(path); }), "Semantic diagnostics shouldnt be available for changed files"); + ts.Debug.assert(!changedFilesSet || !ts.forEachKey(changedFilesSet, function (path) { return oldState.semanticDiagnosticsPerFile.has(path); }), "Semantic diagnostics shouldnt be available for changed files"); } // Copy old state's changed files set - ts.copyEntries(oldState.changedFilesSet, state.changedFilesSet); + if (changedFilesSet) { + ts.copyEntries(changedFilesSet, state.changedFilesSet); + } if (!compilerOptions.outFile && !compilerOptions.out && oldState.affectedFilesPendingEmit) { state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit; state.affectedFilesPendingEmitIndex = oldState.affectedFilesPendingEmitIndex; @@ -89923,6 +90690,18 @@ var ts; } } }); + if (oldCompilerOptions && + (oldCompilerOptions.outDir !== compilerOptions.outDir || + oldCompilerOptions.declarationDir !== compilerOptions.declarationDir || + (oldCompilerOptions.outFile || oldCompilerOptions.out) !== (compilerOptions.outFile || compilerOptions.out))) { + // Add all files to affectedFilesPendingEmit since emit changed + state.affectedFilesPendingEmit = ts.concatenate(state.affectedFilesPendingEmit, newProgram.getSourceFiles().map(function (f) { return f.path; })); + if (state.affectedFilesPendingEmitIndex === undefined) { + state.affectedFilesPendingEmitIndex = 0; + } + ts.Debug.assert(state.seenAffectedFiles === undefined); + state.seenAffectedFiles = ts.createMap(); + } return state; } /** @@ -90144,8 +90923,11 @@ var ts; * This is called after completing operation on the next affected file. * The operations here are postponed to ensure that cancellation during the iteration is handled correctly */ - function doneWithAffectedFile(state, affected, isPendingEmit) { - if (affected === state.program) { + function doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit) { + if (isBuildInfoEmit) { + state.emittedBuildInfo = true; + } + else if (affected === state.program) { state.changedFilesSet.clear(); state.programEmitComplete = true; } @@ -90162,8 +90944,8 @@ var ts; /** * Returns the result with affected file */ - function toAffectedFileResult(state, result, affected, isPendingEmit) { - doneWithAffectedFile(state, affected, isPendingEmit); + function toAffectedFileResult(state, result, affected, isPendingEmit, isBuildInfoEmit) { + doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit); return { result: result, affected: affected }; } /** @@ -90186,6 +90968,46 @@ var ts; } return diagnostics; } + /** + * Gets the program information to be emitted in buildInfo so that we can use it to create new program + */ + function getProgramBuildInfo(state) { + if (state.compilerOptions.outFile || state.compilerOptions.out) + return undefined; + var fileInfos = {}; + state.fileInfos.forEach(function (value, key) { + var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key); + fileInfos[key] = signature === undefined ? value : { version: value.version, signature: signature }; + }); + var result = { fileInfos: fileInfos, options: state.compilerOptions }; + if (state.referencedMap) { + var referencedMap_1 = {}; + state.referencedMap.forEach(function (value, key) { + referencedMap_1[key] = ts.arrayFrom(value.keys()); + }); + result.referencedMap = referencedMap_1; + } + if (state.exportedModulesMap) { + var exportedModulesMap_1 = {}; + state.exportedModulesMap.forEach(function (value, key) { + var newValue = state.currentAffectedFilesExportedModulesMap && state.currentAffectedFilesExportedModulesMap.get(key); + // Not in temporary cache, use existing value + if (newValue === undefined) + exportedModulesMap_1[key] = ts.arrayFrom(value.keys()); + // Value in cache and has updated value map, use that + else if (newValue) + exportedModulesMap_1[key] = ts.arrayFrom(newValue.keys()); + }); + result.exportedModulesMap = exportedModulesMap_1; + } + if (state.semanticDiagnosticsPerFile) { + var semanticDiagnosticsPerFile_1 = []; + // Currently not recording actual errors since those mean no emit for tsc --build + state.semanticDiagnosticsPerFile.forEach(function (_value, key) { return semanticDiagnosticsPerFile_1.push(key); }); + result.semanticDiagnosticsPerFile = semanticDiagnosticsPerFile_1; + } + return result; + } var BuilderProgramKind; (function (BuilderProgramKind) { BuilderProgramKind[BuilderProgramKind["SemanticDiagnosticsBuilderProgram"] = 0] = "SemanticDiagnosticsBuilderProgram"; @@ -90242,6 +91064,7 @@ var ts; var computeHash = host.createHash || ts.generateDjb2Hash; var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState); var backupState; + newProgram.getProgramBuildInfo = function () { return result.getProgramBuildInfo(); }; // To ensure that we arent storing any references to old program or new program without state newProgram = undefined; // TODO: GH#18217 oldProgram = undefined; @@ -90263,6 +91086,7 @@ var ts; releaseCache(state); backupState = undefined; }; + result.getProgramBuildInfo = function () { return getProgramBuildInfo(state); }; if (kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram) { result.getSemanticDiagnosticsOfNextAffectedFile = getSemanticDiagnosticsOfNextAffectedFile; } @@ -90285,7 +91109,16 @@ var ts; if (!state.compilerOptions.out && !state.compilerOptions.outFile) { affected = getNextAffectedFilePendingEmit(state); if (!affected) { - return undefined; + if (state.emittedBuildInfo) { + return undefined; + } + var affected_1 = ts.Debug.assertDefined(state.program); + return toAffectedFileResult(state, + // When whole program is affected, do emit only once (eg when --out or --outFile is specified) + // Otherwise just affected file + affected_1.emitBuildInfo(writeFile || host.writeFile, cancellationToken), affected_1, + /*isPendingEmitFile*/ false, + /*isBuildInfoEmit*/ true); } isPendingEmitFile = true; } @@ -90418,6 +91251,53 @@ var ts; } } ts.createBuilderProgram = createBuilderProgram; + function getMapOfReferencedSet(mapLike) { + if (!mapLike) + return undefined; + var map = ts.createMap(); + // Copies keys/values from template. Note that for..in will not throw if + // template is undefined, and instead will just exit the loop. + for (var key in mapLike) { + if (ts.hasProperty(mapLike, key)) { + map.set(key, ts.arrayToSet(mapLike[key])); + } + } + return map; + } + function createBuildProgramUsingProgramBuildInfo(program) { + var fileInfos = ts.createMapFromTemplate(program.fileInfos); + var state = { + fileInfos: fileInfos, + compilerOptions: program.options, + referencedMap: getMapOfReferencedSet(program.referencedMap), + exportedModulesMap: getMapOfReferencedSet(program.exportedModulesMap), + semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && ts.arrayToMap(program.semanticDiagnosticsPerFile, ts.identity, function () { return ts.emptyArray; }) + }; + return { + getState: function () { return state; }, + backupState: ts.noop, + restoreState: ts.noop, + getProgram: ts.notImplemented, + getProgramOrUndefined: function () { return undefined; }, + releaseProgram: ts.noop, + getCompilerOptions: function () { return state.compilerOptions; }, + getSourceFile: ts.notImplemented, + getSourceFiles: ts.notImplemented, + getOptionsDiagnostics: ts.notImplemented, + getGlobalDiagnostics: ts.notImplemented, + getConfigFileParsingDiagnostics: ts.notImplemented, + getSyntacticDiagnostics: ts.notImplemented, + getDeclarationDiagnostics: ts.notImplemented, + getSemanticDiagnostics: ts.notImplemented, + emit: ts.notImplemented, + getAllDependencies: ts.notImplemented, + getCurrentDirectory: ts.notImplemented, + emitNextAffectedFile: ts.notImplemented, + getSemanticDiagnosticsOfNextAffectedFile: ts.notImplemented, + getProgramBuildInfo: ts.notImplemented + }; + } + ts.createBuildProgramUsingProgramBuildInfo = createBuildProgramUsingProgramBuildInfo; function createRedirectedBuilderProgram(state, configFileParsingDiagnostics) { return { getState: ts.notImplemented, @@ -90437,7 +91317,8 @@ var ts; getSemanticDiagnostics: function (sourceFile, cancellationToken) { return getProgram().getSemanticDiagnostics(sourceFile, cancellationToken); }, emit: function (sourceFile, writeFile, cancellationToken, emitOnlyDts, customTransformers) { return getProgram().emit(sourceFile, writeFile, cancellationToken, emitOnlyDts, customTransformers); }, getAllDependencies: ts.notImplemented, - getCurrentDirectory: function () { return getProgram().getCurrentDirectory(); } + getCurrentDirectory: function () { return getProgram().getCurrentDirectory(); }, + getProgramBuildInfo: function () { return undefined; } }; function getProgram() { return ts.Debug.assertDefined(state.program); @@ -91465,6 +92346,8 @@ var ts; case ".jsx" /* Jsx */: case ".json" /* Json */: return ext; + case ".tsbuildinfo" /* TsBuildInfo */: + return ts.Debug.fail("Extension " + ".tsbuildinfo" /* TsBuildInfo */ + " is unsupported:: FileName:: " + fileName); default: return ts.Debug.assertNever(ext); } @@ -91746,7 +92629,7 @@ var ts; writeFile: function (path, data, writeByteOrderMark) { return system.writeFile(path, data, writeByteOrderMark); }, onCachedDirectoryStructureHostCreate: function (cacheHost) { return host = cacheHost || system; }, createHash: ts.maybeBind(system, system.createHash), - createProgram: createProgram + createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram }; } ts.createProgramHost = createProgramHost; @@ -91756,7 +92639,7 @@ var ts; function createWatchCompilerHost(system, createProgram, reportDiagnostic, reportWatchStatus) { if (system === void 0) { system = ts.sys; } var writeFileName = function (s) { return system.write(s + system.newLine); }; - var result = createProgramHost(system, createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram); + var result = createProgramHost(system, createProgram); ts.copyProperties(result, createWatchHost(system, reportWatchStatus)); result.afterProgramCreate = function (builderProgram) { var compilerOptions = builderProgram.getCompilerOptions(); @@ -92239,16 +93122,22 @@ var ts; * This means we can Pseudo-build (just touch timestamps), as if we had actually built this project. */ UpToDateStatusType[UpToDateStatusType["UpToDateWithUpstreamTypes"] = 2] = "UpToDateWithUpstreamTypes"; - UpToDateStatusType[UpToDateStatusType["OutputMissing"] = 3] = "OutputMissing"; - UpToDateStatusType[UpToDateStatusType["OutOfDateWithSelf"] = 4] = "OutOfDateWithSelf"; - UpToDateStatusType[UpToDateStatusType["OutOfDateWithUpstream"] = 5] = "OutOfDateWithUpstream"; - UpToDateStatusType[UpToDateStatusType["UpstreamOutOfDate"] = 6] = "UpstreamOutOfDate"; - UpToDateStatusType[UpToDateStatusType["UpstreamBlocked"] = 7] = "UpstreamBlocked"; - UpToDateStatusType[UpToDateStatusType["ComputingUpstream"] = 8] = "ComputingUpstream"; + /** + * The project appears out of date because its upstream inputs are newer than its outputs, + * but all of its outputs are actually newer than the previous identical outputs of its (.d.ts) inputs. + * This means we can Pseudo-build (just manipulate outputs), as if we had actually built this project. + */ + UpToDateStatusType[UpToDateStatusType["OutOfDateWithPrepend"] = 3] = "OutOfDateWithPrepend"; + UpToDateStatusType[UpToDateStatusType["OutputMissing"] = 4] = "OutputMissing"; + UpToDateStatusType[UpToDateStatusType["OutOfDateWithSelf"] = 5] = "OutOfDateWithSelf"; + UpToDateStatusType[UpToDateStatusType["OutOfDateWithUpstream"] = 6] = "OutOfDateWithUpstream"; + UpToDateStatusType[UpToDateStatusType["UpstreamOutOfDate"] = 7] = "UpstreamOutOfDate"; + UpToDateStatusType[UpToDateStatusType["UpstreamBlocked"] = 8] = "UpstreamBlocked"; + UpToDateStatusType[UpToDateStatusType["ComputingUpstream"] = 9] = "ComputingUpstream"; /** * Projects with no outputs (i.e. "solution" files) */ - UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 9] = "ContainerOnly"; + UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 10] = "ContainerOnly"; })(UpToDateStatusType = ts.UpToDateStatusType || (ts.UpToDateStatusType = {})); function createFileMap(toPath) { // tslint:disable-next-line:no-null-keyword @@ -92329,24 +93218,18 @@ var ts; } return outputs; } - function getOutFileOutputs(project) { - var out = project.options.outFile || project.options.out; - if (!out) { - return ts.Debug.fail("outFile must be set"); - } + function getOutFileOutputs(project, ignoreBuildInfo) { + ts.Debug.assert(!!project.options.outFile || !!project.options.out, "outFile must be set"); + var _a = ts.getOutputPathsForBundle(project.options, /*forceDtsPaths*/ false), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath; var outputs = []; - outputs.push(out); - if (project.options.sourceMap) { - outputs.push(out + ".map"); - } - if (ts.getEmitDeclarations(project.options)) { - var dts = ts.changeExtension(out, ".d.ts" /* Dts */); - outputs.push(dts); - if (project.options.declarationMap) { - outputs.push(dts + ".map"); - } - } - return outputs; + var addOutput = function (path) { return path && (outputs || (outputs = [])).push(path); }; + addOutput(jsFilePath); + addOutput(sourceMapFilePath); + addOutput(declarationFilePath); + addOutput(declarationMapPath); + if (!ignoreBuildInfo) + addOutput(buildInfoPath); + return outputs || ts.emptyArray; } function rootDirOfOptions(opts, configFileName) { return opts.rootDir || ts.getDirectoryPath(configFileName); @@ -92379,14 +93262,14 @@ var ts; } function createSolutionBuilderHost(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus, reportErrorSummary) { if (system === void 0) { system = ts.sys; } - var host = createSolutionBuilderHostBase(system, createProgram || ts.createAbstractBuilder, reportDiagnostic, reportSolutionBuilderStatus); + var host = createSolutionBuilderHostBase(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus); host.reportErrorSummary = reportErrorSummary; return host; } ts.createSolutionBuilderHost = createSolutionBuilderHost; function createSolutionBuilderWithWatchHost(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus, reportWatchStatus) { if (system === void 0) { system = ts.sys; } - var host = createSolutionBuilderHostBase(system, createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram, reportDiagnostic, reportSolutionBuilderStatus); + var host = createSolutionBuilderHostBase(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus); var watchHost = ts.createWatchHost(system, reportWatchStatus); ts.copyProperties(host, watchHost); return host; @@ -92420,7 +93303,17 @@ var ts; var compilerHost = ts.createCompilerHostFromProgramHost(host, function () { return projectCompilerOptions; }); var originalGetSourceFile = compilerHost.getSourceFile; var computeHash = host.createHash || ts.generateDjb2Hash; - updateGetSourceFile(); + compilerHost.getSourceFile = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var result = originalGetSourceFile.call.apply(originalGetSourceFile, [compilerHost].concat(args)); + if (result) { + result.version = computeHash.call(host, result.text); + } + return result; + }; // Watch state var builderPrograms = createFileMap(toPath); var diagnostics = createFileMap(toPath); @@ -92472,29 +93365,6 @@ var ts; ts.clearMap(allWatchedInputFiles, function (inputFileWatches) { return ts.clearMap(inputFileWatches, ts.closeFileWatcher); }); ts.clearMap(allWatchedConfigFiles, ts.closeFileWatcher); builderPrograms.clear(); - updateGetSourceFile(); - } - function updateGetSourceFile() { - if (options.watch) { - if (compilerHost.getSourceFile === originalGetSourceFile) { - compilerHost.getSourceFile = function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - var result = originalGetSourceFile.call.apply(originalGetSourceFile, [compilerHost].concat(args)); - if (result && options.watch) { - result.version = computeHash.call(host, result.text); - } - return result; - }; - } - } - else { - if (compilerHost.getSourceFile !== originalGetSourceFile) { - compilerHost.getSourceFile = originalGetSourceFile; - } - } } function isParsedCommandLine(entry) { return !!entry.options; @@ -92726,25 +93596,28 @@ var ts; upstreamProjectName: ref.path }; } - // If the upstream project's newest file is older than our oldest output, we - // can't be out of date because of it - if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) { - continue; + // Check oldest output file name only if there is no missing output file name + if (!missingOutputFileName) { + // If the upstream project's newest file is older than our oldest output, we + // can't be out of date because of it + if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) { + continue; + } + // If the upstream project has only change .d.ts files, and we've built + // *after* those files, then we're "psuedo up to date" and eligible for a fast rebuild + if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) { + pseudoUpToDate = true; + upstreamChangedProject = ref.path; + continue; + } + // We have an output older than an upstream output - we are out of date + ts.Debug.assert(oldestOutputFileName !== undefined, "Should have an oldest output filename here"); + return { + type: UpToDateStatusType.OutOfDateWithUpstream, + outOfDateOutputFileName: oldestOutputFileName, + newerProjectName: ref.path + }; } - // If the upstream project has only change .d.ts files, and we've built - // *after* those files, then we're "psuedo up to date" and eligible for a fast rebuild - if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) { - pseudoUpToDate = true; - upstreamChangedProject = ref.path; - continue; - } - // We have an output older than an upstream output - we are out of date - ts.Debug.assert(oldestOutputFileName !== undefined, "Should have an oldest output filename here"); - return { - type: UpToDateStatusType.OutOfDateWithUpstream, - outOfDateOutputFileName: oldestOutputFileName, - newerProjectName: ref.path - }; } } if (missingOutputFileName !== undefined) { @@ -92762,7 +93635,7 @@ var ts; } if (usesPrepend && pseudoUpToDate) { return { - type: UpToDateStatusType.OutOfDateWithUpstream, + type: UpToDateStatusType.OutOfDateWithPrepend, outOfDateOutputFileName: oldestOutputFileName, newerProjectName: upstreamChangedProject }; @@ -92896,7 +93769,9 @@ var ts; updateOutputTimestamps(proj); return; } - var buildResult = buildSingleProject(resolved); + var buildResult = status.type === UpToDateStatusType.OutOfDateWithPrepend ? + updateBundle(resolved) : // Fake that files have been built by manipulating prepend and existing output + buildSingleProject(resolved); // Actual build if (buildResult & BuildResultFlags.AnyErrors) return; var _a = getGlobalDependencyGraph(), referencingProjectsMap = _a.referencingProjectsMap, buildQueue = _a.buildQueue; @@ -92912,17 +93787,26 @@ var ts; // If declaration output is changed, build the project // otherwise mark the project UpToDateWithUpstreamTypes so it updates output time stamps var status_1 = projectStatus.getValue(project); - if (prepend || !(buildResult & BuildResultFlags.DeclarationOutputUnchanged)) { - if (status_1 && (status_1.type === UpToDateStatusType.UpToDate || status_1.type === UpToDateStatusType.UpToDateWithUpstreamTypes)) { + if (!(buildResult & BuildResultFlags.DeclarationOutputUnchanged)) { + if (status_1 && (status_1.type === UpToDateStatusType.UpToDate || status_1.type === UpToDateStatusType.UpToDateWithUpstreamTypes || status_1.type === UpToDateStatusType.OutOfDateWithPrepend)) { projectStatus.setValue(project, { type: UpToDateStatusType.OutOfDateWithUpstream, - outOfDateOutputFileName: status_1.oldestOutputFileName, + outOfDateOutputFileName: status_1.type === UpToDateStatusType.OutOfDateWithPrepend ? status_1.outOfDateOutputFileName : status_1.oldestOutputFileName, newerProjectName: resolved }); } } else if (status_1 && status_1.type === UpToDateStatusType.UpToDate) { - status_1.type = UpToDateStatusType.UpToDateWithUpstreamTypes; + if (prepend) { + projectStatus.setValue(project, { + type: UpToDateStatusType.OutOfDateWithPrepend, + outOfDateOutputFileName: status_1.oldestOutputFileName, + newerProjectName: resolved + }); + } + else { + status_1.type = UpToDateStatusType.UpToDateWithUpstreamTypes; + } } addProjToQueue(project); } @@ -92979,8 +93863,7 @@ var ts; } if (options.verbose) reportStatus(ts.Diagnostics.Building_project_0, proj); - var resultFlags = BuildResultFlags.None; - resultFlags |= BuildResultFlags.DeclarationOutputUnchanged; + var resultFlags = BuildResultFlags.DeclarationOutputUnchanged; var configFile = parseConfigFile(proj); if (!configFile) { // Failed to read the config file @@ -92996,8 +93879,7 @@ var ts; } // TODO: handle resolve module name to cache result in project reference redirect projectCompilerOptions = configFile.options; - var program = host.createProgram(configFile.fileNames, configFile.options, compilerHost, builderPrograms.getValue(proj), configFile.errors, configFile.projectReferences); - projectCompilerOptions = baseCompilerOptions; + var program = host.createProgram(configFile.fileNames, configFile.options, compilerHost, getOldProgram(proj, configFile), configFile.errors, configFile.projectReferences); // Don't emit anything in the presence of syntactic errors or options diagnostics var syntaxDiagnostics = program.getConfigFileParsingDiagnostics().concat(program.getOptionsDiagnostics(), program.getGlobalDiagnostics(), program.getSyntacticDiagnostics()); if (syntaxDiagnostics.length) { @@ -93058,12 +93940,14 @@ var ts; diagnostics.removeKey(proj); projectStatus.setValue(proj, status); afterProgramCreate(proj, program); + projectCompilerOptions = baseCompilerOptions; return resultFlags; function buildErrors(diagnostics, errorFlags, errorType) { resultFlags |= errorFlags; reportAndStoreErrors(proj, diagnostics); projectStatus.setValue(proj, { type: UpToDateStatusType.Unbuildable, reason: errorType + " errors" }); afterProgramCreate(proj, program); + projectCompilerOptions = baseCompilerOptions; return resultFlags; } } @@ -93076,9 +93960,65 @@ var ts; builderPrograms.setValue(proj, program); } } + function getOldProgram(proj, parsed) { + var value = builderPrograms.getValue(proj); + if (value) + return value; + var buildInfoPath = ts.getOutputPathForBuildInfo(parsed.options); + if (!buildInfoPath) + return undefined; + var content = readFileWithCache(buildInfoPath); + if (!content) + return undefined; + var buildInfo = JSON.parse(content); + return buildInfo.program && ts.createBuildProgramUsingProgramBuildInfo(buildInfo.program); + } + function updateBundle(proj) { + if (options.dry) { + reportStatus(ts.Diagnostics.A_non_dry_build_would_update_output_of_project_0, proj); + return BuildResultFlags.Success; + } + if (options.verbose) + reportStatus(ts.Diagnostics.Updating_output_of_project_0, proj); + // Update js, and source map + var config = ts.Debug.assertDefined(parseConfigFile(proj)); + projectCompilerOptions = config.options; + var outputFiles = ts.emitUsingBuildInfo(config, compilerHost, function (ref) { return parseConfigFile(resolveProjectName(ref.path)); }); + if (ts.isString(outputFiles)) { + reportStatus(ts.Diagnostics.Cannot_update_output_of_project_0_because_there_was_error_reading_file_1, proj, relName(outputFiles)); + return buildSingleProject(proj); + } + // Actual Emit + ts.Debug.assert(!!outputFiles.length); + var emitterDiagnostics = ts.createDiagnosticCollection(); + var emittedOutputs = createFileMap(toPath); + outputFiles.forEach(function (_a) { + var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark; + emittedOutputs.setValue(name, true); + ts.writeFile(compilerHost, emitterDiagnostics, name, text, writeByteOrderMark); + }); + var emitDiagnostics = emitterDiagnostics.getDiagnostics(); + if (emitDiagnostics.length) { + reportAndStoreErrors(proj, emitDiagnostics); + projectStatus.setValue(proj, { type: UpToDateStatusType.Unbuildable, reason: "Emit errors" }); + projectCompilerOptions = baseCompilerOptions; + return BuildResultFlags.DeclarationOutputUnchanged | BuildResultFlags.EmitErrors; + } + // Update timestamps for dts + var newestDeclarationFileContentChangedTime = updateOutputTimestampsWorker(config, minimumDate, ts.Diagnostics.Updating_unchanged_output_timestamps_of_project_0, emittedOutputs); + var status = { + type: UpToDateStatusType.UpToDate, + newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTime, + oldestOutputFileName: outputFiles[0].name + }; + diagnostics.removeKey(proj); + projectStatus.setValue(proj, status); + projectCompilerOptions = baseCompilerOptions; + return BuildResultFlags.DeclarationOutputUnchanged; + } function updateOutputTimestamps(proj) { if (options.dry) { - return reportStatus(ts.Diagnostics.A_non_dry_build_would_build_project_0, proj.options.configFilePath); + return reportStatus(ts.Diagnostics.A_non_dry_build_would_update_timestamps_for_output_of_project_0, proj.options.configFilePath); } var priorNewestUpdateTime = updateOutputTimestampsWorker(proj, minimumDate, ts.Diagnostics.Updating_output_timestamps_of_project_0); projectStatus.setValue(proj.options.configFilePath, { type: UpToDateStatusType.UpToDate, newestDeclarationFileContentChangedTime: priorNewestUpdateTime }); @@ -93205,7 +94145,9 @@ var ts; // Do nothing continue; } - var buildResult = buildSingleProject(next); + var buildResult = status.type === UpToDateStatusType.OutOfDateWithPrepend && !options.force ? + updateBundle(next) : // Fake that files have been built by manipulating prepend and existing output + buildSingleProject(next); // Actual build anyFailed = anyFailed || !!(buildResult & BuildResultFlags.AnyErrors); } reportErrorSummary(); @@ -93267,6 +94209,9 @@ var ts; var inputFile = _a[_i]; outputs.push.apply(outputs, getOutputFileNames(inputFile, project)); } + var buildInfoPath = ts.getOutputPathForBuildInfo(project.options); + if (buildInfoPath) + outputs.push(buildInfoPath); return outputs; } } @@ -93298,6 +94243,8 @@ var ts; } // Don't report anything for "up to date because it was already built" -- too verbose break; + case UpToDateStatusType.OutOfDateWithPrepend: + return formatMessage(ts.Diagnostics.Project_0_is_out_of_date_because_output_of_its_dependency_1_has_changed, relName(configFileName), relName(status.newerProjectName)); case UpToDateStatusType.UpToDateWithUpstreamTypes: return formatMessage(ts.Diagnostics.Project_0_is_up_to_date_with_d_ts_files_from_its_dependencies, relName(configFileName)); case UpToDateStatusType.UpstreamOutOfDate: @@ -93798,7 +94745,7 @@ var ts; case 242 /* TypeAliasDeclaration */: case 168 /* TypeLiteral */: return 2 /* Type */; - case 304 /* JSDocTypedefTag */: + case 309 /* JSDocTypedefTag */: // If it has no name node, it shares the name with the value declaration below it. return node.name === undefined ? 1 /* Value */ | 2 /* Type */ : 2 /* Type */; case 278 /* EnumMember */: @@ -93823,14 +94770,14 @@ var ts; case 255 /* ExportDeclaration */: return 7 /* All */; // An external module can be a Value - case 279 /* SourceFile */: + case 284 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 7 /* All */; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.kind === 279 /* SourceFile */) { + if (node.kind === 284 /* SourceFile */) { return 1 /* Value */; } else if (node.parent.kind === 254 /* ExportAssignment */ || node.parent.kind === 259 /* ExternalModuleReference */) { @@ -94036,7 +94983,7 @@ var ts; return undefined; } switch (node.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: case 156 /* MethodDeclaration */: case 155 /* MethodSignature */: case 239 /* FunctionDeclaration */: @@ -94054,7 +95001,7 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: return ts.isExternalModule(node) ? "module" /* moduleElement */ : "script" /* scriptElement */; case 244 /* ModuleDeclaration */: return "module" /* moduleElement */; @@ -94063,8 +95010,8 @@ var ts; return "class" /* classElement */; case 241 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; case 242 /* TypeAliasDeclaration */: - case 297 /* JSDocCallbackTag */: - case 304 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: + case 309 /* JSDocTypedefTag */: return "type" /* typeElement */; case 243 /* EnumDeclaration */: return "enum" /* enumElement */; case 237 /* VariableDeclaration */: @@ -94490,7 +95437,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 279 /* SourceFile */ || n.kind === 1 /* EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); + ts.Debug.assert(startNode !== undefined || n.kind === 284 /* SourceFile */ || n.kind === 1 /* EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); // Here we know that none of child token nodes embrace the position, // the only known case is when position is at the end of the file. // Try to find the rightmost token in the file without filtering. @@ -96235,18 +97182,18 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); // e.g. "param" pos = tag.tagName.end; switch (tag.kind) { - case 299 /* JSDocParameterTag */: + case 304 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 303 /* JSDocTemplateTag */: + case 308 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); pos = tag.end; break; - case 302 /* JSDocTypeTag */: + case 307 /* JSDocTypeTag */: processElement(tag.typeExpression); pos = tag.end; break; - case 300 /* JSDocReturnTag */: + case 305 /* JSDocReturnTag */: processElement(tag.typeExpression); pos = tag.end; break; @@ -96550,6 +97497,7 @@ var ts; case ".jsx" /* Jsx */: return ".jsx" /* jsxModifier */; case ".ts" /* Ts */: return ".ts" /* tsModifier */; case ".tsx" /* Tsx */: return ".tsx" /* tsxModifier */; + case ".tsbuildinfo" /* TsBuildInfo */: return ts.Debug.fail("Extension " + ".tsbuildinfo" /* TsBuildInfo */ + " is unsupported."); case undefined: return "" /* none */; default: return ts.Debug.assertNever(extension); @@ -97574,7 +98522,7 @@ var ts; return symbol.parent && (isModuleSymbol(symbol.parent) ? symbol : getFirstSymbolInChain(symbol.parent, enclosingDeclaration, checker)); } function isModuleSymbol(symbol) { - return symbol.declarations.some(function (d) { return d.kind === 279 /* SourceFile */; }); + return symbol.declarations.some(function (d) { return d.kind === 284 /* SourceFile */; }); } function getCompletionData(program, log, sourceFile, isUncheckedFile, position, preferences, detailsEntryId) { var typeChecker = program.getTypeChecker(); @@ -97625,11 +98573,11 @@ var ts; if (tag.tagName.pos <= position && position <= tag.tagName.end) { return { kind: 1 /* JsDocTagName */ }; } - if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 283 /* JSDocTypeExpression */) { + if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 288 /* JSDocTypeExpression */) { currentToken = ts.getTokenAtPosition(sourceFile, position); if (!currentToken || (!ts.isDeclarationName(currentToken) && - (currentToken.parent.kind !== 305 /* JSDocPropertyTag */ || + (currentToken.parent.kind !== 310 /* JSDocPropertyTag */ || currentToken.parent.name !== currentToken))) { // Use as type location if inside tag's type expression insideJsDocTagTypeExpression = isCurrentlyEditingNode(tag.typeExpression); @@ -97800,11 +98748,11 @@ var ts; return { kind: 0 /* Data */, symbols: symbols, completionKind: completionKind, isInSnippetScope: isInSnippetScope, propertyAccessToConvert: propertyAccessToConvert, isNewIdentifierLocation: isNewIdentifierLocation, location: location, keywordFilters: keywordFilters, literals: literals, symbolToOriginInfoMap: symbolToOriginInfoMap, recommendedCompletion: recommendedCompletion, previousToken: previousToken, isJsxInitializer: isJsxInitializer }; function isTagWithTypeExpression(tag) { switch (tag.kind) { - case 299 /* JSDocParameterTag */: - case 305 /* JSDocPropertyTag */: - case 300 /* JSDocReturnTag */: - case 302 /* JSDocTypeTag */: - case 304 /* JSDocTypedefTag */: + case 304 /* JSDocParameterTag */: + case 310 /* JSDocPropertyTag */: + case 305 /* JSDocReturnTag */: + case 307 /* JSDocTypeTag */: + case 309 /* JSDocTypedefTag */: return true; default: return false; @@ -97844,7 +98792,7 @@ var ts; } } // If the module is merged with a value, we must get the type of the class and add its propertes (for inherited static methods). - if (!isTypeLocation && symbol.declarations.some(function (d) { return d.kind !== 279 /* SourceFile */ && d.kind !== 244 /* ModuleDeclaration */ && d.kind !== 243 /* EnumDeclaration */; })) { + if (!isTypeLocation && symbol.declarations.some(function (d) { return d.kind !== 284 /* SourceFile */ && d.kind !== 244 /* ModuleDeclaration */ && d.kind !== 243 /* EnumDeclaration */; })) { addTypeProperties(typeChecker.getTypeOfSymbolAtLocation(symbol, node)); } return; @@ -97977,7 +98925,7 @@ var ts; var symbolMeanings = (isTypeOnly ? 0 /* None */ : 67220415 /* Value */) | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */; symbols = ts.Debug.assertEachDefined(typeChecker.getSymbolsInScope(scopeNode, symbolMeanings), "getSymbolsInScope() should all be defined"); // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions` - if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 279 /* SourceFile */) { + if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 284 /* SourceFile */) { var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false); if (thisType) { for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker); _i < _a.length; _i++) { @@ -98010,7 +98958,7 @@ var ts; } function isSnippetScope(scopeNode) { switch (scopeNode.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: case 206 /* TemplateExpression */: case 270 /* JsxExpression */: case 218 /* Block */: @@ -98842,7 +99790,7 @@ var ts; function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location) { // class c { method() { } | method2() { } } switch (location.kind) { - case 306 /* SyntaxList */: + case 311 /* SyntaxList */: return ts.tryCast(location.parent, ts.isObjectTypeDeclaration); case 1 /* EndOfFileToken */: var cls = ts.tryCast(ts.lastOrUndefined(ts.cast(location.parent, ts.isSourceFile).statements), ts.isObjectTypeDeclaration); @@ -99027,7 +99975,7 @@ var ts; var child = throwStatement; while (child.parent) { var parent = child.parent; - if (ts.isFunctionBlock(parent) || parent.kind === 279 /* SourceFile */) { + if (ts.isFunctionBlock(parent) || parent.kind === 284 /* SourceFile */) { return parent; } // A throw-statement is only owned by a try-statement if the try-statement has @@ -99085,7 +100033,7 @@ var ts; var container = declaration.parent; switch (container.kind) { case 245 /* ModuleBlock */: - case 279 /* SourceFile */: + case 284 /* SourceFile */: case 218 /* Block */: case 271 /* CaseClause */: case 272 /* DefaultClause */: @@ -99583,7 +100531,7 @@ var ts; } else if (!isAvailableThroughGlobal) { var sourceFileLike = getSourceFileLikeForImportDeclaration(importDeclaration); - ts.Debug.assert(sourceFileLike.kind === 279 /* SourceFile */ || sourceFileLike.kind === 244 /* ModuleDeclaration */); + ts.Debug.assert(sourceFileLike.kind === 284 /* SourceFile */ || sourceFileLike.kind === 244 /* ModuleDeclaration */); if (isReExport || findNamespaceReExports(sourceFileLike, name, checker)) { addIndirectUsers(sourceFileLike); } @@ -99752,7 +100700,7 @@ var ts; for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { var referencingFile = sourceFiles_1[_i]; var searchSourceFile = searchModuleSymbol.valueDeclaration; - if (searchSourceFile.kind === 279 /* SourceFile */) { + if (searchSourceFile.kind === 284 /* SourceFile */) { for (var _a = 0, _b = referencingFile.referencedFiles; _a < _b.length; _a++) { var ref = _b[_a]; if (program.getSourceFileFromReference(referencingFile, ref) === searchSourceFile) { @@ -99800,7 +100748,7 @@ var ts; } /** Iterates over all statements at the top level or in module declarations. Returns the first truthy result. */ function forEachPossibleImportOrExportStatement(sourceFileLike, action) { - return ts.forEach(sourceFileLike.kind === 279 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { + return ts.forEach(sourceFileLike.kind === 284 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { return action(statement) || (isAmbientModuleDeclaration(statement) && ts.forEach(statement.body && statement.body.statements, action)); }); } @@ -100024,7 +100972,7 @@ var ts; return node.getSourceFile(); } var parent = node.parent; - if (parent.kind === 279 /* SourceFile */) { + if (parent.kind === 284 /* SourceFile */) { return parent; } ts.Debug.assert(parent.kind === 245 /* ModuleBlock */); @@ -100086,7 +101034,7 @@ var ts; } FindAllReferences.getImplementationsAtPosition = getImplementationsAtPosition; function getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position) { - if (node.kind === 279 /* SourceFile */) { + if (node.kind === 284 /* SourceFile */) { return undefined; } var checker = program.getTypeChecker(); @@ -100306,8 +101254,8 @@ var ts; case 248 /* ImportEqualsDeclaration */: case 253 /* ImportSpecifier */: case 241 /* InterfaceDeclaration */: - case 297 /* JSDocCallbackTag */: - case 304 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: + case 309 /* JSDocTypedefTag */: case 267 /* JsxAttribute */: case 244 /* ModuleDeclaration */: case 247 /* NamespaceExportDeclaration */: @@ -100332,8 +101280,8 @@ var ts; return !!decl.initializer || ts.isCatchClause(decl.parent); case 155 /* MethodSignature */: case 153 /* PropertySignature */: - case 305 /* JSDocPropertyTag */: - case 299 /* JSDocParameterTag */: + case 310 /* JSDocPropertyTag */: + case 304 /* JSDocParameterTag */: return false; default: return ts.Debug.failBadSyntaxKind(decl); @@ -100493,7 +101441,7 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; switch (decl.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: // Don't include the source file itself. (This may not be ideal behavior, but awkward to include an entire file as a reference.) break; case 244 /* ModuleDeclaration */: @@ -100864,7 +101812,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (!container || container.kind === 279 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { + if (!container || container.kind === 284 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { // This is a global variable and not an external module, any declaration defined // within this scope is visible outside the file return undefined; @@ -101423,7 +102371,7 @@ var ts; staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 279 /* SourceFile */: + case 284 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode) || isParameterName(thisOrSuperKeyword)) { return undefined; } @@ -101436,7 +102384,7 @@ var ts; default: return undefined; } - var references = ts.flatMap(searchSpaceNode.kind === 279 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { + var references = ts.flatMap(searchSpaceNode.kind === 284 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return getPossibleSymbolReferenceNodes(sourceFile, "this", ts.isSourceFile(searchSpaceNode) ? sourceFile : searchSpaceNode).filter(function (node) { if (!ts.isThis(node)) { @@ -101455,8 +102403,8 @@ var ts; // Make sure the container belongs to the same class // and has the appropriate static modifier from the original container. return container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getModifierFlags(container) & 32 /* Static */) === staticFlag; - case 279 /* SourceFile */: - return container.kind === 279 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); + case 284 /* SourceFile */: + return container.kind === 284 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); } }); }).map(function (n) { return FindAllReferences.nodeEntry(n); }); @@ -102310,11 +103258,11 @@ var ts; JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations; function getCommentHavingNodes(declaration) { switch (declaration.kind) { - case 299 /* JSDocParameterTag */: - case 305 /* JSDocPropertyTag */: + case 304 /* JSDocParameterTag */: + case 310 /* JSDocPropertyTag */: return [declaration]; - case 297 /* JSDocCallbackTag */: - case 304 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: + case 309 /* JSDocTypedefTag */: return [declaration, declaration.parent]; default: return ts.getJSDocCommentsAndTags(declaration); @@ -102335,16 +103283,16 @@ var ts; function getCommentText(tag) { var comment = tag.comment; switch (tag.kind) { - case 295 /* JSDocAugmentsTag */: + case 300 /* JSDocAugmentsTag */: return withNode(tag.class); - case 303 /* JSDocTemplateTag */: + case 308 /* JSDocTemplateTag */: return withList(tag.typeParameters); - case 302 /* JSDocTypeTag */: + case 307 /* JSDocTypeTag */: return withNode(tag.typeExpression); - case 304 /* JSDocTypedefTag */: - case 297 /* JSDocCallbackTag */: - case 305 /* JSDocPropertyTag */: - case 299 /* JSDocParameterTag */: + case 309 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: + case 310 /* JSDocPropertyTag */: + case 304 /* JSDocParameterTag */: var name = tag.name; return name ? withNode(name) : comment; default: @@ -102555,7 +103503,7 @@ var ts; : undefined; return { commentOwner: commentOwner, parameters: parameters_1 }; } - case 279 /* SourceFile */: + case 284 /* SourceFile */: return "quit"; case 244 /* ModuleDeclaration */: // If in walking up the tree, we hit a a nested namespace declaration, @@ -103115,7 +104063,7 @@ var ts; } } switch (node.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" @@ -103167,10 +104115,10 @@ var ts; case 243 /* EnumDeclaration */: case 241 /* InterfaceDeclaration */: case 244 /* ModuleDeclaration */: - case 279 /* SourceFile */: + case 284 /* SourceFile */: case 242 /* TypeAliasDeclaration */: - case 304 /* JSDocTypedefTag */: - case 297 /* JSDocCallbackTag */: + case 309 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: return true; case 157 /* Constructor */: case 156 /* MethodDeclaration */: @@ -103191,7 +104139,7 @@ var ts; } switch (navigationBarNodeKind(item.parent)) { case 245 /* ModuleBlock */: - case 279 /* SourceFile */: + case 284 /* SourceFile */: case 156 /* MethodDeclaration */: case 157 /* Constructor */: return true; @@ -103276,7 +104224,7 @@ var ts; return !member.name || member.name.kind === 149 /* ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 279 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); + return node.kind === 284 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); } function getModifiers(node) { if (node.parent && node.parent.kind === 237 /* VariableDeclaration */) { @@ -105456,8 +106404,8 @@ var ts; var name = importNameForConvertToDefaultImport(importNode); if (!name) continue; - var module_1 = ts.getResolvedModule(sourceFile, moduleSpecifier.text); - var resolvedFile = module_1 && program.getSourceFile(module_1.resolvedFileName); + var module = ts.getResolvedModule(sourceFile, moduleSpecifier.text); + var resolvedFile = module && program.getSourceFile(module.resolvedFileName); if (resolvedFile && resolvedFile.externalModuleIndicator && ts.isExportAssignment(resolvedFile.externalModuleIndicator) && resolvedFile.externalModuleIndicator.isExportEquals) { diags.push(ts.createDiagnosticForNode(name, ts.Diagnostics.Import_may_be_converted_to_a_default_import)); } @@ -106094,7 +107042,7 @@ var ts; // For some special property access expressions like `exports.foo = foo` or `module.exports.foo = foo` // there documentation comments might be attached to the right hand side symbol of their declarations. // The pattern of such special property access is that the parent symbol is the symbol of the file. - if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 279 /* SourceFile */; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 284 /* SourceFile */; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; if (!declaration.parent || declaration.parent.kind !== 204 /* BinaryExpression */) { @@ -106219,7 +107167,7 @@ var ts; // If the parent is not sourceFile or module block it is local variable for (var parent = declaration.parent; !ts.isFunctionBlock(parent); parent = parent.parent) { // Reached source file or module block - if (parent.kind === 279 /* SourceFile */ || parent.kind === 245 /* ModuleBlock */) { + if (parent.kind === 284 /* SourceFile */ || parent.kind === 245 /* ModuleBlock */) { return false; } } @@ -107544,7 +108492,7 @@ var ts; case 244 /* ModuleDeclaration */: var body = parent.body; return !!body && body.kind === 245 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 279 /* SourceFile */: + case 284 /* SourceFile */: case 218 /* Block */: case 245 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); @@ -108663,7 +109611,7 @@ var ts; // - parent is SourceFile - by default immediate children of SourceFile are not indented except when user indents them manually // - parent and child are not on the same line var useActualIndentation = (ts.isDeclaration(current) || ts.isStatementButNotDeclaration(current)) && - (parent.kind === 279 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 284 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -108751,7 +109699,7 @@ var ts; case 209 /* ClassExpression */: case 241 /* InterfaceDeclaration */: case 242 /* TypeAliasDeclaration */: - case 303 /* JSDocTemplateTag */: + case 308 /* JSDocTemplateTag */: return getList(node.typeParameters); case 192 /* NewExpression */: case 191 /* CallExpression */: @@ -110314,18 +111262,18 @@ var ts; } function transformJSDocType(node) { switch (node.kind) { - case 284 /* JSDocAllType */: - case 285 /* JSDocUnknownType */: + case 289 /* JSDocAllType */: + case 290 /* JSDocUnknownType */: return ts.createTypeReferenceNode("any", ts.emptyArray); - case 288 /* JSDocOptionalType */: + case 293 /* JSDocOptionalType */: return transformJSDocOptionalType(node); - case 287 /* JSDocNonNullableType */: + case 292 /* JSDocNonNullableType */: return transformJSDocType(node.type); - case 286 /* JSDocNullableType */: + case 291 /* JSDocNullableType */: return transformJSDocNullableType(node); - case 290 /* JSDocVariadicType */: + case 295 /* JSDocVariadicType */: return transformJSDocVariadicType(node); - case 289 /* JSDocFunctionType */: + case 294 /* JSDocFunctionType */: return transformJSDocFunctionType(node); case 164 /* TypeReference */: return transformJSDocTypeReference(node); @@ -110349,7 +111297,7 @@ var ts; } function transformJSDocParameter(node) { var index = node.parent.parameters.indexOf(node); - var isRest = node.type.kind === 290 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 + var isRest = node.type.kind === 295 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 var name = node.name || (isRest ? "rest" : "arg" + index); var dotdotdot = isRest ? ts.createToken(25 /* DotDotDotToken */) : node.dotDotDotToken; return ts.createParameter(node.decorators, node.modifiers, dotdotdot, name, node.questionToken, ts.visitNode(node.type, transformJSDocType), node.initializer); @@ -110668,14 +111616,14 @@ var ts; return undefined; } switch (oldTag.kind) { - case 299 /* JSDocParameterTag */: { + case 304 /* JSDocParameterTag */: { var oldParam = oldTag; var newParam = newTag; return ts.isIdentifier(oldParam.name) && ts.isIdentifier(newParam.name) && oldParam.name.escapedText === newParam.name.escapedText ? ts.createJSDocParamTag(newParam.name, newParam.isBracketed, newParam.typeExpression, oldParam.comment) : undefined; } - case 300 /* JSDocReturnTag */: + case 305 /* JSDocReturnTag */: return ts.createJSDocReturnTag(newTag.typeExpression, oldTag.comment); } } @@ -114055,7 +115003,7 @@ var ts; var typeNode = info.typeNode, type = info.type; var original = typeNode.getText(sourceFile); var actions = [fix(type, fixIdPlain, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript)]; - if (typeNode.kind === 286 /* JSDocNullableType */) { + if (typeNode.kind === 291 /* JSDocNullableType */) { // for nullable types, suggest the flow-compatible `T | null | undefined` // in addition to the jsdoc/closure-compatible `T | null` actions.push(fix(checker.getNullableType(type, 32768 /* Undefined */), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types)); @@ -114075,7 +115023,7 @@ var ts; if (!info) return; var typeNode = info.typeNode, type = info.type; - var fixedType = typeNode.kind === 286 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; + var fixedType = typeNode.kind === 291 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; doChange(changes, sourceFile, typeNode, fixedType, checker); }); } @@ -114707,6 +115655,7 @@ var ts; return ts.textChanges.getNewFileText(toStatements(valueInfo, outputKind), 3 /* TS */, formatSettings.newLineCharacter || "\n", ts.formatting.getFormatContext(formatSettings)); } ts.valueInfoToDeclarationFileText = valueInfoToDeclarationFileText; + /* @internal */ var OutputKind; (function (OutputKind) { OutputKind[OutputKind["ExportEquals"] = 0] = "ExportEquals"; @@ -115874,7 +116823,7 @@ var ts; // * Module/namespace or source file if (isScope(current)) { scopes.push(current); - if (current.kind === 279 /* SourceFile */) { + if (current.kind === 284 /* SourceFile */) { return scopes; } } @@ -116888,7 +117837,7 @@ var ts; function isBlockLike(node) { switch (node.kind) { case 218 /* Block */: - case 279 /* SourceFile */: + case 284 /* SourceFile */: case 245 /* ModuleBlock */: case 271 /* CaseClause */: return true; @@ -117350,9 +118299,9 @@ var ts; if (isTopLevelDeclarationStatement(statement) && !isExported(sourceFile, statement, useEs6Exports) && forEachTopLevelDeclaration(statement, function (d) { return needExport.has(ts.Debug.assertDefined(d.symbol)); })) { - var exports_1 = addExport(statement, useEs6Exports); - if (exports_1) - return exports_1; + var exports = addExport(statement, useEs6Exports); + if (exports) + return exports; } return statement; }); @@ -117952,7 +118901,7 @@ var ts; if (!children.length) { return undefined; } - var child = ts.find(children, function (kid) { return kid.kind < 283 /* FirstJSDocNode */ || kid.kind > 305 /* LastJSDocNode */; }); + var child = ts.find(children, function (kid) { return kid.kind < 288 /* FirstJSDocNode */ || kid.kind > 310 /* LastJSDocNode */; }); return child.kind < 148 /* FirstNode */ ? child : child.getFirstToken(sourceFile); @@ -118022,7 +118971,7 @@ var ts; } } function createSyntaxList(nodes, parent) { - var list = createNode(306 /* SyntaxList */, nodes.pos, nodes.end, parent); + var list = createNode(311 /* SyntaxList */, nodes.pos, nodes.end, parent); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { @@ -121530,6 +122479,7 @@ var ts; LogLevel[LogLevel["verbose"] = 3] = "verbose"; })(LogLevel = server.LogLevel || (server.LogLevel = {})); server.emptyArray = createSortedArray(); + // TODO: Use a const enum (https://github.com/Microsoft/TypeScript/issues/16804) var Msg; (function (Msg) { Msg["Err"] = "Err"; @@ -121539,7 +122489,7 @@ var ts; function createInstallTypingsRequest(project, typeAcquisition, unresolvedImports, cachePath) { return { projectName: project.getProjectName(), - fileNames: project.getFileNames(true, true).concat(project.getExcludedFiles()), + fileNames: project.getFileNames(/*excludeFilesFromExternalLibraries*/ true, /*excludeConfigFiles*/ true).concat(project.getExcludedFiles()), compilerOptions: project.getCompilationSettings(), typeAcquisition: typeAcquisition, unresolvedImports: unresolvedImports, @@ -121596,6 +122546,7 @@ var ts; } server.createNormalizedPathMap = createNormalizedPathMap; function isInferredProjectName(name) { + // POSIX defines /dev/null as a device - there should be no file with this prefix return /dev\/null\/inferredProject\d+\*/.test(name); } server.isInferredProjectName = isInferredProjectName; @@ -121604,25 +122555,34 @@ var ts; } server.makeInferredProjectName = makeInferredProjectName; function createSortedArray() { - return []; + return []; // TODO: GH#19873 } server.createSortedArray = createSortedArray; })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); +/* @internal */ (function (ts) { var server; (function (server) { - var ThrottledOperations = (function () { + var ThrottledOperations = /** @class */ (function () { function ThrottledOperations(host, logger) { this.host = host; this.pendingTimeouts = ts.createMap(); this.logger = logger.hasLevel(server.LogLevel.verbose) ? logger : undefined; } + /** + * Wait `number` milliseconds and then invoke `cb`. If, while waiting, schedule + * is called again with the same `operationId`, cancel this operation in favor + * of the new one. (Note that the amount of time the canceled operation had been + * waiting does not affect the amount of time that the new operation waits.) + */ ThrottledOperations.prototype.schedule = function (operationId, delay, cb) { var pendingTimeout = this.pendingTimeouts.get(operationId); if (pendingTimeout) { + // another operation was already scheduled for this id - cancel it this.host.clearTimeout(pendingTimeout); } + // schedule new operation, pass arguments this.pendingTimeouts.set(operationId, this.host.setTimeout(ThrottledOperations.run, delay, this, operationId, cb)); if (this.logger) { this.logger.info("Scheduled: " + operationId + (pendingTimeout ? ", Cancelled earlier one" : "")); @@ -121638,7 +122598,7 @@ var ts; return ThrottledOperations; }()); server.ThrottledOperations = ThrottledOperations; - var GcTimer = (function () { + var GcTimer = /** @class */ (function () { function GcTimer(host, delay, logger) { this.host = host; this.delay = delay; @@ -121646,6 +122606,7 @@ var ts; } GcTimer.prototype.scheduleCollect = function () { if (!this.host.gc || this.timerId !== undefined) { + // no global.gc or collection was already scheduled - skip this request return; } this.timerId = this.host.setTimeout(GcTimer.run, this.delay, this); @@ -121653,10 +122614,10 @@ var ts; GcTimer.run = function (self) { self.timerId = undefined; var log = self.logger.hasLevel(server.LogLevel.requestTime); - var before = log && self.host.getMemoryUsage(); - self.host.gc(); + var before = log && self.host.getMemoryUsage(); // TODO: GH#18217 + self.host.gc(); // TODO: GH#18217 if (log) { - var after = self.host.getMemoryUsage(); + var after = self.host.getMemoryUsage(); // TODO: GH#18217 self.logger.perftrc("GC::before " + before + ", after " + after); } }; @@ -121687,13 +122648,16 @@ var ts; return indentStr + str.replace(/\n/g, indentStr); } server.indent = indent; + /** Put stringified JSON on the next line, indented. */ function stringifyIndented(json) { return indentStr + JSON.stringify(json); } server.stringifyIndented = stringifyIndented; })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); +/* @internal */ (function (ts) { + // Additional tsserver specific watch information var WatchType; (function (WatchType) { WatchType["ClosedScriptInfo"] = "Closed Script info"; @@ -121702,41 +122666,57 @@ var ts; WatchType["MissingSourceMapFile"] = "Missing source map file"; })(WatchType = ts.WatchType || (ts.WatchType = {})); })(ts || (ts = {})); +// tslint:disable no-unnecessary-qualifier +/** + * Declaration module describing the TypeScript Server protocol + */ var ts; (function (ts) { var server; (function (server) { var protocol; (function (protocol) { + // NOTE: If updating this, be sure to also update `allCommandNames` in `harness/unittests/session.ts`. var CommandTypes; (function (CommandTypes) { CommandTypes["JsxClosingTag"] = "jsxClosingTag"; CommandTypes["Brace"] = "brace"; + /* @internal */ CommandTypes["BraceFull"] = "brace-full"; CommandTypes["BraceCompletion"] = "braceCompletion"; CommandTypes["GetSpanOfEnclosingComment"] = "getSpanOfEnclosingComment"; CommandTypes["Change"] = "change"; CommandTypes["Close"] = "close"; + /** @deprecated Prefer CompletionInfo -- see comment on CompletionsResponse */ CommandTypes["Completions"] = "completions"; CommandTypes["CompletionInfo"] = "completionInfo"; + /* @internal */ CommandTypes["CompletionsFull"] = "completions-full"; CommandTypes["CompletionDetails"] = "completionEntryDetails"; + /* @internal */ CommandTypes["CompletionDetailsFull"] = "completionEntryDetails-full"; CommandTypes["CompileOnSaveAffectedFileList"] = "compileOnSaveAffectedFileList"; CommandTypes["CompileOnSaveEmitFile"] = "compileOnSaveEmitFile"; CommandTypes["Configure"] = "configure"; CommandTypes["Definition"] = "definition"; + /* @internal */ CommandTypes["DefinitionFull"] = "definition-full"; CommandTypes["DefinitionAndBoundSpan"] = "definitionAndBoundSpan"; + /* @internal */ CommandTypes["DefinitionAndBoundSpanFull"] = "definitionAndBoundSpan-full"; CommandTypes["Implementation"] = "implementation"; + /* @internal */ CommandTypes["ImplementationFull"] = "implementation-full"; + /* @internal */ CommandTypes["EmitOutput"] = "emit-output"; CommandTypes["Exit"] = "exit"; CommandTypes["Format"] = "format"; CommandTypes["Formatonkey"] = "formatonkey"; + /* @internal */ CommandTypes["FormatFull"] = "format-full"; + /* @internal */ CommandTypes["FormatonkeyFull"] = "formatonkey-full"; + /* @internal */ CommandTypes["FormatRangeFull"] = "formatRange-full"; CommandTypes["Geterr"] = "geterr"; CommandTypes["GeterrForProject"] = "geterrForProject"; @@ -121744,25 +122724,34 @@ var ts; CommandTypes["SyntacticDiagnosticsSync"] = "syntacticDiagnosticsSync"; CommandTypes["SuggestionDiagnosticsSync"] = "suggestionDiagnosticsSync"; CommandTypes["NavBar"] = "navbar"; + /* @internal */ CommandTypes["NavBarFull"] = "navbar-full"; CommandTypes["Navto"] = "navto"; + /* @internal */ CommandTypes["NavtoFull"] = "navto-full"; CommandTypes["NavTree"] = "navtree"; CommandTypes["NavTreeFull"] = "navtree-full"; + /** @deprecated */ CommandTypes["Occurrences"] = "occurrences"; CommandTypes["DocumentHighlights"] = "documentHighlights"; + /* @internal */ CommandTypes["DocumentHighlightsFull"] = "documentHighlights-full"; CommandTypes["Open"] = "open"; CommandTypes["Quickinfo"] = "quickinfo"; + /* @internal */ CommandTypes["QuickinfoFull"] = "quickinfo-full"; CommandTypes["References"] = "references"; + /* @internal */ CommandTypes["ReferencesFull"] = "references-full"; CommandTypes["Reload"] = "reload"; CommandTypes["Rename"] = "rename"; + /* @internal */ CommandTypes["RenameInfoFull"] = "rename-full"; + /* @internal */ CommandTypes["RenameLocationsFull"] = "renameLocations-full"; CommandTypes["Saveto"] = "saveto"; CommandTypes["SignatureHelp"] = "signatureHelp"; + /* @internal */ CommandTypes["SignatureHelpFull"] = "signatureHelp-full"; CommandTypes["Status"] = "status"; CommandTypes["TypeDefinition"] = "typeDefinition"; @@ -121772,33 +122761,47 @@ var ts; CommandTypes["OpenExternalProject"] = "openExternalProject"; CommandTypes["OpenExternalProjects"] = "openExternalProjects"; CommandTypes["CloseExternalProject"] = "closeExternalProject"; + /* @internal */ CommandTypes["SynchronizeProjectList"] = "synchronizeProjectList"; + /* @internal */ CommandTypes["ApplyChangedToOpenFiles"] = "applyChangedToOpenFiles"; + /* @internal */ CommandTypes["EncodedSemanticClassificationsFull"] = "encodedSemanticClassifications-full"; + /* @internal */ CommandTypes["Cleanup"] = "cleanup"; CommandTypes["GetOutliningSpans"] = "getOutliningSpans"; + /* @internal */ CommandTypes["GetOutliningSpansFull"] = "outliningSpans"; CommandTypes["TodoComments"] = "todoComments"; CommandTypes["Indentation"] = "indentation"; CommandTypes["DocCommentTemplate"] = "docCommentTemplate"; + /* @internal */ CommandTypes["CompilerOptionsDiagnosticsFull"] = "compilerOptionsDiagnostics-full"; + /* @internal */ CommandTypes["NameOrDottedNameSpan"] = "nameOrDottedNameSpan"; + /* @internal */ CommandTypes["BreakpointStatement"] = "breakpointStatement"; CommandTypes["CompilerOptionsForInferredProjects"] = "compilerOptionsForInferredProjects"; CommandTypes["GetCodeFixes"] = "getCodeFixes"; + /* @internal */ CommandTypes["GetCodeFixesFull"] = "getCodeFixes-full"; CommandTypes["GetCombinedCodeFix"] = "getCombinedCodeFix"; + /* @internal */ CommandTypes["GetCombinedCodeFixFull"] = "getCombinedCodeFix-full"; CommandTypes["ApplyCodeActionCommand"] = "applyCodeActionCommand"; CommandTypes["GetSupportedCodeFixes"] = "getSupportedCodeFixes"; CommandTypes["GetApplicableRefactors"] = "getApplicableRefactors"; CommandTypes["GetEditsForRefactor"] = "getEditsForRefactor"; + /* @internal */ CommandTypes["GetEditsForRefactorFull"] = "getEditsForRefactor-full"; CommandTypes["OrganizeImports"] = "organizeImports"; + /* @internal */ CommandTypes["OrganizeImportsFull"] = "organizeImports-full"; CommandTypes["GetEditsForFileRename"] = "getEditsForFileRename"; + /* @internal */ CommandTypes["GetEditsForFileRenameFull"] = "getEditsForFileRename-full"; CommandTypes["ConfigurePlugin"] = "configurePlugin"; + // NOTE: If updating this, be sure to also update `allCommandNames` in `harness/unittests/session.ts`. })(CommandTypes = protocol.CommandTypes || (protocol.CommandTypes = {})); var IndentStyle; (function (IndentStyle) { @@ -121851,13 +122854,23 @@ var ts; (function (ts) { var server; (function (server) { - var TextStorage = (function () { + /* @internal */ + var TextStorage = /** @class */ (function () { function TextStorage(host, fileName, initialVersion, info) { this.host = host; this.fileName = fileName; this.info = info; + /** + * True if the text is for the file thats open in the editor + */ this.isOpen = false; + /** + * True if the text present is the text from the file on the disk + */ this.ownFileText = false; + /** + * True when reloading contents of file from the disk is pending + */ this.pendingReloadFromDisk = false; this.version = initialVersion || { svc: 0, text: 0 }; } @@ -121880,6 +122893,7 @@ var ts; this.info.sourceInfos = undefined; this.info.documentPositionMapper = undefined; }; + /** Public for testing */ TextStorage.prototype.useText = function (newText) { this.svc = undefined; this.text = newText; @@ -121896,23 +122910,42 @@ var ts; this.fileSize = undefined; this.resetSourceMapInfo(); }; + /** + * Set the contents as newText + * returns true if text changed + */ TextStorage.prototype.reload = function (newText) { ts.Debug.assert(newText !== undefined); + // Reload always has fresh content this.pendingReloadFromDisk = false; + // If text changed set the text + // This also ensures that if we had switched to version cache, + // we are switching back to text. + // The change to version cache will happen when needed + // Thus avoiding the computation if there are no changes if (this.text !== newText) { this.useText(newText); + // We cant guarantee new text is own file text this.ownFileText = false; return true; } return false; }; + /** + * Reads the contents from tempFile(if supplied) or own file and sets it as contents + * returns true if text changed + */ TextStorage.prototype.reloadWithFileText = function (tempFileName) { var _a = this.getFileTextAndSize(tempFileName), newText = _a.text, fileSize = _a.fileSize; var reloaded = this.reload(newText); - this.fileSize = fileSize; + this.fileSize = fileSize; // NB: after reload since reload clears it this.ownFileText = !tempFileName || tempFileName === this.fileName; return reloaded; }; + /** + * Reloads the contents from the file if there is no pending reload from disk or the contents of file are same as file text + * returns true if text changed + */ TextStorage.prototype.reloadFromDisk = function () { if (!this.pendingReloadFromDisk && !this.ownFileText) { return this.reloadWithFileText(); @@ -121922,14 +122955,21 @@ var ts; TextStorage.prototype.delayReloadFromFileIntoText = function () { this.pendingReloadFromDisk = true; }; + /** + * For telemetry purposes, we would like to be able to report the size of the file. + * However, we do not want telemetry to require extra file I/O so we report a size + * that may be stale (e.g. may not reflect change made on disk since the last reload). + * NB: Will read from disk if the file contents have never been loaded because + * telemetry falsely indicating size 0 would be counter-productive. + */ TextStorage.prototype.getTelemetryFileSize = function () { return !!this.fileSize ? this.fileSize - : !!this.text - ? this.text.length + : !!this.text // Check text before svc because its length is cheaper + ? this.text.length // Could be wrong if this.pendingReloadFromDisk : !!this.svc - ? this.svc.getSnapshot().getLength() - : this.getSnapshot().getLength(); + ? this.svc.getSnapshot().getLength() // Could be wrong if this.pendingReloadFromDisk + : this.getSnapshot().getLength(); // Should be strictly correct }; TextStorage.prototype.getSnapshot = function () { return this.useScriptVersionCacheIfValidOrOpen() @@ -121939,19 +122979,27 @@ var ts; TextStorage.prototype.getAbsolutePositionAndLineText = function (line) { return this.switchToScriptVersionCache().getAbsolutePositionAndLineText(line); }; + /** + * @param line 0 based index + */ TextStorage.prototype.lineToTextSpan = function (line) { if (!this.useScriptVersionCacheIfValidOrOpen()) { var lineMap = this.getLineMap(); - var start = lineMap[line]; + var start = lineMap[line]; // -1 since line is 1-based var end = line + 1 < lineMap.length ? lineMap[line + 1] : this.text.length; return ts.createTextSpanFromBounds(start, end); } return this.svc.lineToTextSpan(line); }; + /** + * @param line 1 based index + * @param offset 1 based index + */ TextStorage.prototype.lineOffsetToPosition = function (line, offset, allowEdits) { if (!this.useScriptVersionCacheIfValidOrOpen()) { return ts.computePositionOfLineAndCharacter(this.getLineMap(), line - 1, offset - 1, this.text, allowEdits); } + // TODO: assert this offset is actually on the line return this.svc.lineOffsetToPosition(line, offset); }; TextStorage.prototype.positionToLineOffset = function (position) { @@ -121966,6 +123014,7 @@ var ts; var text; var fileName = tempFileName || this.fileName; var getText = function () { return text === undefined ? (text = _this.host.readFile(fileName) || "") : text; }; + // Only non typescript files have size limitation if (!ts.hasTSFileExtension(this.fileName)) { var fileSize = this.host.getFileSize ? this.host.getFileSize(fileName) : getText().length; if (fileSize > server.maxFileSize) { @@ -121986,12 +123035,15 @@ var ts; return this.svc; }; TextStorage.prototype.useScriptVersionCacheIfValidOrOpen = function () { + // If this is open script, use the cache if (this.isOpen) { return this.switchToScriptVersionCache(); } + // If there is pending reload from the disk then, reload the text if (this.pendingReloadFromDisk) { this.reloadWithFileText(); } + // At this point if svc is present its valid return this.svc; }; TextStorage.prototype.getOrLoadText = function () { @@ -122019,17 +123071,21 @@ var ts; return TextStorage; }()); server.TextStorage = TextStorage; + /*@internal*/ function isDynamicFileName(fileName) { return fileName[0] === "^" || ts.getBaseFileName(fileName)[0] === "^"; } server.isDynamicFileName = isDynamicFileName; - var ScriptInfo = (function () { + var ScriptInfo = /** @class */ (function () { function ScriptInfo(host, fileName, scriptKind, hasMixedContent, path, initialVersion) { this.host = host; this.fileName = fileName; this.scriptKind = scriptKind; this.hasMixedContent = hasMixedContent; this.path = path; + /** + * All projects that include this file + */ this.containingProjects = []; this.isDynamic = isDynamicFileName(fileName); this.textStorage = new TextStorage(host, fileName, initialVersion, this); @@ -122041,12 +123097,15 @@ var ts; ? scriptKind : ts.getScriptKindFromFileName(fileName); } + /*@internal*/ ScriptInfo.prototype.getVersion = function () { return this.textStorage.version; }; + /*@internal*/ ScriptInfo.prototype.getTelemetryFileSize = function () { return this.textStorage.getTelemetryFileSize(); }; + /*@internal*/ ScriptInfo.prototype.isDynamicOrHasMixedContent = function () { return this.hasMixedContent || this.isDynamic; }; @@ -122057,6 +123116,7 @@ var ts; this.textStorage.isOpen = true; if (newText !== undefined && this.textStorage.reload(newText)) { + // reload new contents only if the existing contents changed this.markContainingProjectsAsDirty(); } }; @@ -122077,6 +123137,7 @@ var ts; }; ScriptInfo.prototype.ensureRealPath = function () { if (this.realpath === undefined) { + // Default is just the path this.realpath = this.path; if (this.host.realpath) { ts.Debug.assert(!!this.containingProjects.length); @@ -122084,13 +123145,15 @@ var ts; var realpath = this.host.realpath(this.path); if (realpath) { this.realpath = project.toPath(realpath); + // If it is different from this.path, add to the map if (this.realpath !== this.path) { - project.projectService.realpathToScriptInfos.add(this.realpath, this); + project.projectService.realpathToScriptInfos.add(this.realpath, this); // TODO: GH#18217 } } } } }; + /*@internal*/ ScriptInfo.prototype.getRealpathIfDifferent = function () { return this.realpath && this.realpath !== this.path ? this.realpath : undefined; }; @@ -122108,6 +123171,7 @@ var ts; return isNew; }; ScriptInfo.prototype.isAttached = function (project) { + // unrolled for common cases switch (this.containingProjects.length) { case 0: return false; case 1: return this.containingProjects[0] === project; @@ -122116,6 +123180,7 @@ var ts; } }; ScriptInfo.prototype.detachFromProject = function (project) { + // unrolled for common cases switch (this.containingProjects.length) { case 0: return; @@ -122149,7 +123214,10 @@ var ts; p.getCachedDirectoryStructureHost().addOrDeleteFile(this.fileName, this.path, ts.FileWatcherEventKind.Deleted); } var isInfoRoot = p.isRoot(this); - p.removeFile(this, false, false); + // detach is unnecessary since we'll clean the list of containing projects anyways + p.removeFile(this, /*fileExists*/ false, /*detachFromProjects*/ false); + // If the info was for the external or configured project's root, + // add missing file as the root if (isInfoRoot && p.projectKind !== server.ProjectKind.Inferred) { p.addMissingFileRoot(this.fileName); } @@ -122163,6 +123231,9 @@ var ts; case 1: return this.containingProjects[0]; default: + // if this file belongs to multiple projects, the first configured project should be + // the default project; if no configured projects, the first external project should + // be the default project; otherwise the first inferred project should be the default. var firstExternalProject = void 0; for (var _i = 0, _a = this.containingProjects; _i < _a.length; _i++) { var project = _a[_i]; @@ -122205,6 +123276,7 @@ var ts; ScriptInfo.prototype.saveTo = function (fileName) { this.host.writeFile(fileName, ts.getSnapshotText(this.textStorage.getSnapshot())); }; + /*@internal*/ ScriptInfo.prototype.delayReloadNonMixedContentFile = function () { ts.Debug.assert(!this.isDynamicOrHasMixedContent()); this.textStorage.delayReloadFromFileIntoText(); @@ -122224,6 +123296,7 @@ var ts; } return false; }; + /*@internal*/ ScriptInfo.prototype.getAbsolutePositionAndLineText = function (line) { return this.textStorage.getAbsolutePositionAndLineText(line); }; @@ -122240,6 +123313,9 @@ var ts; ScriptInfo.prototype.isOrphan = function () { return !ts.forEach(this.containingProjects, function (p) { return !p.isOrphan(); }); }; + /** + * @param line 1 based index + */ ScriptInfo.prototype.lineToTextSpan = function (line) { return this.textStorage.lineToTextSpan(line); }; @@ -122250,11 +123326,13 @@ var ts; return this.textStorage.positionToLineOffset(position); }; ScriptInfo.prototype.isJavaScript = function () { - return this.scriptKind === 1 || this.scriptKind === 2; + return this.scriptKind === 1 /* JS */ || this.scriptKind === 2 /* JSX */; }; + /*@internal*/ ScriptInfo.prototype.getLineInfo = function () { return this.textStorage.getLineInfo(); }; + /*@internal*/ ScriptInfo.prototype.closeSourceMapFileWatcher = function () { if (this.sourceMapFilePath && !ts.isString(this.sourceMapFilePath)) { ts.closeFileWatcherOf(this.sourceMapFilePath); @@ -122272,12 +123350,13 @@ var ts; (function (server) { server.nullTypingsInstaller = { isKnownTypesPackageName: ts.returnFalse, + // Should never be called because we never provide a types registry. installPackage: ts.notImplemented, inspectValue: ts.notImplemented, enqueueInstallTypingsRequest: ts.noop, attach: ts.noop, onProjectClosed: ts.noop, - globalTypingsCacheLocation: undefined + globalTypingsCacheLocation: undefined // TODO: GH#18217 }; function setIsEqualTo(arr1, arr2) { if (arr1 === arr2) { @@ -122314,6 +123393,7 @@ var ts; !setIsEqualTo(opt1.exclude, opt2.exclude); } function compilerOptionsChanged(opt1, opt2) { + // TODO: add more relevant properties return opt1.allowJs !== opt2.allowJs; } function unresolvedImportsChanged(imports1, imports2) { @@ -122322,7 +123402,8 @@ var ts; } return !ts.arrayIsEqualTo(imports1, imports2); } - var TypingsCache = (function () { + /*@internal*/ + var TypingsCache = /** @class */ (function () { function TypingsCache(installer) { this.installer = installer; this.perProjectCache = ts.createMap(); @@ -122347,6 +123428,8 @@ var ts; typeAcquisitionChanged(typeAcquisition, entry.typeAcquisition) || compilerOptionsChanged(project.getCompilationSettings(), entry.compilerOptions) || unresolvedImportsChanged(unresolvedImports, entry.unresolvedImports)) { + // Note: entry is now poisoned since it does not really contain typings for a given combination of compiler options\typings options. + // instead it acts as a placeholder to prevent issuing multiple requests this.perProjectCache.set(project.getProjectName(), { compilerOptions: project.getCompilationSettings(), typeAcquisition: typeAcquisition, @@ -122354,6 +123437,7 @@ var ts; unresolvedImports: unresolvedImports, poisoned: true }); + // something has been changed, issue a request to update typings this.installer.enqueueInstallTypingsRequest(project, typeAcquisition, unresolvedImports); } }; @@ -122387,6 +123471,7 @@ var ts; ProjectKind[ProjectKind["Configured"] = 1] = "Configured"; ProjectKind[ProjectKind["External"] = 2] = "External"; })(ProjectKind = server.ProjectKind || (server.ProjectKind = {})); + /* @internal */ function countEachFileTypes(infos, includeSizes) { if (includeSizes === void 0) { includeSizes = false; } var result = { @@ -122401,16 +123486,16 @@ var ts; var info = infos_1[_i]; var fileSize = includeSizes ? info.getTelemetryFileSize() : 0; switch (info.scriptKind) { - case 1: + case 1 /* JS */: result.js += 1; result.jsSize += fileSize; break; - case 2: + case 2 /* JSX */: result.jsx += 1; result.jsxSize += fileSize; break; - case 3: - if (ts.fileExtensionIs(info.fileName, ".d.ts")) { + case 3 /* TS */: + if (ts.fileExtensionIs(info.fileName, ".d.ts" /* Dts */)) { result.dts += 1; result.dtsSize += fileSize; } @@ -122419,11 +123504,11 @@ var ts; result.tsSize += fileSize; } break; - case 4: + case 4 /* TSX */: result.tsx += 1; result.tsxSize += fileSize; break; - case 7: + case 7 /* Deferred */: result.deferred += 1; result.deferredSize += fileSize; break; @@ -122446,15 +123531,18 @@ var ts; return counts.ts === 0 && counts.tsx === 0; } server.allFilesAreJsOrDts = allFilesAreJsOrDts; + /* @internal */ function hasNoTypeScriptSource(fileNames) { - return !fileNames.some(function (fileName) { return (ts.fileExtensionIs(fileName, ".ts") && !ts.fileExtensionIs(fileName, ".d.ts")) || ts.fileExtensionIs(fileName, ".tsx"); }); + return !fileNames.some(function (fileName) { return (ts.fileExtensionIs(fileName, ".ts" /* Ts */) && !ts.fileExtensionIs(fileName, ".d.ts" /* Dts */)) || ts.fileExtensionIs(fileName, ".tsx" /* Tsx */); }); } server.hasNoTypeScriptSource = hasNoTypeScriptSource; + /* @internal */ function isScriptInfo(value) { return value instanceof server.ScriptInfo; } server.isScriptInfo = isScriptInfo; - var Project = (function () { + var Project = /** @class */ (function () { + /*@internal*/ function Project(projectName, projectKind, projectService, documentRegistry, hasExplicitListOfFiles, lastFileExceededProgramSize, compilerOptions, compileOnSaveEnabled, directoryStructureHost, currentDirectory) { var _this = this; this.projectName = projectName; @@ -122466,14 +123554,37 @@ var ts; this.rootFiles = []; this.rootFilesMap = ts.createMap(); this.plugins = []; + /*@internal*/ + /** + * This is map from files to unresolved imports in it + * Maop does not contain entries for files that do not have unresolved imports + * This helps in containing the set of files to invalidate + */ this.cachedUnresolvedImportsPerFile = ts.createMap(); + /*@internal*/ this.hasAddedorRemovedFiles = false; + /** + * Last version that was reported. + */ this.lastReportedVersion = 0; + /** + * Current project's program version. (incremented everytime new program is created that is not complete reuse from the old one) + * This property is changed in 'updateGraph' based on the set of files in program + */ this.projectProgramVersion = 0; + /** + * Current version of the project state. It is changed when: + * - new root file was added/removed + * - edit happen in some file that is currently included in the project. + * This property is different from projectStructureVersion since in most cases edits don't affect set of files in the project + */ this.projectStateVersion = 0; this.isInitialLoadPending = ts.returnFalse; + /*@internal*/ this.dirty = false; + /*@internal*/ this.hasChangedAutomaticTypeDirectiveNames = false; + /*@internal*/ this.typingFiles = server.emptyArray; this.directoryStructureHost = directoryStructureHost; this.currentDirectory = this.projectService.getNormalizedAbsolutePath(currentDirectory || ""); @@ -122485,6 +123596,7 @@ var ts; this.compilerOptions.allowJs = true; } else if (hasExplicitListOfFiles || this.compilerOptions.allowJs || this.projectService.hasDeferredExtension()) { + // If files are listed explicitly or allowJs is specified, allow all extensions this.compilerOptions.allowNonTsExtensions = true; } this.languageServiceEnabled = !projectService.syntaxOnly; @@ -122499,7 +123611,8 @@ var ts; if (host.realpath) { this.realpath = function (path) { return host.realpath(path); }; } - this.resolutionCache = ts.createResolutionCache(this, currentDirectory && this.currentDirectory, true); + // Use the current directory as resolution root only if the project created using current directory string + this.resolutionCache = ts.createResolutionCache(this, currentDirectory && this.currentDirectory, /*logChangesWhenResolvingModule*/ true); this.languageService = ts.createLanguageService(this, this.documentRegistry, projectService.syntaxOnly); if (lastFileExceededProgramSize) { this.disableLanguageService(lastFileExceededProgramSize); @@ -122518,7 +123631,7 @@ var ts; Project.resolveModule = function (moduleName, initialDir, host, log) { var resolvedPath = ts.normalizeSlashes(host.resolvePath(ts.combinePaths(initialDir, "node_modules"))); log("Loading " + moduleName + " from " + initialDir + " (resolved to " + resolvedPath + ")"); - var result = host.require(resolvedPath, moduleName); + var result = host.require(resolvedPath, moduleName); // TODO: GH#18217 if (result.error) { var err = result.error.stack || result.error.message || JSON.stringify(result.error); log("Failed to load module '" + moduleName + "': " + err); @@ -122532,6 +123645,7 @@ var ts; Project.prototype.installPackage = function (options) { return this.typingsCache.installPackage(__assign({}, options, { projectName: this.projectName, projectRootPath: this.toPath(this.currentDirectory) })); }; + /* @internal */ Project.prototype.inspectValue = function (options) { return this.typingsCache.inspectValue(options); }; @@ -122542,9 +123656,11 @@ var ts; enumerable: true, configurable: true }); + // Method of LanguageServiceHost Project.prototype.getCompilationSettings = function () { return this.compilerOptions; }; + // Method to support public API Project.prototype.getCompilerOptions = function () { return this.getCompilationSettings(); }; @@ -122565,6 +123681,7 @@ var ts; var result; this.rootFilesMap.forEach(function (value) { if (_this.languageServiceEnabled || (isScriptInfo(value) && value.isScriptOpen())) { + // if language service is disabled - process only files that are open (result || (result = [])).push(isScriptInfo(value) ? value.fileName : value); } }); @@ -122575,6 +123692,7 @@ var ts; if (scriptInfo) { var existingValue = this.rootFilesMap.get(scriptInfo.path); if (existingValue !== scriptInfo && existingValue !== undefined) { + // This was missing path earlier but now the file exists. Update the root this.rootFiles.push(scriptInfo); this.rootFilesMap.set(scriptInfo.path, scriptInfo); } @@ -122584,11 +123702,11 @@ var ts; }; Project.prototype.getScriptKind = function (fileName) { var info = this.getOrCreateScriptInfoAndAttachToProject(fileName); - return (info && info.scriptKind); + return (info && info.scriptKind); // TODO: GH#18217 }; Project.prototype.getScriptVersion = function (filename) { var info = this.getOrCreateScriptInfoAndAttachToProject(filename); - return (info && info.getLatestVersion()); + return (info && info.getLatestVersion()); // TODO: GH#18217 }; Project.prototype.getScriptSnapshot = function (filename) { var scriptInfo = this.getOrCreateScriptInfoAndAttachToProject(filename); @@ -122619,6 +123737,8 @@ var ts; return this.projectService.host.writeFile(fileName, content); }; Project.prototype.fileExists = function (file) { + // As an optimization, don't hit the disks for files we already know don't exist + // (because we're watching for their creation). var path = this.toPath(file); return !this.isWatchedMissingFile(path) && this.directoryStructureHost.fileExists(file); }; @@ -122632,33 +123752,41 @@ var ts; return this.resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); }; Project.prototype.directoryExists = function (path) { - return this.directoryStructureHost.directoryExists(path); + return this.directoryStructureHost.directoryExists(path); // TODO: GH#18217 }; Project.prototype.getDirectories = function (path) { - return this.directoryStructureHost.getDirectories(path); + return this.directoryStructureHost.getDirectories(path); // TODO: GH#18217 }; + /*@internal*/ Project.prototype.getCachedDirectoryStructureHost = function () { - return undefined; + return undefined; // TODO: GH#18217 }; + /*@internal*/ Project.prototype.toPath = function (fileName) { return ts.toPath(fileName, this.currentDirectory, this.projectService.toCanonicalFileName); }; + /*@internal*/ Project.prototype.watchDirectoryOfFailedLookupLocation = function (directory, cb, flags) { - return this.projectService.watchFactory.watchDirectory(this.projectService.host, directory, cb, flags, "Failed Lookup Locations", this); + return this.projectService.watchFactory.watchDirectory(this.projectService.host, directory, cb, flags, "Failed Lookup Locations" /* FailedLookupLocations */, this); }; + /*@internal*/ Project.prototype.onInvalidatedResolution = function () { this.projectService.delayUpdateProjectGraphAndEnsureProjectStructureForOpenFiles(this); }; + /*@internal*/ Project.prototype.watchTypeRootsDirectory = function (directory, cb, flags) { - return this.projectService.watchFactory.watchDirectory(this.projectService.host, directory, cb, flags, "Type roots", this); + return this.projectService.watchFactory.watchDirectory(this.projectService.host, directory, cb, flags, "Type roots" /* TypeRoots */, this); }; + /*@internal*/ Project.prototype.onChangedAutomaticTypeDirectiveNames = function () { this.hasChangedAutomaticTypeDirectiveNames = true; this.projectService.delayUpdateProjectGraphAndEnsureProjectStructureForOpenFiles(this); }; + /*@internal*/ Project.prototype.getGlobalCache = function () { return this.getTypeAcquisition().enable ? this.projectService.typingsInstaller.globalTypingsCacheLocation : undefined; }; + /*@internal*/ Project.prototype.writeLog = function (s) { this.projectService.logger.info(s); }; @@ -122673,6 +123801,9 @@ var ts; this.compilerOptions.noEmitForJsFiles = true; } }; + /** + * Get the errors that dont have any file name associated + */ Project.prototype.getGlobalProjectErrors = function () { return server.emptyArray; }; @@ -122686,12 +123817,15 @@ var ts; } return this.languageService; }; + /** @internal */ Project.prototype.getSourceMapper = function () { return this.getLanguageService().getSourceMapper(); }; + /*@internal*/ Project.prototype.getDocumentPositionMapper = function (generatedFileName, sourceFileName) { return this.projectService.getDocumentPositionMapper(this, generatedFileName, sourceFileName); }; + /*@internal*/ Project.prototype.getSourceFileLike = function (fileName) { return this.projectService.getSourceFileLike(fileName, this); }; @@ -122705,13 +123839,18 @@ var ts; } server.updateProjectIfDirty(this); this.builderState = ts.BuilderState.create(this.program, this.projectService.toCanonicalFileName, this.builderState); - return ts.mapDefined(ts.BuilderState.getFilesAffectedBy(this.builderState, this.program, scriptInfo.path, this.cancellationToken, function (data) { return _this.projectService.host.createHash(data); }), function (sourceFile) { return _this.shouldEmitFile(_this.projectService.getScriptInfoForPath(sourceFile.path)) ? sourceFile.fileName : undefined; }); + return ts.mapDefined(ts.BuilderState.getFilesAffectedBy(this.builderState, this.program, scriptInfo.path, this.cancellationToken, function (data) { return _this.projectService.host.createHash(data); }), // TODO: GH#18217 + function (// TODO: GH#18217 + sourceFile) { return _this.shouldEmitFile(_this.projectService.getScriptInfoForPath(sourceFile.path)) ? sourceFile.fileName : undefined; }); }; + /** + * Returns true if emit was conducted + */ Project.prototype.emitFile = function (scriptInfo, writeFile) { if (!this.languageServiceEnabled || !this.shouldEmitFile(scriptInfo)) { return false; } - var _a = this.getLanguageService(false).getEmitOutput(scriptInfo.fileName), emitSkipped = _a.emitSkipped, outputFiles = _a.outputFiles; + var _a = this.getLanguageService(/*ensureSynchronized*/ false).getEmitOutput(scriptInfo.fileName), emitSkipped = _a.emitSkipped, outputFiles = _a.outputFiles; if (!emitSkipped) { for (var _i = 0, outputFiles_1 = outputFiles; _i < outputFiles_1.length; _i++) { var outputFile = outputFiles_1[_i]; @@ -122727,7 +123866,7 @@ var ts; } this.languageServiceEnabled = true; this.lastFileExceededProgramSize = undefined; - this.projectService.onUpdateLanguageServiceStateForProject(this, true); + this.projectService.onUpdateLanguageServiceStateForProject(this, /*languageServiceEnabled*/ true); }; Project.prototype.disableLanguageService = function (lastFileExceededProgramSize) { if (!this.languageServiceEnabled) { @@ -122739,13 +123878,14 @@ var ts; this.lastFileExceededProgramSize = lastFileExceededProgramSize; this.builderState = undefined; this.resolutionCache.closeTypeRootsWatch(); - this.projectService.onUpdateLanguageServiceStateForProject(this, false); + this.projectService.onUpdateLanguageServiceStateForProject(this, /*languageServiceEnabled*/ false); }; Project.prototype.getProjectName = function () { return this.projectName; }; Project.prototype.removeLocalTypingsFromTypeAcquisition = function (newTypeAcquisition) { if (!newTypeAcquisition || !newTypeAcquisition.include) { + // Nothing to filter out, so just return as-is return newTypeAcquisition; } return __assign({}, newTypeAcquisition, { include: this.removeExistingTypings(newTypeAcquisition.include) }); @@ -122772,6 +123912,7 @@ var ts; } return this.program.getSourceFileByPath(path); }; + /* @internal */ Project.prototype.getSourceFileOrConfigFile = function (path) { var options = this.program.getCompilerOptions(); return path === options.configFilePath ? options.configFile : this.getSourceFile(path); @@ -122779,6 +123920,9 @@ var ts; Project.prototype.close = function () { var _this = this; if (this.program) { + // if we have a program - release all files that are enlisted in program but arent root + // The releasing of the roots happens later + // The project could have pending update remaining and hence the info could be in the files but not in program graph for (var _i = 0, _a = this.program.getSourceFiles(); _i < _a.length; _i++) { var f = _a[_i]; this.detachScriptInfoIfNotRoot(f.fileName); @@ -122789,7 +123933,9 @@ var ts; } }); } + // Release external files ts.forEach(this.externalFiles, function (externalFile) { return _this.detachScriptInfoIfNotRoot(externalFile); }); + // Always remove root files from the project for (var _b = 0, _c = this.rootFiles; _b < _c.length; _b++) { var root = _c[_b]; root.detachFromProject(this); @@ -122804,15 +123950,19 @@ var ts; this.resolutionCache = undefined; this.cachedUnresolvedImportsPerFile = undefined; this.directoryStructureHost = undefined; + // Clean up file watchers waiting for missing files if (this.missingFilesMap) { ts.clearMap(this.missingFilesMap, ts.closeFileWatcher); this.missingFilesMap = undefined; } + // signal language service to release source files acquired from document registry this.languageService.dispose(); this.languageService = undefined; }; Project.prototype.detachScriptInfoIfNotRoot = function (uncheckedFilename) { var info = this.projectService.getScriptInfo(uncheckedFilename); + // We might not find the script info in case its not associated with the project any more + // and project graph was not updated (eg delayed update graph in case of files changed/deleted on the disk) if (info && !this.isRoot(info)) { info.detachFromProject(this); } @@ -122823,12 +123973,14 @@ var ts; Project.prototype.hasRoots = function () { return this.rootFiles && this.rootFiles.length > 0; }; + /*@internal*/ Project.prototype.isOrphan = function () { return false; }; Project.prototype.getRootFiles = function () { return this.rootFiles && this.rootFiles.map(function (info) { return info.fileName; }); }; + /*@internal*/ Project.prototype.getRootFilesMap = function () { return this.rootFilesMap; }; @@ -122838,6 +123990,7 @@ var ts; Project.prototype.getScriptInfos = function () { var _this = this; if (!this.languageServiceEnabled) { + // if language service is not enabled - return just root files return this.rootFiles; } return ts.map(this.program.getSourceFiles(), function (sourceFile) { @@ -122854,6 +124007,7 @@ var ts; return []; } if (!this.languageServiceEnabled) { + // if language service is disabled assume that all files in program are root files + default library var rootFiles = this.getRootFiles(); if (this.compilerOptions) { var defaultLibrary = ts.getDefaultLibFilePath(this.compilerOptions); @@ -122922,6 +124076,7 @@ var ts; Project.prototype.isRoot = function (info) { return this.rootFilesMap && this.rootFilesMap.get(info.path) === info; }; + // add a root file to project Project.prototype.addRoot = function (info) { ts.Debug.assert(!this.isRoot(info)); this.rootFiles.push(info); @@ -122929,6 +124084,7 @@ var ts; info.attachToProject(this); this.markAsDirty(); }; + // add a root file that doesnt exist on host Project.prototype.addMissingFileRoot = function (fileName) { var path = this.projectService.toPath(fileName); this.rootFilesMap.set(path, fileName); @@ -122939,6 +124095,7 @@ var ts; this.removeRoot(info); } if (fileExists) { + // If file is present, just remove the resolutions for the file this.resolutionCache.removeResolutionsOfFile(info.path); } else { @@ -122959,9 +124116,14 @@ var ts; this.dirty = true; } }; + /* @internal */ Project.prototype.onFileAddedOrRemoved = function () { this.hasAddedorRemovedFiles = true; }; + /** + * Updates set of files that contribute to this project + * @returns: true if set of files in the project stays the same and false - otherwise. + */ Project.prototype.updateGraph = function () { this.resolutionCache.startRecordingFilesWithChangedResolutions(); var hasNewProgram = this.updateGraphWorker(); @@ -122970,9 +124132,18 @@ var ts; var changedFiles = this.resolutionCache.finishRecordingFilesWithChangedResolutions() || server.emptyArray; for (var _i = 0, changedFiles_1 = changedFiles; _i < changedFiles_1.length; _i++) { var file = changedFiles_1[_i]; + // delete cached information for changed files this.cachedUnresolvedImportsPerFile.delete(file); } + // update builder only if language service is enabled + // otherwise tell it to drop its internal state if (this.languageServiceEnabled) { + // 1. no changes in structure, no changes in unresolved imports - do nothing + // 2. no changes in structure, unresolved imports were changed - collect unresolved imports for all files + // (can reuse cached imports for files that were not changed) + // 3. new files were added/removed, but compilation settings stays the same - collect unresolved imports for all new/modified files + // (can reuse cached imports for files that were not changed) + // 4. compilation settings were changed in the way that might affect module resolution - drop all caches and collect all data from the scratch if (hasNewProgram || changedFiles.length) { this.lastCachedUnresolvedImportsList = getUnresolvedImports(this.program, this.cachedUnresolvedImportsPerFile); } @@ -122986,12 +124157,16 @@ var ts; } return !hasNewProgram; }; + /*@internal*/ Project.prototype.updateTypingFiles = function (typingFiles) { var _this = this; - ts.enumerateInsertsAndDeletes(typingFiles, this.typingFiles, ts.getStringComparer(!this.useCaseSensitiveFileNames()), ts.noop, function (removed) { return _this.detachScriptInfoFromProject(removed); }); + ts.enumerateInsertsAndDeletes(typingFiles, this.typingFiles, ts.getStringComparer(!this.useCaseSensitiveFileNames()), + /*inserted*/ ts.noop, function (removed) { return _this.detachScriptInfoFromProject(removed); }); this.typingFiles = typingFiles; + // Invalidate files with unresolved imports this.resolutionCache.setFilesWithInvalidatedNonRelativeUnresolvedImports(this.cachedUnresolvedImportsPerFile); }; + /* @internal */ Project.prototype.getCurrentProgram = function () { return this.program; }; @@ -123007,11 +124182,14 @@ var ts; var start = ts.timestamp(); this.hasInvalidatedResolution = this.resolutionCache.createHasInvalidatedResolution(); this.resolutionCache.startCachingPerDirectoryResolution(); - this.program = this.languageService.getProgram(); + this.program = this.languageService.getProgram(); // TODO: GH#18217 this.dirty = false; this.resolutionCache.finishCachingPerDirectoryResolution(); ts.Debug.assert(oldProgram === undefined || this.program !== undefined); - var hasNewProgram = this.program && (!oldProgram || (this.program !== oldProgram && !(oldProgram.structureIsReused & 2))); + // bump up the version if + // - oldProgram is not set - this is a first time updateGraph is called + // - newProgram is different from the old program and structure of the old program was not reused. + var hasNewProgram = this.program && (!oldProgram || (this.program !== oldProgram && !(oldProgram.structureIsReused & 2 /* Completely */))); this.hasChangedAutomaticTypeDirectiveNames = false; if (hasNewProgram) { if (oldProgram) { @@ -123019,6 +124197,8 @@ var ts; var f = _a[_i]; var newFile = this.program.getSourceFileByPath(f.resolvedPath); if (!newFile || (f.resolvedPath === f.path && newFile.resolvedPath !== f.path)) { + // new program does not contain this file - detach it from the project + // - remove resolutions only if the new program doesnt contain source file by the path (not resolvedPath since path is used for resolution) this.detachScriptInfoFromProject(f.fileName, !!this.program.getSourceFileByPath(f.path)); } } @@ -123028,14 +124208,22 @@ var ts; } }); } - ts.updateMissingFilePathsWatch(this.program, this.missingFilesMap || (this.missingFilesMap = ts.createMap()), function (missingFilePath) { return _this.addMissingFileWatcher(missingFilePath); }); + // Update the missing file paths watcher + ts.updateMissingFilePathsWatch(this.program, this.missingFilesMap || (this.missingFilesMap = ts.createMap()), + // Watch the missing files + function (missingFilePath) { return _this.addMissingFileWatcher(missingFilePath); }); + // Watch the type locations that would be added to program as part of automatic type resolutions if (this.languageServiceEnabled) { this.resolutionCache.updateTypeRootsWatch(); } } var oldExternalFiles = this.externalFiles || server.emptyArray; this.externalFiles = this.getExternalFiles(); - ts.enumerateInsertsAndDeletes(this.externalFiles, oldExternalFiles, ts.getStringComparer(!this.useCaseSensitiveFileNames()), function (inserted) { + ts.enumerateInsertsAndDeletes(this.externalFiles, oldExternalFiles, ts.getStringComparer(!this.useCaseSensitiveFileNames()), + // Ensure a ScriptInfo is created for new external files. This is performed indirectly + // by the LSHost for files in the program when the program is retrieved above but + // the program doesn't contain external files so this must be done explicitly. + function (inserted) { var scriptInfo = _this.projectService.getOrCreateScriptInfoNotOpenedByClient(inserted, _this.currentDirectory, _this.directoryStructureHost); scriptInfo.attachToProject(_this); }, function (removed) { return _this.detachScriptInfoFromProject(removed); }); @@ -123061,9 +124249,10 @@ var ts; if (eventKind === ts.FileWatcherEventKind.Created && _this.missingFilesMap.has(missingFilePath)) { _this.missingFilesMap.delete(missingFilePath); fileWatcher.close(); + // When a missing file is created, we should update the graph. _this.projectService.delayUpdateProjectGraphAndEnsureProjectStructureForOpenFiles(_this); } - }, ts.PollingInterval.Medium, "Missing file", this); + }, ts.PollingInterval.Medium, "Missing file" /* MissingFile */, this); return fileWatcher; }; Project.prototype.isWatchedMissingFile = function (path) { @@ -123093,6 +124282,7 @@ var ts; } return strBuilder; }; + /*@internal*/ Project.prototype.print = function (counter) { this.writeLog("Project '" + this.projectName + "' (" + ProjectKind[this.projectKind] + ") " + (counter === undefined ? "" : counter)); this.writeLog(this.filesToString(this.projectService.logger.hasLevel(server.LogLevel.verbose))); @@ -123105,6 +124295,7 @@ var ts; this.compilerOptions = compilerOptions; this.setInternalCompilerOptionsForEmittingJsFiles(); if (ts.changesAffectModuleResolution(oldOptions, compilerOptions)) { + // reset cached unresolved imports if changes in compiler options affected module resolution this.cachedUnresolvedImportsPerFile.clear(); this.lastCachedUnresolvedImportsList = undefined; this.resolutionCache.clear(); @@ -123112,7 +124303,9 @@ var ts; this.markAsDirty(); } }; + /* @internal */ Project.prototype.getChangesSinceVersion = function (lastKnownVersion) { + // Update the graph only if initial configured project load is not pending if (!this.isInitialLoadPending()) { server.updateProjectIfDirty(this); } @@ -123126,10 +124319,13 @@ var ts; }; var updatedFileNames = this.updatedFileNames; this.updatedFileNames = undefined; + // check if requested version is the same that we have reported last time if (this.lastReportedFileNames && lastKnownVersion === this.lastReportedVersion) { + // if current structure version is the same - return info without any changes if (this.projectProgramVersion === this.lastReportedVersion && !updatedFileNames) { return { info: info, projectErrors: this.getGlobalProjectErrors() }; } + // compute and return the difference var lastReportedFileNames_1 = this.lastReportedFileNames; var externalFiles = this.getExternalFiles().map(function (f) { return server.toNormalizedPath(f); }); var currentFiles_1 = ts.arrayToSet(this.getFileNames().concat(externalFiles)); @@ -123151,6 +124347,7 @@ var ts; return { info: info, changes: { added: added_1, removed: removed_1, updated: updated }, projectErrors: this.getGlobalProjectErrors() }; } else { + // unknown version - return everything var projectFileNames = this.getFileNames(); var externalFiles = this.getExternalFiles().map(function (f) { return server.toNormalizedPath(f); }); var allFiles = projectFileNames.concat(externalFiles); @@ -123159,6 +124356,7 @@ var ts; return { info: info, files: allFiles, projectErrors: this.getGlobalProjectErrors() }; } }; + // remove a root file from project Project.prototype.removeRoot = function (info) { ts.orderedRemoveItem(this.rootFiles, info); this.rootFilesMap.delete(info.path); @@ -123169,17 +124367,23 @@ var ts; this.projectService.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded"); return; } + // Search our peer node_modules, then any globally-specified probe paths + // ../../.. to walk from X/node_modules/typescript/lib/tsserver.js to X/node_modules/ var searchPaths = [ts.combinePaths(this.projectService.getExecutingFilePath(), "../../..")].concat(this.projectService.pluginProbeLocations); if (this.projectService.globalPlugins) { var _loop_1 = function (globalPluginName) { + // Skip empty names from odd commandline parses if (!globalPluginName) return "continue"; + // Skip already-locally-loaded plugins if (options.plugins && options.plugins.some(function (p) { return p.name === globalPluginName; })) return "continue"; + // Provide global: true so plugins can detect why they can't find their config this_1.projectService.logger.info("Loading global plugin " + globalPluginName); this_1.enablePlugin({ name: globalPluginName, global: true }, searchPaths, pluginConfigOverrides); }; var this_1 = this; + // Enable global plugins with synthetic configuration entries for (var _i = 0, _a = this.projectService.globalPlugins; _i < _a.length; _i++) { var globalPluginName = _a[_i]; _loop_1(globalPluginName); @@ -123198,6 +124402,7 @@ var ts; if (resolvedModule) { var configurationOverride = pluginConfigOverrides && pluginConfigOverrides.get(pluginConfigEntry.name); if (configurationOverride) { + // Preserve the name property since it's immutable var pluginName = pluginConfigEntry.name; pluginConfigEntry = configurationOverride; pluginConfigEntry.name = pluginName; @@ -123238,6 +124443,7 @@ var ts; this.projectService.logger.info("Plugin activation failed: " + e); } }; + /*@internal*/ Project.prototype.onPluginConfigurationChanged = function (pluginName, configuration) { this.plugins.filter(function (plugin) { return plugin.name === pluginName; }).forEach(function (plugin) { if (plugin.module.onConfigurationChanged) { @@ -123245,6 +124451,7 @@ var ts; } }); }; + /** Starts a new check for diagnostics. Call this if some file has updated that would cause diagnostics to be changed. */ Project.prototype.refreshDiagnostics = function () { this.projectService.sendProjectsUpdatedInBackgroundEvent(); }; @@ -123263,6 +124470,7 @@ var ts; return server.emptyArray; var unresolvedImports; file.resolvedModules.forEach(function (resolvedModule, name) { + // pick unresolved non-relative names if ((!resolvedModule || !ts.resolutionExtensionIsTSOrJson(resolvedModule.extension)) && !ts.isExternalModuleNameRelative(name) && !ambientModules.some(function (m) { return m === name; })) { @@ -123272,10 +124480,19 @@ var ts; return unresolvedImports || server.emptyArray; }); } - var InferredProject = (function (_super) { + /** + * If a file is opened and no tsconfig (or jsconfig) is found, + * the file and its imports/references are put into an InferredProject. + */ + var InferredProject = /** @class */ (function (_super) { __extends(InferredProject, _super); + /*@internal*/ function InferredProject(projectService, documentRegistry, compilerOptions, projectRootPath, currentDirectory, pluginConfigOverrides) { - var _this = _super.call(this, InferredProject.newName(), ProjectKind.Inferred, projectService, documentRegistry, undefined, undefined, compilerOptions, false, projectService.host, currentDirectory) || this; + var _this = _super.call(this, InferredProject.newName(), ProjectKind.Inferred, projectService, documentRegistry, + // TODO: GH#18217 + /*files*/ undefined, + /*lastFileExceededProgramSize*/ undefined, compilerOptions, + /*compileOnSaveEnabled*/ false, projectService.host, currentDirectory) || this; _this._isJsInferredProject = false; _this.projectRootPath = projectRootPath && projectService.toCanonicalFileName(projectRootPath); if (!projectRootPath && !projectService.useSingleInferredProject) { @@ -123291,6 +124508,7 @@ var ts; } }; InferredProject.prototype.setCompilerOptions = function (options) { + // Avoid manipulating the given options directly if (!options && !this.getCompilationSettings()) { return; } @@ -123308,7 +124526,7 @@ var ts; ts.Debug.assert(info.isScriptOpen()); this.projectService.startWatchingConfigFilesForInferredProjectRoot(info); if (!this._isJsInferredProject && info.isJavaScript()) { - this.toggleJsInferredProject(true); + this.toggleJsInferredProject(/*isJsInferredProject*/ true); } _super.prototype.addRoot.call(this, info); }; @@ -123317,14 +124535,18 @@ var ts; _super.prototype.removeRoot.call(this, info); if (this._isJsInferredProject && info.isJavaScript()) { if (ts.every(this.getRootScriptInfos(), function (rootInfo) { return !rootInfo.isJavaScript(); })) { - this.toggleJsInferredProject(false); + this.toggleJsInferredProject(/*isJsInferredProject*/ false); } } }; + /*@internal*/ InferredProject.prototype.isOrphan = function () { return !this.hasRoots(); }; InferredProject.prototype.isProjectWithSingleRoot = function () { + // - when useSingleInferredProject is not set and projectRootPath is not set, + // we can guarantee that this will be the only root + // - other wise it has single root if it has single root script info return (!this.projectRootPath && !this.projectService.useSingleInferredProject) || this.getRootScriptInfos().length === 1; }; @@ -123351,17 +124573,34 @@ var ts; return InferredProject; }(Project)); server.InferredProject = InferredProject; - var ConfiguredProject = (function (_super) { + /** + * If a file is opened, the server will look for a tsconfig (or jsconfig) + * and if successfull create a ConfiguredProject for it. + * Otherwise it will create an InferredProject. + */ + var ConfiguredProject = /** @class */ (function (_super) { __extends(ConfiguredProject, _super); + /*@internal*/ function ConfiguredProject(configFileName, projectService, documentRegistry, cachedDirectoryStructureHost) { - var _this = _super.call(this, configFileName, ProjectKind.Configured, projectService, documentRegistry, false, undefined, {}, false, cachedDirectoryStructureHost, ts.getDirectoryPath(configFileName)) || this; + var _this = _super.call(this, configFileName, ProjectKind.Configured, projectService, documentRegistry, + /*hasExplicitListOfFiles*/ false, + /*lastFileExceededProgramSize*/ undefined, + /*compilerOptions*/ {}, + /*compileOnSaveEnabled*/ false, cachedDirectoryStructureHost, ts.getDirectoryPath(configFileName)) || this; + /*@internal*/ _this.canConfigFileJsonReportNoInputFiles = false; + /** Ref count to the project when opened from external project */ _this.externalProjectRefCount = 0; _this.isInitialLoadPending = ts.returnTrue; + /*@internal*/ _this.sendLoadingProjectFinish = false; _this.canonicalConfigFilePath = server.asNormalizedPath(projectService.toCanonicalFileName(configFileName)); return _this; } + /** + * If the project has reload from disk pending, it reloads (and then updates graph as part of that) instead of just updating the graph + * @returns: true if set of files in the project stays the same and false - otherwise. + */ ConfiguredProject.prototype.updateGraph = function () { this.isInitialLoadPending = ts.returnFalse; var reloadLevel = this.pendingReload; @@ -123384,6 +124623,7 @@ var ts; this.projectService.sendProjectTelemetry(this); return result; }; + /*@internal*/ ConfiguredProject.prototype.getCachedDirectoryStructureHost = function () { return this.directoryStructureHost; }; @@ -123396,22 +124636,27 @@ var ts; ConfiguredProject.prototype.updateReferences = function (refs) { this.projectReferences = refs; }; + /*@internal*/ ConfiguredProject.prototype.forEachResolvedProjectReference = function (cb) { var program = this.getCurrentProgram(); return program && program.forEachResolvedProjectReference(cb); }; + /*@internal*/ ConfiguredProject.prototype.enablePluginsWithOptions = function (options, pluginConfigOverrides) { var host = this.projectService.host; if (!host.require) { this.projectService.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded"); return; } + // Search our peer node_modules, then any globally-specified probe paths + // ../../.. to walk from X/node_modules/typescript/lib/tsserver.js to X/node_modules/ var searchPaths = [ts.combinePaths(this.projectService.getExecutingFilePath(), "../../..")].concat(this.projectService.pluginProbeLocations); if (this.projectService.allowLocalPluginLoads) { var local = ts.getDirectoryPath(this.canonicalConfigFilePath); this.projectService.logger.info("Local plugin loading enabled; adding " + local + " to search paths"); searchPaths.unshift(local); } + // Enable tsconfig-specified plugins if (options.plugins) { for (var _i = 0, _a = options.plugins; _i < _a.length; _i++) { var pluginConfigEntry = _a[_i]; @@ -123420,9 +124665,15 @@ var ts; } this.enableGlobalPlugins(options, pluginConfigOverrides); }; + /** + * Get the errors that dont have any file name associated + */ ConfiguredProject.prototype.getGlobalProjectErrors = function () { return ts.filter(this.projectErrors, function (diagnostic) { return !diagnostic.file; }) || server.emptyArray; }; + /** + * Get all the project errors + */ ConfiguredProject.prototype.getAllProjectErrors = function () { return this.projectErrors || server.emptyArray; }; @@ -123435,10 +124686,14 @@ var ts; ConfiguredProject.prototype.getTypeAcquisition = function () { return this.typeAcquisition; }; + /*@internal*/ ConfiguredProject.prototype.watchWildcards = function (wildcardDirectories) { var _this = this; - ts.updateWatchingWildcardDirectories(this.directoriesWatchedForWildcards || (this.directoriesWatchedForWildcards = ts.createMap()), wildcardDirectories, function (directory, flags) { return _this.projectService.watchWildcardDirectory(directory, flags, _this); }); + ts.updateWatchingWildcardDirectories(this.directoriesWatchedForWildcards || (this.directoriesWatchedForWildcards = ts.createMap()), wildcardDirectories, + // Create new directory watcher + function (directory, flags) { return _this.projectService.watchWildcardDirectory(directory, flags, _this); }); }; + /*@internal*/ ConfiguredProject.prototype.stopWatchingWildCards = function () { if (this.directoriesWatchedForWildcards) { ts.clearMap(this.directoriesWatchedForWildcards, ts.closeFileWatcherOf); @@ -123455,42 +124710,61 @@ var ts; this.configFileSpecs = undefined; _super.prototype.close.call(this); }; + /* @internal */ ConfiguredProject.prototype.addExternalProjectReference = function () { this.externalProjectRefCount++; }; + /* @internal */ ConfiguredProject.prototype.deleteExternalProjectReference = function () { this.externalProjectRefCount--; }; + /** Returns true if the project is needed by any of the open script info/external project */ + /* @internal */ ConfiguredProject.prototype.hasOpenRef = function () { var _this = this; if (!!this.externalProjectRefCount) { return true; } + // Closed project doesnt have any reference if (this.isClosed()) { return false; } var configFileExistenceInfo = this.projectService.getConfigFileExistenceInfo(this); if (this.projectService.hasPendingProjectUpdate(this)) { + // If there is pending update for this project, + // we dont know if this project would be needed by any of the open files impacted by this config file + // In that case keep the project alive if there are open files impacted by this project return !!configFileExistenceInfo.openFilesImpactedByConfigFile.size; } + // If there is no pending update for this project, + // We know exact set of open files that get impacted by this configured project as the files in the project + // The project is referenced only if open files impacted by this project are present in this project return ts.forEachEntry(configFileExistenceInfo.openFilesImpactedByConfigFile, function (_value, infoPath) { return _this.containsScriptInfo(_this.projectService.getScriptInfoForPath(infoPath)); }) || false; }; + /*@internal*/ ConfiguredProject.prototype.hasExternalProjectRef = function () { return !!this.externalProjectRefCount; }; ConfiguredProject.prototype.getEffectiveTypeRoots = function () { return ts.getEffectiveTypeRoots(this.getCompilationSettings(), this.directoryStructureHost) || []; }; + /*@internal*/ ConfiguredProject.prototype.updateErrorOnNoInputFiles = function (fileNameResult) { ts.updateErrorForNoInputFiles(fileNameResult, this.getConfigFilePath(), this.configFileSpecs, this.projectErrors, this.canConfigFileJsonReportNoInputFiles); }; return ConfiguredProject; }(Project)); server.ConfiguredProject = ConfiguredProject; - var ExternalProject = (function (_super) { + /** + * Project whose configuration is handled externally, such as in a '.csproj'. + * These are created only if a host explicitly calls `openExternalProject`. + */ + var ExternalProject = /** @class */ (function (_super) { __extends(ExternalProject, _super); + /*@internal*/ function ExternalProject(externalProjectName, projectService, documentRegistry, compilerOptions, lastFileExceededProgramSize, compileOnSaveEnabled, projectFilePath) { - var _this = _super.call(this, externalProjectName, ProjectKind.External, projectService, documentRegistry, true, lastFileExceededProgramSize, compilerOptions, compileOnSaveEnabled, projectService.host, ts.getDirectoryPath(projectFilePath || ts.normalizeSlashes(externalProjectName))) || this; + var _this = _super.call(this, externalProjectName, ProjectKind.External, projectService, documentRegistry, + /*hasExplicitListOfFiles*/ true, lastFileExceededProgramSize, compilerOptions, compileOnSaveEnabled, projectService.host, ts.getDirectoryPath(projectFilePath || ts.normalizeSlashes(externalProjectName))) || this; _this.externalProjectName = externalProjectName; _this.compileOnSaveEnabled = compileOnSaveEnabled; _this.excludedFiles = []; @@ -123524,7 +124798,9 @@ var ts; var server; (function (server) { server.maxProgramSizeForNonTsFiles = 20 * 1024 * 1024; + /*@internal*/ server.maxFileSize = 4 * 1024 * 1024; + // tslint:disable variable-name server.ProjectsUpdatedInBackgroundEvent = "projectsUpdatedInBackground"; server.ProjectLoadingStartEvent = "projectLoadingStart"; server.ProjectLoadingFinishEvent = "projectLoadingFinish"; @@ -123539,6 +124815,7 @@ var ts; var option = commandLineOptions_1[_i]; if (typeof option.type === "object") { var optionMap = option.type; + // verify that map contains only numbers optionMap.forEach(function (value) { ts.Debug.assert(typeof value === "number"); }); @@ -123553,25 +124830,47 @@ var ts; block: ts.IndentStyle.Block, smart: ts.IndentStyle.Smart }); + /** + * How to understand this block: + * * The 'match' property is a regexp that matches a filename. + * * If 'match' is successful, then: + * * All files from 'exclude' are removed from the project. See below. + * * All 'types' are included in ATA + * * What the heck is 'exclude' ? + * * An array of an array of strings and numbers + * * Each array is: + * * An array of strings and numbers + * * The strings are literals + * * The numbers refer to capture group indices from the 'match' regexp + * * Remember that '1' is the first group + * * These are concatenated together to form a new regexp + * * Filenames matching these regexps are excluded from the project + * This default value is tested in tsserverProjectSystem.ts; add tests there + * if you are changing this so that you can be sure your regexp works! + */ var defaultTypeSafeList = { "jquery": { + // jquery files can have names like "jquery-1.10.2.min.js" (or "jquery.intellisense.js") match: /jquery(-(\.?\d+)+)?(\.intellisense)?(\.min)?\.js$/i, types: ["jquery"] }, "WinJS": { + // e.g. c:/temp/UWApp1/lib/winjs-4.0.1/js/base.js match: /^(.*\/winjs-[.\d]+)\/js\/base\.js$/i, exclude: [["^", 1, "/.*"]], - types: ["winjs"] + types: ["winjs"] // And fetch the @types package for WinJS }, "Kendo": { + // e.g. /Kendo3/wwwroot/lib/kendo/kendo.all.min.js match: /^(.*\/kendo(-ui)?)\/kendo\.all(\.min)?\.js$/i, exclude: [["^", 1, "/.*"]], types: ["kendo-ui"] }, "Office Nuget": { + // e.g. /scripts/Office/1/excel-15.debug.js match: /^(.*\/office\/1)\/excel-\d+\.debug\.js$/i, exclude: [["^", 1, "/.*"]], - types: ["office"] + types: ["office"] // @types package to fetch instead }, "References": { match: /^(.*\/_references\.js)$/i, @@ -123603,18 +124902,19 @@ var ts; function convertScriptKindName(scriptKindName) { switch (scriptKindName) { case "JS": - return 1; + return 1 /* JS */; case "JSX": - return 2; + return 2 /* JSX */; case "TS": - return 3; + return 3 /* TS */; case "TSX": - return 4; + return 4 /* TSX */; default: - return 0; + return 0 /* Unknown */; } } server.convertScriptKindName = convertScriptKindName; + /*@internal*/ function convertUserPreferences(preferences) { var lazyConfiguredProjectsFromExternalProject = preferences.lazyConfiguredProjectsFromExternalProject, userPreferences = __rest(preferences, ["lazyConfiguredProjectsFromExternalProject"]); return userPreferences; @@ -123636,7 +124936,7 @@ var ts; }); } } - return result; + return result; // TODO: GH#18217 }, hasMixedContent: function (fileName, extraFileExtensions) { return ts.some(extraFileExtensions, function (ext) { return ext.isMixedContent && ts.fileExtensionIs(fileName, ext.extension); }); }, }; @@ -123672,6 +124972,7 @@ var ts; function isScriptInfoWatchedFromNodeModules(info) { return !info.isScriptOpen() && info.mTime !== undefined; } + /*@internal*/ function updateProjectIfDirty(project) { return project.dirty && project.updateGraph(); } @@ -123681,26 +124982,66 @@ var ts; project.projectOptions = true; } } - var ProjectService = (function () { + var ProjectService = /** @class */ (function () { function ProjectService(opts) { var _this = this; + /** + * Container of all known scripts + */ + /*@internal*/ this.filenameToScriptInfo = ts.createMap(); this.scriptInfoInNodeModulesWatchers = ts.createMap(); + /** + * Contains all the deleted script info's version information so that + * it does not reset when creating script info again + * (and could have potentially collided with version where contents mismatch) + */ this.filenameToScriptInfoVersion = ts.createMap(); + // Set of all '.js' files ever opened. this.allJsFilesForOpenFileTelemetry = ts.createMap(); + /** + * maps external project file name to list of config files that were the part of this project + */ this.externalProjectToConfiguredProjectMap = ts.createMap(); + /** + * external projects (configuration and list of root files is not controlled by tsserver) + */ this.externalProjects = []; + /** + * projects built from openFileRoots + */ this.inferredProjects = []; + /** + * projects specified by a tsconfig.json file + */ this.configuredProjects = ts.createMap(); + /** + * Open files: with value being project root path, and key being Path of the file that is open + */ this.openFiles = ts.createMap(); + /** + * Map of open files that are opened without complete path but have projectRoot as current directory + */ this.openFilesWithNonRootedDiskPath = ts.createMap(); this.compilerOptionsForInferredProjectsPerProjectRoot = ts.createMap(); + /** + * Project size for configured or external projects + */ this.projectToSizeMap = ts.createMap(); + /** + * This is a map of config file paths existance that doesnt need query to disk + * - The entry can be present because there is inferred project that needs to watch addition of config file to directory + * In this case the exists could be true/false based on config file is present or not + * - Or it is present if we have configured project open with config file at that location + * In this case the exists property is always true + */ this.configFileExistenceInfoCache = ts.createMap(); this.safelist = defaultTypeSafeList; this.legacySafelist = ts.createMap(); this.pendingProjectUpdates = ts.createMap(); + /* @internal */ this.pendingEnsureProjectForOpenFiles = false; + /** Tracks projects that we have already sent telemetry for. */ this.seenProjects = ts.createMap(); this.host = opts.host; this.logger = opts.logger; @@ -123749,26 +125090,33 @@ var ts; ProjectService.prototype.toPath = function (fileName) { return ts.toPath(fileName, this.currentDirectory, this.toCanonicalFileName); }; + /*@internal*/ ProjectService.prototype.getExecutingFilePath = function () { return this.getNormalizedAbsolutePath(this.host.getExecutingFilePath()); }; + /*@internal*/ ProjectService.prototype.getNormalizedAbsolutePath = function (fileName) { return ts.getNormalizedAbsolutePath(fileName, this.host.getCurrentDirectory()); }; + /*@internal*/ ProjectService.prototype.setDocument = function (key, path, sourceFile) { var info = ts.Debug.assertDefined(this.getScriptInfoForPath(path)); info.cacheSourceFile = { key: key, sourceFile: sourceFile }; }; + /*@internal*/ ProjectService.prototype.getDocument = function (key, path) { var info = this.getScriptInfoForPath(path); return info && info.cacheSourceFile && info.cacheSourceFile.key === key ? info.cacheSourceFile.sourceFile : undefined; }; + /* @internal */ ProjectService.prototype.ensureInferredProjectsUpToDate_TestOnly = function () { this.ensureProjectStructuresUptoDate(); }; + /* @internal */ ProjectService.prototype.getCompilerOptionsForInferredProjects = function () { return this.compilerOptionsForInferredProjects; }; + /* @internal */ ProjectService.prototype.onUpdateLanguageServiceStateForProject = function (project, languageServiceEnabled) { if (!this.eventHandler) { return; @@ -123781,16 +125129,18 @@ var ts; }; ProjectService.prototype.loadTypesMap = function () { try { - var fileContent = this.host.readFile(this.typesMapLocation); + var fileContent = this.host.readFile(this.typesMapLocation); // TODO: GH#18217 if (fileContent === undefined) { this.logger.info("Provided types map file \"" + this.typesMapLocation + "\" doesn't exist"); return; } var raw = JSON.parse(fileContent); + // Parse the regexps for (var _i = 0, _a = Object.keys(raw.typesMap); _i < _a.length; _i++) { var k = _a[_i]; raw.typesMap[k].match = new RegExp(raw.typesMap[k].match, "i"); } + // raw is now fixed and ready this.safelist = raw.typesMap; for (var key in raw.simpleMap) { if (raw.simpleMap.hasOwnProperty(key)) { @@ -123811,10 +125161,12 @@ var ts; } switch (response.kind) { case server.ActionSet: + // Update the typing files and update the project project.updateTypingFiles(this.typingsCache.updateTypingsForProject(response.projectName, response.compilerOptions, response.typeAcquisition, response.unresolvedImports, response.typings)); break; case server.ActionInvalidate: - this.typingsCache.enqueueInstallTypingsForProject(project, project.lastCachedUnresolvedImportsList, true); + // Do not clear resolution cache, there was changes detected in typings, so enque typing request and let it get us correct results + this.typingsCache.enqueueInstallTypingsForProject(project, project.lastCachedUnresolvedImportsList, /*forceRefresh*/ true); return; } this.delayUpdateProjectGraphAndEnsureProjectStructureForOpenFiles(project); @@ -123822,13 +125174,15 @@ var ts; ProjectService.prototype.delayEnsureProjectForOpenFiles = function () { var _this = this; this.pendingEnsureProjectForOpenFiles = true; - this.throttledOperations.schedule("*ensureProjectForOpenFiles*", 250, function () { + this.throttledOperations.schedule("*ensureProjectForOpenFiles*", /*delay*/ 250, function () { if (_this.pendingProjectUpdates.size !== 0) { _this.delayEnsureProjectForOpenFiles(); } else { if (_this.pendingEnsureProjectForOpenFiles) { _this.ensureProjectForOpenFiles(); + // Send the event to notify that there were background project updates + // send current list of open files _this.sendProjectsUpdatedInBackgroundEvent(); } } @@ -123839,15 +125193,17 @@ var ts; project.markAsDirty(); var projectName = project.getProjectName(); this.pendingProjectUpdates.set(projectName, project); - this.throttledOperations.schedule(projectName, 250, function () { + this.throttledOperations.schedule(projectName, /*delay*/ 250, function () { if (_this.pendingProjectUpdates.delete(projectName)) { updateProjectIfDirty(project); } }); }; + /*@internal*/ ProjectService.prototype.hasPendingProjectUpdate = function (project) { return this.pendingProjectUpdates.has(project.getProjectName()); }; + /* @internal */ ProjectService.prototype.sendProjectsUpdatedInBackgroundEvent = function () { var _this = this; if (!this.eventHandler) { @@ -123861,6 +125217,7 @@ var ts; }; this.eventHandler(event); }; + /* @internal */ ProjectService.prototype.sendLargeFileReferencedEvent = function (file, fileSize) { if (!this.eventHandler) { return; @@ -123871,6 +125228,7 @@ var ts; }; this.eventHandler(event); }; + /* @internal */ ProjectService.prototype.sendProjectLoadingStartEvent = function (project, reason) { if (!this.eventHandler) { return; @@ -123882,6 +125240,7 @@ var ts; }; this.eventHandler(event); }; + /* @internal */ ProjectService.prototype.sendProjectLoadingFinishEvent = function (project) { if (!this.eventHandler || !project.sendLoadingProjectFinish) { return; @@ -123893,6 +125252,7 @@ var ts; }; this.eventHandler(event); }; + /* @internal */ ProjectService.prototype.delayUpdateProjectGraphAndEnsureProjectStructureForOpenFiles = function (project) { this.delayUpdateProjectGraph(project); this.delayEnsureProjectForOpenFiles(); @@ -123909,6 +125269,8 @@ var ts; ProjectService.prototype.setCompilerOptionsForInferredProjects = function (projectCompilerOptions, projectRootPath) { ts.Debug.assert(projectRootPath === undefined || this.useInferredProjectPerProjectRoot, "Setting compiler options per project root path is only supported when useInferredProjectPerProjectRoot is enabled"); var compilerOptions = convertCompilerOptions(projectCompilerOptions); + // always set 'allowNonTsExtensions' for inferred projects since user cannot configure it from the outside + // previously we did not expose a way for user to change these settings and this option was enabled by default compilerOptions.allowNonTsExtensions = true; var canonicalProjectRootPath = projectRootPath && this.toCanonicalFileName(projectRootPath); if (canonicalProjectRootPath) { @@ -123919,6 +125281,14 @@ var ts; } for (var _i = 0, _a = this.inferredProjects; _i < _a.length; _i++) { var project = _a[_i]; + // Only update compiler options in the following cases: + // - Inferred projects without a projectRootPath, if the new options do not apply to + // a workspace root + // - Inferred projects with a projectRootPath, if the new options do not apply to a + // workspace root and there is no more specific set of options for that project's + // root path + // - Inferred projects with a projectRootPath, if the new options apply to that + // project root path. if (canonicalProjectRootPath ? project.projectRootPath === canonicalProjectRootPath : !project.projectRootPath || !this.compilerOptionsForInferredProjectsPerProjectRoot.has(project.projectRootPath)) { @@ -123939,11 +125309,13 @@ var ts; } return this.findExternalProjectByProjectName(projectName) || this.findConfiguredProjectByProjectName(server.toNormalizedPath(projectName)); }; + /* @internal */ ProjectService.prototype.forEachProject = function (cb) { this.externalProjects.forEach(cb); this.configuredProjects.forEach(cb); this.inferredProjects.forEach(cb); }; + /* @internal */ ProjectService.prototype.forEachEnabledProject = function (cb) { this.forEachProject(function (project) { if (!project.isOrphan() && project.languageServiceEnabled) { @@ -123954,10 +125326,12 @@ var ts; ProjectService.prototype.getDefaultProjectForFile = function (fileName, ensureProject) { return ensureProject ? this.ensureDefaultProjectForFile(fileName) : this.tryGetDefaultProjectForFile(fileName); }; + /* @internal */ ProjectService.prototype.tryGetDefaultProjectForFile = function (fileName) { var scriptInfo = this.getScriptInfoForNormalizedPath(fileName); return scriptInfo && !scriptInfo.isOrphan() ? scriptInfo.getDefaultProject() : undefined; }; + /* @internal */ ProjectService.prototype.ensureDefaultProjectForFile = function (fileName) { return this.tryGetDefaultProjectForFile(fileName) || this.doEnsureDefaultProjectForFile(fileName); }; @@ -123970,6 +125344,13 @@ var ts; this.ensureProjectStructuresUptoDate(); return this.getScriptInfo(uncheckedFileName); }; + /** + * Ensures the project structures are upto date + * This means, + * - we go through all the projects and update them if they are dirty + * - if updates reflect some change in structure or there was pending request to ensure projects for open files + * ensure that each open script info has project + */ ProjectService.prototype.ensureProjectStructuresUptoDate = function () { var hasChanges = this.pendingEnsureProjectForOpenFiles; this.pendingProjectUpdates.clear(); @@ -124007,9 +125388,12 @@ var ts; info.containingProjects.forEach(function (project) { return project.resolutionCache.removeResolutionsFromProjectReferenceRedirects(info.path); }); } if (eventKind === ts.FileWatcherEventKind.Deleted) { + // File was deleted this.handleDeletedFile(info); } else if (!info.isScriptOpen()) { + // file has been changed which might affect the set of referenced files in projects that include + // this file and set of inferred projects info.delayReloadNonMixedContentFile(); this.delayUpdateProjectGraphs(info.containingProjects); this.handleSourceMapProjects(info); @@ -124017,6 +125401,7 @@ var ts; } }; ProjectService.prototype.handleSourceMapProjects = function (info) { + // Change in d.ts, update source projects as well if (info.sourceMapFilePath) { if (ts.isString(info.sourceMapFilePath)) { var sourceMapFileInfo = this.getScriptInfoForPath(info.sourceMapFilePath); @@ -124026,6 +125411,7 @@ var ts; this.delayUpdateSourceInfoProjects(info.sourceMapFilePath.sourceInfos); } } + // Change in mapInfo, update declarationProjects and source projects this.delayUpdateSourceInfoProjects(info.sourceInfos); if (info.declarationInfoPath) { this.delayUpdateProjectsOfScriptInfoPath(info.declarationInfoPath); @@ -124047,11 +125433,14 @@ var ts; this.stopWatchingScriptInfo(info); if (!info.isScriptOpen()) { this.deleteScriptInfo(info); + // capture list of projects since detachAllProjects will wipe out original list var containingProjects = info.containingProjects.slice(); info.detachAllProjects(); + // update projects to make sure that set of referenced files is correct this.delayUpdateProjectGraphs(containingProjects); this.handleSourceMapProjects(info); info.closeSourceMapFileWatcher(); + // need to recalculate source map from declaration file if (info.declarationInfoPath) { var declarationInfo = this.getScriptInfoForPath(info.declarationInfoPath); if (declarationInfo) { @@ -124060,6 +125449,10 @@ var ts; } } }; + /** + * This is to watch whenever files are added or removed to the wildcard directories + */ + /*@internal*/ ProjectService.prototype.watchWildcardDirectory = function (directory, flags, project) { var _this = this; return this.watchFactory.watchDirectory(this.host, directory, function (fileOrDirectory) { @@ -124068,50 +125461,73 @@ var ts; if (ts.isPathInNodeModulesStartingWithDot(fileOrDirectoryPath)) return; var configFilename = project.getConfigFilePath(); + // If the the added or created file or directory is not supported file name, ignore the file + // But when watched directory is added/removed, we need to reload the file list if (fileOrDirectoryPath !== directory && ts.hasExtension(fileOrDirectoryPath) && !ts.isSupportedSourceFileName(fileOrDirectory, project.getCompilationSettings(), _this.hostConfiguration.extraFileExtensions)) { _this.logger.info("Project: " + configFilename + " Detected file add/remove of non supported extension: " + fileOrDirectory); return; } + // Reload is pending, do the reload if (project.pendingReload !== ts.ConfigFileProgramReloadLevel.Full) { project.pendingReload = ts.ConfigFileProgramReloadLevel.Partial; _this.delayUpdateProjectGraphAndEnsureProjectStructureForOpenFiles(project); } - }, flags, "Wild card directory", project); + }, flags, "Wild card directory" /* WildcardDirectory */, project); }; + /** Gets the config file existence info for the configured project */ + /*@internal*/ ProjectService.prototype.getConfigFileExistenceInfo = function (project) { return this.configFileExistenceInfoCache.get(project.canonicalConfigFilePath); }; ProjectService.prototype.onConfigChangedForConfiguredProject = function (project, eventKind) { var configFileExistenceInfo = this.getConfigFileExistenceInfo(project); if (eventKind === ts.FileWatcherEventKind.Deleted) { + // Update the cached status + // We arent updating or removing the cached config file presence info as that will be taken care of by + // setConfigFilePresenceByClosedConfigFile when the project is closed (depending on tracking open files) configFileExistenceInfo.exists = false; this.removeProject(project); - this.logConfigFileWatchUpdate(project.getConfigFilePath(), project.canonicalConfigFilePath, configFileExistenceInfo, "Reloading configured projects for files"); - this.delayReloadConfiguredProjectForFiles(configFileExistenceInfo, false); + // Reload the configured projects for the open files in the map as they are affected by this config file + // Since the configured project was deleted, we want to reload projects for all the open files including files + // that are not root of the inferred project + this.logConfigFileWatchUpdate(project.getConfigFilePath(), project.canonicalConfigFilePath, configFileExistenceInfo, "Reloading configured projects for files" /* ReloadingFiles */); + this.delayReloadConfiguredProjectForFiles(configFileExistenceInfo, /*ignoreIfNotInferredProjectRoot*/ false); } else { - this.logConfigFileWatchUpdate(project.getConfigFilePath(), project.canonicalConfigFilePath, configFileExistenceInfo, "Reloading configured projects for only inferred root files"); + this.logConfigFileWatchUpdate(project.getConfigFilePath(), project.canonicalConfigFilePath, configFileExistenceInfo, "Reloading configured projects for only inferred root files" /* ReloadingInferredRootFiles */); project.pendingReload = ts.ConfigFileProgramReloadLevel.Full; project.pendingReloadReason = "Change in config file detected"; this.delayUpdateProjectGraph(project); - this.delayReloadConfiguredProjectForFiles(configFileExistenceInfo, true); + // As we scheduled the update on configured project graph, + // we would need to schedule the project reload for only the root of inferred projects + this.delayReloadConfiguredProjectForFiles(configFileExistenceInfo, /*ignoreIfNotInferredProjectRoot*/ true); } }; + /** + * This is the callback function for the config file add/remove/change at any location + * that matters to open script info but doesnt have configured project open + * for the config file + */ ProjectService.prototype.onConfigFileChangeForOpenScriptInfo = function (configFileName, eventKind) { + // This callback is called only if we dont have config file project for this config file var canonicalConfigPath = server.normalizedPathToPath(configFileName, this.currentDirectory, this.toCanonicalFileName); var configFileExistenceInfo = this.configFileExistenceInfoCache.get(canonicalConfigPath); configFileExistenceInfo.exists = (eventKind !== ts.FileWatcherEventKind.Deleted); - this.logConfigFileWatchUpdate(configFileName, canonicalConfigPath, configFileExistenceInfo, "Reloading configured projects for files"); - this.delayReloadConfiguredProjectForFiles(configFileExistenceInfo, false); + this.logConfigFileWatchUpdate(configFileName, canonicalConfigPath, configFileExistenceInfo, "Reloading configured projects for files" /* ReloadingFiles */); + // Because there is no configured project open for the config file, the tracking open files map + // will only have open files that need the re-detection of the project and hence + // reload projects for all the tracking open files in the map + this.delayReloadConfiguredProjectForFiles(configFileExistenceInfo, /*ignoreIfNotInferredProjectRoot*/ false); }; ProjectService.prototype.removeProject = function (project) { var _this = this; this.logger.info("`remove Project::"); project.print(); project.close(); - if (ts.Debug.shouldAssert(1)) { + if (ts.Debug.shouldAssert(1 /* Normal */)) { this.filenameToScriptInfo.forEach(function (info) { return ts.Debug.assert(!info.isAttached(project), "Found script Info still attached to project", function () { return project.projectName + ": ScriptInfos still attached: " + JSON.stringify(ts.mapDefined(ts.arrayFrom(_this.filenameToScriptInfo.values()), function (info) { return info.isAttached(project) ? info : undefined; })); }); }); } + // Remove the project from pending project updates this.pendingProjectUpdates.delete(project.getProjectName()); switch (project.projectKind) { case server.ProjectKind.External: @@ -124128,6 +125544,7 @@ var ts; break; } }; + /*@internal*/ ProjectService.prototype.assignOrphanScriptInfoToInferredProject = function (info, projectRootPath) { ts.Debug.assert(info.isOrphan()); var project = this.getOrCreateInferredProjectForProjectRootPathIfEnabled(info, projectRootPath) || @@ -124135,6 +125552,7 @@ var ts; this.getOrCreateSingleInferredWithoutProjectRoot(info.isDynamic ? this.currentDirectory : ts.getDirectoryPath(info.path)); project.addRoot(info); if (info.containingProjects[0] !== project) { + // Ensure this is first project, we could be in this scenario because info could be part of orphan project info.detachFromProject(project); info.containingProjects.unshift(project); } @@ -124144,12 +125562,21 @@ var ts; if (inferredProject === project || inferredProject.isOrphan()) { return "continue"; } + // Remove the inferred project if the root of it is now part of newly created inferred project + // e.g through references + // Which means if any root of inferred project is part of more than 1 project can be removed + // This logic is same as iterating over all open files and calling + // this.removeRootOfInferredProjectIfNowPartOfOtherProject(f); + // Since this is also called from refreshInferredProject and closeOpen file + // to update inferred projects of the open file, this iteration might be faster + // instead of scanning all open files var roots = inferredProject.getRootScriptInfos(); ts.Debug.assert(roots.length === 1 || !!inferredProject.projectRootPath); if (roots.length === 1 && ts.forEach(roots[0].containingProjects, function (p) { return p !== roots[0].containingProjects[0] && !p.isOrphan(); })) { - inferredProject.removeFile(roots[0], true, true); + inferredProject.removeFile(roots[0], /*fileExists*/ true, /*detachFromProject*/ true); } }; + // Note that we need to create a copy of the array since the list of project can change for (var _i = 0, _a = this.inferredProjects; _i < _a.length; _i++) { var inferredProject = _a[_i]; _loop_2(inferredProject); @@ -124157,8 +125584,15 @@ var ts; } return project; }; + /** + * Remove this file from the set of open, non-configured files. + * @param info The file that has been closed or newly configured + */ ProjectService.prototype.closeOpenFile = function (info) { var _this = this; + // Closing file should trigger re-reading the file content from disk. This is + // because the user may chose to discard the buffer content before saving + // to the disk, and the server's version of the file can be out of sync. var fileExists = this.host.fileExists(info.fileName); info.close(fileExists); this.stopWatchingConfigFilesForClosedScriptInfo(info); @@ -124166,6 +125600,7 @@ var ts; if (this.openFilesWithNonRootedDiskPath.get(canonicalFileName) === info) { this.openFilesWithNonRootedDiskPath.delete(canonicalFileName); } + // collect all projects that should be removed var ensureProjectsForOpenFiles = false; for (var _i = 0, _a = info.containingProjects; _i < _a.length; _i++) { var p = _a[_i]; @@ -124173,26 +125608,41 @@ var ts; if (info.hasMixedContent) { info.registerFileUpdate(); } + // Do not remove the project so that we can reuse this project + // if it would need to be re-created with next file open } else if (p.projectKind === server.ProjectKind.Inferred && p.isRoot(info)) { + // If this was the last open root file of inferred project if (p.isProjectWithSingleRoot()) { ensureProjectsForOpenFiles = true; } - p.removeFile(info, fileExists, true); + p.removeFile(info, fileExists, /*detachFromProject*/ true); + // Do not remove the project even if this was last root of the inferred project + // so that we can reuse this project, if it would need to be re-created with next file open } if (!p.languageServiceEnabled) { + // if project language service is disabled then we create a program only for open files. + // this means that project should be marked as dirty to force rebuilding of the program + // on the next request p.markAsDirty(); } } this.openFiles.delete(info.path); if (ensureProjectsForOpenFiles) { + // collect orphaned files and assign them to inferred project just like we treat open of a file this.openFiles.forEach(function (projectRootPath, path) { var info = _this.getScriptInfoForPath(path); + // collect all orphaned script infos from open files if (info.isOrphan()) { _this.assignOrphanScriptInfoToInferredProject(info, projectRootPath); } }); } + // Cleanup script infos that arent part of any project (eg. those could be closed script infos not referenced by any project) + // is postponed to next file open so that if file from same project is opened, + // we wont end up creating same script infos + // If the current info is being just closed - add the watcher file to track changes + // But if file was deleted, handle that part if (fileExists) { this.watchClosedScriptInfo(info); } @@ -124205,18 +125655,28 @@ var ts; this.filenameToScriptInfoVersion.set(info.path, info.getVersion()); var realpath = info.getRealpathIfDifferent(); if (realpath) { - this.realpathToScriptInfos.remove(realpath, info); + this.realpathToScriptInfos.remove(realpath, info); // TODO: GH#18217 } }; ProjectService.prototype.configFileExists = function (configFileName, canonicalConfigFilePath, info) { var configFileExistenceInfo = this.configFileExistenceInfoCache.get(canonicalConfigFilePath); if (configFileExistenceInfo) { + // By default the info would get impacted by presence of config file since its in the detection path + // Only adding the info as a root to inferred project will need the existence to be watched by file watcher if (isOpenScriptInfo(info) && !configFileExistenceInfo.openFilesImpactedByConfigFile.has(info.path)) { configFileExistenceInfo.openFilesImpactedByConfigFile.set(info.path, false); - this.logConfigFileWatchUpdate(configFileName, canonicalConfigFilePath, configFileExistenceInfo, "File added to open files impacted by this config file"); + this.logConfigFileWatchUpdate(configFileName, canonicalConfigFilePath, configFileExistenceInfo, "File added to open files impacted by this config file" /* OpenFilesImpactedByConfigFileAdd */); } return configFileExistenceInfo.exists; } + // Theoretically we should be adding watch for the directory here itself. + // In practice there will be very few scenarios where the config file gets added + // somewhere inside the another config file directory. + // And technically we could handle that case in configFile's directory watcher in some cases + // But given that its a rare scenario it seems like too much overhead. (we werent watching those directories earlier either) + // So what we are now watching is: configFile if the configured project corresponding to it is open + // Or the whole chain of config files for the roots of the inferred projects + // Cache the host value of file exists and add the info to map of open files impacted by this config file var exists = this.host.fileExists(configFileName); var openFilesImpactedByConfigFile = ts.createMap(); if (isOpenScriptInfo(info)) { @@ -124224,27 +125684,34 @@ var ts; } configFileExistenceInfo = { exists: exists, openFilesImpactedByConfigFile: openFilesImpactedByConfigFile }; this.configFileExistenceInfoCache.set(canonicalConfigFilePath, configFileExistenceInfo); - this.logConfigFileWatchUpdate(configFileName, canonicalConfigFilePath, configFileExistenceInfo, "File added to open files impacted by this config file"); + this.logConfigFileWatchUpdate(configFileName, canonicalConfigFilePath, configFileExistenceInfo, "File added to open files impacted by this config file" /* OpenFilesImpactedByConfigFileAdd */); return exists; }; ProjectService.prototype.setConfigFileExistenceByNewConfiguredProject = function (project) { var configFileExistenceInfo = this.getConfigFileExistenceInfo(project); if (configFileExistenceInfo) { + // The existance might not be set if the file watcher is not invoked by the time config project is created by external project configFileExistenceInfo.exists = true; + // close existing watcher if (configFileExistenceInfo.configFileWatcherForRootOfInferredProject) { var configFileName = project.getConfigFilePath(); configFileExistenceInfo.configFileWatcherForRootOfInferredProject.close(); configFileExistenceInfo.configFileWatcherForRootOfInferredProject = undefined; - this.logConfigFileWatchUpdate(configFileName, project.canonicalConfigFilePath, configFileExistenceInfo, "Updated the callback"); + this.logConfigFileWatchUpdate(configFileName, project.canonicalConfigFilePath, configFileExistenceInfo, "Updated the callback" /* UpdatedCallback */); } } else { + // We could be in this scenario if project is the configured project tracked by external project + // Since that route doesnt check if the config file is present or not this.configFileExistenceInfoCache.set(project.canonicalConfigFilePath, { exists: true, openFilesImpactedByConfigFile: ts.createMap() }); } }; + /** + * Returns true if the configFileExistenceInfo is needed/impacted by open files that are root of inferred project + */ ProjectService.prototype.configFileExistenceImpactsRootOfInferredProject = function (configFileExistenceInfo) { return ts.forEachEntry(configFileExistenceInfo.openFilesImpactedByConfigFile, function (isRootOfInferredProject) { return isRootOfInferredProject; }); }; @@ -124253,12 +125720,16 @@ var ts; ts.Debug.assert(!!configFileExistenceInfo); if (configFileExistenceInfo.openFilesImpactedByConfigFile.size) { var configFileName = closedProject.getConfigFilePath(); + // If there are open files that are impacted by this config file existence + // but none of them are root of inferred project, the config file watcher will be + // created when any of the script infos are added as root of inferred project if (this.configFileExistenceImpactsRootOfInferredProject(configFileExistenceInfo)) { ts.Debug.assert(!configFileExistenceInfo.configFileWatcherForRootOfInferredProject); this.createConfigFileWatcherOfConfigFileExistence(configFileName, closedProject.canonicalConfigFilePath, configFileExistenceInfo); } } else { + // There is not a single file open thats tracking the status of this config file. Remove from cache this.configFileExistenceInfoCache.delete(closedProject.canonicalConfigFilePath); } }; @@ -124275,25 +125746,36 @@ var ts; }); var watches = []; if (configFileExistenceInfo.configFileWatcherForRootOfInferredProject) { - watches.push("Config file for the inferred project root"); + watches.push("Config file for the inferred project root" /* ConfigFileForInferredRoot */); } if (this.configuredProjects.has(canonicalConfigFilePath)) { - watches.push("Config file"); + watches.push("Config file" /* ConfigFile */); } this.logger.info("ConfigFilePresence:: Current Watches: " + watches + ":: File: " + configFileName + " Currently impacted open files: RootsOfInferredProjects: " + inferredRoots + " OtherOpenFiles: " + otherFiles + " Status: " + status); }; + /** + * Create the watcher for the configFileExistenceInfo + */ ProjectService.prototype.createConfigFileWatcherOfConfigFileExistence = function (configFileName, canonicalConfigFilePath, configFileExistenceInfo) { var _this = this; - configFileExistenceInfo.configFileWatcherForRootOfInferredProject = this.watchFactory.watchFile(this.host, configFileName, function (_filename, eventKind) { return _this.onConfigFileChangeForOpenScriptInfo(configFileName, eventKind); }, ts.PollingInterval.High, "Config file for the inferred project root"); - this.logConfigFileWatchUpdate(configFileName, canonicalConfigFilePath, configFileExistenceInfo, "Updated the callback"); + configFileExistenceInfo.configFileWatcherForRootOfInferredProject = this.watchFactory.watchFile(this.host, configFileName, function (_filename, eventKind) { return _this.onConfigFileChangeForOpenScriptInfo(configFileName, eventKind); }, ts.PollingInterval.High, "Config file for the inferred project root" /* ConfigFileForInferredRoot */); + this.logConfigFileWatchUpdate(configFileName, canonicalConfigFilePath, configFileExistenceInfo, "Updated the callback" /* UpdatedCallback */); }; + /** + * Close the config file watcher in the cached ConfigFileExistenceInfo + * if there arent any open files that are root of inferred project + */ ProjectService.prototype.closeConfigFileWatcherOfConfigFileExistenceInfo = function (configFileExistenceInfo) { + // Close the config file watcher if there are no more open files that are root of inferred project if (configFileExistenceInfo.configFileWatcherForRootOfInferredProject && !this.configFileExistenceImpactsRootOfInferredProject(configFileExistenceInfo)) { configFileExistenceInfo.configFileWatcherForRootOfInferredProject.close(); configFileExistenceInfo.configFileWatcherForRootOfInferredProject = undefined; } }; + /** + * This is called on file close, so that we stop watching the config file for this script info + */ ProjectService.prototype.stopWatchingConfigFilesForClosedScriptInfo = function (info) { var _this = this; ts.Debug.assert(!info.isScriptOpen()); @@ -124301,11 +125783,18 @@ var ts; var configFileExistenceInfo = _this.configFileExistenceInfoCache.get(canonicalConfigFilePath); if (configFileExistenceInfo) { var infoIsRootOfInferredProject = configFileExistenceInfo.openFilesImpactedByConfigFile.get(info.path); + // Delete the info from map, since this file is no more open configFileExistenceInfo.openFilesImpactedByConfigFile.delete(info.path); - _this.logConfigFileWatchUpdate(configFileName, canonicalConfigFilePath, configFileExistenceInfo, "File removed from open files impacted by this config file"); + _this.logConfigFileWatchUpdate(configFileName, canonicalConfigFilePath, configFileExistenceInfo, "File removed from open files impacted by this config file" /* OpenFilesImpactedByConfigFileRemove */); + // If the script info was not root of inferred project, + // there wont be config file watch open because of this script info if (infoIsRootOfInferredProject) { + // But if it is a root, it could be the last script info that is root of inferred project + // and hence we would need to close the config file watcher _this.closeConfigFileWatcherOfConfigFileExistenceInfo(configFileExistenceInfo); } + // If there are no open files that are impacted by configFileExistenceInfo after closing this script info + // there is no configured project present, remove the cached existence info if (!configFileExistenceInfo.openFilesImpactedByConfigFile.size && !_this.getConfiguredProjectByCanonicalConfigFilePath(canonicalConfigFilePath)) { ts.Debug.assert(!configFileExistenceInfo.configFileWatcherForRootOfInferredProject); @@ -124314,38 +125803,59 @@ var ts; } }); }; + /** + * This is called by inferred project whenever script info is added as a root + */ + /* @internal */ ProjectService.prototype.startWatchingConfigFilesForInferredProjectRoot = function (info) { var _this = this; ts.Debug.assert(info.isScriptOpen()); this.forEachConfigFileLocation(info, function (configFileName, canonicalConfigFilePath) { var configFileExistenceInfo = _this.configFileExistenceInfoCache.get(canonicalConfigFilePath); if (!configFileExistenceInfo) { + // Create the cache configFileExistenceInfo = { exists: _this.host.fileExists(configFileName), openFilesImpactedByConfigFile: ts.createMap() }; _this.configFileExistenceInfoCache.set(canonicalConfigFilePath, configFileExistenceInfo); } + // Set this file as the root of inferred project configFileExistenceInfo.openFilesImpactedByConfigFile.set(info.path, true); - _this.logConfigFileWatchUpdate(configFileName, canonicalConfigFilePath, configFileExistenceInfo, "Open file was set as Inferred root"); + _this.logConfigFileWatchUpdate(configFileName, canonicalConfigFilePath, configFileExistenceInfo, "Open file was set as Inferred root" /* RootOfInferredProjectTrue */); + // If there is no configured project for this config file, add the file watcher if (!configFileExistenceInfo.configFileWatcherForRootOfInferredProject && !_this.getConfiguredProjectByCanonicalConfigFilePath(canonicalConfigFilePath)) { _this.createConfigFileWatcherOfConfigFileExistence(configFileName, canonicalConfigFilePath, configFileExistenceInfo); } }); }; + /** + * This is called by inferred project whenever root script info is removed from it + */ + /* @internal */ ProjectService.prototype.stopWatchingConfigFilesForInferredProjectRoot = function (info) { var _this = this; this.forEachConfigFileLocation(info, function (configFileName, canonicalConfigFilePath) { var configFileExistenceInfo = _this.configFileExistenceInfoCache.get(canonicalConfigFilePath); if (configFileExistenceInfo && configFileExistenceInfo.openFilesImpactedByConfigFile.has(info.path)) { ts.Debug.assert(info.isScriptOpen()); + // Info is not root of inferred project any more configFileExistenceInfo.openFilesImpactedByConfigFile.set(info.path, false); - _this.logConfigFileWatchUpdate(configFileName, canonicalConfigFilePath, configFileExistenceInfo, "Open file was set as not inferred root"); + _this.logConfigFileWatchUpdate(configFileName, canonicalConfigFilePath, configFileExistenceInfo, "Open file was set as not inferred root" /* RootOfInferredProjectFalse */); + // Close the config file watcher _this.closeConfigFileWatcherOfConfigFileExistenceInfo(configFileExistenceInfo); } }); }; + /** + * This function tries to search for a tsconfig.json for the given file. + * This is different from the method the compiler uses because + * the compiler can assume it will always start searching in the + * current directory (the directory in which tsc was invoked). + * The server must start searching from the directory containing + * the newly opened file. + */ ProjectService.prototype.forEachConfigFileLocation = function (info, action) { var _this = this; if (this.syntaxOnly) { @@ -124355,6 +125865,7 @@ var ts; var projectRootPath = this.openFiles.get(info.path); var searchPath = server.asNormalizedPath(ts.getDirectoryPath(info.fileName)); var isSearchPathInProjectRoot = function () { return ts.containsPath(projectRootPath, searchPath, _this.currentDirectory, !_this.host.useCaseSensitiveFileNames); }; + // If projectRootPath doesn't contain info.path, then do normal search for config file var anySearchPathOk = !projectRootPath || !isSearchPathInProjectRoot(); do { var canonicalSearchPath = server.normalizedPathToPath(searchPath, this.currentDirectory, this.toCanonicalFileName); @@ -124376,6 +125887,16 @@ var ts; } while (anySearchPathOk || isSearchPathInProjectRoot()); return undefined; }; + /** + * This function tries to search for a tsconfig.json for the given file. + * This is different from the method the compiler uses because + * the compiler can assume it will always start searching in the + * current directory (the directory in which tsc was invoked). + * The server must start searching from the directory containing + * the newly opened file. + * If script info is passed in, it is asserted to be open script info + * otherwise just file name + */ ProjectService.prototype.getConfigFileNameForFile = function (info) { var _this = this; if (isOpenScriptInfo(info)) @@ -124413,6 +125934,7 @@ var ts; this.logger.endGroup(); }; ProjectService.prototype.findConfiguredProjectByProjectName = function (configFileName) { + // make sure that casing of config file name is consistent var canonicalConfigFilePath = server.asNormalizedPath(this.toCanonicalFileName(configFileName)); return this.getConfiguredProjectByCanonicalConfigFilePath(canonicalConfigFilePath); }; @@ -124422,6 +125944,7 @@ var ts; ProjectService.prototype.findExternalProjectByProjectName = function (projectFileName) { return findProjectByName(projectFileName, this.externalProjects); }; + /** Get a filename if the language service exceeds the maximum allowed program size; otherwise returns undefined. */ ProjectService.prototype.getFilenameForExceededTotalSizeLimitForNonTsFiles = function (name, options, fileNames, propertyReader) { if (options && options.disableSizeLimit || !this.host.getFileSize) { return; @@ -124439,6 +125962,7 @@ var ts; totalNonTsFileSize += this.host.getFileSize(fileName); if (totalNonTsFileSize > server.maxProgramSizeForNonTsFiles || totalNonTsFileSize > availableSpace) { this.logger.info(getExceedLimitMessage({ propertyReader: propertyReader, hasTSFileExtension: ts.hasTSFileExtension, host: this.host }, totalNonTsFileSize)); + // Keep the size as zero since it's disabled return fileName; } } @@ -124452,19 +125976,21 @@ var ts; var propertyReader = _a.propertyReader, hasTSFileExtension = _a.hasTSFileExtension, host = _a.host; return fileNames.map(function (f) { return propertyReader.getFileName(f); }) .filter(function (name) { return hasTSFileExtension(name); }) - .map(function (name) { return ({ name: name, size: host.getFileSize(name) }); }) + .map(function (name) { return ({ name: name, size: host.getFileSize(name) }); }) // TODO: GH#18217 .sort(function (a, b) { return b.size - a.size; }) .slice(0, 5); } }; ProjectService.prototype.createExternalProject = function (projectFileName, files, options, typeAcquisition, excludedFiles) { var compilerOptions = convertCompilerOptions(options); - var project = new server.ExternalProject(projectFileName, this, this.documentRegistry, compilerOptions, this.getFilenameForExceededTotalSizeLimitForNonTsFiles(projectFileName, compilerOptions, files, externalFilePropertyReader), options.compileOnSave === undefined ? true : options.compileOnSave); + var project = new server.ExternalProject(projectFileName, this, this.documentRegistry, compilerOptions, + /*lastFileExceededProgramSize*/ this.getFilenameForExceededTotalSizeLimitForNonTsFiles(projectFileName, compilerOptions, files, externalFilePropertyReader), options.compileOnSave === undefined ? true : options.compileOnSave); project.excludedFiles = excludedFiles; this.addFilesToNonInferredProject(project, files, externalFilePropertyReader, typeAcquisition); this.externalProjects.push(project); return project; }; + /*@internal*/ ProjectService.prototype.sendProjectTelemetry = function (project) { if (this.seenProjects.has(project.projectName)) { setProjectOptionsUsed(project); @@ -124479,7 +126005,7 @@ var ts; setProjectOptionsUsed(project); var data = { projectId: this.host.createSHA256Hash(project.projectName), - fileStats: server.countEachFileTypes(project.getScriptInfos(), true), + fileStats: server.countEachFileTypes(project.getScriptInfos(), /*includeSizes*/ true), compilerOptions: ts.convertCompilerOptionsForTelemetry(project.getCompilationSettings()), typeAcquisition: convertTypeAcquisition(project.getTypeAcquisition()), extends: projectOptions && projectOptions.configHasExtendsProperty, @@ -124514,45 +126040,57 @@ var ts; }; ProjectService.prototype.createConfiguredProject = function (configFileName) { var _this = this; - var cachedDirectoryStructureHost = ts.createCachedDirectoryStructureHost(this.host, this.host.getCurrentDirectory(), this.host.useCaseSensitiveFileNames); + var cachedDirectoryStructureHost = ts.createCachedDirectoryStructureHost(this.host, this.host.getCurrentDirectory(), this.host.useCaseSensitiveFileNames); // TODO: GH#18217 this.logger.info("Opened configuration file " + configFileName); var project = new server.ConfiguredProject(configFileName, this, this.documentRegistry, cachedDirectoryStructureHost); - project.configFileWatcher = this.watchFactory.watchFile(this.host, configFileName, function (_fileName, eventKind) { return _this.onConfigChangedForConfiguredProject(project, eventKind); }, ts.PollingInterval.High, "Config file", project); + // TODO: We probably should also watch the configFiles that are extended + project.configFileWatcher = this.watchFactory.watchFile(this.host, configFileName, function (_fileName, eventKind) { return _this.onConfigChangedForConfiguredProject(project, eventKind); }, ts.PollingInterval.High, "Config file" /* ConfigFile */, project); this.configuredProjects.set(project.canonicalConfigFilePath, project); this.setConfigFileExistenceByNewConfiguredProject(project); return project; }; + /* @internal */ ProjectService.prototype.createConfiguredProjectWithDelayLoad = function (configFileName, reason) { var project = this.createConfiguredProject(configFileName); project.pendingReload = ts.ConfigFileProgramReloadLevel.Full; project.pendingReloadReason = reason; return project; }; + /* @internal */ ProjectService.prototype.createAndLoadConfiguredProject = function (configFileName, reason) { var project = this.createConfiguredProject(configFileName); this.loadConfiguredProject(project, reason); return project; }; + /* @internal */ ProjectService.prototype.createLoadAndUpdateConfiguredProject = function (configFileName, reason) { var project = this.createAndLoadConfiguredProject(configFileName, reason); project.updateGraph(); return project; }; + /** + * Read the config file of the project, and update the project root file names. + */ + /* @internal */ ProjectService.prototype.loadConfiguredProject = function (project, reason) { this.sendProjectLoadingStartEvent(project, reason); + // Read updated contents from disk var configFilename = ts.normalizePath(project.getConfigFilePath()); - var configFileContent = this.host.readFile(configFilename); + var configFileContent = this.host.readFile(configFilename); // TODO: GH#18217 var result = ts.parseJsonText(configFilename, configFileContent); if (!result.endOfFileToken) { - result.endOfFileToken = { kind: 1 }; + result.endOfFileToken = { kind: 1 /* EndOfFileToken */ }; } var configFileErrors = result.parseDiagnostics; - var parsedCommandLine = ts.parseJsonSourceFileConfigFileContent(result, project.getCachedDirectoryStructureHost(), ts.getDirectoryPath(configFilename), {}, configFilename, [], this.hostConfiguration.extraFileExtensions); + var parsedCommandLine = ts.parseJsonSourceFileConfigFileContent(result, project.getCachedDirectoryStructureHost(), ts.getDirectoryPath(configFilename), + /*existingOptions*/ {}, configFilename, + /*resolutionStack*/ [], this.hostConfiguration.extraFileExtensions); if (parsedCommandLine.errors.length) { configFileErrors.push.apply(configFileErrors, parsedCommandLine.errors); } ts.Debug.assert(!!parsedCommandLine.fileNames); var compilerOptions = parsedCommandLine.options; + // Update the project if (!project.projectOptions) { project.projectOptions = { configHasExtendsProperty: parsedCommandLine.raw.extends !== undefined, @@ -124572,11 +126110,11 @@ var ts; } else { project.enableLanguageService(); - project.watchWildcards(ts.createMapFromTemplate(parsedCommandLine.wildcardDirectories)); + project.watchWildcards(ts.createMapFromTemplate(parsedCommandLine.wildcardDirectories)); // TODO: GH#18217 } project.enablePluginsWithOptions(compilerOptions, this.currentPluginConfigOverrides); var filesToAdd = parsedCommandLine.fileNames.concat(project.getExternalFiles()); - this.updateRootAndOptionsOfNonInferredProject(project, filesToAdd, fileNamePropertyReader, compilerOptions, parsedCommandLine.typeAcquisition, parsedCommandLine.compileOnSave); + this.updateRootAndOptionsOfNonInferredProject(project, filesToAdd, fileNamePropertyReader, compilerOptions, parsedCommandLine.typeAcquisition, parsedCommandLine.compileOnSave); // TODO: GH#18217 }; ProjectService.prototype.updateNonInferredProjectFiles = function (project, files, propertyReader) { var projectRootFilesMap = project.getRootFilesMap(); @@ -124588,11 +126126,12 @@ var ts; var isDynamic = server.isDynamicFileName(normalizedPath); var scriptInfo = void 0; var path = void 0; + // Use the project's fileExists so that it can use caching instead of reaching to disk for the query if (!isDynamic && !project.fileExists(newRootFile)) { path = server.normalizedPathToPath(normalizedPath, this.currentDirectory, this.toCanonicalFileName); var existingValue = projectRootFilesMap.get(path); if (server.isScriptInfo(existingValue)) { - project.removeFile(existingValue, false, true); + project.removeFile(existingValue, /*fileExists*/ false, /*detachFromProject*/ true); } projectRootFilesMap.set(path, normalizedPath); scriptInfo = normalizedPath; @@ -124600,22 +126139,27 @@ var ts; else { var scriptKind = propertyReader.getScriptKind(f, this.hostConfiguration.extraFileExtensions); var hasMixedContent = propertyReader.hasMixedContent(f, this.hostConfiguration.extraFileExtensions); - scriptInfo = this.getOrCreateScriptInfoNotOpenedByClientForNormalizedPath(normalizedPath, project.currentDirectory, scriptKind, hasMixedContent, project.directoryStructureHost); + scriptInfo = this.getOrCreateScriptInfoNotOpenedByClientForNormalizedPath(normalizedPath, project.currentDirectory, scriptKind, hasMixedContent, project.directoryStructureHost); // TODO: GH#18217 path = scriptInfo.path; + // If this script info is not already a root add it if (!project.isRoot(scriptInfo)) { project.addRoot(scriptInfo); if (scriptInfo.isScriptOpen()) { + // if file is already root in some inferred project + // - remove the file from that project and delete the project if necessary this.removeRootOfInferredProjectIfNowPartOfOtherProject(scriptInfo); } } } newRootScriptInfoMap.set(path, scriptInfo); } + // project's root file map size is always going to be same or larger than new roots map + // as we have already all the new files to the project if (projectRootFilesMap.size > newRootScriptInfoMap.size) { projectRootFilesMap.forEach(function (value, path) { if (!newRootScriptInfoMap.has(path)) { if (server.isScriptInfo(value)) { - project.removeFile(value, project.fileExists(path), true); + project.removeFile(value, project.fileExists(path), /*detachFromProject*/ true); } else { projectRootFilesMap.delete(path); @@ -124623,28 +126167,43 @@ var ts; } }); } + // Just to ensure that even if root files dont change, the changes to the non root file are picked up, + // mark the project as dirty unconditionally project.markAsDirty(); }; ProjectService.prototype.updateRootAndOptionsOfNonInferredProject = function (project, newUncheckedFiles, propertyReader, newOptions, newTypeAcquisition, compileOnSave) { project.setCompilerOptions(newOptions); + // VS only set the CompileOnSaveEnabled option in the request if the option was changed recently + // therefore if it is undefined, it should not be updated. if (compileOnSave !== undefined) { project.compileOnSaveEnabled = compileOnSave; } this.addFilesToNonInferredProject(project, newUncheckedFiles, propertyReader, newTypeAcquisition); }; + /** + * Reload the file names from config file specs and update the project graph + */ + /*@internal*/ ProjectService.prototype.reloadFileNamesOfConfiguredProject = function (project) { - var configFileSpecs = project.configFileSpecs; + var configFileSpecs = project.configFileSpecs; // TODO: GH#18217 var configFileName = project.getConfigFilePath(); var fileNamesResult = ts.getFileNamesFromConfigSpecs(configFileSpecs, ts.getDirectoryPath(configFileName), project.getCompilationSettings(), project.getCachedDirectoryStructureHost(), this.hostConfiguration.extraFileExtensions); project.updateErrorOnNoInputFiles(fileNamesResult); this.updateNonInferredProjectFiles(project, fileNamesResult.fileNames.concat(project.getExternalFiles()), fileNamePropertyReader); return project.updateGraph(); }; + /** + * Read the config file of the project again by clearing the cache and update the project graph + */ + /* @internal */ ProjectService.prototype.reloadConfiguredProject = function (project, reason) { + // At this point, there is no reason to not have configFile in the host var host = project.getCachedDirectoryStructureHost(); + // Clear the cache since we are reloading the project from disk host.clearCache(); var configFileName = project.getConfigFilePath(); this.logger.info("Reloading configured project " + configFileName); + // Load project from the disk this.loadConfiguredProject(project, reason); project.updateGraph(); this.sendConfigFileDiagEvent(project, configFileName); @@ -124666,21 +126225,28 @@ var ts; } if (projectRootPath) { var canonicalProjectRootPath = this.toCanonicalFileName(projectRootPath); + // if we have an explicit project root path, find (or create) the matching inferred project. for (var _i = 0, _a = this.inferredProjects; _i < _a.length; _i++) { var project = _a[_i]; if (project.projectRootPath === canonicalProjectRootPath) { return project; } } - return this.createInferredProject(projectRootPath, false, projectRootPath); + return this.createInferredProject(projectRootPath, /*isSingleInferredProject*/ false, projectRootPath); } + // we don't have an explicit root path, so we should try to find an inferred project + // that more closely contains the file. var bestMatch; for (var _b = 0, _c = this.inferredProjects; _b < _c.length; _b++) { var project = _c[_b]; + // ignore single inferred projects (handled elsewhere) if (!project.projectRootPath) continue; + // ignore inferred projects that don't contain the root's path if (!ts.containsPath(project.projectRootPath, info.path, this.host.getCurrentDirectory(), !this.host.useCaseSensitiveFileNames)) continue; + // ignore inferred projects that are higher up in the project root. + // TODO(rbuckton): Should we add the file as a root to these as well? if (bestMatch && bestMatch.projectRootPath.length > project.projectRootPath.length) continue; bestMatch = project; @@ -124691,14 +126257,24 @@ var ts; if (!this.useSingleInferredProject) { return undefined; } + // If `useInferredProjectPerProjectRoot` is not enabled, then there will only be one + // inferred project for all files. If `useInferredProjectPerProjectRoot` is enabled + // then we want to put all files that are not opened with a `projectRootPath` into + // the same inferred project. + // + // To avoid the cost of searching through the array and to optimize for the case where + // `useInferredProjectPerProjectRoot` is not enabled, we will always put the inferred + // project for non-rooted files at the front of the array. if (this.inferredProjects.length > 0 && this.inferredProjects[0].projectRootPath === undefined) { return this.inferredProjects[0]; } - return this.createInferredProject(undefined, true); + // Single inferred project does not have a project root and hence no current directory + return this.createInferredProject(/*currentDirectory*/ undefined, /*isSingleInferredProject*/ true); }; ProjectService.prototype.getOrCreateSingleInferredWithoutProjectRoot = function (currentDirectory) { ts.Debug.assert(!this.useSingleInferredProject); var expectedCurrentDirectory = this.toCanonicalFileName(this.getNormalizedAbsolutePath(currentDirectory || "")); + // Reuse the project with same current directory but no roots for (var _i = 0, _a = this.inferredProjects; _i < _a.length; _i++) { var inferredProject = _a[_i]; if (!inferredProject.projectRootPath && @@ -124710,7 +126286,7 @@ var ts; return this.createInferredProject(currentDirectory); }; ProjectService.prototype.createInferredProject = function (currentDirectory, isSingleInferredProject, projectRootPath) { - var compilerOptions = projectRootPath && this.compilerOptionsForInferredProjectsPerProjectRoot.get(projectRootPath) || this.compilerOptionsForInferredProjects; + var compilerOptions = projectRootPath && this.compilerOptionsForInferredProjectsPerProjectRoot.get(projectRootPath) || this.compilerOptionsForInferredProjects; // TODO: GH#18217 var project = new server.InferredProject(this, this.documentRegistry, compilerOptions, projectRootPath, currentDirectory, this.currentPluginConfigOverrides); if (isSingleInferredProject) { this.inferredProjects.unshift(project); @@ -124720,12 +126296,15 @@ var ts; } return project; }; + /*@internal*/ ProjectService.prototype.getOrCreateScriptInfoNotOpenedByClient = function (uncheckedFileName, currentDirectory, hostToQueryFileExistsOn) { - return this.getOrCreateScriptInfoNotOpenedByClientForNormalizedPath(server.toNormalizedPath(uncheckedFileName), currentDirectory, undefined, undefined, hostToQueryFileExistsOn); + return this.getOrCreateScriptInfoNotOpenedByClientForNormalizedPath(server.toNormalizedPath(uncheckedFileName), currentDirectory, /*scriptKind*/ undefined, + /*hasMixedContent*/ undefined, hostToQueryFileExistsOn); }; ProjectService.prototype.getScriptInfo = function (uncheckedFileName) { return this.getScriptInfoForNormalizedPath(server.toNormalizedPath(uncheckedFileName)); }; + /* @internal */ ProjectService.prototype.getScriptInfoOrConfig = function (uncheckedFileName) { var path = server.toNormalizedPath(uncheckedFileName); var info = this.getScriptInfoForNormalizedPath(path); @@ -124734,6 +126313,7 @@ var ts; var configProject = this.configuredProjects.get(this.toPath(uncheckedFileName)); return configProject && configProject.getCompilerOptions().configFile; }; + /* @internal */ ProjectService.prototype.logErrorForScriptInfoNotFound = function (fileName) { var names = ts.arrayFrom(this.filenameToScriptInfo.entries()).map(function (_a) { var path = _a[0], scriptInfo = _a[1]; @@ -124741,6 +126321,11 @@ var ts; }); this.logger.msg("Could not find file " + JSON.stringify(fileName) + ".\nAll files are: " + JSON.stringify(names), server.Msg.Err); }; + /** + * Returns the projects that contain script info through SymLink + * Note that this does not return projects in info.containingProjects + */ + /*@internal*/ ProjectService.prototype.getSymlinkedProjects = function (info) { var projects; if (this.realpathToScriptInfos) { @@ -124754,6 +126339,7 @@ var ts; function combineProjects(toAddInfo) { if (toAddInfo !== info) { var _loop_3 = function (project) { + // Add the projects only if they can use symLink targets and not already in the list if (project.languageServiceEnabled && !project.isOrphan() && !project.getCompilerOptions().preserveSymlinks && @@ -124777,12 +126363,14 @@ var ts; ProjectService.prototype.watchClosedScriptInfo = function (info) { var _this = this; ts.Debug.assert(!info.fileWatcher); + // do not watch files with mixed content - server doesn't know how to interpret it + // do not watch files in the global cache location if (!info.isDynamicOrHasMixedContent() && (!this.globalCacheLocationDirectoryPath || !ts.startsWith(info.path, this.globalCacheLocationDirectoryPath))) { var indexOfNodeModules = info.path.indexOf("/node_modules/"); if (!this.host.getModifiedTime || indexOfNodeModules === -1) { - info.fileWatcher = this.watchFactory.watchFilePath(this.host, info.fileName, function (fileName, eventKind, path) { return _this.onSourceFileChanged(fileName, eventKind, path); }, ts.PollingInterval.Medium, info.path, "Closed Script info"); + info.fileWatcher = this.watchFactory.watchFilePath(this.host, info.fileName, function (fileName, eventKind, path) { return _this.onSourceFileChanged(fileName, eventKind, path); }, ts.PollingInterval.Medium, info.path, "Closed Script info" /* ClosedScriptInfo */); } else { info.mTime = this.getModifiedTime(info); @@ -124792,6 +126380,7 @@ var ts; }; ProjectService.prototype.watchClosedScriptInfoInNodeModules = function (dir) { var _this = this; + // Watch only directory var existing = this.scriptInfoInNodeModulesWatchers.get(dir); if (existing) { existing.refCount++; @@ -124802,6 +126391,7 @@ var ts; var fileOrDirectoryPath = _this.toPath(fileOrDirectory); if (ts.isPathInNodeModulesStartingWithDot(fileOrDirectoryPath)) return; + // Has extension ts.Debug.assert(result.refCount > 0); if (watchDir === fileOrDirectoryPath) { _this.refreshScriptInfosInDirectory(watchDir); @@ -124813,11 +126403,12 @@ var ts; _this.refreshScriptInfo(info); } } + // Folder else if (!ts.hasExtension(fileOrDirectoryPath)) { _this.refreshScriptInfosInDirectory(fileOrDirectoryPath); } } - }, 1, "node_modules for closed script infos in them"); + }, 1 /* Recursive */, "node_modules for closed script infos in them" /* NodeModulesForClosedScriptInfo */); var result = { close: function () { if (result.refCount === 1) { @@ -124861,16 +126452,20 @@ var ts; }; ProjectService.prototype.getOrCreateScriptInfoNotOpenedByClientForNormalizedPath = function (fileName, currentDirectory, scriptKind, hasMixedContent, hostToQueryFileExistsOn) { if (ts.isRootedDiskPath(fileName) || server.isDynamicFileName(fileName)) { - return this.getOrCreateScriptInfoWorker(fileName, currentDirectory, false, undefined, scriptKind, hasMixedContent, hostToQueryFileExistsOn); + return this.getOrCreateScriptInfoWorker(fileName, currentDirectory, /*openedByClient*/ false, /*fileContent*/ undefined, scriptKind, hasMixedContent, hostToQueryFileExistsOn); } + // This is non rooted path with different current directory than project service current directory + // Only paths recognized are open relative file paths var info = this.openFilesWithNonRootedDiskPath.get(this.toCanonicalFileName(fileName)); if (info) { return info; } + // This means triple slash references wont be resolved in dynamic and unsaved files + // which is intentional since we dont know what it means to be relative to non disk files return undefined; }; ProjectService.prototype.getOrCreateScriptInfoOpenedByClientForNormalizedPath = function (fileName, currentDirectory, fileContent, scriptKind, hasMixedContent) { - return this.getOrCreateScriptInfoWorker(fileName, currentDirectory, true, fileContent, scriptKind, hasMixedContent); + return this.getOrCreateScriptInfoWorker(fileName, currentDirectory, /*openedByClient*/ true, fileContent, scriptKind, hasMixedContent); }; ProjectService.prototype.getOrCreateScriptInfoForNormalizedPath = function (fileName, openedByClient, fileContent, scriptKind, hasMixedContent, hostToQueryFileExistsOn) { return this.getOrCreateScriptInfoWorker(fileName, this.currentDirectory, openedByClient, fileContent, scriptKind, hasMixedContent, hostToQueryFileExistsOn); @@ -124885,20 +126480,24 @@ var ts; ts.Debug.assert(ts.isRootedDiskPath(fileName) || isDynamic || openedByClient, "", function () { return JSON.stringify({ fileName: fileName, currentDirectory: currentDirectory, hostCurrentDirectory: _this.currentDirectory, openKeys: ts.arrayFrom(_this.openFilesWithNonRootedDiskPath.keys()) }) + "\nScript info with non-dynamic relative file name can only be open script info or in context of host currentDirectory"; }); ts.Debug.assert(!ts.isRootedDiskPath(fileName) || this.currentDirectory === currentDirectory || !this.openFilesWithNonRootedDiskPath.has(this.toCanonicalFileName(fileName)), "", function () { return JSON.stringify({ fileName: fileName, currentDirectory: currentDirectory, hostCurrentDirectory: _this.currentDirectory, openKeys: ts.arrayFrom(_this.openFilesWithNonRootedDiskPath.keys()) }) + "\nOpen script files with non rooted disk path opened with current directory context cannot have same canonical names"; }); ts.Debug.assert(!isDynamic || this.currentDirectory === currentDirectory, "", function () { return JSON.stringify({ fileName: fileName, currentDirectory: currentDirectory, hostCurrentDirectory: _this.currentDirectory, openKeys: ts.arrayFrom(_this.openFilesWithNonRootedDiskPath.keys()) }) + "\nDynamic files must always have current directory context since containing external project name will always match the script info name."; }); + // If the file is not opened by client and the file doesnot exist on the disk, return if (!openedByClient && !isDynamic && !(hostToQueryFileExistsOn || this.host).fileExists(fileName)) { return; } - info = new server.ScriptInfo(this.host, fileName, scriptKind, !!hasMixedContent, path, this.filenameToScriptInfoVersion.get(path)); + info = new server.ScriptInfo(this.host, fileName, scriptKind, !!hasMixedContent, path, this.filenameToScriptInfoVersion.get(path)); // TODO: GH#18217 this.filenameToScriptInfo.set(info.path, info); this.filenameToScriptInfoVersion.delete(info.path); if (!openedByClient) { this.watchClosedScriptInfo(info); } else if (!ts.isRootedDiskPath(fileName) && !isDynamic) { + // File that is opened by user but isn't rooted disk path this.openFilesWithNonRootedDiskPath.set(this.toCanonicalFileName(fileName), info); } } if (openedByClient && !info.isScriptOpen()) { + // Opening closed script info + // either it was created just now, or was part of projects but was closed this.stopWatchingScriptInfo(info); info.open(fileContent); if (hasMixedContent) { @@ -124910,6 +126509,9 @@ var ts; } return info; }; + /** + * This gets the script info for the normalized path. If the path is not rooted disk path then the open script info with project root context is preferred + */ ProjectService.prototype.getScriptInfoForNormalizedPath = function (fileName) { return !ts.isRootedDiskPath(fileName) && this.openFilesWithNonRootedDiskPath.get(this.toCanonicalFileName(fileName)) || this.getScriptInfoForPath(server.normalizedPathToPath(fileName, this.currentDirectory, this.toCanonicalFileName)); @@ -124917,13 +126519,17 @@ var ts; ProjectService.prototype.getScriptInfoForPath = function (fileName) { return this.filenameToScriptInfo.get(fileName); }; + /*@internal*/ ProjectService.prototype.getDocumentPositionMapper = function (project, generatedFileName, sourceFileName) { var _this = this; + // Since declaration info and map file watches arent updating project's directory structure host (which can cache file structure) use host var declarationInfo = this.getOrCreateScriptInfoNotOpenedByClient(generatedFileName, project.currentDirectory, this.host); if (!declarationInfo) return undefined; - declarationInfo.getSnapshot(); + // Try to get from cache + declarationInfo.getSnapshot(); // Ensure synchronized if (ts.isString(declarationInfo.sourceMapFilePath)) { + // Ensure mapper is synchronized var sourceMapFileInfo_1 = this.getScriptInfoForPath(declarationInfo.sourceMapFilePath); if (sourceMapFileInfo_1) { sourceMapFileInfo_1.getSnapshot(); @@ -124939,8 +126545,10 @@ var ts; return undefined; } else if (declarationInfo.sourceMapFilePath !== undefined) { + // Doesnt have sourceMap return undefined; } + // Create the mapper var sourceMapFileInfo; var mapFileNameFromDeclarationInfo; var readMapFile = function (mapFileName, mapFileNameFromDts) { @@ -124957,7 +126565,7 @@ var ts; }; var projectName = project.projectName; var documentPositionMapper = ts.getDocumentPositionMapper({ getCanonicalFileName: this.toCanonicalFileName, log: function (s) { return _this.logger.info(s); }, getSourceFileLike: function (f) { return _this.getSourceFileLike(f, projectName, declarationInfo); } }, declarationInfo.fileName, declarationInfo.getLineInfo(), readMapFile); - readMapFile = undefined; + readMapFile = undefined; // Remove ref to project if (sourceMapFileInfo) { declarationInfo.sourceMapFilePath = sourceMapFileInfo.path; sourceMapFileInfo.declarationInfoPath = declarationInfo.path; @@ -124979,6 +126587,7 @@ var ts; }; ProjectService.prototype.addSourceInfoToSourceMap = function (sourceFileName, project, sourceInfos) { if (sourceFileName) { + // Attach as source var sourceInfo = this.getOrCreateScriptInfoNotOpenedByClient(sourceFileName, project.currentDirectory, project.directoryStructureHost); (sourceInfos || (sourceInfos = ts.createMap())).set(sourceInfo.path, true); } @@ -124989,13 +126598,15 @@ var ts; var fileWatcher = this.watchFactory.watchFile(this.host, mapFileName, function () { var declarationInfo = _this.getScriptInfoForPath(declarationInfoPath); if (declarationInfo && declarationInfo.sourceMapFilePath && !ts.isString(declarationInfo.sourceMapFilePath)) { + // Update declaration and source projects _this.delayUpdateProjectGraphs(declarationInfo.containingProjects); _this.delayUpdateSourceInfoProjects(declarationInfo.sourceMapFilePath.sourceInfos); declarationInfo.closeSourceMapFileWatcher(); } - }, ts.PollingInterval.High, "Missing source map file"); + }, ts.PollingInterval.High, "Missing source map file" /* MissingSourceMapFile */); return fileWatcher; }; + /*@internal*/ ProjectService.prototype.getSourceFileLike = function (fileName, projectNameOrProject, declarationInfo) { var project = projectNameOrProject.projectName ? projectNameOrProject : this.findProject(projectNameOrProject); if (project) { @@ -125004,17 +126615,21 @@ var ts; if (sourceFile && sourceFile.resolvedPath === path) return sourceFile; } + // Need to look for other files. var info = this.getOrCreateScriptInfoNotOpenedByClient(fileName, (project || this).currentDirectory, project ? project.directoryStructureHost : this.host); if (!info) return undefined; + // Attach as source if (declarationInfo && ts.isString(declarationInfo.sourceMapFilePath) && info !== declarationInfo) { var sourceMapInfo = this.getScriptInfoForPath(declarationInfo.sourceMapFilePath); if (sourceMapInfo) { (sourceMapInfo.sourceInfos || (sourceMapInfo.sourceInfos = ts.createMap())).set(info.path, true); } } + // Key doesnt matter since its only for text and lines if (info.cacheSourceFile) return info.cacheSourceFile.sourceFile; + // Create sourceFileLike if (!info.sourceFileLike) { info.sourceFileLike = { get text() { @@ -125052,6 +126667,7 @@ var ts; var lazyConfiguredProjectsFromExternalProject = this.hostConfiguration.preferences.lazyConfiguredProjectsFromExternalProject; this.hostConfiguration.preferences = __assign({}, this.hostConfiguration.preferences, args.preferences); if (lazyConfiguredProjectsFromExternalProject && !this.hostConfiguration.preferences.lazyConfiguredProjectsFromExternalProject) { + // Load configured projects for external projects that are pending reload this.configuredProjects.forEach(function (project) { if (project.hasExternalProjectRef() && project.pendingReload === ts.ConfigFileProgramReloadLevel.Full && @@ -125063,6 +126679,8 @@ var ts; } if (args.extraFileExtensions) { this.hostConfiguration.extraFileExtensions = args.extraFileExtensions; + // We need to update the project structures again as it is possible that existing + // project structure could have more or less files depending on extensions permitted this.reloadProjects(); this.logger.info("Host file extension mappings updated"); } @@ -125071,26 +126689,51 @@ var ts; ProjectService.prototype.closeLog = function () { this.logger.close(); }; + /** + * This function rebuilds the project for every file opened by the client + * This does not reload contents of open files from disk. But we could do that if needed + */ ProjectService.prototype.reloadProjects = function () { this.logger.info("reload projects."); - this.reloadConfiguredProjectForFiles(this.openFiles, false, ts.returnTrue, "User requested reload projects"); + // If we want this to also reload open files from disk, we could do that, + // but then we need to make sure we arent calling this function + // (and would separate out below reloading of projects to be called when immediate reload is needed) + // as there is no need to load contents of the files from the disk + // Reload Projects + this.reloadConfiguredProjectForFiles(this.openFiles, /*delayReload*/ false, ts.returnTrue, "User requested reload projects"); this.ensureProjectForOpenFiles(); }; ProjectService.prototype.delayReloadConfiguredProjectForFiles = function (configFileExistenceInfo, ignoreIfNotRootOfInferredProject) { - this.reloadConfiguredProjectForFiles(configFileExistenceInfo.openFilesImpactedByConfigFile, true, ignoreIfNotRootOfInferredProject ? - function (isRootOfInferredProject) { return isRootOfInferredProject; } : - ts.returnTrue, "Change in config file detected"); + // Get open files to reload projects for + this.reloadConfiguredProjectForFiles(configFileExistenceInfo.openFilesImpactedByConfigFile, + /*delayReload*/ true, ignoreIfNotRootOfInferredProject ? + function (isRootOfInferredProject) { return isRootOfInferredProject; } : // Reload open files if they are root of inferred project + ts.returnTrue, // Reload all the open files impacted by config file + "Change in config file detected"); this.delayEnsureProjectForOpenFiles(); }; + /** + * This function goes through all the openFiles and tries to file the config file for them. + * If the config file is found and it refers to existing project, it reloads it either immediately + * or schedules it for reload depending on delayReload option + * If the there is no existing project it just opens the configured project for the config file + * reloadForInfo provides a way to filter out files to reload configured project for + */ ProjectService.prototype.reloadConfiguredProjectForFiles = function (openFiles, delayReload, shouldReloadProjectFor, reason) { var _this = this; var updatedProjects = ts.createMap(); + // try to reload config file for all open files openFiles.forEach(function (openFileValue, path) { + // Filter out the files that need to be ignored if (!shouldReloadProjectFor(openFileValue)) { return; } - var info = _this.getScriptInfoForPath(path); + var info = _this.getScriptInfoForPath(path); // TODO: GH#18217 ts.Debug.assert(info.isScriptOpen()); + // This tries to search for a tsconfig.json for the given file. If we found it, + // we first detect if there is already a configured project created for it: if so, + // we re- read the tsconfig file content and update the project only if we havent already done so + // otherwise we create a new one. var configFileName = _this.getConfigFileNameForFile(info); if (configFileName) { var project = _this.findConfiguredProjectByProjectName(configFileName) || _this.createConfiguredProject(configFileName); @@ -125101,6 +126744,7 @@ var ts; _this.delayUpdateProjectGraph(project); } else { + // reload from the disk _this.reloadConfiguredProject(project, reason); } updatedProjects.set(configFileName, true); @@ -125108,26 +126752,51 @@ var ts; } }); }; + /** + * Remove the root of inferred project if script info is part of another project + */ ProjectService.prototype.removeRootOfInferredProjectIfNowPartOfOtherProject = function (info) { + // If the script info is root of inferred project, it could only be first containing project + // since info is added as root to the inferred project only when there are no other projects containing it + // So when it is root of the inferred project and after project structure updates its now part + // of multiple project it needs to be removed from that inferred project because: + // - references in inferred project supercede the root part + // - root / reference in non - inferred project beats root in inferred project + // eg. say this is structure /a/b/a.ts /a/b/c.ts where c.ts references a.ts + // When a.ts is opened, since there is no configured project/external project a.ts can be part of + // a.ts is added as root to inferred project. + // Now at time of opening c.ts, c.ts is also not aprt of any existing project, + // so it will be added to inferred project as a root. (for sake of this example assume single inferred project is false) + // So at this poing a.ts is part of first inferred project and second inferred project (of which c.ts is root) + // And hence it needs to be removed from the first inferred project. ts.Debug.assert(info.containingProjects.length > 0); var firstProject = info.containingProjects[0]; if (!firstProject.isOrphan() && firstProject.projectKind === server.ProjectKind.Inferred && firstProject.isRoot(info) && ts.forEach(info.containingProjects, function (p) { return p !== firstProject && !p.isOrphan(); })) { - firstProject.removeFile(info, true, true); + firstProject.removeFile(info, /*fileExists*/ true, /*detachFromProject*/ true); } }; + /** + * This function is to update the project structure for every inferred project. + * It is called on the premise that all the configured projects are + * up to date. + * This will go through open files and assign them to inferred project if open file is not part of any other project + * After that all the inferred project graphs are updated + */ ProjectService.prototype.ensureProjectForOpenFiles = function () { var _this = this; this.logger.info("Structure before ensureProjectForOpenFiles:"); this.printProjects(); this.openFiles.forEach(function (projectRootPath, path) { var info = _this.getScriptInfoForPath(path); + // collect all orphaned script infos from open files if (info.isOrphan()) { _this.assignOrphanScriptInfoToInferredProject(info, projectRootPath); } else { + // Or remove the root of inferred project if is referenced in more than one projects _this.removeRootOfInferredProjectIfNowPartOfOtherProject(info); } }); @@ -125136,9 +126805,15 @@ var ts; this.logger.info("Structure after ensureProjectForOpenFiles:"); this.printProjects(); }; + /** + * Open file whose contents is managed by the client + * @param filename is absolute pathname + * @param fileContent is a known version of the file content that is more up to date than the one on disk + */ ProjectService.prototype.openClientFile = function (fileName, fileContent, scriptKind, projectRootPath) { - return this.openClientFileWithNormalizedPath(server.toNormalizedPath(fileName), fileContent, scriptKind, false, projectRootPath ? server.toNormalizedPath(projectRootPath) : undefined); + return this.openClientFileWithNormalizedPath(server.toNormalizedPath(fileName), fileContent, scriptKind, /*hasMixedContent*/ false, projectRootPath ? server.toNormalizedPath(projectRootPath) : undefined); }; + /*@internal*/ ProjectService.prototype.getOriginalLocationEnsuringConfiguredProject = function (project, location) { var originalLocation = project.getSourceMapper().tryGetSourcePosition(location); if (!originalLocation) @@ -125153,10 +126828,12 @@ var ts; var configuredProject = this.findConfiguredProjectByProjectName(configFileName) || this.createAndLoadConfiguredProject(configFileName, "Creating project for original file: " + originalFileInfo.fileName + " for location: " + location.fileName); updateProjectIfDirty(configuredProject); + // Keep this configured project as referenced from project addOriginalConfiguredProject(configuredProject); var originalScriptInfo = this.getScriptInfo(fileName); if (!originalScriptInfo || !originalScriptInfo.containingProjects.length) return undefined; + // Add configured projects as referenced originalScriptInfo.containingProjects.forEach(function (project) { if (project.projectKind === server.ProjectKind.Configured) { addOriginalConfiguredProject(project); @@ -125170,11 +126847,13 @@ var ts; project.originalConfiguredProjects.set(originalProject.canonicalConfigFilePath, true); } }; + /** @internal */ ProjectService.prototype.fileExists = function (fileName) { return !!this.getScriptInfoForNormalizedPath(fileName) || this.host.fileExists(fileName); }; ProjectService.prototype.findExternalProjectContainingOpenScriptInfo = function (info) { return ts.find(this.externalProjects, function (proj) { + // Ensure project structure is up-to-date to check if info is present in external project updateProjectIfDirty(proj); return proj.containsScriptInfo(info); }); @@ -125182,16 +126861,18 @@ var ts; ProjectService.prototype.openClientFileWithNormalizedPath = function (fileName, fileContent, scriptKind, hasMixedContent, projectRootPath) { var configFileName; var configFileErrors; - var info = this.getOrCreateScriptInfoOpenedByClientForNormalizedPath(fileName, projectRootPath ? this.getNormalizedAbsolutePath(projectRootPath) : this.currentDirectory, fileContent, scriptKind, hasMixedContent); + var info = this.getOrCreateScriptInfoOpenedByClientForNormalizedPath(fileName, projectRootPath ? this.getNormalizedAbsolutePath(projectRootPath) : this.currentDirectory, fileContent, scriptKind, hasMixedContent); // TODO: GH#18217 this.openFiles.set(info.path, projectRootPath); var project = this.findExternalProjectContainingOpenScriptInfo(info); - if (!project && !this.syntaxOnly) { + if (!project && !this.syntaxOnly) { // Checking syntaxOnly is an optimization configFileName = this.getConfigFileNameForFile(info); if (configFileName) { project = this.findConfiguredProjectByProjectName(configFileName); if (!project) { project = this.createLoadAndUpdateConfiguredProject(configFileName, "Creating possible configured project for " + fileName + " to open"); + // Send the event only if the project got created as part of this open request and info is part of the project if (info.isOrphan()) { + // Since the file isnt part of configured project, do not send config file info configFileName = undefined; } else { @@ -125200,22 +126881,39 @@ var ts; } } else { + // Ensure project is ready to check if it contains opened script info updateProjectIfDirty(project); } } } + // Project we have at this point is going to be updated since its either found through + // - external project search, which updates the project before checking if info is present in it + // - configured project - either created or updated to ensure we know correct status of info + // At this point we need to ensure that containing projects of the info are uptodate + // This will ensure that later question of info.isOrphan() will return correct answer + // and we correctly create inferred project for the info info.containingProjects.forEach(updateProjectIfDirty); + // At this point if file is part of any any configured or external project, then it would be present in the containing projects + // So if it still doesnt have any containing projects, it needs to be part of inferred project if (info.isOrphan()) { this.assignOrphanScriptInfoToInferredProject(info, projectRootPath); } ts.Debug.assert(!info.isOrphan()); + // This was postponed from closeOpenFile to after opening next file, + // so that we can reuse the project if we need to right away this.removeOrphanConfiguredProjects(); + // Remove orphan inferred projects now that we have reused projects + // We need to create a duplicate because we cant guarantee order after removal for (var _i = 0, _a = this.inferredProjects.slice(); _i < _a.length; _i++) { var inferredProject = _a[_i]; if (inferredProject.isOrphan()) { this.removeProject(inferredProject); } } + // Delete the orphan files here because there might be orphan script infos (which are not part of project) + // when some file/s were closed which resulted in project removal. + // It was then postponed to cleanup these script infos so that they can be reused if + // the file from that old project is reopened because of opening file from here. this.removeOrphanScriptInfos(); this.printProjects(); this.telemetryOnOpenFile(info); @@ -125224,14 +126922,17 @@ var ts; ProjectService.prototype.removeOrphanConfiguredProjects = function () { var _this = this; var toRemoveConfiguredProjects = ts.cloneMap(this.configuredProjects); + // Do not remove configured projects that are used as original projects of other this.inferredProjects.forEach(markOriginalProjectsAsUsed); this.externalProjects.forEach(markOriginalProjectsAsUsed); this.configuredProjects.forEach(function (project) { + // If project has open ref (there are more than zero references from external project/open file), keep it alive as well as any project it references if (project.hasOpenRef()) { toRemoveConfiguredProjects.delete(project.canonicalConfigFilePath); markOriginalProjectsAsUsed(project); } else { + // If the configured project for project reference has more than zero references, keep it alive project.forEachResolvedProjectReference(function (ref) { if (ref) { var refProject = _this.configuredProjects.get(ref.sourceFile.path); @@ -125242,6 +126943,7 @@ var ts; }); } }); + // Remove all the non marked projects toRemoveConfiguredProjects.forEach(function (project) { return _this.removeProject(project); }); function markOriginalProjectsAsUsed(project) { if (!project.isOrphan() && project.originalConfiguredProjects) { @@ -125253,7 +126955,9 @@ var ts; var _this = this; var toRemoveScriptInfos = ts.cloneMap(this.filenameToScriptInfo); this.filenameToScriptInfo.forEach(function (info) { + // If script info is open or orphan, retain it and its dependencies if (!info.isScriptOpen() && info.isOrphan()) { + // Otherwise if there is any source info that is alive, this alive too if (!info.sourceMapFilePath) return; var sourceInfos = void 0; @@ -125273,10 +126977,12 @@ var ts; return; } } + // Retain this script info toRemoveScriptInfos.delete(info.path); if (info.sourceMapFilePath) { var sourceInfos = void 0; if (ts.isString(info.sourceMapFilePath)) { + // And map file info and source infos toRemoveScriptInfos.delete(info.sourceMapFilePath); var sourceMapInfo = _this.getScriptInfoForPath(info.sourceMapFilePath); sourceInfos = sourceMapInfo && sourceMapInfo.sourceInfos; @@ -125290,6 +126996,7 @@ var ts; } }); toRemoveScriptInfos.forEach(function (info) { + // if there are not projects that include this script info - delete it _this.stopWatchingScriptInfo(info); _this.deleteScriptInfo(info); info.closeSourceMapFileWatcher(); @@ -125306,6 +127013,10 @@ var ts; var info = { checkJs: !!project.getSourceFile(scriptInfo.path).checkJsDirective }; this.eventHandler({ eventName: server.OpenFileInfoTelemetryEvent, data: { info: info } }); }; + /** + * Close file whose contents is managed by the client + * @param filename is absolute pathname + */ ProjectService.prototype.closeClientFile = function (uncheckedFileName) { var info = this.getScriptInfoForNormalizedPath(server.toNormalizedPath(uncheckedFileName)); if (info) { @@ -125323,6 +127034,7 @@ var ts; _loop_4(proj); } }; + /* @internal */ ProjectService.prototype.synchronizeProjectList = function (knownProjects) { var files = []; this.collectChanges(knownProjects, this.externalProjects, files); @@ -125330,6 +127042,7 @@ var ts; this.collectChanges(knownProjects, this.inferredProjects, files); return files; }; + /* @internal */ ProjectService.prototype.applyChangesInOpenFiles = function (openFiles, changedFiles, closedFiles) { if (openFiles) { for (var _i = 0, openFiles_1 = openFiles; _i < openFiles_1.length; _i++) { @@ -125337,7 +127050,7 @@ var ts; var scriptInfo = this.getScriptInfo(file.fileName); ts.Debug.assert(!scriptInfo || !scriptInfo.isScriptOpen(), "Script should not exist and not be open already"); var normalizedPath = scriptInfo ? scriptInfo.fileName : server.toNormalizedPath(file.fileName); - this.openClientFileWithNormalizedPath(normalizedPath, file.content, tryConvertScriptKindName(file.scriptKind), file.hasMixedContent); + this.openClientFileWithNormalizedPath(normalizedPath, file.content, tryConvertScriptKindName(file.scriptKind), file.hasMixedContent); // TODO: GH#18217 } } if (changedFiles) { @@ -125355,7 +127068,9 @@ var ts; } } }; + /* @internal */ ProjectService.prototype.applyChangesToFile = function (scriptInfo, changes) { + // apply changes in reverse order for (var i = changes.length - 1; i >= 0; i--) { var change = changes[i]; scriptInfo.editContent(change.span.start, change.span.start + change.span.length, change.newText); @@ -125382,6 +127097,7 @@ var ts; this.externalProjectToConfiguredProjectMap.delete(fileName); } else { + // close external project var externalProject = this.findExternalProjectByProjectName(uncheckedFileName); if (externalProject) { this.removeProject(externalProject); @@ -125390,6 +127106,7 @@ var ts; }; ProjectService.prototype.openExternalProjects = function (projects) { var _this = this; + // record project list before the update var projectsToClose = ts.arrayToMap(this.externalProjects, function (p) { return p.getProjectName(); }, function (_) { return true; }); ts.forEachKey(this.externalProjectToConfiguredProjectMap, function (externalProjectName) { projectsToClose.set(externalProjectName, true); @@ -125397,8 +127114,10 @@ var ts; for (var _i = 0, projects_3 = projects; _i < projects_3.length; _i++) { var externalProject = projects_3[_i]; this.openExternalProject(externalProject); + // delete project that is present in input list projectsToClose.delete(externalProject.projectFileName); } + // close projects that were missing in the input list ts.forEachKey(projectsToClose, function (externalProjectName) { _this.closeExternalProject(externalProjectName); }); @@ -125414,6 +127133,7 @@ var ts; var rootFiles = proj.rootFiles; var typeAcquisition = proj.typeAcquisition; ts.Debug.assert(!!typeAcquisition, "proj.typeAcquisition should be set by now"); + // If type acquisition has been explicitly disabled, do not exclude anything from the project if (typeAcquisition.enable === false) { return []; } @@ -125427,9 +127147,12 @@ var ts; var root = normalizedNames_1[_i]; if (rule.match.test(root)) { this_2.logger.info("Excluding files based on rule " + name + " matching file '" + root + "'"); + // If the file matches, collect its types packages and exclude rules if (rule.types) { for (var _a = 0, _b = rule.types; _a < _b.length; _a++) { var type = _b[_a]; + // Best-effort de-duping here - doesn't need to be unduplicated but + // we don't want the list to become a 400-element array of just 'kendo' if (typeAcqInclude.indexOf(type) < 0) { typeAcqInclude.push(type); } @@ -125443,9 +127166,13 @@ var ts; groups[_i] = arguments[_i]; } return exclude.map(function (groupNumberOrString) { + // RegExp group numbers are 1-based, but the first element in groups + // is actually the original string, so it all works out in the end. if (typeof groupNumberOrString === "number") { if (!ts.isString(groups[groupNumberOrString])) { + // Specification was wrong - exclude nothing! _this.logger.info("Incorrect RegExp specification in safelist rule " + name + " - not enough groups"); + // * can't appear in a filename; escape it because it's feeding into a RegExp return "\\*"; } return ProjectService.escapeFilenameForRegex(groups[groupNumberOrString]); @@ -125463,6 +127190,7 @@ var ts; } } else { + // If not rules listed, add the default rule to exclude the matched file var escaped = ProjectService.escapeFilenameForRegex(root); if (excludeRules.indexOf(escaped) < 0) { excludeRules.push(escaped); @@ -125493,7 +127221,10 @@ var ts; if (typeName !== undefined) { this_3.logger.info("Excluded '" + normalizedNames[i] + "' because it matched " + cleanedTypingName + " from the legacy safelist"); excludedFiles.push(normalizedNames[i]); + // *exclude* it from the project... exclude = true; + // ... but *include* it in the list of types to acquire + // Same best-effort dedupe as above if (typeAcqInclude.indexOf(typeName) < 0) { typeAcqInclude.push(typeName); } @@ -125501,6 +127232,7 @@ var ts; } } if (!exclude) { + // Exclude any minified files that get this far if (/^.+[\.-]min\.js$/.test(normalizedNames[i])) { excludedFiles.push(normalizedNames[i]); } @@ -125518,6 +127250,8 @@ var ts; return excludedFiles; }; ProjectService.prototype.openExternalProject = function (proj) { + // typingOptions has been deprecated and is only supported for backward compatibility + // purposes. It should be removed in future releases - use typeAcquisition instead. if (proj.typingOptions && !proj.typeAcquisition) { var typeAcquisition = ts.convertEnableAutoDiscoveryToEnable(proj.typingOptions); proj.typeAcquisition = typeAcquisition; @@ -125543,6 +127277,7 @@ var ts; rootFiles.push(file); } } + // sort config files to simplify comparison later if (tsConfigFiles) { tsConfigFiles.sort(); } @@ -125559,17 +127294,24 @@ var ts; else { externalProject.enableLanguageService(); } + // external project already exists and not config files were added - update the project and return; + // The graph update here isnt postponed since any file open operation needs all updated external projects this.updateRootAndOptionsOfNonInferredProject(externalProject, proj.rootFiles, externalFilePropertyReader, compilerOptions, proj.typeAcquisition, proj.options.compileOnSave); externalProject.updateGraph(); return; } + // some config files were added to external project (that previously were not there) + // close existing project and later we'll open a set of configured projects for these files this.closeExternalProject(proj.projectFileName); } else if (this.externalProjectToConfiguredProjectMap.get(proj.projectFileName)) { + // this project used to include config files if (!tsConfigFiles) { + // config files were removed from the project - close existing external project which in turn will close configured projects this.closeExternalProject(proj.projectFileName); } else { + // project previously had some config files - compare them with new set of files and close all configured projects that correspond to unused files var oldConfigFiles = this.externalProjectToConfiguredProjectMap.get(proj.projectFileName); var iNew = 0; var iOld = 0; @@ -125584,55 +127326,68 @@ var ts; iNew++; } else { + // record existing config files so avoid extra add-refs (exisingConfigFiles || (exisingConfigFiles = [])).push(oldConfig); iOld++; iNew++; } } for (var i = iOld; i < oldConfigFiles.length; i++) { + // projects for all remaining old config files should be closed this.closeConfiguredProjectReferencedFromExternalProject(oldConfigFiles[i]); } } } if (tsConfigFiles) { + // store the list of tsconfig files that belong to the external project this.externalProjectToConfiguredProjectMap.set(proj.projectFileName, tsConfigFiles); for (var _b = 0, tsConfigFiles_1 = tsConfigFiles; _b < tsConfigFiles_1.length; _b++) { var tsconfigFile = tsConfigFiles_1[_b]; var project = this.findConfiguredProjectByProjectName(tsconfigFile); if (!project) { + // errors are stored in the project, do not need to update the graph project = this.getHostPreferences().lazyConfiguredProjectsFromExternalProject ? this.createConfiguredProjectWithDelayLoad(tsconfigFile, "Creating configured project in external project: " + proj.projectFileName) : this.createLoadAndUpdateConfiguredProject(tsconfigFile, "Creating configured project in external project: " + proj.projectFileName); } if (project && !ts.contains(exisingConfigFiles, tsconfigFile)) { + // keep project alive even if no documents are opened - its lifetime is bound to the lifetime of containing external project project.addExternalProjectReference(); } } } else { + // no config files - remove the item from the collection + // Create external project and update its graph, do not delay update since + // any file open operation needs all updated external projects this.externalProjectToConfiguredProjectMap.delete(proj.projectFileName); var project = this.createExternalProject(proj.projectFileName, rootFiles, proj.options, proj.typeAcquisition, excludedFiles); project.updateGraph(); } }; ProjectService.prototype.hasDeferredExtension = function () { - for (var _i = 0, _a = this.hostConfiguration.extraFileExtensions; _i < _a.length; _i++) { + for (var _i = 0, _a = this.hostConfiguration.extraFileExtensions; _i < _a.length; _i++) { // TODO: GH#18217 var extension = _a[_i]; - if (extension.scriptKind === 7) { + if (extension.scriptKind === 7 /* Deferred */) { return true; } } return false; }; ProjectService.prototype.configurePlugin = function (args) { + // For any projects that already have the plugin loaded, configure the plugin this.forEachEnabledProject(function (project) { return project.onPluginConfigurationChanged(args.pluginName, args.configuration); }); + // Also save the current configuration to pass on to any projects that are yet to be loaded. + // If a plugin is configured twice, only the latest configuration will be remembered. this.currentPluginConfigOverrides = this.currentPluginConfigOverrides || ts.createMap(); this.currentPluginConfigOverrides.set(args.pluginName, args.configuration); }; + /** Makes a filename safe to insert in a RegExp */ ProjectService.filenameEscapeRegexp = /[-\/\\^$*+?.()|[\]{}]/g; return ProjectService; }()); server.ProjectService = ProjectService; + /* @internal */ function isConfigFile(config) { return config.kind !== undefined; } @@ -125662,6 +127417,18 @@ var ts; return ((1e9 * seconds) + nanoseconds) / 1000000.0; } function isDeclarationFileInJSOnlyNonConfiguredProject(project, file) { + // Checking for semantic diagnostics is an expensive process. We want to avoid it if we + // know for sure it is not needed. + // For instance, .d.ts files injected by ATA automatically do not produce any relevant + // errors to a JS- only project. + // + // Note that configured projects can set skipLibCheck (on by default in jsconfig.json) to + // disable checking for declaration files. We only need to verify for inferred projects (e.g. + // miscellaneous context in VS) and external projects(e.g.VS.csproj project) with only JS + // files. + // + // We still want to check .js files in a JS-only inferred or external project (e.g. if the + // file has '// @ts-check'). if ((project.projectKind === server.ProjectKind.Inferred || project.projectKind === server.ProjectKind.External) && project.isJsOnlyProject()) { var scriptInfo = project.getScriptInfoForNormalizedPath(file); @@ -125670,7 +127437,7 @@ var ts; return false; } function formatDiag(fileName, project, diag) { - var scriptInfo = project.getScriptInfoForNormalizedPath(fileName); + var scriptInfo = project.getScriptInfoForNormalizedPath(fileName); // TODO: GH#18217 return { start: scriptInfo.positionToLineOffset(diag.start), end: scriptInfo.positionToLineOffset(diag.start + diag.length), @@ -125705,8 +127472,8 @@ var ts; return { line: lineAndCharacter.line + 1, offset: lineAndCharacter.character + 1 }; } function formatConfigFileDiag(diag, includeFileName) { - var start = (diag.file && convertToLocation(ts.getLineAndCharacterOfPosition(diag.file, diag.start))); - var end = (diag.file && convertToLocation(ts.getLineAndCharacterOfPosition(diag.file, diag.start + diag.length))); + var start = (diag.file && convertToLocation(ts.getLineAndCharacterOfPosition(diag.file, diag.start))); // TODO: GH#18217 + var end = (diag.file && convertToLocation(ts.getLineAndCharacterOfPosition(diag.file, diag.start + diag.length))); // TODO: GH#18217 var text = ts.flattenDiagnosticMessageText(diag.messageText, "\n"); var code = diag.code, source = diag.source; var category = ts.diagnosticCategoryName(diag); @@ -125726,7 +127493,7 @@ var ts; function allEditsBeforePos(edits, pos) { return edits.every(function (edit) { return ts.textSpanEnd(edit.span) < pos; }); } - server.CommandNames = server.protocol.CommandTypes; + server.CommandNames = server.protocol.CommandTypes; // tslint:disable-line variable-name function formatMessage(msg, logger, byteLength, newLine) { var verboseLogging = logger.hasLevel(server.LogLevel.verbose); var json = JSON.stringify(msg); @@ -125737,7 +127504,11 @@ var ts; return "Content-Length: " + (1 + len) + "\r\n\r\n" + json + newLine; } server.formatMessage = formatMessage; - var MultistepOperation = (function () { + /** + * Represents operation that can schedule its next step to be executed later. + * Scheduling is done via instance of NextStep. If on current step subsequent step was not scheduled - operation is assumed to be completed. + */ + var MultistepOperation = /** @class */ (function () { function MultistepOperation(operationHost) { this.operationHost = operationHost; } @@ -125784,6 +127555,7 @@ var ts; } catch (e) { stop = true; + // ignore cancellation request if (!(e instanceof ts.OperationCanceledException)) { this.operationHost.logError(e, "delayed processing of request " + this.requestId); } @@ -125809,6 +127581,7 @@ var ts; }; return MultistepOperation; }()); + /** @internal */ function toEvent(eventName, body) { return { seq: 0, @@ -125818,6 +127591,9 @@ var ts; }; } server.toEvent = toEvent; + /** + * This helper function processes a list of projects and return the concatenated, sortd and deduplicated output of processing each project. + */ function combineProjectOutput(defaultValue, getValue, projects, action) { var outputs = ts.flatMapToMutable(ts.isArray(projects) ? projects : projects.projects, function (project) { return action(project, defaultValue); }); if (!ts.isArray(projects) && projects.symLinkedProjects) { @@ -125838,7 +127614,8 @@ var ts; } function combineProjectOutputWhileOpeningReferencedProjects(projects, defaultProject, action, getLocation, resultsEqual) { var outputs = []; - combineProjectOutputWorker(projects, defaultProject, undefined, function (_a, tryAddToTodo) { + combineProjectOutputWorker(projects, defaultProject, + /*initialLocation*/ undefined, function (_a, tryAddToTodo) { var project = _a.project; for (var _i = 0, _b = action(project); _i < _b.length; _i++) { var output = _b[_i]; @@ -125846,7 +127623,8 @@ var ts; outputs.push(output); } } - }, undefined); + }, + /*getDefinition*/ undefined); return outputs; } function combineProjectOutputForRenameLocations(projects, defaultProject, initialLocation, findInStrings, findInComments, hostPreferences) { @@ -125881,6 +127659,7 @@ var ts; } for (var _i = 0, _a = outputReferencedSymbol.references; _i < _a.length; _i++) { var ref = _a[_i]; + // If it's in a mapped file, that is added to the todo list by `getMappedLocation`. if (!ts.contains(symbolToAddTo.references, ref, ts.documentSpansEqual) && !getMappedLocation(project, documentSpanLocation(ref))) { symbolToAddTo.references.push(ref); } @@ -125912,9 +127691,11 @@ var ts; var toDo; var seenProjects = ts.createMap(); forEachProjectInProjects(projects, initialLocation && initialLocation.fileName, function (project, path) { + // TLocation shoud be either `DocumentPosition` or `undefined`. Since `initialLocation` is `TLocation` this cast should be valid. var location = (initialLocation ? { fileName: path, pos: initialLocation.pos } : undefined); toDo = callbackProjectAndLocation({ project: project, location: location }, projectService, toDo, seenProjects, cb); }); + // After initial references are collected, go over every other project and see if it has a reference for the symbol definition. if (getDefinition) { var memGetDefinition_1 = ts.memoize(getDefinition); projectService.forEachEnabledProject(function (project) { @@ -125938,7 +127719,7 @@ var ts; } function callbackProjectAndLocation(projectAndLocation, projectService, toDo, seenProjects, cb) { if (projectAndLocation.project.getCancellationToken().isCancellationRequested()) - return undefined; + return undefined; // Skip rest of toDo if cancelled cb(projectAndLocation, function (project, location) { seenProjects.set(projectAndLocation.project.projectName, true); var originalLocation = projectService.getOriginalLocationEnsuringConfiguredProject(project, location); @@ -125975,7 +127756,7 @@ var ts; var mapsTo = project.getSourceMapper().tryGetSourcePosition(location); return mapsTo && projectService.fileExists(server.toNormalizedPath(mapsTo.fileName)) ? mapsTo : undefined; } - var Session = (function () { + var Session = /** @class */ (function () { function Session(opts) { var _a; var _this = this; @@ -125987,15 +127768,18 @@ var ts; }, _a[server.CommandNames.OpenExternalProject] = function (request) { _this.projectService.openExternalProject(request.arguments); - return _this.requiredResponse(true); + // TODO: GH#20447 report errors + return _this.requiredResponse(/*response*/ true); }, _a[server.CommandNames.OpenExternalProjects] = function (request) { _this.projectService.openExternalProjects(request.arguments.projects); - return _this.requiredResponse(true); + // TODO: GH#20447 report errors + return _this.requiredResponse(/*response*/ true); }, _a[server.CommandNames.CloseExternalProject] = function (request) { _this.projectService.closeExternalProject(request.arguments.projectFileName); - return _this.requiredResponse(true); + // TODO: GH#20447 report errors + return _this.requiredResponse(/*response*/ true); }, _a[server.CommandNames.SynchronizeProjectList] = function (request) { var result = _this.projectService.synchronizeProjectList(request.arguments.knownProjects); @@ -126010,31 +127794,32 @@ var ts; info: p.info, changes: p.changes, files: p.files, - projectErrors: _this.convertToDiagnosticsWithLinePosition(p.projectErrors, undefined) + projectErrors: _this.convertToDiagnosticsWithLinePosition(p.projectErrors, /*scriptInfo*/ undefined) }; }); return _this.requiredResponse(converted); }, _a[server.CommandNames.ApplyChangedToOpenFiles] = function (request) { _this.changeSeq++; - _this.projectService.applyChangesInOpenFiles(request.arguments.openFiles, request.arguments.changedFiles, request.arguments.closedFiles); - return _this.requiredResponse(true); + _this.projectService.applyChangesInOpenFiles(request.arguments.openFiles, request.arguments.changedFiles, request.arguments.closedFiles); // TODO: GH#18217 + // TODO: report errors + return _this.requiredResponse(/*response*/ true); }, _a[server.CommandNames.Exit] = function () { _this.exit(); return _this.notRequired(); }, _a[server.CommandNames.Definition] = function (request) { - return _this.requiredResponse(_this.getDefinition(request.arguments, true)); + return _this.requiredResponse(_this.getDefinition(request.arguments, /*simplifiedResult*/ true)); }, _a[server.CommandNames.DefinitionFull] = function (request) { - return _this.requiredResponse(_this.getDefinition(request.arguments, false)); + return _this.requiredResponse(_this.getDefinition(request.arguments, /*simplifiedResult*/ false)); }, _a[server.CommandNames.DefinitionAndBoundSpan] = function (request) { - return _this.requiredResponse(_this.getDefinitionAndBoundSpan(request.arguments, true)); + return _this.requiredResponse(_this.getDefinitionAndBoundSpan(request.arguments, /*simplifiedResult*/ true)); }, _a[server.CommandNames.DefinitionAndBoundSpanFull] = function (request) { - return _this.requiredResponse(_this.getDefinitionAndBoundSpan(request.arguments, false)); + return _this.requiredResponse(_this.getDefinitionAndBoundSpan(request.arguments, /*simplifiedResult*/ false)); }, _a[server.CommandNames.EmitOutput] = function (request) { return _this.requiredResponse(_this.getEmitOutput(request.arguments)); @@ -126043,41 +127828,42 @@ var ts; return _this.requiredResponse(_this.getTypeDefinition(request.arguments)); }, _a[server.CommandNames.Implementation] = function (request) { - return _this.requiredResponse(_this.getImplementation(request.arguments, true)); + return _this.requiredResponse(_this.getImplementation(request.arguments, /*simplifiedResult*/ true)); }, _a[server.CommandNames.ImplementationFull] = function (request) { - return _this.requiredResponse(_this.getImplementation(request.arguments, false)); + return _this.requiredResponse(_this.getImplementation(request.arguments, /*simplifiedResult*/ false)); }, _a[server.CommandNames.References] = function (request) { - return _this.requiredResponse(_this.getReferences(request.arguments, true)); + return _this.requiredResponse(_this.getReferences(request.arguments, /*simplifiedResult*/ true)); }, _a[server.CommandNames.ReferencesFull] = function (request) { - return _this.requiredResponse(_this.getReferences(request.arguments, false)); + return _this.requiredResponse(_this.getReferences(request.arguments, /*simplifiedResult*/ false)); }, _a[server.CommandNames.Rename] = function (request) { - return _this.requiredResponse(_this.getRenameLocations(request.arguments, true)); + return _this.requiredResponse(_this.getRenameLocations(request.arguments, /*simplifiedResult*/ true)); }, _a[server.CommandNames.RenameLocationsFull] = function (request) { - return _this.requiredResponse(_this.getRenameLocations(request.arguments, false)); + return _this.requiredResponse(_this.getRenameLocations(request.arguments, /*simplifiedResult*/ false)); }, _a[server.CommandNames.RenameInfoFull] = function (request) { return _this.requiredResponse(_this.getRenameInfo(request.arguments)); }, _a[server.CommandNames.Open] = function (request) { - _this.openClientFile(server.toNormalizedPath(request.arguments.file), request.arguments.fileContent, server.convertScriptKindName(request.arguments.scriptKindName), request.arguments.projectRootPath ? server.toNormalizedPath(request.arguments.projectRootPath) : undefined); + _this.openClientFile(server.toNormalizedPath(request.arguments.file), request.arguments.fileContent, server.convertScriptKindName(request.arguments.scriptKindName), // TODO: GH#18217 + request.arguments.projectRootPath ? server.toNormalizedPath(request.arguments.projectRootPath) : undefined); return _this.notRequired(); }, _a[server.CommandNames.Quickinfo] = function (request) { - return _this.requiredResponse(_this.getQuickInfoWorker(request.arguments, true)); + return _this.requiredResponse(_this.getQuickInfoWorker(request.arguments, /*simplifiedResult*/ true)); }, _a[server.CommandNames.QuickinfoFull] = function (request) { - return _this.requiredResponse(_this.getQuickInfoWorker(request.arguments, false)); + return _this.requiredResponse(_this.getQuickInfoWorker(request.arguments, /*simplifiedResult*/ false)); }, _a[server.CommandNames.GetOutliningSpans] = function (request) { - return _this.requiredResponse(_this.getOutliningSpans(request.arguments, true)); + return _this.requiredResponse(_this.getOutliningSpans(request.arguments, /*simplifiedResult*/ true)); }, _a[server.CommandNames.GetOutliningSpansFull] = function (request) { - return _this.requiredResponse(_this.getOutliningSpans(request.arguments, false)); + return _this.requiredResponse(_this.getOutliningSpans(request.arguments, /*simplifiedResult*/ false)); }, _a[server.CommandNames.TodoComments] = function (request) { return _this.requiredResponse(_this.getTodoComments(request.arguments)); @@ -126125,10 +127911,10 @@ var ts; return _this.requiredResponse(_this.getCompletions(request.arguments, server.CommandNames.CompletionsFull)); }, _a[server.CommandNames.CompletionDetails] = function (request) { - return _this.requiredResponse(_this.getCompletionEntryDetails(request.arguments, true)); + return _this.requiredResponse(_this.getCompletionEntryDetails(request.arguments, /*simplifiedResult*/ true)); }, _a[server.CommandNames.CompletionDetailsFull] = function (request) { - return _this.requiredResponse(_this.getCompletionEntryDetails(request.arguments, false)); + return _this.requiredResponse(_this.getCompletionEntryDetails(request.arguments, /*simplifiedResult*/ false)); }, _a[server.CommandNames.CompileOnSaveAffectedFileList] = function (request) { return _this.requiredResponse(_this.getCompileOnSaveAffectedFileList(request.arguments)); @@ -126137,10 +127923,10 @@ var ts; return _this.requiredResponse(_this.emitFile(request.arguments)); }, _a[server.CommandNames.SignatureHelp] = function (request) { - return _this.requiredResponse(_this.getSignatureHelpItems(request.arguments, true)); + return _this.requiredResponse(_this.getSignatureHelpItems(request.arguments, /*simplifiedResult*/ true)); }, _a[server.CommandNames.SignatureHelpFull] = function (request) { - return _this.requiredResponse(_this.getSignatureHelpItems(request.arguments, false)); + return _this.requiredResponse(_this.getSignatureHelpItems(request.arguments, /*simplifiedResult*/ false)); }, _a[server.CommandNames.CompilerOptionsDiagnosticsFull] = function (request) { return _this.requiredResponse(_this.getCompilerOptionsDiagnostics(request.arguments)); @@ -126150,7 +127936,7 @@ var ts; }, _a[server.CommandNames.Cleanup] = function () { _this.cleanup(); - return _this.requiredResponse(true); + return _this.requiredResponse(/*response*/ true); }, _a[server.CommandNames.SemanticDiagnosticsSync] = function (request) { return _this.requiredResponse(_this.getSemanticDiagnosticsSync(request.arguments)); @@ -126175,7 +127961,7 @@ var ts; }, _a[server.CommandNames.Configure] = function (request) { _this.projectService.setHostConfiguration(request.arguments); - _this.doOutput(undefined, server.CommandNames.Configure, request.seq, true); + _this.doOutput(/*info*/ undefined, server.CommandNames.Configure, request.seq, /*success*/ true); return _this.notRequired(); }, _a[server.CommandNames.Reload] = function (request) { @@ -126193,41 +127979,41 @@ var ts; return _this.notRequired(); }, _a[server.CommandNames.Navto] = function (request) { - return _this.requiredResponse(_this.getNavigateToItems(request.arguments, true)); + return _this.requiredResponse(_this.getNavigateToItems(request.arguments, /*simplifiedResult*/ true)); }, _a[server.CommandNames.NavtoFull] = function (request) { - return _this.requiredResponse(_this.getNavigateToItems(request.arguments, false)); + return _this.requiredResponse(_this.getNavigateToItems(request.arguments, /*simplifiedResult*/ false)); }, _a[server.CommandNames.Brace] = function (request) { - return _this.requiredResponse(_this.getBraceMatching(request.arguments, true)); + return _this.requiredResponse(_this.getBraceMatching(request.arguments, /*simplifiedResult*/ true)); }, _a[server.CommandNames.BraceFull] = function (request) { - return _this.requiredResponse(_this.getBraceMatching(request.arguments, false)); + return _this.requiredResponse(_this.getBraceMatching(request.arguments, /*simplifiedResult*/ false)); }, _a[server.CommandNames.NavBar] = function (request) { - return _this.requiredResponse(_this.getNavigationBarItems(request.arguments, true)); + return _this.requiredResponse(_this.getNavigationBarItems(request.arguments, /*simplifiedResult*/ true)); }, _a[server.CommandNames.NavBarFull] = function (request) { - return _this.requiredResponse(_this.getNavigationBarItems(request.arguments, false)); + return _this.requiredResponse(_this.getNavigationBarItems(request.arguments, /*simplifiedResult*/ false)); }, _a[server.CommandNames.NavTree] = function (request) { - return _this.requiredResponse(_this.getNavigationTree(request.arguments, true)); + return _this.requiredResponse(_this.getNavigationTree(request.arguments, /*simplifiedResult*/ true)); }, _a[server.CommandNames.NavTreeFull] = function (request) { - return _this.requiredResponse(_this.getNavigationTree(request.arguments, false)); + return _this.requiredResponse(_this.getNavigationTree(request.arguments, /*simplifiedResult*/ false)); }, _a[server.CommandNames.Occurrences] = function (request) { return _this.requiredResponse(_this.getOccurrences(request.arguments)); }, _a[server.CommandNames.DocumentHighlights] = function (request) { - return _this.requiredResponse(_this.getDocumentHighlights(request.arguments, true)); + return _this.requiredResponse(_this.getDocumentHighlights(request.arguments, /*simplifiedResult*/ true)); }, _a[server.CommandNames.DocumentHighlightsFull] = function (request) { - return _this.requiredResponse(_this.getDocumentHighlights(request.arguments, false)); + return _this.requiredResponse(_this.getDocumentHighlights(request.arguments, /*simplifiedResult*/ false)); }, _a[server.CommandNames.CompilerOptionsForInferredProjects] = function (request) { _this.setCompilerOptionsForInferredProjects(request.arguments); - return _this.requiredResponse(true); + return _this.requiredResponse(/*response*/ true); }, _a[server.CommandNames.ProjectInfo] = function (request) { return _this.requiredResponse(_this.getProjectInfo(request.arguments)); @@ -126240,16 +128026,16 @@ var ts; return _this.requiredResponse(_this.getJsxClosingTag(request.arguments)); }, _a[server.CommandNames.GetCodeFixes] = function (request) { - return _this.requiredResponse(_this.getCodeFixes(request.arguments, true)); + return _this.requiredResponse(_this.getCodeFixes(request.arguments, /*simplifiedResult*/ true)); }, _a[server.CommandNames.GetCodeFixesFull] = function (request) { - return _this.requiredResponse(_this.getCodeFixes(request.arguments, false)); + return _this.requiredResponse(_this.getCodeFixes(request.arguments, /*simplifiedResult*/ false)); }, _a[server.CommandNames.GetCombinedCodeFix] = function (request) { - return _this.requiredResponse(_this.getCombinedCodeFix(request.arguments, true)); + return _this.requiredResponse(_this.getCombinedCodeFix(request.arguments, /*simplifiedResult*/ true)); }, _a[server.CommandNames.GetCombinedCodeFixFull] = function (request) { - return _this.requiredResponse(_this.getCombinedCodeFix(request.arguments, false)); + return _this.requiredResponse(_this.getCombinedCodeFix(request.arguments, /*simplifiedResult*/ false)); }, _a[server.CommandNames.ApplyCodeActionCommand] = function (request) { return _this.requiredResponse(_this.applyCodeActionCommand(request.arguments)); @@ -126261,22 +128047,22 @@ var ts; return _this.requiredResponse(_this.getApplicableRefactors(request.arguments)); }, _a[server.CommandNames.GetEditsForRefactor] = function (request) { - return _this.requiredResponse(_this.getEditsForRefactor(request.arguments, true)); + return _this.requiredResponse(_this.getEditsForRefactor(request.arguments, /*simplifiedResult*/ true)); }, _a[server.CommandNames.GetEditsForRefactorFull] = function (request) { - return _this.requiredResponse(_this.getEditsForRefactor(request.arguments, false)); + return _this.requiredResponse(_this.getEditsForRefactor(request.arguments, /*simplifiedResult*/ false)); }, _a[server.CommandNames.OrganizeImports] = function (request) { - return _this.requiredResponse(_this.organizeImports(request.arguments, true)); + return _this.requiredResponse(_this.organizeImports(request.arguments, /*simplifiedResult*/ true)); }, _a[server.CommandNames.OrganizeImportsFull] = function (request) { - return _this.requiredResponse(_this.organizeImports(request.arguments, false)); + return _this.requiredResponse(_this.organizeImports(request.arguments, /*simplifiedResult*/ false)); }, _a[server.CommandNames.GetEditsForFileRename] = function (request) { - return _this.requiredResponse(_this.getEditsForFileRename(request.arguments, true)); + return _this.requiredResponse(_this.getEditsForFileRename(request.arguments, /*simplifiedResult*/ true)); }, _a[server.CommandNames.GetEditsForFileRenameFull] = function (request) { - return _this.requiredResponse(_this.getEditsForFileRename(request.arguments, false)); + return _this.requiredResponse(_this.getEditsForFileRename(request.arguments, /*simplifiedResult*/ false)); }, _a[server.CommandNames.ConfigurePlugin] = function (request) { _this.configurePlugin(request.arguments); @@ -126322,7 +128108,7 @@ var ts; syntaxOnly: opts.syntaxOnly, }; this.projectService = new server.ProjectService(settings); - this.gcTimer = new server.GcTimer(this.host, 7000, this.logger); + this.gcTimer = new server.GcTimer(this.host, /*delay*/ 7000, this.logger); } Session.prototype.sendRequestCompletedEvent = function (requestId) { this.event({ request_seq: requestId }, "requestCompleted"); @@ -126347,7 +128133,7 @@ var ts; break; case server.ConfigFileDiagEvent: var _c = event.data, triggerFile = _c.triggerFile, configFile = _c.configFileName, diagnostics = _c.diagnostics; - var bakedDiags = ts.map(diagnostics, function (diagnostic) { return formatConfigFileDiag(diagnostic, true); }); + var bakedDiags = ts.map(diagnostics, function (diagnostic) { return formatConfigFileDiag(diagnostic, /*includeFileName*/ true); }); this.event({ triggerFile: triggerFile, configFile: configFile, @@ -126378,8 +128164,10 @@ var ts; if (openFiles.length) { if (!this.suppressDiagnosticEvents && !this.noGetErrOnBackgroundUpdate) { var checkList_1 = this.createCheckList(openFiles); - this.errorCheck.startNew(function (next) { return _this.updateErrorCheck(next, checkList_1, 100, true); }); + // For now only queue error checking for open files. We can change this to include non open files as well + this.errorCheck.startNew(function (next) { return _this.updateErrorCheck(next, checkList_1, 100, /*requireOpen*/ true); }); } + // Send project changed event this.event({ openFiles: openFiles }, server.ProjectsUpdatedInBackgroundEvent); @@ -126405,7 +128193,7 @@ var ts; msg += "\n\nFile text of " + fileRequest.file + ":" + server.indent(text) + "\n"; } } - catch (_b) { } + catch (_b) { } // tslint:disable-line no-empty } this.logger.msg(msg, server.Msg.Err); }; @@ -126421,8 +128209,10 @@ var ts; Session.prototype.event = function (body, eventName) { this.send(toEvent(eventName, body)); }; + // For backwards-compatibility only. + /** @deprecated */ Session.prototype.output = function (info, cmdName, reqSeq, errorMsg) { - this.doOutput(info, cmdName, reqSeq, !errorMsg, errorMsg); + this.doOutput(info, cmdName, reqSeq, /*success*/ !errorMsg, errorMsg); // TODO: GH#18217 }; Session.prototype.doOutput = function (info, cmdName, reqSeq, success, message) { var res = { @@ -126483,10 +128273,11 @@ var ts; this.logError(err, kind); } }; + /** It is the caller's responsibility to verify that `!this.suppressDiagnosticEvents`. */ Session.prototype.updateErrorCheck = function (next, checkList, ms, requireOpen) { var _this = this; if (requireOpen === void 0) { requireOpen = true; } - ts.Debug.assert(!this.suppressDiagnosticEvents); + ts.Debug.assert(!this.suppressDiagnosticEvents); // Caller's responsibility var seq = this.changeSeq; var followMs = Math.min(ms, 200); var index = 0; @@ -126496,6 +128287,7 @@ var ts; } var _a = checkList[index], fileName = _a.fileName, project = _a.project; index++; + // Ensure the project is upto date before checking if this file is present in the project server.updateProjectIfDirty(project); if (!project.containsFile(fileName, requireOpen)) { return; @@ -126536,7 +128328,7 @@ var ts; this.logger.info("cleaning " + caption); for (var _i = 0, projects_5 = projects; _i < projects_5.length; _i++) { var p = projects_5[_i]; - p.getLanguageService(false).cleanupSemanticCache(); + p.getLanguageService(/*ensureSynchronized*/ false).cleanupSemanticCache(); } }; Session.prototype.cleanup = function () { @@ -126569,7 +128361,7 @@ var ts; var diagnosticsForConfigFile = ts.filter(ts.concatenate(projectErrors, optionsErrors), function (diagnostic) { return !!diagnostic.file && diagnostic.file.fileName === configFile; }); return includeLinePosition ? this.convertToDiagnosticsWithLinePositionFromDiagnosticFile(diagnosticsForConfigFile) : - ts.map(diagnosticsForConfigFile, function (diagnostic) { return formatConfigFileDiag(diagnostic, false); }); + ts.map(diagnosticsForConfigFile, function (diagnostic) { return formatConfigFileDiag(diagnostic, /*includeFileName*/ false); }); }; Session.prototype.convertToDiagnosticsWithLinePositionFromDiagnosticFile = function (diagnostics) { var _this = this; @@ -126586,7 +128378,11 @@ var ts; }; Session.prototype.getCompilerOptionsDiagnostics = function (args) { var project = this.getProject(args.projectFileName); - return this.convertToDiagnosticsWithLinePosition(ts.filter(project.getLanguageService().getCompilerOptionsDiagnostics(), function (diagnostic) { return !diagnostic.file; }), undefined); + // Get diagnostics that dont have associated file with them + // The diagnostics which have file would be in config file and + // would be reported as part of configFileDiagnostics + return this.convertToDiagnosticsWithLinePosition(ts.filter(project.getLanguageService().getCompilerOptionsDiagnostics(), function (diagnostic) { return !diagnostic.file; }), + /*scriptInfo*/ undefined); }; Session.prototype.convertToDiagnosticsWithLinePosition = function (diagnostics, scriptInfo) { var _this = this; @@ -126647,7 +128443,7 @@ var ts; if (!unmappedDefinitionAndBoundSpan || !unmappedDefinitionAndBoundSpan.definitions) { return { definitions: server.emptyArray, - textSpan: undefined + textSpan: undefined // TODO: GH#18217 }; } var definitions = this.mapDefinitionInfoLocations(unmappedDefinitionAndBoundSpan.definitions, project); @@ -126671,6 +128467,13 @@ var ts; var _this = this; return definitions.map(function (def) { return _this.toFileSpan(def.fileName, def.textSpan, project); }); }; + /* + * When we map a .d.ts location to .ts, Visual Studio gets confused because there's no associated Roslyn Document in + * the same project which corresponds to the file. VS Code has no problem with this, and luckily we have two protocols. + * This retains the existing behavior for the "simplified" (VS Code) protocol but stores the .d.ts location in a + * set of additional fields, and does the reverse for VS (store the .d.ts location where + * it used to be and stores the .ts location in the additional fields). + */ Session.mapToOriginalLocation = function (def) { if (def.originalFileName) { ts.Debug.assert(def.originalTextSpan !== undefined, "originalTextSpan should be present if originalFileName is"); @@ -126680,7 +128483,7 @@ var ts; }; Session.prototype.toFileSpan = function (fileName, textSpan, project) { var ls = project.getLanguageService(); - var start = ls.toLineColumnOffset(fileName, textSpan.start); + var start = ls.toLineColumnOffset(fileName, textSpan.start); // TODO: GH#18217 var end = ls.toLineColumnOffset(fileName, ts.textSpanEnd(textSpan)); return { file: fileName, @@ -126740,6 +128543,7 @@ var ts; file: fileName, isWriteAccess: isWriteAccess, }; + // no need to serialize the property if it is not true if (isInString) { result.isInString = isInString; } @@ -126749,23 +128553,26 @@ var ts; Session.prototype.getSyntacticDiagnosticsSync = function (args) { var configFile = this.getConfigFileAndProject(args).configFile; if (configFile) { + // all the config file errors are reported as part of semantic check so nothing to report here return server.emptyArray; } - return this.getDiagnosticsWorker(args, false, function (project, file) { return project.getLanguageService().getSyntacticDiagnostics(file); }, !!args.includeLinePosition); + return this.getDiagnosticsWorker(args, /*isSemantic*/ false, function (project, file) { return project.getLanguageService().getSyntacticDiagnostics(file); }, !!args.includeLinePosition); }; Session.prototype.getSemanticDiagnosticsSync = function (args) { var _a = this.getConfigFileAndProject(args), configFile = _a.configFile, project = _a.project; if (configFile) { - return this.getConfigFileDiagnostics(configFile, project, !!args.includeLinePosition); + return this.getConfigFileDiagnostics(configFile, project, !!args.includeLinePosition); // TODO: GH#18217 } - return this.getDiagnosticsWorker(args, true, function (project, file) { return project.getLanguageService().getSemanticDiagnostics(file); }, !!args.includeLinePosition); + return this.getDiagnosticsWorker(args, /*isSemantic*/ true, function (project, file) { return project.getLanguageService().getSemanticDiagnostics(file); }, !!args.includeLinePosition); }; Session.prototype.getSuggestionDiagnosticsSync = function (args) { var configFile = this.getConfigFileAndProject(args).configFile; if (configFile) { + // Currently there are no info diagnostics for config files. return server.emptyArray; } - return this.getDiagnosticsWorker(args, true, function (project, file) { return project.getLanguageService().getSuggestionDiagnostics(file); }, !!args.includeLinePosition); + // isSemantic because we don't want to info diagnostics in declaration files for JS-only users + return this.getDiagnosticsWorker(args, /*isSemantic*/ true, function (project, file) { return project.getLanguageService().getSuggestionDiagnostics(file); }, !!args.includeLinePosition); }; Session.prototype.getJsxClosingTag = function (args) { var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; @@ -126805,7 +128612,7 @@ var ts; this.projectService.setCompilerOptionsForInferredProjects(args.options, args.projectRootPath); }; Session.prototype.getProjectInfo = function (args) { - return this.getProjectInfoWorker(args.file, args.projectFileName, args.needFileNameList, false); + return this.getProjectInfoWorker(args.file, args.projectFileName, args.needFileNameList, /*excludeConfigFiles*/ false); }; Session.prototype.getProjectInfoWorker = function (uncheckedFileName, projectFileName, needFileNameList, excludeConfigFiles) { var project = this.getFileAndProjectWorker(uncheckedFileName, projectFileName).project; @@ -126813,7 +128620,7 @@ var ts; var projectInfo = { configFileName: project.getProjectName(), languageServiceDisabled: !project.languageServiceEnabled, - fileNames: needFileNameList ? project.getFileNames(false, excludeConfigFiles) : undefined + fileNames: needFileNameList ? project.getFileNames(/*excludeFilesFromExternalLibraries*/ false, excludeConfigFiles) : undefined }; return projectInfo; }; @@ -126844,12 +128651,13 @@ var ts; projects = scriptInfo.containingProjects; symLinkedProjects = this.projectService.getSymlinkedProjects(scriptInfo); } + // filter handles case when 'projects' is undefined projects = ts.filter(projects, function (p) { return p.languageServiceEnabled && !p.isOrphan(); }); if (!ignoreNoProjectError && (!projects || !projects.length) && !symLinkedProjects) { this.projectService.logErrorForScriptInfoNotFound(args.file); return server.Errors.ThrowNoProject(); } - return symLinkedProjects ? { projects: projects, symLinkedProjects: symLinkedProjects } : projects; + return symLinkedProjects ? { projects: projects, symLinkedProjects: symLinkedProjects } : projects; // TODO: GH#18217 }; Session.prototype.getDefaultProject = function (args) { if (args.projectFileName) { @@ -126925,8 +128733,12 @@ var ts; return references; } }; + /** + * @param fileName is the name of the file to be opened + * @param fileContent is a version of the file content that is known to be more up to date than the one on disk + */ Session.prototype.openClientFile = function (fileName, fileContent, scriptKind, projectRootPath) { - this.projectService.openClientFileWithNormalizedPath(fileName, fileContent, scriptKind, false, projectRootPath); + this.projectService.openClientFileWithNormalizedPath(fileName, fileContent, scriptKind, /*hasMixedContent*/ false, projectRootPath); }; Session.prototype.getPosition = function (args, scriptInfo) { return args.position !== undefined ? args.position : scriptInfo.lineOffsetToPosition(args.line, args.offset); @@ -126939,6 +128751,8 @@ var ts; return this.getFileAndProjectWorker(args.file, args.projectFileName); }; Session.prototype.getFileAndLanguageServiceForSyntacticOperation = function (args) { + // Since this is syntactic operation, there should always be project for the file + // we wouldnt have to ensure project but rather throw if we dont get project var file = server.toNormalizedPath(args.file); var project = this.getProject(args.projectFileName) || this.projectService.tryGetDefaultProjectForFile(file); if (!project) { @@ -126946,7 +128760,7 @@ var ts; } return { file: file, - languageService: project.getLanguageService(false) + languageService: project.getLanguageService(/*ensureSynchronized*/ false) }; }; Session.prototype.getFileAndProjectWorker = function (uncheckedFileName, projectFileName) { @@ -127039,6 +128853,7 @@ var ts; var scriptInfo = this.projectService.getScriptInfoForNormalizedPath(file); var startPosition = scriptInfo.lineOffsetToPosition(args.line, args.offset); var endPosition = scriptInfo.lineOffsetToPosition(args.endLine, args.endOffset); + // TODO: avoid duplicate code (with formatonkey) var edits = languageService.getFormattingEditsForRange(file, startPosition, endPosition, this.getFormatOptions(file)); if (!edits) { return undefined; @@ -127048,7 +128863,7 @@ var ts; Session.prototype.getFormattingEditsForRangeFull = function (args) { var _a = this.getFileAndLanguageServiceForSyntacticOperation(args), file = _a.file, languageService = _a.languageService; var options = args.options ? server.convertFormatOptions(args.options) : this.getFormatOptions(file); - return languageService.getFormattingEditsForRange(file, args.position, args.endPosition, options); + return languageService.getFormattingEditsForRange(file, args.position, args.endPosition, options); // TODO: GH#18217 }; Session.prototype.getFormattingEditsForDocumentFull = function (args) { var _a = this.getFileAndLanguageServiceForSyntacticOperation(args), file = _a.file, languageService = _a.languageService; @@ -127058,7 +128873,7 @@ var ts; Session.prototype.getFormattingEditsAfterKeystrokeFull = function (args) { var _a = this.getFileAndLanguageServiceForSyntacticOperation(args), file = _a.file, languageService = _a.languageService; var options = args.options ? server.convertFormatOptions(args.options) : this.getFormatOptions(file); - return languageService.getFormattingEditsAfterKeystroke(file, args.position, args.key, options); + return languageService.getFormattingEditsAfterKeystroke(file, args.position, args.key, options); // TODO: GH#18217 }; Session.prototype.getFormattingEditsAfterKeystroke = function (args) { var _a = this.getFileAndLanguageServiceForSyntacticOperation(args), file = _a.file, languageService = _a.languageService; @@ -127066,6 +128881,12 @@ var ts; var position = scriptInfo.lineOffsetToPosition(args.line, args.offset); var formatOptions = this.getFormatOptions(file); var edits = languageService.getFormattingEditsAfterKeystroke(file, position, args.key, formatOptions); + // Check whether we should auto-indent. This will be when + // the position is on a line containing only whitespace. + // This should leave the edits returned from + // getFormattingEditsAfterKeystroke either empty or pertaining + // only to the previous line. If all this is true, then + // add edits necessary to properly indent the current line. if ((args.key === "\n") && ((!edits) || (edits.length === 0) || allEditsBeforePos(edits, position))) { var _b = scriptInfo.getAbsolutePositionAndLineText(args.line), lineText = _b.lineText, absolutePosition = _b.absolutePosition; if (lineText && lineText.search("\\S") < 0) { @@ -127077,12 +128898,13 @@ var ts; hasIndent++; } else if (lineText.charAt(i) === "\t") { - hasIndent += formatOptions.tabSize; + hasIndent += formatOptions.tabSize; // TODO: GH#18217 } else { break; } } + // i points to the first non whitespace character if (preferredIndent !== hasIndent) { var firstNoWhiteSpacePosition = absolutePosition + i; edits.push({ @@ -127111,17 +128933,18 @@ var ts; var completions = project.getLanguageService().getCompletionsAtPosition(file, position, __assign({}, server.convertUserPreferences(this.getPreferences(file)), { triggerCharacter: args.triggerCharacter, includeExternalModuleExports: args.includeExternalModuleExports, includeInsertTextCompletions: args.includeInsertTextCompletions })); if (completions === undefined) return undefined; - if (kind === "completions-full") + if (kind === "completions-full" /* CompletionsFull */) return completions; var prefix = args.prefix || ""; var entries = ts.mapDefined(completions.entries, function (entry) { if (completions.isMemberCompletion || ts.startsWith(entry.name.toLowerCase(), prefix.toLowerCase())) { var name = entry.name, kind_1 = entry.kind, kindModifiers = entry.kindModifiers, sortText = entry.sortText, insertText = entry.insertText, replacementSpan = entry.replacementSpan, hasAction = entry.hasAction, source = entry.source, isRecommended = entry.isRecommended; var convertedSpan = replacementSpan ? _this.toLocationTextSpan(replacementSpan, scriptInfo) : undefined; + // Use `hasAction || undefined` to avoid serializing `false`. return { name: name, kind: kind_1, kindModifiers: kindModifiers, sortText: sortText, insertText: insertText, replacementSpan: convertedSpan, hasAction: hasAction || undefined, source: source, isRecommended: isRecommended }; } }).sort(function (a, b) { return ts.compareStringsCaseSensitiveUI(a.name, b.name); }); - if (kind === "completions") { + if (kind === "completions" /* Completions */) { if (completions.metadata) entries.metadata = completions.metadata; return entries; @@ -127145,7 +128968,7 @@ var ts; }; Session.prototype.getCompileOnSaveAffectedFileList = function (args) { var _this = this; - var projects = this.getProjects(args, true, true); + var projects = this.getProjects(args, /*getScriptInfoEnsuringProjectsUptoDate*/ true, /*ignoreNoProjectError*/ true); var info = this.projectService.getScriptInfo(args.file); if (!info) { return server.emptyArray; @@ -127225,7 +129048,7 @@ var ts; this.changeSeq++; this.projectService.applyChangesToFile(scriptInfo, [{ span: { start: start, length: end - start }, - newText: args.insertString + newText: args.insertString // TODO: GH#18217 }]); } }; @@ -127235,8 +129058,9 @@ var ts; var info = this.projectService.getScriptInfoForNormalizedPath(file); if (info) { this.changeSeq++; + // make sure no changes happen before this one is finished if (info.reloadFromFile(tempFileName)) { - this.doOutput(undefined, server.CommandNames.Reload, reqSeq, true); + this.doOutput(/*info*/ undefined, server.CommandNames.Reload, reqSeq, /*success*/ true); } } }; @@ -127334,7 +129158,7 @@ var ts; } else { return combineProjectOutputWhileOpeningReferencedProjects(this.getProjects(args), this.getDefaultProject(args), function (project) { - return project.getLanguageService().getNavigateToItems(searchValue, maxResultCount, undefined, project.isNonTsProject()); + return project.getLanguageService().getNavigateToItems(searchValue, maxResultCount, /*fileName*/ undefined, /*excludeDts*/ project.isNonTsProject()); }, documentSpanLocation, navigateToItemIsEqualTo); } function navigateToItemIsEqualTo(a, b) { @@ -127446,7 +129270,7 @@ var ts; } }; Session.prototype.applyCodeActionCommand = function (args) { - var commands = args.command; + var commands = args.command; // They should be sending back the command we sent them. for (var _i = 0, _a = ts.toArray(commands); _i < _a.length; _i++) { var command = _a[_i]; var _b = this.getFileAndProject(command), file = _b.file, project = _b.project; @@ -127461,6 +129285,7 @@ var ts; } else { startPosition = scriptInfo.lineOffsetToPosition(args.startLine, args.startOffset); + // save the result so we don't always recompute args.startPosition = startPosition; } if (args.endPosition !== undefined) { @@ -127487,7 +129312,7 @@ var ts; Session.prototype.mapTextChangeToCodeEdit = function (textChanges) { var scriptInfo = this.projectService.getScriptInfoOrConfig(textChanges.fileName); if (!!textChanges.isNewFile === !!scriptInfo) { - if (!scriptInfo) { + if (!scriptInfo) { // and !isNewFile this.projectService.logErrorForScriptInfoNotFound(textChanges.fileName); } ts.Debug.fail("Expected isNewFile for (only) new files. " + JSON.stringify({ isNewFile: !!textChanges.isNewFile, hasScriptInfo: !!scriptInfo })); @@ -127519,14 +129344,16 @@ var ts; if (this.suppressDiagnosticEvents) { return; } - var _a = this.getProjectInfoWorker(fileName, undefined, true, true), fileNames = _a.fileNames, languageServiceDisabled = _a.languageServiceDisabled; + var _a = this.getProjectInfoWorker(fileName, /*projectFileName*/ undefined, /*needFileNameList*/ true, /*excludeConfigFiles*/ true), fileNames = _a.fileNames, languageServiceDisabled = _a.languageServiceDisabled; if (languageServiceDisabled) { return; } - var fileNamesInProject = fileNames.filter(function (value) { return !ts.stringContains(value, "lib.d.ts"); }); + // No need to analyze lib.d.ts + var fileNamesInProject = fileNames.filter(function (value) { return !ts.stringContains(value, "lib.d.ts"); }); // TODO: GH#18217 if (fileNamesInProject.length === 0) { return; } + // Sort the file name list to make the recently touched files come first var highPriorityFiles = []; var mediumPriorityFiles = []; var lowPriorityFiles = []; @@ -127539,9 +129366,9 @@ var ts; highPriorityFiles.push(fileNameInProject); } else { - var info = this.projectService.getScriptInfo(fileNameInProject); + var info = this.projectService.getScriptInfo(fileNameInProject); // TODO: GH#18217 if (!info.isScriptOpen()) { - if (ts.fileExtensionIs(fileNameInProject, ".d.ts")) { + if (ts.fileExtensionIs(fileNameInProject, ".d.ts" /* Dts */)) { veryLowPriorityFiles.push(fileNameInProject); } else { @@ -127555,7 +129382,9 @@ var ts; } var sortedFiles = highPriorityFiles.concat(mediumPriorityFiles, lowPriorityFiles, veryLowPriorityFiles); var checkList = sortedFiles.map(function (fileName) { return ({ fileName: fileName, project: project }); }); - this.updateErrorCheck(next, checkList, delay, false); + // Project level error analysis runs on background files too, therefore + // doesn't require the file to be opened + this.updateErrorCheck(next, checkList, delay, /*requireOpen*/ false); }; Session.prototype.configurePlugin = function (args) { this.projectService.configurePlugin(args); @@ -127584,7 +129413,7 @@ var ts; }; Session.prototype.resetCurrentRequest = function (requestId) { ts.Debug.assert(this.currentRequestId === requestId); - this.currentRequestId = undefined; + this.currentRequestId = undefined; // TODO: GH#18217 this.cancellationToken.resetRequest(requestId); }; Session.prototype.executeWithRequestId = function (requestId, f) { @@ -127603,7 +129432,7 @@ var ts; } else { this.logger.msg("Unrecognized JSON command:" + server.stringifyIndented(request), server.Msg.Err); - this.doOutput(undefined, server.CommandNames.Unknown, request.seq, false, "Unrecognized JSON command: " + request.command); + this.doOutput(/*info*/ undefined, server.CommandNames.Unknown, request.seq, /*success*/ false, "Unrecognized JSON command: " + request.command); return { responseRequired: false }; } }; @@ -127632,19 +129461,22 @@ var ts; } } if (response) { - this.doOutput(response, request.command, request.seq, true); + this.doOutput(response, request.command, request.seq, /*success*/ true); } else if (responseRequired) { - this.doOutput(undefined, request.command, request.seq, false, "No content available."); + this.doOutput(/*info*/ undefined, request.command, request.seq, /*success*/ false, "No content available."); } } catch (err) { if (err instanceof ts.OperationCanceledException) { - this.doOutput({ canceled: true }, request.command, request.seq, true); + // Handle cancellation exceptions + this.doOutput({ canceled: true }, request.command, request.seq, /*success*/ true); return; } this.logErrorWorker(err, message, relevantFile); - this.doOutput(undefined, request ? request.command : server.CommandNames.Unknown, request ? request.seq : 0, false, "Error processing request. " + err.message + "\n" + err.stack); + this.doOutput( + /*info*/ undefined, request ? request.command : server.CommandNames.Unknown, request ? request.seq : 0, + /*success*/ false, "Error processing request. " + err.message + "\n" + err.stack); } }; Session.prototype.getFormatOptions = function (file) { @@ -127680,6 +129512,7 @@ var ts; ts.Debug.assert(change.span.start === 0 && change.span.length === 0); return { fileName: textChanges.fileName, textChanges: [{ start: { line: 0, offset: 0 }, end: { line: 0, offset: 0 }, newText: change.newText }] }; } + /* @internal */ // Exported only for tests function getLocationInNewDocument(oldText, renameFilename, renameLocation, edits) { var newText = applyEdits(oldText, renameFilename, edits); var _a = ts.computeLineAndCharacterOfPosition(ts.computeLineStarts(newText), renameLocation), line = _a.line, character = _a.character; @@ -127701,6 +129534,7 @@ var ts; } })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); +/*@internal*/ var ts; (function (ts) { var server; @@ -127715,12 +129549,12 @@ var ts; CharRangeSection[CharRangeSection["End"] = 4] = "End"; CharRangeSection[CharRangeSection["PostEnd"] = 5] = "PostEnd"; })(CharRangeSection || (CharRangeSection = {})); - var EditWalker = (function () { + var EditWalker = /** @class */ (function () { function EditWalker() { this.goSubtree = true; this.lineIndex = new LineIndex(); this.endBranch = []; - this.state = 2; + this.state = 2 /* Entire */; this.initialText = ""; this.trailingText = ""; this.lineIndex.root = new LineNode(); @@ -127766,6 +129600,7 @@ var ts; if (lastZeroCount) { branchParent.remove(lastZeroCount); } + // path at least length two (root and leaf) var leafNode = this.startPath[this.startPath.length - 1]; if (lines.length > 0) { leafNode.text = lines[0]; @@ -127800,6 +129635,7 @@ var ts; } else { var insertionNode = this.startPath[this.startPath.length - 2]; + // no content for leaf node, so delete it insertionNode.remove(leafNode); for (var j = this.startPath.length - 2; j >= 0; j--) { this.startPath[j].updateCounts(); @@ -127808,15 +129644,20 @@ var ts; return this.lineIndex; }; EditWalker.prototype.post = function (_relativeStart, _relativeLength, lineCollection) { + // have visited the path for start of range, now looking for end + // if range is on single line, we will never make this state transition if (lineCollection === this.lineCollectionAtBranch) { - this.state = 4; + this.state = 4 /* End */; } + // always pop stack because post only called when child has been visited this.stack.pop(); }; EditWalker.prototype.pre = function (_relativeStart, _relativeLength, lineCollection, _parent, nodeType) { + // currentNode corresponds to parent, but in the new tree var currentNode = this.stack[this.stack.length - 1]; - if ((this.state === 2) && (nodeType === 1)) { - this.state = 1; + if ((this.state === 2 /* Entire */) && (nodeType === 1 /* Start */)) { + // if range is on single line, we will never make this state transition + this.state = 1 /* Start */; this.branchNode = currentNode; this.lineCollectionAtBranch = lineCollection; } @@ -127829,14 +129670,14 @@ var ts; return new LineNode(); } switch (nodeType) { - case 0: + case 0 /* PreStart */: this.goSubtree = false; - if (this.state !== 4) { + if (this.state !== 4 /* End */) { currentNode.add(lineCollection); } break; - case 1: - if (this.state === 4) { + case 1 /* Start */: + if (this.state === 4 /* End */) { this.goSubtree = false; } else { @@ -127845,8 +129686,8 @@ var ts; this.startPath.push(child); } break; - case 2: - if (this.state !== 4) { + case 2 /* Entire */: + if (this.state !== 4 /* End */) { child = fresh(lineCollection); currentNode.add(child); this.startPath.push(child); @@ -127859,11 +129700,11 @@ var ts; } } break; - case 3: + case 3 /* Mid */: this.goSubtree = false; break; - case 4: - if (this.state !== 4) { + case 4 /* End */: + if (this.state !== 4 /* End */) { this.goSubtree = false; } else { @@ -127874,9 +129715,9 @@ var ts; } } break; - case 5: + case 5 /* PostEnd */: this.goSubtree = false; - if (this.state !== 1) { + if (this.state !== 1 /* Start */) { currentNode.add(lineCollection); } break; @@ -127885,21 +129726,24 @@ var ts; this.stack.push(child); } }; + // just gather text from the leaves EditWalker.prototype.leaf = function (relativeStart, relativeLength, ll) { - if (this.state === 1) { + if (this.state === 1 /* Start */) { this.initialText = ll.text.substring(0, relativeStart); } - else if (this.state === 2) { + else if (this.state === 2 /* Entire */) { this.initialText = ll.text.substring(0, relativeStart); this.trailingText = ll.text.substring(relativeStart + relativeLength); } else { + // state is CharRangeSection.End this.trailingText = ll.text.substring(relativeStart + relativeLength); } }; return EditWalker; }()); - var TextChange = (function () { + // text change information + var TextChange = /** @class */ (function () { function TextChange(pos, deleteLen, insertedText) { this.pos = pos; this.deleteLen = deleteLen; @@ -127910,11 +129754,11 @@ var ts; }; return TextChange; }()); - var ScriptVersionCache = (function () { + var ScriptVersionCache = /** @class */ (function () { function ScriptVersionCache() { this.changes = []; this.versions = new Array(ScriptVersionCache.maxVersions); - this.minVersion = 0; + this.minVersion = 0; // no versions earlier than min version will maintain change history this.currentVersion = 0; } ScriptVersionCache.prototype.versionToIndex = function (version) { @@ -127926,6 +129770,7 @@ var ts; ScriptVersionCache.prototype.currentVersionToIndex = function () { return this.currentVersion % ScriptVersionCache.maxVersions; }; + // REVIEW: can optimize by coalescing simple edits ScriptVersionCache.prototype.edit = function (pos, deleteLen, insertedText) { this.changes.push(new TextChange(pos, deleteLen, insertedText)); if (this.changes.length > ScriptVersionCache.changeNumberThreshold || @@ -127976,7 +129821,7 @@ var ts; if (oldVersion >= this.minVersion) { var textChangeRanges = []; for (var i = oldVersion + 1; i <= newVersion; i++) { - var snap = this.versions[this.versionToIndex(i)]; + var snap = this.versions[this.versionToIndex(i)]; // TODO: GH#18217 for (var _i = 0, _a = snap.changesSincePreviousVersion; _i < _a.length; _i++) { var textChange = _a[_i]; textChangeRanges.push(textChange.getTextChangeRange()); @@ -128009,7 +129854,7 @@ var ts; return ScriptVersionCache; }()); server.ScriptVersionCache = ScriptVersionCache; - var LineIndexSnapshot = (function () { + var LineIndexSnapshot = /** @class */ (function () { function LineIndexSnapshot(version, cache, index, changesSincePreviousVersion) { if (changesSincePreviousVersion === void 0) { changesSincePreviousVersion = server.emptyArray; } this.version = version; @@ -128035,8 +129880,9 @@ var ts; }; return LineIndexSnapshot; }()); - var LineIndex = (function () { + var LineIndex = /** @class */ (function () { function LineIndex() { + // set this to true to check each edit for accuracy this.checkEdits = false; } LineIndex.prototype.absolutePositionOfStartOfLine = function (oneBasedLine) { @@ -128111,12 +129957,12 @@ var ts; }; LineIndex.prototype.edit = function (pos, deleteLength, newText) { if (this.root.charCount() === 0) { - ts.Debug.assert(deleteLength === 0); + ts.Debug.assert(deleteLength === 0); // Can't delete from empty document if (newText !== undefined) { this.load(LineIndex.linesFromText(newText).lines); return this; } - return undefined; + return undefined; // TODO: GH#18217 } else { var checkText = void 0; @@ -128127,6 +129973,7 @@ var ts; var walker = new EditWalker(); var suppressTrailingText = false; if (pos >= this.root.charCount()) { + // insert at end pos = this.root.charCount() - 1; var endString = this.getText(pos, 1); if (newText) { @@ -128139,10 +129986,13 @@ var ts; suppressTrailingText = true; } else if (deleteLength > 0) { + // check whether last characters deleted are line break var e = pos + deleteLength; var _a = this.positionToColumnAndLineText(e), zeroBasedColumn = _a.zeroBasedColumn, lineText = _a.lineText; if (zeroBasedColumn === 0) { - deleteLength += lineText.length; + // move range end just past line that will merge with previous line + deleteLength += lineText.length; // TODO: GH#18217 + // store text by appending to end of insertedText newText = newText ? newText + lineText : lineText; } } @@ -128190,7 +130040,7 @@ var ts; return LineIndex; }()); server.LineIndex = LineIndex; - var LineNode = (function () { + var LineNode = /** @class */ (function () { function LineNode(children) { if (children === void 0) { children = []; } this.children = children; @@ -128233,22 +130083,26 @@ var ts; } }; LineNode.prototype.walk = function (rangeStart, rangeLength, walkFns) { + // assume (rangeStart < this.totalChars) && (rangeLength <= this.totalChars) var childIndex = 0; var childCharCount = this.children[childIndex].charCount(); + // find sub-tree containing start var adjustedStart = rangeStart; while (adjustedStart >= childCharCount) { - this.skipChild(adjustedStart, rangeLength, childIndex, walkFns, 0); + this.skipChild(adjustedStart, rangeLength, childIndex, walkFns, 0 /* PreStart */); adjustedStart -= childCharCount; childIndex++; childCharCount = this.children[childIndex].charCount(); } + // Case I: both start and end of range in same subtree if ((adjustedStart + rangeLength) <= childCharCount) { - if (this.execWalk(adjustedStart, rangeLength, walkFns, childIndex, 2)) { + if (this.execWalk(adjustedStart, rangeLength, walkFns, childIndex, 2 /* Entire */)) { return; } } else { - if (this.execWalk(adjustedStart, childCharCount - adjustedStart, walkFns, childIndex, 1)) { + // Case II: start and end of range in different subtrees (possibly with subtrees in the middle) + if (this.execWalk(adjustedStart, childCharCount - adjustedStart, walkFns, childIndex, 1 /* Start */)) { return; } var adjustedLength = rangeLength - (childCharCount - adjustedStart); @@ -128256,7 +130110,7 @@ var ts; var child = this.children[childIndex]; childCharCount = child.charCount(); while (adjustedLength > childCharCount) { - if (this.execWalk(0, childCharCount, walkFns, childIndex, 3)) { + if (this.execWalk(0, childCharCount, walkFns, childIndex, 3 /* Mid */)) { return; } adjustedLength -= childCharCount; @@ -128264,22 +130118,26 @@ var ts; childCharCount = this.children[childIndex].charCount(); } if (adjustedLength > 0) { - if (this.execWalk(0, adjustedLength, walkFns, childIndex, 4)) { + if (this.execWalk(0, adjustedLength, walkFns, childIndex, 4 /* End */)) { return; } } } + // Process any subtrees after the one containing range end if (walkFns.pre) { var clen = this.children.length; if (childIndex < (clen - 1)) { for (var ej = childIndex + 1; ej < clen; ej++) { - this.skipChild(0, 0, ej, walkFns, 5); + this.skipChild(0, 0, ej, walkFns, 5 /* PostEnd */); } } } }; + // Input position is relative to the start of this node. + // Output line number is absolute. LineNode.prototype.charOffsetToLineInfo = function (lineNumberAccumulator, relativePosition) { if (this.children.length === 0) { + // Root node might have no children if this is an empty document. return { oneBasedLine: lineNumberAccumulator, zeroBasedColumn: relativePosition, lineText: undefined }; } for (var _i = 0, _a = this.children; _i < _a.length; _i++) { @@ -128297,9 +130155,15 @@ var ts; lineNumberAccumulator += child.lineCount(); } } + // Skipped all children var leaf = this.lineNumberToInfo(this.lineCount(), 0).leaf; return { oneBasedLine: this.lineCount(), zeroBasedColumn: leaf ? leaf.charCount() : 0, lineText: undefined }; }; + /** + * Input line number is relative to the start of this node. + * Output line number is relative to the child. + * positionAccumulator will be an absolute position once relativeLineNumber reaches 0. + */ LineNode.prototype.lineNumberToInfo = function (relativeOneBasedLine, positionAccumulator) { for (var _i = 0, _a = this.children; _i < _a.length; _i++) { var child = _a[_i]; @@ -128349,6 +130213,7 @@ var ts; var childIndex = this.findChildIndex(child); var clen = this.children.length; var nodeCount = nodes.length; + // if child is last and there is more room and only one node to place, place it if ((clen < lineCollectionCapacity) && (childIndex === (clen - 1)) && (nodeCount === 1)) { this.add(nodes[0]); this.updateCounts(); @@ -128397,6 +130262,7 @@ var ts; return splitNodes; } }; + // assume there is room for the item; return true if more room LineNode.prototype.add = function (collection) { this.children.push(collection); ts.Debug.assert(this.children.length <= lineCollectionCapacity); @@ -128409,7 +130275,7 @@ var ts; }; return LineNode; }()); - var LineLeaf = (function () { + var LineLeaf = /** @class */ (function () { function LineLeaf(text) { this.text = text; } diff --git a/lib/tsserverlibrary.d.ts b/lib/tsserverlibrary.d.ts index fab6f905efc..338d1827411 100644 --- a/lib/tsserverlibrary.d.ts +++ b/lib/tsserverlibrary.d.ts @@ -355,40 +355,45 @@ declare namespace ts { ShorthandPropertyAssignment = 276, SpreadAssignment = 277, EnumMember = 278, - SourceFile = 279, - Bundle = 280, - UnparsedSource = 281, - InputFiles = 282, - JSDocTypeExpression = 283, - JSDocAllType = 284, - JSDocUnknownType = 285, - JSDocNullableType = 286, - JSDocNonNullableType = 287, - JSDocOptionalType = 288, - JSDocFunctionType = 289, - JSDocVariadicType = 290, - JSDocComment = 291, - JSDocTypeLiteral = 292, - JSDocSignature = 293, - JSDocTag = 294, - JSDocAugmentsTag = 295, - JSDocClassTag = 296, - JSDocCallbackTag = 297, - JSDocEnumTag = 298, - JSDocParameterTag = 299, - JSDocReturnTag = 300, - JSDocThisTag = 301, - JSDocTypeTag = 302, - JSDocTemplateTag = 303, - JSDocTypedefTag = 304, - JSDocPropertyTag = 305, - SyntaxList = 306, - NotEmittedStatement = 307, - PartiallyEmittedExpression = 308, - CommaListExpression = 309, - MergeDeclarationMarker = 310, - EndOfDeclarationMarker = 311, - Count = 312, + UnparsedPrologue = 279, + UnparsedPrepend = 280, + UnparsedText = 281, + UnparsedInternalText = 282, + UnparsedSyntheticReference = 283, + SourceFile = 284, + Bundle = 285, + UnparsedSource = 286, + InputFiles = 287, + JSDocTypeExpression = 288, + JSDocAllType = 289, + JSDocUnknownType = 290, + JSDocNullableType = 291, + JSDocNonNullableType = 292, + JSDocOptionalType = 293, + JSDocFunctionType = 294, + JSDocVariadicType = 295, + JSDocComment = 296, + JSDocTypeLiteral = 297, + JSDocSignature = 298, + JSDocTag = 299, + JSDocAugmentsTag = 300, + JSDocClassTag = 301, + JSDocCallbackTag = 302, + JSDocEnumTag = 303, + JSDocParameterTag = 304, + JSDocReturnTag = 305, + JSDocThisTag = 306, + JSDocTypeTag = 307, + JSDocTemplateTag = 308, + JSDocTypedefTag = 309, + JSDocPropertyTag = 310, + SyntaxList = 311, + NotEmittedStatement = 312, + PartiallyEmittedExpression = 313, + CommaListExpression = 314, + MergeDeclarationMarker = 315, + EndOfDeclarationMarker = 316, + Count = 317, FirstAssignment = 59, LastAssignment = 71, FirstCompoundAssignment = 60, @@ -414,10 +419,10 @@ declare namespace ts { FirstBinaryOperator = 28, LastBinaryOperator = 71, FirstNode = 148, - FirstJSDocNode = 283, - LastJSDocNode = 305, - FirstJSDocTagNode = 294, - LastJSDocTagNode = 305 + FirstJSDocNode = 288, + LastJSDocNode = 310, + FirstJSDocTagNode = 299, + LastJSDocTagNode = 310 } enum NodeFlags { None = 0, @@ -1745,10 +1750,44 @@ declare namespace ts { } interface UnparsedSource extends Node { kind: SyntaxKind.UnparsedSource; - fileName?: string; + fileName: string; text: string; + prologues: ReadonlyArray; + helpers: ReadonlyArray | undefined; + referencedFiles: ReadonlyArray; + typeReferenceDirectives: ReadonlyArray | undefined; + libReferenceDirectives: ReadonlyArray; + hasNoDefaultLib?: boolean; sourceMapPath?: string; sourceMapText?: string; + syntheticReferences?: ReadonlyArray; + texts: ReadonlyArray; + } + type UnparsedSourceText = UnparsedPrepend | UnparsedTextLike; + type UnparsedNode = UnparsedPrologue | UnparsedSourceText | UnparsedSyntheticReference; + interface UnparsedSection extends Node { + kind: SyntaxKind; + data?: string; + parent: UnparsedSource; + } + interface UnparsedPrologue extends UnparsedSection { + kind: SyntaxKind.UnparsedPrologue; + data: string; + parent: UnparsedSource; + } + interface UnparsedPrepend extends UnparsedSection { + kind: SyntaxKind.UnparsedPrepend; + data: string; + parent: UnparsedSource; + texts: ReadonlyArray; + } + interface UnparsedTextLike extends UnparsedSection { + kind: SyntaxKind.UnparsedText | SyntaxKind.UnparsedInternalText; + parent: UnparsedSource; + } + interface UnparsedSyntheticReference extends UnparsedSection { + kind: SyntaxKind.UnparsedSyntheticReference; + parent: UnparsedSource; } interface JsonSourceFile extends SourceFile { statements: NodeArray; @@ -2503,6 +2542,8 @@ declare namespace ts { reactNamespace?: string; jsxFactory?: string; composite?: boolean; + incremental?: boolean; + tsBuildInfoFile?: string; removeComments?: boolean; rootDir?: string; rootDirs?: string[]; @@ -2679,7 +2720,8 @@ declare namespace ts { Dts = ".d.ts", Js = ".js", Jsx = ".jsx", - Json = ".json" + Json = ".json", + TsBuildInfo = ".tsbuildinfo" } interface ResolvedModuleWithFailedLookupLocations { readonly resolvedModule: ResolvedModuleFull | undefined; @@ -2760,6 +2802,10 @@ declare namespace ts { readonly text: string | ((node: EmitHelperUniqueNameCallback) => string); readonly priority?: number; } + interface UnscopedEmitHelper extends EmitHelper { + readonly scoped: false; + readonly text: string; + } type EmitHelperUniqueNameCallback = (name: string) => string; enum EmitHint { SourceFile = 0, @@ -3459,6 +3505,9 @@ declare namespace ts { function isSourceFile(node: Node): node is SourceFile; function isBundle(node: Node): node is Bundle; function isUnparsedSource(node: Node): node is UnparsedSource; + function isUnparsedPrepend(node: Node): node is UnparsedPrepend; + function isUnparsedTextLike(node: Node): node is UnparsedTextLike; + function isUnparsedNode(node: Node): node is UnparsedNode; function isJSDocTypeExpression(node: Node): node is JSDocTypeExpression; function isJSDocAllType(node: JSDocAllType): node is JSDocAllType; function isJSDocUnknownType(node: Node): node is JSDocUnknownType; @@ -3994,10 +4043,10 @@ declare namespace ts { function updateCommaList(node: CommaListExpression, elements: ReadonlyArray): CommaListExpression; function createBundle(sourceFiles: ReadonlyArray, prepends?: ReadonlyArray): Bundle; function createUnparsedSourceFile(text: string): UnparsedSource; - function createUnparsedSourceFile(inputFile: InputFiles, type: "js" | "dts"): UnparsedSource; + function createUnparsedSourceFile(inputFile: InputFiles, type: "js" | "dts", stripInternal?: boolean): UnparsedSource; function createUnparsedSourceFile(text: string, mapPath: string | undefined, map: string | undefined): UnparsedSource; function createInputFiles(javascriptText: string, declarationText: string): InputFiles; - function createInputFiles(readFileText: (path: string) => string | undefined, javascriptPath: string, javascriptMapPath: string | undefined, declarationPath: string, declarationMapPath: string | undefined): InputFiles; + function createInputFiles(readFileText: (path: string) => string | undefined, javascriptPath: string, javascriptMapPath: string | undefined, declarationPath: string, declarationMapPath: string | undefined, buildInfoPath: string | undefined): InputFiles; function createInputFiles(javascriptText: string, declarationText: string, javascriptMapPath: string | undefined, javascriptMapText: string | undefined, declarationMapPath: string | undefined, declarationMapText: string | undefined): InputFiles; function updateBundle(node: Bundle, sourceFiles: ReadonlyArray, prepends?: ReadonlyArray): Bundle; function createImmediatelyInvokedFunctionExpression(statements: ReadonlyArray): CallExpression; @@ -8355,7 +8404,7 @@ declare namespace ts.server { excludedFiles: ReadonlyArray; private typeAcquisition; updateGraph(): boolean; - getExcludedFiles(): ReadonlyArray; + getExcludedFiles(): readonly NormalizedPath[]; getTypeAcquisition(): TypeAcquisition; setTypeAcquisition(newTypeAcquisition: TypeAcquisition): void; } diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js index e6bc5dd0d83..bc32404f38b 100644 --- a/lib/tsserverlibrary.js +++ b/lib/tsserverlibrary.js @@ -2876,47 +2876,53 @@ var ts; SyntaxKind[SyntaxKind["SpreadAssignment"] = 277] = "SpreadAssignment"; // Enum SyntaxKind[SyntaxKind["EnumMember"] = 278] = "EnumMember"; + // Unparsed + SyntaxKind[SyntaxKind["UnparsedPrologue"] = 279] = "UnparsedPrologue"; + SyntaxKind[SyntaxKind["UnparsedPrepend"] = 280] = "UnparsedPrepend"; + SyntaxKind[SyntaxKind["UnparsedText"] = 281] = "UnparsedText"; + SyntaxKind[SyntaxKind["UnparsedInternalText"] = 282] = "UnparsedInternalText"; + SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 283] = "UnparsedSyntheticReference"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 279] = "SourceFile"; - SyntaxKind[SyntaxKind["Bundle"] = 280] = "Bundle"; - SyntaxKind[SyntaxKind["UnparsedSource"] = 281] = "UnparsedSource"; - SyntaxKind[SyntaxKind["InputFiles"] = 282] = "InputFiles"; + SyntaxKind[SyntaxKind["SourceFile"] = 284] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 285] = "Bundle"; + SyntaxKind[SyntaxKind["UnparsedSource"] = 286] = "UnparsedSource"; + SyntaxKind[SyntaxKind["InputFiles"] = 287] = "InputFiles"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 283] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 288] = "JSDocTypeExpression"; // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 284] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 289] = "JSDocAllType"; // The ? type - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 285] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 286] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 287] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 288] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 289] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 290] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 291] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 292] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocSignature"] = 293] = "JSDocSignature"; - SyntaxKind[SyntaxKind["JSDocTag"] = 294] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 295] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocClassTag"] = 296] = "JSDocClassTag"; - SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 297] = "JSDocCallbackTag"; - SyntaxKind[SyntaxKind["JSDocEnumTag"] = 298] = "JSDocEnumTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 299] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 300] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocThisTag"] = 301] = "JSDocThisTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 302] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 303] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 304] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 305] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 290] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 291] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 292] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 293] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 294] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 295] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 296] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 297] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocSignature"] = 298] = "JSDocSignature"; + SyntaxKind[SyntaxKind["JSDocTag"] = 299] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 300] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocClassTag"] = 301] = "JSDocClassTag"; + SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 302] = "JSDocCallbackTag"; + SyntaxKind[SyntaxKind["JSDocEnumTag"] = 303] = "JSDocEnumTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 304] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 305] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocThisTag"] = 306] = "JSDocThisTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 307] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 308] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 309] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 310] = "JSDocPropertyTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 306] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 311] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 307] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 308] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["CommaListExpression"] = 309] = "CommaListExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 310] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 311] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 312] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 313] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["CommaListExpression"] = 314] = "CommaListExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 315] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 316] = "EndOfDeclarationMarker"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 312] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 317] = "Count"; // Markers SyntaxKind[SyntaxKind["FirstAssignment"] = 59] = "FirstAssignment"; SyntaxKind[SyntaxKind["LastAssignment"] = 71] = "LastAssignment"; @@ -2943,10 +2949,10 @@ var ts; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 28] = "FirstBinaryOperator"; SyntaxKind[SyntaxKind["LastBinaryOperator"] = 71] = "LastBinaryOperator"; SyntaxKind[SyntaxKind["FirstNode"] = 148] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 283] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 305] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 294] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 305] = "LastJSDocTagNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 288] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 310] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 299] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 310] = "LastJSDocTagNode"; /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 118] = "FirstContextualKeyword"; /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 147] = "LastContextualKeyword"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); @@ -3823,6 +3829,7 @@ var ts; Extension["Js"] = ".js"; Extension["Jsx"] = ".jsx"; Extension["Json"] = ".json"; + Extension["TsBuildInfo"] = ".tsbuildinfo"; })(Extension = ts.Extension || (ts.Extension = {})); /* @internal */ var TransformFlags; @@ -3980,6 +3987,20 @@ var ts; EmitHint[EmitHint["Unspecified"] = 4] = "Unspecified"; EmitHint[EmitHint["EmbeddedStatement"] = 5] = "EmbeddedStatement"; })(EmitHint = ts.EmitHint || (ts.EmitHint = {})); + /*@internal*/ + var BundleFileSectionKind; + (function (BundleFileSectionKind) { + BundleFileSectionKind["Prologue"] = "prologue"; + BundleFileSectionKind["EmitHelpers"] = "emitHelpers"; + BundleFileSectionKind["NoDefaultLib"] = "no-default-lib"; + BundleFileSectionKind["Reference"] = "reference"; + BundleFileSectionKind["Type"] = "type"; + BundleFileSectionKind["Lib"] = "lib"; + BundleFileSectionKind["Prepend"] = "prepend"; + BundleFileSectionKind["Text"] = "text"; + BundleFileSectionKind["Internal"] = "internal"; + // comments? + })(BundleFileSectionKind = ts.BundleFileSectionKind || (ts.BundleFileSectionKind = {})); var ListFormat; (function (ListFormat) { ListFormat[ListFormat["None"] = 0] = "None"; @@ -6109,6 +6130,15 @@ var ts; Option_build_must_be_the_first_command_line_argument: diag(6369, ts.DiagnosticCategory.Error, "Option_build_must_be_the_first_command_line_argument_6369", "Option '--build' must be the first command line argument."), Options_0_and_1_cannot_be_combined: diag(6370, ts.DiagnosticCategory.Error, "Options_0_and_1_cannot_be_combined_6370", "Options '{0}' and '{1}' cannot be combined."), Updating_unchanged_output_timestamps_of_project_0: diag(6371, ts.DiagnosticCategory.Message, "Updating_unchanged_output_timestamps_of_project_0_6371", "Updating unchanged output timestamps of project '{0}'..."), + Project_0_is_out_of_date_because_output_of_its_dependency_1_has_changed: diag(6372, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_output_of_its_dependency_1_has_changed_6372", "Project '{0}' is out of date because output of its dependency '{1}' has changed"), + Updating_output_of_project_0: diag(6373, ts.DiagnosticCategory.Message, "Updating_output_of_project_0_6373", "Updating output of project '{0}'..."), + A_non_dry_build_would_update_timestamps_for_output_of_project_0: diag(6374, ts.DiagnosticCategory.Message, "A_non_dry_build_would_update_timestamps_for_output_of_project_0_6374", "A non-dry build would update timestamps for output of project '{0}'"), + A_non_dry_build_would_update_output_of_project_0: diag(6375, ts.DiagnosticCategory.Message, "A_non_dry_build_would_update_output_of_project_0_6375", "A non-dry build would update output of project '{0}'"), + Cannot_update_output_of_project_0_because_there_was_error_reading_file_1: diag(6376, ts.DiagnosticCategory.Message, "Cannot_update_output_of_project_0_because_there_was_error_reading_file_1_6376", "Cannot update output of project '{0}' because there was error reading file '{1}'"), + Cannot_write_file_0_because_it_will_overwrite_tsbuildinfo_file_generated_by_referenced_project_1: diag(6377, ts.DiagnosticCategory.Error, "Cannot_write_file_0_because_it_will_overwrite_tsbuildinfo_file_generated_by_referenced_project_1_6377", "Cannot write file '{0}' because it will overwrite '.tsbuildinfo' file generated by referenced project '{1}'"), + Enable_incremental_compilation: diag(6378, ts.DiagnosticCategory.Message, "Enable_incremental_compilation_6378", "Enable incremental compilation"), + Composite_projects_may_not_disable_incremental_compilation: diag(6379, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_incremental_compilation_6379", "Composite projects may not disable incremental compilation."), + Specify_file_to_store_incremental_compilation_information: diag(6380, ts.DiagnosticCategory.Message, "Specify_file_to_store_incremental_compilation_information_6380", "Specify file to store incremental compilation information"), The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: diag(6500, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1_6500", "The expected type comes from property '{0}' which is declared here on type '{1}'"), The_expected_type_comes_from_this_index_signature: diag(6501, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_this_index_signature_6501", "The expected type comes from this index signature."), The_expected_type_comes_from_the_return_type_of_this_signature: diag(6502, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_the_return_type_of_this_signature_6502", "The expected type comes from the return type of this signature."), @@ -6812,16 +6842,20 @@ var ts; return pos; } var shebangTriviaRegex = /^#!.*/; + /*@internal*/ function isShebangTrivia(text, pos) { // Shebangs check must only be done at the start of the file ts.Debug.assert(pos === 0); return shebangTriviaRegex.test(text); } + ts.isShebangTrivia = isShebangTrivia; + /*@internal*/ function scanShebangTrivia(text, pos) { var shebang = shebangTriviaRegex.exec(text)[0]; pos = pos + shebang.length; return pos; } + ts.scanShebangTrivia = scanShebangTrivia; /** * Invokes a callback for each comment range following the provided position. * @@ -8531,7 +8565,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 279 /* SourceFile */) { + while (node && node.kind !== 284 /* SourceFile */) { node = node.parent; } return node; @@ -8677,7 +8711,7 @@ var ts; // the syntax list itself considers them as normal trivia. Therefore if we simply skip // trivia for the list, we may have skipped the JSDocComment as well. So we should process its // first child to determine the actual position of its first token. - if (node.kind === 306 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 311 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); @@ -8696,7 +8730,7 @@ var ts; } ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; function isJSDocTypeExpressionOrChild(node) { - return node.kind === 283 /* JSDocTypeExpression */ || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); + return node.kind === 288 /* JSDocTypeExpression */ || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); } function getTextOfNodeFromSourceText(sourceText, node, includeTrivia) { if (includeTrivia === void 0) { includeTrivia = false; } @@ -8823,7 +8857,7 @@ var ts; return node && node.kind === 244 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 279 /* SourceFile */ || + return node.kind === 284 /* SourceFile */ || node.kind === 244 /* ModuleDeclaration */ || ts.isFunctionLike(node); } @@ -8841,7 +8875,7 @@ var ts; // - defined in the top level scope and source file is an external module // - defined inside ambient module declaration located in the top level scope and source file not an external module switch (node.parent.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: return ts.isExternalModule(node.parent); case 245 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); @@ -8859,7 +8893,7 @@ var ts; ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: case 246 /* CaseBlock */: case 274 /* CatchClause */: case 244 /* ModuleDeclaration */: @@ -8884,9 +8918,9 @@ var ts; ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 297 /* JSDocCallbackTag */: - case 304 /* JSDocTypedefTag */: - case 293 /* JSDocSignature */: + case 302 /* JSDocCallbackTag */: + case 309 /* JSDocTypedefTag */: + case 298 /* JSDocSignature */: return true; default: ts.assertType(node); @@ -8902,12 +8936,12 @@ var ts; case 162 /* IndexSignature */: case 165 /* FunctionType */: case 166 /* ConstructorType */: - case 289 /* JSDocFunctionType */: + case 294 /* JSDocFunctionType */: case 240 /* ClassDeclaration */: case 209 /* ClassExpression */: case 241 /* InterfaceDeclaration */: case 242 /* TypeAliasDeclaration */: - case 303 /* JSDocTemplateTag */: + case 308 /* JSDocTemplateTag */: case 239 /* FunctionDeclaration */: case 156 /* MethodDeclaration */: case 157 /* Constructor */: @@ -9052,7 +9086,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: var pos_1 = ts.skipTrivia(sourceFile.text, 0, /*stopAfterLineBreak*/ false); if (pos_1 === sourceFile.text.length) { // file is empty - return span for the beginning of the file @@ -9227,7 +9261,7 @@ var ts; return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); case 150 /* TypeParameter */: return node === parent.constraint; - case 303 /* JSDocTemplateTag */: + case 308 /* JSDocTemplateTag */: return node === parent.constraint; case 154 /* PropertyDeclaration */: case 153 /* PropertySignature */: @@ -9487,7 +9521,7 @@ var ts; } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 279 /* SourceFile */); + ts.Debug.assert(node.kind !== 284 /* SourceFile */); while (true) { node = node.parent; if (!node) { @@ -9541,7 +9575,7 @@ var ts; case 161 /* ConstructSignature */: case 162 /* IndexSignature */: case 243 /* EnumDeclaration */: - case 279 /* SourceFile */: + case 284 /* SourceFile */: return node; } } @@ -10249,7 +10283,7 @@ var ts; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 304 /* JSDocTypedefTag */ || node.kind === 297 /* JSDocCallbackTag */; + return node.kind === 309 /* JSDocTypedefTag */ || node.kind === 302 /* JSDocCallbackTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -10393,7 +10427,7 @@ var ts; ts.hasRestParameter = hasRestParameter; function isRestParameter(node) { var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type; - return node.dotDotDotToken !== undefined || !!type && type.kind === 290 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 295 /* JSDocVariadicType */; } ts.isRestParameter = isRestParameter; var AssignmentKind; @@ -10878,7 +10912,7 @@ var ts; || kind === 158 /* GetAccessor */ || kind === 159 /* SetAccessor */ || kind === 244 /* ModuleDeclaration */ - || kind === 279 /* SourceFile */; + || kind === 284 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -10955,7 +10989,7 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 309 /* CommaListExpression */: + case 314 /* CommaListExpression */: return 0; case 208 /* SpreadElement */: return 1; @@ -11273,6 +11307,9 @@ var ts; lineStart = true; } } + function getTextPosWithWriteLine() { + return lineStart ? output.length : (output.length + newLine.length); + } reset(); return { write: write, @@ -11301,7 +11338,8 @@ var ts; writeStringLiteral: write, writeSymbol: function (s, _) { return write(s); }, writeTrailingSemicolon: write, - writeComment: write + writeComment: write, + getTextPosWithWriteLine: getTextPosWithWriteLine }; } ts.createTextWriter = createTextWriter; @@ -11592,7 +11630,7 @@ var ts; ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations; /** template tags are only available when a typedef isn't already using them */ function isNonTypeAliasTemplate(tag) { - return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 291 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 296 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node @@ -12564,19 +12602,29 @@ var ts; || kind === 96 /* NullKeyword */ || kind === 132 /* NeverKeyword */ || kind === 211 /* ExpressionWithTypeArguments */ - || kind === 284 /* JSDocAllType */ - || kind === 285 /* JSDocUnknownType */ - || kind === 286 /* JSDocNullableType */ - || kind === 287 /* JSDocNonNullableType */ - || kind === 288 /* JSDocOptionalType */ - || kind === 289 /* JSDocFunctionType */ - || kind === 290 /* JSDocVariadicType */; + || kind === 289 /* JSDocAllType */ + || kind === 290 /* JSDocUnknownType */ + || kind === 291 /* JSDocNullableType */ + || kind === 292 /* JSDocNonNullableType */ + || kind === 293 /* JSDocOptionalType */ + || kind === 294 /* JSDocFunctionType */ + || kind === 295 /* JSDocVariadicType */; } ts.isTypeNodeKind = isTypeNodeKind; function isAccessExpression(node) { return node.kind === 189 /* PropertyAccessExpression */ || node.kind === 190 /* ElementAccessExpression */; } ts.isAccessExpression = isAccessExpression; + function isBundleFileTextLike(section) { + switch (section.kind) { + case "text" /* Text */: + case "internal" /* Internal */: + return true; + default: + return false; + } + } + ts.isBundleFileTextLike = isBundleFileTextLike; })(ts || (ts = {})); (function (ts) { function getDefaultLibFileName(options) { @@ -13038,8 +13086,8 @@ var ts; switch (declaration.kind) { case 72 /* Identifier */: return declaration; - case 305 /* JSDocPropertyTag */: - case 299 /* JSDocParameterTag */: { + case 310 /* JSDocPropertyTag */: + case 304 /* JSDocParameterTag */: { var name = declaration.name; if (name.kind === 148 /* QualifiedName */) { return name.right; @@ -13063,7 +13111,7 @@ var ts; return undefined; } } - case 304 /* JSDocTypedefTag */: + case 309 /* JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); case 254 /* ExportAssignment */: { var expression = declaration.expression; @@ -13267,7 +13315,7 @@ var ts; return ts.emptyArray; } if (ts.isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 291 /* JSDocComment */); + ts.Debug.assert(node.parent.kind === 296 /* JSDocComment */); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } if (node.typeParameters) { @@ -13539,7 +13587,7 @@ var ts; } ts.isParenthesizedExpression = isParenthesizedExpression; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 308 /* PartiallyEmittedExpression */) { + while (node.kind === 313 /* PartiallyEmittedExpression */) { node = node.expression; } return node; @@ -13886,108 +13934,128 @@ var ts; ts.isEnumMember = isEnumMember; // Top-level nodes function isSourceFile(node) { - return node.kind === 279 /* SourceFile */; + return node.kind === 284 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 280 /* Bundle */; + return node.kind === 285 /* Bundle */; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 281 /* UnparsedSource */; + return node.kind === 286 /* UnparsedSource */; } ts.isUnparsedSource = isUnparsedSource; + function isUnparsedPrepend(node) { + return node.kind === 280 /* UnparsedPrepend */; + } + ts.isUnparsedPrepend = isUnparsedPrepend; + function isUnparsedTextLike(node) { + switch (node.kind) { + case 281 /* UnparsedText */: + case 282 /* UnparsedInternalText */: + return true; + default: + return false; + } + } + ts.isUnparsedTextLike = isUnparsedTextLike; + function isUnparsedNode(node) { + return isUnparsedTextLike(node) || + node.kind === 279 /* UnparsedPrologue */ || + node.kind === 283 /* UnparsedSyntheticReference */; + } + ts.isUnparsedNode = isUnparsedNode; // JSDoc function isJSDocTypeExpression(node) { - return node.kind === 283 /* JSDocTypeExpression */; + return node.kind === 288 /* JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocAllType(node) { - return node.kind === 284 /* JSDocAllType */; + return node.kind === 289 /* JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 285 /* JSDocUnknownType */; + return node.kind === 290 /* JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 286 /* JSDocNullableType */; + return node.kind === 291 /* JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 287 /* JSDocNonNullableType */; + return node.kind === 292 /* JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 288 /* JSDocOptionalType */; + return node.kind === 293 /* JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 289 /* JSDocFunctionType */; + return node.kind === 294 /* JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 290 /* JSDocVariadicType */; + return node.kind === 295 /* JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDoc(node) { - return node.kind === 291 /* JSDocComment */; + return node.kind === 296 /* JSDocComment */; } ts.isJSDoc = isJSDoc; function isJSDocAugmentsTag(node) { - return node.kind === 295 /* JSDocAugmentsTag */; + return node.kind === 300 /* JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocClassTag(node) { - return node.kind === 296 /* JSDocClassTag */; + return node.kind === 301 /* JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocEnumTag(node) { - return node.kind === 298 /* JSDocEnumTag */; + return node.kind === 303 /* JSDocEnumTag */; } ts.isJSDocEnumTag = isJSDocEnumTag; function isJSDocThisTag(node) { - return node.kind === 301 /* JSDocThisTag */; + return node.kind === 306 /* JSDocThisTag */; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocParameterTag(node) { - return node.kind === 299 /* JSDocParameterTag */; + return node.kind === 304 /* JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 300 /* JSDocReturnTag */; + return node.kind === 305 /* JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocTypeTag(node) { - return node.kind === 302 /* JSDocTypeTag */; + return node.kind === 307 /* JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 303 /* JSDocTemplateTag */; + return node.kind === 308 /* JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 304 /* JSDocTypedefTag */; + return node.kind === 309 /* JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocPropertyTag(node) { - return node.kind === 305 /* JSDocPropertyTag */; + return node.kind === 310 /* JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocPropertyLikeTag(node) { - return node.kind === 305 /* JSDocPropertyTag */ || node.kind === 299 /* JSDocParameterTag */; + return node.kind === 310 /* JSDocPropertyTag */ || node.kind === 304 /* JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; function isJSDocTypeLiteral(node) { - return node.kind === 292 /* JSDocTypeLiteral */; + return node.kind === 297 /* JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocCallbackTag(node) { - return node.kind === 297 /* JSDocCallbackTag */; + return node.kind === 302 /* JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocSignature(node) { - return node.kind === 293 /* JSDocSignature */; + return node.kind === 298 /* JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; })(ts || (ts = {})); @@ -13998,7 +14066,7 @@ var ts; (function (ts) { /* @internal */ function isSyntaxList(n) { - return n.kind === 306 /* SyntaxList */; + return n.kind === 311 /* SyntaxList */; } ts.isSyntaxList = isSyntaxList; /* @internal */ @@ -14150,11 +14218,11 @@ var ts; switch (kind) { case 155 /* MethodSignature */: case 160 /* CallSignature */: - case 293 /* JSDocSignature */: + case 298 /* JSDocSignature */: case 161 /* ConstructSignature */: case 162 /* IndexSignature */: case 165 /* FunctionType */: - case 289 /* JSDocFunctionType */: + case 294 /* JSDocFunctionType */: case 166 /* ConstructorType */: return true; default: @@ -14445,8 +14513,8 @@ var ts; case 208 /* SpreadElement */: case 212 /* AsExpression */: case 210 /* OmittedExpression */: - case 309 /* CommaListExpression */: - case 308 /* PartiallyEmittedExpression */: + case 314 /* CommaListExpression */: + case 313 /* PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -14460,12 +14528,12 @@ var ts; ts.isAssertionExpression = isAssertionExpression; /* @internal */ function isPartiallyEmittedExpression(node) { - return node.kind === 308 /* PartiallyEmittedExpression */; + return node.kind === 313 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; /* @internal */ function isNotEmittedStatement(node) { - return node.kind === 307 /* NotEmittedStatement */; + return node.kind === 312 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ @@ -14576,9 +14644,9 @@ var ts; || kind === 242 /* TypeAliasDeclaration */ || kind === 150 /* TypeParameter */ || kind === 237 /* VariableDeclaration */ - || kind === 304 /* JSDocTypedefTag */ - || kind === 297 /* JSDocCallbackTag */ - || kind === 305 /* JSDocPropertyTag */; + || kind === 309 /* JSDocTypedefTag */ + || kind === 302 /* JSDocCallbackTag */ + || kind === 310 /* JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { return kind === 239 /* FunctionDeclaration */ @@ -14613,14 +14681,14 @@ var ts; || kind === 219 /* VariableStatement */ || kind === 224 /* WhileStatement */ || kind === 231 /* WithStatement */ - || kind === 307 /* NotEmittedStatement */ - || kind === 311 /* EndOfDeclarationMarker */ - || kind === 310 /* MergeDeclarationMarker */; + || kind === 312 /* NotEmittedStatement */ + || kind === 316 /* EndOfDeclarationMarker */ + || kind === 315 /* MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { if (node.kind === 150 /* TypeParameter */) { - return node.parent.kind !== 303 /* JSDocTemplateTag */ || ts.isInJSFile(node); + return (node.parent && node.parent.kind !== 308 /* JSDocTemplateTag */) || ts.isInJSFile(node); } return isDeclarationKind(node.kind); } @@ -14715,18 +14783,18 @@ var ts; /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 283 /* FirstJSDocNode */ && node.kind <= 305 /* LastJSDocNode */; + return node.kind >= 288 /* FirstJSDocNode */ && node.kind <= 310 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 291 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 296 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); } ts.isJSDocCommentContainingNode = isJSDocCommentContainingNode; // TODO: determine what this does before making it public. /* @internal */ function isJSDocTag(node) { - return node.kind >= 294 /* FirstJSDocTagNode */ && node.kind <= 305 /* LastJSDocTagNode */; + return node.kind >= 299 /* FirstJSDocTagNode */ && node.kind <= 310 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { @@ -15043,6 +15111,10 @@ var ts; return !!(compilerOptions.declaration || compilerOptions.composite); } ts.getEmitDeclarations = getEmitDeclarations; + function isIncrementalCompilation(options) { + return !!(options.incremental || options.composite); + } + ts.isIncrementalCompilation = isIncrementalCompilation; function getStrictOptionValue(compilerOptions, flag) { return compilerOptions[flag] === undefined ? !!compilerOptions.strict : !!compilerOptions[flag]; } @@ -16327,7 +16399,7 @@ var ts; var SourceFileConstructor; // tslint:enable variable-name function createNode(kind, pos, end) { - if (kind === 279 /* SourceFile */) { + if (kind === 284 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else if (kind === 72 /* Identifier */) { @@ -16578,7 +16650,7 @@ var ts; case 218 /* Block */: case 245 /* ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 279 /* SourceFile */: + case 284 /* SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); case 219 /* VariableStatement */: @@ -16727,7 +16799,7 @@ var ts; return visitNode(cbNode, node.expression); case 258 /* MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators); - case 309 /* CommaListExpression */: + case 314 /* CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); case 260 /* JsxElement */: return visitNode(cbNode, node.openingElement) || @@ -16756,60 +16828,60 @@ var ts; return visitNode(cbNode, node.tagName); case 171 /* OptionalType */: case 172 /* RestType */: - case 283 /* JSDocTypeExpression */: - case 287 /* JSDocNonNullableType */: - case 286 /* JSDocNullableType */: - case 288 /* JSDocOptionalType */: - case 290 /* JSDocVariadicType */: + case 288 /* JSDocTypeExpression */: + case 292 /* JSDocNonNullableType */: + case 291 /* JSDocNullableType */: + case 293 /* JSDocOptionalType */: + case 295 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 289 /* JSDocFunctionType */: + case 294 /* JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 291 /* JSDocComment */: + case 296 /* JSDocComment */: return visitNodes(cbNode, cbNodes, node.tags); - case 299 /* JSDocParameterTag */: - case 305 /* JSDocPropertyTag */: + case 304 /* JSDocParameterTag */: + case 310 /* JSDocPropertyTag */: return visitNode(cbNode, node.tagName) || (node.isNameFirst ? visitNode(cbNode, node.name) || visitNode(cbNode, node.typeExpression) : visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name)); - case 295 /* JSDocAugmentsTag */: + case 300 /* JSDocAugmentsTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.class); - case 303 /* JSDocTemplateTag */: + case 308 /* JSDocTemplateTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.constraint) || visitNodes(cbNode, cbNodes, node.typeParameters); - case 304 /* JSDocTypedefTag */: + case 309 /* JSDocTypedefTag */: return visitNode(cbNode, node.tagName) || (node.typeExpression && - node.typeExpression.kind === 283 /* JSDocTypeExpression */ + node.typeExpression.kind === 288 /* JSDocTypeExpression */ ? visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) : visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression)); - case 297 /* JSDocCallbackTag */: + case 302 /* JSDocCallbackTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); - case 300 /* JSDocReturnTag */: - case 302 /* JSDocTypeTag */: - case 301 /* JSDocThisTag */: - case 298 /* JSDocEnumTag */: + case 305 /* JSDocReturnTag */: + case 307 /* JSDocTypeTag */: + case 306 /* JSDocThisTag */: + case 303 /* JSDocEnumTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.typeExpression); - case 293 /* JSDocSignature */: + case 298 /* JSDocSignature */: return ts.forEach(node.typeParameters, cbNode) || ts.forEach(node.parameters, cbNode) || visitNode(cbNode, node.type); - case 292 /* JSDocTypeLiteral */: + case 297 /* JSDocTypeLiteral */: return ts.forEach(node.jsDocPropertyTags, cbNode); - case 294 /* JSDocTag */: - case 296 /* JSDocClassTag */: + case 299 /* JSDocTag */: + case 301 /* JSDocClassTag */: return visitNode(cbNode, node.tagName); - case 308 /* PartiallyEmittedExpression */: + case 313 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -17183,7 +17255,7 @@ var ts; function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile) { // code from createNode is inlined here so createNode won't have to deal with special case of creating source files // this is quite rare comparing to other nodes and createNode should be as fast as possible - var sourceFile = new SourceFileConstructor(279 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); + var sourceFile = new SourceFileConstructor(284 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -18383,9 +18455,9 @@ var ts; return finishNode(node); } function parseJSDocAllType(postFixEquals) { - var result = createNode(284 /* JSDocAllType */); + var result = createNode(289 /* JSDocAllType */); if (postFixEquals) { - return createPostfixType(288 /* JSDocOptionalType */, result); + return createPostfixType(293 /* JSDocOptionalType */, result); } else { nextToken(); @@ -18393,7 +18465,7 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(287 /* JSDocNonNullableType */); + var result = createNode(292 /* JSDocNonNullableType */); nextToken(); result.type = parseNonArrayType(); return finishNode(result); @@ -18417,18 +18489,18 @@ var ts; token() === 30 /* GreaterThanToken */ || token() === 59 /* EqualsToken */ || token() === 50 /* BarToken */) { - var result = createNode(285 /* JSDocUnknownType */, pos); + var result = createNode(290 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(286 /* JSDocNullableType */, pos); + var result = createNode(291 /* JSDocNullableType */, pos); result.type = parseType(); return finishNode(result); } } function parseJSDocFunctionType() { if (lookAhead(nextTokenIsOpenParen)) { - var result = createNodeWithJSDoc(289 /* JSDocFunctionType */); + var result = createNodeWithJSDoc(294 /* JSDocFunctionType */); nextToken(); fillSignature(57 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result); return finishNode(result); @@ -18452,12 +18524,12 @@ var ts; var type = parseTypeOrTypePredicate(); scanner.setInJSDocType(false); if (dotdotdot) { - var variadic = createNode(290 /* JSDocVariadicType */, dotdotdot.pos); + var variadic = createNode(295 /* JSDocVariadicType */, dotdotdot.pos); variadic.type = type; type = finishNode(variadic); } if (token() === 59 /* EqualsToken */) { - return createPostfixType(288 /* JSDocOptionalType */, type); + return createPostfixType(293 /* JSDocOptionalType */, type); } return type; } @@ -18829,7 +18901,7 @@ var ts; return finishNode(node); } var type = parseType(); - if (!(contextFlags & 2097152 /* JSDoc */) && type.kind === 286 /* JSDocNullableType */ && type.pos === type.type.pos) { + if (!(contextFlags & 2097152 /* JSDoc */) && type.kind === 291 /* JSDocNullableType */ && type.pos === type.type.pos) { type.kind = 171 /* OptionalType */; } return type; @@ -19016,14 +19088,14 @@ var ts; while (!scanner.hasPrecedingLineBreak()) { switch (token()) { case 52 /* ExclamationToken */: - type = createPostfixType(287 /* JSDocNonNullableType */, type); + type = createPostfixType(292 /* JSDocNonNullableType */, type); break; case 56 /* QuestionToken */: // If not in JSDoc and next token is start of a type we have a conditional type if (!(contextFlags & 2097152 /* JSDoc */) && lookAhead(nextTokenIsStartOfType)) { return type; } - type = createPostfixType(286 /* JSDocNullableType */, type); + type = createPostfixType(291 /* JSDocNullableType */, type); break; case 22 /* OpenBracketToken */: parseExpected(22 /* OpenBracketToken */); @@ -21960,7 +22032,7 @@ var ts; JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; // Parses out a JSDoc type expression. function parseJSDocTypeExpression(mayOmitBraces) { - var result = createNode(283 /* JSDocTypeExpression */); + var result = createNode(288 /* JSDocTypeExpression */); var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* OpenBraceToken */); result.type = doInsideOfContext(2097152 /* JSDoc */, parseJSDocType); if (!mayOmitBraces || hasBrace) { @@ -22123,7 +22195,7 @@ var ts; } } function createJSDocComment() { - var result = createNode(291 /* JSDocComment */, start); + var result = createNode(296 /* JSDocComment */, start); result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -22290,7 +22362,7 @@ var ts; return comments.length === 0 ? undefined : comments.join(""); } function parseUnknownTag(start, tagName) { - var result = createNode(294 /* JSDocTag */, start); + var result = createNode(299 /* JSDocTag */, start); result.tagName = tagName; return finishNode(result); } @@ -22349,8 +22421,8 @@ var ts; typeExpression = tryParseTypeExpression(); } var result = target === 1 /* Property */ ? - createNode(305 /* JSDocPropertyTag */, start) : - createNode(299 /* JSDocParameterTag */, start); + createNode(310 /* JSDocPropertyTag */, start) : + createNode(304 /* JSDocParameterTag */, start); var comment = parseTagComments(indent + scanner.getStartPos() - start); var nestedTypeLiteral = target !== 4 /* CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target, indent); if (nestedTypeLiteral) { @@ -22367,18 +22439,18 @@ var ts; } function parseNestedTypeLiteral(typeExpression, name, target, indent) { if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) { - var typeLiteralExpression = createNode(283 /* JSDocTypeExpression */, scanner.getTokenPos()); + var typeLiteralExpression = createNode(288 /* JSDocTypeExpression */, scanner.getTokenPos()); var child = void 0; var jsdocTypeLiteral = void 0; var start_2 = scanner.getStartPos(); var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) { - if (child.kind === 299 /* JSDocParameterTag */ || child.kind === 305 /* JSDocPropertyTag */) { + if (child.kind === 304 /* JSDocParameterTag */ || child.kind === 310 /* JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - jsdocTypeLiteral = createNode(292 /* JSDocTypeLiteral */, start_2); + jsdocTypeLiteral = createNode(297 /* JSDocTypeLiteral */, start_2); jsdocTypeLiteral.jsDocPropertyTags = children; if (typeExpression.type.kind === 169 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; @@ -22389,25 +22461,25 @@ var ts; } } function parseReturnTag(start, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 300 /* JSDocReturnTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 305 /* JSDocReturnTag */; })) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(300 /* JSDocReturnTag */, start); + var result = createNode(305 /* JSDocReturnTag */, start); result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); } function parseTypeTag(start, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 302 /* JSDocTypeTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 307 /* JSDocTypeTag */; })) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(302 /* JSDocTypeTag */, start); + var result = createNode(307 /* JSDocTypeTag */, start); result.tagName = tagName; result.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); return finishNode(result); } function parseAugmentsTag(start, tagName) { - var result = createNode(295 /* JSDocAugmentsTag */, start); + var result = createNode(300 /* JSDocAugmentsTag */, start); result.tagName = tagName; result.class = parseExpressionWithTypeArgumentsForAugments(); return finishNode(result); @@ -22434,19 +22506,19 @@ var ts; return node; } function parseClassTag(start, tagName) { - var tag = createNode(296 /* JSDocClassTag */, start); + var tag = createNode(301 /* JSDocClassTag */, start); tag.tagName = tagName; return finishNode(tag); } function parseThisTag(start, tagName) { - var tag = createNode(301 /* JSDocThisTag */, start); + var tag = createNode(306 /* JSDocThisTag */, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); return finishNode(tag); } function parseEnumTag(start, tagName) { - var tag = createNode(298 /* JSDocEnumTag */, start); + var tag = createNode(303 /* JSDocEnumTag */, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); @@ -22455,7 +22527,7 @@ var ts; function parseTypedefTag(start, tagName, indent) { var typeExpression = tryParseTypeExpression(); skipWhitespaceOrAsterisk(); - var typedefTag = createNode(304 /* JSDocTypedefTag */, start); + var typedefTag = createNode(309 /* JSDocTypedefTag */, start); typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(); typedefTag.name = getJSDocTypeAliasName(typedefTag.fullName); @@ -22469,9 +22541,9 @@ var ts; var childTypeTag = void 0; while (child = tryParse(function () { return parseChildPropertyTag(indent); })) { if (!jsdocTypeLiteral) { - jsdocTypeLiteral = createNode(292 /* JSDocTypeLiteral */, start); + jsdocTypeLiteral = createNode(297 /* JSDocTypeLiteral */, start); } - if (child.kind === 302 /* JSDocTypeTag */) { + if (child.kind === 307 /* JSDocTypeTag */) { if (childTypeTag) { break; } @@ -22517,14 +22589,14 @@ var ts; return typeNameOrNamespaceName; } function parseCallbackTag(start, tagName, indent) { - var callbackTag = createNode(297 /* JSDocCallbackTag */, start); + var callbackTag = createNode(302 /* JSDocCallbackTag */, start); callbackTag.tagName = tagName; callbackTag.fullName = parseJSDocTypeNameWithNamespace(); callbackTag.name = getJSDocTypeAliasName(callbackTag.fullName); skipWhitespace(); callbackTag.comment = parseTagComments(indent); var child; - var jsdocSignature = createNode(293 /* JSDocSignature */, start); + var jsdocSignature = createNode(298 /* JSDocSignature */, start); jsdocSignature.parameters = []; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* CallbackParameter */, indent); })) { jsdocSignature.parameters = ts.append(jsdocSignature.parameters, child); @@ -22532,7 +22604,7 @@ var ts; var returnTag = tryParse(function () { if (parseOptionalJsdoc(58 /* AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 300 /* JSDocReturnTag */) { + if (tag && tag.kind === 305 /* JSDocReturnTag */) { return tag; } } @@ -22577,7 +22649,7 @@ var ts; case 58 /* AtToken */: if (canParseTag) { var child = tryParseChildTag(target, indent); - if (child && (child.kind === 299 /* JSDocParameterTag */ || child.kind === 305 /* JSDocPropertyTag */) && + if (child && (child.kind === 304 /* JSDocParameterTag */ || child.kind === 310 /* JSDocPropertyTag */) && target !== 4 /* CallbackParameter */ && name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; @@ -22647,7 +22719,7 @@ var ts; skipWhitespace(); typeParameters.push(typeParameter); } while (parseOptionalJsdoc(27 /* CommaToken */)); - var result = createNode(303 /* JSDocTemplateTag */, start); + var result = createNode(308 /* JSDocTemplateTag */, start); result.tagName = tagName; result.constraint = constraint; result.typeParameters = createNodeArray(typeParameters, typeParametersPos); @@ -23733,6 +23805,22 @@ var ts; category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Enable_project_compilation, }, + { + name: "incremental", + type: "boolean", + isTSConfigOnly: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Enable_incremental_compilation, + }, + { + name: "tsBuildInfoFile", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.FILE, + isTSConfigOnly: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Specify_file_to_store_incremental_compilation_information, + }, { name: "removeComments", type: "boolean", @@ -27451,7 +27539,7 @@ var ts; return "__constructor" /* Constructor */; case 165 /* FunctionType */: case 160 /* CallSignature */: - case 293 /* JSDocSignature */: + case 298 /* JSDocSignature */: return "__call" /* Call */; case 166 /* ConstructorType */: case 161 /* ConstructSignature */: @@ -27460,7 +27548,7 @@ var ts; return "__index" /* Index */; case 255 /* ExportDeclaration */: return "__export" /* ExportStar */; - case 279 /* SourceFile */: + case 284 /* SourceFile */: // json file should behave as // module.exports = ... return "export=" /* ExportEquals */; @@ -27471,12 +27559,12 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 289 /* JSDocFunctionType */: + case 294 /* JSDocFunctionType */: return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); case 151 /* Parameter */: // Parameters with names are handled at the top of this function. Parameters // without names can only come from JSDocFunctionTypes. - ts.Debug.assert(node.parent.kind === 289 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); + ts.Debug.assert(node.parent.kind === 294 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); var functionType = node.parent; var index = functionType.parameters.indexOf(node); return "arg" + index; @@ -27715,7 +27803,7 @@ var ts; if (hasExplicitReturn) node.flags |= 256 /* HasExplicitReturn */; } - if (node.kind === 279 /* SourceFile */) { + if (node.kind === 284 /* SourceFile */) { node.flags |= emitFlags; } if (currentReturnTarget) { @@ -27859,12 +27947,12 @@ var ts; case 191 /* CallExpression */: bindCallExpressionFlow(node); break; - case 304 /* JSDocTypedefTag */: - case 297 /* JSDocCallbackTag */: + case 309 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: bindJSDocTypeAlias(node); break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 279 /* SourceFile */: { + case 284 /* SourceFile */: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; @@ -28551,7 +28639,7 @@ var ts; case 243 /* EnumDeclaration */: case 188 /* ObjectLiteralExpression */: case 168 /* TypeLiteral */: - case 292 /* JSDocTypeLiteral */: + case 297 /* JSDocTypeLiteral */: case 268 /* JsxAttributes */: return 1 /* IsContainer */; case 241 /* InterfaceDeclaration */: @@ -28560,7 +28648,7 @@ var ts; case 242 /* TypeAliasDeclaration */: case 181 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 279 /* SourceFile */: + case 284 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; case 156 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { @@ -28573,8 +28661,8 @@ var ts; case 158 /* GetAccessor */: case 159 /* SetAccessor */: case 160 /* CallSignature */: - case 293 /* JSDocSignature */: - case 289 /* JSDocFunctionType */: + case 298 /* JSDocSignature */: + case 294 /* JSDocFunctionType */: case 165 /* FunctionType */: case 161 /* ConstructSignature */: case 162 /* IndexSignature */: @@ -28628,7 +28716,7 @@ var ts; // handlers to take care of declaring these child members. case 244 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 279 /* SourceFile */: + case 284 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); case 209 /* ClassExpression */: case 240 /* ClassDeclaration */: @@ -28636,7 +28724,7 @@ var ts; case 243 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); case 168 /* TypeLiteral */: - case 292 /* JSDocTypeLiteral */: + case 297 /* JSDocTypeLiteral */: case 188 /* ObjectLiteralExpression */: case 241 /* InterfaceDeclaration */: case 268 /* JsxAttributes */: @@ -28650,7 +28738,7 @@ var ts; case 166 /* ConstructorType */: case 160 /* CallSignature */: case 161 /* ConstructSignature */: - case 293 /* JSDocSignature */: + case 298 /* JSDocSignature */: case 162 /* IndexSignature */: case 156 /* MethodDeclaration */: case 155 /* MethodSignature */: @@ -28660,9 +28748,9 @@ var ts; case 239 /* FunctionDeclaration */: case 196 /* FunctionExpression */: case 197 /* ArrowFunction */: - case 289 /* JSDocFunctionType */: - case 304 /* JSDocTypedefTag */: - case 297 /* JSDocCallbackTag */: + case 294 /* JSDocFunctionType */: + case 309 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: case 242 /* TypeAliasDeclaration */: case 181 /* MappedType */: // All the children of these container types are never visible through another @@ -28685,8 +28773,8 @@ var ts; : declareSymbol(file.locals, /*parent*/ undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 279 /* SourceFile */ ? node : node.body; - if (body && (body.kind === 279 /* SourceFile */ || body.kind === 245 /* ModuleBlock */)) { + var body = node.kind === 284 /* SourceFile */ ? node : node.body; + if (body && (body.kind === 284 /* SourceFile */ || body.kind === 245 /* ModuleBlock */)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; if (stat.kind === 255 /* ExportDeclaration */ || stat.kind === 254 /* ExportAssignment */) { @@ -28820,7 +28908,7 @@ var ts; case 244 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 279 /* SourceFile */: + case 284 /* SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -28958,7 +29046,7 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 279 /* SourceFile */ && + if (blockScopeContainer.kind !== 284 /* SourceFile */ && blockScopeContainer.kind !== 244 /* ModuleDeclaration */ && !ts.isFunctionLike(blockScopeContainer)) { // We check first if the name is inside class declaration or class expression; if so give explicit message @@ -29233,12 +29321,12 @@ var ts; case 159 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 67187647 /* SetAccessorExcludes */); case 165 /* FunctionType */: - case 289 /* JSDocFunctionType */: - case 293 /* JSDocSignature */: + case 294 /* JSDocFunctionType */: + case 298 /* JSDocSignature */: case 166 /* ConstructorType */: return bindFunctionOrConstructorType(node); case 168 /* TypeLiteral */: - case 292 /* JSDocTypeLiteral */: + case 297 /* JSDocTypeLiteral */: case 181 /* MappedType */: return bindAnonymousTypeWorker(node); case 188 /* ObjectLiteralExpression */: @@ -29297,7 +29385,7 @@ var ts; return bindExportDeclaration(node); case 254 /* ExportAssignment */: return bindExportAssignment(node); - case 279 /* SourceFile */: + case 284 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); case 218 /* Block */: @@ -29307,22 +29395,22 @@ var ts; // falls through case 245 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 299 /* JSDocParameterTag */: - if (node.parent.kind === 293 /* JSDocSignature */) { + case 304 /* JSDocParameterTag */: + if (node.parent.kind === 298 /* JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 292 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 297 /* JSDocTypeLiteral */) { break; } // falls through - case 305 /* JSDocPropertyTag */: + case 310 /* JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 288 /* JSDocOptionalType */ ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 293 /* JSDocOptionalType */ ? 4 /* Property */ | 16777216 /* Optional */ : 4 /* Property */; return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 304 /* JSDocTypedefTag */: - case 297 /* JSDocCallbackTag */: + case 309 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -29494,7 +29582,7 @@ var ts; var symbolTable = ts.hasModifier(thisContainer, 32 /* Static */) ? containingClass.symbol.exports : containingClass.symbol.members; declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */, 0 /* None */, /*isReplaceableByMethod*/ true); break; - case 279 /* SourceFile */: + case 284 /* SourceFile */: // this.property = assignment in a source file -- declare symbol in exports for a module, in locals for a script if (thisContainer.commonJsModuleIndicator) { declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 /* Property */ | 1048576 /* ExportValue */, 0 /* None */); @@ -29511,7 +29599,7 @@ var ts; if (node.expression.kind === 100 /* ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 279 /* SourceFile */) { + else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 284 /* SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -29548,7 +29636,7 @@ var ts; } function bindObjectDefinePropertyAssignment(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]); - var isToplevel = node.parent.parent.kind === 279 /* SourceFile */; + var isToplevel = node.parent.parent.kind === 284 /* SourceFile */; namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false); bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ false); } @@ -29615,8 +29703,8 @@ var ts; function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty) { var namespaceSymbol = lookupSymbolForPropertyAccess(name); var isToplevel = ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 279 /* SourceFile */ - : propertyAccess.parent.parent.kind === 279 /* SourceFile */; + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 284 /* SourceFile */ + : propertyAccess.parent.parent.kind === 284 /* SourceFile */; namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty); bindPotentiallyNewExpandoMemberToNamespace(propertyAccess, namespaceSymbol, isPrototypeProperty); } @@ -29754,7 +29842,7 @@ var ts; } } function bindParameter(node) { - if (node.kind === 299 /* JSDocParameterTag */ && container.kind !== 293 /* JSDocSignature */) { + if (node.kind === 304 /* JSDocParameterTag */ && container.kind !== 298 /* JSDocSignature */) { return; } if (inStrictMode && !(node.flags & 4194304 /* Ambient */)) { @@ -30497,7 +30585,7 @@ var ts; break; case 194 /* TypeAssertionExpression */: case 212 /* AsExpression */: - case 308 /* PartiallyEmittedExpression */: + case 313 /* PartiallyEmittedExpression */: // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; excludeFlags = 536872257 /* OuterExpressionExcludes */; @@ -30698,7 +30786,7 @@ var ts; transformFlags |= 192 /* AssertES2015 */; } break; - case 279 /* SourceFile */: + case 284 /* SourceFile */: if (subtreeFlags & 16384 /* ContainsCapturedLexicalThis */) { transformFlags |= 192 /* AssertES2015 */; } @@ -30778,7 +30866,7 @@ var ts; return 637666625 /* BindingPatternExcludes */; case 194 /* TypeAssertionExpression */: case 212 /* AsExpression */: - case 308 /* PartiallyEmittedExpression */: + case 313 /* PartiallyEmittedExpression */: case 195 /* ParenthesizedExpression */: case 98 /* SuperKeyword */: return 536872257 /* OuterExpressionExcludes */; @@ -31955,7 +32043,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); } function isGlobalSourceFile(node) { - return node.kind === 279 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 284 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -32129,7 +32217,7 @@ var ts; // - parameters are only in the scope of function body // This restriction does not apply to JSDoc comment types because they are parented // at a higher level than type parameters would normally be - if (meaning & result.flags & 67897832 /* Type */ && lastLocation.kind !== 291 /* JSDocComment */) { + if (meaning & result.flags & 67897832 /* Type */ && lastLocation.kind !== 296 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || @@ -32171,14 +32259,14 @@ var ts; } } switch (location.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through case 244 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 279 /* SourceFile */ || ts.isAmbientModule(location)) { + if (location.kind === 284 /* SourceFile */ || ts.isAmbientModule(location)) { // It's an external module. First see if the module has an export default and if the local // name of that export default matches. if (result = moduleExports.get("default" /* Default */)) { @@ -32350,8 +32438,8 @@ var ts; location = location.parent; } break; - case 304 /* JSDocTypedefTag */: - case 297 /* JSDocCallbackTag */: + case 309 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: // js type aliases do not resolve names from their host, so skip past it location = ts.getJSDocHost(location); break; @@ -32370,7 +32458,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 279 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 284 /* SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) { return lastLocation.symbol; } @@ -33226,7 +33314,7 @@ var ts; function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias) { var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 279 /* SourceFile */)) { + if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 284 /* SourceFile */)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; @@ -33577,7 +33665,7 @@ var ts; } } switch (location.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } @@ -33817,10 +33905,10 @@ var ts; return node && getSymbolOfNode(node); } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 279 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 284 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 279 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 284 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -34277,7 +34365,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 279 /* SourceFile */ || declaration.parent.kind === 245 /* ModuleBlock */; + return declaration.parent.kind === 284 /* SourceFile */ || declaration.parent.kind === 245 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -34662,7 +34750,7 @@ var ts; function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) { var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 151 /* Parameter */); if (!parameterDeclaration && !isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 299 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 304 /* JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { @@ -34820,7 +34908,7 @@ var ts; return top; } function getSpecifierForModuleSymbol(symbol, context) { - var file = ts.getDeclarationOfKind(symbol, 279 /* SourceFile */); + var file = ts.getDeclarationOfKind(symbol, 284 /* SourceFile */); if (file && file.moduleName !== undefined) { // Use the amd name if it is available return file.moduleName; @@ -35073,7 +35161,7 @@ var ts; ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 279 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 284 /* SourceFile */ || ts.isAmbientModule(location); } function getNameOfSymbolFromNameType(symbol, context) { var nameType = symbol.nameType; @@ -35150,8 +35238,8 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 297 /* JSDocCallbackTag */: - case 304 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: + case 309 /* JSDocTypedefTag */: // Top-level jsdoc type aliases are considered exported // First parent is comment node, second is hosting declaration or token; we only care about those tokens or declarations whose parent is a source file return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent)); @@ -35178,7 +35266,7 @@ var ts; var parent = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) if (!(ts.getCombinedModifierFlags(node) & 1 /* Export */) && - !(node.kind !== 248 /* ImportEqualsDeclaration */ && parent.kind !== 279 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { + !(node.kind !== 248 /* ImportEqualsDeclaration */ && parent.kind !== 284 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible @@ -35220,7 +35308,7 @@ var ts; // Type parameters are always visible case 150 /* TypeParameter */: // Source file and namespace export are always visible - case 279 /* SourceFile */: + case 284 /* SourceFile */: case 247 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module @@ -36330,15 +36418,15 @@ var ts; case 155 /* MethodSignature */: case 165 /* FunctionType */: case 166 /* ConstructorType */: - case 289 /* JSDocFunctionType */: + case 294 /* JSDocFunctionType */: case 239 /* FunctionDeclaration */: case 156 /* MethodDeclaration */: case 196 /* FunctionExpression */: case 197 /* ArrowFunction */: case 242 /* TypeAliasDeclaration */: - case 303 /* JSDocTemplateTag */: - case 304 /* JSDocTypedefTag */: - case 297 /* JSDocCallbackTag */: + case 308 /* JSDocTemplateTag */: + case 309 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: case 181 /* MappedType */: case 175 /* ConditionalType */: var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); @@ -38330,10 +38418,10 @@ var ts; function isJSDocOptionalParameter(node) { return ts.isInJSFile(node) && ( // node.type should only be a JSDocOptionalType when node is a parameter of a JSDocFunctionType - node.type && node.type.kind === 288 /* JSDocOptionalType */ + node.type && node.type.kind === 293 /* JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 288 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 293 /* JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -38367,7 +38455,7 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 288 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 293 /* JSDocOptionalType */; } function createIdentifierTypePredicate(parameterName, parameterIndex, type) { return { kind: 1 /* Identifier */, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; @@ -39107,7 +39195,7 @@ var ts; } function getConstrainedTypeVariable(typeVariable, node) { var constraints; - while (node && !ts.isStatement(node) && node.kind !== 291 /* JSDocComment */) { + while (node && !ts.isStatement(node) && node.kind !== 296 /* JSDocComment */) { var parent = node.parent; if (parent.kind === 175 /* ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(typeVariable, parent.checkType, parent.extendsType); @@ -40680,8 +40768,8 @@ var ts; function getTypeFromTypeNode(node) { switch (node.kind) { case 120 /* AnyKeyword */: - case 284 /* JSDocAllType */: - case 285 /* JSDocUnknownType */: + case 289 /* JSDocAllType */: + case 290 /* JSDocUnknownType */: return anyType; case 143 /* UnknownKeyword */: return unknownType; @@ -40728,23 +40816,23 @@ var ts; return getTypeFromUnionTypeNode(node); case 174 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 286 /* JSDocNullableType */: + case 291 /* JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 288 /* JSDocOptionalType */: + case 293 /* JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); case 177 /* ParenthesizedType */: case 172 /* RestType */: - case 287 /* JSDocNonNullableType */: - case 283 /* JSDocTypeExpression */: + case 292 /* JSDocNonNullableType */: + case 288 /* JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 290 /* JSDocVariadicType */: + case 295 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); case 165 /* FunctionType */: case 166 /* ConstructorType */: case 168 /* TypeLiteral */: - case 292 /* JSDocTypeLiteral */: - case 289 /* JSDocFunctionType */: - case 293 /* JSDocSignature */: + case 297 /* JSDocTypeLiteral */: + case 294 /* JSDocFunctionType */: + case 298 /* JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); case 179 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); @@ -44105,7 +44193,7 @@ var ts; return; } break; - case 289 /* JSDocFunctionType */: + case 294 /* JSDocFunctionType */: error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; case 239 /* FunctionDeclaration */: @@ -46386,7 +46474,7 @@ var ts; return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || node.kind === 245 /* ModuleBlock */ || - node.kind === 279 /* SourceFile */ || + node.kind === 284 /* SourceFile */ || node.kind === 154 /* PropertyDeclaration */; }); } @@ -46507,7 +46595,7 @@ var ts; // to the constructor in the initializer, we will need to substitute that // binding with an alias as the class name is not in scope. var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); - while (container.kind !== 279 /* SourceFile */) { + while (container.kind !== 284 /* SourceFile */) { if (container.parent === declaration) { if (container.kind === 154 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; @@ -46930,7 +47018,7 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 289 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 294 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -52932,7 +53020,7 @@ var ts; checkAsyncFunctionReturnType(node, returnTypeNode); } } - if (node.kind !== 162 /* IndexSignature */ && node.kind !== 289 /* JSDocFunctionType */) { + if (node.kind !== 162 /* IndexSignature */ && node.kind !== 294 /* JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } @@ -53688,8 +53776,8 @@ var ts; case 241 /* InterfaceDeclaration */: case 242 /* TypeAliasDeclaration */: // A jsdoc typedef and callback are, by definition, type aliases - case 304 /* JSDocTypedefTag */: - case 297 /* JSDocCallbackTag */: + case 309 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: return 2 /* ExportType */; case 244 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ @@ -53698,7 +53786,7 @@ var ts; case 240 /* ClassDeclaration */: case 243 /* EnumDeclaration */: return 2 /* ExportType */ | 1 /* ExportValue */; - case 279 /* SourceFile */: + case 284 /* SourceFile */: return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; case 254 /* ExportAssignment */: // Export assigned entity name expressions act as aliases and should fall through, otherwise they export values @@ -54339,7 +54427,7 @@ var ts; checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 279 /* SourceFile */: + case 284 /* SourceFile */: case 244 /* ModuleDeclaration */: case 218 /* Block */: case 246 /* CaseBlock */: @@ -54686,7 +54774,7 @@ var ts; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 279 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 284 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -54701,7 +54789,7 @@ var ts; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 279 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { + if (parent.kind === 284 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { // If the declaration happens to be in external module, report error that Promise is a reserved identifier. error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -54758,7 +54846,7 @@ var ts; (container.kind === 218 /* Block */ && ts.isFunctionLike(container.parent) || container.kind === 245 /* ModuleBlock */ || container.kind === 244 /* ModuleDeclaration */ || - container.kind === 279 /* SourceFile */); + container.kind === 284 /* SourceFile */); // here we know that function scoped variable is shadowed by block scoped one // if they are defined in the same scope - binder has already reported redeclaration error // otherwise if variable has an initializer - show error that initialization will fail @@ -56608,7 +56696,7 @@ var ts; return false; } var inAmbientExternalModule = node.parent.kind === 245 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 279 /* SourceFile */ && !inAmbientExternalModule) { + if (node.parent.kind !== 284 /* SourceFile */ && !inAmbientExternalModule) { error(moduleName, node.kind === 255 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); @@ -56739,7 +56827,7 @@ var ts; var inAmbientExternalModule = node.parent.kind === 245 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 245 /* ModuleBlock */ && !node.moduleSpecifier && node.flags & 4194304 /* Ambient */; - if (node.parent.kind !== 279 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + if (node.parent.kind !== 284 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -56756,7 +56844,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 279 /* SourceFile */ || node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 244 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 284 /* SourceFile */ || node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 244 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -56785,7 +56873,7 @@ var ts; // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 279 /* SourceFile */ ? node.parent : node.parent.parent; + var container = node.parent.kind === 284 /* SourceFile */ ? node.parent : node.parent.parent; if (container.kind === 244 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); @@ -56955,32 +57043,32 @@ var ts; return checkInferType(node); case 183 /* ImportType */: return checkImportType(node); - case 295 /* JSDocAugmentsTag */: + case 300 /* JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 304 /* JSDocTypedefTag */: - case 297 /* JSDocCallbackTag */: + case 309 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: return checkJSDocTypeAliasTag(node); - case 303 /* JSDocTemplateTag */: + case 308 /* JSDocTemplateTag */: return checkJSDocTemplateTag(node); - case 302 /* JSDocTypeTag */: + case 307 /* JSDocTypeTag */: return checkJSDocTypeTag(node); - case 299 /* JSDocParameterTag */: + case 304 /* JSDocParameterTag */: return checkJSDocParameterTag(node); - case 289 /* JSDocFunctionType */: + case 294 /* JSDocFunctionType */: checkJSDocFunctionType(node); // falls through - case 287 /* JSDocNonNullableType */: - case 286 /* JSDocNullableType */: - case 284 /* JSDocAllType */: - case 285 /* JSDocUnknownType */: - case 292 /* JSDocTypeLiteral */: + case 292 /* JSDocNonNullableType */: + case 291 /* JSDocNullableType */: + case 289 /* JSDocAllType */: + case 290 /* JSDocUnknownType */: + case 297 /* JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 290 /* JSDocVariadicType */: + case 295 /* JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 283 /* JSDocTypeExpression */: + case 288 /* JSDocTypeExpression */: return checkSourceElement(node.type); case 180 /* IndexedAccessType */: return checkIndexedAccessType(node); @@ -57288,7 +57376,7 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; // falls through @@ -57507,10 +57595,10 @@ var ts; return entityNameSymbol; } } - if (entityName.parent.kind === 299 /* JSDocParameterTag */) { + if (entityName.parent.kind === 304 /* JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(entityName.parent); } - if (entityName.parent.kind === 150 /* TypeParameter */ && entityName.parent.parent.kind === 303 /* JSDocTemplateTag */) { + if (entityName.parent.kind === 150 /* TypeParameter */ && entityName.parent.parent.kind === 308 /* JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJSFile(entityName)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(entityName.parent); return typeParameter && typeParameter.symbol; @@ -57552,7 +57640,7 @@ var ts; return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 279 /* SourceFile */) { + if (node.kind === 284 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; @@ -57894,7 +57982,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 279 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 284 /* SourceFile */) { var symbolFile = parentSymbol_1.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); // If `node` accesses an export and that export isn't in the same file, then symbol is a namespace export, so return undefined. @@ -58009,7 +58097,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 279 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 284 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -58438,7 +58526,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 279 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 284 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -58471,7 +58559,7 @@ var ts; if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 279 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 284 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -58703,7 +58791,7 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 279 /* SourceFile */) { + else if (node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 284 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128 /* Abstract */) { @@ -58726,7 +58814,7 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 279 /* SourceFile */) { + else if (node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 284 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } else if (node.kind === 151 /* Parameter */) { @@ -58771,7 +58859,7 @@ var ts; flags |= 1 /* Export */; break; case 80 /* DefaultKeyword */: - var container = node.parent.kind === 279 /* SourceFile */ ? node.parent : node.parent.parent; + var container = node.parent.kind === 284 /* SourceFile */ ? node.parent : node.parent.parent; if (container.kind === 244 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } @@ -58894,7 +58982,7 @@ var ts; case 151 /* Parameter */: return false; default: - if (node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 279 /* SourceFile */) { + if (node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 284 /* SourceFile */) { return false; } switch (node.kind) { @@ -59817,7 +59905,7 @@ var ts; // to prevent noisiness. So use a bit on the block to indicate if // this has already been reported, and don't report if it has. // - if (node.parent.kind === 218 /* Block */ || node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 279 /* SourceFile */) { + if (node.parent.kind === 218 /* Block */ || node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 284 /* SourceFile */) { var links_2 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_2.hasReportedStatementInAmbientContext) { @@ -61871,14 +61959,14 @@ var ts; // JSDoc /* @internal */ function createJSDocTypeExpression(type) { - var node = createSynthesizedNode(283 /* JSDocTypeExpression */); + var node = createSynthesizedNode(288 /* JSDocTypeExpression */); node.type = type; return node; } ts.createJSDocTypeExpression = createJSDocTypeExpression; /* @internal */ function createJSDocTypeTag(typeExpression, comment) { - var tag = createJSDocTag(302 /* JSDocTypeTag */, "type"); + var tag = createJSDocTag(307 /* JSDocTypeTag */, "type"); tag.typeExpression = typeExpression; tag.comment = comment; return tag; @@ -61886,7 +61974,7 @@ var ts; ts.createJSDocTypeTag = createJSDocTypeTag; /* @internal */ function createJSDocReturnTag(typeExpression, comment) { - var tag = createJSDocTag(300 /* JSDocReturnTag */, "returns"); + var tag = createJSDocTag(305 /* JSDocReturnTag */, "returns"); tag.typeExpression = typeExpression; tag.comment = comment; return tag; @@ -61894,7 +61982,7 @@ var ts; ts.createJSDocReturnTag = createJSDocReturnTag; /* @internal */ function createJSDocParamTag(name, isBracketed, typeExpression, comment) { - var tag = createJSDocTag(299 /* JSDocParameterTag */, "param"); + var tag = createJSDocTag(304 /* JSDocParameterTag */, "param"); tag.typeExpression = typeExpression; tag.name = name; tag.isBracketed = isBracketed; @@ -61904,7 +61992,7 @@ var ts; ts.createJSDocParamTag = createJSDocParamTag; /* @internal */ function createJSDocComment(comment, tags) { - var node = createSynthesizedNode(291 /* JSDocComment */); + var node = createSynthesizedNode(296 /* JSDocComment */); node.comment = comment; node.tags = tags; return node; @@ -62163,7 +62251,7 @@ var ts; (typeReferences !== undefined && node.typeReferenceDirectives !== typeReferences) || (libReferences !== undefined && node.libReferenceDirectives !== libReferences) || (hasNoDefaultLib !== undefined && node.hasNoDefaultLib !== hasNoDefaultLib)) { - var updated = createSynthesizedNode(279 /* SourceFile */); + var updated = createSynthesizedNode(284 /* SourceFile */); updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; @@ -62247,7 +62335,7 @@ var ts; * @param original The original statement. */ function createNotEmittedStatement(original) { - var node = createSynthesizedNode(307 /* NotEmittedStatement */); + var node = createSynthesizedNode(312 /* NotEmittedStatement */); node.original = original; setTextRange(node, original); return node; @@ -62259,7 +62347,7 @@ var ts; */ /* @internal */ function createEndOfDeclarationMarker(original) { - var node = createSynthesizedNode(311 /* EndOfDeclarationMarker */); + var node = createSynthesizedNode(316 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -62271,7 +62359,7 @@ var ts; */ /* @internal */ function createMergeDeclarationMarker(original) { - var node = createSynthesizedNode(310 /* MergeDeclarationMarker */); + var node = createSynthesizedNode(315 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -62286,7 +62374,7 @@ var ts; * @param location The location for the expression. Defaults to the positions from "original" if provided. */ function createPartiallyEmittedExpression(expression, original) { - var node = createSynthesizedNode(308 /* PartiallyEmittedExpression */); + var node = createSynthesizedNode(313 /* PartiallyEmittedExpression */); node.expression = expression; node.original = original; setTextRange(node, original); @@ -62302,7 +62390,7 @@ var ts; ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; function flattenCommaElements(node) { if (ts.nodeIsSynthesized(node) && !ts.isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) { - if (node.kind === 309 /* CommaListExpression */) { + if (node.kind === 314 /* CommaListExpression */) { return node.elements; } if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27 /* CommaToken */) { @@ -62312,7 +62400,7 @@ var ts; return node; } function createCommaList(elements) { - var node = createSynthesizedNode(309 /* CommaListExpression */); + var node = createSynthesizedNode(314 /* CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); return node; } @@ -62325,33 +62413,197 @@ var ts; ts.updateCommaList = updateCommaList; function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = ts.createNode(280 /* Bundle */); + var node = ts.createNode(285 /* Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; } ts.createBundle = createBundle; - function createUnparsedSourceFile(textOrInputFiles, mapPathOrType, map) { - var node = ts.createNode(281 /* UnparsedSource */); + var allUnscopedEmitHelpers; + function getAllUnscopedEmitHelpers() { + return allUnscopedEmitHelpers || (allUnscopedEmitHelpers = ts.arrayToMap([ + ts.valuesHelper, + ts.readHelper, + ts.spreadHelper, + ts.restHelper, + ts.decorateHelper, + ts.metadataHelper, + ts.paramHelper, + ts.awaiterHelper, + ts.assignHelper, + ts.awaitHelper, + ts.asyncGeneratorHelper, + ts.asyncDelegator, + ts.asyncValues, + ts.extendsHelper, + ts.templateObjectHelper, + ts.generatorHelper, + ts.importStarHelper, + ts.importDefaultHelper + ], function (helper) { return helper.name; })); + } + function createUnparsedSource() { + var node = ts.createNode(286 /* UnparsedSource */); + node.prologues = ts.emptyArray; + node.referencedFiles = ts.emptyArray; + node.libReferenceDirectives = ts.emptyArray; + node.getLineAndCharacterOfPosition = function (pos) { return ts.getLineAndCharacterOfPosition(node, pos); }; + return node; + } + function createUnparsedSourceFile(textOrInputFiles, mapPathOrType, mapTextOrStripInternal) { + var node = createUnparsedSource(); + var stripInternal; + var bundleFileInfo; if (!ts.isString(textOrInputFiles)) { ts.Debug.assert(mapPathOrType === "js" || mapPathOrType === "dts"); - node.fileName = mapPathOrType === "js" ? textOrInputFiles.javascriptPath : textOrInputFiles.declarationPath; + node.fileName = (mapPathOrType === "js" ? textOrInputFiles.javascriptPath : textOrInputFiles.declarationPath) || ""; node.sourceMapPath = mapPathOrType === "js" ? textOrInputFiles.javascriptMapPath : textOrInputFiles.declarationMapPath; Object.defineProperties(node, { text: { get: function () { return mapPathOrType === "js" ? textOrInputFiles.javascriptText : textOrInputFiles.declarationText; } }, sourceMapText: { get: function () { return mapPathOrType === "js" ? textOrInputFiles.javascriptMapText : textOrInputFiles.declarationMapText; } }, }); + if (textOrInputFiles.buildInfo && textOrInputFiles.buildInfo.bundle) { + node.oldFileOfCurrentEmit = textOrInputFiles.oldFileOfCurrentEmit; + ts.Debug.assert(mapTextOrStripInternal === undefined || typeof mapTextOrStripInternal === "boolean"); + stripInternal = mapTextOrStripInternal; + bundleFileInfo = mapPathOrType === "js" ? textOrInputFiles.buildInfo.bundle.js : textOrInputFiles.buildInfo.bundle.dts; + if (node.oldFileOfCurrentEmit) { + parseOldFileOfCurrentEmit(node, ts.Debug.assertDefined(bundleFileInfo)); + return node; + } + } } else { + node.fileName = ""; node.text = textOrInputFiles; node.sourceMapPath = mapPathOrType; - node.sourceMapText = map; + node.sourceMapText = mapTextOrStripInternal; } + ts.Debug.assert(!node.oldFileOfCurrentEmit); + parseUnparsedSourceFile(node, bundleFileInfo, stripInternal); return node; } ts.createUnparsedSourceFile = createUnparsedSourceFile; - function createInputFiles(javascriptTextOrReadFileText, declarationTextOrJavascriptPath, javascriptMapPath, javascriptMapTextOrDeclarationPath, declarationMapPath, declarationMapText) { - var node = ts.createNode(282 /* InputFiles */); + function parseUnparsedSourceFile(node, bundleFileInfo, stripInternal) { + var prologues; + var helpers; + var referencedFiles; + var typeReferenceDirectives; + var libReferenceDirectives; + var texts; + for (var _i = 0, _a = bundleFileInfo ? bundleFileInfo.sections : ts.emptyArray; _i < _a.length; _i++) { + var section = _a[_i]; + switch (section.kind) { + case "prologue" /* Prologue */: + (prologues || (prologues = [])).push(createUnparsedNode(section, node)); + break; + case "emitHelpers" /* EmitHelpers */: + (helpers || (helpers = [])).push(getAllUnscopedEmitHelpers().get(section.data)); + break; + case "no-default-lib" /* NoDefaultLib */: + node.hasNoDefaultLib = true; + break; + case "reference" /* Reference */: + (referencedFiles || (referencedFiles = [])).push({ pos: -1, end: -1, fileName: section.data }); + break; + case "type" /* Type */: + (typeReferenceDirectives || (typeReferenceDirectives = [])).push(section.data); + break; + case "lib" /* Lib */: + (libReferenceDirectives || (libReferenceDirectives = [])).push({ pos: -1, end: -1, fileName: section.data }); + break; + case "prepend" /* Prepend */: + var prependNode = createUnparsedNode(section, node); + var prependTexts = void 0; + for (var _b = 0, _c = section.texts; _b < _c.length; _b++) { + var text = _c[_b]; + if (!stripInternal || text.kind !== "internal" /* Internal */) { + (prependTexts || (prependTexts = [])).push(createUnparsedNode(text, node)); + } + } + prependNode.texts = prependTexts || ts.emptyArray; + (texts || (texts = [])).push(prependNode); + break; + case "internal" /* Internal */: + if (stripInternal) + break; + // falls through + case "text" /* Text */: + (texts || (texts = [])).push(createUnparsedNode(section, node)); + break; + default: + ts.Debug.assertNever(section); + } + } + node.prologues = prologues || ts.emptyArray; + node.helpers = helpers; + node.referencedFiles = referencedFiles || ts.emptyArray; + node.typeReferenceDirectives = typeReferenceDirectives; + node.libReferenceDirectives = libReferenceDirectives || ts.emptyArray; + node.texts = texts || [createUnparsedNode({ kind: "text" /* Text */, pos: 0, end: node.text.length }, node)]; + } + function parseOldFileOfCurrentEmit(node, bundleFileInfo) { + ts.Debug.assert(!!node.oldFileOfCurrentEmit); + var texts; + var syntheticReferences; + for (var _i = 0, _a = bundleFileInfo.sections; _i < _a.length; _i++) { + var section = _a[_i]; + switch (section.kind) { + case "internal" /* Internal */: + case "text" /* Text */: + (texts || (texts = [])).push(createUnparsedNode(section, node)); + break; + case "no-default-lib" /* NoDefaultLib */: + case "reference" /* Reference */: + case "type" /* Type */: + case "lib" /* Lib */: + (syntheticReferences || (syntheticReferences = [])).push(createUnparsedSyntheticReference(section, node)); + break; + // Ignore + case "prologue" /* Prologue */: + case "emitHelpers" /* EmitHelpers */: + case "prepend" /* Prepend */: + break; + default: + ts.Debug.assertNever(section); + } + } + node.texts = texts || ts.emptyArray; + node.helpers = ts.map(bundleFileInfo.sources && bundleFileInfo.sources.helpers, function (name) { return getAllUnscopedEmitHelpers().get(name); }); + node.syntheticReferences = syntheticReferences; + return node; + } + function mapBundleFileSectionKindToSyntaxKind(kind) { + switch (kind) { + case "prologue" /* Prologue */: return 279 /* UnparsedPrologue */; + case "prepend" /* Prepend */: return 280 /* UnparsedPrepend */; + case "internal" /* Internal */: return 282 /* UnparsedInternalText */; + case "text" /* Text */: return 281 /* UnparsedText */; + case "emitHelpers" /* EmitHelpers */: + case "no-default-lib" /* NoDefaultLib */: + case "reference" /* Reference */: + case "type" /* Type */: + case "lib" /* Lib */: + return ts.Debug.fail("BundleFileSectionKind: " + kind + " not yet mapped to SyntaxKind"); + default: + return ts.Debug.assertNever(kind); + } + } + function createUnparsedNode(section, parent) { + var node = ts.createNode(mapBundleFileSectionKindToSyntaxKind(section.kind), section.pos, section.end); + node.parent = parent; + node.data = section.data; + return node; + } + function createUnparsedSyntheticReference(section, parent) { + var node = ts.createNode(283 /* UnparsedSyntheticReference */, section.pos, section.end); + node.parent = parent; + node.data = section.data; + node.section = section; + return node; + } + function createInputFiles(javascriptTextOrReadFileText, declarationTextOrJavascriptPath, javascriptMapPath, javascriptMapTextOrDeclarationPath, declarationMapPath, declarationMapTextOrBuildInfoPath, javascriptPath, declarationPath, buildInfoPath, buildInfo, oldFileOfCurrentEmit) { + var node = ts.createNode(287 /* InputFiles */); if (!ts.isString(javascriptTextOrReadFileText)) { var cache_1 = ts.createMap(); var textGetter_1 = function (path) { @@ -62368,15 +62620,25 @@ var ts; var result = textGetter_1(path); return result !== undefined ? result : "/* Input file " + path + " was missing */\r\n"; }; + var buildInfo_1; + var getBuildInfo_1 = function (getText) { + if (buildInfo_1 === undefined) { + var result = getText(); + buildInfo_1 = result !== undefined ? JSON.parse(result) : false; + } + return buildInfo_1 || undefined; + }; node.javascriptPath = declarationTextOrJavascriptPath; node.javascriptMapPath = javascriptMapPath; node.declarationPath = ts.Debug.assertDefined(javascriptMapTextOrDeclarationPath); node.declarationMapPath = declarationMapPath; + node.buildInfoPath = declarationMapTextOrBuildInfoPath; Object.defineProperties(node, { javascriptText: { get: function () { return definedTextGetter_1(declarationTextOrJavascriptPath); } }, javascriptMapText: { get: function () { return textGetter_1(javascriptMapPath); } }, declarationText: { get: function () { return definedTextGetter_1(ts.Debug.assertDefined(javascriptMapTextOrDeclarationPath)); } }, - declarationMapText: { get: function () { return textGetter_1(declarationMapPath); } } // TODO:: if there is inline sourceMap in dtsFile, use that + declarationMapText: { get: function () { return textGetter_1(declarationMapPath); } }, + buildInfo: { get: function () { return getBuildInfo_1(function () { return textGetter_1(declarationMapTextOrBuildInfoPath); }); } } }); } else { @@ -62385,7 +62647,12 @@ var ts; node.javascriptMapText = javascriptMapTextOrDeclarationPath; node.declarationText = declarationTextOrJavascriptPath; node.declarationMapPath = declarationMapPath; - node.declarationMapText = declarationMapText; + node.declarationMapText = declarationMapTextOrBuildInfoPath; + node.javascriptPath = javascriptPath; + node.declarationPath = declarationPath, + node.buildInfoPath = buildInfoPath; + node.buildInfo = buildInfo; + node.oldFileOfCurrentEmit = oldFileOfCurrentEmit; } return node; } @@ -62523,7 +62790,7 @@ var ts; // To avoid holding onto transformation artifacts, we keep track of any // parse tree node we are annotating. This allows us to clean them up after // all transformations have completed. - if (node.kind === 279 /* SourceFile */) { + if (node.kind === 284 /* SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(ts.getParseTreeNode(ts.getSourceFileOfNode(node))); @@ -62969,38 +63236,38 @@ var ts; return ts.setEmitFlags(ts.createIdentifier(name), 4096 /* HelperName */ | 2 /* AdviseOnEmitNode */); } ts.getHelperName = getHelperName; - var valuesHelper = { + ts.valuesHelper = { name: "typescript:values", scoped: false, text: "\n var __values = (this && this.__values) || function (o) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator], i = 0;\n if (m) return m.call(o);\n return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n };" }; function createValuesHelper(context, expression, location) { - context.requestEmitHelper(valuesHelper); + context.requestEmitHelper(ts.valuesHelper); return ts.setTextRange(ts.createCall(getHelperName("__values"), /*typeArguments*/ undefined, [expression]), location); } ts.createValuesHelper = createValuesHelper; - var readHelper = { + ts.readHelper = { name: "typescript:read", scoped: false, text: "\n var __read = (this && this.__read) || function (o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n };" }; function createReadHelper(context, iteratorRecord, count, location) { - context.requestEmitHelper(readHelper); + context.requestEmitHelper(ts.readHelper); return ts.setTextRange(ts.createCall(getHelperName("__read"), /*typeArguments*/ undefined, count !== undefined ? [iteratorRecord, ts.createLiteral(count)] : [iteratorRecord]), location); } ts.createReadHelper = createReadHelper; - var spreadHelper = { + ts.spreadHelper = { name: "typescript:spread", scoped: false, text: "\n var __spread = (this && this.__spread) || function () {\n for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));\n return ar;\n };" }; function createSpreadHelper(context, argumentList, location) { - context.requestEmitHelper(readHelper); - context.requestEmitHelper(spreadHelper); + context.requestEmitHelper(ts.readHelper); + context.requestEmitHelper(ts.spreadHelper); return ts.setTextRange(ts.createCall(getHelperName("__spread"), /*typeArguments*/ undefined, argumentList), location); } @@ -63846,7 +64113,7 @@ var ts; case 190 /* ElementAccessExpression */: case 189 /* PropertyAccessExpression */: case 213 /* NonNullExpression */: - case 308 /* PartiallyEmittedExpression */: + case 313 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -63862,7 +64129,7 @@ var ts; ts.parenthesizeConciseBody = parenthesizeConciseBody; function isCommaSequence(node) { return node.kind === 204 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || - node.kind === 309 /* CommaListExpression */; + node.kind === 314 /* CommaListExpression */; } ts.isCommaSequence = isCommaSequence; var OuterExpressionKinds; @@ -63881,7 +64148,7 @@ var ts; case 212 /* AsExpression */: case 213 /* NonNullExpression */: return (kinds & 2 /* Assertions */) !== 0; - case 308 /* PartiallyEmittedExpression */: + case 313 /* PartiallyEmittedExpression */: return (kinds & 4 /* PartiallyEmittedExpressions */) !== 0; } return false; @@ -63918,7 +64185,7 @@ var ts; case 194 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); case 212 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); case 213 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); - case 308 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); + case 313 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -64710,12 +64977,12 @@ var ts; case 278 /* EnumMember */: return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); // Top-level nodes - case 279 /* SourceFile */: + case 284 /* SourceFile */: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 308 /* PartiallyEmittedExpression */: + case 313 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 309 /* CommaListExpression */: + case 314 /* CommaListExpression */: return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: // No need to visit nodes with no children. @@ -64771,7 +65038,7 @@ var ts; case 220 /* EmptyStatement */: case 210 /* OmittedExpression */: case 236 /* DebuggerStatement */: - case 307 /* NotEmittedStatement */: + case 312 /* NotEmittedStatement */: // No need to visit nodes with no children. break; // Names @@ -65148,14 +65415,14 @@ var ts; result = reduceNode(node.initializer, cbNode, result); break; // Top-level nodes - case 279 /* SourceFile */: + case 284 /* SourceFile */: result = reduceNodes(node.statements, cbNodes, result); break; // Transformation nodes - case 308 /* PartiallyEmittedExpression */: + case 313 /* PartiallyEmittedExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 309 /* CommaListExpression */: + case 314 /* CommaListExpression */: result = reduceNodes(node.elements, cbNodes, result); break; default: @@ -65436,7 +65703,7 @@ var ts; } exit(); } - function appendSourceMap(generatedLine, generatedCharacter, map, sourceMapPath) { + function appendSourceMap(generatedLine, generatedCharacter, map, sourceMapPath, start, end) { var _a; ts.Debug.assert(generatedLine >= pendingGeneratedLine, "generatedLine cannot backtrack"); ts.Debug.assert(generatedCharacter >= 0, "generatedCharacter cannot be negative"); @@ -65446,6 +65713,14 @@ var ts; var nameIndexToNewNameIndexMap; var mappingIterator = decodeMappings(map.mappings); for (var _b = mappingIterator.next(), raw = _b.value, done = _b.done; !done; _a = mappingIterator.next(), raw = _a.value, done = _a.done, _a) { + if (end && (raw.generatedLine > end.line || + (raw.generatedLine === end.line && raw.generatedCharacter > end.character))) { + break; + } + if (start && (raw.generatedLine < start.line || + (start.line === raw.generatedLine && raw.generatedCharacter < start.character))) { + continue; + } // Then reencode all the updated mappings into the overall map var newSourceIndex = void 0; var newSourceLine = void 0; @@ -65474,8 +65749,10 @@ var ts; } } } - var newGeneratedLine = raw.generatedLine + generatedLine; - var newGeneratedCharacter = raw.generatedLine === 0 ? raw.generatedCharacter + generatedCharacter : raw.generatedCharacter; + var rawGeneratedLine = raw.generatedLine - (start ? start.line : 0); + var newGeneratedLine = rawGeneratedLine + generatedLine; + var rawGeneratedCharacter = start && start.line === raw.generatedLine ? raw.generatedCharacter - start.character : raw.generatedCharacter; + var newGeneratedCharacter = rawGeneratedLine === 0 ? rawGeneratedCharacter + generatedCharacter : rawGeneratedCharacter; addMapping(newGeneratedLine, newGeneratedCharacter, newSourceIndex, newSourceLine, newSourceCharacter, newNameIndex); } exit(); @@ -65958,7 +66235,7 @@ var ts; function chainBundle(transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 279 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 284 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return ts.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -66619,7 +66896,7 @@ var ts; function makeAssignmentElement(name) { return name; } - var restHelper = { + ts.restHelper = { name: "typescript:rest", scoped: false, text: "\n var __rest = (this && this.__rest) || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)\n t[p[i]] = s[p[i]];\n return t;\n };" @@ -66628,7 +66905,7 @@ var ts; * `{ a, b, ...p } = o`, create `p = __rest(o, ["a", "b"]);` */ function createRestCall(context, value, elements, computedTempVariables, location) { - context.requestEmitHelper(restHelper); + context.requestEmitHelper(ts.restHelper); var propertyNames = []; var computedTempVariableOffset = 0; for (var i = 0; i < elements.length - 1; i++) { @@ -66729,14 +67006,14 @@ var ts; var pendingExpressions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 280 /* Bundle */) { + if (node.kind === 285 /* Bundle */) { return transformBundle(node); } return transformSourceFile(node); } function transformBundle(node) { return ts.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 282 /* InputFiles */) { + if (prepend.kind === 287 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend, "js"); } return prepend; @@ -66785,7 +67062,7 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: case 246 /* CaseBlock */: case 245 /* ModuleBlock */: case 218 /* Block */: @@ -69016,7 +69293,7 @@ var ts; // enums in any other scope are emitted as a `let` declaration. var statement = ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ ts.createVariableDeclaration(ts.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true)) - ], currentLexicalScope.kind === 279 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentLexicalScope.kind === 284 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { @@ -69581,7 +69858,7 @@ var ts; // If we are nested within a namespace declaration, we may need to qualifiy // an identifier that is exported from a merged namespace. var container = resolver.getReferencedExportContainer(node, /*prefixLocals*/ false); - if (container && container.kind !== 279 /* SourceFile */) { + if (container && container.kind !== 284 /* SourceFile */) { var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 244 /* ModuleDeclaration */) || (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 243 /* EnumDeclaration */); if (substitute) { @@ -69632,39 +69909,39 @@ var ts; argumentsArray.push(descriptor); } } - context.requestEmitHelper(decorateHelper); + context.requestEmitHelper(ts.decorateHelper); return ts.setTextRange(ts.createCall(ts.getHelperName("__decorate"), /*typeArguments*/ undefined, argumentsArray), location); } - var decorateHelper = { + ts.decorateHelper = { name: "typescript:decorate", scoped: false, priority: 2, text: "\n var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n };" }; function createMetadataHelper(context, metadataKey, metadataValue) { - context.requestEmitHelper(metadataHelper); + context.requestEmitHelper(ts.metadataHelper); return ts.createCall(ts.getHelperName("__metadata"), /*typeArguments*/ undefined, [ ts.createLiteral(metadataKey), metadataValue ]); } - var metadataHelper = { + ts.metadataHelper = { name: "typescript:metadata", scoped: false, priority: 3, text: "\n var __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n };" }; function createParamHelper(context, expression, parameterOffset, location) { - context.requestEmitHelper(paramHelper); + context.requestEmitHelper(ts.paramHelper); return ts.setTextRange(ts.createCall(ts.getHelperName("__param"), /*typeArguments*/ undefined, [ ts.createLiteral(parameterOffset), expression ]), location); } - var paramHelper = { + ts.paramHelper = { name: "typescript:param", scoped: false, priority: 4, @@ -70215,14 +70492,14 @@ var ts; ], 2 /* Const */)); } ts.createSuperAccessVariableStatement = createSuperAccessVariableStatement; - var awaiterHelper = { + ts.awaiterHelper = { name: "typescript:awaiter", scoped: false, priority: 5, text: "\n var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n };" }; function createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, body) { - context.requestEmitHelper(awaiterHelper); + context.requestEmitHelper(ts.awaiterHelper); var generatorFunc = ts.createFunctionExpression( /*modifiers*/ undefined, ts.createToken(40 /* AsteriskToken */), /*name*/ undefined, @@ -70854,7 +71131,7 @@ var ts; } } ts.transformES2018 = transformES2018; - var assignHelper = { + ts.assignHelper = { name: "typescript:assign", scoped: false, priority: 1, @@ -70865,28 +71142,28 @@ var ts; return ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "assign"), /*typeArguments*/ undefined, attributesSegments); } - context.requestEmitHelper(assignHelper); + context.requestEmitHelper(ts.assignHelper); return ts.createCall(ts.getHelperName("__assign"), /*typeArguments*/ undefined, attributesSegments); } ts.createAssignHelper = createAssignHelper; - var awaitHelper = { + ts.awaitHelper = { name: "typescript:await", scoped: false, text: "\n var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }" }; function createAwaitHelper(context, expression) { - context.requestEmitHelper(awaitHelper); + context.requestEmitHelper(ts.awaitHelper); return ts.createCall(ts.getHelperName("__await"), /*typeArguments*/ undefined, [expression]); } - var asyncGeneratorHelper = { + ts.asyncGeneratorHelper = { name: "typescript:asyncGenerator", scoped: false, text: "\n var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n };" }; function createAsyncGeneratorHelper(context, generatorFunc) { - context.requestEmitHelper(awaitHelper); - context.requestEmitHelper(asyncGeneratorHelper); + context.requestEmitHelper(ts.awaitHelper); + context.requestEmitHelper(ts.asyncGeneratorHelper); // Mark this node as originally an async function (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* AsyncFunctionBody */; return ts.createCall(ts.getHelperName("__asyncGenerator"), @@ -70896,24 +71173,24 @@ var ts; generatorFunc ]); } - var asyncDelegator = { + ts.asyncDelegator = { name: "typescript:asyncDelegator", scoped: false, text: "\n var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {\n var i, p;\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\n };" }; function createAsyncDelegatorHelper(context, expression, location) { - context.requestEmitHelper(awaitHelper); - context.requestEmitHelper(asyncDelegator); + context.requestEmitHelper(ts.awaitHelper); + context.requestEmitHelper(ts.asyncDelegator); return ts.setTextRange(ts.createCall(ts.getHelperName("__asyncDelegator"), /*typeArguments*/ undefined, [expression]), location); } - var asyncValues = { + ts.asyncValues = { name: "typescript:asyncValues", scoped: false, text: "\n var __asyncValues = (this && this.__asyncValues) || function (o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator], i;\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\n };" }; function createAsyncValuesHelper(context, expression, location) { - context.requestEmitHelper(asyncValues); + context.requestEmitHelper(ts.asyncValues); return ts.setTextRange(ts.createCall(ts.getHelperName("__asyncValues"), /*typeArguments*/ undefined, [expression]), location); } @@ -74725,7 +75002,7 @@ var ts; } ts.transformES2015 = transformES2015; function createExtendsHelper(context, name) { - context.requestEmitHelper(extendsHelper); + context.requestEmitHelper(ts.extendsHelper); return ts.createCall(ts.getHelperName("__extends"), /*typeArguments*/ undefined, [ name, @@ -74733,20 +75010,20 @@ var ts; ]); } function createTemplateObjectHelper(context, cooked, raw) { - context.requestEmitHelper(templateObjectHelper); + context.requestEmitHelper(ts.templateObjectHelper); return ts.createCall(ts.getHelperName("__makeTemplateObject"), /*typeArguments*/ undefined, [ cooked, raw ]); } - var extendsHelper = { + ts.extendsHelper = { name: "typescript:extends", scoped: false, priority: 0, text: "\n var __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n })();" }; - var templateObjectHelper = { + ts.templateObjectHelper = { name: "typescript:makeTemplateObject", scoped: false, priority: 0, @@ -77440,7 +77717,7 @@ var ts; } ts.transformGenerators = transformGenerators; function createGeneratorHelper(context, body) { - context.requestEmitHelper(generatorHelper); + context.requestEmitHelper(ts.generatorHelper); return ts.createCall(ts.getHelperName("__generator"), /*typeArguments*/ undefined, [ts.createThis(), body]); } @@ -77503,7 +77780,7 @@ var ts; // entering a finally block. // // For examples of how these are used, see the comments in ./transformers/generators.ts - var generatorHelper = { + ts.generatorHelper = { name: "typescript:generator", scoped: false, priority: 6, @@ -77536,7 +77813,7 @@ var ts; context.enableSubstitution(202 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. context.enableSubstitution(203 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. context.enableSubstitution(276 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(279 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableEmitNotification(284 /* SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var currentSourceFile; // The current file. @@ -77878,9 +78155,9 @@ var ts; return visitFunctionDeclaration(node); case 240 /* ClassDeclaration */: return visitClassDeclaration(node); - case 310 /* MergeDeclarationMarker */: + case 315 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 311 /* EndOfDeclarationMarker */: + case 316 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); @@ -78038,7 +78315,7 @@ var ts; } var promise = ts.createNew(ts.createIdentifier("Promise"), /*typeArguments*/ undefined, [func]); if (compilerOptions.esModuleInterop) { - context.requestEmitHelper(importStarHelper); + context.requestEmitHelper(ts.importStarHelper); return ts.createCall(ts.createPropertyAccess(promise, ts.createIdentifier("then")), /*typeArguments*/ undefined, [ts.getHelperName("__importStar")]); } return promise; @@ -78052,7 +78329,7 @@ var ts; var promiseResolveCall = ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Promise"), "resolve"), /*typeArguments*/ undefined, /*argumentsArray*/ []); var requireCall = ts.createCall(ts.createIdentifier("require"), /*typeArguments*/ undefined, arg ? [arg] : []); if (compilerOptions.esModuleInterop) { - context.requestEmitHelper(importStarHelper); + context.requestEmitHelper(ts.importStarHelper); requireCall = ts.createCall(ts.getHelperName("__importStar"), /*typeArguments*/ undefined, [requireCall]); } var func; @@ -78086,11 +78363,11 @@ var ts; return innerExpr; } if (ts.getImportNeedsImportStarHelper(node)) { - context.requestEmitHelper(importStarHelper); + context.requestEmitHelper(ts.importStarHelper); return ts.createCall(ts.getHelperName("__importStar"), /*typeArguments*/ undefined, [innerExpr]); } if (ts.getImportNeedsImportDefaultHelper(node)) { - context.requestEmitHelper(importDefaultHelper); + context.requestEmitHelper(ts.importDefaultHelper); return ts.createCall(ts.getHelperName("__importDefault"), /*typeArguments*/ undefined, [innerExpr]); } return innerExpr; @@ -78659,7 +78936,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 279 /* SourceFile */) { + if (node.kind === 284 /* SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -78747,7 +79024,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 279 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 284 /* SourceFile */) { return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), /*location*/ node); } @@ -78873,13 +79150,13 @@ var ts; text: "\n var __syncRequire = typeof module === \"object\" && typeof module.exports === \"object\";" }; // emit helper for `import * as Name from "foo"` - var importStarHelper = { + ts.importStarHelper = { name: "typescript:commonjsimportstar", scoped: false, text: "\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\n result[\"default\"] = mod;\n return result;\n};" }; // emit helper for `import Name from "foo"` - var importDefaultHelper = { + ts.importDefaultHelper = { name: "typescript:commonjsimportdefault", scoped: false, text: "\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};" @@ -78902,7 +79179,7 @@ var ts; context.enableSubstitution(204 /* BinaryExpression */); // Substitutes assignments to exported symbols. context.enableSubstitution(202 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. context.enableSubstitution(203 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableEmitNotification(279 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableEmitNotification(284 /* SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var exportFunctionsMap = []; // The export function associated with a source file. @@ -79472,7 +79749,7 @@ var ts; function shouldHoistVariableDeclarationList(node) { // hoist only non-block scoped declarations or block scoped declarations parented by source file return (ts.getEmitFlags(node) & 2097152 /* NoHoisting */) === 0 - && (enclosingBlockScopedContainer.kind === 279 /* SourceFile */ + && (enclosingBlockScopedContainer.kind === 284 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -79815,9 +80092,9 @@ var ts; return visitCatchClause(node); case 218 /* Block */: return visitBlock(node); - case 310 /* MergeDeclarationMarker */: + case 315 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 311 /* EndOfDeclarationMarker */: + case 316 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -80065,7 +80342,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 279 /* SourceFile */; + return container !== undefined && container.kind === 284 /* SourceFile */; } else { return false; @@ -80098,7 +80375,7 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 279 /* SourceFile */) { + if (node.kind === 284 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -80307,7 +80584,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 279 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 284 /* SourceFile */) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -80346,7 +80623,7 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(279 /* SourceFile */); + context.enableEmitNotification(284 /* SourceFile */); context.enableSubstitution(72 /* Identifier */); var currentSourceFile; return ts.chainBundle(transformSourceFile); @@ -80859,6 +81136,15 @@ var ts; return result.diagnostics; } ts.getDeclarationDiagnostics = getDeclarationDiagnostics; + function isInternalDeclaration(node, currentSourceFile) { + var parseTreeNode = ts.getParseTreeNode(node); + var leadingCommentRanges = parseTreeNode && ts.getLeadingCommentRangesOfNode(parseTreeNode, currentSourceFile); + return !!ts.forEach(leadingCommentRanges, function (range) { + var comment = currentSourceFile.text.substring(range.pos, range.end); + return ts.stringContains(comment, "@internal"); + }); + } + ts.isInternalDeclaration = isInternalDeclaration; var declarationEmitNodeBuilderFlags = 1024 /* MultilineObjectLiterals */ | 2048 /* WriteClassExpressionAsTypeLiteral */ | 4096 /* UseTypeOfFunction */ | @@ -80987,10 +81273,10 @@ var ts; } } function transformRoot(node) { - if (node.kind === 279 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJS(node))) { + if (node.kind === 284 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJS(node))) { return node; } - if (node.kind === 280 /* Bundle */) { + if (node.kind === 285 /* Bundle */) { isBundledEmit = true; refs = ts.createMap(); libs = ts.createMap(); @@ -81020,9 +81306,15 @@ var ts; var updated = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); return ts.updateSourceFileNode(sourceFile, transformAndReplaceLatePaintedStatements(updated), /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); }), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 282 /* InputFiles */) { - return ts.createUnparsedSourceFile(prepend, "dts"); + if (prepend.kind === 287 /* InputFiles */) { + var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal); + hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib; + collectReferences(sourceFile, refs); + recordTypeReferenceDirectivesIfNecessary(sourceFile.typeReferenceDirectives); + collectLibs(sourceFile, libs); + return sourceFile; } + return prepend; })); bundle.syntheticFileReferences = []; bundle.syntheticTypeReferences = getFileReferencesForUsedTypeReferences(); @@ -81114,7 +81406,7 @@ var ts; } } function collectReferences(sourceFile, ret) { - if (noResolve || ts.isSourceFileJS(sourceFile)) + if (noResolve || (!ts.isUnparsedSource(sourceFile) && ts.isSourceFileJS(sourceFile))) return ret; ts.forEach(sourceFile.referencedFiles, function (f) { var elem = ts.tryResolveScriptReference(host, sourceFile, f); @@ -81842,18 +82134,8 @@ var ts; } errorNameNode = undefined; } - function hasInternalAnnotation(range) { - var comment = currentSourceFile.text.substring(range.pos, range.end); - return ts.stringContains(comment, "@internal"); - } function shouldStripInternal(node) { - if (stripInternal && node) { - var leadingCommentRanges = ts.getLeadingCommentRangesOfNode(ts.getParseTreeNode(node), currentSourceFile); - if (ts.forEach(leadingCommentRanges, hasInternalAnnotation)) { - return true; - } - } - return false; + return !!stripInternal && !!node && isInternalDeclaration(node, currentSourceFile); } function isScopeMarker(node) { return ts.isExportAssignment(node) || ts.isExportDeclaration(node); @@ -81875,7 +82157,7 @@ var ts; function ensureModifierFlags(node, privateDeclaration) { var mask = 3071 /* All */ ^ (4 /* Public */ | 256 /* Async */); // No async modifiers in declaration files var additions = (needsDeclare && !isAlwaysType(node)) ? 2 /* Ambient */ : 0 /* None */; - var parentIsFile = node.parent.kind === 279 /* SourceFile */; + var parentIsFile = node.parent.kind === 284 /* SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= ((privateDeclaration || (isBundledEmit && parentIsFile) || hasScopeMarker(node.parent) ? 0 : 1 /* Export */) | 2 /* Ambient */); additions = 0 /* None */; @@ -82092,7 +82374,7 @@ var ts; * @param allowDtsFiles A value indicating whether to allow the transformation of .d.ts files. */ function transformNodes(resolver, host, options, nodes, transformers, allowDtsFiles) { - var enabledSyntaxKindFeatures = new Array(312 /* Count */); + var enabledSyntaxKindFeatures = new Array(317 /* Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentVariableDeclarationsStack = []; @@ -82352,10 +82634,14 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - var infoExtension = ".tsbundleinfo"; var brackets = createBracketsMap(); var syntheticParent = { pos: -1, end: -1 }; /*@internal*/ + function isBuildInfoFile(file) { + return ts.fileExtensionIs(file, ".tsbuildinfo" /* TsBuildInfo */); + } + ts.isBuildInfoFile = isBuildInfoFile; + /*@internal*/ /** * Iterates over the source files that are expected to have an emit output. * @@ -82365,13 +82651,14 @@ var ts; * If an array, the full list of source files to emit. * Else, calls `getSourceFilesToEmit` with the (optional) target source file to determine the list of source files to emit. */ - function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, emitOnlyDtsFiles) { + function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, emitOnlyDtsFiles, onlyBuildInfo, includeBuildInfo) { if (emitOnlyDtsFiles === void 0) { emitOnlyDtsFiles = false; } var sourceFiles = ts.isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : ts.getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile); var options = host.getCompilerOptions(); if (options.outFile || options.out) { - if (sourceFiles.length) { - var bundle = ts.createBundle(sourceFiles, host.getPrependNodes()); + var prepends = host.getPrependNodes(); + if (sourceFiles.length || prepends.length) { + var bundle = ts.createBundle(sourceFiles, prepends); var result = action(getOutputPathsFor(bundle, host, emitOnlyDtsFiles), bundle); if (result) { return result; @@ -82379,31 +82666,61 @@ var ts; } } else { - for (var _a = 0, sourceFiles_1 = sourceFiles; _a < sourceFiles_1.length; _a++) { - var sourceFile = sourceFiles_1[_a]; - var result = action(getOutputPathsFor(sourceFile, host, emitOnlyDtsFiles), sourceFile); - if (result) { - return result; + if (!onlyBuildInfo) { + for (var _a = 0, sourceFiles_1 = sourceFiles; _a < sourceFiles_1.length; _a++) { + var sourceFile = sourceFiles_1[_a]; + var result = action(getOutputPathsFor(sourceFile, host, emitOnlyDtsFiles), sourceFile); + if (result) { + return result; + } } } + if (includeBuildInfo) { + var buildInfoPath = getOutputPathForBuildInfo(host.getCompilerOptions()); + if (buildInfoPath) + return action({ buildInfoPath: buildInfoPath }, /*sourceFileOrBundle*/ undefined); + } } } ts.forEachEmittedFile = forEachEmittedFile; /*@internal*/ + function getOutputPathForBuildInfo(options) { + var configFile = options.configFilePath; + if (!configFile || !ts.isIncrementalCompilation(options)) + return undefined; + if (options.tsBuildInfoFile) + return options.tsBuildInfoFile; + var outPath = options.outFile || options.out; + var buildInfoExtensionLess; + if (outPath) { + buildInfoExtensionLess = ts.removeFileExtension(outPath); + } + else { + var configFileExtensionLess = ts.removeFileExtension(configFile); + buildInfoExtensionLess = options.outDir ? + options.rootDir ? + ts.resolvePath(options.outDir, ts.getRelativePathFromDirectory(options.rootDir, configFileExtensionLess, /*ignoreCase*/ true)) : + ts.combinePaths(options.outDir, ts.getBaseFileName(configFileExtensionLess)) : + configFileExtensionLess; + } + return buildInfoExtensionLess + ".tsbuildinfo" /* TsBuildInfo */; + } + ts.getOutputPathForBuildInfo = getOutputPathForBuildInfo; + /*@internal*/ function getOutputPathsForBundle(options, forceDtsPaths) { var outPath = options.outFile || options.out; var jsFilePath = options.emitDeclarationOnly ? undefined : outPath; var sourceMapFilePath = jsFilePath && getSourceMapFilePath(jsFilePath, options); var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.removeFileExtension(outPath) + ".d.ts" /* Dts */ : undefined; var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; - var bundleInfoPath = options.references && jsFilePath ? (ts.removeFileExtension(jsFilePath) + infoExtension) : undefined; - return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, bundleInfoPath: bundleInfoPath }; + var buildInfoPath = getOutputPathForBuildInfo(options); + return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: buildInfoPath }; } ts.getOutputPathsForBundle = getOutputPathsForBundle; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 280 /* Bundle */) { + if (sourceFile.kind === 285 /* Bundle */) { return getOutputPathsForBundle(options, forceDtsPaths); } else { @@ -82417,19 +82734,13 @@ var ts; var isJs = ts.isSourceFileJS(sourceFile); var declarationFilePath = ((forceDtsPaths || ts.getEmitDeclarations(options)) && !isJs) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; - return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, bundleInfoPath: undefined }; + return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: undefined }; } } ts.getOutputPathsFor = getOutputPathsFor; function getSourceMapFilePath(jsFilePath, options) { return (options.sourceMap && !options.inlineSourceMap) ? jsFilePath + ".map" : undefined; } - function createDefaultBundleInfo() { - return { - originalOffset: -1, - totalLength: -1 - }; - } // JavaScript files are always LanguageVariant.JSX, as JSX syntax is allowed in .js files also. // So for JavaScript files, '.jsx' is only emitted if the input was '.jsx', and JsxEmit.Preserve. // For TypeScript, the only time to emit with a '.jsx' extension, is on JSX input, and JsxEmit.Preserve @@ -82454,7 +82765,7 @@ var ts; ts.getOutputExtension = getOutputExtension; /*@internal*/ // targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature - function emitFiles(resolver, host, targetSourceFile, emitOnlyDtsFiles, transformers, declarationTransformers) { + function emitFiles(resolver, host, targetSourceFile, emitOnlyDtsFiles, transformers, declarationTransformers, onlyBuildInfo) { var compilerOptions = host.getCompilerOptions(); var sourceMapDataList = (compilerOptions.sourceMap || compilerOptions.inlineSourceMap || ts.getAreDeclarationMapsEnabled(compilerOptions)) ? [] : undefined; var emittedFilesList = compilerOptions.listEmittedFiles ? [] : undefined; @@ -82462,12 +82773,12 @@ var ts; var newLine = ts.getNewLineCharacter(compilerOptions, function () { return host.getNewLine(); }); var writer = ts.createTextWriter(newLine); var _a = ts.performance.createTimer("printTime", "beforePrint", "afterPrint"), enter = _a.enter, exit = _a.exit; - var bundleInfo = createDefaultBundleInfo(); + var bundleBuildInfo; var emitSkipped = false; var exportedModulesFromDeclarationEmit; // Emit each output file enter(); - forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), emitOnlyDtsFiles); + forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), emitOnlyDtsFiles, onlyBuildInfo, !targetSourceFile); exit(); return { emitSkipped: emitSkipped, @@ -82477,9 +82788,16 @@ var ts; exportedModulesFromDeclarationEmit: exportedModulesFromDeclarationEmit }; function emitSourceFileOrBundle(_a, sourceFileOrBundle) { - var jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, bundleInfoPath = _a.bundleInfoPath; - emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, bundleInfoPath); + var jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath; + if (buildInfoPath && sourceFileOrBundle && ts.isBundle(sourceFileOrBundle)) { + bundleBuildInfo = { + commonSourceDirectory: host.getCommonSourceDirectory(), + sourceFiles: sourceFileOrBundle.sourceFiles.map(function (file) { return file.fileName; }) + }; + } + emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath); emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath); + emitBuildInfo(bundleBuildInfo, buildInfoPath); if (!emitSkipped && emittedFilesList) { if (!emitOnlyDtsFiles) { if (jsFilePath) { @@ -82488,8 +82806,8 @@ var ts; if (sourceMapFilePath) { emittedFilesList.push(sourceMapFilePath); } - if (bundleInfoPath) { - emittedFilesList.push(bundleInfoPath); + if (buildInfoPath) { + emittedFilesList.push(buildInfoPath); } } if (declarationFilePath) { @@ -82500,8 +82818,21 @@ var ts; } } } - function emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, bundleInfoPath) { - if (emitOnlyDtsFiles || !jsFilePath) { + function emitBuildInfo(bundle, buildInfoPath) { + // Write build information if applicable + if (!buildInfoPath || targetSourceFile || emitSkipped) + return; + var program = host.getProgramBuildInfo(); + if (!bundle && !program) + return; + if (host.isEmitBlocked(buildInfoPath) || compilerOptions.noEmit) { + emitSkipped = true; + return; + } + ts.writeFile(host, emitterDiagnostics, buildInfoPath, getBuildInfoText({ bundle: bundle, program: program }), /*writeByteOrderMark*/ false); + } + function emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath) { + if (!sourceFileOrBundle || emitOnlyDtsFiles || !jsFilePath) { return; } // Make sure not to write js file and source map file if any of them cannot be written @@ -82521,6 +82852,7 @@ var ts; inlineSourceMap: compilerOptions.inlineSourceMap, inlineSources: compilerOptions.inlineSources, extendedDiagnostics: compilerOptions.extendedDiagnostics, + writeBundleFileInfo: !!bundleBuildInfo }; // Create a printer to print the nodes var printer = createPrinter(printerOptions, { @@ -82531,12 +82863,14 @@ var ts; substituteNode: transform.substituteNode, }); ts.Debug.assert(transform.transformed.length === 1, "Should only see one output from the transform"); - printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform.transformed[0], bundleInfoPath, printer, compilerOptions); + printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform.transformed[0], printer, compilerOptions); // Clean up emit nodes on parse tree transform.dispose(); + if (bundleBuildInfo) + bundleBuildInfo.js = printer.bundleFileInfo; } function emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath) { - if (!(declarationFilePath && !ts.isInJSFile(sourceFileOrBundle))) { + if (!sourceFileOrBundle || !(declarationFilePath && !ts.isInJSFile(sourceFileOrBundle))) { return; } var sourceFiles = ts.isSourceFile(sourceFileOrBundle) ? [sourceFileOrBundle] : sourceFileOrBundle.sourceFiles; @@ -82565,6 +82899,8 @@ var ts; inlineSourceMap: compilerOptions.inlineSourceMap, extendedDiagnostics: compilerOptions.extendedDiagnostics, onlyPrintJsDocStyle: true, + writeBundleFileInfo: !!bundleBuildInfo, + recordInternalSection: !!bundleBuildInfo }; var declarationPrinter = createPrinter(printerOptions, { // resolver hooks @@ -82577,18 +82913,20 @@ var ts; emitSkipped = emitSkipped || declBlocked; if (!declBlocked || emitOnlyDtsFiles) { ts.Debug.assert(declarationTransform.transformed.length === 1, "Should only see one output from the decl transform"); - printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], /* bundleInfopath*/ undefined, declarationPrinter, { + printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], declarationPrinter, { sourceMap: compilerOptions.declarationMap, sourceRoot: compilerOptions.sourceRoot, mapRoot: compilerOptions.mapRoot, extendedDiagnostics: compilerOptions.extendedDiagnostics, }); - if (emitOnlyDtsFiles && declarationTransform.transformed[0].kind === 279 /* SourceFile */) { + if (emitOnlyDtsFiles && declarationTransform.transformed[0].kind === 284 /* SourceFile */) { var sourceFile = declarationTransform.transformed[0]; exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit; } } declarationTransform.dispose(); + if (bundleBuildInfo) + bundleBuildInfo.dts = declarationPrinter.bundleFileInfo; } function collectLinkedAliases(node) { if (ts.isExportAssignment(node)) { @@ -82603,16 +82941,16 @@ var ts; } ts.forEachChild(node, collectLinkedAliases); } - function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, bundleInfoPath, printer, mapOptions) { - var bundle = sourceFileOrBundle.kind === 280 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 279 /* SourceFile */ ? sourceFileOrBundle : undefined; + function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) { + var bundle = sourceFileOrBundle.kind === 285 /* Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 284 /* SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; var sourceMapGenerator; if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) { sourceMapGenerator = ts.createSourceMapGenerator(host, ts.getBaseFileName(ts.normalizeSlashes(jsFilePath)), getSourceRoot(mapOptions), getSourceMapDirectory(mapOptions, jsFilePath, sourceFile), mapOptions); } if (bundle) { - printer.writeBundle(bundle, bundleInfo, writer, sourceMapGenerator); + printer.writeBundle(bundle, writer, sourceMapGenerator); } else { printer.writeFile(sourceFile, writer, sourceMapGenerator); @@ -82641,18 +82979,12 @@ var ts; } // Write the output file ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles); - // Write bundled offset information if applicable - if (bundleInfoPath) { - bundleInfo.totalLength = writer.getTextPos(); - ts.writeFile(host, emitterDiagnostics, bundleInfoPath, JSON.stringify(bundleInfo, undefined, 2), /*writeByteOrderMark*/ false); - } // Reset state writer.clear(); - bundleInfo = createDefaultBundleInfo(); } function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) { return (mapOptions.sourceMap || mapOptions.inlineSourceMap) - && (sourceFileOrBundle.kind !== 279 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); + && (sourceFileOrBundle.kind !== 284 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); } function getSourceRoot(mapOptions) { // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the @@ -82709,6 +83041,161 @@ var ts; } } ts.emitFiles = emitFiles; + /*@internal*/ + function getBuildInfoText(buildInfo) { + return JSON.stringify(buildInfo, undefined, 2); + } + ts.getBuildInfoText = getBuildInfoText; + /*@internal*/ + ts.notImplementedResolver = { + hasGlobalName: ts.notImplemented, + getReferencedExportContainer: ts.notImplemented, + getReferencedImportDeclaration: ts.notImplemented, + getReferencedDeclarationWithCollidingName: ts.notImplemented, + isDeclarationWithCollidingName: ts.notImplemented, + isValueAliasDeclaration: ts.notImplemented, + isReferencedAliasDeclaration: ts.notImplemented, + isTopLevelValueImportEqualsWithEntityName: ts.notImplemented, + getNodeCheckFlags: ts.notImplemented, + isDeclarationVisible: ts.notImplemented, + isLateBound: function (_node) { return false; }, + collectLinkedAliases: ts.notImplemented, + isImplementationOfOverload: ts.notImplemented, + isRequiredInitializedParameter: ts.notImplemented, + isOptionalUninitializedParameterProperty: ts.notImplemented, + isExpandoFunctionDeclaration: ts.notImplemented, + getPropertiesOfContainerFunction: ts.notImplemented, + createTypeOfDeclaration: ts.notImplemented, + createReturnTypeOfSignatureDeclaration: ts.notImplemented, + createTypeOfExpression: ts.notImplemented, + createLiteralConstValue: ts.notImplemented, + isSymbolAccessible: ts.notImplemented, + isEntityNameVisible: ts.notImplemented, + // Returns the constant value this property access resolves to: notImplemented, or 'undefined' for a non-constant + getConstantValue: ts.notImplemented, + getReferencedValueDeclaration: ts.notImplemented, + getTypeReferenceSerializationKind: ts.notImplemented, + isOptionalParameter: ts.notImplemented, + moduleExportsSomeValue: ts.notImplemented, + isArgumentsLocalBinding: ts.notImplemented, + getExternalModuleFileFromDeclaration: ts.notImplemented, + getTypeReferenceDirectivesForEntityName: ts.notImplemented, + getTypeReferenceDirectivesForSymbol: ts.notImplemented, + isLiteralConstDeclaration: ts.notImplemented, + getJsxFactoryEntity: ts.notImplemented, + getAllAccessorDeclarations: ts.notImplemented, + getSymbolOfExternalModuleSpecifier: ts.notImplemented, + isBindingCapturedByNode: ts.notImplemented, + }; + function createSourceFilesFromBundleBuildInfo(bundle) { + var sourceFiles = bundle.sourceFiles.map(function (fileName) { + var sourceFile = ts.createNode(284 /* SourceFile */, 0, 0); + sourceFile.fileName = fileName; + sourceFile.text = ""; + sourceFile.statements = ts.createNodeArray(); + return sourceFile; + }); + var jsBundle = ts.Debug.assertDefined(bundle.js); + ts.forEach(jsBundle.sources && jsBundle.sources.prologues, function (prologueInfo) { + var sourceFile = sourceFiles[prologueInfo.file]; + sourceFile.text = prologueInfo.text; + sourceFile.end = prologueInfo.text.length; + sourceFile.statements = ts.createNodeArray(prologueInfo.directives.map(function (directive) { + var statement = ts.createNode(221 /* ExpressionStatement */, directive.pos, directive.end); + statement.expression = ts.createNode(10 /* StringLiteral */, directive.expression.pos, directive.expression.end); + statement.expression.text = directive.expression.text; + return statement; + })); + }); + return sourceFiles; + } + /*@internal*/ + function emitUsingBuildInfo(config, host, getCommandLine) { + var _a = getOutputPathsForBundle(config.options, /*forceDtsPaths*/ false), buildInfoPath = _a.buildInfoPath, jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath; + var buildInfoText = host.readFile(ts.Debug.assertDefined(buildInfoPath)); + if (!buildInfoText) + return buildInfoPath; + var jsFileText = host.readFile(ts.Debug.assertDefined(jsFilePath)); + if (!jsFileText) + return jsFilePath; + var sourceMapText = sourceMapFilePath && host.readFile(sourceMapFilePath); + // error if no source map or for now if inline sourcemap + if ((sourceMapFilePath && !sourceMapText) || config.options.inlineSourceMap) + return sourceMapFilePath || "inline sourcemap decoding"; + // read declaration text + var declarationText = declarationFilePath && host.readFile(declarationFilePath); + if (declarationFilePath && !declarationText) + return declarationFilePath; + var declarationMapText = declarationMapPath && host.readFile(declarationMapPath); + // error if no source map or for now if inline sourcemap + if ((declarationMapPath && !declarationMapText) || config.options.inlineSourceMap) + return declarationMapPath || "inline sourcemap decoding"; + var buildInfo = JSON.parse(buildInfoText); + if (!buildInfo.bundle || !buildInfo.bundle.js || (declarationText && !buildInfo.bundle.dts)) + return buildInfoPath; + var ownPrependInput = ts.createInputFiles(jsFileText, declarationText, sourceMapFilePath, sourceMapText, declarationMapPath, declarationMapText, jsFilePath, declarationFilePath, buildInfoPath, buildInfo, + /*onlyOwnText*/ true); + var outputFiles = []; + var prependNodes = ts.createPrependNodes(config.projectReferences, getCommandLine, function (f) { return host.readFile(f); }); + var sourceFilesForJsEmit = createSourceFilesFromBundleBuildInfo(buildInfo.bundle); + var emitHost = { + getPrependNodes: ts.memoize(function () { return prependNodes.concat([ownPrependInput]); }), + getCanonicalFileName: host.getCanonicalFileName, + getCommonSourceDirectory: function () { return buildInfo.bundle.commonSourceDirectory; }, + getCompilerOptions: function () { return config.options; }, + getCurrentDirectory: function () { return host.getCurrentDirectory(); }, + getNewLine: function () { return host.getNewLine(); }, + getSourceFile: function () { return undefined; }, + getSourceFileByPath: function () { return undefined; }, + getSourceFiles: function () { return sourceFilesForJsEmit; }, + getLibFileFromReference: ts.notImplemented, + isSourceFileFromExternalLibrary: ts.returnFalse, + writeFile: function (name, text, writeByteOrderMark) { + switch (name) { + case jsFilePath: + if (jsFileText === text) + return; + break; + case sourceMapFilePath: + if (sourceMapText === text) + return; + break; + case buildInfoPath: + var newBuildInfo = JSON.parse(text); + newBuildInfo.program = buildInfo.program; + // Update sourceFileInfo + var _a = buildInfo.bundle, js = _a.js, dts = _a.dts, sourceFiles = _a.sourceFiles; + newBuildInfo.bundle.js.sources = js.sources; + if (dts) { + newBuildInfo.bundle.dts.sources = dts.sources; + } + newBuildInfo.bundle.sourceFiles = sourceFiles; + outputFiles.push({ name: name, text: getBuildInfoText(newBuildInfo), writeByteOrderMark: writeByteOrderMark }); + return; + case declarationFilePath: + if (declarationText === text) + return; + break; + case declarationMapPath: + if (declarationMapText === text) + return; + break; + default: + ts.Debug.assertNever(name); + } + outputFiles.push({ name: name, text: text, writeByteOrderMark: writeByteOrderMark }); + }, + isEmitBlocked: ts.returnFalse, + readFile: function (f) { return host.readFile(f); }, + fileExists: function (f) { return host.fileExists(f); }, + directoryExists: host.directoryExists && (function (f) { return host.directoryExists(f); }), + useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, + getProgramBuildInfo: function () { return undefined; } + }; + emitFiles(ts.notImplementedResolver, emitHost, /*targetSourceFile*/ undefined, /*emitOnlyDtsFiles*/ false, ts.getTransformers(config.options)); + return outputFiles; + } + ts.emitUsingBuildInfo = emitUsingBuildInfo; var PipelinePhase; (function (PipelinePhase) { PipelinePhase[PipelinePhase["Notification"] = 0] = "Notification"; @@ -82737,6 +83224,10 @@ var ts; var ownWriter; // Reusable `EmitTextWriter` for basic printing. var write = writeBase; var isOwnFileEmit; + var bundleFileInfo = printerOptions.writeBundleFileInfo ? { sections: [] } : undefined; + var recordInternalSection = printerOptions.recordInternalSection; + var sourceFileTextPos = 0; + var sourceFileTextKind = "text" /* Text */; // Source Maps var sourceMapsDisabled = true; var sourceMapGenerator; @@ -82762,7 +83253,8 @@ var ts; writeNode: writeNode, writeList: writeList, writeFile: writeFile, - writeBundle: writeBundle + writeBundle: writeBundle, + bundleFileInfo: bundleFileInfo }; function printNode(hint, node, sourceFile) { switch (hint) { @@ -82777,9 +83269,9 @@ var ts; break; } switch (node.kind) { - case 279 /* SourceFile */: return printFile(node); - case 280 /* Bundle */: return printBundle(node); - case 281 /* UnparsedSource */: return printUnparsedSource(node); + case 284 /* SourceFile */: return printFile(node); + case 285 /* Bundle */: return printBundle(node); + case 286 /* UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -82789,7 +83281,7 @@ var ts; return endPrint(); } function printBundle(bundle) { - writeBundle(bundle, /*bundleInfo*/ undefined, beginPrint(), /*sourceMapEmitter*/ undefined); + writeBundle(bundle, beginPrint(), /*sourceMapEmitter*/ undefined); return endPrint(); } function printFile(sourceFile) { @@ -82817,7 +83309,49 @@ var ts; reset(); writer = previousWriter; } - function writeBundle(bundle, bundleInfo, output, sourceMapGenerator) { + function getTextPosWithWriteLine() { + return writer.getTextPosWithWriteLine ? writer.getTextPosWithWriteLine() : writer.getTextPos(); + } + function updateOrPushBundleFileTextLike(pos, end, kind) { + var last = ts.lastOrUndefined(bundleFileInfo.sections); + if (last && last.kind === kind) { + last.end = end; + } + else { + bundleFileInfo.sections.push({ pos: pos, end: end, kind: kind }); + } + } + function recordBundleFileInternalSectionStart(node) { + if (recordInternalSection && + bundleFileInfo && + currentSourceFile && + (ts.isDeclaration(node) || ts.isVariableStatement(node)) && + ts.isInternalDeclaration(node, currentSourceFile) && + sourceFileTextKind !== "internal" /* Internal */) { + var prevSourceFileTextKind = sourceFileTextKind; + recordBundleFileTextLikeSection(writer.getTextPos()); + sourceFileTextPos = getTextPosWithWriteLine(); + sourceFileTextKind = "internal" /* Internal */; + return prevSourceFileTextKind; + } + return undefined; + } + function recordBundleFileInternalSectionEnd(prevSourceFileTextKind) { + if (prevSourceFileTextKind) { + recordBundleFileTextLikeSection(writer.getTextPos()); + sourceFileTextPos = getTextPosWithWriteLine(); + sourceFileTextKind = prevSourceFileTextKind; + } + } + function recordBundleFileTextLikeSection(end) { + if (sourceFileTextPos < end) { + updateOrPushBundleFileTextLike(sourceFileTextPos, end, sourceFileTextKind); + return true; + } + return false; + } + function writeBundle(bundle, output, sourceMapGenerator) { + var _a; isOwnFileEmit = false; var previousWriter = writer; setWriter(output, sourceMapGenerator); @@ -82825,18 +83359,49 @@ var ts; emitPrologueDirectivesIfNeeded(bundle); emitHelpers(bundle); emitSyntheticTripleSlashReferencesIfNeeded(bundle); - for (var _a = 0, _b = bundle.prepends; _a < _b.length; _a++) { - var prepend = _b[_a]; + for (var _b = 0, _c = bundle.prepends; _b < _c.length; _b++) { + var prepend = _c[_b]; writeLine(); + var pos = writer.getTextPos(); + var savedSections = bundleFileInfo && bundleFileInfo.sections; + if (savedSections) + bundleFileInfo.sections = []; print(4 /* Unspecified */, prepend, /*sourceFile*/ undefined); + if (bundleFileInfo) { + var newSections = bundleFileInfo.sections; + bundleFileInfo.sections = savedSections; + if (prepend.oldFileOfCurrentEmit) + (_a = bundleFileInfo.sections).push.apply(_a, newSections); + else { + newSections.forEach(function (section) { return ts.Debug.assert(ts.isBundleFileTextLike(section)); }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prepend" /* Prepend */, data: prepend.fileName, texts: newSections }); + } + } } - if (bundleInfo) { - bundleInfo.originalOffset = writer.getTextPos(); - } - for (var _c = 0, _d = bundle.sourceFiles; _c < _d.length; _c++) { - var sourceFile = _d[_c]; + sourceFileTextPos = getTextPosWithWriteLine(); + for (var _d = 0, _e = bundle.sourceFiles; _d < _e.length; _d++) { + var sourceFile = _e[_d]; print(0 /* SourceFile */, sourceFile, sourceFile); } + if (bundleFileInfo && bundle.sourceFiles.length) { + var end = writer.getTextPos(); + if (recordBundleFileTextLikeSection(end)) { + // Store prologues + var prologues = getPrologueDirectivesFromBundledSourceFiles(bundle); + if (prologues) { + if (!bundleFileInfo.sources) + bundleFileInfo.sources = {}; + bundleFileInfo.sources.prologues = prologues; + } + // Store helpes + var helpers = getHelpersFromBundledSourceFiles(bundle); + if (helpers) { + if (!bundleFileInfo.sources) + bundleFileInfo.sources = {}; + bundleFileInfo.sources.helpers = helpers; + } + } + } reset(); writer = previousWriter; } @@ -82906,8 +83471,10 @@ var ts; function emit(node) { if (node === undefined) return; + var prevSourceFileTextKind = recordBundleFileInternalSectionStart(node); var pipelinePhase = getPipelinePhase(0 /* Notification */, node); pipelinePhase(4 /* Unspecified */, node); + recordBundleFileInternalSectionEnd(prevSourceFileTextKind); } function emitIdentifierName(node) { if (node === undefined) @@ -82934,12 +83501,12 @@ var ts; } // falls through case 2 /* Comments */: - if (!commentsDisabled && node.kind !== 279 /* SourceFile */) { + if (!commentsDisabled && node.kind !== 284 /* SourceFile */) { return pipelineEmitWithComments; } // falls through case 3 /* SourceMaps */: - if (!sourceMapsDisabled && node.kind !== 279 /* SourceFile */ && !ts.isInJsonFile(node)) { + if (!sourceMapsDisabled && node.kind !== 284 /* SourceFile */ && !ts.isInJsonFile(node)) { return pipelineEmitWithSourceMap; } // falls through @@ -82976,8 +83543,16 @@ var ts; case 16 /* TemplateMiddle */: case 17 /* TemplateTail */: return emitLiteral(node); - case 281 /* UnparsedSource */: - return emitUnparsedSource(node); + case 286 /* UnparsedSource */: + case 280 /* UnparsedPrepend */: + return emitUnparsedSourceOrPrepend(node); + case 279 /* UnparsedPrologue */: + return writeUnparsedNode(node); + case 281 /* UnparsedText */: + case 282 /* UnparsedInternalText */: + return emitUnparsedTextLike(node); + case 283 /* UnparsedSyntheticReference */: + return emitUnparsedSyntheticReference(node); // Identifiers case 72 /* Identifier */: return emitIdentifier(node); @@ -83021,7 +83596,7 @@ var ts; return emitTypeReference(node); case 165 /* FunctionType */: return emitFunctionType(node); - case 289 /* JSDocFunctionType */: + case 294 /* JSDocFunctionType */: return emitJSDocFunctionType(node); case 166 /* ConstructorType */: return emitConstructorType(node); @@ -83059,20 +83634,20 @@ var ts; return emitLiteralType(node); case 183 /* ImportType */: return emitImportTypeNode(node); - case 284 /* JSDocAllType */: + case 289 /* JSDocAllType */: writePunctuation("*"); return; - case 285 /* JSDocUnknownType */: + case 290 /* JSDocUnknownType */: writePunctuation("?"); return; - case 286 /* JSDocNullableType */: + case 291 /* JSDocNullableType */: return emitJSDocNullableType(node); - case 287 /* JSDocNonNullableType */: + case 292 /* JSDocNonNullableType */: return emitJSDocNonNullableType(node); - case 288 /* JSDocOptionalType */: + case 293 /* JSDocOptionalType */: return emitJSDocOptionalType(node); case 172 /* RestType */: - case 290 /* JSDocVariadicType */: + case 295 /* JSDocVariadicType */: return emitRestOrJSDocVariadicType(node); // Binding patterns case 184 /* ObjectBindingPattern */: @@ -83210,30 +83785,30 @@ var ts; case 278 /* EnumMember */: return emitEnumMember(node); // JSDoc nodes (only used in codefixes currently) - case 299 /* JSDocParameterTag */: - case 305 /* JSDocPropertyTag */: + case 304 /* JSDocParameterTag */: + case 310 /* JSDocPropertyTag */: return emitJSDocPropertyLikeTag(node); - case 300 /* JSDocReturnTag */: - case 302 /* JSDocTypeTag */: - case 301 /* JSDocThisTag */: - case 298 /* JSDocEnumTag */: + case 305 /* JSDocReturnTag */: + case 307 /* JSDocTypeTag */: + case 306 /* JSDocThisTag */: + case 303 /* JSDocEnumTag */: return emitJSDocSimpleTypedTag(node); - case 295 /* JSDocAugmentsTag */: + case 300 /* JSDocAugmentsTag */: return emitJSDocAugmentsTag(node); - case 303 /* JSDocTemplateTag */: + case 308 /* JSDocTemplateTag */: return emitJSDocTemplateTag(node); - case 304 /* JSDocTypedefTag */: + case 309 /* JSDocTypedefTag */: return emitJSDocTypedefTag(node); - case 297 /* JSDocCallbackTag */: + case 302 /* JSDocCallbackTag */: return emitJSDocCallbackTag(node); - case 293 /* JSDocSignature */: + case 298 /* JSDocSignature */: return emitJSDocSignature(node); - case 292 /* JSDocTypeLiteral */: + case 297 /* JSDocTypeLiteral */: return emitJSDocTypeLiteral(node); - case 296 /* JSDocClassTag */: - case 294 /* JSDocTag */: + case 301 /* JSDocClassTag */: + case 299 /* JSDocTag */: return emitJSDocSimpleTag(node); - case 291 /* JSDocComment */: + case 296 /* JSDocComment */: return emitJSDoc(node); // Transformation nodes (ignored) } @@ -83332,9 +83907,9 @@ var ts; case 264 /* JsxFragment */: return emitJsxFragment(node); // Transformation nodes - case 308 /* PartiallyEmittedExpression */: + case 313 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 309 /* CommaListExpression */: + case 314 /* CommaListExpression */: return emitCommaList(node); } } @@ -83350,22 +83925,45 @@ var ts; var pipelinePhase = getNextPipelinePhase(1 /* Substitution */, node); pipelinePhase(hint, substituteNode(hint, node)); } + function getHelpersFromBundledSourceFiles(bundle) { + var result; + if (moduleKind === ts.ModuleKind.None || printerOptions.noEmitHelpers) { + return undefined; + } + var bundledHelpers = ts.createMap(); + for (var _a = 0, _b = bundle.sourceFiles; _a < _b.length; _a++) { + var sourceFile = _b[_a]; + var shouldSkip = ts.getExternalHelpersModuleName(sourceFile) !== undefined; + var helpers = getSortedEmitHelpers(sourceFile); + if (!helpers) + continue; + for (var _c = 0, helpers_3 = helpers; _c < helpers_3.length; _c++) { + var helper = helpers_3[_c]; + if (!helper.scoped && !shouldSkip && !bundledHelpers.get(helper.name)) { + bundledHelpers.set(helper.name, true); + (result || (result = [])).push(helper.name); + } + } + } + return result; + } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 280 /* Bundle */ ? node : undefined; + var bundle = node.kind === 285 /* Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } - var numNodes = bundle ? bundle.sourceFiles.length : 1; + var numPrepends = bundle ? bundle.prepends.length : 0; + var numNodes = bundle ? bundle.sourceFiles.length + numPrepends : 1; for (var i = 0; i < numNodes; i++) { - var currentNode = bundle ? bundle.sourceFiles[i] : node; - var sourceFile = ts.isSourceFile(currentNode) ? currentNode : currentSourceFile; - var shouldSkip = printerOptions.noEmitHelpers || ts.getExternalHelpersModuleName(sourceFile) !== undefined; - var shouldBundle = ts.isSourceFile(currentNode) && !isOwnFileEmit; - var helpers = ts.getEmitHelpers(currentNode); + var currentNode = bundle ? i < numPrepends ? bundle.prepends[i] : bundle.sourceFiles[i - numPrepends] : node; + var sourceFile = ts.isSourceFile(currentNode) ? currentNode : ts.isUnparsedSource(currentNode) ? undefined : currentSourceFile; + var shouldSkip = printerOptions.noEmitHelpers || (!!sourceFile && ts.getExternalHelpersModuleName(sourceFile) !== undefined); + var shouldBundle = (ts.isSourceFile(currentNode) || ts.isUnparsedSource(currentNode)) && !isOwnFileEmit; + var helpers = ts.isUnparsedSource(currentNode) ? currentNode.helpers : getSortedEmitHelpers(currentNode); if (helpers) { - for (var _a = 0, _b = ts.stableSort(helpers, ts.compareEmitHelpers); _a < _b.length; _a++) { - var helper = _b[_a]; + for (var _a = 0, helpers_4 = helpers; _a < helpers_4.length; _a++) { + var helper = helpers_4[_a]; if (!helper.scoped) { // Skip the helper if it can be skipped and the noEmitHelpers compiler // option is set, or if it can be imported and the importHelpers compiler @@ -83385,18 +83983,25 @@ var ts; // Skip the helper if it is scoped and we are emitting bundled helpers continue; } + var pos = getTextPosWithWriteLine(); if (typeof helper.text === "string") { writeLines(helper.text); } else { writeLines(helper.text(makeFileLevelOptimisticUniqueName)); } + if (bundleFileInfo) + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "emitHelpers" /* EmitHelpers */, data: helper.name }); helpersEmitted = true; } } } return helpersEmitted; } + function getSortedEmitHelpers(node) { + var helpers = ts.getEmitHelpers(node); + return helpers && ts.stableSort(helpers, ts.compareEmitHelpers); + } // // Literals/Pseudo-literals // @@ -83423,8 +84028,42 @@ var ts; } } // SyntaxKind.UnparsedSource - function emitUnparsedSource(unparsed) { - writer.rawWrite(unparsed.text); + // SyntaxKind.UnparsedPrepend + function emitUnparsedSourceOrPrepend(unparsed) { + for (var _a = 0, _b = unparsed.texts; _a < _b.length; _a++) { + var text = _b[_a]; + writeLine(); + emit(text); + } + } + // SyntaxKind.UnparsedPrologue + // SyntaxKind.UnparsedText + // SyntaxKind.UnparsedInternal + // SyntaxKind.UnparsedSyntheticReference + function writeUnparsedNode(unparsed) { + writer.rawWrite(unparsed.parent.text.substring(unparsed.pos, unparsed.end)); + } + // SyntaxKind.UnparsedText + // SyntaxKind.UnparsedInternal + function emitUnparsedTextLike(unparsed) { + var pos = getTextPosWithWriteLine(); + writeUnparsedNode(unparsed); + if (bundleFileInfo) { + updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 281 /* UnparsedText */ ? + "text" /* Text */ : + "internal" /* Internal */); + } + } + // SyntaxKind.UnparsedSyntheticReference + function emitUnparsedSyntheticReference(unparsed) { + var pos = getTextPosWithWriteLine(); + writeUnparsedNode(unparsed); + if (bundleFileInfo) { + var section = ts.clone(unparsed.section); + section.pos = pos; + section.end = writer.getTextPos(); + bundleFileInfo.sections.push(section); + } } // // Identifiers @@ -83479,7 +84118,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 289 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 294 /* JSDocFunctionType */ && !node.name) { emit(node.type); } else { @@ -84359,7 +84998,7 @@ var ts; } function emitBlockFunctionBodyWorker(body, emitBlockFunctionBodyOnSingleLine) { // Emit all the prologue directives (like "use strict"). - var statementOffset = emitPrologueDirectives(body.statements, /*startWithNewLine*/ true); + var statementOffset = emitPrologueDirectives(body.statements); var pos = writer.getTextPos(); emitHelpers(body); if (statementOffset === 0 && pos === writer.getTextPos() && emitBlockFunctionBodyOnSingleLine) { @@ -84764,7 +85403,7 @@ var ts; } } if (node.tags) { - if (node.tags.length === 1 && node.tags[0].kind === 302 /* JSDocTypeTag */ && !node.comment) { + if (node.tags.length === 1 && node.tags[0].kind === 307 /* JSDocTypeTag */ && !node.comment) { writeSpace(); emit(node.tags[0]); } @@ -84798,7 +85437,7 @@ var ts; function emitJSDocTypedefTag(tag) { emitJSDocTagName(tag.tagName); if (tag.typeExpression) { - if (tag.typeExpression.kind === 283 /* JSDocTypeExpression */) { + if (tag.typeExpression.kind === 288 /* JSDocTypeExpression */) { emitJSDocTypeExpression(tag.typeExpression); } else { @@ -84817,7 +85456,7 @@ var ts; emit(tag.fullName); } emitJSDocComment(tag.comment); - if (tag.typeExpression && tag.typeExpression.kind === 292 /* JSDocTypeLiteral */) { + if (tag.typeExpression && tag.typeExpression.kind === 297 /* JSDocTypeLiteral */) { emitJSDocTypeLiteral(tag.typeExpression); } } @@ -84904,6 +85543,16 @@ var ts; } function emitSyntheticTripleSlashReferencesIfNeeded(node) { emitTripleSlashDirectives(!!node.hasNoDefaultLib, node.syntheticFileReferences || [], node.syntheticTypeReferences || [], node.syntheticLibReferences || []); + for (var _a = 0, _b = node.prepends; _a < _b.length; _a++) { + var prepend = _b[_a]; + if (ts.isUnparsedSource(prepend) && prepend.syntheticReferences) { + for (var _c = 0, _d = prepend.syntheticReferences; _c < _d.length; _c++) { + var ref = _d[_c]; + emit(ref); + writeLine(); + } + } + } } function emitTripleSlashDirectivesIfNeeded(node) { if (node.isDeclarationFile) @@ -84911,7 +85560,10 @@ var ts; } function emitTripleSlashDirectives(hasNoDefaultLib, files, types, libs) { if (hasNoDefaultLib) { + var pos = writer.getTextPos(); writeComment("/// "); + if (bundleFileInfo) + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "no-default-lib" /* NoDefaultLib */ }); writeLine(); } if (currentSourceFile && currentSourceFile.moduleName) { @@ -84932,17 +85584,26 @@ var ts; } for (var _c = 0, files_1 = files; _c < files_1.length; _c++) { var directive = files_1[_c]; + var pos = writer.getTextPos(); writeComment("/// "); + if (bundleFileInfo) + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference" /* Reference */, data: directive.fileName }); writeLine(); } for (var _d = 0, types_19 = types; _d < types_19.length; _d++) { var directive = types_19[_d]; + var pos = writer.getTextPos(); writeComment("/// "); + if (bundleFileInfo) + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "type" /* Type */, data: directive.fileName }); writeLine(); } for (var _e = 0, libs_1 = libs; _e < libs_1.length; _e++) { var directive = libs_1[_e]; + var pos = writer.getTextPos(); writeComment("/// "); + if (bundleFileInfo) + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "lib" /* Lib */, data: directive.fileName }); writeLine(); } } @@ -84967,16 +85628,22 @@ var ts; * Emits any prologue directives at the start of a Statement list, returning the * number of prologue directives written to the output. */ - function emitPrologueDirectives(statements, startWithNewLine, seenPrologueDirectives) { + function emitPrologueDirectives(statements, sourceFile, seenPrologueDirectives) { + var needsToSetSourceFile = !!sourceFile; for (var i = 0; i < statements.length; i++) { var statement = statements[i]; if (ts.isPrologueDirective(statement)) { var shouldEmitPrologueDirective = seenPrologueDirectives ? !seenPrologueDirectives.has(statement.expression.text) : true; if (shouldEmitPrologueDirective) { - if (startWithNewLine || i > 0) { - writeLine(); + if (needsToSetSourceFile) { + needsToSetSourceFile = false; + setSourceFile(sourceFile); } + writeLine(); + var pos = writer.getTextPos(); emit(statement); + if (bundleFileInfo) + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* Prologue */, data: statement.expression.text }); if (seenPrologueDirectives) { seenPrologueDirectives.set(statement.expression.text, true); } @@ -84989,23 +85656,70 @@ var ts; } return statements.length; } + function emitUnparsedPrologues(prologues, seenPrologueDirectives) { + for (var _a = 0, prologues_1 = prologues; _a < prologues_1.length; _a++) { + var prologue = prologues_1[_a]; + if (!seenPrologueDirectives.has(prologue.data)) { + writeLine(); + var pos = writer.getTextPos(); + emit(prologue); + if (bundleFileInfo) + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* Prologue */, data: prologue.data }); + if (seenPrologueDirectives) { + seenPrologueDirectives.set(prologue.data, true); + } + } + } + } function emitPrologueDirectivesIfNeeded(sourceFileOrBundle) { if (ts.isSourceFile(sourceFileOrBundle)) { - setSourceFile(sourceFileOrBundle); - emitPrologueDirectives(sourceFileOrBundle.statements); + emitPrologueDirectives(sourceFileOrBundle.statements, sourceFileOrBundle); } else { var seenPrologueDirectives = ts.createMap(); - for (var _a = 0, _b = sourceFileOrBundle.sourceFiles; _a < _b.length; _a++) { - var sourceFile = _b[_a]; - setSourceFile(sourceFile); - emitPrologueDirectives(sourceFile.statements, /*startWithNewLine*/ true, seenPrologueDirectives); + for (var _a = 0, _b = sourceFileOrBundle.prepends; _a < _b.length; _a++) { + var prepend = _b[_a]; + emitUnparsedPrologues(prepend.prologues, seenPrologueDirectives); + } + for (var _c = 0, _d = sourceFileOrBundle.sourceFiles; _c < _d.length; _c++) { + var sourceFile = _d[_c]; + emitPrologueDirectives(sourceFile.statements, sourceFile, seenPrologueDirectives); } setSourceFile(undefined); } } + function getPrologueDirectivesFromBundledSourceFiles(bundle) { + var seenPrologueDirectives = ts.createMap(); + var prologues; + for (var index = 0; index < bundle.sourceFiles.length; index++) { + var sourceFile = bundle.sourceFiles[index]; + var directives = void 0; + var end = 0; + for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { + var statement = _b[_a]; + if (!ts.isPrologueDirective(statement)) + break; + if (seenPrologueDirectives.has(statement.expression.text)) + continue; + seenPrologueDirectives.set(statement.expression.text, true); + (directives || (directives = [])).push({ + pos: statement.pos, + end: statement.end, + expression: { + pos: statement.expression.pos, + end: statement.expression.end, + text: statement.expression.text + } + }); + end = end < statement.end ? statement.end : end; + } + if (directives) + (prologues || (prologues = [])).push({ file: index, text: sourceFile.text.substring(0, end), directives: directives }); + } + return prologues; + } function emitShebangIfNeeded(sourceFileOrBundle) { - if (ts.isSourceFile(sourceFileOrBundle)) { + if (ts.isSourceFile(sourceFileOrBundle) || ts.isUnparsedSource(sourceFileOrBundle)) { var shebang = ts.getShebang(sourceFileOrBundle.text); if (shebang) { writeComment(shebang); @@ -85014,11 +85728,18 @@ var ts; } } else { - for (var _a = 0, _b = sourceFileOrBundle.sourceFiles; _a < _b.length; _a++) { - var sourceFile = _b[_a]; + for (var _a = 0, _b = sourceFileOrBundle.prepends; _a < _b.length; _a++) { + var prepend = _b[_a]; + ts.Debug.assertNode(prepend, ts.isUnparsedSource); + if (emitShebangIfNeeded(prepend)) { + return true; + } + } + for (var _c = 0, _d = sourceFileOrBundle.sourceFiles; _c < _d.length; _c++) { + var sourceFile = _d[_c]; // Emit only the first encountered shebang if (emitShebangIfNeeded(sourceFile)) { - break; + return true; } } } @@ -85221,6 +85942,7 @@ var ts; } // Emit each child. var previousSibling = void 0; + var previousSourceFileTextKind = void 0; var shouldDecreaseIndentAfterEmit = false; for (var i = 0; i < count; i++) { var child = children[start + i]; @@ -85241,6 +85963,7 @@ var ts; emitLeadingCommentsOfPosition(previousSibling.end); } writeDelimiter(format); + recordBundleFileInternalSectionEnd(previousSourceFileTextKind); // Write either a line terminator or whitespace to separate the elements. if (shouldWriteSeparatingLineTerminator(previousSibling, child, format)) { // If a synthesized node in a single-line list starts on a new @@ -85257,6 +85980,7 @@ var ts; } } // Emit this child. + previousSourceFileTextKind = recordBundleFileInternalSectionStart(child); if (shouldEmitInterveningComments) { if (emitTrailingCommentsOfPosition) { var commentRange = ts.getCommentRange(child); @@ -85291,6 +86015,7 @@ var ts; if (format & 128 /* Indented */) { decreaseIndent(); } + recordBundleFileInternalSectionEnd(previousSourceFileTextKind); // Write the closing line terminator or closing whitespace. if (shouldWriteClosingLineTerminator(parentNode, children, format)) { writeLine(); @@ -85392,7 +86117,6 @@ var ts; if (line.length) { writeLine(); write(line); - writer.rawWrite(newLine); } } } @@ -85906,7 +86630,7 @@ var ts; hasWrittenComment = false; var emitFlags = ts.getEmitFlags(node); var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end; - var isEmittedNode = node.kind !== 307 /* NotEmittedStatement */; + var isEmittedNode = node.kind !== 312 /* NotEmittedStatement */; // We have to explicitly check that the node is JsxText because if the compilerOptions.jsx is "preserve" we will not do any transformation. // It is expensive to walk entire tree just to set one kind of node to have no comments. var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0 || node.kind === 11 /* JsxText */; @@ -86166,19 +86890,28 @@ var ts; return ts.isRecognizedTripleSlashComment(currentSourceFile.text, commentPos, commentEnd); } // Source Maps + function getParsedSourceMap(node) { + if (node.parsedSourceMap === undefined && node.sourceMapText !== undefined) { + node.parsedSourceMap = ts.tryParseRawSourceMap(node.sourceMapText) || false; + } + return node.parsedSourceMap || undefined; + } function pipelineEmitWithSourceMap(hint, node) { var pipelinePhase = getNextPipelinePhase(3 /* SourceMaps */, node); - if (ts.isUnparsedSource(node) && node.sourceMapText !== undefined) { - var parsed = ts.tryParseRawSourceMap(node.sourceMapText); - if (parsed) { - sourceMapGenerator.appendSourceMap(writer.getLine(), writer.getColumn(), parsed, node.sourceMapPath); + if (ts.isUnparsedSource(node) || ts.isUnparsedPrepend(node)) { + pipelinePhase(hint, node); + } + else if (ts.isUnparsedNode(node)) { + var parsed = getParsedSourceMap(node.parent); + if (parsed && sourceMapGenerator) { + sourceMapGenerator.appendSourceMap(writer.getLine(), writer.getColumn(), parsed, node.parent.sourceMapPath, node.parent.getLineAndCharacterOfPosition(node.pos), node.parent.getLineAndCharacterOfPosition(node.end)); } pipelinePhase(hint, node); } else { var _a = ts.getSourceMapRange(node), pos = _a.pos, end = _a.end, _b = _a.source, source = _b === void 0 ? sourceMapSource : _b; var emitFlags = ts.getEmitFlags(node); - if (node.kind !== 307 /* NotEmittedStatement */ + if (node.kind !== 312 /* NotEmittedStatement */ && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 && pos >= 0) { emitSourcePos(source, skipSourceTrivia(source, pos)); @@ -86191,7 +86924,7 @@ var ts; else { pipelinePhase(hint, node); } - if (node.kind !== 307 /* NotEmittedStatement */ + if (node.kind !== 312 /* NotEmittedStatement */ && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 && end >= 0) { emitSourcePos(source, end); @@ -86839,7 +87572,8 @@ var ts; var value = readFileCache.get(key); if (value !== undefined) return value !== false ? value : undefined; // could be .d.ts from output - if (!ts.fileExtensionIs(fileName, ".json" /* Json */)) { + // Cache json or buildInfo + if (!ts.fileExtensionIs(fileName, ".json" /* Json */) && !ts.isBuildInfoFile(fileName)) { return originalReadFile.call(host, fileName); } return setReadFileCache(key, fileName); @@ -86870,7 +87604,7 @@ var ts; var key = toPath(fileName); fileExistsCache.delete(key); var value = readFileCache.get(key); - if (value && value !== data) { + if (value !== undefined && value !== data) { readFileCache.delete(key); sourceFileCache.delete(key); } @@ -87425,7 +88159,8 @@ var ts; getProjectReferenceRedirect: getProjectReferenceRedirect, getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, getResolvedProjectReferenceByPath: getResolvedProjectReferenceByPath, - forEachResolvedProjectReference: forEachResolvedProjectReference + forEachResolvedProjectReference: forEachResolvedProjectReference, + emitBuildInfo: emitBuildInfo }; verifyCompilerOptions(); ts.performance.mark("afterProgram"); @@ -87852,7 +88587,20 @@ var ts; return false; // Before falling back to the host return host.fileExists(f); - } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {}), { useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); } }); + } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {}), { useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, getProgramBuildInfo: function () { return program.getProgramBuildInfo && program.getProgramBuildInfo(); } }); + } + function emitBuildInfo(writeFileCallback) { + ts.Debug.assert(!options.out && !options.outFile); + ts.performance.mark("beforeEmit"); + var emitResult = ts.emitFiles(ts.notImplementedResolver, getEmitHost(writeFileCallback), + /*targetSourceFile*/ undefined, + /*emitOnlyDtsFiles*/ false, + /*transformers*/ undefined, + /*declaraitonTransformers*/ undefined, + /*onlyBuildInfo*/ true); + ts.performance.mark("afterEmit"); + ts.performance.measure("Emit", "beforeEmit", "afterEmit"); + return emitResult; } function getResolvedProjectReferences() { return resolvedProjectReferences; @@ -87861,28 +88609,11 @@ var ts; return projectReferences; } function getPrependNodes() { - if (!projectReferences) { - return ts.emptyArray; - } - var nodes = []; - for (var i = 0; i < projectReferences.length; i++) { - var ref = projectReferences[i]; - var resolvedRefOpts = resolvedProjectReferences[i].commandLine; - if (ref.prepend && resolvedRefOpts && resolvedRefOpts.options) { - var out = resolvedRefOpts.options.outFile || resolvedRefOpts.options.out; - // Upstream project didn't have outFile set -- skip (error will have been issued earlier) - if (!out) - continue; - var _a = ts.getOutputPathsForBundle(resolvedRefOpts.options, /*forceDtsPaths*/ true), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath; - var node = ts.createInputFiles(function (fileName) { - var path = toPath(fileName); - var sourceFile = getSourceFileByPath(path); - return sourceFile ? sourceFile.text : filesByName.has(path) ? undefined : host.readFile(path); - }, jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath); - nodes.push(node); - } - } - return nodes; + return createPrependNodes(projectReferences, function (_ref, index) { return resolvedProjectReferences[index].commandLine; }, function (fileName) { + var path = toPath(fileName); + var sourceFile = getSourceFileByPath(path); + return sourceFile ? sourceFile.text : filesByName.has(path) ? undefined : host.readFile(path); + }); } function isSourceFileFromExternalLibrary(file) { return !!sourceFilesFoundSearchingNodeModules.get(file.path); @@ -87954,8 +88685,7 @@ var ts; var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile, cancellationToken); ts.performance.mark("beforeEmit"); var transformers = emitOnlyDtsFiles ? [] : ts.getTransformers(options, customTransformers); - var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, // TODO: GH#18217 - emitOnlyDtsFiles, transformers, customTransformers && customTransformers.afterDeclarations); + var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, emitOnlyDtsFiles, transformers, customTransformers && customTransformers.afterDeclarations); ts.performance.mark("afterEmit"); ts.performance.measure("Emit", "beforeEmit", "afterEmit"); return emitResult; @@ -88957,6 +89687,14 @@ var ts; if (options.declaration === false) { createDiagnosticForOptionName(ts.Diagnostics.Composite_projects_may_not_disable_declaration_emit, "declaration"); } + if (options.incremental === false) { + createDiagnosticForOptionName(ts.Diagnostics.Composite_projects_may_not_disable_incremental_compilation, "declaration"); + } + } + if (options.tsBuildInfoFile) { + if (!ts.isIncrementalCompilation(options)) { + createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "tsBuildInfoFile", "incremental", "composite"); + } } verifyProjectReferences(); // List of collected files is complete; validate exhautiveness if this is a project with a file list @@ -89151,6 +89889,7 @@ var ts; } } function verifyProjectReferences() { + var buildInfoPath = !options.noEmit && !options.suppressOutputPathCheck ? ts.getOutputPathForBuildInfo(options) : undefined; forEachProjectReference(projectReferences, resolvedProjectReferences, function (resolvedRef, index, parent) { var ref = (parent ? parent.commandLine.projectReferences : projectReferences)[index]; var parentFile = parent && parent.sourceFile; @@ -89177,6 +89916,10 @@ var ts; createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_prepend_project_0_because_it_does_not_have_outFile_set, ref.path); } } + if (!parent && buildInfoPath && buildInfoPath === ts.getOutputPathForBuildInfo(options)) { + createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_write_file_0_because_it_will_overwrite_tsbuildinfo_file_generated_by_referenced_project_1, buildInfoPath, ref.path); + hasEmitBlockingDiagnostics.set(toPath(buildInfoPath), true); + } }); } function createDiagnosticForOptionPathKeyValue(key, valueIndex, message, arg0, arg1, arg2) { @@ -89326,6 +90069,27 @@ var ts; }; } ts.parseConfigHostFromCompilerHostLike = parseConfigHostFromCompilerHostLike; + /* @internal */ + function createPrependNodes(projectReferences, getCommandLine, readFile) { + if (!projectReferences) + return ts.emptyArray; + var nodes; + for (var i = 0; i < projectReferences.length; i++) { + var ref = projectReferences[i]; + var resolvedRefOpts = getCommandLine(ref, i); + if (ref.prepend && resolvedRefOpts && resolvedRefOpts.options) { + var out = resolvedRefOpts.options.outFile || resolvedRefOpts.options.out; + // Upstream project didn't have outFile set -- skip (error will have been issued earlier) + if (!out) + continue; + var _a = ts.getOutputPathsForBundle(resolvedRefOpts.options, /*forceDtsPaths*/ true), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath; + var node = ts.createInputFiles(readFile, jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, buildInfoPath); + (nodes || (nodes = [])).push(node); + } + } + return nodes || ts.emptyArray; + } + ts.createPrependNodes = createPrependNodes; function resolveProjectReferencePath(hostOrRef, ref) { var passedInRef = ref ? ref : hostOrRef; return ts.resolveConfigFileProjectName(passedInRef.path); @@ -89869,11 +90633,14 @@ var ts; var affectedSignatures = oldState.currentAffectedFilesSignatures; ts.Debug.assert(!oldState.affectedFiles && (!affectedSignatures || !affectedSignatures.size), "Cannot reuse if only few affected files of currentChangedFile were iterated"); } + var changedFilesSet = oldState.changedFilesSet; if (canCopySemanticDiagnostics) { - ts.Debug.assert(!ts.forEachKey(oldState.changedFilesSet, function (path) { return oldState.semanticDiagnosticsPerFile.has(path); }), "Semantic diagnostics shouldnt be available for changed files"); + ts.Debug.assert(!changedFilesSet || !ts.forEachKey(changedFilesSet, function (path) { return oldState.semanticDiagnosticsPerFile.has(path); }), "Semantic diagnostics shouldnt be available for changed files"); } // Copy old state's changed files set - ts.copyEntries(oldState.changedFilesSet, state.changedFilesSet); + if (changedFilesSet) { + ts.copyEntries(changedFilesSet, state.changedFilesSet); + } if (!compilerOptions.outFile && !compilerOptions.out && oldState.affectedFilesPendingEmit) { state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit; state.affectedFilesPendingEmitIndex = oldState.affectedFilesPendingEmitIndex; @@ -89919,6 +90686,18 @@ var ts; } } }); + if (oldCompilerOptions && + (oldCompilerOptions.outDir !== compilerOptions.outDir || + oldCompilerOptions.declarationDir !== compilerOptions.declarationDir || + (oldCompilerOptions.outFile || oldCompilerOptions.out) !== (compilerOptions.outFile || compilerOptions.out))) { + // Add all files to affectedFilesPendingEmit since emit changed + state.affectedFilesPendingEmit = ts.concatenate(state.affectedFilesPendingEmit, newProgram.getSourceFiles().map(function (f) { return f.path; })); + if (state.affectedFilesPendingEmitIndex === undefined) { + state.affectedFilesPendingEmitIndex = 0; + } + ts.Debug.assert(state.seenAffectedFiles === undefined); + state.seenAffectedFiles = ts.createMap(); + } return state; } /** @@ -90140,8 +90919,11 @@ var ts; * This is called after completing operation on the next affected file. * The operations here are postponed to ensure that cancellation during the iteration is handled correctly */ - function doneWithAffectedFile(state, affected, isPendingEmit) { - if (affected === state.program) { + function doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit) { + if (isBuildInfoEmit) { + state.emittedBuildInfo = true; + } + else if (affected === state.program) { state.changedFilesSet.clear(); state.programEmitComplete = true; } @@ -90158,8 +90940,8 @@ var ts; /** * Returns the result with affected file */ - function toAffectedFileResult(state, result, affected, isPendingEmit) { - doneWithAffectedFile(state, affected, isPendingEmit); + function toAffectedFileResult(state, result, affected, isPendingEmit, isBuildInfoEmit) { + doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit); return { result: result, affected: affected }; } /** @@ -90182,6 +90964,46 @@ var ts; } return diagnostics; } + /** + * Gets the program information to be emitted in buildInfo so that we can use it to create new program + */ + function getProgramBuildInfo(state) { + if (state.compilerOptions.outFile || state.compilerOptions.out) + return undefined; + var fileInfos = {}; + state.fileInfos.forEach(function (value, key) { + var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key); + fileInfos[key] = signature === undefined ? value : { version: value.version, signature: signature }; + }); + var result = { fileInfos: fileInfos, options: state.compilerOptions }; + if (state.referencedMap) { + var referencedMap_1 = {}; + state.referencedMap.forEach(function (value, key) { + referencedMap_1[key] = ts.arrayFrom(value.keys()); + }); + result.referencedMap = referencedMap_1; + } + if (state.exportedModulesMap) { + var exportedModulesMap_1 = {}; + state.exportedModulesMap.forEach(function (value, key) { + var newValue = state.currentAffectedFilesExportedModulesMap && state.currentAffectedFilesExportedModulesMap.get(key); + // Not in temporary cache, use existing value + if (newValue === undefined) + exportedModulesMap_1[key] = ts.arrayFrom(value.keys()); + // Value in cache and has updated value map, use that + else if (newValue) + exportedModulesMap_1[key] = ts.arrayFrom(newValue.keys()); + }); + result.exportedModulesMap = exportedModulesMap_1; + } + if (state.semanticDiagnosticsPerFile) { + var semanticDiagnosticsPerFile_1 = []; + // Currently not recording actual errors since those mean no emit for tsc --build + state.semanticDiagnosticsPerFile.forEach(function (_value, key) { return semanticDiagnosticsPerFile_1.push(key); }); + result.semanticDiagnosticsPerFile = semanticDiagnosticsPerFile_1; + } + return result; + } var BuilderProgramKind; (function (BuilderProgramKind) { BuilderProgramKind[BuilderProgramKind["SemanticDiagnosticsBuilderProgram"] = 0] = "SemanticDiagnosticsBuilderProgram"; @@ -90238,6 +91060,7 @@ var ts; var computeHash = host.createHash || ts.generateDjb2Hash; var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState); var backupState; + newProgram.getProgramBuildInfo = function () { return result.getProgramBuildInfo(); }; // To ensure that we arent storing any references to old program or new program without state newProgram = undefined; // TODO: GH#18217 oldProgram = undefined; @@ -90259,6 +91082,7 @@ var ts; releaseCache(state); backupState = undefined; }; + result.getProgramBuildInfo = function () { return getProgramBuildInfo(state); }; if (kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram) { result.getSemanticDiagnosticsOfNextAffectedFile = getSemanticDiagnosticsOfNextAffectedFile; } @@ -90281,7 +91105,16 @@ var ts; if (!state.compilerOptions.out && !state.compilerOptions.outFile) { affected = getNextAffectedFilePendingEmit(state); if (!affected) { - return undefined; + if (state.emittedBuildInfo) { + return undefined; + } + var affected_1 = ts.Debug.assertDefined(state.program); + return toAffectedFileResult(state, + // When whole program is affected, do emit only once (eg when --out or --outFile is specified) + // Otherwise just affected file + affected_1.emitBuildInfo(writeFile || host.writeFile, cancellationToken), affected_1, + /*isPendingEmitFile*/ false, + /*isBuildInfoEmit*/ true); } isPendingEmitFile = true; } @@ -90414,6 +91247,53 @@ var ts; } } ts.createBuilderProgram = createBuilderProgram; + function getMapOfReferencedSet(mapLike) { + if (!mapLike) + return undefined; + var map = ts.createMap(); + // Copies keys/values from template. Note that for..in will not throw if + // template is undefined, and instead will just exit the loop. + for (var key in mapLike) { + if (ts.hasProperty(mapLike, key)) { + map.set(key, ts.arrayToSet(mapLike[key])); + } + } + return map; + } + function createBuildProgramUsingProgramBuildInfo(program) { + var fileInfos = ts.createMapFromTemplate(program.fileInfos); + var state = { + fileInfos: fileInfos, + compilerOptions: program.options, + referencedMap: getMapOfReferencedSet(program.referencedMap), + exportedModulesMap: getMapOfReferencedSet(program.exportedModulesMap), + semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && ts.arrayToMap(program.semanticDiagnosticsPerFile, ts.identity, function () { return ts.emptyArray; }) + }; + return { + getState: function () { return state; }, + backupState: ts.noop, + restoreState: ts.noop, + getProgram: ts.notImplemented, + getProgramOrUndefined: function () { return undefined; }, + releaseProgram: ts.noop, + getCompilerOptions: function () { return state.compilerOptions; }, + getSourceFile: ts.notImplemented, + getSourceFiles: ts.notImplemented, + getOptionsDiagnostics: ts.notImplemented, + getGlobalDiagnostics: ts.notImplemented, + getConfigFileParsingDiagnostics: ts.notImplemented, + getSyntacticDiagnostics: ts.notImplemented, + getDeclarationDiagnostics: ts.notImplemented, + getSemanticDiagnostics: ts.notImplemented, + emit: ts.notImplemented, + getAllDependencies: ts.notImplemented, + getCurrentDirectory: ts.notImplemented, + emitNextAffectedFile: ts.notImplemented, + getSemanticDiagnosticsOfNextAffectedFile: ts.notImplemented, + getProgramBuildInfo: ts.notImplemented + }; + } + ts.createBuildProgramUsingProgramBuildInfo = createBuildProgramUsingProgramBuildInfo; function createRedirectedBuilderProgram(state, configFileParsingDiagnostics) { return { getState: ts.notImplemented, @@ -90433,7 +91313,8 @@ var ts; getSemanticDiagnostics: function (sourceFile, cancellationToken) { return getProgram().getSemanticDiagnostics(sourceFile, cancellationToken); }, emit: function (sourceFile, writeFile, cancellationToken, emitOnlyDts, customTransformers) { return getProgram().emit(sourceFile, writeFile, cancellationToken, emitOnlyDts, customTransformers); }, getAllDependencies: ts.notImplemented, - getCurrentDirectory: function () { return getProgram().getCurrentDirectory(); } + getCurrentDirectory: function () { return getProgram().getCurrentDirectory(); }, + getProgramBuildInfo: function () { return undefined; } }; function getProgram() { return ts.Debug.assertDefined(state.program); @@ -91461,6 +92342,8 @@ var ts; case ".jsx" /* Jsx */: case ".json" /* Json */: return ext; + case ".tsbuildinfo" /* TsBuildInfo */: + return ts.Debug.fail("Extension " + ".tsbuildinfo" /* TsBuildInfo */ + " is unsupported:: FileName:: " + fileName); default: return ts.Debug.assertNever(ext); } @@ -91742,7 +92625,7 @@ var ts; writeFile: function (path, data, writeByteOrderMark) { return system.writeFile(path, data, writeByteOrderMark); }, onCachedDirectoryStructureHostCreate: function (cacheHost) { return host = cacheHost || system; }, createHash: ts.maybeBind(system, system.createHash), - createProgram: createProgram + createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram }; } ts.createProgramHost = createProgramHost; @@ -91752,7 +92635,7 @@ var ts; function createWatchCompilerHost(system, createProgram, reportDiagnostic, reportWatchStatus) { if (system === void 0) { system = ts.sys; } var writeFileName = function (s) { return system.write(s + system.newLine); }; - var result = createProgramHost(system, createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram); + var result = createProgramHost(system, createProgram); ts.copyProperties(result, createWatchHost(system, reportWatchStatus)); result.afterProgramCreate = function (builderProgram) { var compilerOptions = builderProgram.getCompilerOptions(); @@ -92235,16 +93118,22 @@ var ts; * This means we can Pseudo-build (just touch timestamps), as if we had actually built this project. */ UpToDateStatusType[UpToDateStatusType["UpToDateWithUpstreamTypes"] = 2] = "UpToDateWithUpstreamTypes"; - UpToDateStatusType[UpToDateStatusType["OutputMissing"] = 3] = "OutputMissing"; - UpToDateStatusType[UpToDateStatusType["OutOfDateWithSelf"] = 4] = "OutOfDateWithSelf"; - UpToDateStatusType[UpToDateStatusType["OutOfDateWithUpstream"] = 5] = "OutOfDateWithUpstream"; - UpToDateStatusType[UpToDateStatusType["UpstreamOutOfDate"] = 6] = "UpstreamOutOfDate"; - UpToDateStatusType[UpToDateStatusType["UpstreamBlocked"] = 7] = "UpstreamBlocked"; - UpToDateStatusType[UpToDateStatusType["ComputingUpstream"] = 8] = "ComputingUpstream"; + /** + * The project appears out of date because its upstream inputs are newer than its outputs, + * but all of its outputs are actually newer than the previous identical outputs of its (.d.ts) inputs. + * This means we can Pseudo-build (just manipulate outputs), as if we had actually built this project. + */ + UpToDateStatusType[UpToDateStatusType["OutOfDateWithPrepend"] = 3] = "OutOfDateWithPrepend"; + UpToDateStatusType[UpToDateStatusType["OutputMissing"] = 4] = "OutputMissing"; + UpToDateStatusType[UpToDateStatusType["OutOfDateWithSelf"] = 5] = "OutOfDateWithSelf"; + UpToDateStatusType[UpToDateStatusType["OutOfDateWithUpstream"] = 6] = "OutOfDateWithUpstream"; + UpToDateStatusType[UpToDateStatusType["UpstreamOutOfDate"] = 7] = "UpstreamOutOfDate"; + UpToDateStatusType[UpToDateStatusType["UpstreamBlocked"] = 8] = "UpstreamBlocked"; + UpToDateStatusType[UpToDateStatusType["ComputingUpstream"] = 9] = "ComputingUpstream"; /** * Projects with no outputs (i.e. "solution" files) */ - UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 9] = "ContainerOnly"; + UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 10] = "ContainerOnly"; })(UpToDateStatusType = ts.UpToDateStatusType || (ts.UpToDateStatusType = {})); function createFileMap(toPath) { // tslint:disable-next-line:no-null-keyword @@ -92325,24 +93214,18 @@ var ts; } return outputs; } - function getOutFileOutputs(project) { - var out = project.options.outFile || project.options.out; - if (!out) { - return ts.Debug.fail("outFile must be set"); - } + function getOutFileOutputs(project, ignoreBuildInfo) { + ts.Debug.assert(!!project.options.outFile || !!project.options.out, "outFile must be set"); + var _a = ts.getOutputPathsForBundle(project.options, /*forceDtsPaths*/ false), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath; var outputs = []; - outputs.push(out); - if (project.options.sourceMap) { - outputs.push(out + ".map"); - } - if (ts.getEmitDeclarations(project.options)) { - var dts = ts.changeExtension(out, ".d.ts" /* Dts */); - outputs.push(dts); - if (project.options.declarationMap) { - outputs.push(dts + ".map"); - } - } - return outputs; + var addOutput = function (path) { return path && (outputs || (outputs = [])).push(path); }; + addOutput(jsFilePath); + addOutput(sourceMapFilePath); + addOutput(declarationFilePath); + addOutput(declarationMapPath); + if (!ignoreBuildInfo) + addOutput(buildInfoPath); + return outputs || ts.emptyArray; } function rootDirOfOptions(opts, configFileName) { return opts.rootDir || ts.getDirectoryPath(configFileName); @@ -92375,14 +93258,14 @@ var ts; } function createSolutionBuilderHost(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus, reportErrorSummary) { if (system === void 0) { system = ts.sys; } - var host = createSolutionBuilderHostBase(system, createProgram || ts.createAbstractBuilder, reportDiagnostic, reportSolutionBuilderStatus); + var host = createSolutionBuilderHostBase(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus); host.reportErrorSummary = reportErrorSummary; return host; } ts.createSolutionBuilderHost = createSolutionBuilderHost; function createSolutionBuilderWithWatchHost(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus, reportWatchStatus) { if (system === void 0) { system = ts.sys; } - var host = createSolutionBuilderHostBase(system, createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram, reportDiagnostic, reportSolutionBuilderStatus); + var host = createSolutionBuilderHostBase(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus); var watchHost = ts.createWatchHost(system, reportWatchStatus); ts.copyProperties(host, watchHost); return host; @@ -92416,7 +93299,17 @@ var ts; var compilerHost = ts.createCompilerHostFromProgramHost(host, function () { return projectCompilerOptions; }); var originalGetSourceFile = compilerHost.getSourceFile; var computeHash = host.createHash || ts.generateDjb2Hash; - updateGetSourceFile(); + compilerHost.getSourceFile = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var result = originalGetSourceFile.call.apply(originalGetSourceFile, [compilerHost].concat(args)); + if (result) { + result.version = computeHash.call(host, result.text); + } + return result; + }; // Watch state var builderPrograms = createFileMap(toPath); var diagnostics = createFileMap(toPath); @@ -92468,29 +93361,6 @@ var ts; ts.clearMap(allWatchedInputFiles, function (inputFileWatches) { return ts.clearMap(inputFileWatches, ts.closeFileWatcher); }); ts.clearMap(allWatchedConfigFiles, ts.closeFileWatcher); builderPrograms.clear(); - updateGetSourceFile(); - } - function updateGetSourceFile() { - if (options.watch) { - if (compilerHost.getSourceFile === originalGetSourceFile) { - compilerHost.getSourceFile = function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - var result = originalGetSourceFile.call.apply(originalGetSourceFile, [compilerHost].concat(args)); - if (result && options.watch) { - result.version = computeHash.call(host, result.text); - } - return result; - }; - } - } - else { - if (compilerHost.getSourceFile !== originalGetSourceFile) { - compilerHost.getSourceFile = originalGetSourceFile; - } - } } function isParsedCommandLine(entry) { return !!entry.options; @@ -92722,25 +93592,28 @@ var ts; upstreamProjectName: ref.path }; } - // If the upstream project's newest file is older than our oldest output, we - // can't be out of date because of it - if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) { - continue; + // Check oldest output file name only if there is no missing output file name + if (!missingOutputFileName) { + // If the upstream project's newest file is older than our oldest output, we + // can't be out of date because of it + if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) { + continue; + } + // If the upstream project has only change .d.ts files, and we've built + // *after* those files, then we're "psuedo up to date" and eligible for a fast rebuild + if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) { + pseudoUpToDate = true; + upstreamChangedProject = ref.path; + continue; + } + // We have an output older than an upstream output - we are out of date + ts.Debug.assert(oldestOutputFileName !== undefined, "Should have an oldest output filename here"); + return { + type: UpToDateStatusType.OutOfDateWithUpstream, + outOfDateOutputFileName: oldestOutputFileName, + newerProjectName: ref.path + }; } - // If the upstream project has only change .d.ts files, and we've built - // *after* those files, then we're "psuedo up to date" and eligible for a fast rebuild - if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) { - pseudoUpToDate = true; - upstreamChangedProject = ref.path; - continue; - } - // We have an output older than an upstream output - we are out of date - ts.Debug.assert(oldestOutputFileName !== undefined, "Should have an oldest output filename here"); - return { - type: UpToDateStatusType.OutOfDateWithUpstream, - outOfDateOutputFileName: oldestOutputFileName, - newerProjectName: ref.path - }; } } if (missingOutputFileName !== undefined) { @@ -92758,7 +93631,7 @@ var ts; } if (usesPrepend && pseudoUpToDate) { return { - type: UpToDateStatusType.OutOfDateWithUpstream, + type: UpToDateStatusType.OutOfDateWithPrepend, outOfDateOutputFileName: oldestOutputFileName, newerProjectName: upstreamChangedProject }; @@ -92892,7 +93765,9 @@ var ts; updateOutputTimestamps(proj); return; } - var buildResult = buildSingleProject(resolved); + var buildResult = status.type === UpToDateStatusType.OutOfDateWithPrepend ? + updateBundle(resolved) : // Fake that files have been built by manipulating prepend and existing output + buildSingleProject(resolved); // Actual build if (buildResult & BuildResultFlags.AnyErrors) return; var _a = getGlobalDependencyGraph(), referencingProjectsMap = _a.referencingProjectsMap, buildQueue = _a.buildQueue; @@ -92908,17 +93783,26 @@ var ts; // If declaration output is changed, build the project // otherwise mark the project UpToDateWithUpstreamTypes so it updates output time stamps var status_1 = projectStatus.getValue(project); - if (prepend || !(buildResult & BuildResultFlags.DeclarationOutputUnchanged)) { - if (status_1 && (status_1.type === UpToDateStatusType.UpToDate || status_1.type === UpToDateStatusType.UpToDateWithUpstreamTypes)) { + if (!(buildResult & BuildResultFlags.DeclarationOutputUnchanged)) { + if (status_1 && (status_1.type === UpToDateStatusType.UpToDate || status_1.type === UpToDateStatusType.UpToDateWithUpstreamTypes || status_1.type === UpToDateStatusType.OutOfDateWithPrepend)) { projectStatus.setValue(project, { type: UpToDateStatusType.OutOfDateWithUpstream, - outOfDateOutputFileName: status_1.oldestOutputFileName, + outOfDateOutputFileName: status_1.type === UpToDateStatusType.OutOfDateWithPrepend ? status_1.outOfDateOutputFileName : status_1.oldestOutputFileName, newerProjectName: resolved }); } } else if (status_1 && status_1.type === UpToDateStatusType.UpToDate) { - status_1.type = UpToDateStatusType.UpToDateWithUpstreamTypes; + if (prepend) { + projectStatus.setValue(project, { + type: UpToDateStatusType.OutOfDateWithPrepend, + outOfDateOutputFileName: status_1.oldestOutputFileName, + newerProjectName: resolved + }); + } + else { + status_1.type = UpToDateStatusType.UpToDateWithUpstreamTypes; + } } addProjToQueue(project); } @@ -92975,8 +93859,7 @@ var ts; } if (options.verbose) reportStatus(ts.Diagnostics.Building_project_0, proj); - var resultFlags = BuildResultFlags.None; - resultFlags |= BuildResultFlags.DeclarationOutputUnchanged; + var resultFlags = BuildResultFlags.DeclarationOutputUnchanged; var configFile = parseConfigFile(proj); if (!configFile) { // Failed to read the config file @@ -92992,8 +93875,7 @@ var ts; } // TODO: handle resolve module name to cache result in project reference redirect projectCompilerOptions = configFile.options; - var program = host.createProgram(configFile.fileNames, configFile.options, compilerHost, builderPrograms.getValue(proj), configFile.errors, configFile.projectReferences); - projectCompilerOptions = baseCompilerOptions; + var program = host.createProgram(configFile.fileNames, configFile.options, compilerHost, getOldProgram(proj, configFile), configFile.errors, configFile.projectReferences); // Don't emit anything in the presence of syntactic errors or options diagnostics var syntaxDiagnostics = program.getConfigFileParsingDiagnostics().concat(program.getOptionsDiagnostics(), program.getGlobalDiagnostics(), program.getSyntacticDiagnostics()); if (syntaxDiagnostics.length) { @@ -93054,12 +93936,14 @@ var ts; diagnostics.removeKey(proj); projectStatus.setValue(proj, status); afterProgramCreate(proj, program); + projectCompilerOptions = baseCompilerOptions; return resultFlags; function buildErrors(diagnostics, errorFlags, errorType) { resultFlags |= errorFlags; reportAndStoreErrors(proj, diagnostics); projectStatus.setValue(proj, { type: UpToDateStatusType.Unbuildable, reason: errorType + " errors" }); afterProgramCreate(proj, program); + projectCompilerOptions = baseCompilerOptions; return resultFlags; } } @@ -93072,9 +93956,65 @@ var ts; builderPrograms.setValue(proj, program); } } + function getOldProgram(proj, parsed) { + var value = builderPrograms.getValue(proj); + if (value) + return value; + var buildInfoPath = ts.getOutputPathForBuildInfo(parsed.options); + if (!buildInfoPath) + return undefined; + var content = readFileWithCache(buildInfoPath); + if (!content) + return undefined; + var buildInfo = JSON.parse(content); + return buildInfo.program && ts.createBuildProgramUsingProgramBuildInfo(buildInfo.program); + } + function updateBundle(proj) { + if (options.dry) { + reportStatus(ts.Diagnostics.A_non_dry_build_would_update_output_of_project_0, proj); + return BuildResultFlags.Success; + } + if (options.verbose) + reportStatus(ts.Diagnostics.Updating_output_of_project_0, proj); + // Update js, and source map + var config = ts.Debug.assertDefined(parseConfigFile(proj)); + projectCompilerOptions = config.options; + var outputFiles = ts.emitUsingBuildInfo(config, compilerHost, function (ref) { return parseConfigFile(resolveProjectName(ref.path)); }); + if (ts.isString(outputFiles)) { + reportStatus(ts.Diagnostics.Cannot_update_output_of_project_0_because_there_was_error_reading_file_1, proj, relName(outputFiles)); + return buildSingleProject(proj); + } + // Actual Emit + ts.Debug.assert(!!outputFiles.length); + var emitterDiagnostics = ts.createDiagnosticCollection(); + var emittedOutputs = createFileMap(toPath); + outputFiles.forEach(function (_a) { + var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark; + emittedOutputs.setValue(name, true); + ts.writeFile(compilerHost, emitterDiagnostics, name, text, writeByteOrderMark); + }); + var emitDiagnostics = emitterDiagnostics.getDiagnostics(); + if (emitDiagnostics.length) { + reportAndStoreErrors(proj, emitDiagnostics); + projectStatus.setValue(proj, { type: UpToDateStatusType.Unbuildable, reason: "Emit errors" }); + projectCompilerOptions = baseCompilerOptions; + return BuildResultFlags.DeclarationOutputUnchanged | BuildResultFlags.EmitErrors; + } + // Update timestamps for dts + var newestDeclarationFileContentChangedTime = updateOutputTimestampsWorker(config, minimumDate, ts.Diagnostics.Updating_unchanged_output_timestamps_of_project_0, emittedOutputs); + var status = { + type: UpToDateStatusType.UpToDate, + newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTime, + oldestOutputFileName: outputFiles[0].name + }; + diagnostics.removeKey(proj); + projectStatus.setValue(proj, status); + projectCompilerOptions = baseCompilerOptions; + return BuildResultFlags.DeclarationOutputUnchanged; + } function updateOutputTimestamps(proj) { if (options.dry) { - return reportStatus(ts.Diagnostics.A_non_dry_build_would_build_project_0, proj.options.configFilePath); + return reportStatus(ts.Diagnostics.A_non_dry_build_would_update_timestamps_for_output_of_project_0, proj.options.configFilePath); } var priorNewestUpdateTime = updateOutputTimestampsWorker(proj, minimumDate, ts.Diagnostics.Updating_output_timestamps_of_project_0); projectStatus.setValue(proj.options.configFilePath, { type: UpToDateStatusType.UpToDate, newestDeclarationFileContentChangedTime: priorNewestUpdateTime }); @@ -93201,7 +94141,9 @@ var ts; // Do nothing continue; } - var buildResult = buildSingleProject(next); + var buildResult = status.type === UpToDateStatusType.OutOfDateWithPrepend && !options.force ? + updateBundle(next) : // Fake that files have been built by manipulating prepend and existing output + buildSingleProject(next); // Actual build anyFailed = anyFailed || !!(buildResult & BuildResultFlags.AnyErrors); } reportErrorSummary(); @@ -93263,6 +94205,9 @@ var ts; var inputFile = _a[_i]; outputs.push.apply(outputs, getOutputFileNames(inputFile, project)); } + var buildInfoPath = ts.getOutputPathForBuildInfo(project.options); + if (buildInfoPath) + outputs.push(buildInfoPath); return outputs; } } @@ -93294,6 +94239,8 @@ var ts; } // Don't report anything for "up to date because it was already built" -- too verbose break; + case UpToDateStatusType.OutOfDateWithPrepend: + return formatMessage(ts.Diagnostics.Project_0_is_out_of_date_because_output_of_its_dependency_1_has_changed, relName(configFileName), relName(status.newerProjectName)); case UpToDateStatusType.UpToDateWithUpstreamTypes: return formatMessage(ts.Diagnostics.Project_0_is_up_to_date_with_d_ts_files_from_its_dependencies, relName(configFileName)); case UpToDateStatusType.UpstreamOutOfDate: @@ -94108,7 +95055,7 @@ var ts; case 242 /* TypeAliasDeclaration */: case 168 /* TypeLiteral */: return 2 /* Type */; - case 304 /* JSDocTypedefTag */: + case 309 /* JSDocTypedefTag */: // If it has no name node, it shares the name with the value declaration below it. return node.name === undefined ? 1 /* Value */ | 2 /* Type */ : 2 /* Type */; case 278 /* EnumMember */: @@ -94133,14 +95080,14 @@ var ts; case 255 /* ExportDeclaration */: return 7 /* All */; // An external module can be a Value - case 279 /* SourceFile */: + case 284 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 7 /* All */; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.kind === 279 /* SourceFile */) { + if (node.kind === 284 /* SourceFile */) { return 1 /* Value */; } else if (node.parent.kind === 254 /* ExportAssignment */ || node.parent.kind === 259 /* ExternalModuleReference */) { @@ -94346,7 +95293,7 @@ var ts; return undefined; } switch (node.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: case 156 /* MethodDeclaration */: case 155 /* MethodSignature */: case 239 /* FunctionDeclaration */: @@ -94364,7 +95311,7 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: return ts.isExternalModule(node) ? "module" /* moduleElement */ : "script" /* scriptElement */; case 244 /* ModuleDeclaration */: return "module" /* moduleElement */; @@ -94373,8 +95320,8 @@ var ts; return "class" /* classElement */; case 241 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; case 242 /* TypeAliasDeclaration */: - case 297 /* JSDocCallbackTag */: - case 304 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: + case 309 /* JSDocTypedefTag */: return "type" /* typeElement */; case 243 /* EnumDeclaration */: return "enum" /* enumElement */; case 237 /* VariableDeclaration */: @@ -94800,7 +95747,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 279 /* SourceFile */ || n.kind === 1 /* EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); + ts.Debug.assert(startNode !== undefined || n.kind === 284 /* SourceFile */ || n.kind === 1 /* EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); // Here we know that none of child token nodes embrace the position, // the only known case is when position is at the end of the file. // Try to find the rightmost token in the file without filtering. @@ -96545,18 +97492,18 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); // e.g. "param" pos = tag.tagName.end; switch (tag.kind) { - case 299 /* JSDocParameterTag */: + case 304 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 303 /* JSDocTemplateTag */: + case 308 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); pos = tag.end; break; - case 302 /* JSDocTypeTag */: + case 307 /* JSDocTypeTag */: processElement(tag.typeExpression); pos = tag.end; break; - case 300 /* JSDocReturnTag */: + case 305 /* JSDocReturnTag */: processElement(tag.typeExpression); pos = tag.end; break; @@ -96860,6 +97807,7 @@ var ts; case ".jsx" /* Jsx */: return ".jsx" /* jsxModifier */; case ".ts" /* Ts */: return ".ts" /* tsModifier */; case ".tsx" /* Tsx */: return ".tsx" /* tsxModifier */; + case ".tsbuildinfo" /* TsBuildInfo */: return ts.Debug.fail("Extension " + ".tsbuildinfo" /* TsBuildInfo */ + " is unsupported."); case undefined: return "" /* none */; default: return ts.Debug.assertNever(extension); @@ -97884,7 +98832,7 @@ var ts; return symbol.parent && (isModuleSymbol(symbol.parent) ? symbol : getFirstSymbolInChain(symbol.parent, enclosingDeclaration, checker)); } function isModuleSymbol(symbol) { - return symbol.declarations.some(function (d) { return d.kind === 279 /* SourceFile */; }); + return symbol.declarations.some(function (d) { return d.kind === 284 /* SourceFile */; }); } function getCompletionData(program, log, sourceFile, isUncheckedFile, position, preferences, detailsEntryId) { var typeChecker = program.getTypeChecker(); @@ -97935,11 +98883,11 @@ var ts; if (tag.tagName.pos <= position && position <= tag.tagName.end) { return { kind: 1 /* JsDocTagName */ }; } - if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 283 /* JSDocTypeExpression */) { + if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 288 /* JSDocTypeExpression */) { currentToken = ts.getTokenAtPosition(sourceFile, position); if (!currentToken || (!ts.isDeclarationName(currentToken) && - (currentToken.parent.kind !== 305 /* JSDocPropertyTag */ || + (currentToken.parent.kind !== 310 /* JSDocPropertyTag */ || currentToken.parent.name !== currentToken))) { // Use as type location if inside tag's type expression insideJsDocTagTypeExpression = isCurrentlyEditingNode(tag.typeExpression); @@ -98110,11 +99058,11 @@ var ts; return { kind: 0 /* Data */, symbols: symbols, completionKind: completionKind, isInSnippetScope: isInSnippetScope, propertyAccessToConvert: propertyAccessToConvert, isNewIdentifierLocation: isNewIdentifierLocation, location: location, keywordFilters: keywordFilters, literals: literals, symbolToOriginInfoMap: symbolToOriginInfoMap, recommendedCompletion: recommendedCompletion, previousToken: previousToken, isJsxInitializer: isJsxInitializer }; function isTagWithTypeExpression(tag) { switch (tag.kind) { - case 299 /* JSDocParameterTag */: - case 305 /* JSDocPropertyTag */: - case 300 /* JSDocReturnTag */: - case 302 /* JSDocTypeTag */: - case 304 /* JSDocTypedefTag */: + case 304 /* JSDocParameterTag */: + case 310 /* JSDocPropertyTag */: + case 305 /* JSDocReturnTag */: + case 307 /* JSDocTypeTag */: + case 309 /* JSDocTypedefTag */: return true; default: return false; @@ -98154,7 +99102,7 @@ var ts; } } // If the module is merged with a value, we must get the type of the class and add its propertes (for inherited static methods). - if (!isTypeLocation && symbol.declarations.some(function (d) { return d.kind !== 279 /* SourceFile */ && d.kind !== 244 /* ModuleDeclaration */ && d.kind !== 243 /* EnumDeclaration */; })) { + if (!isTypeLocation && symbol.declarations.some(function (d) { return d.kind !== 284 /* SourceFile */ && d.kind !== 244 /* ModuleDeclaration */ && d.kind !== 243 /* EnumDeclaration */; })) { addTypeProperties(typeChecker.getTypeOfSymbolAtLocation(symbol, node)); } return; @@ -98287,7 +99235,7 @@ var ts; var symbolMeanings = (isTypeOnly ? 0 /* None */ : 67220415 /* Value */) | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */; symbols = ts.Debug.assertEachDefined(typeChecker.getSymbolsInScope(scopeNode, symbolMeanings), "getSymbolsInScope() should all be defined"); // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions` - if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 279 /* SourceFile */) { + if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 284 /* SourceFile */) { var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false); if (thisType) { for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker); _i < _a.length; _i++) { @@ -98320,7 +99268,7 @@ var ts; } function isSnippetScope(scopeNode) { switch (scopeNode.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: case 206 /* TemplateExpression */: case 270 /* JsxExpression */: case 218 /* Block */: @@ -99152,7 +100100,7 @@ var ts; function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location) { // class c { method() { } | method2() { } } switch (location.kind) { - case 306 /* SyntaxList */: + case 311 /* SyntaxList */: return ts.tryCast(location.parent, ts.isObjectTypeDeclaration); case 1 /* EndOfFileToken */: var cls = ts.tryCast(ts.lastOrUndefined(ts.cast(location.parent, ts.isSourceFile).statements), ts.isObjectTypeDeclaration); @@ -99337,7 +100285,7 @@ var ts; var child = throwStatement; while (child.parent) { var parent = child.parent; - if (ts.isFunctionBlock(parent) || parent.kind === 279 /* SourceFile */) { + if (ts.isFunctionBlock(parent) || parent.kind === 284 /* SourceFile */) { return parent; } // A throw-statement is only owned by a try-statement if the try-statement has @@ -99395,7 +100343,7 @@ var ts; var container = declaration.parent; switch (container.kind) { case 245 /* ModuleBlock */: - case 279 /* SourceFile */: + case 284 /* SourceFile */: case 218 /* Block */: case 271 /* CaseClause */: case 272 /* DefaultClause */: @@ -99893,7 +100841,7 @@ var ts; } else if (!isAvailableThroughGlobal) { var sourceFileLike = getSourceFileLikeForImportDeclaration(importDeclaration); - ts.Debug.assert(sourceFileLike.kind === 279 /* SourceFile */ || sourceFileLike.kind === 244 /* ModuleDeclaration */); + ts.Debug.assert(sourceFileLike.kind === 284 /* SourceFile */ || sourceFileLike.kind === 244 /* ModuleDeclaration */); if (isReExport || findNamespaceReExports(sourceFileLike, name, checker)) { addIndirectUsers(sourceFileLike); } @@ -100062,7 +101010,7 @@ var ts; for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { var referencingFile = sourceFiles_3[_i]; var searchSourceFile = searchModuleSymbol.valueDeclaration; - if (searchSourceFile.kind === 279 /* SourceFile */) { + if (searchSourceFile.kind === 284 /* SourceFile */) { for (var _a = 0, _b = referencingFile.referencedFiles; _a < _b.length; _a++) { var ref = _b[_a]; if (program.getSourceFileFromReference(referencingFile, ref) === searchSourceFile) { @@ -100110,7 +101058,7 @@ var ts; } /** Iterates over all statements at the top level or in module declarations. Returns the first truthy result. */ function forEachPossibleImportOrExportStatement(sourceFileLike, action) { - return ts.forEach(sourceFileLike.kind === 279 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { + return ts.forEach(sourceFileLike.kind === 284 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { return action(statement) || (isAmbientModuleDeclaration(statement) && ts.forEach(statement.body && statement.body.statements, action)); }); } @@ -100334,7 +101282,7 @@ var ts; return node.getSourceFile(); } var parent = node.parent; - if (parent.kind === 279 /* SourceFile */) { + if (parent.kind === 284 /* SourceFile */) { return parent; } ts.Debug.assert(parent.kind === 245 /* ModuleBlock */); @@ -100396,7 +101344,7 @@ var ts; } FindAllReferences.getImplementationsAtPosition = getImplementationsAtPosition; function getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position) { - if (node.kind === 279 /* SourceFile */) { + if (node.kind === 284 /* SourceFile */) { return undefined; } var checker = program.getTypeChecker(); @@ -100616,8 +101564,8 @@ var ts; case 248 /* ImportEqualsDeclaration */: case 253 /* ImportSpecifier */: case 241 /* InterfaceDeclaration */: - case 297 /* JSDocCallbackTag */: - case 304 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: + case 309 /* JSDocTypedefTag */: case 267 /* JsxAttribute */: case 244 /* ModuleDeclaration */: case 247 /* NamespaceExportDeclaration */: @@ -100642,8 +101590,8 @@ var ts; return !!decl.initializer || ts.isCatchClause(decl.parent); case 155 /* MethodSignature */: case 153 /* PropertySignature */: - case 305 /* JSDocPropertyTag */: - case 299 /* JSDocParameterTag */: + case 310 /* JSDocPropertyTag */: + case 304 /* JSDocParameterTag */: return false; default: return ts.Debug.failBadSyntaxKind(decl); @@ -100803,7 +101751,7 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; switch (decl.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: // Don't include the source file itself. (This may not be ideal behavior, but awkward to include an entire file as a reference.) break; case 244 /* ModuleDeclaration */: @@ -101174,7 +102122,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (!container || container.kind === 279 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { + if (!container || container.kind === 284 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { // This is a global variable and not an external module, any declaration defined // within this scope is visible outside the file return undefined; @@ -101733,7 +102681,7 @@ var ts; staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 279 /* SourceFile */: + case 284 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode) || isParameterName(thisOrSuperKeyword)) { return undefined; } @@ -101746,7 +102694,7 @@ var ts; default: return undefined; } - var references = ts.flatMap(searchSpaceNode.kind === 279 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { + var references = ts.flatMap(searchSpaceNode.kind === 284 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return getPossibleSymbolReferenceNodes(sourceFile, "this", ts.isSourceFile(searchSpaceNode) ? sourceFile : searchSpaceNode).filter(function (node) { if (!ts.isThis(node)) { @@ -101765,8 +102713,8 @@ var ts; // Make sure the container belongs to the same class // and has the appropriate static modifier from the original container. return container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getModifierFlags(container) & 32 /* Static */) === staticFlag; - case 279 /* SourceFile */: - return container.kind === 279 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); + case 284 /* SourceFile */: + return container.kind === 284 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); } }); }).map(function (n) { return FindAllReferences.nodeEntry(n); }); @@ -102620,11 +103568,11 @@ var ts; JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations; function getCommentHavingNodes(declaration) { switch (declaration.kind) { - case 299 /* JSDocParameterTag */: - case 305 /* JSDocPropertyTag */: + case 304 /* JSDocParameterTag */: + case 310 /* JSDocPropertyTag */: return [declaration]; - case 297 /* JSDocCallbackTag */: - case 304 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: + case 309 /* JSDocTypedefTag */: return [declaration, declaration.parent]; default: return ts.getJSDocCommentsAndTags(declaration); @@ -102645,16 +103593,16 @@ var ts; function getCommentText(tag) { var comment = tag.comment; switch (tag.kind) { - case 295 /* JSDocAugmentsTag */: + case 300 /* JSDocAugmentsTag */: return withNode(tag.class); - case 303 /* JSDocTemplateTag */: + case 308 /* JSDocTemplateTag */: return withList(tag.typeParameters); - case 302 /* JSDocTypeTag */: + case 307 /* JSDocTypeTag */: return withNode(tag.typeExpression); - case 304 /* JSDocTypedefTag */: - case 297 /* JSDocCallbackTag */: - case 305 /* JSDocPropertyTag */: - case 299 /* JSDocParameterTag */: + case 309 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: + case 310 /* JSDocPropertyTag */: + case 304 /* JSDocParameterTag */: var name = tag.name; return name ? withNode(name) : comment; default: @@ -102865,7 +103813,7 @@ var ts; : undefined; return { commentOwner: commentOwner, parameters: parameters_1 }; } - case 279 /* SourceFile */: + case 284 /* SourceFile */: return "quit"; case 244 /* ModuleDeclaration */: // If in walking up the tree, we hit a a nested namespace declaration, @@ -103425,7 +104373,7 @@ var ts; } } switch (node.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" @@ -103477,10 +104425,10 @@ var ts; case 243 /* EnumDeclaration */: case 241 /* InterfaceDeclaration */: case 244 /* ModuleDeclaration */: - case 279 /* SourceFile */: + case 284 /* SourceFile */: case 242 /* TypeAliasDeclaration */: - case 304 /* JSDocTypedefTag */: - case 297 /* JSDocCallbackTag */: + case 309 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: return true; case 157 /* Constructor */: case 156 /* MethodDeclaration */: @@ -103501,7 +104449,7 @@ var ts; } switch (navigationBarNodeKind(item.parent)) { case 245 /* ModuleBlock */: - case 279 /* SourceFile */: + case 284 /* SourceFile */: case 156 /* MethodDeclaration */: case 157 /* Constructor */: return true; @@ -103586,7 +104534,7 @@ var ts; return !member.name || member.name.kind === 149 /* ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 279 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); + return node.kind === 284 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); } function getModifiers(node) { if (node.parent && node.parent.kind === 237 /* VariableDeclaration */) { @@ -106404,7 +107352,7 @@ var ts; // For some special property access expressions like `exports.foo = foo` or `module.exports.foo = foo` // there documentation comments might be attached to the right hand side symbol of their declarations. // The pattern of such special property access is that the parent symbol is the symbol of the file. - if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 279 /* SourceFile */; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 284 /* SourceFile */; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; if (!declaration.parent || declaration.parent.kind !== 204 /* BinaryExpression */) { @@ -106529,7 +107477,7 @@ var ts; // If the parent is not sourceFile or module block it is local variable for (var parent = declaration.parent; !ts.isFunctionBlock(parent); parent = parent.parent) { // Reached source file or module block - if (parent.kind === 279 /* SourceFile */ || parent.kind === 245 /* ModuleBlock */) { + if (parent.kind === 284 /* SourceFile */ || parent.kind === 245 /* ModuleBlock */) { return false; } } @@ -107854,7 +108802,7 @@ var ts; case 244 /* ModuleDeclaration */: var body = parent.body; return !!body && body.kind === 245 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 279 /* SourceFile */: + case 284 /* SourceFile */: case 218 /* Block */: case 245 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); @@ -108973,7 +109921,7 @@ var ts; // - parent is SourceFile - by default immediate children of SourceFile are not indented except when user indents them manually // - parent and child are not on the same line var useActualIndentation = (ts.isDeclaration(current) || ts.isStatementButNotDeclaration(current)) && - (parent.kind === 279 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 284 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -109061,7 +110009,7 @@ var ts; case 209 /* ClassExpression */: case 241 /* InterfaceDeclaration */: case 242 /* TypeAliasDeclaration */: - case 303 /* JSDocTemplateTag */: + case 308 /* JSDocTemplateTag */: return getList(node.typeParameters); case 192 /* NewExpression */: case 191 /* CallExpression */: @@ -110624,18 +111572,18 @@ var ts; } function transformJSDocType(node) { switch (node.kind) { - case 284 /* JSDocAllType */: - case 285 /* JSDocUnknownType */: + case 289 /* JSDocAllType */: + case 290 /* JSDocUnknownType */: return ts.createTypeReferenceNode("any", ts.emptyArray); - case 288 /* JSDocOptionalType */: + case 293 /* JSDocOptionalType */: return transformJSDocOptionalType(node); - case 287 /* JSDocNonNullableType */: + case 292 /* JSDocNonNullableType */: return transformJSDocType(node.type); - case 286 /* JSDocNullableType */: + case 291 /* JSDocNullableType */: return transformJSDocNullableType(node); - case 290 /* JSDocVariadicType */: + case 295 /* JSDocVariadicType */: return transformJSDocVariadicType(node); - case 289 /* JSDocFunctionType */: + case 294 /* JSDocFunctionType */: return transformJSDocFunctionType(node); case 164 /* TypeReference */: return transformJSDocTypeReference(node); @@ -110659,7 +111607,7 @@ var ts; } function transformJSDocParameter(node) { var index = node.parent.parameters.indexOf(node); - var isRest = node.type.kind === 290 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 + var isRest = node.type.kind === 295 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 var name = node.name || (isRest ? "rest" : "arg" + index); var dotdotdot = isRest ? ts.createToken(25 /* DotDotDotToken */) : node.dotDotDotToken; return ts.createParameter(node.decorators, node.modifiers, dotdotdot, name, node.questionToken, ts.visitNode(node.type, transformJSDocType), node.initializer); @@ -110978,14 +111926,14 @@ var ts; return undefined; } switch (oldTag.kind) { - case 299 /* JSDocParameterTag */: { + case 304 /* JSDocParameterTag */: { var oldParam = oldTag; var newParam = newTag; return ts.isIdentifier(oldParam.name) && ts.isIdentifier(newParam.name) && oldParam.name.escapedText === newParam.name.escapedText ? ts.createJSDocParamTag(newParam.name, newParam.isBracketed, newParam.typeExpression, oldParam.comment) : undefined; } - case 300 /* JSDocReturnTag */: + case 305 /* JSDocReturnTag */: return ts.createJSDocReturnTag(newTag.typeExpression, oldTag.comment); } } @@ -114365,7 +115313,7 @@ var ts; var typeNode = info.typeNode, type = info.type; var original = typeNode.getText(sourceFile); var actions = [fix(type, fixIdPlain, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript)]; - if (typeNode.kind === 286 /* JSDocNullableType */) { + if (typeNode.kind === 291 /* JSDocNullableType */) { // for nullable types, suggest the flow-compatible `T | null | undefined` // in addition to the jsdoc/closure-compatible `T | null` actions.push(fix(checker.getNullableType(type, 32768 /* Undefined */), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types)); @@ -114385,7 +115333,7 @@ var ts; if (!info) return; var typeNode = info.typeNode, type = info.type; - var fixedType = typeNode.kind === 286 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; + var fixedType = typeNode.kind === 291 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; doChange(changes, sourceFile, typeNode, fixedType, checker); }); } @@ -115017,6 +115965,7 @@ var ts; return ts.textChanges.getNewFileText(toStatements(valueInfo, outputKind), 3 /* TS */, formatSettings.newLineCharacter || "\n", ts.formatting.getFormatContext(formatSettings)); } ts.valueInfoToDeclarationFileText = valueInfoToDeclarationFileText; + /* @internal */ var OutputKind; (function (OutputKind) { OutputKind[OutputKind["ExportEquals"] = 0] = "ExportEquals"; @@ -116184,7 +117133,7 @@ var ts; // * Module/namespace or source file if (isScope(current)) { scopes.push(current); - if (current.kind === 279 /* SourceFile */) { + if (current.kind === 284 /* SourceFile */) { return scopes; } } @@ -117198,7 +118147,7 @@ var ts; function isBlockLike(node) { switch (node.kind) { case 218 /* Block */: - case 279 /* SourceFile */: + case 284 /* SourceFile */: case 245 /* ModuleBlock */: case 271 /* CaseClause */: return true; @@ -118262,7 +119211,7 @@ var ts; if (!children.length) { return undefined; } - var child = ts.find(children, function (kid) { return kid.kind < 283 /* FirstJSDocNode */ || kid.kind > 305 /* LastJSDocNode */; }); + var child = ts.find(children, function (kid) { return kid.kind < 288 /* FirstJSDocNode */ || kid.kind > 310 /* LastJSDocNode */; }); return child.kind < 148 /* FirstNode */ ? child : child.getFirstToken(sourceFile); @@ -118332,7 +119281,7 @@ var ts; } } function createSyntaxList(nodes, parent) { - var list = createNode(306 /* SyntaxList */, nodes.pos, nodes.end, parent); + var list = createNode(311 /* SyntaxList */, nodes.pos, nodes.end, parent); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_7 = nodes; _i < nodes_7.length; _i++) { diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts index 40e16bf55bd..dc5cb6675bd 100644 --- a/lib/typescript.d.ts +++ b/lib/typescript.d.ts @@ -355,40 +355,45 @@ declare namespace ts { ShorthandPropertyAssignment = 276, SpreadAssignment = 277, EnumMember = 278, - SourceFile = 279, - Bundle = 280, - UnparsedSource = 281, - InputFiles = 282, - JSDocTypeExpression = 283, - JSDocAllType = 284, - JSDocUnknownType = 285, - JSDocNullableType = 286, - JSDocNonNullableType = 287, - JSDocOptionalType = 288, - JSDocFunctionType = 289, - JSDocVariadicType = 290, - JSDocComment = 291, - JSDocTypeLiteral = 292, - JSDocSignature = 293, - JSDocTag = 294, - JSDocAugmentsTag = 295, - JSDocClassTag = 296, - JSDocCallbackTag = 297, - JSDocEnumTag = 298, - JSDocParameterTag = 299, - JSDocReturnTag = 300, - JSDocThisTag = 301, - JSDocTypeTag = 302, - JSDocTemplateTag = 303, - JSDocTypedefTag = 304, - JSDocPropertyTag = 305, - SyntaxList = 306, - NotEmittedStatement = 307, - PartiallyEmittedExpression = 308, - CommaListExpression = 309, - MergeDeclarationMarker = 310, - EndOfDeclarationMarker = 311, - Count = 312, + UnparsedPrologue = 279, + UnparsedPrepend = 280, + UnparsedText = 281, + UnparsedInternalText = 282, + UnparsedSyntheticReference = 283, + SourceFile = 284, + Bundle = 285, + UnparsedSource = 286, + InputFiles = 287, + JSDocTypeExpression = 288, + JSDocAllType = 289, + JSDocUnknownType = 290, + JSDocNullableType = 291, + JSDocNonNullableType = 292, + JSDocOptionalType = 293, + JSDocFunctionType = 294, + JSDocVariadicType = 295, + JSDocComment = 296, + JSDocTypeLiteral = 297, + JSDocSignature = 298, + JSDocTag = 299, + JSDocAugmentsTag = 300, + JSDocClassTag = 301, + JSDocCallbackTag = 302, + JSDocEnumTag = 303, + JSDocParameterTag = 304, + JSDocReturnTag = 305, + JSDocThisTag = 306, + JSDocTypeTag = 307, + JSDocTemplateTag = 308, + JSDocTypedefTag = 309, + JSDocPropertyTag = 310, + SyntaxList = 311, + NotEmittedStatement = 312, + PartiallyEmittedExpression = 313, + CommaListExpression = 314, + MergeDeclarationMarker = 315, + EndOfDeclarationMarker = 316, + Count = 317, FirstAssignment = 59, LastAssignment = 71, FirstCompoundAssignment = 60, @@ -414,10 +419,10 @@ declare namespace ts { FirstBinaryOperator = 28, LastBinaryOperator = 71, FirstNode = 148, - FirstJSDocNode = 283, - LastJSDocNode = 305, - FirstJSDocTagNode = 294, - LastJSDocTagNode = 305 + FirstJSDocNode = 288, + LastJSDocNode = 310, + FirstJSDocTagNode = 299, + LastJSDocTagNode = 310 } enum NodeFlags { None = 0, @@ -1745,10 +1750,44 @@ declare namespace ts { } interface UnparsedSource extends Node { kind: SyntaxKind.UnparsedSource; - fileName?: string; + fileName: string; text: string; + prologues: ReadonlyArray; + helpers: ReadonlyArray | undefined; + referencedFiles: ReadonlyArray; + typeReferenceDirectives: ReadonlyArray | undefined; + libReferenceDirectives: ReadonlyArray; + hasNoDefaultLib?: boolean; sourceMapPath?: string; sourceMapText?: string; + syntheticReferences?: ReadonlyArray; + texts: ReadonlyArray; + } + type UnparsedSourceText = UnparsedPrepend | UnparsedTextLike; + type UnparsedNode = UnparsedPrologue | UnparsedSourceText | UnparsedSyntheticReference; + interface UnparsedSection extends Node { + kind: SyntaxKind; + data?: string; + parent: UnparsedSource; + } + interface UnparsedPrologue extends UnparsedSection { + kind: SyntaxKind.UnparsedPrologue; + data: string; + parent: UnparsedSource; + } + interface UnparsedPrepend extends UnparsedSection { + kind: SyntaxKind.UnparsedPrepend; + data: string; + parent: UnparsedSource; + texts: ReadonlyArray; + } + interface UnparsedTextLike extends UnparsedSection { + kind: SyntaxKind.UnparsedText | SyntaxKind.UnparsedInternalText; + parent: UnparsedSource; + } + interface UnparsedSyntheticReference extends UnparsedSection { + kind: SyntaxKind.UnparsedSyntheticReference; + parent: UnparsedSource; } interface JsonSourceFile extends SourceFile { statements: NodeArray; @@ -2503,6 +2542,8 @@ declare namespace ts { reactNamespace?: string; jsxFactory?: string; composite?: boolean; + incremental?: boolean; + tsBuildInfoFile?: string; removeComments?: boolean; rootDir?: string; rootDirs?: string[]; @@ -2679,7 +2720,8 @@ declare namespace ts { Dts = ".d.ts", Js = ".js", Jsx = ".jsx", - Json = ".json" + Json = ".json", + TsBuildInfo = ".tsbuildinfo" } interface ResolvedModuleWithFailedLookupLocations { readonly resolvedModule: ResolvedModuleFull | undefined; @@ -2760,6 +2802,10 @@ declare namespace ts { readonly text: string | ((node: EmitHelperUniqueNameCallback) => string); readonly priority?: number; } + interface UnscopedEmitHelper extends EmitHelper { + readonly scoped: false; + readonly text: string; + } type EmitHelperUniqueNameCallback = (name: string) => string; enum EmitHint { SourceFile = 0, @@ -3459,6 +3505,9 @@ declare namespace ts { function isSourceFile(node: Node): node is SourceFile; function isBundle(node: Node): node is Bundle; function isUnparsedSource(node: Node): node is UnparsedSource; + function isUnparsedPrepend(node: Node): node is UnparsedPrepend; + function isUnparsedTextLike(node: Node): node is UnparsedTextLike; + function isUnparsedNode(node: Node): node is UnparsedNode; function isJSDocTypeExpression(node: Node): node is JSDocTypeExpression; function isJSDocAllType(node: JSDocAllType): node is JSDocAllType; function isJSDocUnknownType(node: Node): node is JSDocUnknownType; @@ -3994,10 +4043,10 @@ declare namespace ts { function updateCommaList(node: CommaListExpression, elements: ReadonlyArray): CommaListExpression; function createBundle(sourceFiles: ReadonlyArray, prepends?: ReadonlyArray): Bundle; function createUnparsedSourceFile(text: string): UnparsedSource; - function createUnparsedSourceFile(inputFile: InputFiles, type: "js" | "dts"): UnparsedSource; + function createUnparsedSourceFile(inputFile: InputFiles, type: "js" | "dts", stripInternal?: boolean): UnparsedSource; function createUnparsedSourceFile(text: string, mapPath: string | undefined, map: string | undefined): UnparsedSource; function createInputFiles(javascriptText: string, declarationText: string): InputFiles; - function createInputFiles(readFileText: (path: string) => string | undefined, javascriptPath: string, javascriptMapPath: string | undefined, declarationPath: string, declarationMapPath: string | undefined): InputFiles; + function createInputFiles(readFileText: (path: string) => string | undefined, javascriptPath: string, javascriptMapPath: string | undefined, declarationPath: string, declarationMapPath: string | undefined, buildInfoPath: string | undefined): InputFiles; function createInputFiles(javascriptText: string, declarationText: string, javascriptMapPath: string | undefined, javascriptMapText: string | undefined, declarationMapPath: string | undefined, declarationMapText: string | undefined): InputFiles; function updateBundle(node: Bundle, sourceFiles: ReadonlyArray, prepends?: ReadonlyArray): Bundle; function createImmediatelyInvokedFunctionExpression(statements: ReadonlyArray): CallExpression; diff --git a/lib/typescript.js b/lib/typescript.js index 04665d089e1..650b48917ea 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -2867,47 +2867,53 @@ var ts; SyntaxKind[SyntaxKind["SpreadAssignment"] = 277] = "SpreadAssignment"; // Enum SyntaxKind[SyntaxKind["EnumMember"] = 278] = "EnumMember"; + // Unparsed + SyntaxKind[SyntaxKind["UnparsedPrologue"] = 279] = "UnparsedPrologue"; + SyntaxKind[SyntaxKind["UnparsedPrepend"] = 280] = "UnparsedPrepend"; + SyntaxKind[SyntaxKind["UnparsedText"] = 281] = "UnparsedText"; + SyntaxKind[SyntaxKind["UnparsedInternalText"] = 282] = "UnparsedInternalText"; + SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 283] = "UnparsedSyntheticReference"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 279] = "SourceFile"; - SyntaxKind[SyntaxKind["Bundle"] = 280] = "Bundle"; - SyntaxKind[SyntaxKind["UnparsedSource"] = 281] = "UnparsedSource"; - SyntaxKind[SyntaxKind["InputFiles"] = 282] = "InputFiles"; + SyntaxKind[SyntaxKind["SourceFile"] = 284] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 285] = "Bundle"; + SyntaxKind[SyntaxKind["UnparsedSource"] = 286] = "UnparsedSource"; + SyntaxKind[SyntaxKind["InputFiles"] = 287] = "InputFiles"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 283] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 288] = "JSDocTypeExpression"; // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 284] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 289] = "JSDocAllType"; // The ? type - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 285] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 286] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 287] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 288] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 289] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 290] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 291] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 292] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocSignature"] = 293] = "JSDocSignature"; - SyntaxKind[SyntaxKind["JSDocTag"] = 294] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 295] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocClassTag"] = 296] = "JSDocClassTag"; - SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 297] = "JSDocCallbackTag"; - SyntaxKind[SyntaxKind["JSDocEnumTag"] = 298] = "JSDocEnumTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 299] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 300] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocThisTag"] = 301] = "JSDocThisTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 302] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 303] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 304] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 305] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 290] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 291] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 292] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 293] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 294] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 295] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 296] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 297] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocSignature"] = 298] = "JSDocSignature"; + SyntaxKind[SyntaxKind["JSDocTag"] = 299] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 300] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocClassTag"] = 301] = "JSDocClassTag"; + SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 302] = "JSDocCallbackTag"; + SyntaxKind[SyntaxKind["JSDocEnumTag"] = 303] = "JSDocEnumTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 304] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 305] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocThisTag"] = 306] = "JSDocThisTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 307] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 308] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 309] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 310] = "JSDocPropertyTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 306] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 311] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 307] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 308] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["CommaListExpression"] = 309] = "CommaListExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 310] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 311] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 312] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 313] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["CommaListExpression"] = 314] = "CommaListExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 315] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 316] = "EndOfDeclarationMarker"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 312] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 317] = "Count"; // Markers SyntaxKind[SyntaxKind["FirstAssignment"] = 59] = "FirstAssignment"; SyntaxKind[SyntaxKind["LastAssignment"] = 71] = "LastAssignment"; @@ -2934,10 +2940,10 @@ var ts; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 28] = "FirstBinaryOperator"; SyntaxKind[SyntaxKind["LastBinaryOperator"] = 71] = "LastBinaryOperator"; SyntaxKind[SyntaxKind["FirstNode"] = 148] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 283] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 305] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 294] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 305] = "LastJSDocTagNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 288] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 310] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 299] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 310] = "LastJSDocTagNode"; /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 118] = "FirstContextualKeyword"; /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 147] = "LastContextualKeyword"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); @@ -3814,6 +3820,7 @@ var ts; Extension["Js"] = ".js"; Extension["Jsx"] = ".jsx"; Extension["Json"] = ".json"; + Extension["TsBuildInfo"] = ".tsbuildinfo"; })(Extension = ts.Extension || (ts.Extension = {})); /* @internal */ var TransformFlags; @@ -3971,6 +3978,20 @@ var ts; EmitHint[EmitHint["Unspecified"] = 4] = "Unspecified"; EmitHint[EmitHint["EmbeddedStatement"] = 5] = "EmbeddedStatement"; })(EmitHint = ts.EmitHint || (ts.EmitHint = {})); + /*@internal*/ + var BundleFileSectionKind; + (function (BundleFileSectionKind) { + BundleFileSectionKind["Prologue"] = "prologue"; + BundleFileSectionKind["EmitHelpers"] = "emitHelpers"; + BundleFileSectionKind["NoDefaultLib"] = "no-default-lib"; + BundleFileSectionKind["Reference"] = "reference"; + BundleFileSectionKind["Type"] = "type"; + BundleFileSectionKind["Lib"] = "lib"; + BundleFileSectionKind["Prepend"] = "prepend"; + BundleFileSectionKind["Text"] = "text"; + BundleFileSectionKind["Internal"] = "internal"; + // comments? + })(BundleFileSectionKind = ts.BundleFileSectionKind || (ts.BundleFileSectionKind = {})); var ListFormat; (function (ListFormat) { ListFormat[ListFormat["None"] = 0] = "None"; @@ -6100,6 +6121,15 @@ var ts; Option_build_must_be_the_first_command_line_argument: diag(6369, ts.DiagnosticCategory.Error, "Option_build_must_be_the_first_command_line_argument_6369", "Option '--build' must be the first command line argument."), Options_0_and_1_cannot_be_combined: diag(6370, ts.DiagnosticCategory.Error, "Options_0_and_1_cannot_be_combined_6370", "Options '{0}' and '{1}' cannot be combined."), Updating_unchanged_output_timestamps_of_project_0: diag(6371, ts.DiagnosticCategory.Message, "Updating_unchanged_output_timestamps_of_project_0_6371", "Updating unchanged output timestamps of project '{0}'..."), + Project_0_is_out_of_date_because_output_of_its_dependency_1_has_changed: diag(6372, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_output_of_its_dependency_1_has_changed_6372", "Project '{0}' is out of date because output of its dependency '{1}' has changed"), + Updating_output_of_project_0: diag(6373, ts.DiagnosticCategory.Message, "Updating_output_of_project_0_6373", "Updating output of project '{0}'..."), + A_non_dry_build_would_update_timestamps_for_output_of_project_0: diag(6374, ts.DiagnosticCategory.Message, "A_non_dry_build_would_update_timestamps_for_output_of_project_0_6374", "A non-dry build would update timestamps for output of project '{0}'"), + A_non_dry_build_would_update_output_of_project_0: diag(6375, ts.DiagnosticCategory.Message, "A_non_dry_build_would_update_output_of_project_0_6375", "A non-dry build would update output of project '{0}'"), + Cannot_update_output_of_project_0_because_there_was_error_reading_file_1: diag(6376, ts.DiagnosticCategory.Message, "Cannot_update_output_of_project_0_because_there_was_error_reading_file_1_6376", "Cannot update output of project '{0}' because there was error reading file '{1}'"), + Cannot_write_file_0_because_it_will_overwrite_tsbuildinfo_file_generated_by_referenced_project_1: diag(6377, ts.DiagnosticCategory.Error, "Cannot_write_file_0_because_it_will_overwrite_tsbuildinfo_file_generated_by_referenced_project_1_6377", "Cannot write file '{0}' because it will overwrite '.tsbuildinfo' file generated by referenced project '{1}'"), + Enable_incremental_compilation: diag(6378, ts.DiagnosticCategory.Message, "Enable_incremental_compilation_6378", "Enable incremental compilation"), + Composite_projects_may_not_disable_incremental_compilation: diag(6379, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_incremental_compilation_6379", "Composite projects may not disable incremental compilation."), + Specify_file_to_store_incremental_compilation_information: diag(6380, ts.DiagnosticCategory.Message, "Specify_file_to_store_incremental_compilation_information_6380", "Specify file to store incremental compilation information"), The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: diag(6500, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1_6500", "The expected type comes from property '{0}' which is declared here on type '{1}'"), The_expected_type_comes_from_this_index_signature: diag(6501, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_this_index_signature_6501", "The expected type comes from this index signature."), The_expected_type_comes_from_the_return_type_of_this_signature: diag(6502, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_the_return_type_of_this_signature_6502", "The expected type comes from the return type of this signature."), @@ -6803,16 +6833,20 @@ var ts; return pos; } var shebangTriviaRegex = /^#!.*/; + /*@internal*/ function isShebangTrivia(text, pos) { // Shebangs check must only be done at the start of the file ts.Debug.assert(pos === 0); return shebangTriviaRegex.test(text); } + ts.isShebangTrivia = isShebangTrivia; + /*@internal*/ function scanShebangTrivia(text, pos) { var shebang = shebangTriviaRegex.exec(text)[0]; pos = pos + shebang.length; return pos; } + ts.scanShebangTrivia = scanShebangTrivia; /** * Invokes a callback for each comment range following the provided position. * @@ -8522,7 +8556,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 279 /* SourceFile */) { + while (node && node.kind !== 284 /* SourceFile */) { node = node.parent; } return node; @@ -8668,7 +8702,7 @@ var ts; // the syntax list itself considers them as normal trivia. Therefore if we simply skip // trivia for the list, we may have skipped the JSDocComment as well. So we should process its // first child to determine the actual position of its first token. - if (node.kind === 306 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 311 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); @@ -8687,7 +8721,7 @@ var ts; } ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; function isJSDocTypeExpressionOrChild(node) { - return node.kind === 283 /* JSDocTypeExpression */ || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); + return node.kind === 288 /* JSDocTypeExpression */ || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); } function getTextOfNodeFromSourceText(sourceText, node, includeTrivia) { if (includeTrivia === void 0) { includeTrivia = false; } @@ -8814,7 +8848,7 @@ var ts; return node && node.kind === 244 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 279 /* SourceFile */ || + return node.kind === 284 /* SourceFile */ || node.kind === 244 /* ModuleDeclaration */ || ts.isFunctionLike(node); } @@ -8832,7 +8866,7 @@ var ts; // - defined in the top level scope and source file is an external module // - defined inside ambient module declaration located in the top level scope and source file not an external module switch (node.parent.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: return ts.isExternalModule(node.parent); case 245 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); @@ -8850,7 +8884,7 @@ var ts; ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: case 246 /* CaseBlock */: case 274 /* CatchClause */: case 244 /* ModuleDeclaration */: @@ -8875,9 +8909,9 @@ var ts; ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 297 /* JSDocCallbackTag */: - case 304 /* JSDocTypedefTag */: - case 293 /* JSDocSignature */: + case 302 /* JSDocCallbackTag */: + case 309 /* JSDocTypedefTag */: + case 298 /* JSDocSignature */: return true; default: ts.assertType(node); @@ -8893,12 +8927,12 @@ var ts; case 162 /* IndexSignature */: case 165 /* FunctionType */: case 166 /* ConstructorType */: - case 289 /* JSDocFunctionType */: + case 294 /* JSDocFunctionType */: case 240 /* ClassDeclaration */: case 209 /* ClassExpression */: case 241 /* InterfaceDeclaration */: case 242 /* TypeAliasDeclaration */: - case 303 /* JSDocTemplateTag */: + case 308 /* JSDocTemplateTag */: case 239 /* FunctionDeclaration */: case 156 /* MethodDeclaration */: case 157 /* Constructor */: @@ -9043,7 +9077,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: var pos_1 = ts.skipTrivia(sourceFile.text, 0, /*stopAfterLineBreak*/ false); if (pos_1 === sourceFile.text.length) { // file is empty - return span for the beginning of the file @@ -9218,7 +9252,7 @@ var ts; return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); case 150 /* TypeParameter */: return node === parent.constraint; - case 303 /* JSDocTemplateTag */: + case 308 /* JSDocTemplateTag */: return node === parent.constraint; case 154 /* PropertyDeclaration */: case 153 /* PropertySignature */: @@ -9478,7 +9512,7 @@ var ts; } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 279 /* SourceFile */); + ts.Debug.assert(node.kind !== 284 /* SourceFile */); while (true) { node = node.parent; if (!node) { @@ -9532,7 +9566,7 @@ var ts; case 161 /* ConstructSignature */: case 162 /* IndexSignature */: case 243 /* EnumDeclaration */: - case 279 /* SourceFile */: + case 284 /* SourceFile */: return node; } } @@ -10240,7 +10274,7 @@ var ts; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 304 /* JSDocTypedefTag */ || node.kind === 297 /* JSDocCallbackTag */; + return node.kind === 309 /* JSDocTypedefTag */ || node.kind === 302 /* JSDocCallbackTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -10384,7 +10418,7 @@ var ts; ts.hasRestParameter = hasRestParameter; function isRestParameter(node) { var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type; - return node.dotDotDotToken !== undefined || !!type && type.kind === 290 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 295 /* JSDocVariadicType */; } ts.isRestParameter = isRestParameter; var AssignmentKind; @@ -10869,7 +10903,7 @@ var ts; || kind === 158 /* GetAccessor */ || kind === 159 /* SetAccessor */ || kind === 244 /* ModuleDeclaration */ - || kind === 279 /* SourceFile */; + || kind === 284 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -10946,7 +10980,7 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 309 /* CommaListExpression */: + case 314 /* CommaListExpression */: return 0; case 208 /* SpreadElement */: return 1; @@ -11264,6 +11298,9 @@ var ts; lineStart = true; } } + function getTextPosWithWriteLine() { + return lineStart ? output.length : (output.length + newLine.length); + } reset(); return { write: write, @@ -11292,7 +11329,8 @@ var ts; writeStringLiteral: write, writeSymbol: function (s, _) { return write(s); }, writeTrailingSemicolon: write, - writeComment: write + writeComment: write, + getTextPosWithWriteLine: getTextPosWithWriteLine }; } ts.createTextWriter = createTextWriter; @@ -11583,7 +11621,7 @@ var ts; ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations; /** template tags are only available when a typedef isn't already using them */ function isNonTypeAliasTemplate(tag) { - return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 291 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 296 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node @@ -12555,19 +12593,29 @@ var ts; || kind === 96 /* NullKeyword */ || kind === 132 /* NeverKeyword */ || kind === 211 /* ExpressionWithTypeArguments */ - || kind === 284 /* JSDocAllType */ - || kind === 285 /* JSDocUnknownType */ - || kind === 286 /* JSDocNullableType */ - || kind === 287 /* JSDocNonNullableType */ - || kind === 288 /* JSDocOptionalType */ - || kind === 289 /* JSDocFunctionType */ - || kind === 290 /* JSDocVariadicType */; + || kind === 289 /* JSDocAllType */ + || kind === 290 /* JSDocUnknownType */ + || kind === 291 /* JSDocNullableType */ + || kind === 292 /* JSDocNonNullableType */ + || kind === 293 /* JSDocOptionalType */ + || kind === 294 /* JSDocFunctionType */ + || kind === 295 /* JSDocVariadicType */; } ts.isTypeNodeKind = isTypeNodeKind; function isAccessExpression(node) { return node.kind === 189 /* PropertyAccessExpression */ || node.kind === 190 /* ElementAccessExpression */; } ts.isAccessExpression = isAccessExpression; + function isBundleFileTextLike(section) { + switch (section.kind) { + case "text" /* Text */: + case "internal" /* Internal */: + return true; + default: + return false; + } + } + ts.isBundleFileTextLike = isBundleFileTextLike; })(ts || (ts = {})); (function (ts) { function getDefaultLibFileName(options) { @@ -13029,8 +13077,8 @@ var ts; switch (declaration.kind) { case 72 /* Identifier */: return declaration; - case 305 /* JSDocPropertyTag */: - case 299 /* JSDocParameterTag */: { + case 310 /* JSDocPropertyTag */: + case 304 /* JSDocParameterTag */: { var name = declaration.name; if (name.kind === 148 /* QualifiedName */) { return name.right; @@ -13054,7 +13102,7 @@ var ts; return undefined; } } - case 304 /* JSDocTypedefTag */: + case 309 /* JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); case 254 /* ExportAssignment */: { var expression = declaration.expression; @@ -13258,7 +13306,7 @@ var ts; return ts.emptyArray; } if (ts.isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 291 /* JSDocComment */); + ts.Debug.assert(node.parent.kind === 296 /* JSDocComment */); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } if (node.typeParameters) { @@ -13530,7 +13578,7 @@ var ts; } ts.isParenthesizedExpression = isParenthesizedExpression; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 308 /* PartiallyEmittedExpression */) { + while (node.kind === 313 /* PartiallyEmittedExpression */) { node = node.expression; } return node; @@ -13877,108 +13925,128 @@ var ts; ts.isEnumMember = isEnumMember; // Top-level nodes function isSourceFile(node) { - return node.kind === 279 /* SourceFile */; + return node.kind === 284 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 280 /* Bundle */; + return node.kind === 285 /* Bundle */; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 281 /* UnparsedSource */; + return node.kind === 286 /* UnparsedSource */; } ts.isUnparsedSource = isUnparsedSource; + function isUnparsedPrepend(node) { + return node.kind === 280 /* UnparsedPrepend */; + } + ts.isUnparsedPrepend = isUnparsedPrepend; + function isUnparsedTextLike(node) { + switch (node.kind) { + case 281 /* UnparsedText */: + case 282 /* UnparsedInternalText */: + return true; + default: + return false; + } + } + ts.isUnparsedTextLike = isUnparsedTextLike; + function isUnparsedNode(node) { + return isUnparsedTextLike(node) || + node.kind === 279 /* UnparsedPrologue */ || + node.kind === 283 /* UnparsedSyntheticReference */; + } + ts.isUnparsedNode = isUnparsedNode; // JSDoc function isJSDocTypeExpression(node) { - return node.kind === 283 /* JSDocTypeExpression */; + return node.kind === 288 /* JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocAllType(node) { - return node.kind === 284 /* JSDocAllType */; + return node.kind === 289 /* JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 285 /* JSDocUnknownType */; + return node.kind === 290 /* JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 286 /* JSDocNullableType */; + return node.kind === 291 /* JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 287 /* JSDocNonNullableType */; + return node.kind === 292 /* JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 288 /* JSDocOptionalType */; + return node.kind === 293 /* JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 289 /* JSDocFunctionType */; + return node.kind === 294 /* JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 290 /* JSDocVariadicType */; + return node.kind === 295 /* JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDoc(node) { - return node.kind === 291 /* JSDocComment */; + return node.kind === 296 /* JSDocComment */; } ts.isJSDoc = isJSDoc; function isJSDocAugmentsTag(node) { - return node.kind === 295 /* JSDocAugmentsTag */; + return node.kind === 300 /* JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocClassTag(node) { - return node.kind === 296 /* JSDocClassTag */; + return node.kind === 301 /* JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocEnumTag(node) { - return node.kind === 298 /* JSDocEnumTag */; + return node.kind === 303 /* JSDocEnumTag */; } ts.isJSDocEnumTag = isJSDocEnumTag; function isJSDocThisTag(node) { - return node.kind === 301 /* JSDocThisTag */; + return node.kind === 306 /* JSDocThisTag */; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocParameterTag(node) { - return node.kind === 299 /* JSDocParameterTag */; + return node.kind === 304 /* JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 300 /* JSDocReturnTag */; + return node.kind === 305 /* JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocTypeTag(node) { - return node.kind === 302 /* JSDocTypeTag */; + return node.kind === 307 /* JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 303 /* JSDocTemplateTag */; + return node.kind === 308 /* JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 304 /* JSDocTypedefTag */; + return node.kind === 309 /* JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocPropertyTag(node) { - return node.kind === 305 /* JSDocPropertyTag */; + return node.kind === 310 /* JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocPropertyLikeTag(node) { - return node.kind === 305 /* JSDocPropertyTag */ || node.kind === 299 /* JSDocParameterTag */; + return node.kind === 310 /* JSDocPropertyTag */ || node.kind === 304 /* JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; function isJSDocTypeLiteral(node) { - return node.kind === 292 /* JSDocTypeLiteral */; + return node.kind === 297 /* JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocCallbackTag(node) { - return node.kind === 297 /* JSDocCallbackTag */; + return node.kind === 302 /* JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocSignature(node) { - return node.kind === 293 /* JSDocSignature */; + return node.kind === 298 /* JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; })(ts || (ts = {})); @@ -13989,7 +14057,7 @@ var ts; (function (ts) { /* @internal */ function isSyntaxList(n) { - return n.kind === 306 /* SyntaxList */; + return n.kind === 311 /* SyntaxList */; } ts.isSyntaxList = isSyntaxList; /* @internal */ @@ -14141,11 +14209,11 @@ var ts; switch (kind) { case 155 /* MethodSignature */: case 160 /* CallSignature */: - case 293 /* JSDocSignature */: + case 298 /* JSDocSignature */: case 161 /* ConstructSignature */: case 162 /* IndexSignature */: case 165 /* FunctionType */: - case 289 /* JSDocFunctionType */: + case 294 /* JSDocFunctionType */: case 166 /* ConstructorType */: return true; default: @@ -14436,8 +14504,8 @@ var ts; case 208 /* SpreadElement */: case 212 /* AsExpression */: case 210 /* OmittedExpression */: - case 309 /* CommaListExpression */: - case 308 /* PartiallyEmittedExpression */: + case 314 /* CommaListExpression */: + case 313 /* PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -14451,12 +14519,12 @@ var ts; ts.isAssertionExpression = isAssertionExpression; /* @internal */ function isPartiallyEmittedExpression(node) { - return node.kind === 308 /* PartiallyEmittedExpression */; + return node.kind === 313 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; /* @internal */ function isNotEmittedStatement(node) { - return node.kind === 307 /* NotEmittedStatement */; + return node.kind === 312 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ @@ -14567,9 +14635,9 @@ var ts; || kind === 242 /* TypeAliasDeclaration */ || kind === 150 /* TypeParameter */ || kind === 237 /* VariableDeclaration */ - || kind === 304 /* JSDocTypedefTag */ - || kind === 297 /* JSDocCallbackTag */ - || kind === 305 /* JSDocPropertyTag */; + || kind === 309 /* JSDocTypedefTag */ + || kind === 302 /* JSDocCallbackTag */ + || kind === 310 /* JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { return kind === 239 /* FunctionDeclaration */ @@ -14604,14 +14672,14 @@ var ts; || kind === 219 /* VariableStatement */ || kind === 224 /* WhileStatement */ || kind === 231 /* WithStatement */ - || kind === 307 /* NotEmittedStatement */ - || kind === 311 /* EndOfDeclarationMarker */ - || kind === 310 /* MergeDeclarationMarker */; + || kind === 312 /* NotEmittedStatement */ + || kind === 316 /* EndOfDeclarationMarker */ + || kind === 315 /* MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { if (node.kind === 150 /* TypeParameter */) { - return node.parent.kind !== 303 /* JSDocTemplateTag */ || ts.isInJSFile(node); + return (node.parent && node.parent.kind !== 308 /* JSDocTemplateTag */) || ts.isInJSFile(node); } return isDeclarationKind(node.kind); } @@ -14706,18 +14774,18 @@ var ts; /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 283 /* FirstJSDocNode */ && node.kind <= 305 /* LastJSDocNode */; + return node.kind >= 288 /* FirstJSDocNode */ && node.kind <= 310 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 291 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 296 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); } ts.isJSDocCommentContainingNode = isJSDocCommentContainingNode; // TODO: determine what this does before making it public. /* @internal */ function isJSDocTag(node) { - return node.kind >= 294 /* FirstJSDocTagNode */ && node.kind <= 305 /* LastJSDocTagNode */; + return node.kind >= 299 /* FirstJSDocTagNode */ && node.kind <= 310 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { @@ -15034,6 +15102,10 @@ var ts; return !!(compilerOptions.declaration || compilerOptions.composite); } ts.getEmitDeclarations = getEmitDeclarations; + function isIncrementalCompilation(options) { + return !!(options.incremental || options.composite); + } + ts.isIncrementalCompilation = isIncrementalCompilation; function getStrictOptionValue(compilerOptions, flag) { return compilerOptions[flag] === undefined ? !!compilerOptions.strict : !!compilerOptions[flag]; } @@ -16318,7 +16390,7 @@ var ts; var SourceFileConstructor; // tslint:enable variable-name function createNode(kind, pos, end) { - if (kind === 279 /* SourceFile */) { + if (kind === 284 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else if (kind === 72 /* Identifier */) { @@ -16569,7 +16641,7 @@ var ts; case 218 /* Block */: case 245 /* ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 279 /* SourceFile */: + case 284 /* SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); case 219 /* VariableStatement */: @@ -16718,7 +16790,7 @@ var ts; return visitNode(cbNode, node.expression); case 258 /* MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators); - case 309 /* CommaListExpression */: + case 314 /* CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); case 260 /* JsxElement */: return visitNode(cbNode, node.openingElement) || @@ -16747,60 +16819,60 @@ var ts; return visitNode(cbNode, node.tagName); case 171 /* OptionalType */: case 172 /* RestType */: - case 283 /* JSDocTypeExpression */: - case 287 /* JSDocNonNullableType */: - case 286 /* JSDocNullableType */: - case 288 /* JSDocOptionalType */: - case 290 /* JSDocVariadicType */: + case 288 /* JSDocTypeExpression */: + case 292 /* JSDocNonNullableType */: + case 291 /* JSDocNullableType */: + case 293 /* JSDocOptionalType */: + case 295 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 289 /* JSDocFunctionType */: + case 294 /* JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 291 /* JSDocComment */: + case 296 /* JSDocComment */: return visitNodes(cbNode, cbNodes, node.tags); - case 299 /* JSDocParameterTag */: - case 305 /* JSDocPropertyTag */: + case 304 /* JSDocParameterTag */: + case 310 /* JSDocPropertyTag */: return visitNode(cbNode, node.tagName) || (node.isNameFirst ? visitNode(cbNode, node.name) || visitNode(cbNode, node.typeExpression) : visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name)); - case 295 /* JSDocAugmentsTag */: + case 300 /* JSDocAugmentsTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.class); - case 303 /* JSDocTemplateTag */: + case 308 /* JSDocTemplateTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.constraint) || visitNodes(cbNode, cbNodes, node.typeParameters); - case 304 /* JSDocTypedefTag */: + case 309 /* JSDocTypedefTag */: return visitNode(cbNode, node.tagName) || (node.typeExpression && - node.typeExpression.kind === 283 /* JSDocTypeExpression */ + node.typeExpression.kind === 288 /* JSDocTypeExpression */ ? visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) : visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression)); - case 297 /* JSDocCallbackTag */: + case 302 /* JSDocCallbackTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); - case 300 /* JSDocReturnTag */: - case 302 /* JSDocTypeTag */: - case 301 /* JSDocThisTag */: - case 298 /* JSDocEnumTag */: + case 305 /* JSDocReturnTag */: + case 307 /* JSDocTypeTag */: + case 306 /* JSDocThisTag */: + case 303 /* JSDocEnumTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.typeExpression); - case 293 /* JSDocSignature */: + case 298 /* JSDocSignature */: return ts.forEach(node.typeParameters, cbNode) || ts.forEach(node.parameters, cbNode) || visitNode(cbNode, node.type); - case 292 /* JSDocTypeLiteral */: + case 297 /* JSDocTypeLiteral */: return ts.forEach(node.jsDocPropertyTags, cbNode); - case 294 /* JSDocTag */: - case 296 /* JSDocClassTag */: + case 299 /* JSDocTag */: + case 301 /* JSDocClassTag */: return visitNode(cbNode, node.tagName); - case 308 /* PartiallyEmittedExpression */: + case 313 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -17174,7 +17246,7 @@ var ts; function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile) { // code from createNode is inlined here so createNode won't have to deal with special case of creating source files // this is quite rare comparing to other nodes and createNode should be as fast as possible - var sourceFile = new SourceFileConstructor(279 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); + var sourceFile = new SourceFileConstructor(284 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -18374,9 +18446,9 @@ var ts; return finishNode(node); } function parseJSDocAllType(postFixEquals) { - var result = createNode(284 /* JSDocAllType */); + var result = createNode(289 /* JSDocAllType */); if (postFixEquals) { - return createPostfixType(288 /* JSDocOptionalType */, result); + return createPostfixType(293 /* JSDocOptionalType */, result); } else { nextToken(); @@ -18384,7 +18456,7 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(287 /* JSDocNonNullableType */); + var result = createNode(292 /* JSDocNonNullableType */); nextToken(); result.type = parseNonArrayType(); return finishNode(result); @@ -18408,18 +18480,18 @@ var ts; token() === 30 /* GreaterThanToken */ || token() === 59 /* EqualsToken */ || token() === 50 /* BarToken */) { - var result = createNode(285 /* JSDocUnknownType */, pos); + var result = createNode(290 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(286 /* JSDocNullableType */, pos); + var result = createNode(291 /* JSDocNullableType */, pos); result.type = parseType(); return finishNode(result); } } function parseJSDocFunctionType() { if (lookAhead(nextTokenIsOpenParen)) { - var result = createNodeWithJSDoc(289 /* JSDocFunctionType */); + var result = createNodeWithJSDoc(294 /* JSDocFunctionType */); nextToken(); fillSignature(57 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result); return finishNode(result); @@ -18443,12 +18515,12 @@ var ts; var type = parseTypeOrTypePredicate(); scanner.setInJSDocType(false); if (dotdotdot) { - var variadic = createNode(290 /* JSDocVariadicType */, dotdotdot.pos); + var variadic = createNode(295 /* JSDocVariadicType */, dotdotdot.pos); variadic.type = type; type = finishNode(variadic); } if (token() === 59 /* EqualsToken */) { - return createPostfixType(288 /* JSDocOptionalType */, type); + return createPostfixType(293 /* JSDocOptionalType */, type); } return type; } @@ -18820,7 +18892,7 @@ var ts; return finishNode(node); } var type = parseType(); - if (!(contextFlags & 2097152 /* JSDoc */) && type.kind === 286 /* JSDocNullableType */ && type.pos === type.type.pos) { + if (!(contextFlags & 2097152 /* JSDoc */) && type.kind === 291 /* JSDocNullableType */ && type.pos === type.type.pos) { type.kind = 171 /* OptionalType */; } return type; @@ -19007,14 +19079,14 @@ var ts; while (!scanner.hasPrecedingLineBreak()) { switch (token()) { case 52 /* ExclamationToken */: - type = createPostfixType(287 /* JSDocNonNullableType */, type); + type = createPostfixType(292 /* JSDocNonNullableType */, type); break; case 56 /* QuestionToken */: // If not in JSDoc and next token is start of a type we have a conditional type if (!(contextFlags & 2097152 /* JSDoc */) && lookAhead(nextTokenIsStartOfType)) { return type; } - type = createPostfixType(286 /* JSDocNullableType */, type); + type = createPostfixType(291 /* JSDocNullableType */, type); break; case 22 /* OpenBracketToken */: parseExpected(22 /* OpenBracketToken */); @@ -21951,7 +22023,7 @@ var ts; JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; // Parses out a JSDoc type expression. function parseJSDocTypeExpression(mayOmitBraces) { - var result = createNode(283 /* JSDocTypeExpression */); + var result = createNode(288 /* JSDocTypeExpression */); var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* OpenBraceToken */); result.type = doInsideOfContext(2097152 /* JSDoc */, parseJSDocType); if (!mayOmitBraces || hasBrace) { @@ -22114,7 +22186,7 @@ var ts; } } function createJSDocComment() { - var result = createNode(291 /* JSDocComment */, start); + var result = createNode(296 /* JSDocComment */, start); result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -22281,7 +22353,7 @@ var ts; return comments.length === 0 ? undefined : comments.join(""); } function parseUnknownTag(start, tagName) { - var result = createNode(294 /* JSDocTag */, start); + var result = createNode(299 /* JSDocTag */, start); result.tagName = tagName; return finishNode(result); } @@ -22340,8 +22412,8 @@ var ts; typeExpression = tryParseTypeExpression(); } var result = target === 1 /* Property */ ? - createNode(305 /* JSDocPropertyTag */, start) : - createNode(299 /* JSDocParameterTag */, start); + createNode(310 /* JSDocPropertyTag */, start) : + createNode(304 /* JSDocParameterTag */, start); var comment = parseTagComments(indent + scanner.getStartPos() - start); var nestedTypeLiteral = target !== 4 /* CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target, indent); if (nestedTypeLiteral) { @@ -22358,18 +22430,18 @@ var ts; } function parseNestedTypeLiteral(typeExpression, name, target, indent) { if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) { - var typeLiteralExpression = createNode(283 /* JSDocTypeExpression */, scanner.getTokenPos()); + var typeLiteralExpression = createNode(288 /* JSDocTypeExpression */, scanner.getTokenPos()); var child = void 0; var jsdocTypeLiteral = void 0; var start_2 = scanner.getStartPos(); var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) { - if (child.kind === 299 /* JSDocParameterTag */ || child.kind === 305 /* JSDocPropertyTag */) { + if (child.kind === 304 /* JSDocParameterTag */ || child.kind === 310 /* JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - jsdocTypeLiteral = createNode(292 /* JSDocTypeLiteral */, start_2); + jsdocTypeLiteral = createNode(297 /* JSDocTypeLiteral */, start_2); jsdocTypeLiteral.jsDocPropertyTags = children; if (typeExpression.type.kind === 169 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; @@ -22380,25 +22452,25 @@ var ts; } } function parseReturnTag(start, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 300 /* JSDocReturnTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 305 /* JSDocReturnTag */; })) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(300 /* JSDocReturnTag */, start); + var result = createNode(305 /* JSDocReturnTag */, start); result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); } function parseTypeTag(start, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 302 /* JSDocTypeTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 307 /* JSDocTypeTag */; })) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(302 /* JSDocTypeTag */, start); + var result = createNode(307 /* JSDocTypeTag */, start); result.tagName = tagName; result.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); return finishNode(result); } function parseAugmentsTag(start, tagName) { - var result = createNode(295 /* JSDocAugmentsTag */, start); + var result = createNode(300 /* JSDocAugmentsTag */, start); result.tagName = tagName; result.class = parseExpressionWithTypeArgumentsForAugments(); return finishNode(result); @@ -22425,19 +22497,19 @@ var ts; return node; } function parseClassTag(start, tagName) { - var tag = createNode(296 /* JSDocClassTag */, start); + var tag = createNode(301 /* JSDocClassTag */, start); tag.tagName = tagName; return finishNode(tag); } function parseThisTag(start, tagName) { - var tag = createNode(301 /* JSDocThisTag */, start); + var tag = createNode(306 /* JSDocThisTag */, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); return finishNode(tag); } function parseEnumTag(start, tagName) { - var tag = createNode(298 /* JSDocEnumTag */, start); + var tag = createNode(303 /* JSDocEnumTag */, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); @@ -22446,7 +22518,7 @@ var ts; function parseTypedefTag(start, tagName, indent) { var typeExpression = tryParseTypeExpression(); skipWhitespaceOrAsterisk(); - var typedefTag = createNode(304 /* JSDocTypedefTag */, start); + var typedefTag = createNode(309 /* JSDocTypedefTag */, start); typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(); typedefTag.name = getJSDocTypeAliasName(typedefTag.fullName); @@ -22460,9 +22532,9 @@ var ts; var childTypeTag = void 0; while (child = tryParse(function () { return parseChildPropertyTag(indent); })) { if (!jsdocTypeLiteral) { - jsdocTypeLiteral = createNode(292 /* JSDocTypeLiteral */, start); + jsdocTypeLiteral = createNode(297 /* JSDocTypeLiteral */, start); } - if (child.kind === 302 /* JSDocTypeTag */) { + if (child.kind === 307 /* JSDocTypeTag */) { if (childTypeTag) { break; } @@ -22508,14 +22580,14 @@ var ts; return typeNameOrNamespaceName; } function parseCallbackTag(start, tagName, indent) { - var callbackTag = createNode(297 /* JSDocCallbackTag */, start); + var callbackTag = createNode(302 /* JSDocCallbackTag */, start); callbackTag.tagName = tagName; callbackTag.fullName = parseJSDocTypeNameWithNamespace(); callbackTag.name = getJSDocTypeAliasName(callbackTag.fullName); skipWhitespace(); callbackTag.comment = parseTagComments(indent); var child; - var jsdocSignature = createNode(293 /* JSDocSignature */, start); + var jsdocSignature = createNode(298 /* JSDocSignature */, start); jsdocSignature.parameters = []; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* CallbackParameter */, indent); })) { jsdocSignature.parameters = ts.append(jsdocSignature.parameters, child); @@ -22523,7 +22595,7 @@ var ts; var returnTag = tryParse(function () { if (parseOptionalJsdoc(58 /* AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 300 /* JSDocReturnTag */) { + if (tag && tag.kind === 305 /* JSDocReturnTag */) { return tag; } } @@ -22568,7 +22640,7 @@ var ts; case 58 /* AtToken */: if (canParseTag) { var child = tryParseChildTag(target, indent); - if (child && (child.kind === 299 /* JSDocParameterTag */ || child.kind === 305 /* JSDocPropertyTag */) && + if (child && (child.kind === 304 /* JSDocParameterTag */ || child.kind === 310 /* JSDocPropertyTag */) && target !== 4 /* CallbackParameter */ && name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; @@ -22638,7 +22710,7 @@ var ts; skipWhitespace(); typeParameters.push(typeParameter); } while (parseOptionalJsdoc(27 /* CommaToken */)); - var result = createNode(303 /* JSDocTemplateTag */, start); + var result = createNode(308 /* JSDocTemplateTag */, start); result.tagName = tagName; result.constraint = constraint; result.typeParameters = createNodeArray(typeParameters, typeParametersPos); @@ -23724,6 +23796,22 @@ var ts; category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Enable_project_compilation, }, + { + name: "incremental", + type: "boolean", + isTSConfigOnly: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Enable_incremental_compilation, + }, + { + name: "tsBuildInfoFile", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.FILE, + isTSConfigOnly: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Specify_file_to_store_incremental_compilation_information, + }, { name: "removeComments", type: "boolean", @@ -27442,7 +27530,7 @@ var ts; return "__constructor" /* Constructor */; case 165 /* FunctionType */: case 160 /* CallSignature */: - case 293 /* JSDocSignature */: + case 298 /* JSDocSignature */: return "__call" /* Call */; case 166 /* ConstructorType */: case 161 /* ConstructSignature */: @@ -27451,7 +27539,7 @@ var ts; return "__index" /* Index */; case 255 /* ExportDeclaration */: return "__export" /* ExportStar */; - case 279 /* SourceFile */: + case 284 /* SourceFile */: // json file should behave as // module.exports = ... return "export=" /* ExportEquals */; @@ -27462,12 +27550,12 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 289 /* JSDocFunctionType */: + case 294 /* JSDocFunctionType */: return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); case 151 /* Parameter */: // Parameters with names are handled at the top of this function. Parameters // without names can only come from JSDocFunctionTypes. - ts.Debug.assert(node.parent.kind === 289 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); + ts.Debug.assert(node.parent.kind === 294 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); var functionType = node.parent; var index = functionType.parameters.indexOf(node); return "arg" + index; @@ -27706,7 +27794,7 @@ var ts; if (hasExplicitReturn) node.flags |= 256 /* HasExplicitReturn */; } - if (node.kind === 279 /* SourceFile */) { + if (node.kind === 284 /* SourceFile */) { node.flags |= emitFlags; } if (currentReturnTarget) { @@ -27850,12 +27938,12 @@ var ts; case 191 /* CallExpression */: bindCallExpressionFlow(node); break; - case 304 /* JSDocTypedefTag */: - case 297 /* JSDocCallbackTag */: + case 309 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: bindJSDocTypeAlias(node); break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 279 /* SourceFile */: { + case 284 /* SourceFile */: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; @@ -28542,7 +28630,7 @@ var ts; case 243 /* EnumDeclaration */: case 188 /* ObjectLiteralExpression */: case 168 /* TypeLiteral */: - case 292 /* JSDocTypeLiteral */: + case 297 /* JSDocTypeLiteral */: case 268 /* JsxAttributes */: return 1 /* IsContainer */; case 241 /* InterfaceDeclaration */: @@ -28551,7 +28639,7 @@ var ts; case 242 /* TypeAliasDeclaration */: case 181 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 279 /* SourceFile */: + case 284 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; case 156 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { @@ -28564,8 +28652,8 @@ var ts; case 158 /* GetAccessor */: case 159 /* SetAccessor */: case 160 /* CallSignature */: - case 293 /* JSDocSignature */: - case 289 /* JSDocFunctionType */: + case 298 /* JSDocSignature */: + case 294 /* JSDocFunctionType */: case 165 /* FunctionType */: case 161 /* ConstructSignature */: case 162 /* IndexSignature */: @@ -28619,7 +28707,7 @@ var ts; // handlers to take care of declaring these child members. case 244 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 279 /* SourceFile */: + case 284 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); case 209 /* ClassExpression */: case 240 /* ClassDeclaration */: @@ -28627,7 +28715,7 @@ var ts; case 243 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); case 168 /* TypeLiteral */: - case 292 /* JSDocTypeLiteral */: + case 297 /* JSDocTypeLiteral */: case 188 /* ObjectLiteralExpression */: case 241 /* InterfaceDeclaration */: case 268 /* JsxAttributes */: @@ -28641,7 +28729,7 @@ var ts; case 166 /* ConstructorType */: case 160 /* CallSignature */: case 161 /* ConstructSignature */: - case 293 /* JSDocSignature */: + case 298 /* JSDocSignature */: case 162 /* IndexSignature */: case 156 /* MethodDeclaration */: case 155 /* MethodSignature */: @@ -28651,9 +28739,9 @@ var ts; case 239 /* FunctionDeclaration */: case 196 /* FunctionExpression */: case 197 /* ArrowFunction */: - case 289 /* JSDocFunctionType */: - case 304 /* JSDocTypedefTag */: - case 297 /* JSDocCallbackTag */: + case 294 /* JSDocFunctionType */: + case 309 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: case 242 /* TypeAliasDeclaration */: case 181 /* MappedType */: // All the children of these container types are never visible through another @@ -28676,8 +28764,8 @@ var ts; : declareSymbol(file.locals, /*parent*/ undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 279 /* SourceFile */ ? node : node.body; - if (body && (body.kind === 279 /* SourceFile */ || body.kind === 245 /* ModuleBlock */)) { + var body = node.kind === 284 /* SourceFile */ ? node : node.body; + if (body && (body.kind === 284 /* SourceFile */ || body.kind === 245 /* ModuleBlock */)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; if (stat.kind === 255 /* ExportDeclaration */ || stat.kind === 254 /* ExportAssignment */) { @@ -28811,7 +28899,7 @@ var ts; case 244 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 279 /* SourceFile */: + case 284 /* SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -28949,7 +29037,7 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 279 /* SourceFile */ && + if (blockScopeContainer.kind !== 284 /* SourceFile */ && blockScopeContainer.kind !== 244 /* ModuleDeclaration */ && !ts.isFunctionLike(blockScopeContainer)) { // We check first if the name is inside class declaration or class expression; if so give explicit message @@ -29224,12 +29312,12 @@ var ts; case 159 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 67187647 /* SetAccessorExcludes */); case 165 /* FunctionType */: - case 289 /* JSDocFunctionType */: - case 293 /* JSDocSignature */: + case 294 /* JSDocFunctionType */: + case 298 /* JSDocSignature */: case 166 /* ConstructorType */: return bindFunctionOrConstructorType(node); case 168 /* TypeLiteral */: - case 292 /* JSDocTypeLiteral */: + case 297 /* JSDocTypeLiteral */: case 181 /* MappedType */: return bindAnonymousTypeWorker(node); case 188 /* ObjectLiteralExpression */: @@ -29288,7 +29376,7 @@ var ts; return bindExportDeclaration(node); case 254 /* ExportAssignment */: return bindExportAssignment(node); - case 279 /* SourceFile */: + case 284 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); case 218 /* Block */: @@ -29298,22 +29386,22 @@ var ts; // falls through case 245 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 299 /* JSDocParameterTag */: - if (node.parent.kind === 293 /* JSDocSignature */) { + case 304 /* JSDocParameterTag */: + if (node.parent.kind === 298 /* JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 292 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 297 /* JSDocTypeLiteral */) { break; } // falls through - case 305 /* JSDocPropertyTag */: + case 310 /* JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 288 /* JSDocOptionalType */ ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 293 /* JSDocOptionalType */ ? 4 /* Property */ | 16777216 /* Optional */ : 4 /* Property */; return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 304 /* JSDocTypedefTag */: - case 297 /* JSDocCallbackTag */: + case 309 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -29485,7 +29573,7 @@ var ts; var symbolTable = ts.hasModifier(thisContainer, 32 /* Static */) ? containingClass.symbol.exports : containingClass.symbol.members; declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */, 0 /* None */, /*isReplaceableByMethod*/ true); break; - case 279 /* SourceFile */: + case 284 /* SourceFile */: // this.property = assignment in a source file -- declare symbol in exports for a module, in locals for a script if (thisContainer.commonJsModuleIndicator) { declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 /* Property */ | 1048576 /* ExportValue */, 0 /* None */); @@ -29502,7 +29590,7 @@ var ts; if (node.expression.kind === 100 /* ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 279 /* SourceFile */) { + else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 284 /* SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -29539,7 +29627,7 @@ var ts; } function bindObjectDefinePropertyAssignment(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]); - var isToplevel = node.parent.parent.kind === 279 /* SourceFile */; + var isToplevel = node.parent.parent.kind === 284 /* SourceFile */; namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false); bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ false); } @@ -29606,8 +29694,8 @@ var ts; function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty) { var namespaceSymbol = lookupSymbolForPropertyAccess(name); var isToplevel = ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 279 /* SourceFile */ - : propertyAccess.parent.parent.kind === 279 /* SourceFile */; + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 284 /* SourceFile */ + : propertyAccess.parent.parent.kind === 284 /* SourceFile */; namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty); bindPotentiallyNewExpandoMemberToNamespace(propertyAccess, namespaceSymbol, isPrototypeProperty); } @@ -29745,7 +29833,7 @@ var ts; } } function bindParameter(node) { - if (node.kind === 299 /* JSDocParameterTag */ && container.kind !== 293 /* JSDocSignature */) { + if (node.kind === 304 /* JSDocParameterTag */ && container.kind !== 298 /* JSDocSignature */) { return; } if (inStrictMode && !(node.flags & 4194304 /* Ambient */)) { @@ -30488,7 +30576,7 @@ var ts; break; case 194 /* TypeAssertionExpression */: case 212 /* AsExpression */: - case 308 /* PartiallyEmittedExpression */: + case 313 /* PartiallyEmittedExpression */: // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; excludeFlags = 536872257 /* OuterExpressionExcludes */; @@ -30689,7 +30777,7 @@ var ts; transformFlags |= 192 /* AssertES2015 */; } break; - case 279 /* SourceFile */: + case 284 /* SourceFile */: if (subtreeFlags & 16384 /* ContainsCapturedLexicalThis */) { transformFlags |= 192 /* AssertES2015 */; } @@ -30769,7 +30857,7 @@ var ts; return 637666625 /* BindingPatternExcludes */; case 194 /* TypeAssertionExpression */: case 212 /* AsExpression */: - case 308 /* PartiallyEmittedExpression */: + case 313 /* PartiallyEmittedExpression */: case 195 /* ParenthesizedExpression */: case 98 /* SuperKeyword */: return 536872257 /* OuterExpressionExcludes */; @@ -31946,7 +32034,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); } function isGlobalSourceFile(node) { - return node.kind === 279 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 284 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -32120,7 +32208,7 @@ var ts; // - parameters are only in the scope of function body // This restriction does not apply to JSDoc comment types because they are parented // at a higher level than type parameters would normally be - if (meaning & result.flags & 67897832 /* Type */ && lastLocation.kind !== 291 /* JSDocComment */) { + if (meaning & result.flags & 67897832 /* Type */ && lastLocation.kind !== 296 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || @@ -32162,14 +32250,14 @@ var ts; } } switch (location.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through case 244 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 279 /* SourceFile */ || ts.isAmbientModule(location)) { + if (location.kind === 284 /* SourceFile */ || ts.isAmbientModule(location)) { // It's an external module. First see if the module has an export default and if the local // name of that export default matches. if (result = moduleExports.get("default" /* Default */)) { @@ -32341,8 +32429,8 @@ var ts; location = location.parent; } break; - case 304 /* JSDocTypedefTag */: - case 297 /* JSDocCallbackTag */: + case 309 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: // js type aliases do not resolve names from their host, so skip past it location = ts.getJSDocHost(location); break; @@ -32361,7 +32449,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 279 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 284 /* SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) { return lastLocation.symbol; } @@ -33217,7 +33305,7 @@ var ts; function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias) { var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 279 /* SourceFile */)) { + if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 284 /* SourceFile */)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; @@ -33568,7 +33656,7 @@ var ts; } } switch (location.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } @@ -33808,10 +33896,10 @@ var ts; return node && getSymbolOfNode(node); } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 279 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 284 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 279 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 284 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -34268,7 +34356,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 279 /* SourceFile */ || declaration.parent.kind === 245 /* ModuleBlock */; + return declaration.parent.kind === 284 /* SourceFile */ || declaration.parent.kind === 245 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -34653,7 +34741,7 @@ var ts; function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) { var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 151 /* Parameter */); if (!parameterDeclaration && !isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 299 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 304 /* JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { @@ -34811,7 +34899,7 @@ var ts; return top; } function getSpecifierForModuleSymbol(symbol, context) { - var file = ts.getDeclarationOfKind(symbol, 279 /* SourceFile */); + var file = ts.getDeclarationOfKind(symbol, 284 /* SourceFile */); if (file && file.moduleName !== undefined) { // Use the amd name if it is available return file.moduleName; @@ -35064,7 +35152,7 @@ var ts; ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 279 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 284 /* SourceFile */ || ts.isAmbientModule(location); } function getNameOfSymbolFromNameType(symbol, context) { var nameType = symbol.nameType; @@ -35141,8 +35229,8 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 297 /* JSDocCallbackTag */: - case 304 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: + case 309 /* JSDocTypedefTag */: // Top-level jsdoc type aliases are considered exported // First parent is comment node, second is hosting declaration or token; we only care about those tokens or declarations whose parent is a source file return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent)); @@ -35169,7 +35257,7 @@ var ts; var parent = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) if (!(ts.getCombinedModifierFlags(node) & 1 /* Export */) && - !(node.kind !== 248 /* ImportEqualsDeclaration */ && parent.kind !== 279 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { + !(node.kind !== 248 /* ImportEqualsDeclaration */ && parent.kind !== 284 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible @@ -35211,7 +35299,7 @@ var ts; // Type parameters are always visible case 150 /* TypeParameter */: // Source file and namespace export are always visible - case 279 /* SourceFile */: + case 284 /* SourceFile */: case 247 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module @@ -36321,15 +36409,15 @@ var ts; case 155 /* MethodSignature */: case 165 /* FunctionType */: case 166 /* ConstructorType */: - case 289 /* JSDocFunctionType */: + case 294 /* JSDocFunctionType */: case 239 /* FunctionDeclaration */: case 156 /* MethodDeclaration */: case 196 /* FunctionExpression */: case 197 /* ArrowFunction */: case 242 /* TypeAliasDeclaration */: - case 303 /* JSDocTemplateTag */: - case 304 /* JSDocTypedefTag */: - case 297 /* JSDocCallbackTag */: + case 308 /* JSDocTemplateTag */: + case 309 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: case 181 /* MappedType */: case 175 /* ConditionalType */: var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); @@ -38321,10 +38409,10 @@ var ts; function isJSDocOptionalParameter(node) { return ts.isInJSFile(node) && ( // node.type should only be a JSDocOptionalType when node is a parameter of a JSDocFunctionType - node.type && node.type.kind === 288 /* JSDocOptionalType */ + node.type && node.type.kind === 293 /* JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 288 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 293 /* JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -38358,7 +38446,7 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 288 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 293 /* JSDocOptionalType */; } function createIdentifierTypePredicate(parameterName, parameterIndex, type) { return { kind: 1 /* Identifier */, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; @@ -39098,7 +39186,7 @@ var ts; } function getConstrainedTypeVariable(typeVariable, node) { var constraints; - while (node && !ts.isStatement(node) && node.kind !== 291 /* JSDocComment */) { + while (node && !ts.isStatement(node) && node.kind !== 296 /* JSDocComment */) { var parent = node.parent; if (parent.kind === 175 /* ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(typeVariable, parent.checkType, parent.extendsType); @@ -40671,8 +40759,8 @@ var ts; function getTypeFromTypeNode(node) { switch (node.kind) { case 120 /* AnyKeyword */: - case 284 /* JSDocAllType */: - case 285 /* JSDocUnknownType */: + case 289 /* JSDocAllType */: + case 290 /* JSDocUnknownType */: return anyType; case 143 /* UnknownKeyword */: return unknownType; @@ -40719,23 +40807,23 @@ var ts; return getTypeFromUnionTypeNode(node); case 174 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 286 /* JSDocNullableType */: + case 291 /* JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 288 /* JSDocOptionalType */: + case 293 /* JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); case 177 /* ParenthesizedType */: case 172 /* RestType */: - case 287 /* JSDocNonNullableType */: - case 283 /* JSDocTypeExpression */: + case 292 /* JSDocNonNullableType */: + case 288 /* JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 290 /* JSDocVariadicType */: + case 295 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); case 165 /* FunctionType */: case 166 /* ConstructorType */: case 168 /* TypeLiteral */: - case 292 /* JSDocTypeLiteral */: - case 289 /* JSDocFunctionType */: - case 293 /* JSDocSignature */: + case 297 /* JSDocTypeLiteral */: + case 294 /* JSDocFunctionType */: + case 298 /* JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); case 179 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); @@ -44096,7 +44184,7 @@ var ts; return; } break; - case 289 /* JSDocFunctionType */: + case 294 /* JSDocFunctionType */: error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; case 239 /* FunctionDeclaration */: @@ -46377,7 +46465,7 @@ var ts; return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || node.kind === 245 /* ModuleBlock */ || - node.kind === 279 /* SourceFile */ || + node.kind === 284 /* SourceFile */ || node.kind === 154 /* PropertyDeclaration */; }); } @@ -46498,7 +46586,7 @@ var ts; // to the constructor in the initializer, we will need to substitute that // binding with an alias as the class name is not in scope. var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); - while (container.kind !== 279 /* SourceFile */) { + while (container.kind !== 284 /* SourceFile */) { if (container.parent === declaration) { if (container.kind === 154 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; @@ -46921,7 +47009,7 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 289 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 294 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -52923,7 +53011,7 @@ var ts; checkAsyncFunctionReturnType(node, returnTypeNode); } } - if (node.kind !== 162 /* IndexSignature */ && node.kind !== 289 /* JSDocFunctionType */) { + if (node.kind !== 162 /* IndexSignature */ && node.kind !== 294 /* JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } @@ -53679,8 +53767,8 @@ var ts; case 241 /* InterfaceDeclaration */: case 242 /* TypeAliasDeclaration */: // A jsdoc typedef and callback are, by definition, type aliases - case 304 /* JSDocTypedefTag */: - case 297 /* JSDocCallbackTag */: + case 309 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: return 2 /* ExportType */; case 244 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ @@ -53689,7 +53777,7 @@ var ts; case 240 /* ClassDeclaration */: case 243 /* EnumDeclaration */: return 2 /* ExportType */ | 1 /* ExportValue */; - case 279 /* SourceFile */: + case 284 /* SourceFile */: return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; case 254 /* ExportAssignment */: // Export assigned entity name expressions act as aliases and should fall through, otherwise they export values @@ -54330,7 +54418,7 @@ var ts; checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 279 /* SourceFile */: + case 284 /* SourceFile */: case 244 /* ModuleDeclaration */: case 218 /* Block */: case 246 /* CaseBlock */: @@ -54677,7 +54765,7 @@ var ts; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 279 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 284 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -54692,7 +54780,7 @@ var ts; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 279 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { + if (parent.kind === 284 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { // If the declaration happens to be in external module, report error that Promise is a reserved identifier. error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -54749,7 +54837,7 @@ var ts; (container.kind === 218 /* Block */ && ts.isFunctionLike(container.parent) || container.kind === 245 /* ModuleBlock */ || container.kind === 244 /* ModuleDeclaration */ || - container.kind === 279 /* SourceFile */); + container.kind === 284 /* SourceFile */); // here we know that function scoped variable is shadowed by block scoped one // if they are defined in the same scope - binder has already reported redeclaration error // otherwise if variable has an initializer - show error that initialization will fail @@ -56599,7 +56687,7 @@ var ts; return false; } var inAmbientExternalModule = node.parent.kind === 245 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 279 /* SourceFile */ && !inAmbientExternalModule) { + if (node.parent.kind !== 284 /* SourceFile */ && !inAmbientExternalModule) { error(moduleName, node.kind === 255 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); @@ -56730,7 +56818,7 @@ var ts; var inAmbientExternalModule = node.parent.kind === 245 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 245 /* ModuleBlock */ && !node.moduleSpecifier && node.flags & 4194304 /* Ambient */; - if (node.parent.kind !== 279 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + if (node.parent.kind !== 284 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -56747,7 +56835,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 279 /* SourceFile */ || node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 244 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 284 /* SourceFile */ || node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 244 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -56776,7 +56864,7 @@ var ts; // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 279 /* SourceFile */ ? node.parent : node.parent.parent; + var container = node.parent.kind === 284 /* SourceFile */ ? node.parent : node.parent.parent; if (container.kind === 244 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); @@ -56946,32 +57034,32 @@ var ts; return checkInferType(node); case 183 /* ImportType */: return checkImportType(node); - case 295 /* JSDocAugmentsTag */: + case 300 /* JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 304 /* JSDocTypedefTag */: - case 297 /* JSDocCallbackTag */: + case 309 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: return checkJSDocTypeAliasTag(node); - case 303 /* JSDocTemplateTag */: + case 308 /* JSDocTemplateTag */: return checkJSDocTemplateTag(node); - case 302 /* JSDocTypeTag */: + case 307 /* JSDocTypeTag */: return checkJSDocTypeTag(node); - case 299 /* JSDocParameterTag */: + case 304 /* JSDocParameterTag */: return checkJSDocParameterTag(node); - case 289 /* JSDocFunctionType */: + case 294 /* JSDocFunctionType */: checkJSDocFunctionType(node); // falls through - case 287 /* JSDocNonNullableType */: - case 286 /* JSDocNullableType */: - case 284 /* JSDocAllType */: - case 285 /* JSDocUnknownType */: - case 292 /* JSDocTypeLiteral */: + case 292 /* JSDocNonNullableType */: + case 291 /* JSDocNullableType */: + case 289 /* JSDocAllType */: + case 290 /* JSDocUnknownType */: + case 297 /* JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 290 /* JSDocVariadicType */: + case 295 /* JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 283 /* JSDocTypeExpression */: + case 288 /* JSDocTypeExpression */: return checkSourceElement(node.type); case 180 /* IndexedAccessType */: return checkIndexedAccessType(node); @@ -57279,7 +57367,7 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; // falls through @@ -57498,10 +57586,10 @@ var ts; return entityNameSymbol; } } - if (entityName.parent.kind === 299 /* JSDocParameterTag */) { + if (entityName.parent.kind === 304 /* JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(entityName.parent); } - if (entityName.parent.kind === 150 /* TypeParameter */ && entityName.parent.parent.kind === 303 /* JSDocTemplateTag */) { + if (entityName.parent.kind === 150 /* TypeParameter */ && entityName.parent.parent.kind === 308 /* JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJSFile(entityName)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(entityName.parent); return typeParameter && typeParameter.symbol; @@ -57543,7 +57631,7 @@ var ts; return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 279 /* SourceFile */) { + if (node.kind === 284 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; @@ -57885,7 +57973,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 279 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 284 /* SourceFile */) { var symbolFile = parentSymbol_1.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); // If `node` accesses an export and that export isn't in the same file, then symbol is a namespace export, so return undefined. @@ -58000,7 +58088,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 279 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 284 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -58429,7 +58517,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 279 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 284 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -58462,7 +58550,7 @@ var ts; if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 279 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 284 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -58694,7 +58782,7 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 279 /* SourceFile */) { + else if (node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 284 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128 /* Abstract */) { @@ -58717,7 +58805,7 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 279 /* SourceFile */) { + else if (node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 284 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } else if (node.kind === 151 /* Parameter */) { @@ -58762,7 +58850,7 @@ var ts; flags |= 1 /* Export */; break; case 80 /* DefaultKeyword */: - var container = node.parent.kind === 279 /* SourceFile */ ? node.parent : node.parent.parent; + var container = node.parent.kind === 284 /* SourceFile */ ? node.parent : node.parent.parent; if (container.kind === 244 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } @@ -58885,7 +58973,7 @@ var ts; case 151 /* Parameter */: return false; default: - if (node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 279 /* SourceFile */) { + if (node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 284 /* SourceFile */) { return false; } switch (node.kind) { @@ -59808,7 +59896,7 @@ var ts; // to prevent noisiness. So use a bit on the block to indicate if // this has already been reported, and don't report if it has. // - if (node.parent.kind === 218 /* Block */ || node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 279 /* SourceFile */) { + if (node.parent.kind === 218 /* Block */ || node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 284 /* SourceFile */) { var links_2 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_2.hasReportedStatementInAmbientContext) { @@ -61862,14 +61950,14 @@ var ts; // JSDoc /* @internal */ function createJSDocTypeExpression(type) { - var node = createSynthesizedNode(283 /* JSDocTypeExpression */); + var node = createSynthesizedNode(288 /* JSDocTypeExpression */); node.type = type; return node; } ts.createJSDocTypeExpression = createJSDocTypeExpression; /* @internal */ function createJSDocTypeTag(typeExpression, comment) { - var tag = createJSDocTag(302 /* JSDocTypeTag */, "type"); + var tag = createJSDocTag(307 /* JSDocTypeTag */, "type"); tag.typeExpression = typeExpression; tag.comment = comment; return tag; @@ -61877,7 +61965,7 @@ var ts; ts.createJSDocTypeTag = createJSDocTypeTag; /* @internal */ function createJSDocReturnTag(typeExpression, comment) { - var tag = createJSDocTag(300 /* JSDocReturnTag */, "returns"); + var tag = createJSDocTag(305 /* JSDocReturnTag */, "returns"); tag.typeExpression = typeExpression; tag.comment = comment; return tag; @@ -61885,7 +61973,7 @@ var ts; ts.createJSDocReturnTag = createJSDocReturnTag; /* @internal */ function createJSDocParamTag(name, isBracketed, typeExpression, comment) { - var tag = createJSDocTag(299 /* JSDocParameterTag */, "param"); + var tag = createJSDocTag(304 /* JSDocParameterTag */, "param"); tag.typeExpression = typeExpression; tag.name = name; tag.isBracketed = isBracketed; @@ -61895,7 +61983,7 @@ var ts; ts.createJSDocParamTag = createJSDocParamTag; /* @internal */ function createJSDocComment(comment, tags) { - var node = createSynthesizedNode(291 /* JSDocComment */); + var node = createSynthesizedNode(296 /* JSDocComment */); node.comment = comment; node.tags = tags; return node; @@ -62154,7 +62242,7 @@ var ts; (typeReferences !== undefined && node.typeReferenceDirectives !== typeReferences) || (libReferences !== undefined && node.libReferenceDirectives !== libReferences) || (hasNoDefaultLib !== undefined && node.hasNoDefaultLib !== hasNoDefaultLib)) { - var updated = createSynthesizedNode(279 /* SourceFile */); + var updated = createSynthesizedNode(284 /* SourceFile */); updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; @@ -62238,7 +62326,7 @@ var ts; * @param original The original statement. */ function createNotEmittedStatement(original) { - var node = createSynthesizedNode(307 /* NotEmittedStatement */); + var node = createSynthesizedNode(312 /* NotEmittedStatement */); node.original = original; setTextRange(node, original); return node; @@ -62250,7 +62338,7 @@ var ts; */ /* @internal */ function createEndOfDeclarationMarker(original) { - var node = createSynthesizedNode(311 /* EndOfDeclarationMarker */); + var node = createSynthesizedNode(316 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -62262,7 +62350,7 @@ var ts; */ /* @internal */ function createMergeDeclarationMarker(original) { - var node = createSynthesizedNode(310 /* MergeDeclarationMarker */); + var node = createSynthesizedNode(315 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -62277,7 +62365,7 @@ var ts; * @param location The location for the expression. Defaults to the positions from "original" if provided. */ function createPartiallyEmittedExpression(expression, original) { - var node = createSynthesizedNode(308 /* PartiallyEmittedExpression */); + var node = createSynthesizedNode(313 /* PartiallyEmittedExpression */); node.expression = expression; node.original = original; setTextRange(node, original); @@ -62293,7 +62381,7 @@ var ts; ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; function flattenCommaElements(node) { if (ts.nodeIsSynthesized(node) && !ts.isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) { - if (node.kind === 309 /* CommaListExpression */) { + if (node.kind === 314 /* CommaListExpression */) { return node.elements; } if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27 /* CommaToken */) { @@ -62303,7 +62391,7 @@ var ts; return node; } function createCommaList(elements) { - var node = createSynthesizedNode(309 /* CommaListExpression */); + var node = createSynthesizedNode(314 /* CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); return node; } @@ -62316,33 +62404,197 @@ var ts; ts.updateCommaList = updateCommaList; function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = ts.createNode(280 /* Bundle */); + var node = ts.createNode(285 /* Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; } ts.createBundle = createBundle; - function createUnparsedSourceFile(textOrInputFiles, mapPathOrType, map) { - var node = ts.createNode(281 /* UnparsedSource */); + var allUnscopedEmitHelpers; + function getAllUnscopedEmitHelpers() { + return allUnscopedEmitHelpers || (allUnscopedEmitHelpers = ts.arrayToMap([ + ts.valuesHelper, + ts.readHelper, + ts.spreadHelper, + ts.restHelper, + ts.decorateHelper, + ts.metadataHelper, + ts.paramHelper, + ts.awaiterHelper, + ts.assignHelper, + ts.awaitHelper, + ts.asyncGeneratorHelper, + ts.asyncDelegator, + ts.asyncValues, + ts.extendsHelper, + ts.templateObjectHelper, + ts.generatorHelper, + ts.importStarHelper, + ts.importDefaultHelper + ], function (helper) { return helper.name; })); + } + function createUnparsedSource() { + var node = ts.createNode(286 /* UnparsedSource */); + node.prologues = ts.emptyArray; + node.referencedFiles = ts.emptyArray; + node.libReferenceDirectives = ts.emptyArray; + node.getLineAndCharacterOfPosition = function (pos) { return ts.getLineAndCharacterOfPosition(node, pos); }; + return node; + } + function createUnparsedSourceFile(textOrInputFiles, mapPathOrType, mapTextOrStripInternal) { + var node = createUnparsedSource(); + var stripInternal; + var bundleFileInfo; if (!ts.isString(textOrInputFiles)) { ts.Debug.assert(mapPathOrType === "js" || mapPathOrType === "dts"); - node.fileName = mapPathOrType === "js" ? textOrInputFiles.javascriptPath : textOrInputFiles.declarationPath; + node.fileName = (mapPathOrType === "js" ? textOrInputFiles.javascriptPath : textOrInputFiles.declarationPath) || ""; node.sourceMapPath = mapPathOrType === "js" ? textOrInputFiles.javascriptMapPath : textOrInputFiles.declarationMapPath; Object.defineProperties(node, { text: { get: function () { return mapPathOrType === "js" ? textOrInputFiles.javascriptText : textOrInputFiles.declarationText; } }, sourceMapText: { get: function () { return mapPathOrType === "js" ? textOrInputFiles.javascriptMapText : textOrInputFiles.declarationMapText; } }, }); + if (textOrInputFiles.buildInfo && textOrInputFiles.buildInfo.bundle) { + node.oldFileOfCurrentEmit = textOrInputFiles.oldFileOfCurrentEmit; + ts.Debug.assert(mapTextOrStripInternal === undefined || typeof mapTextOrStripInternal === "boolean"); + stripInternal = mapTextOrStripInternal; + bundleFileInfo = mapPathOrType === "js" ? textOrInputFiles.buildInfo.bundle.js : textOrInputFiles.buildInfo.bundle.dts; + if (node.oldFileOfCurrentEmit) { + parseOldFileOfCurrentEmit(node, ts.Debug.assertDefined(bundleFileInfo)); + return node; + } + } } else { + node.fileName = ""; node.text = textOrInputFiles; node.sourceMapPath = mapPathOrType; - node.sourceMapText = map; + node.sourceMapText = mapTextOrStripInternal; } + ts.Debug.assert(!node.oldFileOfCurrentEmit); + parseUnparsedSourceFile(node, bundleFileInfo, stripInternal); return node; } ts.createUnparsedSourceFile = createUnparsedSourceFile; - function createInputFiles(javascriptTextOrReadFileText, declarationTextOrJavascriptPath, javascriptMapPath, javascriptMapTextOrDeclarationPath, declarationMapPath, declarationMapText) { - var node = ts.createNode(282 /* InputFiles */); + function parseUnparsedSourceFile(node, bundleFileInfo, stripInternal) { + var prologues; + var helpers; + var referencedFiles; + var typeReferenceDirectives; + var libReferenceDirectives; + var texts; + for (var _i = 0, _a = bundleFileInfo ? bundleFileInfo.sections : ts.emptyArray; _i < _a.length; _i++) { + var section = _a[_i]; + switch (section.kind) { + case "prologue" /* Prologue */: + (prologues || (prologues = [])).push(createUnparsedNode(section, node)); + break; + case "emitHelpers" /* EmitHelpers */: + (helpers || (helpers = [])).push(getAllUnscopedEmitHelpers().get(section.data)); + break; + case "no-default-lib" /* NoDefaultLib */: + node.hasNoDefaultLib = true; + break; + case "reference" /* Reference */: + (referencedFiles || (referencedFiles = [])).push({ pos: -1, end: -1, fileName: section.data }); + break; + case "type" /* Type */: + (typeReferenceDirectives || (typeReferenceDirectives = [])).push(section.data); + break; + case "lib" /* Lib */: + (libReferenceDirectives || (libReferenceDirectives = [])).push({ pos: -1, end: -1, fileName: section.data }); + break; + case "prepend" /* Prepend */: + var prependNode = createUnparsedNode(section, node); + var prependTexts = void 0; + for (var _b = 0, _c = section.texts; _b < _c.length; _b++) { + var text = _c[_b]; + if (!stripInternal || text.kind !== "internal" /* Internal */) { + (prependTexts || (prependTexts = [])).push(createUnparsedNode(text, node)); + } + } + prependNode.texts = prependTexts || ts.emptyArray; + (texts || (texts = [])).push(prependNode); + break; + case "internal" /* Internal */: + if (stripInternal) + break; + // falls through + case "text" /* Text */: + (texts || (texts = [])).push(createUnparsedNode(section, node)); + break; + default: + ts.Debug.assertNever(section); + } + } + node.prologues = prologues || ts.emptyArray; + node.helpers = helpers; + node.referencedFiles = referencedFiles || ts.emptyArray; + node.typeReferenceDirectives = typeReferenceDirectives; + node.libReferenceDirectives = libReferenceDirectives || ts.emptyArray; + node.texts = texts || [createUnparsedNode({ kind: "text" /* Text */, pos: 0, end: node.text.length }, node)]; + } + function parseOldFileOfCurrentEmit(node, bundleFileInfo) { + ts.Debug.assert(!!node.oldFileOfCurrentEmit); + var texts; + var syntheticReferences; + for (var _i = 0, _a = bundleFileInfo.sections; _i < _a.length; _i++) { + var section = _a[_i]; + switch (section.kind) { + case "internal" /* Internal */: + case "text" /* Text */: + (texts || (texts = [])).push(createUnparsedNode(section, node)); + break; + case "no-default-lib" /* NoDefaultLib */: + case "reference" /* Reference */: + case "type" /* Type */: + case "lib" /* Lib */: + (syntheticReferences || (syntheticReferences = [])).push(createUnparsedSyntheticReference(section, node)); + break; + // Ignore + case "prologue" /* Prologue */: + case "emitHelpers" /* EmitHelpers */: + case "prepend" /* Prepend */: + break; + default: + ts.Debug.assertNever(section); + } + } + node.texts = texts || ts.emptyArray; + node.helpers = ts.map(bundleFileInfo.sources && bundleFileInfo.sources.helpers, function (name) { return getAllUnscopedEmitHelpers().get(name); }); + node.syntheticReferences = syntheticReferences; + return node; + } + function mapBundleFileSectionKindToSyntaxKind(kind) { + switch (kind) { + case "prologue" /* Prologue */: return 279 /* UnparsedPrologue */; + case "prepend" /* Prepend */: return 280 /* UnparsedPrepend */; + case "internal" /* Internal */: return 282 /* UnparsedInternalText */; + case "text" /* Text */: return 281 /* UnparsedText */; + case "emitHelpers" /* EmitHelpers */: + case "no-default-lib" /* NoDefaultLib */: + case "reference" /* Reference */: + case "type" /* Type */: + case "lib" /* Lib */: + return ts.Debug.fail("BundleFileSectionKind: " + kind + " not yet mapped to SyntaxKind"); + default: + return ts.Debug.assertNever(kind); + } + } + function createUnparsedNode(section, parent) { + var node = ts.createNode(mapBundleFileSectionKindToSyntaxKind(section.kind), section.pos, section.end); + node.parent = parent; + node.data = section.data; + return node; + } + function createUnparsedSyntheticReference(section, parent) { + var node = ts.createNode(283 /* UnparsedSyntheticReference */, section.pos, section.end); + node.parent = parent; + node.data = section.data; + node.section = section; + return node; + } + function createInputFiles(javascriptTextOrReadFileText, declarationTextOrJavascriptPath, javascriptMapPath, javascriptMapTextOrDeclarationPath, declarationMapPath, declarationMapTextOrBuildInfoPath, javascriptPath, declarationPath, buildInfoPath, buildInfo, oldFileOfCurrentEmit) { + var node = ts.createNode(287 /* InputFiles */); if (!ts.isString(javascriptTextOrReadFileText)) { var cache_1 = ts.createMap(); var textGetter_1 = function (path) { @@ -62359,15 +62611,25 @@ var ts; var result = textGetter_1(path); return result !== undefined ? result : "/* Input file " + path + " was missing */\r\n"; }; + var buildInfo_1; + var getBuildInfo_1 = function (getText) { + if (buildInfo_1 === undefined) { + var result = getText(); + buildInfo_1 = result !== undefined ? JSON.parse(result) : false; + } + return buildInfo_1 || undefined; + }; node.javascriptPath = declarationTextOrJavascriptPath; node.javascriptMapPath = javascriptMapPath; node.declarationPath = ts.Debug.assertDefined(javascriptMapTextOrDeclarationPath); node.declarationMapPath = declarationMapPath; + node.buildInfoPath = declarationMapTextOrBuildInfoPath; Object.defineProperties(node, { javascriptText: { get: function () { return definedTextGetter_1(declarationTextOrJavascriptPath); } }, javascriptMapText: { get: function () { return textGetter_1(javascriptMapPath); } }, declarationText: { get: function () { return definedTextGetter_1(ts.Debug.assertDefined(javascriptMapTextOrDeclarationPath)); } }, - declarationMapText: { get: function () { return textGetter_1(declarationMapPath); } } // TODO:: if there is inline sourceMap in dtsFile, use that + declarationMapText: { get: function () { return textGetter_1(declarationMapPath); } }, + buildInfo: { get: function () { return getBuildInfo_1(function () { return textGetter_1(declarationMapTextOrBuildInfoPath); }); } } }); } else { @@ -62376,7 +62638,12 @@ var ts; node.javascriptMapText = javascriptMapTextOrDeclarationPath; node.declarationText = declarationTextOrJavascriptPath; node.declarationMapPath = declarationMapPath; - node.declarationMapText = declarationMapText; + node.declarationMapText = declarationMapTextOrBuildInfoPath; + node.javascriptPath = javascriptPath; + node.declarationPath = declarationPath, + node.buildInfoPath = buildInfoPath; + node.buildInfo = buildInfo; + node.oldFileOfCurrentEmit = oldFileOfCurrentEmit; } return node; } @@ -62514,7 +62781,7 @@ var ts; // To avoid holding onto transformation artifacts, we keep track of any // parse tree node we are annotating. This allows us to clean them up after // all transformations have completed. - if (node.kind === 279 /* SourceFile */) { + if (node.kind === 284 /* SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(ts.getParseTreeNode(ts.getSourceFileOfNode(node))); @@ -62960,38 +63227,38 @@ var ts; return ts.setEmitFlags(ts.createIdentifier(name), 4096 /* HelperName */ | 2 /* AdviseOnEmitNode */); } ts.getHelperName = getHelperName; - var valuesHelper = { + ts.valuesHelper = { name: "typescript:values", scoped: false, text: "\n var __values = (this && this.__values) || function (o) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator], i = 0;\n if (m) return m.call(o);\n return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n };" }; function createValuesHelper(context, expression, location) { - context.requestEmitHelper(valuesHelper); + context.requestEmitHelper(ts.valuesHelper); return ts.setTextRange(ts.createCall(getHelperName("__values"), /*typeArguments*/ undefined, [expression]), location); } ts.createValuesHelper = createValuesHelper; - var readHelper = { + ts.readHelper = { name: "typescript:read", scoped: false, text: "\n var __read = (this && this.__read) || function (o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n };" }; function createReadHelper(context, iteratorRecord, count, location) { - context.requestEmitHelper(readHelper); + context.requestEmitHelper(ts.readHelper); return ts.setTextRange(ts.createCall(getHelperName("__read"), /*typeArguments*/ undefined, count !== undefined ? [iteratorRecord, ts.createLiteral(count)] : [iteratorRecord]), location); } ts.createReadHelper = createReadHelper; - var spreadHelper = { + ts.spreadHelper = { name: "typescript:spread", scoped: false, text: "\n var __spread = (this && this.__spread) || function () {\n for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));\n return ar;\n };" }; function createSpreadHelper(context, argumentList, location) { - context.requestEmitHelper(readHelper); - context.requestEmitHelper(spreadHelper); + context.requestEmitHelper(ts.readHelper); + context.requestEmitHelper(ts.spreadHelper); return ts.setTextRange(ts.createCall(getHelperName("__spread"), /*typeArguments*/ undefined, argumentList), location); } @@ -63837,7 +64104,7 @@ var ts; case 190 /* ElementAccessExpression */: case 189 /* PropertyAccessExpression */: case 213 /* NonNullExpression */: - case 308 /* PartiallyEmittedExpression */: + case 313 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -63853,7 +64120,7 @@ var ts; ts.parenthesizeConciseBody = parenthesizeConciseBody; function isCommaSequence(node) { return node.kind === 204 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || - node.kind === 309 /* CommaListExpression */; + node.kind === 314 /* CommaListExpression */; } ts.isCommaSequence = isCommaSequence; var OuterExpressionKinds; @@ -63872,7 +64139,7 @@ var ts; case 212 /* AsExpression */: case 213 /* NonNullExpression */: return (kinds & 2 /* Assertions */) !== 0; - case 308 /* PartiallyEmittedExpression */: + case 313 /* PartiallyEmittedExpression */: return (kinds & 4 /* PartiallyEmittedExpressions */) !== 0; } return false; @@ -63909,7 +64176,7 @@ var ts; case 194 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); case 212 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); case 213 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); - case 308 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); + case 313 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -64701,12 +64968,12 @@ var ts; case 278 /* EnumMember */: return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); // Top-level nodes - case 279 /* SourceFile */: + case 284 /* SourceFile */: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 308 /* PartiallyEmittedExpression */: + case 313 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 309 /* CommaListExpression */: + case 314 /* CommaListExpression */: return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: // No need to visit nodes with no children. @@ -64762,7 +65029,7 @@ var ts; case 220 /* EmptyStatement */: case 210 /* OmittedExpression */: case 236 /* DebuggerStatement */: - case 307 /* NotEmittedStatement */: + case 312 /* NotEmittedStatement */: // No need to visit nodes with no children. break; // Names @@ -65139,14 +65406,14 @@ var ts; result = reduceNode(node.initializer, cbNode, result); break; // Top-level nodes - case 279 /* SourceFile */: + case 284 /* SourceFile */: result = reduceNodes(node.statements, cbNodes, result); break; // Transformation nodes - case 308 /* PartiallyEmittedExpression */: + case 313 /* PartiallyEmittedExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 309 /* CommaListExpression */: + case 314 /* CommaListExpression */: result = reduceNodes(node.elements, cbNodes, result); break; default: @@ -65427,7 +65694,7 @@ var ts; } exit(); } - function appendSourceMap(generatedLine, generatedCharacter, map, sourceMapPath) { + function appendSourceMap(generatedLine, generatedCharacter, map, sourceMapPath, start, end) { var _a; ts.Debug.assert(generatedLine >= pendingGeneratedLine, "generatedLine cannot backtrack"); ts.Debug.assert(generatedCharacter >= 0, "generatedCharacter cannot be negative"); @@ -65437,6 +65704,14 @@ var ts; var nameIndexToNewNameIndexMap; var mappingIterator = decodeMappings(map.mappings); for (var _b = mappingIterator.next(), raw = _b.value, done = _b.done; !done; _a = mappingIterator.next(), raw = _a.value, done = _a.done, _a) { + if (end && (raw.generatedLine > end.line || + (raw.generatedLine === end.line && raw.generatedCharacter > end.character))) { + break; + } + if (start && (raw.generatedLine < start.line || + (start.line === raw.generatedLine && raw.generatedCharacter < start.character))) { + continue; + } // Then reencode all the updated mappings into the overall map var newSourceIndex = void 0; var newSourceLine = void 0; @@ -65465,8 +65740,10 @@ var ts; } } } - var newGeneratedLine = raw.generatedLine + generatedLine; - var newGeneratedCharacter = raw.generatedLine === 0 ? raw.generatedCharacter + generatedCharacter : raw.generatedCharacter; + var rawGeneratedLine = raw.generatedLine - (start ? start.line : 0); + var newGeneratedLine = rawGeneratedLine + generatedLine; + var rawGeneratedCharacter = start && start.line === raw.generatedLine ? raw.generatedCharacter - start.character : raw.generatedCharacter; + var newGeneratedCharacter = rawGeneratedLine === 0 ? rawGeneratedCharacter + generatedCharacter : rawGeneratedCharacter; addMapping(newGeneratedLine, newGeneratedCharacter, newSourceIndex, newSourceLine, newSourceCharacter, newNameIndex); } exit(); @@ -65949,7 +66226,7 @@ var ts; function chainBundle(transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 279 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 284 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return ts.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -66610,7 +66887,7 @@ var ts; function makeAssignmentElement(name) { return name; } - var restHelper = { + ts.restHelper = { name: "typescript:rest", scoped: false, text: "\n var __rest = (this && this.__rest) || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)\n t[p[i]] = s[p[i]];\n return t;\n };" @@ -66619,7 +66896,7 @@ var ts; * `{ a, b, ...p } = o`, create `p = __rest(o, ["a", "b"]);` */ function createRestCall(context, value, elements, computedTempVariables, location) { - context.requestEmitHelper(restHelper); + context.requestEmitHelper(ts.restHelper); var propertyNames = []; var computedTempVariableOffset = 0; for (var i = 0; i < elements.length - 1; i++) { @@ -66720,14 +66997,14 @@ var ts; var pendingExpressions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 280 /* Bundle */) { + if (node.kind === 285 /* Bundle */) { return transformBundle(node); } return transformSourceFile(node); } function transformBundle(node) { return ts.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 282 /* InputFiles */) { + if (prepend.kind === 287 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend, "js"); } return prepend; @@ -66776,7 +67053,7 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: case 246 /* CaseBlock */: case 245 /* ModuleBlock */: case 218 /* Block */: @@ -69007,7 +69284,7 @@ var ts; // enums in any other scope are emitted as a `let` declaration. var statement = ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ ts.createVariableDeclaration(ts.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true)) - ], currentLexicalScope.kind === 279 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentLexicalScope.kind === 284 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { @@ -69572,7 +69849,7 @@ var ts; // If we are nested within a namespace declaration, we may need to qualifiy // an identifier that is exported from a merged namespace. var container = resolver.getReferencedExportContainer(node, /*prefixLocals*/ false); - if (container && container.kind !== 279 /* SourceFile */) { + if (container && container.kind !== 284 /* SourceFile */) { var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 244 /* ModuleDeclaration */) || (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 243 /* EnumDeclaration */); if (substitute) { @@ -69623,39 +69900,39 @@ var ts; argumentsArray.push(descriptor); } } - context.requestEmitHelper(decorateHelper); + context.requestEmitHelper(ts.decorateHelper); return ts.setTextRange(ts.createCall(ts.getHelperName("__decorate"), /*typeArguments*/ undefined, argumentsArray), location); } - var decorateHelper = { + ts.decorateHelper = { name: "typescript:decorate", scoped: false, priority: 2, text: "\n var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n };" }; function createMetadataHelper(context, metadataKey, metadataValue) { - context.requestEmitHelper(metadataHelper); + context.requestEmitHelper(ts.metadataHelper); return ts.createCall(ts.getHelperName("__metadata"), /*typeArguments*/ undefined, [ ts.createLiteral(metadataKey), metadataValue ]); } - var metadataHelper = { + ts.metadataHelper = { name: "typescript:metadata", scoped: false, priority: 3, text: "\n var __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n };" }; function createParamHelper(context, expression, parameterOffset, location) { - context.requestEmitHelper(paramHelper); + context.requestEmitHelper(ts.paramHelper); return ts.setTextRange(ts.createCall(ts.getHelperName("__param"), /*typeArguments*/ undefined, [ ts.createLiteral(parameterOffset), expression ]), location); } - var paramHelper = { + ts.paramHelper = { name: "typescript:param", scoped: false, priority: 4, @@ -70206,14 +70483,14 @@ var ts; ], 2 /* Const */)); } ts.createSuperAccessVariableStatement = createSuperAccessVariableStatement; - var awaiterHelper = { + ts.awaiterHelper = { name: "typescript:awaiter", scoped: false, priority: 5, text: "\n var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n };" }; function createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, body) { - context.requestEmitHelper(awaiterHelper); + context.requestEmitHelper(ts.awaiterHelper); var generatorFunc = ts.createFunctionExpression( /*modifiers*/ undefined, ts.createToken(40 /* AsteriskToken */), /*name*/ undefined, @@ -70845,7 +71122,7 @@ var ts; } } ts.transformES2018 = transformES2018; - var assignHelper = { + ts.assignHelper = { name: "typescript:assign", scoped: false, priority: 1, @@ -70856,28 +71133,28 @@ var ts; return ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "assign"), /*typeArguments*/ undefined, attributesSegments); } - context.requestEmitHelper(assignHelper); + context.requestEmitHelper(ts.assignHelper); return ts.createCall(ts.getHelperName("__assign"), /*typeArguments*/ undefined, attributesSegments); } ts.createAssignHelper = createAssignHelper; - var awaitHelper = { + ts.awaitHelper = { name: "typescript:await", scoped: false, text: "\n var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }" }; function createAwaitHelper(context, expression) { - context.requestEmitHelper(awaitHelper); + context.requestEmitHelper(ts.awaitHelper); return ts.createCall(ts.getHelperName("__await"), /*typeArguments*/ undefined, [expression]); } - var asyncGeneratorHelper = { + ts.asyncGeneratorHelper = { name: "typescript:asyncGenerator", scoped: false, text: "\n var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n };" }; function createAsyncGeneratorHelper(context, generatorFunc) { - context.requestEmitHelper(awaitHelper); - context.requestEmitHelper(asyncGeneratorHelper); + context.requestEmitHelper(ts.awaitHelper); + context.requestEmitHelper(ts.asyncGeneratorHelper); // Mark this node as originally an async function (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* AsyncFunctionBody */; return ts.createCall(ts.getHelperName("__asyncGenerator"), @@ -70887,24 +71164,24 @@ var ts; generatorFunc ]); } - var asyncDelegator = { + ts.asyncDelegator = { name: "typescript:asyncDelegator", scoped: false, text: "\n var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {\n var i, p;\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\n };" }; function createAsyncDelegatorHelper(context, expression, location) { - context.requestEmitHelper(awaitHelper); - context.requestEmitHelper(asyncDelegator); + context.requestEmitHelper(ts.awaitHelper); + context.requestEmitHelper(ts.asyncDelegator); return ts.setTextRange(ts.createCall(ts.getHelperName("__asyncDelegator"), /*typeArguments*/ undefined, [expression]), location); } - var asyncValues = { + ts.asyncValues = { name: "typescript:asyncValues", scoped: false, text: "\n var __asyncValues = (this && this.__asyncValues) || function (o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator], i;\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\n };" }; function createAsyncValuesHelper(context, expression, location) { - context.requestEmitHelper(asyncValues); + context.requestEmitHelper(ts.asyncValues); return ts.setTextRange(ts.createCall(ts.getHelperName("__asyncValues"), /*typeArguments*/ undefined, [expression]), location); } @@ -74716,7 +74993,7 @@ var ts; } ts.transformES2015 = transformES2015; function createExtendsHelper(context, name) { - context.requestEmitHelper(extendsHelper); + context.requestEmitHelper(ts.extendsHelper); return ts.createCall(ts.getHelperName("__extends"), /*typeArguments*/ undefined, [ name, @@ -74724,20 +75001,20 @@ var ts; ]); } function createTemplateObjectHelper(context, cooked, raw) { - context.requestEmitHelper(templateObjectHelper); + context.requestEmitHelper(ts.templateObjectHelper); return ts.createCall(ts.getHelperName("__makeTemplateObject"), /*typeArguments*/ undefined, [ cooked, raw ]); } - var extendsHelper = { + ts.extendsHelper = { name: "typescript:extends", scoped: false, priority: 0, text: "\n var __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n })();" }; - var templateObjectHelper = { + ts.templateObjectHelper = { name: "typescript:makeTemplateObject", scoped: false, priority: 0, @@ -77431,7 +77708,7 @@ var ts; } ts.transformGenerators = transformGenerators; function createGeneratorHelper(context, body) { - context.requestEmitHelper(generatorHelper); + context.requestEmitHelper(ts.generatorHelper); return ts.createCall(ts.getHelperName("__generator"), /*typeArguments*/ undefined, [ts.createThis(), body]); } @@ -77494,7 +77771,7 @@ var ts; // entering a finally block. // // For examples of how these are used, see the comments in ./transformers/generators.ts - var generatorHelper = { + ts.generatorHelper = { name: "typescript:generator", scoped: false, priority: 6, @@ -77527,7 +77804,7 @@ var ts; context.enableSubstitution(202 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. context.enableSubstitution(203 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. context.enableSubstitution(276 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(279 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableEmitNotification(284 /* SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var currentSourceFile; // The current file. @@ -77869,9 +78146,9 @@ var ts; return visitFunctionDeclaration(node); case 240 /* ClassDeclaration */: return visitClassDeclaration(node); - case 310 /* MergeDeclarationMarker */: + case 315 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 311 /* EndOfDeclarationMarker */: + case 316 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); @@ -78029,7 +78306,7 @@ var ts; } var promise = ts.createNew(ts.createIdentifier("Promise"), /*typeArguments*/ undefined, [func]); if (compilerOptions.esModuleInterop) { - context.requestEmitHelper(importStarHelper); + context.requestEmitHelper(ts.importStarHelper); return ts.createCall(ts.createPropertyAccess(promise, ts.createIdentifier("then")), /*typeArguments*/ undefined, [ts.getHelperName("__importStar")]); } return promise; @@ -78043,7 +78320,7 @@ var ts; var promiseResolveCall = ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Promise"), "resolve"), /*typeArguments*/ undefined, /*argumentsArray*/ []); var requireCall = ts.createCall(ts.createIdentifier("require"), /*typeArguments*/ undefined, arg ? [arg] : []); if (compilerOptions.esModuleInterop) { - context.requestEmitHelper(importStarHelper); + context.requestEmitHelper(ts.importStarHelper); requireCall = ts.createCall(ts.getHelperName("__importStar"), /*typeArguments*/ undefined, [requireCall]); } var func; @@ -78077,11 +78354,11 @@ var ts; return innerExpr; } if (ts.getImportNeedsImportStarHelper(node)) { - context.requestEmitHelper(importStarHelper); + context.requestEmitHelper(ts.importStarHelper); return ts.createCall(ts.getHelperName("__importStar"), /*typeArguments*/ undefined, [innerExpr]); } if (ts.getImportNeedsImportDefaultHelper(node)) { - context.requestEmitHelper(importDefaultHelper); + context.requestEmitHelper(ts.importDefaultHelper); return ts.createCall(ts.getHelperName("__importDefault"), /*typeArguments*/ undefined, [innerExpr]); } return innerExpr; @@ -78650,7 +78927,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 279 /* SourceFile */) { + if (node.kind === 284 /* SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -78738,7 +79015,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 279 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 284 /* SourceFile */) { return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), /*location*/ node); } @@ -78864,13 +79141,13 @@ var ts; text: "\n var __syncRequire = typeof module === \"object\" && typeof module.exports === \"object\";" }; // emit helper for `import * as Name from "foo"` - var importStarHelper = { + ts.importStarHelper = { name: "typescript:commonjsimportstar", scoped: false, text: "\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\n result[\"default\"] = mod;\n return result;\n};" }; // emit helper for `import Name from "foo"` - var importDefaultHelper = { + ts.importDefaultHelper = { name: "typescript:commonjsimportdefault", scoped: false, text: "\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};" @@ -78893,7 +79170,7 @@ var ts; context.enableSubstitution(204 /* BinaryExpression */); // Substitutes assignments to exported symbols. context.enableSubstitution(202 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. context.enableSubstitution(203 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableEmitNotification(279 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableEmitNotification(284 /* SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var exportFunctionsMap = []; // The export function associated with a source file. @@ -79463,7 +79740,7 @@ var ts; function shouldHoistVariableDeclarationList(node) { // hoist only non-block scoped declarations or block scoped declarations parented by source file return (ts.getEmitFlags(node) & 2097152 /* NoHoisting */) === 0 - && (enclosingBlockScopedContainer.kind === 279 /* SourceFile */ + && (enclosingBlockScopedContainer.kind === 284 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -79806,9 +80083,9 @@ var ts; return visitCatchClause(node); case 218 /* Block */: return visitBlock(node); - case 310 /* MergeDeclarationMarker */: + case 315 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 311 /* EndOfDeclarationMarker */: + case 316 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -80056,7 +80333,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 279 /* SourceFile */; + return container !== undefined && container.kind === 284 /* SourceFile */; } else { return false; @@ -80089,7 +80366,7 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 279 /* SourceFile */) { + if (node.kind === 284 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -80298,7 +80575,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 279 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 284 /* SourceFile */) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -80337,7 +80614,7 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(279 /* SourceFile */); + context.enableEmitNotification(284 /* SourceFile */); context.enableSubstitution(72 /* Identifier */); var currentSourceFile; return ts.chainBundle(transformSourceFile); @@ -80850,6 +81127,15 @@ var ts; return result.diagnostics; } ts.getDeclarationDiagnostics = getDeclarationDiagnostics; + function isInternalDeclaration(node, currentSourceFile) { + var parseTreeNode = ts.getParseTreeNode(node); + var leadingCommentRanges = parseTreeNode && ts.getLeadingCommentRangesOfNode(parseTreeNode, currentSourceFile); + return !!ts.forEach(leadingCommentRanges, function (range) { + var comment = currentSourceFile.text.substring(range.pos, range.end); + return ts.stringContains(comment, "@internal"); + }); + } + ts.isInternalDeclaration = isInternalDeclaration; var declarationEmitNodeBuilderFlags = 1024 /* MultilineObjectLiterals */ | 2048 /* WriteClassExpressionAsTypeLiteral */ | 4096 /* UseTypeOfFunction */ | @@ -80978,10 +81264,10 @@ var ts; } } function transformRoot(node) { - if (node.kind === 279 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJS(node))) { + if (node.kind === 284 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJS(node))) { return node; } - if (node.kind === 280 /* Bundle */) { + if (node.kind === 285 /* Bundle */) { isBundledEmit = true; refs = ts.createMap(); libs = ts.createMap(); @@ -81011,9 +81297,15 @@ var ts; var updated = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); return ts.updateSourceFileNode(sourceFile, transformAndReplaceLatePaintedStatements(updated), /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); }), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 282 /* InputFiles */) { - return ts.createUnparsedSourceFile(prepend, "dts"); + if (prepend.kind === 287 /* InputFiles */) { + var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal); + hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib; + collectReferences(sourceFile, refs); + recordTypeReferenceDirectivesIfNecessary(sourceFile.typeReferenceDirectives); + collectLibs(sourceFile, libs); + return sourceFile; } + return prepend; })); bundle.syntheticFileReferences = []; bundle.syntheticTypeReferences = getFileReferencesForUsedTypeReferences(); @@ -81105,7 +81397,7 @@ var ts; } } function collectReferences(sourceFile, ret) { - if (noResolve || ts.isSourceFileJS(sourceFile)) + if (noResolve || (!ts.isUnparsedSource(sourceFile) && ts.isSourceFileJS(sourceFile))) return ret; ts.forEach(sourceFile.referencedFiles, function (f) { var elem = ts.tryResolveScriptReference(host, sourceFile, f); @@ -81833,18 +82125,8 @@ var ts; } errorNameNode = undefined; } - function hasInternalAnnotation(range) { - var comment = currentSourceFile.text.substring(range.pos, range.end); - return ts.stringContains(comment, "@internal"); - } function shouldStripInternal(node) { - if (stripInternal && node) { - var leadingCommentRanges = ts.getLeadingCommentRangesOfNode(ts.getParseTreeNode(node), currentSourceFile); - if (ts.forEach(leadingCommentRanges, hasInternalAnnotation)) { - return true; - } - } - return false; + return !!stripInternal && !!node && isInternalDeclaration(node, currentSourceFile); } function isScopeMarker(node) { return ts.isExportAssignment(node) || ts.isExportDeclaration(node); @@ -81866,7 +82148,7 @@ var ts; function ensureModifierFlags(node, privateDeclaration) { var mask = 3071 /* All */ ^ (4 /* Public */ | 256 /* Async */); // No async modifiers in declaration files var additions = (needsDeclare && !isAlwaysType(node)) ? 2 /* Ambient */ : 0 /* None */; - var parentIsFile = node.parent.kind === 279 /* SourceFile */; + var parentIsFile = node.parent.kind === 284 /* SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= ((privateDeclaration || (isBundledEmit && parentIsFile) || hasScopeMarker(node.parent) ? 0 : 1 /* Export */) | 2 /* Ambient */); additions = 0 /* None */; @@ -82083,7 +82365,7 @@ var ts; * @param allowDtsFiles A value indicating whether to allow the transformation of .d.ts files. */ function transformNodes(resolver, host, options, nodes, transformers, allowDtsFiles) { - var enabledSyntaxKindFeatures = new Array(312 /* Count */); + var enabledSyntaxKindFeatures = new Array(317 /* Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentVariableDeclarationsStack = []; @@ -82343,10 +82625,14 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - var infoExtension = ".tsbundleinfo"; var brackets = createBracketsMap(); var syntheticParent = { pos: -1, end: -1 }; /*@internal*/ + function isBuildInfoFile(file) { + return ts.fileExtensionIs(file, ".tsbuildinfo" /* TsBuildInfo */); + } + ts.isBuildInfoFile = isBuildInfoFile; + /*@internal*/ /** * Iterates over the source files that are expected to have an emit output. * @@ -82356,13 +82642,14 @@ var ts; * If an array, the full list of source files to emit. * Else, calls `getSourceFilesToEmit` with the (optional) target source file to determine the list of source files to emit. */ - function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, emitOnlyDtsFiles) { + function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, emitOnlyDtsFiles, onlyBuildInfo, includeBuildInfo) { if (emitOnlyDtsFiles === void 0) { emitOnlyDtsFiles = false; } var sourceFiles = ts.isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : ts.getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile); var options = host.getCompilerOptions(); if (options.outFile || options.out) { - if (sourceFiles.length) { - var bundle = ts.createBundle(sourceFiles, host.getPrependNodes()); + var prepends = host.getPrependNodes(); + if (sourceFiles.length || prepends.length) { + var bundle = ts.createBundle(sourceFiles, prepends); var result = action(getOutputPathsFor(bundle, host, emitOnlyDtsFiles), bundle); if (result) { return result; @@ -82370,31 +82657,61 @@ var ts; } } else { - for (var _a = 0, sourceFiles_1 = sourceFiles; _a < sourceFiles_1.length; _a++) { - var sourceFile = sourceFiles_1[_a]; - var result = action(getOutputPathsFor(sourceFile, host, emitOnlyDtsFiles), sourceFile); - if (result) { - return result; + if (!onlyBuildInfo) { + for (var _a = 0, sourceFiles_1 = sourceFiles; _a < sourceFiles_1.length; _a++) { + var sourceFile = sourceFiles_1[_a]; + var result = action(getOutputPathsFor(sourceFile, host, emitOnlyDtsFiles), sourceFile); + if (result) { + return result; + } } } + if (includeBuildInfo) { + var buildInfoPath = getOutputPathForBuildInfo(host.getCompilerOptions()); + if (buildInfoPath) + return action({ buildInfoPath: buildInfoPath }, /*sourceFileOrBundle*/ undefined); + } } } ts.forEachEmittedFile = forEachEmittedFile; /*@internal*/ + function getOutputPathForBuildInfo(options) { + var configFile = options.configFilePath; + if (!configFile || !ts.isIncrementalCompilation(options)) + return undefined; + if (options.tsBuildInfoFile) + return options.tsBuildInfoFile; + var outPath = options.outFile || options.out; + var buildInfoExtensionLess; + if (outPath) { + buildInfoExtensionLess = ts.removeFileExtension(outPath); + } + else { + var configFileExtensionLess = ts.removeFileExtension(configFile); + buildInfoExtensionLess = options.outDir ? + options.rootDir ? + ts.resolvePath(options.outDir, ts.getRelativePathFromDirectory(options.rootDir, configFileExtensionLess, /*ignoreCase*/ true)) : + ts.combinePaths(options.outDir, ts.getBaseFileName(configFileExtensionLess)) : + configFileExtensionLess; + } + return buildInfoExtensionLess + ".tsbuildinfo" /* TsBuildInfo */; + } + ts.getOutputPathForBuildInfo = getOutputPathForBuildInfo; + /*@internal*/ function getOutputPathsForBundle(options, forceDtsPaths) { var outPath = options.outFile || options.out; var jsFilePath = options.emitDeclarationOnly ? undefined : outPath; var sourceMapFilePath = jsFilePath && getSourceMapFilePath(jsFilePath, options); var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.removeFileExtension(outPath) + ".d.ts" /* Dts */ : undefined; var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; - var bundleInfoPath = options.references && jsFilePath ? (ts.removeFileExtension(jsFilePath) + infoExtension) : undefined; - return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, bundleInfoPath: bundleInfoPath }; + var buildInfoPath = getOutputPathForBuildInfo(options); + return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: buildInfoPath }; } ts.getOutputPathsForBundle = getOutputPathsForBundle; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 280 /* Bundle */) { + if (sourceFile.kind === 285 /* Bundle */) { return getOutputPathsForBundle(options, forceDtsPaths); } else { @@ -82408,19 +82725,13 @@ var ts; var isJs = ts.isSourceFileJS(sourceFile); var declarationFilePath = ((forceDtsPaths || ts.getEmitDeclarations(options)) && !isJs) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; - return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, bundleInfoPath: undefined }; + return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: undefined }; } } ts.getOutputPathsFor = getOutputPathsFor; function getSourceMapFilePath(jsFilePath, options) { return (options.sourceMap && !options.inlineSourceMap) ? jsFilePath + ".map" : undefined; } - function createDefaultBundleInfo() { - return { - originalOffset: -1, - totalLength: -1 - }; - } // JavaScript files are always LanguageVariant.JSX, as JSX syntax is allowed in .js files also. // So for JavaScript files, '.jsx' is only emitted if the input was '.jsx', and JsxEmit.Preserve. // For TypeScript, the only time to emit with a '.jsx' extension, is on JSX input, and JsxEmit.Preserve @@ -82445,7 +82756,7 @@ var ts; ts.getOutputExtension = getOutputExtension; /*@internal*/ // targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature - function emitFiles(resolver, host, targetSourceFile, emitOnlyDtsFiles, transformers, declarationTransformers) { + function emitFiles(resolver, host, targetSourceFile, emitOnlyDtsFiles, transformers, declarationTransformers, onlyBuildInfo) { var compilerOptions = host.getCompilerOptions(); var sourceMapDataList = (compilerOptions.sourceMap || compilerOptions.inlineSourceMap || ts.getAreDeclarationMapsEnabled(compilerOptions)) ? [] : undefined; var emittedFilesList = compilerOptions.listEmittedFiles ? [] : undefined; @@ -82453,12 +82764,12 @@ var ts; var newLine = ts.getNewLineCharacter(compilerOptions, function () { return host.getNewLine(); }); var writer = ts.createTextWriter(newLine); var _a = ts.performance.createTimer("printTime", "beforePrint", "afterPrint"), enter = _a.enter, exit = _a.exit; - var bundleInfo = createDefaultBundleInfo(); + var bundleBuildInfo; var emitSkipped = false; var exportedModulesFromDeclarationEmit; // Emit each output file enter(); - forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), emitOnlyDtsFiles); + forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), emitOnlyDtsFiles, onlyBuildInfo, !targetSourceFile); exit(); return { emitSkipped: emitSkipped, @@ -82468,9 +82779,16 @@ var ts; exportedModulesFromDeclarationEmit: exportedModulesFromDeclarationEmit }; function emitSourceFileOrBundle(_a, sourceFileOrBundle) { - var jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, bundleInfoPath = _a.bundleInfoPath; - emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, bundleInfoPath); + var jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath; + if (buildInfoPath && sourceFileOrBundle && ts.isBundle(sourceFileOrBundle)) { + bundleBuildInfo = { + commonSourceDirectory: host.getCommonSourceDirectory(), + sourceFiles: sourceFileOrBundle.sourceFiles.map(function (file) { return file.fileName; }) + }; + } + emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath); emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath); + emitBuildInfo(bundleBuildInfo, buildInfoPath); if (!emitSkipped && emittedFilesList) { if (!emitOnlyDtsFiles) { if (jsFilePath) { @@ -82479,8 +82797,8 @@ var ts; if (sourceMapFilePath) { emittedFilesList.push(sourceMapFilePath); } - if (bundleInfoPath) { - emittedFilesList.push(bundleInfoPath); + if (buildInfoPath) { + emittedFilesList.push(buildInfoPath); } } if (declarationFilePath) { @@ -82491,8 +82809,21 @@ var ts; } } } - function emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, bundleInfoPath) { - if (emitOnlyDtsFiles || !jsFilePath) { + function emitBuildInfo(bundle, buildInfoPath) { + // Write build information if applicable + if (!buildInfoPath || targetSourceFile || emitSkipped) + return; + var program = host.getProgramBuildInfo(); + if (!bundle && !program) + return; + if (host.isEmitBlocked(buildInfoPath) || compilerOptions.noEmit) { + emitSkipped = true; + return; + } + ts.writeFile(host, emitterDiagnostics, buildInfoPath, getBuildInfoText({ bundle: bundle, program: program }), /*writeByteOrderMark*/ false); + } + function emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath) { + if (!sourceFileOrBundle || emitOnlyDtsFiles || !jsFilePath) { return; } // Make sure not to write js file and source map file if any of them cannot be written @@ -82512,6 +82843,7 @@ var ts; inlineSourceMap: compilerOptions.inlineSourceMap, inlineSources: compilerOptions.inlineSources, extendedDiagnostics: compilerOptions.extendedDiagnostics, + writeBundleFileInfo: !!bundleBuildInfo }; // Create a printer to print the nodes var printer = createPrinter(printerOptions, { @@ -82522,12 +82854,14 @@ var ts; substituteNode: transform.substituteNode, }); ts.Debug.assert(transform.transformed.length === 1, "Should only see one output from the transform"); - printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform.transformed[0], bundleInfoPath, printer, compilerOptions); + printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform.transformed[0], printer, compilerOptions); // Clean up emit nodes on parse tree transform.dispose(); + if (bundleBuildInfo) + bundleBuildInfo.js = printer.bundleFileInfo; } function emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath) { - if (!(declarationFilePath && !ts.isInJSFile(sourceFileOrBundle))) { + if (!sourceFileOrBundle || !(declarationFilePath && !ts.isInJSFile(sourceFileOrBundle))) { return; } var sourceFiles = ts.isSourceFile(sourceFileOrBundle) ? [sourceFileOrBundle] : sourceFileOrBundle.sourceFiles; @@ -82556,6 +82890,8 @@ var ts; inlineSourceMap: compilerOptions.inlineSourceMap, extendedDiagnostics: compilerOptions.extendedDiagnostics, onlyPrintJsDocStyle: true, + writeBundleFileInfo: !!bundleBuildInfo, + recordInternalSection: !!bundleBuildInfo }; var declarationPrinter = createPrinter(printerOptions, { // resolver hooks @@ -82568,18 +82904,20 @@ var ts; emitSkipped = emitSkipped || declBlocked; if (!declBlocked || emitOnlyDtsFiles) { ts.Debug.assert(declarationTransform.transformed.length === 1, "Should only see one output from the decl transform"); - printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], /* bundleInfopath*/ undefined, declarationPrinter, { + printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], declarationPrinter, { sourceMap: compilerOptions.declarationMap, sourceRoot: compilerOptions.sourceRoot, mapRoot: compilerOptions.mapRoot, extendedDiagnostics: compilerOptions.extendedDiagnostics, }); - if (emitOnlyDtsFiles && declarationTransform.transformed[0].kind === 279 /* SourceFile */) { + if (emitOnlyDtsFiles && declarationTransform.transformed[0].kind === 284 /* SourceFile */) { var sourceFile = declarationTransform.transformed[0]; exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit; } } declarationTransform.dispose(); + if (bundleBuildInfo) + bundleBuildInfo.dts = declarationPrinter.bundleFileInfo; } function collectLinkedAliases(node) { if (ts.isExportAssignment(node)) { @@ -82594,16 +82932,16 @@ var ts; } ts.forEachChild(node, collectLinkedAliases); } - function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, bundleInfoPath, printer, mapOptions) { - var bundle = sourceFileOrBundle.kind === 280 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 279 /* SourceFile */ ? sourceFileOrBundle : undefined; + function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) { + var bundle = sourceFileOrBundle.kind === 285 /* Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 284 /* SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; var sourceMapGenerator; if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) { sourceMapGenerator = ts.createSourceMapGenerator(host, ts.getBaseFileName(ts.normalizeSlashes(jsFilePath)), getSourceRoot(mapOptions), getSourceMapDirectory(mapOptions, jsFilePath, sourceFile), mapOptions); } if (bundle) { - printer.writeBundle(bundle, bundleInfo, writer, sourceMapGenerator); + printer.writeBundle(bundle, writer, sourceMapGenerator); } else { printer.writeFile(sourceFile, writer, sourceMapGenerator); @@ -82632,18 +82970,12 @@ var ts; } // Write the output file ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles); - // Write bundled offset information if applicable - if (bundleInfoPath) { - bundleInfo.totalLength = writer.getTextPos(); - ts.writeFile(host, emitterDiagnostics, bundleInfoPath, JSON.stringify(bundleInfo, undefined, 2), /*writeByteOrderMark*/ false); - } // Reset state writer.clear(); - bundleInfo = createDefaultBundleInfo(); } function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) { return (mapOptions.sourceMap || mapOptions.inlineSourceMap) - && (sourceFileOrBundle.kind !== 279 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); + && (sourceFileOrBundle.kind !== 284 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); } function getSourceRoot(mapOptions) { // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the @@ -82700,6 +83032,161 @@ var ts; } } ts.emitFiles = emitFiles; + /*@internal*/ + function getBuildInfoText(buildInfo) { + return JSON.stringify(buildInfo, undefined, 2); + } + ts.getBuildInfoText = getBuildInfoText; + /*@internal*/ + ts.notImplementedResolver = { + hasGlobalName: ts.notImplemented, + getReferencedExportContainer: ts.notImplemented, + getReferencedImportDeclaration: ts.notImplemented, + getReferencedDeclarationWithCollidingName: ts.notImplemented, + isDeclarationWithCollidingName: ts.notImplemented, + isValueAliasDeclaration: ts.notImplemented, + isReferencedAliasDeclaration: ts.notImplemented, + isTopLevelValueImportEqualsWithEntityName: ts.notImplemented, + getNodeCheckFlags: ts.notImplemented, + isDeclarationVisible: ts.notImplemented, + isLateBound: function (_node) { return false; }, + collectLinkedAliases: ts.notImplemented, + isImplementationOfOverload: ts.notImplemented, + isRequiredInitializedParameter: ts.notImplemented, + isOptionalUninitializedParameterProperty: ts.notImplemented, + isExpandoFunctionDeclaration: ts.notImplemented, + getPropertiesOfContainerFunction: ts.notImplemented, + createTypeOfDeclaration: ts.notImplemented, + createReturnTypeOfSignatureDeclaration: ts.notImplemented, + createTypeOfExpression: ts.notImplemented, + createLiteralConstValue: ts.notImplemented, + isSymbolAccessible: ts.notImplemented, + isEntityNameVisible: ts.notImplemented, + // Returns the constant value this property access resolves to: notImplemented, or 'undefined' for a non-constant + getConstantValue: ts.notImplemented, + getReferencedValueDeclaration: ts.notImplemented, + getTypeReferenceSerializationKind: ts.notImplemented, + isOptionalParameter: ts.notImplemented, + moduleExportsSomeValue: ts.notImplemented, + isArgumentsLocalBinding: ts.notImplemented, + getExternalModuleFileFromDeclaration: ts.notImplemented, + getTypeReferenceDirectivesForEntityName: ts.notImplemented, + getTypeReferenceDirectivesForSymbol: ts.notImplemented, + isLiteralConstDeclaration: ts.notImplemented, + getJsxFactoryEntity: ts.notImplemented, + getAllAccessorDeclarations: ts.notImplemented, + getSymbolOfExternalModuleSpecifier: ts.notImplemented, + isBindingCapturedByNode: ts.notImplemented, + }; + function createSourceFilesFromBundleBuildInfo(bundle) { + var sourceFiles = bundle.sourceFiles.map(function (fileName) { + var sourceFile = ts.createNode(284 /* SourceFile */, 0, 0); + sourceFile.fileName = fileName; + sourceFile.text = ""; + sourceFile.statements = ts.createNodeArray(); + return sourceFile; + }); + var jsBundle = ts.Debug.assertDefined(bundle.js); + ts.forEach(jsBundle.sources && jsBundle.sources.prologues, function (prologueInfo) { + var sourceFile = sourceFiles[prologueInfo.file]; + sourceFile.text = prologueInfo.text; + sourceFile.end = prologueInfo.text.length; + sourceFile.statements = ts.createNodeArray(prologueInfo.directives.map(function (directive) { + var statement = ts.createNode(221 /* ExpressionStatement */, directive.pos, directive.end); + statement.expression = ts.createNode(10 /* StringLiteral */, directive.expression.pos, directive.expression.end); + statement.expression.text = directive.expression.text; + return statement; + })); + }); + return sourceFiles; + } + /*@internal*/ + function emitUsingBuildInfo(config, host, getCommandLine) { + var _a = getOutputPathsForBundle(config.options, /*forceDtsPaths*/ false), buildInfoPath = _a.buildInfoPath, jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath; + var buildInfoText = host.readFile(ts.Debug.assertDefined(buildInfoPath)); + if (!buildInfoText) + return buildInfoPath; + var jsFileText = host.readFile(ts.Debug.assertDefined(jsFilePath)); + if (!jsFileText) + return jsFilePath; + var sourceMapText = sourceMapFilePath && host.readFile(sourceMapFilePath); + // error if no source map or for now if inline sourcemap + if ((sourceMapFilePath && !sourceMapText) || config.options.inlineSourceMap) + return sourceMapFilePath || "inline sourcemap decoding"; + // read declaration text + var declarationText = declarationFilePath && host.readFile(declarationFilePath); + if (declarationFilePath && !declarationText) + return declarationFilePath; + var declarationMapText = declarationMapPath && host.readFile(declarationMapPath); + // error if no source map or for now if inline sourcemap + if ((declarationMapPath && !declarationMapText) || config.options.inlineSourceMap) + return declarationMapPath || "inline sourcemap decoding"; + var buildInfo = JSON.parse(buildInfoText); + if (!buildInfo.bundle || !buildInfo.bundle.js || (declarationText && !buildInfo.bundle.dts)) + return buildInfoPath; + var ownPrependInput = ts.createInputFiles(jsFileText, declarationText, sourceMapFilePath, sourceMapText, declarationMapPath, declarationMapText, jsFilePath, declarationFilePath, buildInfoPath, buildInfo, + /*onlyOwnText*/ true); + var outputFiles = []; + var prependNodes = ts.createPrependNodes(config.projectReferences, getCommandLine, function (f) { return host.readFile(f); }); + var sourceFilesForJsEmit = createSourceFilesFromBundleBuildInfo(buildInfo.bundle); + var emitHost = { + getPrependNodes: ts.memoize(function () { return prependNodes.concat([ownPrependInput]); }), + getCanonicalFileName: host.getCanonicalFileName, + getCommonSourceDirectory: function () { return buildInfo.bundle.commonSourceDirectory; }, + getCompilerOptions: function () { return config.options; }, + getCurrentDirectory: function () { return host.getCurrentDirectory(); }, + getNewLine: function () { return host.getNewLine(); }, + getSourceFile: function () { return undefined; }, + getSourceFileByPath: function () { return undefined; }, + getSourceFiles: function () { return sourceFilesForJsEmit; }, + getLibFileFromReference: ts.notImplemented, + isSourceFileFromExternalLibrary: ts.returnFalse, + writeFile: function (name, text, writeByteOrderMark) { + switch (name) { + case jsFilePath: + if (jsFileText === text) + return; + break; + case sourceMapFilePath: + if (sourceMapText === text) + return; + break; + case buildInfoPath: + var newBuildInfo = JSON.parse(text); + newBuildInfo.program = buildInfo.program; + // Update sourceFileInfo + var _a = buildInfo.bundle, js = _a.js, dts = _a.dts, sourceFiles = _a.sourceFiles; + newBuildInfo.bundle.js.sources = js.sources; + if (dts) { + newBuildInfo.bundle.dts.sources = dts.sources; + } + newBuildInfo.bundle.sourceFiles = sourceFiles; + outputFiles.push({ name: name, text: getBuildInfoText(newBuildInfo), writeByteOrderMark: writeByteOrderMark }); + return; + case declarationFilePath: + if (declarationText === text) + return; + break; + case declarationMapPath: + if (declarationMapText === text) + return; + break; + default: + ts.Debug.assertNever(name); + } + outputFiles.push({ name: name, text: text, writeByteOrderMark: writeByteOrderMark }); + }, + isEmitBlocked: ts.returnFalse, + readFile: function (f) { return host.readFile(f); }, + fileExists: function (f) { return host.fileExists(f); }, + directoryExists: host.directoryExists && (function (f) { return host.directoryExists(f); }), + useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, + getProgramBuildInfo: function () { return undefined; } + }; + emitFiles(ts.notImplementedResolver, emitHost, /*targetSourceFile*/ undefined, /*emitOnlyDtsFiles*/ false, ts.getTransformers(config.options)); + return outputFiles; + } + ts.emitUsingBuildInfo = emitUsingBuildInfo; var PipelinePhase; (function (PipelinePhase) { PipelinePhase[PipelinePhase["Notification"] = 0] = "Notification"; @@ -82728,6 +83215,10 @@ var ts; var ownWriter; // Reusable `EmitTextWriter` for basic printing. var write = writeBase; var isOwnFileEmit; + var bundleFileInfo = printerOptions.writeBundleFileInfo ? { sections: [] } : undefined; + var recordInternalSection = printerOptions.recordInternalSection; + var sourceFileTextPos = 0; + var sourceFileTextKind = "text" /* Text */; // Source Maps var sourceMapsDisabled = true; var sourceMapGenerator; @@ -82753,7 +83244,8 @@ var ts; writeNode: writeNode, writeList: writeList, writeFile: writeFile, - writeBundle: writeBundle + writeBundle: writeBundle, + bundleFileInfo: bundleFileInfo }; function printNode(hint, node, sourceFile) { switch (hint) { @@ -82768,9 +83260,9 @@ var ts; break; } switch (node.kind) { - case 279 /* SourceFile */: return printFile(node); - case 280 /* Bundle */: return printBundle(node); - case 281 /* UnparsedSource */: return printUnparsedSource(node); + case 284 /* SourceFile */: return printFile(node); + case 285 /* Bundle */: return printBundle(node); + case 286 /* UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -82780,7 +83272,7 @@ var ts; return endPrint(); } function printBundle(bundle) { - writeBundle(bundle, /*bundleInfo*/ undefined, beginPrint(), /*sourceMapEmitter*/ undefined); + writeBundle(bundle, beginPrint(), /*sourceMapEmitter*/ undefined); return endPrint(); } function printFile(sourceFile) { @@ -82808,7 +83300,49 @@ var ts; reset(); writer = previousWriter; } - function writeBundle(bundle, bundleInfo, output, sourceMapGenerator) { + function getTextPosWithWriteLine() { + return writer.getTextPosWithWriteLine ? writer.getTextPosWithWriteLine() : writer.getTextPos(); + } + function updateOrPushBundleFileTextLike(pos, end, kind) { + var last = ts.lastOrUndefined(bundleFileInfo.sections); + if (last && last.kind === kind) { + last.end = end; + } + else { + bundleFileInfo.sections.push({ pos: pos, end: end, kind: kind }); + } + } + function recordBundleFileInternalSectionStart(node) { + if (recordInternalSection && + bundleFileInfo && + currentSourceFile && + (ts.isDeclaration(node) || ts.isVariableStatement(node)) && + ts.isInternalDeclaration(node, currentSourceFile) && + sourceFileTextKind !== "internal" /* Internal */) { + var prevSourceFileTextKind = sourceFileTextKind; + recordBundleFileTextLikeSection(writer.getTextPos()); + sourceFileTextPos = getTextPosWithWriteLine(); + sourceFileTextKind = "internal" /* Internal */; + return prevSourceFileTextKind; + } + return undefined; + } + function recordBundleFileInternalSectionEnd(prevSourceFileTextKind) { + if (prevSourceFileTextKind) { + recordBundleFileTextLikeSection(writer.getTextPos()); + sourceFileTextPos = getTextPosWithWriteLine(); + sourceFileTextKind = prevSourceFileTextKind; + } + } + function recordBundleFileTextLikeSection(end) { + if (sourceFileTextPos < end) { + updateOrPushBundleFileTextLike(sourceFileTextPos, end, sourceFileTextKind); + return true; + } + return false; + } + function writeBundle(bundle, output, sourceMapGenerator) { + var _a; isOwnFileEmit = false; var previousWriter = writer; setWriter(output, sourceMapGenerator); @@ -82816,18 +83350,49 @@ var ts; emitPrologueDirectivesIfNeeded(bundle); emitHelpers(bundle); emitSyntheticTripleSlashReferencesIfNeeded(bundle); - for (var _a = 0, _b = bundle.prepends; _a < _b.length; _a++) { - var prepend = _b[_a]; + for (var _b = 0, _c = bundle.prepends; _b < _c.length; _b++) { + var prepend = _c[_b]; writeLine(); + var pos = writer.getTextPos(); + var savedSections = bundleFileInfo && bundleFileInfo.sections; + if (savedSections) + bundleFileInfo.sections = []; print(4 /* Unspecified */, prepend, /*sourceFile*/ undefined); + if (bundleFileInfo) { + var newSections = bundleFileInfo.sections; + bundleFileInfo.sections = savedSections; + if (prepend.oldFileOfCurrentEmit) + (_a = bundleFileInfo.sections).push.apply(_a, newSections); + else { + newSections.forEach(function (section) { return ts.Debug.assert(ts.isBundleFileTextLike(section)); }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prepend" /* Prepend */, data: prepend.fileName, texts: newSections }); + } + } } - if (bundleInfo) { - bundleInfo.originalOffset = writer.getTextPos(); - } - for (var _c = 0, _d = bundle.sourceFiles; _c < _d.length; _c++) { - var sourceFile = _d[_c]; + sourceFileTextPos = getTextPosWithWriteLine(); + for (var _d = 0, _e = bundle.sourceFiles; _d < _e.length; _d++) { + var sourceFile = _e[_d]; print(0 /* SourceFile */, sourceFile, sourceFile); } + if (bundleFileInfo && bundle.sourceFiles.length) { + var end = writer.getTextPos(); + if (recordBundleFileTextLikeSection(end)) { + // Store prologues + var prologues = getPrologueDirectivesFromBundledSourceFiles(bundle); + if (prologues) { + if (!bundleFileInfo.sources) + bundleFileInfo.sources = {}; + bundleFileInfo.sources.prologues = prologues; + } + // Store helpes + var helpers = getHelpersFromBundledSourceFiles(bundle); + if (helpers) { + if (!bundleFileInfo.sources) + bundleFileInfo.sources = {}; + bundleFileInfo.sources.helpers = helpers; + } + } + } reset(); writer = previousWriter; } @@ -82897,8 +83462,10 @@ var ts; function emit(node) { if (node === undefined) return; + var prevSourceFileTextKind = recordBundleFileInternalSectionStart(node); var pipelinePhase = getPipelinePhase(0 /* Notification */, node); pipelinePhase(4 /* Unspecified */, node); + recordBundleFileInternalSectionEnd(prevSourceFileTextKind); } function emitIdentifierName(node) { if (node === undefined) @@ -82925,12 +83492,12 @@ var ts; } // falls through case 2 /* Comments */: - if (!commentsDisabled && node.kind !== 279 /* SourceFile */) { + if (!commentsDisabled && node.kind !== 284 /* SourceFile */) { return pipelineEmitWithComments; } // falls through case 3 /* SourceMaps */: - if (!sourceMapsDisabled && node.kind !== 279 /* SourceFile */ && !ts.isInJsonFile(node)) { + if (!sourceMapsDisabled && node.kind !== 284 /* SourceFile */ && !ts.isInJsonFile(node)) { return pipelineEmitWithSourceMap; } // falls through @@ -82967,8 +83534,16 @@ var ts; case 16 /* TemplateMiddle */: case 17 /* TemplateTail */: return emitLiteral(node); - case 281 /* UnparsedSource */: - return emitUnparsedSource(node); + case 286 /* UnparsedSource */: + case 280 /* UnparsedPrepend */: + return emitUnparsedSourceOrPrepend(node); + case 279 /* UnparsedPrologue */: + return writeUnparsedNode(node); + case 281 /* UnparsedText */: + case 282 /* UnparsedInternalText */: + return emitUnparsedTextLike(node); + case 283 /* UnparsedSyntheticReference */: + return emitUnparsedSyntheticReference(node); // Identifiers case 72 /* Identifier */: return emitIdentifier(node); @@ -83012,7 +83587,7 @@ var ts; return emitTypeReference(node); case 165 /* FunctionType */: return emitFunctionType(node); - case 289 /* JSDocFunctionType */: + case 294 /* JSDocFunctionType */: return emitJSDocFunctionType(node); case 166 /* ConstructorType */: return emitConstructorType(node); @@ -83050,20 +83625,20 @@ var ts; return emitLiteralType(node); case 183 /* ImportType */: return emitImportTypeNode(node); - case 284 /* JSDocAllType */: + case 289 /* JSDocAllType */: writePunctuation("*"); return; - case 285 /* JSDocUnknownType */: + case 290 /* JSDocUnknownType */: writePunctuation("?"); return; - case 286 /* JSDocNullableType */: + case 291 /* JSDocNullableType */: return emitJSDocNullableType(node); - case 287 /* JSDocNonNullableType */: + case 292 /* JSDocNonNullableType */: return emitJSDocNonNullableType(node); - case 288 /* JSDocOptionalType */: + case 293 /* JSDocOptionalType */: return emitJSDocOptionalType(node); case 172 /* RestType */: - case 290 /* JSDocVariadicType */: + case 295 /* JSDocVariadicType */: return emitRestOrJSDocVariadicType(node); // Binding patterns case 184 /* ObjectBindingPattern */: @@ -83201,30 +83776,30 @@ var ts; case 278 /* EnumMember */: return emitEnumMember(node); // JSDoc nodes (only used in codefixes currently) - case 299 /* JSDocParameterTag */: - case 305 /* JSDocPropertyTag */: + case 304 /* JSDocParameterTag */: + case 310 /* JSDocPropertyTag */: return emitJSDocPropertyLikeTag(node); - case 300 /* JSDocReturnTag */: - case 302 /* JSDocTypeTag */: - case 301 /* JSDocThisTag */: - case 298 /* JSDocEnumTag */: + case 305 /* JSDocReturnTag */: + case 307 /* JSDocTypeTag */: + case 306 /* JSDocThisTag */: + case 303 /* JSDocEnumTag */: return emitJSDocSimpleTypedTag(node); - case 295 /* JSDocAugmentsTag */: + case 300 /* JSDocAugmentsTag */: return emitJSDocAugmentsTag(node); - case 303 /* JSDocTemplateTag */: + case 308 /* JSDocTemplateTag */: return emitJSDocTemplateTag(node); - case 304 /* JSDocTypedefTag */: + case 309 /* JSDocTypedefTag */: return emitJSDocTypedefTag(node); - case 297 /* JSDocCallbackTag */: + case 302 /* JSDocCallbackTag */: return emitJSDocCallbackTag(node); - case 293 /* JSDocSignature */: + case 298 /* JSDocSignature */: return emitJSDocSignature(node); - case 292 /* JSDocTypeLiteral */: + case 297 /* JSDocTypeLiteral */: return emitJSDocTypeLiteral(node); - case 296 /* JSDocClassTag */: - case 294 /* JSDocTag */: + case 301 /* JSDocClassTag */: + case 299 /* JSDocTag */: return emitJSDocSimpleTag(node); - case 291 /* JSDocComment */: + case 296 /* JSDocComment */: return emitJSDoc(node); // Transformation nodes (ignored) } @@ -83323,9 +83898,9 @@ var ts; case 264 /* JsxFragment */: return emitJsxFragment(node); // Transformation nodes - case 308 /* PartiallyEmittedExpression */: + case 313 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 309 /* CommaListExpression */: + case 314 /* CommaListExpression */: return emitCommaList(node); } } @@ -83341,22 +83916,45 @@ var ts; var pipelinePhase = getNextPipelinePhase(1 /* Substitution */, node); pipelinePhase(hint, substituteNode(hint, node)); } + function getHelpersFromBundledSourceFiles(bundle) { + var result; + if (moduleKind === ts.ModuleKind.None || printerOptions.noEmitHelpers) { + return undefined; + } + var bundledHelpers = ts.createMap(); + for (var _a = 0, _b = bundle.sourceFiles; _a < _b.length; _a++) { + var sourceFile = _b[_a]; + var shouldSkip = ts.getExternalHelpersModuleName(sourceFile) !== undefined; + var helpers = getSortedEmitHelpers(sourceFile); + if (!helpers) + continue; + for (var _c = 0, helpers_3 = helpers; _c < helpers_3.length; _c++) { + var helper = helpers_3[_c]; + if (!helper.scoped && !shouldSkip && !bundledHelpers.get(helper.name)) { + bundledHelpers.set(helper.name, true); + (result || (result = [])).push(helper.name); + } + } + } + return result; + } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 280 /* Bundle */ ? node : undefined; + var bundle = node.kind === 285 /* Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } - var numNodes = bundle ? bundle.sourceFiles.length : 1; + var numPrepends = bundle ? bundle.prepends.length : 0; + var numNodes = bundle ? bundle.sourceFiles.length + numPrepends : 1; for (var i = 0; i < numNodes; i++) { - var currentNode = bundle ? bundle.sourceFiles[i] : node; - var sourceFile = ts.isSourceFile(currentNode) ? currentNode : currentSourceFile; - var shouldSkip = printerOptions.noEmitHelpers || ts.getExternalHelpersModuleName(sourceFile) !== undefined; - var shouldBundle = ts.isSourceFile(currentNode) && !isOwnFileEmit; - var helpers = ts.getEmitHelpers(currentNode); + var currentNode = bundle ? i < numPrepends ? bundle.prepends[i] : bundle.sourceFiles[i - numPrepends] : node; + var sourceFile = ts.isSourceFile(currentNode) ? currentNode : ts.isUnparsedSource(currentNode) ? undefined : currentSourceFile; + var shouldSkip = printerOptions.noEmitHelpers || (!!sourceFile && ts.getExternalHelpersModuleName(sourceFile) !== undefined); + var shouldBundle = (ts.isSourceFile(currentNode) || ts.isUnparsedSource(currentNode)) && !isOwnFileEmit; + var helpers = ts.isUnparsedSource(currentNode) ? currentNode.helpers : getSortedEmitHelpers(currentNode); if (helpers) { - for (var _a = 0, _b = ts.stableSort(helpers, ts.compareEmitHelpers); _a < _b.length; _a++) { - var helper = _b[_a]; + for (var _a = 0, helpers_4 = helpers; _a < helpers_4.length; _a++) { + var helper = helpers_4[_a]; if (!helper.scoped) { // Skip the helper if it can be skipped and the noEmitHelpers compiler // option is set, or if it can be imported and the importHelpers compiler @@ -83376,18 +83974,25 @@ var ts; // Skip the helper if it is scoped and we are emitting bundled helpers continue; } + var pos = getTextPosWithWriteLine(); if (typeof helper.text === "string") { writeLines(helper.text); } else { writeLines(helper.text(makeFileLevelOptimisticUniqueName)); } + if (bundleFileInfo) + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "emitHelpers" /* EmitHelpers */, data: helper.name }); helpersEmitted = true; } } } return helpersEmitted; } + function getSortedEmitHelpers(node) { + var helpers = ts.getEmitHelpers(node); + return helpers && ts.stableSort(helpers, ts.compareEmitHelpers); + } // // Literals/Pseudo-literals // @@ -83414,8 +84019,42 @@ var ts; } } // SyntaxKind.UnparsedSource - function emitUnparsedSource(unparsed) { - writer.rawWrite(unparsed.text); + // SyntaxKind.UnparsedPrepend + function emitUnparsedSourceOrPrepend(unparsed) { + for (var _a = 0, _b = unparsed.texts; _a < _b.length; _a++) { + var text = _b[_a]; + writeLine(); + emit(text); + } + } + // SyntaxKind.UnparsedPrologue + // SyntaxKind.UnparsedText + // SyntaxKind.UnparsedInternal + // SyntaxKind.UnparsedSyntheticReference + function writeUnparsedNode(unparsed) { + writer.rawWrite(unparsed.parent.text.substring(unparsed.pos, unparsed.end)); + } + // SyntaxKind.UnparsedText + // SyntaxKind.UnparsedInternal + function emitUnparsedTextLike(unparsed) { + var pos = getTextPosWithWriteLine(); + writeUnparsedNode(unparsed); + if (bundleFileInfo) { + updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 281 /* UnparsedText */ ? + "text" /* Text */ : + "internal" /* Internal */); + } + } + // SyntaxKind.UnparsedSyntheticReference + function emitUnparsedSyntheticReference(unparsed) { + var pos = getTextPosWithWriteLine(); + writeUnparsedNode(unparsed); + if (bundleFileInfo) { + var section = ts.clone(unparsed.section); + section.pos = pos; + section.end = writer.getTextPos(); + bundleFileInfo.sections.push(section); + } } // // Identifiers @@ -83470,7 +84109,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 289 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 294 /* JSDocFunctionType */ && !node.name) { emit(node.type); } else { @@ -84350,7 +84989,7 @@ var ts; } function emitBlockFunctionBodyWorker(body, emitBlockFunctionBodyOnSingleLine) { // Emit all the prologue directives (like "use strict"). - var statementOffset = emitPrologueDirectives(body.statements, /*startWithNewLine*/ true); + var statementOffset = emitPrologueDirectives(body.statements); var pos = writer.getTextPos(); emitHelpers(body); if (statementOffset === 0 && pos === writer.getTextPos() && emitBlockFunctionBodyOnSingleLine) { @@ -84755,7 +85394,7 @@ var ts; } } if (node.tags) { - if (node.tags.length === 1 && node.tags[0].kind === 302 /* JSDocTypeTag */ && !node.comment) { + if (node.tags.length === 1 && node.tags[0].kind === 307 /* JSDocTypeTag */ && !node.comment) { writeSpace(); emit(node.tags[0]); } @@ -84789,7 +85428,7 @@ var ts; function emitJSDocTypedefTag(tag) { emitJSDocTagName(tag.tagName); if (tag.typeExpression) { - if (tag.typeExpression.kind === 283 /* JSDocTypeExpression */) { + if (tag.typeExpression.kind === 288 /* JSDocTypeExpression */) { emitJSDocTypeExpression(tag.typeExpression); } else { @@ -84808,7 +85447,7 @@ var ts; emit(tag.fullName); } emitJSDocComment(tag.comment); - if (tag.typeExpression && tag.typeExpression.kind === 292 /* JSDocTypeLiteral */) { + if (tag.typeExpression && tag.typeExpression.kind === 297 /* JSDocTypeLiteral */) { emitJSDocTypeLiteral(tag.typeExpression); } } @@ -84895,6 +85534,16 @@ var ts; } function emitSyntheticTripleSlashReferencesIfNeeded(node) { emitTripleSlashDirectives(!!node.hasNoDefaultLib, node.syntheticFileReferences || [], node.syntheticTypeReferences || [], node.syntheticLibReferences || []); + for (var _a = 0, _b = node.prepends; _a < _b.length; _a++) { + var prepend = _b[_a]; + if (ts.isUnparsedSource(prepend) && prepend.syntheticReferences) { + for (var _c = 0, _d = prepend.syntheticReferences; _c < _d.length; _c++) { + var ref = _d[_c]; + emit(ref); + writeLine(); + } + } + } } function emitTripleSlashDirectivesIfNeeded(node) { if (node.isDeclarationFile) @@ -84902,7 +85551,10 @@ var ts; } function emitTripleSlashDirectives(hasNoDefaultLib, files, types, libs) { if (hasNoDefaultLib) { + var pos = writer.getTextPos(); writeComment("/// "); + if (bundleFileInfo) + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "no-default-lib" /* NoDefaultLib */ }); writeLine(); } if (currentSourceFile && currentSourceFile.moduleName) { @@ -84923,17 +85575,26 @@ var ts; } for (var _c = 0, files_1 = files; _c < files_1.length; _c++) { var directive = files_1[_c]; + var pos = writer.getTextPos(); writeComment("/// "); + if (bundleFileInfo) + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference" /* Reference */, data: directive.fileName }); writeLine(); } for (var _d = 0, types_19 = types; _d < types_19.length; _d++) { var directive = types_19[_d]; + var pos = writer.getTextPos(); writeComment("/// "); + if (bundleFileInfo) + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "type" /* Type */, data: directive.fileName }); writeLine(); } for (var _e = 0, libs_1 = libs; _e < libs_1.length; _e++) { var directive = libs_1[_e]; + var pos = writer.getTextPos(); writeComment("/// "); + if (bundleFileInfo) + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "lib" /* Lib */, data: directive.fileName }); writeLine(); } } @@ -84958,16 +85619,22 @@ var ts; * Emits any prologue directives at the start of a Statement list, returning the * number of prologue directives written to the output. */ - function emitPrologueDirectives(statements, startWithNewLine, seenPrologueDirectives) { + function emitPrologueDirectives(statements, sourceFile, seenPrologueDirectives) { + var needsToSetSourceFile = !!sourceFile; for (var i = 0; i < statements.length; i++) { var statement = statements[i]; if (ts.isPrologueDirective(statement)) { var shouldEmitPrologueDirective = seenPrologueDirectives ? !seenPrologueDirectives.has(statement.expression.text) : true; if (shouldEmitPrologueDirective) { - if (startWithNewLine || i > 0) { - writeLine(); + if (needsToSetSourceFile) { + needsToSetSourceFile = false; + setSourceFile(sourceFile); } + writeLine(); + var pos = writer.getTextPos(); emit(statement); + if (bundleFileInfo) + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* Prologue */, data: statement.expression.text }); if (seenPrologueDirectives) { seenPrologueDirectives.set(statement.expression.text, true); } @@ -84980,23 +85647,70 @@ var ts; } return statements.length; } + function emitUnparsedPrologues(prologues, seenPrologueDirectives) { + for (var _a = 0, prologues_1 = prologues; _a < prologues_1.length; _a++) { + var prologue = prologues_1[_a]; + if (!seenPrologueDirectives.has(prologue.data)) { + writeLine(); + var pos = writer.getTextPos(); + emit(prologue); + if (bundleFileInfo) + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* Prologue */, data: prologue.data }); + if (seenPrologueDirectives) { + seenPrologueDirectives.set(prologue.data, true); + } + } + } + } function emitPrologueDirectivesIfNeeded(sourceFileOrBundle) { if (ts.isSourceFile(sourceFileOrBundle)) { - setSourceFile(sourceFileOrBundle); - emitPrologueDirectives(sourceFileOrBundle.statements); + emitPrologueDirectives(sourceFileOrBundle.statements, sourceFileOrBundle); } else { var seenPrologueDirectives = ts.createMap(); - for (var _a = 0, _b = sourceFileOrBundle.sourceFiles; _a < _b.length; _a++) { - var sourceFile = _b[_a]; - setSourceFile(sourceFile); - emitPrologueDirectives(sourceFile.statements, /*startWithNewLine*/ true, seenPrologueDirectives); + for (var _a = 0, _b = sourceFileOrBundle.prepends; _a < _b.length; _a++) { + var prepend = _b[_a]; + emitUnparsedPrologues(prepend.prologues, seenPrologueDirectives); + } + for (var _c = 0, _d = sourceFileOrBundle.sourceFiles; _c < _d.length; _c++) { + var sourceFile = _d[_c]; + emitPrologueDirectives(sourceFile.statements, sourceFile, seenPrologueDirectives); } setSourceFile(undefined); } } + function getPrologueDirectivesFromBundledSourceFiles(bundle) { + var seenPrologueDirectives = ts.createMap(); + var prologues; + for (var index = 0; index < bundle.sourceFiles.length; index++) { + var sourceFile = bundle.sourceFiles[index]; + var directives = void 0; + var end = 0; + for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { + var statement = _b[_a]; + if (!ts.isPrologueDirective(statement)) + break; + if (seenPrologueDirectives.has(statement.expression.text)) + continue; + seenPrologueDirectives.set(statement.expression.text, true); + (directives || (directives = [])).push({ + pos: statement.pos, + end: statement.end, + expression: { + pos: statement.expression.pos, + end: statement.expression.end, + text: statement.expression.text + } + }); + end = end < statement.end ? statement.end : end; + } + if (directives) + (prologues || (prologues = [])).push({ file: index, text: sourceFile.text.substring(0, end), directives: directives }); + } + return prologues; + } function emitShebangIfNeeded(sourceFileOrBundle) { - if (ts.isSourceFile(sourceFileOrBundle)) { + if (ts.isSourceFile(sourceFileOrBundle) || ts.isUnparsedSource(sourceFileOrBundle)) { var shebang = ts.getShebang(sourceFileOrBundle.text); if (shebang) { writeComment(shebang); @@ -85005,11 +85719,18 @@ var ts; } } else { - for (var _a = 0, _b = sourceFileOrBundle.sourceFiles; _a < _b.length; _a++) { - var sourceFile = _b[_a]; + for (var _a = 0, _b = sourceFileOrBundle.prepends; _a < _b.length; _a++) { + var prepend = _b[_a]; + ts.Debug.assertNode(prepend, ts.isUnparsedSource); + if (emitShebangIfNeeded(prepend)) { + return true; + } + } + for (var _c = 0, _d = sourceFileOrBundle.sourceFiles; _c < _d.length; _c++) { + var sourceFile = _d[_c]; // Emit only the first encountered shebang if (emitShebangIfNeeded(sourceFile)) { - break; + return true; } } } @@ -85212,6 +85933,7 @@ var ts; } // Emit each child. var previousSibling = void 0; + var previousSourceFileTextKind = void 0; var shouldDecreaseIndentAfterEmit = false; for (var i = 0; i < count; i++) { var child = children[start + i]; @@ -85232,6 +85954,7 @@ var ts; emitLeadingCommentsOfPosition(previousSibling.end); } writeDelimiter(format); + recordBundleFileInternalSectionEnd(previousSourceFileTextKind); // Write either a line terminator or whitespace to separate the elements. if (shouldWriteSeparatingLineTerminator(previousSibling, child, format)) { // If a synthesized node in a single-line list starts on a new @@ -85248,6 +85971,7 @@ var ts; } } // Emit this child. + previousSourceFileTextKind = recordBundleFileInternalSectionStart(child); if (shouldEmitInterveningComments) { if (emitTrailingCommentsOfPosition) { var commentRange = ts.getCommentRange(child); @@ -85282,6 +86006,7 @@ var ts; if (format & 128 /* Indented */) { decreaseIndent(); } + recordBundleFileInternalSectionEnd(previousSourceFileTextKind); // Write the closing line terminator or closing whitespace. if (shouldWriteClosingLineTerminator(parentNode, children, format)) { writeLine(); @@ -85383,7 +86108,6 @@ var ts; if (line.length) { writeLine(); write(line); - writer.rawWrite(newLine); } } } @@ -85897,7 +86621,7 @@ var ts; hasWrittenComment = false; var emitFlags = ts.getEmitFlags(node); var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end; - var isEmittedNode = node.kind !== 307 /* NotEmittedStatement */; + var isEmittedNode = node.kind !== 312 /* NotEmittedStatement */; // We have to explicitly check that the node is JsxText because if the compilerOptions.jsx is "preserve" we will not do any transformation. // It is expensive to walk entire tree just to set one kind of node to have no comments. var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0 || node.kind === 11 /* JsxText */; @@ -86157,19 +86881,28 @@ var ts; return ts.isRecognizedTripleSlashComment(currentSourceFile.text, commentPos, commentEnd); } // Source Maps + function getParsedSourceMap(node) { + if (node.parsedSourceMap === undefined && node.sourceMapText !== undefined) { + node.parsedSourceMap = ts.tryParseRawSourceMap(node.sourceMapText) || false; + } + return node.parsedSourceMap || undefined; + } function pipelineEmitWithSourceMap(hint, node) { var pipelinePhase = getNextPipelinePhase(3 /* SourceMaps */, node); - if (ts.isUnparsedSource(node) && node.sourceMapText !== undefined) { - var parsed = ts.tryParseRawSourceMap(node.sourceMapText); - if (parsed) { - sourceMapGenerator.appendSourceMap(writer.getLine(), writer.getColumn(), parsed, node.sourceMapPath); + if (ts.isUnparsedSource(node) || ts.isUnparsedPrepend(node)) { + pipelinePhase(hint, node); + } + else if (ts.isUnparsedNode(node)) { + var parsed = getParsedSourceMap(node.parent); + if (parsed && sourceMapGenerator) { + sourceMapGenerator.appendSourceMap(writer.getLine(), writer.getColumn(), parsed, node.parent.sourceMapPath, node.parent.getLineAndCharacterOfPosition(node.pos), node.parent.getLineAndCharacterOfPosition(node.end)); } pipelinePhase(hint, node); } else { var _a = ts.getSourceMapRange(node), pos = _a.pos, end = _a.end, _b = _a.source, source = _b === void 0 ? sourceMapSource : _b; var emitFlags = ts.getEmitFlags(node); - if (node.kind !== 307 /* NotEmittedStatement */ + if (node.kind !== 312 /* NotEmittedStatement */ && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 && pos >= 0) { emitSourcePos(source, skipSourceTrivia(source, pos)); @@ -86182,7 +86915,7 @@ var ts; else { pipelinePhase(hint, node); } - if (node.kind !== 307 /* NotEmittedStatement */ + if (node.kind !== 312 /* NotEmittedStatement */ && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 && end >= 0) { emitSourcePos(source, end); @@ -86830,7 +87563,8 @@ var ts; var value = readFileCache.get(key); if (value !== undefined) return value !== false ? value : undefined; // could be .d.ts from output - if (!ts.fileExtensionIs(fileName, ".json" /* Json */)) { + // Cache json or buildInfo + if (!ts.fileExtensionIs(fileName, ".json" /* Json */) && !ts.isBuildInfoFile(fileName)) { return originalReadFile.call(host, fileName); } return setReadFileCache(key, fileName); @@ -86861,7 +87595,7 @@ var ts; var key = toPath(fileName); fileExistsCache.delete(key); var value = readFileCache.get(key); - if (value && value !== data) { + if (value !== undefined && value !== data) { readFileCache.delete(key); sourceFileCache.delete(key); } @@ -87416,7 +88150,8 @@ var ts; getProjectReferenceRedirect: getProjectReferenceRedirect, getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, getResolvedProjectReferenceByPath: getResolvedProjectReferenceByPath, - forEachResolvedProjectReference: forEachResolvedProjectReference + forEachResolvedProjectReference: forEachResolvedProjectReference, + emitBuildInfo: emitBuildInfo }; verifyCompilerOptions(); ts.performance.mark("afterProgram"); @@ -87843,7 +88578,20 @@ var ts; return false; // Before falling back to the host return host.fileExists(f); - } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {}), { useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); } }); + } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {}), { useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, getProgramBuildInfo: function () { return program.getProgramBuildInfo && program.getProgramBuildInfo(); } }); + } + function emitBuildInfo(writeFileCallback) { + ts.Debug.assert(!options.out && !options.outFile); + ts.performance.mark("beforeEmit"); + var emitResult = ts.emitFiles(ts.notImplementedResolver, getEmitHost(writeFileCallback), + /*targetSourceFile*/ undefined, + /*emitOnlyDtsFiles*/ false, + /*transformers*/ undefined, + /*declaraitonTransformers*/ undefined, + /*onlyBuildInfo*/ true); + ts.performance.mark("afterEmit"); + ts.performance.measure("Emit", "beforeEmit", "afterEmit"); + return emitResult; } function getResolvedProjectReferences() { return resolvedProjectReferences; @@ -87852,28 +88600,11 @@ var ts; return projectReferences; } function getPrependNodes() { - if (!projectReferences) { - return ts.emptyArray; - } - var nodes = []; - for (var i = 0; i < projectReferences.length; i++) { - var ref = projectReferences[i]; - var resolvedRefOpts = resolvedProjectReferences[i].commandLine; - if (ref.prepend && resolvedRefOpts && resolvedRefOpts.options) { - var out = resolvedRefOpts.options.outFile || resolvedRefOpts.options.out; - // Upstream project didn't have outFile set -- skip (error will have been issued earlier) - if (!out) - continue; - var _a = ts.getOutputPathsForBundle(resolvedRefOpts.options, /*forceDtsPaths*/ true), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath; - var node = ts.createInputFiles(function (fileName) { - var path = toPath(fileName); - var sourceFile = getSourceFileByPath(path); - return sourceFile ? sourceFile.text : filesByName.has(path) ? undefined : host.readFile(path); - }, jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath); - nodes.push(node); - } - } - return nodes; + return createPrependNodes(projectReferences, function (_ref, index) { return resolvedProjectReferences[index].commandLine; }, function (fileName) { + var path = toPath(fileName); + var sourceFile = getSourceFileByPath(path); + return sourceFile ? sourceFile.text : filesByName.has(path) ? undefined : host.readFile(path); + }); } function isSourceFileFromExternalLibrary(file) { return !!sourceFilesFoundSearchingNodeModules.get(file.path); @@ -87945,8 +88676,7 @@ var ts; var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile, cancellationToken); ts.performance.mark("beforeEmit"); var transformers = emitOnlyDtsFiles ? [] : ts.getTransformers(options, customTransformers); - var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, // TODO: GH#18217 - emitOnlyDtsFiles, transformers, customTransformers && customTransformers.afterDeclarations); + var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, emitOnlyDtsFiles, transformers, customTransformers && customTransformers.afterDeclarations); ts.performance.mark("afterEmit"); ts.performance.measure("Emit", "beforeEmit", "afterEmit"); return emitResult; @@ -88948,6 +89678,14 @@ var ts; if (options.declaration === false) { createDiagnosticForOptionName(ts.Diagnostics.Composite_projects_may_not_disable_declaration_emit, "declaration"); } + if (options.incremental === false) { + createDiagnosticForOptionName(ts.Diagnostics.Composite_projects_may_not_disable_incremental_compilation, "declaration"); + } + } + if (options.tsBuildInfoFile) { + if (!ts.isIncrementalCompilation(options)) { + createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "tsBuildInfoFile", "incremental", "composite"); + } } verifyProjectReferences(); // List of collected files is complete; validate exhautiveness if this is a project with a file list @@ -89142,6 +89880,7 @@ var ts; } } function verifyProjectReferences() { + var buildInfoPath = !options.noEmit && !options.suppressOutputPathCheck ? ts.getOutputPathForBuildInfo(options) : undefined; forEachProjectReference(projectReferences, resolvedProjectReferences, function (resolvedRef, index, parent) { var ref = (parent ? parent.commandLine.projectReferences : projectReferences)[index]; var parentFile = parent && parent.sourceFile; @@ -89168,6 +89907,10 @@ var ts; createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_prepend_project_0_because_it_does_not_have_outFile_set, ref.path); } } + if (!parent && buildInfoPath && buildInfoPath === ts.getOutputPathForBuildInfo(options)) { + createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_write_file_0_because_it_will_overwrite_tsbuildinfo_file_generated_by_referenced_project_1, buildInfoPath, ref.path); + hasEmitBlockingDiagnostics.set(toPath(buildInfoPath), true); + } }); } function createDiagnosticForOptionPathKeyValue(key, valueIndex, message, arg0, arg1, arg2) { @@ -89317,6 +90060,27 @@ var ts; }; } ts.parseConfigHostFromCompilerHostLike = parseConfigHostFromCompilerHostLike; + /* @internal */ + function createPrependNodes(projectReferences, getCommandLine, readFile) { + if (!projectReferences) + return ts.emptyArray; + var nodes; + for (var i = 0; i < projectReferences.length; i++) { + var ref = projectReferences[i]; + var resolvedRefOpts = getCommandLine(ref, i); + if (ref.prepend && resolvedRefOpts && resolvedRefOpts.options) { + var out = resolvedRefOpts.options.outFile || resolvedRefOpts.options.out; + // Upstream project didn't have outFile set -- skip (error will have been issued earlier) + if (!out) + continue; + var _a = ts.getOutputPathsForBundle(resolvedRefOpts.options, /*forceDtsPaths*/ true), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath; + var node = ts.createInputFiles(readFile, jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, buildInfoPath); + (nodes || (nodes = [])).push(node); + } + } + return nodes || ts.emptyArray; + } + ts.createPrependNodes = createPrependNodes; function resolveProjectReferencePath(hostOrRef, ref) { var passedInRef = ref ? ref : hostOrRef; return ts.resolveConfigFileProjectName(passedInRef.path); @@ -89860,11 +90624,14 @@ var ts; var affectedSignatures = oldState.currentAffectedFilesSignatures; ts.Debug.assert(!oldState.affectedFiles && (!affectedSignatures || !affectedSignatures.size), "Cannot reuse if only few affected files of currentChangedFile were iterated"); } + var changedFilesSet = oldState.changedFilesSet; if (canCopySemanticDiagnostics) { - ts.Debug.assert(!ts.forEachKey(oldState.changedFilesSet, function (path) { return oldState.semanticDiagnosticsPerFile.has(path); }), "Semantic diagnostics shouldnt be available for changed files"); + ts.Debug.assert(!changedFilesSet || !ts.forEachKey(changedFilesSet, function (path) { return oldState.semanticDiagnosticsPerFile.has(path); }), "Semantic diagnostics shouldnt be available for changed files"); } // Copy old state's changed files set - ts.copyEntries(oldState.changedFilesSet, state.changedFilesSet); + if (changedFilesSet) { + ts.copyEntries(changedFilesSet, state.changedFilesSet); + } if (!compilerOptions.outFile && !compilerOptions.out && oldState.affectedFilesPendingEmit) { state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit; state.affectedFilesPendingEmitIndex = oldState.affectedFilesPendingEmitIndex; @@ -89910,6 +90677,18 @@ var ts; } } }); + if (oldCompilerOptions && + (oldCompilerOptions.outDir !== compilerOptions.outDir || + oldCompilerOptions.declarationDir !== compilerOptions.declarationDir || + (oldCompilerOptions.outFile || oldCompilerOptions.out) !== (compilerOptions.outFile || compilerOptions.out))) { + // Add all files to affectedFilesPendingEmit since emit changed + state.affectedFilesPendingEmit = ts.concatenate(state.affectedFilesPendingEmit, newProgram.getSourceFiles().map(function (f) { return f.path; })); + if (state.affectedFilesPendingEmitIndex === undefined) { + state.affectedFilesPendingEmitIndex = 0; + } + ts.Debug.assert(state.seenAffectedFiles === undefined); + state.seenAffectedFiles = ts.createMap(); + } return state; } /** @@ -90131,8 +90910,11 @@ var ts; * This is called after completing operation on the next affected file. * The operations here are postponed to ensure that cancellation during the iteration is handled correctly */ - function doneWithAffectedFile(state, affected, isPendingEmit) { - if (affected === state.program) { + function doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit) { + if (isBuildInfoEmit) { + state.emittedBuildInfo = true; + } + else if (affected === state.program) { state.changedFilesSet.clear(); state.programEmitComplete = true; } @@ -90149,8 +90931,8 @@ var ts; /** * Returns the result with affected file */ - function toAffectedFileResult(state, result, affected, isPendingEmit) { - doneWithAffectedFile(state, affected, isPendingEmit); + function toAffectedFileResult(state, result, affected, isPendingEmit, isBuildInfoEmit) { + doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit); return { result: result, affected: affected }; } /** @@ -90173,6 +90955,46 @@ var ts; } return diagnostics; } + /** + * Gets the program information to be emitted in buildInfo so that we can use it to create new program + */ + function getProgramBuildInfo(state) { + if (state.compilerOptions.outFile || state.compilerOptions.out) + return undefined; + var fileInfos = {}; + state.fileInfos.forEach(function (value, key) { + var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key); + fileInfos[key] = signature === undefined ? value : { version: value.version, signature: signature }; + }); + var result = { fileInfos: fileInfos, options: state.compilerOptions }; + if (state.referencedMap) { + var referencedMap_1 = {}; + state.referencedMap.forEach(function (value, key) { + referencedMap_1[key] = ts.arrayFrom(value.keys()); + }); + result.referencedMap = referencedMap_1; + } + if (state.exportedModulesMap) { + var exportedModulesMap_1 = {}; + state.exportedModulesMap.forEach(function (value, key) { + var newValue = state.currentAffectedFilesExportedModulesMap && state.currentAffectedFilesExportedModulesMap.get(key); + // Not in temporary cache, use existing value + if (newValue === undefined) + exportedModulesMap_1[key] = ts.arrayFrom(value.keys()); + // Value in cache and has updated value map, use that + else if (newValue) + exportedModulesMap_1[key] = ts.arrayFrom(newValue.keys()); + }); + result.exportedModulesMap = exportedModulesMap_1; + } + if (state.semanticDiagnosticsPerFile) { + var semanticDiagnosticsPerFile_1 = []; + // Currently not recording actual errors since those mean no emit for tsc --build + state.semanticDiagnosticsPerFile.forEach(function (_value, key) { return semanticDiagnosticsPerFile_1.push(key); }); + result.semanticDiagnosticsPerFile = semanticDiagnosticsPerFile_1; + } + return result; + } var BuilderProgramKind; (function (BuilderProgramKind) { BuilderProgramKind[BuilderProgramKind["SemanticDiagnosticsBuilderProgram"] = 0] = "SemanticDiagnosticsBuilderProgram"; @@ -90229,6 +91051,7 @@ var ts; var computeHash = host.createHash || ts.generateDjb2Hash; var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState); var backupState; + newProgram.getProgramBuildInfo = function () { return result.getProgramBuildInfo(); }; // To ensure that we arent storing any references to old program or new program without state newProgram = undefined; // TODO: GH#18217 oldProgram = undefined; @@ -90250,6 +91073,7 @@ var ts; releaseCache(state); backupState = undefined; }; + result.getProgramBuildInfo = function () { return getProgramBuildInfo(state); }; if (kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram) { result.getSemanticDiagnosticsOfNextAffectedFile = getSemanticDiagnosticsOfNextAffectedFile; } @@ -90272,7 +91096,16 @@ var ts; if (!state.compilerOptions.out && !state.compilerOptions.outFile) { affected = getNextAffectedFilePendingEmit(state); if (!affected) { - return undefined; + if (state.emittedBuildInfo) { + return undefined; + } + var affected_1 = ts.Debug.assertDefined(state.program); + return toAffectedFileResult(state, + // When whole program is affected, do emit only once (eg when --out or --outFile is specified) + // Otherwise just affected file + affected_1.emitBuildInfo(writeFile || host.writeFile, cancellationToken), affected_1, + /*isPendingEmitFile*/ false, + /*isBuildInfoEmit*/ true); } isPendingEmitFile = true; } @@ -90405,6 +91238,53 @@ var ts; } } ts.createBuilderProgram = createBuilderProgram; + function getMapOfReferencedSet(mapLike) { + if (!mapLike) + return undefined; + var map = ts.createMap(); + // Copies keys/values from template. Note that for..in will not throw if + // template is undefined, and instead will just exit the loop. + for (var key in mapLike) { + if (ts.hasProperty(mapLike, key)) { + map.set(key, ts.arrayToSet(mapLike[key])); + } + } + return map; + } + function createBuildProgramUsingProgramBuildInfo(program) { + var fileInfos = ts.createMapFromTemplate(program.fileInfos); + var state = { + fileInfos: fileInfos, + compilerOptions: program.options, + referencedMap: getMapOfReferencedSet(program.referencedMap), + exportedModulesMap: getMapOfReferencedSet(program.exportedModulesMap), + semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && ts.arrayToMap(program.semanticDiagnosticsPerFile, ts.identity, function () { return ts.emptyArray; }) + }; + return { + getState: function () { return state; }, + backupState: ts.noop, + restoreState: ts.noop, + getProgram: ts.notImplemented, + getProgramOrUndefined: function () { return undefined; }, + releaseProgram: ts.noop, + getCompilerOptions: function () { return state.compilerOptions; }, + getSourceFile: ts.notImplemented, + getSourceFiles: ts.notImplemented, + getOptionsDiagnostics: ts.notImplemented, + getGlobalDiagnostics: ts.notImplemented, + getConfigFileParsingDiagnostics: ts.notImplemented, + getSyntacticDiagnostics: ts.notImplemented, + getDeclarationDiagnostics: ts.notImplemented, + getSemanticDiagnostics: ts.notImplemented, + emit: ts.notImplemented, + getAllDependencies: ts.notImplemented, + getCurrentDirectory: ts.notImplemented, + emitNextAffectedFile: ts.notImplemented, + getSemanticDiagnosticsOfNextAffectedFile: ts.notImplemented, + getProgramBuildInfo: ts.notImplemented + }; + } + ts.createBuildProgramUsingProgramBuildInfo = createBuildProgramUsingProgramBuildInfo; function createRedirectedBuilderProgram(state, configFileParsingDiagnostics) { return { getState: ts.notImplemented, @@ -90424,7 +91304,8 @@ var ts; getSemanticDiagnostics: function (sourceFile, cancellationToken) { return getProgram().getSemanticDiagnostics(sourceFile, cancellationToken); }, emit: function (sourceFile, writeFile, cancellationToken, emitOnlyDts, customTransformers) { return getProgram().emit(sourceFile, writeFile, cancellationToken, emitOnlyDts, customTransformers); }, getAllDependencies: ts.notImplemented, - getCurrentDirectory: function () { return getProgram().getCurrentDirectory(); } + getCurrentDirectory: function () { return getProgram().getCurrentDirectory(); }, + getProgramBuildInfo: function () { return undefined; } }; function getProgram() { return ts.Debug.assertDefined(state.program); @@ -91452,6 +92333,8 @@ var ts; case ".jsx" /* Jsx */: case ".json" /* Json */: return ext; + case ".tsbuildinfo" /* TsBuildInfo */: + return ts.Debug.fail("Extension " + ".tsbuildinfo" /* TsBuildInfo */ + " is unsupported:: FileName:: " + fileName); default: return ts.Debug.assertNever(ext); } @@ -91733,7 +92616,7 @@ var ts; writeFile: function (path, data, writeByteOrderMark) { return system.writeFile(path, data, writeByteOrderMark); }, onCachedDirectoryStructureHostCreate: function (cacheHost) { return host = cacheHost || system; }, createHash: ts.maybeBind(system, system.createHash), - createProgram: createProgram + createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram }; } ts.createProgramHost = createProgramHost; @@ -91743,7 +92626,7 @@ var ts; function createWatchCompilerHost(system, createProgram, reportDiagnostic, reportWatchStatus) { if (system === void 0) { system = ts.sys; } var writeFileName = function (s) { return system.write(s + system.newLine); }; - var result = createProgramHost(system, createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram); + var result = createProgramHost(system, createProgram); ts.copyProperties(result, createWatchHost(system, reportWatchStatus)); result.afterProgramCreate = function (builderProgram) { var compilerOptions = builderProgram.getCompilerOptions(); @@ -92226,16 +93109,22 @@ var ts; * This means we can Pseudo-build (just touch timestamps), as if we had actually built this project. */ UpToDateStatusType[UpToDateStatusType["UpToDateWithUpstreamTypes"] = 2] = "UpToDateWithUpstreamTypes"; - UpToDateStatusType[UpToDateStatusType["OutputMissing"] = 3] = "OutputMissing"; - UpToDateStatusType[UpToDateStatusType["OutOfDateWithSelf"] = 4] = "OutOfDateWithSelf"; - UpToDateStatusType[UpToDateStatusType["OutOfDateWithUpstream"] = 5] = "OutOfDateWithUpstream"; - UpToDateStatusType[UpToDateStatusType["UpstreamOutOfDate"] = 6] = "UpstreamOutOfDate"; - UpToDateStatusType[UpToDateStatusType["UpstreamBlocked"] = 7] = "UpstreamBlocked"; - UpToDateStatusType[UpToDateStatusType["ComputingUpstream"] = 8] = "ComputingUpstream"; + /** + * The project appears out of date because its upstream inputs are newer than its outputs, + * but all of its outputs are actually newer than the previous identical outputs of its (.d.ts) inputs. + * This means we can Pseudo-build (just manipulate outputs), as if we had actually built this project. + */ + UpToDateStatusType[UpToDateStatusType["OutOfDateWithPrepend"] = 3] = "OutOfDateWithPrepend"; + UpToDateStatusType[UpToDateStatusType["OutputMissing"] = 4] = "OutputMissing"; + UpToDateStatusType[UpToDateStatusType["OutOfDateWithSelf"] = 5] = "OutOfDateWithSelf"; + UpToDateStatusType[UpToDateStatusType["OutOfDateWithUpstream"] = 6] = "OutOfDateWithUpstream"; + UpToDateStatusType[UpToDateStatusType["UpstreamOutOfDate"] = 7] = "UpstreamOutOfDate"; + UpToDateStatusType[UpToDateStatusType["UpstreamBlocked"] = 8] = "UpstreamBlocked"; + UpToDateStatusType[UpToDateStatusType["ComputingUpstream"] = 9] = "ComputingUpstream"; /** * Projects with no outputs (i.e. "solution" files) */ - UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 9] = "ContainerOnly"; + UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 10] = "ContainerOnly"; })(UpToDateStatusType = ts.UpToDateStatusType || (ts.UpToDateStatusType = {})); function createFileMap(toPath) { // tslint:disable-next-line:no-null-keyword @@ -92316,24 +93205,18 @@ var ts; } return outputs; } - function getOutFileOutputs(project) { - var out = project.options.outFile || project.options.out; - if (!out) { - return ts.Debug.fail("outFile must be set"); - } + function getOutFileOutputs(project, ignoreBuildInfo) { + ts.Debug.assert(!!project.options.outFile || !!project.options.out, "outFile must be set"); + var _a = ts.getOutputPathsForBundle(project.options, /*forceDtsPaths*/ false), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath; var outputs = []; - outputs.push(out); - if (project.options.sourceMap) { - outputs.push(out + ".map"); - } - if (ts.getEmitDeclarations(project.options)) { - var dts = ts.changeExtension(out, ".d.ts" /* Dts */); - outputs.push(dts); - if (project.options.declarationMap) { - outputs.push(dts + ".map"); - } - } - return outputs; + var addOutput = function (path) { return path && (outputs || (outputs = [])).push(path); }; + addOutput(jsFilePath); + addOutput(sourceMapFilePath); + addOutput(declarationFilePath); + addOutput(declarationMapPath); + if (!ignoreBuildInfo) + addOutput(buildInfoPath); + return outputs || ts.emptyArray; } function rootDirOfOptions(opts, configFileName) { return opts.rootDir || ts.getDirectoryPath(configFileName); @@ -92366,14 +93249,14 @@ var ts; } function createSolutionBuilderHost(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus, reportErrorSummary) { if (system === void 0) { system = ts.sys; } - var host = createSolutionBuilderHostBase(system, createProgram || ts.createAbstractBuilder, reportDiagnostic, reportSolutionBuilderStatus); + var host = createSolutionBuilderHostBase(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus); host.reportErrorSummary = reportErrorSummary; return host; } ts.createSolutionBuilderHost = createSolutionBuilderHost; function createSolutionBuilderWithWatchHost(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus, reportWatchStatus) { if (system === void 0) { system = ts.sys; } - var host = createSolutionBuilderHostBase(system, createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram, reportDiagnostic, reportSolutionBuilderStatus); + var host = createSolutionBuilderHostBase(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus); var watchHost = ts.createWatchHost(system, reportWatchStatus); ts.copyProperties(host, watchHost); return host; @@ -92407,7 +93290,17 @@ var ts; var compilerHost = ts.createCompilerHostFromProgramHost(host, function () { return projectCompilerOptions; }); var originalGetSourceFile = compilerHost.getSourceFile; var computeHash = host.createHash || ts.generateDjb2Hash; - updateGetSourceFile(); + compilerHost.getSourceFile = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var result = originalGetSourceFile.call.apply(originalGetSourceFile, [compilerHost].concat(args)); + if (result) { + result.version = computeHash.call(host, result.text); + } + return result; + }; // Watch state var builderPrograms = createFileMap(toPath); var diagnostics = createFileMap(toPath); @@ -92459,29 +93352,6 @@ var ts; ts.clearMap(allWatchedInputFiles, function (inputFileWatches) { return ts.clearMap(inputFileWatches, ts.closeFileWatcher); }); ts.clearMap(allWatchedConfigFiles, ts.closeFileWatcher); builderPrograms.clear(); - updateGetSourceFile(); - } - function updateGetSourceFile() { - if (options.watch) { - if (compilerHost.getSourceFile === originalGetSourceFile) { - compilerHost.getSourceFile = function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - var result = originalGetSourceFile.call.apply(originalGetSourceFile, [compilerHost].concat(args)); - if (result && options.watch) { - result.version = computeHash.call(host, result.text); - } - return result; - }; - } - } - else { - if (compilerHost.getSourceFile !== originalGetSourceFile) { - compilerHost.getSourceFile = originalGetSourceFile; - } - } } function isParsedCommandLine(entry) { return !!entry.options; @@ -92713,25 +93583,28 @@ var ts; upstreamProjectName: ref.path }; } - // If the upstream project's newest file is older than our oldest output, we - // can't be out of date because of it - if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) { - continue; + // Check oldest output file name only if there is no missing output file name + if (!missingOutputFileName) { + // If the upstream project's newest file is older than our oldest output, we + // can't be out of date because of it + if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) { + continue; + } + // If the upstream project has only change .d.ts files, and we've built + // *after* those files, then we're "psuedo up to date" and eligible for a fast rebuild + if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) { + pseudoUpToDate = true; + upstreamChangedProject = ref.path; + continue; + } + // We have an output older than an upstream output - we are out of date + ts.Debug.assert(oldestOutputFileName !== undefined, "Should have an oldest output filename here"); + return { + type: UpToDateStatusType.OutOfDateWithUpstream, + outOfDateOutputFileName: oldestOutputFileName, + newerProjectName: ref.path + }; } - // If the upstream project has only change .d.ts files, and we've built - // *after* those files, then we're "psuedo up to date" and eligible for a fast rebuild - if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) { - pseudoUpToDate = true; - upstreamChangedProject = ref.path; - continue; - } - // We have an output older than an upstream output - we are out of date - ts.Debug.assert(oldestOutputFileName !== undefined, "Should have an oldest output filename here"); - return { - type: UpToDateStatusType.OutOfDateWithUpstream, - outOfDateOutputFileName: oldestOutputFileName, - newerProjectName: ref.path - }; } } if (missingOutputFileName !== undefined) { @@ -92749,7 +93622,7 @@ var ts; } if (usesPrepend && pseudoUpToDate) { return { - type: UpToDateStatusType.OutOfDateWithUpstream, + type: UpToDateStatusType.OutOfDateWithPrepend, outOfDateOutputFileName: oldestOutputFileName, newerProjectName: upstreamChangedProject }; @@ -92883,7 +93756,9 @@ var ts; updateOutputTimestamps(proj); return; } - var buildResult = buildSingleProject(resolved); + var buildResult = status.type === UpToDateStatusType.OutOfDateWithPrepend ? + updateBundle(resolved) : // Fake that files have been built by manipulating prepend and existing output + buildSingleProject(resolved); // Actual build if (buildResult & BuildResultFlags.AnyErrors) return; var _a = getGlobalDependencyGraph(), referencingProjectsMap = _a.referencingProjectsMap, buildQueue = _a.buildQueue; @@ -92899,17 +93774,26 @@ var ts; // If declaration output is changed, build the project // otherwise mark the project UpToDateWithUpstreamTypes so it updates output time stamps var status_1 = projectStatus.getValue(project); - if (prepend || !(buildResult & BuildResultFlags.DeclarationOutputUnchanged)) { - if (status_1 && (status_1.type === UpToDateStatusType.UpToDate || status_1.type === UpToDateStatusType.UpToDateWithUpstreamTypes)) { + if (!(buildResult & BuildResultFlags.DeclarationOutputUnchanged)) { + if (status_1 && (status_1.type === UpToDateStatusType.UpToDate || status_1.type === UpToDateStatusType.UpToDateWithUpstreamTypes || status_1.type === UpToDateStatusType.OutOfDateWithPrepend)) { projectStatus.setValue(project, { type: UpToDateStatusType.OutOfDateWithUpstream, - outOfDateOutputFileName: status_1.oldestOutputFileName, + outOfDateOutputFileName: status_1.type === UpToDateStatusType.OutOfDateWithPrepend ? status_1.outOfDateOutputFileName : status_1.oldestOutputFileName, newerProjectName: resolved }); } } else if (status_1 && status_1.type === UpToDateStatusType.UpToDate) { - status_1.type = UpToDateStatusType.UpToDateWithUpstreamTypes; + if (prepend) { + projectStatus.setValue(project, { + type: UpToDateStatusType.OutOfDateWithPrepend, + outOfDateOutputFileName: status_1.oldestOutputFileName, + newerProjectName: resolved + }); + } + else { + status_1.type = UpToDateStatusType.UpToDateWithUpstreamTypes; + } } addProjToQueue(project); } @@ -92966,8 +93850,7 @@ var ts; } if (options.verbose) reportStatus(ts.Diagnostics.Building_project_0, proj); - var resultFlags = BuildResultFlags.None; - resultFlags |= BuildResultFlags.DeclarationOutputUnchanged; + var resultFlags = BuildResultFlags.DeclarationOutputUnchanged; var configFile = parseConfigFile(proj); if (!configFile) { // Failed to read the config file @@ -92983,8 +93866,7 @@ var ts; } // TODO: handle resolve module name to cache result in project reference redirect projectCompilerOptions = configFile.options; - var program = host.createProgram(configFile.fileNames, configFile.options, compilerHost, builderPrograms.getValue(proj), configFile.errors, configFile.projectReferences); - projectCompilerOptions = baseCompilerOptions; + var program = host.createProgram(configFile.fileNames, configFile.options, compilerHost, getOldProgram(proj, configFile), configFile.errors, configFile.projectReferences); // Don't emit anything in the presence of syntactic errors or options diagnostics var syntaxDiagnostics = program.getConfigFileParsingDiagnostics().concat(program.getOptionsDiagnostics(), program.getGlobalDiagnostics(), program.getSyntacticDiagnostics()); if (syntaxDiagnostics.length) { @@ -93045,12 +93927,14 @@ var ts; diagnostics.removeKey(proj); projectStatus.setValue(proj, status); afterProgramCreate(proj, program); + projectCompilerOptions = baseCompilerOptions; return resultFlags; function buildErrors(diagnostics, errorFlags, errorType) { resultFlags |= errorFlags; reportAndStoreErrors(proj, diagnostics); projectStatus.setValue(proj, { type: UpToDateStatusType.Unbuildable, reason: errorType + " errors" }); afterProgramCreate(proj, program); + projectCompilerOptions = baseCompilerOptions; return resultFlags; } } @@ -93063,9 +93947,65 @@ var ts; builderPrograms.setValue(proj, program); } } + function getOldProgram(proj, parsed) { + var value = builderPrograms.getValue(proj); + if (value) + return value; + var buildInfoPath = ts.getOutputPathForBuildInfo(parsed.options); + if (!buildInfoPath) + return undefined; + var content = readFileWithCache(buildInfoPath); + if (!content) + return undefined; + var buildInfo = JSON.parse(content); + return buildInfo.program && ts.createBuildProgramUsingProgramBuildInfo(buildInfo.program); + } + function updateBundle(proj) { + if (options.dry) { + reportStatus(ts.Diagnostics.A_non_dry_build_would_update_output_of_project_0, proj); + return BuildResultFlags.Success; + } + if (options.verbose) + reportStatus(ts.Diagnostics.Updating_output_of_project_0, proj); + // Update js, and source map + var config = ts.Debug.assertDefined(parseConfigFile(proj)); + projectCompilerOptions = config.options; + var outputFiles = ts.emitUsingBuildInfo(config, compilerHost, function (ref) { return parseConfigFile(resolveProjectName(ref.path)); }); + if (ts.isString(outputFiles)) { + reportStatus(ts.Diagnostics.Cannot_update_output_of_project_0_because_there_was_error_reading_file_1, proj, relName(outputFiles)); + return buildSingleProject(proj); + } + // Actual Emit + ts.Debug.assert(!!outputFiles.length); + var emitterDiagnostics = ts.createDiagnosticCollection(); + var emittedOutputs = createFileMap(toPath); + outputFiles.forEach(function (_a) { + var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark; + emittedOutputs.setValue(name, true); + ts.writeFile(compilerHost, emitterDiagnostics, name, text, writeByteOrderMark); + }); + var emitDiagnostics = emitterDiagnostics.getDiagnostics(); + if (emitDiagnostics.length) { + reportAndStoreErrors(proj, emitDiagnostics); + projectStatus.setValue(proj, { type: UpToDateStatusType.Unbuildable, reason: "Emit errors" }); + projectCompilerOptions = baseCompilerOptions; + return BuildResultFlags.DeclarationOutputUnchanged | BuildResultFlags.EmitErrors; + } + // Update timestamps for dts + var newestDeclarationFileContentChangedTime = updateOutputTimestampsWorker(config, minimumDate, ts.Diagnostics.Updating_unchanged_output_timestamps_of_project_0, emittedOutputs); + var status = { + type: UpToDateStatusType.UpToDate, + newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTime, + oldestOutputFileName: outputFiles[0].name + }; + diagnostics.removeKey(proj); + projectStatus.setValue(proj, status); + projectCompilerOptions = baseCompilerOptions; + return BuildResultFlags.DeclarationOutputUnchanged; + } function updateOutputTimestamps(proj) { if (options.dry) { - return reportStatus(ts.Diagnostics.A_non_dry_build_would_build_project_0, proj.options.configFilePath); + return reportStatus(ts.Diagnostics.A_non_dry_build_would_update_timestamps_for_output_of_project_0, proj.options.configFilePath); } var priorNewestUpdateTime = updateOutputTimestampsWorker(proj, minimumDate, ts.Diagnostics.Updating_output_timestamps_of_project_0); projectStatus.setValue(proj.options.configFilePath, { type: UpToDateStatusType.UpToDate, newestDeclarationFileContentChangedTime: priorNewestUpdateTime }); @@ -93192,7 +94132,9 @@ var ts; // Do nothing continue; } - var buildResult = buildSingleProject(next); + var buildResult = status.type === UpToDateStatusType.OutOfDateWithPrepend && !options.force ? + updateBundle(next) : // Fake that files have been built by manipulating prepend and existing output + buildSingleProject(next); // Actual build anyFailed = anyFailed || !!(buildResult & BuildResultFlags.AnyErrors); } reportErrorSummary(); @@ -93254,6 +94196,9 @@ var ts; var inputFile = _a[_i]; outputs.push.apply(outputs, getOutputFileNames(inputFile, project)); } + var buildInfoPath = ts.getOutputPathForBuildInfo(project.options); + if (buildInfoPath) + outputs.push(buildInfoPath); return outputs; } } @@ -93285,6 +94230,8 @@ var ts; } // Don't report anything for "up to date because it was already built" -- too verbose break; + case UpToDateStatusType.OutOfDateWithPrepend: + return formatMessage(ts.Diagnostics.Project_0_is_out_of_date_because_output_of_its_dependency_1_has_changed, relName(configFileName), relName(status.newerProjectName)); case UpToDateStatusType.UpToDateWithUpstreamTypes: return formatMessage(ts.Diagnostics.Project_0_is_up_to_date_with_d_ts_files_from_its_dependencies, relName(configFileName)); case UpToDateStatusType.UpstreamOutOfDate: @@ -94099,7 +95046,7 @@ var ts; case 242 /* TypeAliasDeclaration */: case 168 /* TypeLiteral */: return 2 /* Type */; - case 304 /* JSDocTypedefTag */: + case 309 /* JSDocTypedefTag */: // If it has no name node, it shares the name with the value declaration below it. return node.name === undefined ? 1 /* Value */ | 2 /* Type */ : 2 /* Type */; case 278 /* EnumMember */: @@ -94124,14 +95071,14 @@ var ts; case 255 /* ExportDeclaration */: return 7 /* All */; // An external module can be a Value - case 279 /* SourceFile */: + case 284 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 7 /* All */; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.kind === 279 /* SourceFile */) { + if (node.kind === 284 /* SourceFile */) { return 1 /* Value */; } else if (node.parent.kind === 254 /* ExportAssignment */ || node.parent.kind === 259 /* ExternalModuleReference */) { @@ -94337,7 +95284,7 @@ var ts; return undefined; } switch (node.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: case 156 /* MethodDeclaration */: case 155 /* MethodSignature */: case 239 /* FunctionDeclaration */: @@ -94355,7 +95302,7 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: return ts.isExternalModule(node) ? "module" /* moduleElement */ : "script" /* scriptElement */; case 244 /* ModuleDeclaration */: return "module" /* moduleElement */; @@ -94364,8 +95311,8 @@ var ts; return "class" /* classElement */; case 241 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; case 242 /* TypeAliasDeclaration */: - case 297 /* JSDocCallbackTag */: - case 304 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: + case 309 /* JSDocTypedefTag */: return "type" /* typeElement */; case 243 /* EnumDeclaration */: return "enum" /* enumElement */; case 237 /* VariableDeclaration */: @@ -94791,7 +95738,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 279 /* SourceFile */ || n.kind === 1 /* EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); + ts.Debug.assert(startNode !== undefined || n.kind === 284 /* SourceFile */ || n.kind === 1 /* EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); // Here we know that none of child token nodes embrace the position, // the only known case is when position is at the end of the file. // Try to find the rightmost token in the file without filtering. @@ -96536,18 +97483,18 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); // e.g. "param" pos = tag.tagName.end; switch (tag.kind) { - case 299 /* JSDocParameterTag */: + case 304 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 303 /* JSDocTemplateTag */: + case 308 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); pos = tag.end; break; - case 302 /* JSDocTypeTag */: + case 307 /* JSDocTypeTag */: processElement(tag.typeExpression); pos = tag.end; break; - case 300 /* JSDocReturnTag */: + case 305 /* JSDocReturnTag */: processElement(tag.typeExpression); pos = tag.end; break; @@ -96851,6 +97798,7 @@ var ts; case ".jsx" /* Jsx */: return ".jsx" /* jsxModifier */; case ".ts" /* Ts */: return ".ts" /* tsModifier */; case ".tsx" /* Tsx */: return ".tsx" /* tsxModifier */; + case ".tsbuildinfo" /* TsBuildInfo */: return ts.Debug.fail("Extension " + ".tsbuildinfo" /* TsBuildInfo */ + " is unsupported."); case undefined: return "" /* none */; default: return ts.Debug.assertNever(extension); @@ -97875,7 +98823,7 @@ var ts; return symbol.parent && (isModuleSymbol(symbol.parent) ? symbol : getFirstSymbolInChain(symbol.parent, enclosingDeclaration, checker)); } function isModuleSymbol(symbol) { - return symbol.declarations.some(function (d) { return d.kind === 279 /* SourceFile */; }); + return symbol.declarations.some(function (d) { return d.kind === 284 /* SourceFile */; }); } function getCompletionData(program, log, sourceFile, isUncheckedFile, position, preferences, detailsEntryId) { var typeChecker = program.getTypeChecker(); @@ -97926,11 +98874,11 @@ var ts; if (tag.tagName.pos <= position && position <= tag.tagName.end) { return { kind: 1 /* JsDocTagName */ }; } - if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 283 /* JSDocTypeExpression */) { + if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 288 /* JSDocTypeExpression */) { currentToken = ts.getTokenAtPosition(sourceFile, position); if (!currentToken || (!ts.isDeclarationName(currentToken) && - (currentToken.parent.kind !== 305 /* JSDocPropertyTag */ || + (currentToken.parent.kind !== 310 /* JSDocPropertyTag */ || currentToken.parent.name !== currentToken))) { // Use as type location if inside tag's type expression insideJsDocTagTypeExpression = isCurrentlyEditingNode(tag.typeExpression); @@ -98101,11 +99049,11 @@ var ts; return { kind: 0 /* Data */, symbols: symbols, completionKind: completionKind, isInSnippetScope: isInSnippetScope, propertyAccessToConvert: propertyAccessToConvert, isNewIdentifierLocation: isNewIdentifierLocation, location: location, keywordFilters: keywordFilters, literals: literals, symbolToOriginInfoMap: symbolToOriginInfoMap, recommendedCompletion: recommendedCompletion, previousToken: previousToken, isJsxInitializer: isJsxInitializer }; function isTagWithTypeExpression(tag) { switch (tag.kind) { - case 299 /* JSDocParameterTag */: - case 305 /* JSDocPropertyTag */: - case 300 /* JSDocReturnTag */: - case 302 /* JSDocTypeTag */: - case 304 /* JSDocTypedefTag */: + case 304 /* JSDocParameterTag */: + case 310 /* JSDocPropertyTag */: + case 305 /* JSDocReturnTag */: + case 307 /* JSDocTypeTag */: + case 309 /* JSDocTypedefTag */: return true; default: return false; @@ -98145,7 +99093,7 @@ var ts; } } // If the module is merged with a value, we must get the type of the class and add its propertes (for inherited static methods). - if (!isTypeLocation && symbol.declarations.some(function (d) { return d.kind !== 279 /* SourceFile */ && d.kind !== 244 /* ModuleDeclaration */ && d.kind !== 243 /* EnumDeclaration */; })) { + if (!isTypeLocation && symbol.declarations.some(function (d) { return d.kind !== 284 /* SourceFile */ && d.kind !== 244 /* ModuleDeclaration */ && d.kind !== 243 /* EnumDeclaration */; })) { addTypeProperties(typeChecker.getTypeOfSymbolAtLocation(symbol, node)); } return; @@ -98278,7 +99226,7 @@ var ts; var symbolMeanings = (isTypeOnly ? 0 /* None */ : 67220415 /* Value */) | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */; symbols = ts.Debug.assertEachDefined(typeChecker.getSymbolsInScope(scopeNode, symbolMeanings), "getSymbolsInScope() should all be defined"); // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions` - if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 279 /* SourceFile */) { + if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 284 /* SourceFile */) { var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false); if (thisType) { for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker); _i < _a.length; _i++) { @@ -98311,7 +99259,7 @@ var ts; } function isSnippetScope(scopeNode) { switch (scopeNode.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: case 206 /* TemplateExpression */: case 270 /* JsxExpression */: case 218 /* Block */: @@ -99143,7 +100091,7 @@ var ts; function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location) { // class c { method() { } | method2() { } } switch (location.kind) { - case 306 /* SyntaxList */: + case 311 /* SyntaxList */: return ts.tryCast(location.parent, ts.isObjectTypeDeclaration); case 1 /* EndOfFileToken */: var cls = ts.tryCast(ts.lastOrUndefined(ts.cast(location.parent, ts.isSourceFile).statements), ts.isObjectTypeDeclaration); @@ -99328,7 +100276,7 @@ var ts; var child = throwStatement; while (child.parent) { var parent = child.parent; - if (ts.isFunctionBlock(parent) || parent.kind === 279 /* SourceFile */) { + if (ts.isFunctionBlock(parent) || parent.kind === 284 /* SourceFile */) { return parent; } // A throw-statement is only owned by a try-statement if the try-statement has @@ -99386,7 +100334,7 @@ var ts; var container = declaration.parent; switch (container.kind) { case 245 /* ModuleBlock */: - case 279 /* SourceFile */: + case 284 /* SourceFile */: case 218 /* Block */: case 271 /* CaseClause */: case 272 /* DefaultClause */: @@ -99884,7 +100832,7 @@ var ts; } else if (!isAvailableThroughGlobal) { var sourceFileLike = getSourceFileLikeForImportDeclaration(importDeclaration); - ts.Debug.assert(sourceFileLike.kind === 279 /* SourceFile */ || sourceFileLike.kind === 244 /* ModuleDeclaration */); + ts.Debug.assert(sourceFileLike.kind === 284 /* SourceFile */ || sourceFileLike.kind === 244 /* ModuleDeclaration */); if (isReExport || findNamespaceReExports(sourceFileLike, name, checker)) { addIndirectUsers(sourceFileLike); } @@ -100053,7 +101001,7 @@ var ts; for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { var referencingFile = sourceFiles_3[_i]; var searchSourceFile = searchModuleSymbol.valueDeclaration; - if (searchSourceFile.kind === 279 /* SourceFile */) { + if (searchSourceFile.kind === 284 /* SourceFile */) { for (var _a = 0, _b = referencingFile.referencedFiles; _a < _b.length; _a++) { var ref = _b[_a]; if (program.getSourceFileFromReference(referencingFile, ref) === searchSourceFile) { @@ -100101,7 +101049,7 @@ var ts; } /** Iterates over all statements at the top level or in module declarations. Returns the first truthy result. */ function forEachPossibleImportOrExportStatement(sourceFileLike, action) { - return ts.forEach(sourceFileLike.kind === 279 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { + return ts.forEach(sourceFileLike.kind === 284 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { return action(statement) || (isAmbientModuleDeclaration(statement) && ts.forEach(statement.body && statement.body.statements, action)); }); } @@ -100325,7 +101273,7 @@ var ts; return node.getSourceFile(); } var parent = node.parent; - if (parent.kind === 279 /* SourceFile */) { + if (parent.kind === 284 /* SourceFile */) { return parent; } ts.Debug.assert(parent.kind === 245 /* ModuleBlock */); @@ -100387,7 +101335,7 @@ var ts; } FindAllReferences.getImplementationsAtPosition = getImplementationsAtPosition; function getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position) { - if (node.kind === 279 /* SourceFile */) { + if (node.kind === 284 /* SourceFile */) { return undefined; } var checker = program.getTypeChecker(); @@ -100607,8 +101555,8 @@ var ts; case 248 /* ImportEqualsDeclaration */: case 253 /* ImportSpecifier */: case 241 /* InterfaceDeclaration */: - case 297 /* JSDocCallbackTag */: - case 304 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: + case 309 /* JSDocTypedefTag */: case 267 /* JsxAttribute */: case 244 /* ModuleDeclaration */: case 247 /* NamespaceExportDeclaration */: @@ -100633,8 +101581,8 @@ var ts; return !!decl.initializer || ts.isCatchClause(decl.parent); case 155 /* MethodSignature */: case 153 /* PropertySignature */: - case 305 /* JSDocPropertyTag */: - case 299 /* JSDocParameterTag */: + case 310 /* JSDocPropertyTag */: + case 304 /* JSDocParameterTag */: return false; default: return ts.Debug.failBadSyntaxKind(decl); @@ -100794,7 +101742,7 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; switch (decl.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: // Don't include the source file itself. (This may not be ideal behavior, but awkward to include an entire file as a reference.) break; case 244 /* ModuleDeclaration */: @@ -101165,7 +102113,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (!container || container.kind === 279 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { + if (!container || container.kind === 284 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { // This is a global variable and not an external module, any declaration defined // within this scope is visible outside the file return undefined; @@ -101724,7 +102672,7 @@ var ts; staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 279 /* SourceFile */: + case 284 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode) || isParameterName(thisOrSuperKeyword)) { return undefined; } @@ -101737,7 +102685,7 @@ var ts; default: return undefined; } - var references = ts.flatMap(searchSpaceNode.kind === 279 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { + var references = ts.flatMap(searchSpaceNode.kind === 284 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return getPossibleSymbolReferenceNodes(sourceFile, "this", ts.isSourceFile(searchSpaceNode) ? sourceFile : searchSpaceNode).filter(function (node) { if (!ts.isThis(node)) { @@ -101756,8 +102704,8 @@ var ts; // Make sure the container belongs to the same class // and has the appropriate static modifier from the original container. return container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getModifierFlags(container) & 32 /* Static */) === staticFlag; - case 279 /* SourceFile */: - return container.kind === 279 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); + case 284 /* SourceFile */: + return container.kind === 284 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); } }); }).map(function (n) { return FindAllReferences.nodeEntry(n); }); @@ -102611,11 +103559,11 @@ var ts; JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations; function getCommentHavingNodes(declaration) { switch (declaration.kind) { - case 299 /* JSDocParameterTag */: - case 305 /* JSDocPropertyTag */: + case 304 /* JSDocParameterTag */: + case 310 /* JSDocPropertyTag */: return [declaration]; - case 297 /* JSDocCallbackTag */: - case 304 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: + case 309 /* JSDocTypedefTag */: return [declaration, declaration.parent]; default: return ts.getJSDocCommentsAndTags(declaration); @@ -102636,16 +103584,16 @@ var ts; function getCommentText(tag) { var comment = tag.comment; switch (tag.kind) { - case 295 /* JSDocAugmentsTag */: + case 300 /* JSDocAugmentsTag */: return withNode(tag.class); - case 303 /* JSDocTemplateTag */: + case 308 /* JSDocTemplateTag */: return withList(tag.typeParameters); - case 302 /* JSDocTypeTag */: + case 307 /* JSDocTypeTag */: return withNode(tag.typeExpression); - case 304 /* JSDocTypedefTag */: - case 297 /* JSDocCallbackTag */: - case 305 /* JSDocPropertyTag */: - case 299 /* JSDocParameterTag */: + case 309 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: + case 310 /* JSDocPropertyTag */: + case 304 /* JSDocParameterTag */: var name = tag.name; return name ? withNode(name) : comment; default: @@ -102856,7 +103804,7 @@ var ts; : undefined; return { commentOwner: commentOwner, parameters: parameters_1 }; } - case 279 /* SourceFile */: + case 284 /* SourceFile */: return "quit"; case 244 /* ModuleDeclaration */: // If in walking up the tree, we hit a a nested namespace declaration, @@ -103416,7 +104364,7 @@ var ts; } } switch (node.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" @@ -103468,10 +104416,10 @@ var ts; case 243 /* EnumDeclaration */: case 241 /* InterfaceDeclaration */: case 244 /* ModuleDeclaration */: - case 279 /* SourceFile */: + case 284 /* SourceFile */: case 242 /* TypeAliasDeclaration */: - case 304 /* JSDocTypedefTag */: - case 297 /* JSDocCallbackTag */: + case 309 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: return true; case 157 /* Constructor */: case 156 /* MethodDeclaration */: @@ -103492,7 +104440,7 @@ var ts; } switch (navigationBarNodeKind(item.parent)) { case 245 /* ModuleBlock */: - case 279 /* SourceFile */: + case 284 /* SourceFile */: case 156 /* MethodDeclaration */: case 157 /* Constructor */: return true; @@ -103577,7 +104525,7 @@ var ts; return !member.name || member.name.kind === 149 /* ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 279 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); + return node.kind === 284 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); } function getModifiers(node) { if (node.parent && node.parent.kind === 237 /* VariableDeclaration */) { @@ -106395,7 +107343,7 @@ var ts; // For some special property access expressions like `exports.foo = foo` or `module.exports.foo = foo` // there documentation comments might be attached to the right hand side symbol of their declarations. // The pattern of such special property access is that the parent symbol is the symbol of the file. - if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 279 /* SourceFile */; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 284 /* SourceFile */; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; if (!declaration.parent || declaration.parent.kind !== 204 /* BinaryExpression */) { @@ -106520,7 +107468,7 @@ var ts; // If the parent is not sourceFile or module block it is local variable for (var parent = declaration.parent; !ts.isFunctionBlock(parent); parent = parent.parent) { // Reached source file or module block - if (parent.kind === 279 /* SourceFile */ || parent.kind === 245 /* ModuleBlock */) { + if (parent.kind === 284 /* SourceFile */ || parent.kind === 245 /* ModuleBlock */) { return false; } } @@ -107845,7 +108793,7 @@ var ts; case 244 /* ModuleDeclaration */: var body = parent.body; return !!body && body.kind === 245 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 279 /* SourceFile */: + case 284 /* SourceFile */: case 218 /* Block */: case 245 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); @@ -108964,7 +109912,7 @@ var ts; // - parent is SourceFile - by default immediate children of SourceFile are not indented except when user indents them manually // - parent and child are not on the same line var useActualIndentation = (ts.isDeclaration(current) || ts.isStatementButNotDeclaration(current)) && - (parent.kind === 279 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 284 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -109052,7 +110000,7 @@ var ts; case 209 /* ClassExpression */: case 241 /* InterfaceDeclaration */: case 242 /* TypeAliasDeclaration */: - case 303 /* JSDocTemplateTag */: + case 308 /* JSDocTemplateTag */: return getList(node.typeParameters); case 192 /* NewExpression */: case 191 /* CallExpression */: @@ -110615,18 +111563,18 @@ var ts; } function transformJSDocType(node) { switch (node.kind) { - case 284 /* JSDocAllType */: - case 285 /* JSDocUnknownType */: + case 289 /* JSDocAllType */: + case 290 /* JSDocUnknownType */: return ts.createTypeReferenceNode("any", ts.emptyArray); - case 288 /* JSDocOptionalType */: + case 293 /* JSDocOptionalType */: return transformJSDocOptionalType(node); - case 287 /* JSDocNonNullableType */: + case 292 /* JSDocNonNullableType */: return transformJSDocType(node.type); - case 286 /* JSDocNullableType */: + case 291 /* JSDocNullableType */: return transformJSDocNullableType(node); - case 290 /* JSDocVariadicType */: + case 295 /* JSDocVariadicType */: return transformJSDocVariadicType(node); - case 289 /* JSDocFunctionType */: + case 294 /* JSDocFunctionType */: return transformJSDocFunctionType(node); case 164 /* TypeReference */: return transformJSDocTypeReference(node); @@ -110650,7 +111598,7 @@ var ts; } function transformJSDocParameter(node) { var index = node.parent.parameters.indexOf(node); - var isRest = node.type.kind === 290 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 + var isRest = node.type.kind === 295 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 var name = node.name || (isRest ? "rest" : "arg" + index); var dotdotdot = isRest ? ts.createToken(25 /* DotDotDotToken */) : node.dotDotDotToken; return ts.createParameter(node.decorators, node.modifiers, dotdotdot, name, node.questionToken, ts.visitNode(node.type, transformJSDocType), node.initializer); @@ -110969,14 +111917,14 @@ var ts; return undefined; } switch (oldTag.kind) { - case 299 /* JSDocParameterTag */: { + case 304 /* JSDocParameterTag */: { var oldParam = oldTag; var newParam = newTag; return ts.isIdentifier(oldParam.name) && ts.isIdentifier(newParam.name) && oldParam.name.escapedText === newParam.name.escapedText ? ts.createJSDocParamTag(newParam.name, newParam.isBracketed, newParam.typeExpression, oldParam.comment) : undefined; } - case 300 /* JSDocReturnTag */: + case 305 /* JSDocReturnTag */: return ts.createJSDocReturnTag(newTag.typeExpression, oldTag.comment); } } @@ -114356,7 +115304,7 @@ var ts; var typeNode = info.typeNode, type = info.type; var original = typeNode.getText(sourceFile); var actions = [fix(type, fixIdPlain, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript)]; - if (typeNode.kind === 286 /* JSDocNullableType */) { + if (typeNode.kind === 291 /* JSDocNullableType */) { // for nullable types, suggest the flow-compatible `T | null | undefined` // in addition to the jsdoc/closure-compatible `T | null` actions.push(fix(checker.getNullableType(type, 32768 /* Undefined */), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types)); @@ -114376,7 +115324,7 @@ var ts; if (!info) return; var typeNode = info.typeNode, type = info.type; - var fixedType = typeNode.kind === 286 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; + var fixedType = typeNode.kind === 291 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; doChange(changes, sourceFile, typeNode, fixedType, checker); }); } @@ -115008,6 +115956,7 @@ var ts; return ts.textChanges.getNewFileText(toStatements(valueInfo, outputKind), 3 /* TS */, formatSettings.newLineCharacter || "\n", ts.formatting.getFormatContext(formatSettings)); } ts.valueInfoToDeclarationFileText = valueInfoToDeclarationFileText; + /* @internal */ var OutputKind; (function (OutputKind) { OutputKind[OutputKind["ExportEquals"] = 0] = "ExportEquals"; @@ -116175,7 +117124,7 @@ var ts; // * Module/namespace or source file if (isScope(current)) { scopes.push(current); - if (current.kind === 279 /* SourceFile */) { + if (current.kind === 284 /* SourceFile */) { return scopes; } } @@ -117189,7 +118138,7 @@ var ts; function isBlockLike(node) { switch (node.kind) { case 218 /* Block */: - case 279 /* SourceFile */: + case 284 /* SourceFile */: case 245 /* ModuleBlock */: case 271 /* CaseClause */: return true; @@ -118253,7 +119202,7 @@ var ts; if (!children.length) { return undefined; } - var child = ts.find(children, function (kid) { return kid.kind < 283 /* FirstJSDocNode */ || kid.kind > 305 /* LastJSDocNode */; }); + var child = ts.find(children, function (kid) { return kid.kind < 288 /* FirstJSDocNode */ || kid.kind > 310 /* LastJSDocNode */; }); return child.kind < 148 /* FirstNode */ ? child : child.getFirstToken(sourceFile); @@ -118323,7 +119272,7 @@ var ts; } } function createSyntaxList(nodes, parent) { - var list = createNode(306 /* SyntaxList */, nodes.pos, nodes.end, parent); + var list = createNode(311 /* SyntaxList */, nodes.pos, nodes.end, parent); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_7 = nodes; _i < nodes_7.length; _i++) { diff --git a/lib/typescriptServices.d.ts b/lib/typescriptServices.d.ts index 0c77acd5540..e303f9320a6 100644 --- a/lib/typescriptServices.d.ts +++ b/lib/typescriptServices.d.ts @@ -355,40 +355,45 @@ declare namespace ts { ShorthandPropertyAssignment = 276, SpreadAssignment = 277, EnumMember = 278, - SourceFile = 279, - Bundle = 280, - UnparsedSource = 281, - InputFiles = 282, - JSDocTypeExpression = 283, - JSDocAllType = 284, - JSDocUnknownType = 285, - JSDocNullableType = 286, - JSDocNonNullableType = 287, - JSDocOptionalType = 288, - JSDocFunctionType = 289, - JSDocVariadicType = 290, - JSDocComment = 291, - JSDocTypeLiteral = 292, - JSDocSignature = 293, - JSDocTag = 294, - JSDocAugmentsTag = 295, - JSDocClassTag = 296, - JSDocCallbackTag = 297, - JSDocEnumTag = 298, - JSDocParameterTag = 299, - JSDocReturnTag = 300, - JSDocThisTag = 301, - JSDocTypeTag = 302, - JSDocTemplateTag = 303, - JSDocTypedefTag = 304, - JSDocPropertyTag = 305, - SyntaxList = 306, - NotEmittedStatement = 307, - PartiallyEmittedExpression = 308, - CommaListExpression = 309, - MergeDeclarationMarker = 310, - EndOfDeclarationMarker = 311, - Count = 312, + UnparsedPrologue = 279, + UnparsedPrepend = 280, + UnparsedText = 281, + UnparsedInternalText = 282, + UnparsedSyntheticReference = 283, + SourceFile = 284, + Bundle = 285, + UnparsedSource = 286, + InputFiles = 287, + JSDocTypeExpression = 288, + JSDocAllType = 289, + JSDocUnknownType = 290, + JSDocNullableType = 291, + JSDocNonNullableType = 292, + JSDocOptionalType = 293, + JSDocFunctionType = 294, + JSDocVariadicType = 295, + JSDocComment = 296, + JSDocTypeLiteral = 297, + JSDocSignature = 298, + JSDocTag = 299, + JSDocAugmentsTag = 300, + JSDocClassTag = 301, + JSDocCallbackTag = 302, + JSDocEnumTag = 303, + JSDocParameterTag = 304, + JSDocReturnTag = 305, + JSDocThisTag = 306, + JSDocTypeTag = 307, + JSDocTemplateTag = 308, + JSDocTypedefTag = 309, + JSDocPropertyTag = 310, + SyntaxList = 311, + NotEmittedStatement = 312, + PartiallyEmittedExpression = 313, + CommaListExpression = 314, + MergeDeclarationMarker = 315, + EndOfDeclarationMarker = 316, + Count = 317, FirstAssignment = 59, LastAssignment = 71, FirstCompoundAssignment = 60, @@ -414,10 +419,10 @@ declare namespace ts { FirstBinaryOperator = 28, LastBinaryOperator = 71, FirstNode = 148, - FirstJSDocNode = 283, - LastJSDocNode = 305, - FirstJSDocTagNode = 294, - LastJSDocTagNode = 305 + FirstJSDocNode = 288, + LastJSDocNode = 310, + FirstJSDocTagNode = 299, + LastJSDocTagNode = 310 } enum NodeFlags { None = 0, @@ -1745,10 +1750,44 @@ declare namespace ts { } interface UnparsedSource extends Node { kind: SyntaxKind.UnparsedSource; - fileName?: string; + fileName: string; text: string; + prologues: ReadonlyArray; + helpers: ReadonlyArray | undefined; + referencedFiles: ReadonlyArray; + typeReferenceDirectives: ReadonlyArray | undefined; + libReferenceDirectives: ReadonlyArray; + hasNoDefaultLib?: boolean; sourceMapPath?: string; sourceMapText?: string; + syntheticReferences?: ReadonlyArray; + texts: ReadonlyArray; + } + type UnparsedSourceText = UnparsedPrepend | UnparsedTextLike; + type UnparsedNode = UnparsedPrologue | UnparsedSourceText | UnparsedSyntheticReference; + interface UnparsedSection extends Node { + kind: SyntaxKind; + data?: string; + parent: UnparsedSource; + } + interface UnparsedPrologue extends UnparsedSection { + kind: SyntaxKind.UnparsedPrologue; + data: string; + parent: UnparsedSource; + } + interface UnparsedPrepend extends UnparsedSection { + kind: SyntaxKind.UnparsedPrepend; + data: string; + parent: UnparsedSource; + texts: ReadonlyArray; + } + interface UnparsedTextLike extends UnparsedSection { + kind: SyntaxKind.UnparsedText | SyntaxKind.UnparsedInternalText; + parent: UnparsedSource; + } + interface UnparsedSyntheticReference extends UnparsedSection { + kind: SyntaxKind.UnparsedSyntheticReference; + parent: UnparsedSource; } interface JsonSourceFile extends SourceFile { statements: NodeArray; @@ -2503,6 +2542,8 @@ declare namespace ts { reactNamespace?: string; jsxFactory?: string; composite?: boolean; + incremental?: boolean; + tsBuildInfoFile?: string; removeComments?: boolean; rootDir?: string; rootDirs?: string[]; @@ -2679,7 +2720,8 @@ declare namespace ts { Dts = ".d.ts", Js = ".js", Jsx = ".jsx", - Json = ".json" + Json = ".json", + TsBuildInfo = ".tsbuildinfo" } interface ResolvedModuleWithFailedLookupLocations { readonly resolvedModule: ResolvedModuleFull | undefined; @@ -2760,6 +2802,10 @@ declare namespace ts { readonly text: string | ((node: EmitHelperUniqueNameCallback) => string); readonly priority?: number; } + interface UnscopedEmitHelper extends EmitHelper { + readonly scoped: false; + readonly text: string; + } type EmitHelperUniqueNameCallback = (name: string) => string; enum EmitHint { SourceFile = 0, @@ -3459,6 +3505,9 @@ declare namespace ts { function isSourceFile(node: Node): node is SourceFile; function isBundle(node: Node): node is Bundle; function isUnparsedSource(node: Node): node is UnparsedSource; + function isUnparsedPrepend(node: Node): node is UnparsedPrepend; + function isUnparsedTextLike(node: Node): node is UnparsedTextLike; + function isUnparsedNode(node: Node): node is UnparsedNode; function isJSDocTypeExpression(node: Node): node is JSDocTypeExpression; function isJSDocAllType(node: JSDocAllType): node is JSDocAllType; function isJSDocUnknownType(node: Node): node is JSDocUnknownType; @@ -3994,10 +4043,10 @@ declare namespace ts { function updateCommaList(node: CommaListExpression, elements: ReadonlyArray): CommaListExpression; function createBundle(sourceFiles: ReadonlyArray, prepends?: ReadonlyArray): Bundle; function createUnparsedSourceFile(text: string): UnparsedSource; - function createUnparsedSourceFile(inputFile: InputFiles, type: "js" | "dts"): UnparsedSource; + function createUnparsedSourceFile(inputFile: InputFiles, type: "js" | "dts", stripInternal?: boolean): UnparsedSource; function createUnparsedSourceFile(text: string, mapPath: string | undefined, map: string | undefined): UnparsedSource; function createInputFiles(javascriptText: string, declarationText: string): InputFiles; - function createInputFiles(readFileText: (path: string) => string | undefined, javascriptPath: string, javascriptMapPath: string | undefined, declarationPath: string, declarationMapPath: string | undefined): InputFiles; + function createInputFiles(readFileText: (path: string) => string | undefined, javascriptPath: string, javascriptMapPath: string | undefined, declarationPath: string, declarationMapPath: string | undefined, buildInfoPath: string | undefined): InputFiles; function createInputFiles(javascriptText: string, declarationText: string, javascriptMapPath: string | undefined, javascriptMapText: string | undefined, declarationMapPath: string | undefined, declarationMapText: string | undefined): InputFiles; function updateBundle(node: Bundle, sourceFiles: ReadonlyArray, prepends?: ReadonlyArray): Bundle; function createImmediatelyInvokedFunctionExpression(statements: ReadonlyArray): CallExpression; diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index c7d8109b6be..ef383167ce9 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -2867,47 +2867,53 @@ var ts; SyntaxKind[SyntaxKind["SpreadAssignment"] = 277] = "SpreadAssignment"; // Enum SyntaxKind[SyntaxKind["EnumMember"] = 278] = "EnumMember"; + // Unparsed + SyntaxKind[SyntaxKind["UnparsedPrologue"] = 279] = "UnparsedPrologue"; + SyntaxKind[SyntaxKind["UnparsedPrepend"] = 280] = "UnparsedPrepend"; + SyntaxKind[SyntaxKind["UnparsedText"] = 281] = "UnparsedText"; + SyntaxKind[SyntaxKind["UnparsedInternalText"] = 282] = "UnparsedInternalText"; + SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 283] = "UnparsedSyntheticReference"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 279] = "SourceFile"; - SyntaxKind[SyntaxKind["Bundle"] = 280] = "Bundle"; - SyntaxKind[SyntaxKind["UnparsedSource"] = 281] = "UnparsedSource"; - SyntaxKind[SyntaxKind["InputFiles"] = 282] = "InputFiles"; + SyntaxKind[SyntaxKind["SourceFile"] = 284] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 285] = "Bundle"; + SyntaxKind[SyntaxKind["UnparsedSource"] = 286] = "UnparsedSource"; + SyntaxKind[SyntaxKind["InputFiles"] = 287] = "InputFiles"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 283] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 288] = "JSDocTypeExpression"; // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 284] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 289] = "JSDocAllType"; // The ? type - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 285] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 286] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 287] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 288] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 289] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 290] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 291] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 292] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocSignature"] = 293] = "JSDocSignature"; - SyntaxKind[SyntaxKind["JSDocTag"] = 294] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 295] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocClassTag"] = 296] = "JSDocClassTag"; - SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 297] = "JSDocCallbackTag"; - SyntaxKind[SyntaxKind["JSDocEnumTag"] = 298] = "JSDocEnumTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 299] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 300] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocThisTag"] = 301] = "JSDocThisTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 302] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 303] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 304] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 305] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 290] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 291] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 292] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 293] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 294] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 295] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 296] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 297] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocSignature"] = 298] = "JSDocSignature"; + SyntaxKind[SyntaxKind["JSDocTag"] = 299] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 300] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocClassTag"] = 301] = "JSDocClassTag"; + SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 302] = "JSDocCallbackTag"; + SyntaxKind[SyntaxKind["JSDocEnumTag"] = 303] = "JSDocEnumTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 304] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 305] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocThisTag"] = 306] = "JSDocThisTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 307] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 308] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 309] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 310] = "JSDocPropertyTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 306] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 311] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 307] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 308] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["CommaListExpression"] = 309] = "CommaListExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 310] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 311] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 312] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 313] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["CommaListExpression"] = 314] = "CommaListExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 315] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 316] = "EndOfDeclarationMarker"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 312] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 317] = "Count"; // Markers SyntaxKind[SyntaxKind["FirstAssignment"] = 59] = "FirstAssignment"; SyntaxKind[SyntaxKind["LastAssignment"] = 71] = "LastAssignment"; @@ -2934,10 +2940,10 @@ var ts; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 28] = "FirstBinaryOperator"; SyntaxKind[SyntaxKind["LastBinaryOperator"] = 71] = "LastBinaryOperator"; SyntaxKind[SyntaxKind["FirstNode"] = 148] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 283] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 305] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 294] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 305] = "LastJSDocTagNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 288] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 310] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 299] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 310] = "LastJSDocTagNode"; /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 118] = "FirstContextualKeyword"; /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 147] = "LastContextualKeyword"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); @@ -3814,6 +3820,7 @@ var ts; Extension["Js"] = ".js"; Extension["Jsx"] = ".jsx"; Extension["Json"] = ".json"; + Extension["TsBuildInfo"] = ".tsbuildinfo"; })(Extension = ts.Extension || (ts.Extension = {})); /* @internal */ var TransformFlags; @@ -3971,6 +3978,20 @@ var ts; EmitHint[EmitHint["Unspecified"] = 4] = "Unspecified"; EmitHint[EmitHint["EmbeddedStatement"] = 5] = "EmbeddedStatement"; })(EmitHint = ts.EmitHint || (ts.EmitHint = {})); + /*@internal*/ + var BundleFileSectionKind; + (function (BundleFileSectionKind) { + BundleFileSectionKind["Prologue"] = "prologue"; + BundleFileSectionKind["EmitHelpers"] = "emitHelpers"; + BundleFileSectionKind["NoDefaultLib"] = "no-default-lib"; + BundleFileSectionKind["Reference"] = "reference"; + BundleFileSectionKind["Type"] = "type"; + BundleFileSectionKind["Lib"] = "lib"; + BundleFileSectionKind["Prepend"] = "prepend"; + BundleFileSectionKind["Text"] = "text"; + BundleFileSectionKind["Internal"] = "internal"; + // comments? + })(BundleFileSectionKind = ts.BundleFileSectionKind || (ts.BundleFileSectionKind = {})); var ListFormat; (function (ListFormat) { ListFormat[ListFormat["None"] = 0] = "None"; @@ -6100,6 +6121,15 @@ var ts; Option_build_must_be_the_first_command_line_argument: diag(6369, ts.DiagnosticCategory.Error, "Option_build_must_be_the_first_command_line_argument_6369", "Option '--build' must be the first command line argument."), Options_0_and_1_cannot_be_combined: diag(6370, ts.DiagnosticCategory.Error, "Options_0_and_1_cannot_be_combined_6370", "Options '{0}' and '{1}' cannot be combined."), Updating_unchanged_output_timestamps_of_project_0: diag(6371, ts.DiagnosticCategory.Message, "Updating_unchanged_output_timestamps_of_project_0_6371", "Updating unchanged output timestamps of project '{0}'..."), + Project_0_is_out_of_date_because_output_of_its_dependency_1_has_changed: diag(6372, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_output_of_its_dependency_1_has_changed_6372", "Project '{0}' is out of date because output of its dependency '{1}' has changed"), + Updating_output_of_project_0: diag(6373, ts.DiagnosticCategory.Message, "Updating_output_of_project_0_6373", "Updating output of project '{0}'..."), + A_non_dry_build_would_update_timestamps_for_output_of_project_0: diag(6374, ts.DiagnosticCategory.Message, "A_non_dry_build_would_update_timestamps_for_output_of_project_0_6374", "A non-dry build would update timestamps for output of project '{0}'"), + A_non_dry_build_would_update_output_of_project_0: diag(6375, ts.DiagnosticCategory.Message, "A_non_dry_build_would_update_output_of_project_0_6375", "A non-dry build would update output of project '{0}'"), + Cannot_update_output_of_project_0_because_there_was_error_reading_file_1: diag(6376, ts.DiagnosticCategory.Message, "Cannot_update_output_of_project_0_because_there_was_error_reading_file_1_6376", "Cannot update output of project '{0}' because there was error reading file '{1}'"), + Cannot_write_file_0_because_it_will_overwrite_tsbuildinfo_file_generated_by_referenced_project_1: diag(6377, ts.DiagnosticCategory.Error, "Cannot_write_file_0_because_it_will_overwrite_tsbuildinfo_file_generated_by_referenced_project_1_6377", "Cannot write file '{0}' because it will overwrite '.tsbuildinfo' file generated by referenced project '{1}'"), + Enable_incremental_compilation: diag(6378, ts.DiagnosticCategory.Message, "Enable_incremental_compilation_6378", "Enable incremental compilation"), + Composite_projects_may_not_disable_incremental_compilation: diag(6379, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_incremental_compilation_6379", "Composite projects may not disable incremental compilation."), + Specify_file_to_store_incremental_compilation_information: diag(6380, ts.DiagnosticCategory.Message, "Specify_file_to_store_incremental_compilation_information_6380", "Specify file to store incremental compilation information"), The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: diag(6500, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1_6500", "The expected type comes from property '{0}' which is declared here on type '{1}'"), The_expected_type_comes_from_this_index_signature: diag(6501, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_this_index_signature_6501", "The expected type comes from this index signature."), The_expected_type_comes_from_the_return_type_of_this_signature: diag(6502, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_the_return_type_of_this_signature_6502", "The expected type comes from the return type of this signature."), @@ -6803,16 +6833,20 @@ var ts; return pos; } var shebangTriviaRegex = /^#!.*/; + /*@internal*/ function isShebangTrivia(text, pos) { // Shebangs check must only be done at the start of the file ts.Debug.assert(pos === 0); return shebangTriviaRegex.test(text); } + ts.isShebangTrivia = isShebangTrivia; + /*@internal*/ function scanShebangTrivia(text, pos) { var shebang = shebangTriviaRegex.exec(text)[0]; pos = pos + shebang.length; return pos; } + ts.scanShebangTrivia = scanShebangTrivia; /** * Invokes a callback for each comment range following the provided position. * @@ -8522,7 +8556,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 279 /* SourceFile */) { + while (node && node.kind !== 284 /* SourceFile */) { node = node.parent; } return node; @@ -8668,7 +8702,7 @@ var ts; // the syntax list itself considers them as normal trivia. Therefore if we simply skip // trivia for the list, we may have skipped the JSDocComment as well. So we should process its // first child to determine the actual position of its first token. - if (node.kind === 306 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 311 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); @@ -8687,7 +8721,7 @@ var ts; } ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; function isJSDocTypeExpressionOrChild(node) { - return node.kind === 283 /* JSDocTypeExpression */ || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); + return node.kind === 288 /* JSDocTypeExpression */ || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); } function getTextOfNodeFromSourceText(sourceText, node, includeTrivia) { if (includeTrivia === void 0) { includeTrivia = false; } @@ -8814,7 +8848,7 @@ var ts; return node && node.kind === 244 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 279 /* SourceFile */ || + return node.kind === 284 /* SourceFile */ || node.kind === 244 /* ModuleDeclaration */ || ts.isFunctionLike(node); } @@ -8832,7 +8866,7 @@ var ts; // - defined in the top level scope and source file is an external module // - defined inside ambient module declaration located in the top level scope and source file not an external module switch (node.parent.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: return ts.isExternalModule(node.parent); case 245 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); @@ -8850,7 +8884,7 @@ var ts; ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: case 246 /* CaseBlock */: case 274 /* CatchClause */: case 244 /* ModuleDeclaration */: @@ -8875,9 +8909,9 @@ var ts; ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 297 /* JSDocCallbackTag */: - case 304 /* JSDocTypedefTag */: - case 293 /* JSDocSignature */: + case 302 /* JSDocCallbackTag */: + case 309 /* JSDocTypedefTag */: + case 298 /* JSDocSignature */: return true; default: ts.assertType(node); @@ -8893,12 +8927,12 @@ var ts; case 162 /* IndexSignature */: case 165 /* FunctionType */: case 166 /* ConstructorType */: - case 289 /* JSDocFunctionType */: + case 294 /* JSDocFunctionType */: case 240 /* ClassDeclaration */: case 209 /* ClassExpression */: case 241 /* InterfaceDeclaration */: case 242 /* TypeAliasDeclaration */: - case 303 /* JSDocTemplateTag */: + case 308 /* JSDocTemplateTag */: case 239 /* FunctionDeclaration */: case 156 /* MethodDeclaration */: case 157 /* Constructor */: @@ -9043,7 +9077,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: var pos_1 = ts.skipTrivia(sourceFile.text, 0, /*stopAfterLineBreak*/ false); if (pos_1 === sourceFile.text.length) { // file is empty - return span for the beginning of the file @@ -9218,7 +9252,7 @@ var ts; return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); case 150 /* TypeParameter */: return node === parent.constraint; - case 303 /* JSDocTemplateTag */: + case 308 /* JSDocTemplateTag */: return node === parent.constraint; case 154 /* PropertyDeclaration */: case 153 /* PropertySignature */: @@ -9478,7 +9512,7 @@ var ts; } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 279 /* SourceFile */); + ts.Debug.assert(node.kind !== 284 /* SourceFile */); while (true) { node = node.parent; if (!node) { @@ -9532,7 +9566,7 @@ var ts; case 161 /* ConstructSignature */: case 162 /* IndexSignature */: case 243 /* EnumDeclaration */: - case 279 /* SourceFile */: + case 284 /* SourceFile */: return node; } } @@ -10240,7 +10274,7 @@ var ts; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 304 /* JSDocTypedefTag */ || node.kind === 297 /* JSDocCallbackTag */; + return node.kind === 309 /* JSDocTypedefTag */ || node.kind === 302 /* JSDocCallbackTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -10384,7 +10418,7 @@ var ts; ts.hasRestParameter = hasRestParameter; function isRestParameter(node) { var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type; - return node.dotDotDotToken !== undefined || !!type && type.kind === 290 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 295 /* JSDocVariadicType */; } ts.isRestParameter = isRestParameter; var AssignmentKind; @@ -10869,7 +10903,7 @@ var ts; || kind === 158 /* GetAccessor */ || kind === 159 /* SetAccessor */ || kind === 244 /* ModuleDeclaration */ - || kind === 279 /* SourceFile */; + || kind === 284 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -10946,7 +10980,7 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 309 /* CommaListExpression */: + case 314 /* CommaListExpression */: return 0; case 208 /* SpreadElement */: return 1; @@ -11264,6 +11298,9 @@ var ts; lineStart = true; } } + function getTextPosWithWriteLine() { + return lineStart ? output.length : (output.length + newLine.length); + } reset(); return { write: write, @@ -11292,7 +11329,8 @@ var ts; writeStringLiteral: write, writeSymbol: function (s, _) { return write(s); }, writeTrailingSemicolon: write, - writeComment: write + writeComment: write, + getTextPosWithWriteLine: getTextPosWithWriteLine }; } ts.createTextWriter = createTextWriter; @@ -11583,7 +11621,7 @@ var ts; ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations; /** template tags are only available when a typedef isn't already using them */ function isNonTypeAliasTemplate(tag) { - return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 291 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 296 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node @@ -12555,19 +12593,29 @@ var ts; || kind === 96 /* NullKeyword */ || kind === 132 /* NeverKeyword */ || kind === 211 /* ExpressionWithTypeArguments */ - || kind === 284 /* JSDocAllType */ - || kind === 285 /* JSDocUnknownType */ - || kind === 286 /* JSDocNullableType */ - || kind === 287 /* JSDocNonNullableType */ - || kind === 288 /* JSDocOptionalType */ - || kind === 289 /* JSDocFunctionType */ - || kind === 290 /* JSDocVariadicType */; + || kind === 289 /* JSDocAllType */ + || kind === 290 /* JSDocUnknownType */ + || kind === 291 /* JSDocNullableType */ + || kind === 292 /* JSDocNonNullableType */ + || kind === 293 /* JSDocOptionalType */ + || kind === 294 /* JSDocFunctionType */ + || kind === 295 /* JSDocVariadicType */; } ts.isTypeNodeKind = isTypeNodeKind; function isAccessExpression(node) { return node.kind === 189 /* PropertyAccessExpression */ || node.kind === 190 /* ElementAccessExpression */; } ts.isAccessExpression = isAccessExpression; + function isBundleFileTextLike(section) { + switch (section.kind) { + case "text" /* Text */: + case "internal" /* Internal */: + return true; + default: + return false; + } + } + ts.isBundleFileTextLike = isBundleFileTextLike; })(ts || (ts = {})); (function (ts) { function getDefaultLibFileName(options) { @@ -13029,8 +13077,8 @@ var ts; switch (declaration.kind) { case 72 /* Identifier */: return declaration; - case 305 /* JSDocPropertyTag */: - case 299 /* JSDocParameterTag */: { + case 310 /* JSDocPropertyTag */: + case 304 /* JSDocParameterTag */: { var name = declaration.name; if (name.kind === 148 /* QualifiedName */) { return name.right; @@ -13054,7 +13102,7 @@ var ts; return undefined; } } - case 304 /* JSDocTypedefTag */: + case 309 /* JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); case 254 /* ExportAssignment */: { var expression = declaration.expression; @@ -13258,7 +13306,7 @@ var ts; return ts.emptyArray; } if (ts.isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 291 /* JSDocComment */); + ts.Debug.assert(node.parent.kind === 296 /* JSDocComment */); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } if (node.typeParameters) { @@ -13530,7 +13578,7 @@ var ts; } ts.isParenthesizedExpression = isParenthesizedExpression; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 308 /* PartiallyEmittedExpression */) { + while (node.kind === 313 /* PartiallyEmittedExpression */) { node = node.expression; } return node; @@ -13877,108 +13925,128 @@ var ts; ts.isEnumMember = isEnumMember; // Top-level nodes function isSourceFile(node) { - return node.kind === 279 /* SourceFile */; + return node.kind === 284 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 280 /* Bundle */; + return node.kind === 285 /* Bundle */; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 281 /* UnparsedSource */; + return node.kind === 286 /* UnparsedSource */; } ts.isUnparsedSource = isUnparsedSource; + function isUnparsedPrepend(node) { + return node.kind === 280 /* UnparsedPrepend */; + } + ts.isUnparsedPrepend = isUnparsedPrepend; + function isUnparsedTextLike(node) { + switch (node.kind) { + case 281 /* UnparsedText */: + case 282 /* UnparsedInternalText */: + return true; + default: + return false; + } + } + ts.isUnparsedTextLike = isUnparsedTextLike; + function isUnparsedNode(node) { + return isUnparsedTextLike(node) || + node.kind === 279 /* UnparsedPrologue */ || + node.kind === 283 /* UnparsedSyntheticReference */; + } + ts.isUnparsedNode = isUnparsedNode; // JSDoc function isJSDocTypeExpression(node) { - return node.kind === 283 /* JSDocTypeExpression */; + return node.kind === 288 /* JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocAllType(node) { - return node.kind === 284 /* JSDocAllType */; + return node.kind === 289 /* JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 285 /* JSDocUnknownType */; + return node.kind === 290 /* JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 286 /* JSDocNullableType */; + return node.kind === 291 /* JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 287 /* JSDocNonNullableType */; + return node.kind === 292 /* JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 288 /* JSDocOptionalType */; + return node.kind === 293 /* JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 289 /* JSDocFunctionType */; + return node.kind === 294 /* JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 290 /* JSDocVariadicType */; + return node.kind === 295 /* JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDoc(node) { - return node.kind === 291 /* JSDocComment */; + return node.kind === 296 /* JSDocComment */; } ts.isJSDoc = isJSDoc; function isJSDocAugmentsTag(node) { - return node.kind === 295 /* JSDocAugmentsTag */; + return node.kind === 300 /* JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocClassTag(node) { - return node.kind === 296 /* JSDocClassTag */; + return node.kind === 301 /* JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocEnumTag(node) { - return node.kind === 298 /* JSDocEnumTag */; + return node.kind === 303 /* JSDocEnumTag */; } ts.isJSDocEnumTag = isJSDocEnumTag; function isJSDocThisTag(node) { - return node.kind === 301 /* JSDocThisTag */; + return node.kind === 306 /* JSDocThisTag */; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocParameterTag(node) { - return node.kind === 299 /* JSDocParameterTag */; + return node.kind === 304 /* JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 300 /* JSDocReturnTag */; + return node.kind === 305 /* JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocTypeTag(node) { - return node.kind === 302 /* JSDocTypeTag */; + return node.kind === 307 /* JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 303 /* JSDocTemplateTag */; + return node.kind === 308 /* JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 304 /* JSDocTypedefTag */; + return node.kind === 309 /* JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocPropertyTag(node) { - return node.kind === 305 /* JSDocPropertyTag */; + return node.kind === 310 /* JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocPropertyLikeTag(node) { - return node.kind === 305 /* JSDocPropertyTag */ || node.kind === 299 /* JSDocParameterTag */; + return node.kind === 310 /* JSDocPropertyTag */ || node.kind === 304 /* JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; function isJSDocTypeLiteral(node) { - return node.kind === 292 /* JSDocTypeLiteral */; + return node.kind === 297 /* JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocCallbackTag(node) { - return node.kind === 297 /* JSDocCallbackTag */; + return node.kind === 302 /* JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocSignature(node) { - return node.kind === 293 /* JSDocSignature */; + return node.kind === 298 /* JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; })(ts || (ts = {})); @@ -13989,7 +14057,7 @@ var ts; (function (ts) { /* @internal */ function isSyntaxList(n) { - return n.kind === 306 /* SyntaxList */; + return n.kind === 311 /* SyntaxList */; } ts.isSyntaxList = isSyntaxList; /* @internal */ @@ -14141,11 +14209,11 @@ var ts; switch (kind) { case 155 /* MethodSignature */: case 160 /* CallSignature */: - case 293 /* JSDocSignature */: + case 298 /* JSDocSignature */: case 161 /* ConstructSignature */: case 162 /* IndexSignature */: case 165 /* FunctionType */: - case 289 /* JSDocFunctionType */: + case 294 /* JSDocFunctionType */: case 166 /* ConstructorType */: return true; default: @@ -14436,8 +14504,8 @@ var ts; case 208 /* SpreadElement */: case 212 /* AsExpression */: case 210 /* OmittedExpression */: - case 309 /* CommaListExpression */: - case 308 /* PartiallyEmittedExpression */: + case 314 /* CommaListExpression */: + case 313 /* PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -14451,12 +14519,12 @@ var ts; ts.isAssertionExpression = isAssertionExpression; /* @internal */ function isPartiallyEmittedExpression(node) { - return node.kind === 308 /* PartiallyEmittedExpression */; + return node.kind === 313 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; /* @internal */ function isNotEmittedStatement(node) { - return node.kind === 307 /* NotEmittedStatement */; + return node.kind === 312 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ @@ -14567,9 +14635,9 @@ var ts; || kind === 242 /* TypeAliasDeclaration */ || kind === 150 /* TypeParameter */ || kind === 237 /* VariableDeclaration */ - || kind === 304 /* JSDocTypedefTag */ - || kind === 297 /* JSDocCallbackTag */ - || kind === 305 /* JSDocPropertyTag */; + || kind === 309 /* JSDocTypedefTag */ + || kind === 302 /* JSDocCallbackTag */ + || kind === 310 /* JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { return kind === 239 /* FunctionDeclaration */ @@ -14604,14 +14672,14 @@ var ts; || kind === 219 /* VariableStatement */ || kind === 224 /* WhileStatement */ || kind === 231 /* WithStatement */ - || kind === 307 /* NotEmittedStatement */ - || kind === 311 /* EndOfDeclarationMarker */ - || kind === 310 /* MergeDeclarationMarker */; + || kind === 312 /* NotEmittedStatement */ + || kind === 316 /* EndOfDeclarationMarker */ + || kind === 315 /* MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { if (node.kind === 150 /* TypeParameter */) { - return node.parent.kind !== 303 /* JSDocTemplateTag */ || ts.isInJSFile(node); + return (node.parent && node.parent.kind !== 308 /* JSDocTemplateTag */) || ts.isInJSFile(node); } return isDeclarationKind(node.kind); } @@ -14706,18 +14774,18 @@ var ts; /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 283 /* FirstJSDocNode */ && node.kind <= 305 /* LastJSDocNode */; + return node.kind >= 288 /* FirstJSDocNode */ && node.kind <= 310 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 291 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 296 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); } ts.isJSDocCommentContainingNode = isJSDocCommentContainingNode; // TODO: determine what this does before making it public. /* @internal */ function isJSDocTag(node) { - return node.kind >= 294 /* FirstJSDocTagNode */ && node.kind <= 305 /* LastJSDocTagNode */; + return node.kind >= 299 /* FirstJSDocTagNode */ && node.kind <= 310 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { @@ -15034,6 +15102,10 @@ var ts; return !!(compilerOptions.declaration || compilerOptions.composite); } ts.getEmitDeclarations = getEmitDeclarations; + function isIncrementalCompilation(options) { + return !!(options.incremental || options.composite); + } + ts.isIncrementalCompilation = isIncrementalCompilation; function getStrictOptionValue(compilerOptions, flag) { return compilerOptions[flag] === undefined ? !!compilerOptions.strict : !!compilerOptions[flag]; } @@ -16318,7 +16390,7 @@ var ts; var SourceFileConstructor; // tslint:enable variable-name function createNode(kind, pos, end) { - if (kind === 279 /* SourceFile */) { + if (kind === 284 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else if (kind === 72 /* Identifier */) { @@ -16569,7 +16641,7 @@ var ts; case 218 /* Block */: case 245 /* ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 279 /* SourceFile */: + case 284 /* SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); case 219 /* VariableStatement */: @@ -16718,7 +16790,7 @@ var ts; return visitNode(cbNode, node.expression); case 258 /* MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators); - case 309 /* CommaListExpression */: + case 314 /* CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); case 260 /* JsxElement */: return visitNode(cbNode, node.openingElement) || @@ -16747,60 +16819,60 @@ var ts; return visitNode(cbNode, node.tagName); case 171 /* OptionalType */: case 172 /* RestType */: - case 283 /* JSDocTypeExpression */: - case 287 /* JSDocNonNullableType */: - case 286 /* JSDocNullableType */: - case 288 /* JSDocOptionalType */: - case 290 /* JSDocVariadicType */: + case 288 /* JSDocTypeExpression */: + case 292 /* JSDocNonNullableType */: + case 291 /* JSDocNullableType */: + case 293 /* JSDocOptionalType */: + case 295 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 289 /* JSDocFunctionType */: + case 294 /* JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 291 /* JSDocComment */: + case 296 /* JSDocComment */: return visitNodes(cbNode, cbNodes, node.tags); - case 299 /* JSDocParameterTag */: - case 305 /* JSDocPropertyTag */: + case 304 /* JSDocParameterTag */: + case 310 /* JSDocPropertyTag */: return visitNode(cbNode, node.tagName) || (node.isNameFirst ? visitNode(cbNode, node.name) || visitNode(cbNode, node.typeExpression) : visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name)); - case 295 /* JSDocAugmentsTag */: + case 300 /* JSDocAugmentsTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.class); - case 303 /* JSDocTemplateTag */: + case 308 /* JSDocTemplateTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.constraint) || visitNodes(cbNode, cbNodes, node.typeParameters); - case 304 /* JSDocTypedefTag */: + case 309 /* JSDocTypedefTag */: return visitNode(cbNode, node.tagName) || (node.typeExpression && - node.typeExpression.kind === 283 /* JSDocTypeExpression */ + node.typeExpression.kind === 288 /* JSDocTypeExpression */ ? visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) : visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression)); - case 297 /* JSDocCallbackTag */: + case 302 /* JSDocCallbackTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); - case 300 /* JSDocReturnTag */: - case 302 /* JSDocTypeTag */: - case 301 /* JSDocThisTag */: - case 298 /* JSDocEnumTag */: + case 305 /* JSDocReturnTag */: + case 307 /* JSDocTypeTag */: + case 306 /* JSDocThisTag */: + case 303 /* JSDocEnumTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.typeExpression); - case 293 /* JSDocSignature */: + case 298 /* JSDocSignature */: return ts.forEach(node.typeParameters, cbNode) || ts.forEach(node.parameters, cbNode) || visitNode(cbNode, node.type); - case 292 /* JSDocTypeLiteral */: + case 297 /* JSDocTypeLiteral */: return ts.forEach(node.jsDocPropertyTags, cbNode); - case 294 /* JSDocTag */: - case 296 /* JSDocClassTag */: + case 299 /* JSDocTag */: + case 301 /* JSDocClassTag */: return visitNode(cbNode, node.tagName); - case 308 /* PartiallyEmittedExpression */: + case 313 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -17174,7 +17246,7 @@ var ts; function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile) { // code from createNode is inlined here so createNode won't have to deal with special case of creating source files // this is quite rare comparing to other nodes and createNode should be as fast as possible - var sourceFile = new SourceFileConstructor(279 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); + var sourceFile = new SourceFileConstructor(284 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -18374,9 +18446,9 @@ var ts; return finishNode(node); } function parseJSDocAllType(postFixEquals) { - var result = createNode(284 /* JSDocAllType */); + var result = createNode(289 /* JSDocAllType */); if (postFixEquals) { - return createPostfixType(288 /* JSDocOptionalType */, result); + return createPostfixType(293 /* JSDocOptionalType */, result); } else { nextToken(); @@ -18384,7 +18456,7 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(287 /* JSDocNonNullableType */); + var result = createNode(292 /* JSDocNonNullableType */); nextToken(); result.type = parseNonArrayType(); return finishNode(result); @@ -18408,18 +18480,18 @@ var ts; token() === 30 /* GreaterThanToken */ || token() === 59 /* EqualsToken */ || token() === 50 /* BarToken */) { - var result = createNode(285 /* JSDocUnknownType */, pos); + var result = createNode(290 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(286 /* JSDocNullableType */, pos); + var result = createNode(291 /* JSDocNullableType */, pos); result.type = parseType(); return finishNode(result); } } function parseJSDocFunctionType() { if (lookAhead(nextTokenIsOpenParen)) { - var result = createNodeWithJSDoc(289 /* JSDocFunctionType */); + var result = createNodeWithJSDoc(294 /* JSDocFunctionType */); nextToken(); fillSignature(57 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result); return finishNode(result); @@ -18443,12 +18515,12 @@ var ts; var type = parseTypeOrTypePredicate(); scanner.setInJSDocType(false); if (dotdotdot) { - var variadic = createNode(290 /* JSDocVariadicType */, dotdotdot.pos); + var variadic = createNode(295 /* JSDocVariadicType */, dotdotdot.pos); variadic.type = type; type = finishNode(variadic); } if (token() === 59 /* EqualsToken */) { - return createPostfixType(288 /* JSDocOptionalType */, type); + return createPostfixType(293 /* JSDocOptionalType */, type); } return type; } @@ -18820,7 +18892,7 @@ var ts; return finishNode(node); } var type = parseType(); - if (!(contextFlags & 2097152 /* JSDoc */) && type.kind === 286 /* JSDocNullableType */ && type.pos === type.type.pos) { + if (!(contextFlags & 2097152 /* JSDoc */) && type.kind === 291 /* JSDocNullableType */ && type.pos === type.type.pos) { type.kind = 171 /* OptionalType */; } return type; @@ -19007,14 +19079,14 @@ var ts; while (!scanner.hasPrecedingLineBreak()) { switch (token()) { case 52 /* ExclamationToken */: - type = createPostfixType(287 /* JSDocNonNullableType */, type); + type = createPostfixType(292 /* JSDocNonNullableType */, type); break; case 56 /* QuestionToken */: // If not in JSDoc and next token is start of a type we have a conditional type if (!(contextFlags & 2097152 /* JSDoc */) && lookAhead(nextTokenIsStartOfType)) { return type; } - type = createPostfixType(286 /* JSDocNullableType */, type); + type = createPostfixType(291 /* JSDocNullableType */, type); break; case 22 /* OpenBracketToken */: parseExpected(22 /* OpenBracketToken */); @@ -21951,7 +22023,7 @@ var ts; JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; // Parses out a JSDoc type expression. function parseJSDocTypeExpression(mayOmitBraces) { - var result = createNode(283 /* JSDocTypeExpression */); + var result = createNode(288 /* JSDocTypeExpression */); var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* OpenBraceToken */); result.type = doInsideOfContext(2097152 /* JSDoc */, parseJSDocType); if (!mayOmitBraces || hasBrace) { @@ -22114,7 +22186,7 @@ var ts; } } function createJSDocComment() { - var result = createNode(291 /* JSDocComment */, start); + var result = createNode(296 /* JSDocComment */, start); result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -22281,7 +22353,7 @@ var ts; return comments.length === 0 ? undefined : comments.join(""); } function parseUnknownTag(start, tagName) { - var result = createNode(294 /* JSDocTag */, start); + var result = createNode(299 /* JSDocTag */, start); result.tagName = tagName; return finishNode(result); } @@ -22340,8 +22412,8 @@ var ts; typeExpression = tryParseTypeExpression(); } var result = target === 1 /* Property */ ? - createNode(305 /* JSDocPropertyTag */, start) : - createNode(299 /* JSDocParameterTag */, start); + createNode(310 /* JSDocPropertyTag */, start) : + createNode(304 /* JSDocParameterTag */, start); var comment = parseTagComments(indent + scanner.getStartPos() - start); var nestedTypeLiteral = target !== 4 /* CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target, indent); if (nestedTypeLiteral) { @@ -22358,18 +22430,18 @@ var ts; } function parseNestedTypeLiteral(typeExpression, name, target, indent) { if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) { - var typeLiteralExpression = createNode(283 /* JSDocTypeExpression */, scanner.getTokenPos()); + var typeLiteralExpression = createNode(288 /* JSDocTypeExpression */, scanner.getTokenPos()); var child = void 0; var jsdocTypeLiteral = void 0; var start_2 = scanner.getStartPos(); var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) { - if (child.kind === 299 /* JSDocParameterTag */ || child.kind === 305 /* JSDocPropertyTag */) { + if (child.kind === 304 /* JSDocParameterTag */ || child.kind === 310 /* JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - jsdocTypeLiteral = createNode(292 /* JSDocTypeLiteral */, start_2); + jsdocTypeLiteral = createNode(297 /* JSDocTypeLiteral */, start_2); jsdocTypeLiteral.jsDocPropertyTags = children; if (typeExpression.type.kind === 169 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; @@ -22380,25 +22452,25 @@ var ts; } } function parseReturnTag(start, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 300 /* JSDocReturnTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 305 /* JSDocReturnTag */; })) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(300 /* JSDocReturnTag */, start); + var result = createNode(305 /* JSDocReturnTag */, start); result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); } function parseTypeTag(start, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 302 /* JSDocTypeTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 307 /* JSDocTypeTag */; })) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(302 /* JSDocTypeTag */, start); + var result = createNode(307 /* JSDocTypeTag */, start); result.tagName = tagName; result.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); return finishNode(result); } function parseAugmentsTag(start, tagName) { - var result = createNode(295 /* JSDocAugmentsTag */, start); + var result = createNode(300 /* JSDocAugmentsTag */, start); result.tagName = tagName; result.class = parseExpressionWithTypeArgumentsForAugments(); return finishNode(result); @@ -22425,19 +22497,19 @@ var ts; return node; } function parseClassTag(start, tagName) { - var tag = createNode(296 /* JSDocClassTag */, start); + var tag = createNode(301 /* JSDocClassTag */, start); tag.tagName = tagName; return finishNode(tag); } function parseThisTag(start, tagName) { - var tag = createNode(301 /* JSDocThisTag */, start); + var tag = createNode(306 /* JSDocThisTag */, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); return finishNode(tag); } function parseEnumTag(start, tagName) { - var tag = createNode(298 /* JSDocEnumTag */, start); + var tag = createNode(303 /* JSDocEnumTag */, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); @@ -22446,7 +22518,7 @@ var ts; function parseTypedefTag(start, tagName, indent) { var typeExpression = tryParseTypeExpression(); skipWhitespaceOrAsterisk(); - var typedefTag = createNode(304 /* JSDocTypedefTag */, start); + var typedefTag = createNode(309 /* JSDocTypedefTag */, start); typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(); typedefTag.name = getJSDocTypeAliasName(typedefTag.fullName); @@ -22460,9 +22532,9 @@ var ts; var childTypeTag = void 0; while (child = tryParse(function () { return parseChildPropertyTag(indent); })) { if (!jsdocTypeLiteral) { - jsdocTypeLiteral = createNode(292 /* JSDocTypeLiteral */, start); + jsdocTypeLiteral = createNode(297 /* JSDocTypeLiteral */, start); } - if (child.kind === 302 /* JSDocTypeTag */) { + if (child.kind === 307 /* JSDocTypeTag */) { if (childTypeTag) { break; } @@ -22508,14 +22580,14 @@ var ts; return typeNameOrNamespaceName; } function parseCallbackTag(start, tagName, indent) { - var callbackTag = createNode(297 /* JSDocCallbackTag */, start); + var callbackTag = createNode(302 /* JSDocCallbackTag */, start); callbackTag.tagName = tagName; callbackTag.fullName = parseJSDocTypeNameWithNamespace(); callbackTag.name = getJSDocTypeAliasName(callbackTag.fullName); skipWhitespace(); callbackTag.comment = parseTagComments(indent); var child; - var jsdocSignature = createNode(293 /* JSDocSignature */, start); + var jsdocSignature = createNode(298 /* JSDocSignature */, start); jsdocSignature.parameters = []; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* CallbackParameter */, indent); })) { jsdocSignature.parameters = ts.append(jsdocSignature.parameters, child); @@ -22523,7 +22595,7 @@ var ts; var returnTag = tryParse(function () { if (parseOptionalJsdoc(58 /* AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 300 /* JSDocReturnTag */) { + if (tag && tag.kind === 305 /* JSDocReturnTag */) { return tag; } } @@ -22568,7 +22640,7 @@ var ts; case 58 /* AtToken */: if (canParseTag) { var child = tryParseChildTag(target, indent); - if (child && (child.kind === 299 /* JSDocParameterTag */ || child.kind === 305 /* JSDocPropertyTag */) && + if (child && (child.kind === 304 /* JSDocParameterTag */ || child.kind === 310 /* JSDocPropertyTag */) && target !== 4 /* CallbackParameter */ && name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; @@ -22638,7 +22710,7 @@ var ts; skipWhitespace(); typeParameters.push(typeParameter); } while (parseOptionalJsdoc(27 /* CommaToken */)); - var result = createNode(303 /* JSDocTemplateTag */, start); + var result = createNode(308 /* JSDocTemplateTag */, start); result.tagName = tagName; result.constraint = constraint; result.typeParameters = createNodeArray(typeParameters, typeParametersPos); @@ -23724,6 +23796,22 @@ var ts; category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Enable_project_compilation, }, + { + name: "incremental", + type: "boolean", + isTSConfigOnly: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Enable_incremental_compilation, + }, + { + name: "tsBuildInfoFile", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.FILE, + isTSConfigOnly: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Specify_file_to_store_incremental_compilation_information, + }, { name: "removeComments", type: "boolean", @@ -27442,7 +27530,7 @@ var ts; return "__constructor" /* Constructor */; case 165 /* FunctionType */: case 160 /* CallSignature */: - case 293 /* JSDocSignature */: + case 298 /* JSDocSignature */: return "__call" /* Call */; case 166 /* ConstructorType */: case 161 /* ConstructSignature */: @@ -27451,7 +27539,7 @@ var ts; return "__index" /* Index */; case 255 /* ExportDeclaration */: return "__export" /* ExportStar */; - case 279 /* SourceFile */: + case 284 /* SourceFile */: // json file should behave as // module.exports = ... return "export=" /* ExportEquals */; @@ -27462,12 +27550,12 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 289 /* JSDocFunctionType */: + case 294 /* JSDocFunctionType */: return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); case 151 /* Parameter */: // Parameters with names are handled at the top of this function. Parameters // without names can only come from JSDocFunctionTypes. - ts.Debug.assert(node.parent.kind === 289 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); + ts.Debug.assert(node.parent.kind === 294 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); var functionType = node.parent; var index = functionType.parameters.indexOf(node); return "arg" + index; @@ -27706,7 +27794,7 @@ var ts; if (hasExplicitReturn) node.flags |= 256 /* HasExplicitReturn */; } - if (node.kind === 279 /* SourceFile */) { + if (node.kind === 284 /* SourceFile */) { node.flags |= emitFlags; } if (currentReturnTarget) { @@ -27850,12 +27938,12 @@ var ts; case 191 /* CallExpression */: bindCallExpressionFlow(node); break; - case 304 /* JSDocTypedefTag */: - case 297 /* JSDocCallbackTag */: + case 309 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: bindJSDocTypeAlias(node); break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 279 /* SourceFile */: { + case 284 /* SourceFile */: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; @@ -28542,7 +28630,7 @@ var ts; case 243 /* EnumDeclaration */: case 188 /* ObjectLiteralExpression */: case 168 /* TypeLiteral */: - case 292 /* JSDocTypeLiteral */: + case 297 /* JSDocTypeLiteral */: case 268 /* JsxAttributes */: return 1 /* IsContainer */; case 241 /* InterfaceDeclaration */: @@ -28551,7 +28639,7 @@ var ts; case 242 /* TypeAliasDeclaration */: case 181 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 279 /* SourceFile */: + case 284 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; case 156 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { @@ -28564,8 +28652,8 @@ var ts; case 158 /* GetAccessor */: case 159 /* SetAccessor */: case 160 /* CallSignature */: - case 293 /* JSDocSignature */: - case 289 /* JSDocFunctionType */: + case 298 /* JSDocSignature */: + case 294 /* JSDocFunctionType */: case 165 /* FunctionType */: case 161 /* ConstructSignature */: case 162 /* IndexSignature */: @@ -28619,7 +28707,7 @@ var ts; // handlers to take care of declaring these child members. case 244 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 279 /* SourceFile */: + case 284 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); case 209 /* ClassExpression */: case 240 /* ClassDeclaration */: @@ -28627,7 +28715,7 @@ var ts; case 243 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); case 168 /* TypeLiteral */: - case 292 /* JSDocTypeLiteral */: + case 297 /* JSDocTypeLiteral */: case 188 /* ObjectLiteralExpression */: case 241 /* InterfaceDeclaration */: case 268 /* JsxAttributes */: @@ -28641,7 +28729,7 @@ var ts; case 166 /* ConstructorType */: case 160 /* CallSignature */: case 161 /* ConstructSignature */: - case 293 /* JSDocSignature */: + case 298 /* JSDocSignature */: case 162 /* IndexSignature */: case 156 /* MethodDeclaration */: case 155 /* MethodSignature */: @@ -28651,9 +28739,9 @@ var ts; case 239 /* FunctionDeclaration */: case 196 /* FunctionExpression */: case 197 /* ArrowFunction */: - case 289 /* JSDocFunctionType */: - case 304 /* JSDocTypedefTag */: - case 297 /* JSDocCallbackTag */: + case 294 /* JSDocFunctionType */: + case 309 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: case 242 /* TypeAliasDeclaration */: case 181 /* MappedType */: // All the children of these container types are never visible through another @@ -28676,8 +28764,8 @@ var ts; : declareSymbol(file.locals, /*parent*/ undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 279 /* SourceFile */ ? node : node.body; - if (body && (body.kind === 279 /* SourceFile */ || body.kind === 245 /* ModuleBlock */)) { + var body = node.kind === 284 /* SourceFile */ ? node : node.body; + if (body && (body.kind === 284 /* SourceFile */ || body.kind === 245 /* ModuleBlock */)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; if (stat.kind === 255 /* ExportDeclaration */ || stat.kind === 254 /* ExportAssignment */) { @@ -28811,7 +28899,7 @@ var ts; case 244 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 279 /* SourceFile */: + case 284 /* SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -28949,7 +29037,7 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 279 /* SourceFile */ && + if (blockScopeContainer.kind !== 284 /* SourceFile */ && blockScopeContainer.kind !== 244 /* ModuleDeclaration */ && !ts.isFunctionLike(blockScopeContainer)) { // We check first if the name is inside class declaration or class expression; if so give explicit message @@ -29224,12 +29312,12 @@ var ts; case 159 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 67187647 /* SetAccessorExcludes */); case 165 /* FunctionType */: - case 289 /* JSDocFunctionType */: - case 293 /* JSDocSignature */: + case 294 /* JSDocFunctionType */: + case 298 /* JSDocSignature */: case 166 /* ConstructorType */: return bindFunctionOrConstructorType(node); case 168 /* TypeLiteral */: - case 292 /* JSDocTypeLiteral */: + case 297 /* JSDocTypeLiteral */: case 181 /* MappedType */: return bindAnonymousTypeWorker(node); case 188 /* ObjectLiteralExpression */: @@ -29288,7 +29376,7 @@ var ts; return bindExportDeclaration(node); case 254 /* ExportAssignment */: return bindExportAssignment(node); - case 279 /* SourceFile */: + case 284 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); case 218 /* Block */: @@ -29298,22 +29386,22 @@ var ts; // falls through case 245 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 299 /* JSDocParameterTag */: - if (node.parent.kind === 293 /* JSDocSignature */) { + case 304 /* JSDocParameterTag */: + if (node.parent.kind === 298 /* JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 292 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 297 /* JSDocTypeLiteral */) { break; } // falls through - case 305 /* JSDocPropertyTag */: + case 310 /* JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 288 /* JSDocOptionalType */ ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 293 /* JSDocOptionalType */ ? 4 /* Property */ | 16777216 /* Optional */ : 4 /* Property */; return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 304 /* JSDocTypedefTag */: - case 297 /* JSDocCallbackTag */: + case 309 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -29485,7 +29573,7 @@ var ts; var symbolTable = ts.hasModifier(thisContainer, 32 /* Static */) ? containingClass.symbol.exports : containingClass.symbol.members; declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */, 0 /* None */, /*isReplaceableByMethod*/ true); break; - case 279 /* SourceFile */: + case 284 /* SourceFile */: // this.property = assignment in a source file -- declare symbol in exports for a module, in locals for a script if (thisContainer.commonJsModuleIndicator) { declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 /* Property */ | 1048576 /* ExportValue */, 0 /* None */); @@ -29502,7 +29590,7 @@ var ts; if (node.expression.kind === 100 /* ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 279 /* SourceFile */) { + else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 284 /* SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -29539,7 +29627,7 @@ var ts; } function bindObjectDefinePropertyAssignment(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]); - var isToplevel = node.parent.parent.kind === 279 /* SourceFile */; + var isToplevel = node.parent.parent.kind === 284 /* SourceFile */; namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false); bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ false); } @@ -29606,8 +29694,8 @@ var ts; function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty) { var namespaceSymbol = lookupSymbolForPropertyAccess(name); var isToplevel = ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 279 /* SourceFile */ - : propertyAccess.parent.parent.kind === 279 /* SourceFile */; + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 284 /* SourceFile */ + : propertyAccess.parent.parent.kind === 284 /* SourceFile */; namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty); bindPotentiallyNewExpandoMemberToNamespace(propertyAccess, namespaceSymbol, isPrototypeProperty); } @@ -29745,7 +29833,7 @@ var ts; } } function bindParameter(node) { - if (node.kind === 299 /* JSDocParameterTag */ && container.kind !== 293 /* JSDocSignature */) { + if (node.kind === 304 /* JSDocParameterTag */ && container.kind !== 298 /* JSDocSignature */) { return; } if (inStrictMode && !(node.flags & 4194304 /* Ambient */)) { @@ -30488,7 +30576,7 @@ var ts; break; case 194 /* TypeAssertionExpression */: case 212 /* AsExpression */: - case 308 /* PartiallyEmittedExpression */: + case 313 /* PartiallyEmittedExpression */: // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; excludeFlags = 536872257 /* OuterExpressionExcludes */; @@ -30689,7 +30777,7 @@ var ts; transformFlags |= 192 /* AssertES2015 */; } break; - case 279 /* SourceFile */: + case 284 /* SourceFile */: if (subtreeFlags & 16384 /* ContainsCapturedLexicalThis */) { transformFlags |= 192 /* AssertES2015 */; } @@ -30769,7 +30857,7 @@ var ts; return 637666625 /* BindingPatternExcludes */; case 194 /* TypeAssertionExpression */: case 212 /* AsExpression */: - case 308 /* PartiallyEmittedExpression */: + case 313 /* PartiallyEmittedExpression */: case 195 /* ParenthesizedExpression */: case 98 /* SuperKeyword */: return 536872257 /* OuterExpressionExcludes */; @@ -31946,7 +32034,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); } function isGlobalSourceFile(node) { - return node.kind === 279 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 284 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -32120,7 +32208,7 @@ var ts; // - parameters are only in the scope of function body // This restriction does not apply to JSDoc comment types because they are parented // at a higher level than type parameters would normally be - if (meaning & result.flags & 67897832 /* Type */ && lastLocation.kind !== 291 /* JSDocComment */) { + if (meaning & result.flags & 67897832 /* Type */ && lastLocation.kind !== 296 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || @@ -32162,14 +32250,14 @@ var ts; } } switch (location.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through case 244 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 279 /* SourceFile */ || ts.isAmbientModule(location)) { + if (location.kind === 284 /* SourceFile */ || ts.isAmbientModule(location)) { // It's an external module. First see if the module has an export default and if the local // name of that export default matches. if (result = moduleExports.get("default" /* Default */)) { @@ -32341,8 +32429,8 @@ var ts; location = location.parent; } break; - case 304 /* JSDocTypedefTag */: - case 297 /* JSDocCallbackTag */: + case 309 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: // js type aliases do not resolve names from their host, so skip past it location = ts.getJSDocHost(location); break; @@ -32361,7 +32449,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 279 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 284 /* SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) { return lastLocation.symbol; } @@ -33217,7 +33305,7 @@ var ts; function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias) { var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 279 /* SourceFile */)) { + if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 284 /* SourceFile */)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; @@ -33568,7 +33656,7 @@ var ts; } } switch (location.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } @@ -33808,10 +33896,10 @@ var ts; return node && getSymbolOfNode(node); } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 279 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 284 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 279 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 284 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -34268,7 +34356,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 279 /* SourceFile */ || declaration.parent.kind === 245 /* ModuleBlock */; + return declaration.parent.kind === 284 /* SourceFile */ || declaration.parent.kind === 245 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -34653,7 +34741,7 @@ var ts; function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) { var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 151 /* Parameter */); if (!parameterDeclaration && !isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 299 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 304 /* JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { @@ -34811,7 +34899,7 @@ var ts; return top; } function getSpecifierForModuleSymbol(symbol, context) { - var file = ts.getDeclarationOfKind(symbol, 279 /* SourceFile */); + var file = ts.getDeclarationOfKind(symbol, 284 /* SourceFile */); if (file && file.moduleName !== undefined) { // Use the amd name if it is available return file.moduleName; @@ -35064,7 +35152,7 @@ var ts; ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 279 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 284 /* SourceFile */ || ts.isAmbientModule(location); } function getNameOfSymbolFromNameType(symbol, context) { var nameType = symbol.nameType; @@ -35141,8 +35229,8 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 297 /* JSDocCallbackTag */: - case 304 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: + case 309 /* JSDocTypedefTag */: // Top-level jsdoc type aliases are considered exported // First parent is comment node, second is hosting declaration or token; we only care about those tokens or declarations whose parent is a source file return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent)); @@ -35169,7 +35257,7 @@ var ts; var parent = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) if (!(ts.getCombinedModifierFlags(node) & 1 /* Export */) && - !(node.kind !== 248 /* ImportEqualsDeclaration */ && parent.kind !== 279 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { + !(node.kind !== 248 /* ImportEqualsDeclaration */ && parent.kind !== 284 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible @@ -35211,7 +35299,7 @@ var ts; // Type parameters are always visible case 150 /* TypeParameter */: // Source file and namespace export are always visible - case 279 /* SourceFile */: + case 284 /* SourceFile */: case 247 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module @@ -36321,15 +36409,15 @@ var ts; case 155 /* MethodSignature */: case 165 /* FunctionType */: case 166 /* ConstructorType */: - case 289 /* JSDocFunctionType */: + case 294 /* JSDocFunctionType */: case 239 /* FunctionDeclaration */: case 156 /* MethodDeclaration */: case 196 /* FunctionExpression */: case 197 /* ArrowFunction */: case 242 /* TypeAliasDeclaration */: - case 303 /* JSDocTemplateTag */: - case 304 /* JSDocTypedefTag */: - case 297 /* JSDocCallbackTag */: + case 308 /* JSDocTemplateTag */: + case 309 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: case 181 /* MappedType */: case 175 /* ConditionalType */: var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); @@ -38321,10 +38409,10 @@ var ts; function isJSDocOptionalParameter(node) { return ts.isInJSFile(node) && ( // node.type should only be a JSDocOptionalType when node is a parameter of a JSDocFunctionType - node.type && node.type.kind === 288 /* JSDocOptionalType */ + node.type && node.type.kind === 293 /* JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 288 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 293 /* JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -38358,7 +38446,7 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 288 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 293 /* JSDocOptionalType */; } function createIdentifierTypePredicate(parameterName, parameterIndex, type) { return { kind: 1 /* Identifier */, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; @@ -39098,7 +39186,7 @@ var ts; } function getConstrainedTypeVariable(typeVariable, node) { var constraints; - while (node && !ts.isStatement(node) && node.kind !== 291 /* JSDocComment */) { + while (node && !ts.isStatement(node) && node.kind !== 296 /* JSDocComment */) { var parent = node.parent; if (parent.kind === 175 /* ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(typeVariable, parent.checkType, parent.extendsType); @@ -40671,8 +40759,8 @@ var ts; function getTypeFromTypeNode(node) { switch (node.kind) { case 120 /* AnyKeyword */: - case 284 /* JSDocAllType */: - case 285 /* JSDocUnknownType */: + case 289 /* JSDocAllType */: + case 290 /* JSDocUnknownType */: return anyType; case 143 /* UnknownKeyword */: return unknownType; @@ -40719,23 +40807,23 @@ var ts; return getTypeFromUnionTypeNode(node); case 174 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 286 /* JSDocNullableType */: + case 291 /* JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 288 /* JSDocOptionalType */: + case 293 /* JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); case 177 /* ParenthesizedType */: case 172 /* RestType */: - case 287 /* JSDocNonNullableType */: - case 283 /* JSDocTypeExpression */: + case 292 /* JSDocNonNullableType */: + case 288 /* JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 290 /* JSDocVariadicType */: + case 295 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); case 165 /* FunctionType */: case 166 /* ConstructorType */: case 168 /* TypeLiteral */: - case 292 /* JSDocTypeLiteral */: - case 289 /* JSDocFunctionType */: - case 293 /* JSDocSignature */: + case 297 /* JSDocTypeLiteral */: + case 294 /* JSDocFunctionType */: + case 298 /* JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); case 179 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); @@ -44096,7 +44184,7 @@ var ts; return; } break; - case 289 /* JSDocFunctionType */: + case 294 /* JSDocFunctionType */: error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; case 239 /* FunctionDeclaration */: @@ -46377,7 +46465,7 @@ var ts; return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || node.kind === 245 /* ModuleBlock */ || - node.kind === 279 /* SourceFile */ || + node.kind === 284 /* SourceFile */ || node.kind === 154 /* PropertyDeclaration */; }); } @@ -46498,7 +46586,7 @@ var ts; // to the constructor in the initializer, we will need to substitute that // binding with an alias as the class name is not in scope. var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); - while (container.kind !== 279 /* SourceFile */) { + while (container.kind !== 284 /* SourceFile */) { if (container.parent === declaration) { if (container.kind === 154 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; @@ -46921,7 +47009,7 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 289 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 294 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -52923,7 +53011,7 @@ var ts; checkAsyncFunctionReturnType(node, returnTypeNode); } } - if (node.kind !== 162 /* IndexSignature */ && node.kind !== 289 /* JSDocFunctionType */) { + if (node.kind !== 162 /* IndexSignature */ && node.kind !== 294 /* JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } @@ -53679,8 +53767,8 @@ var ts; case 241 /* InterfaceDeclaration */: case 242 /* TypeAliasDeclaration */: // A jsdoc typedef and callback are, by definition, type aliases - case 304 /* JSDocTypedefTag */: - case 297 /* JSDocCallbackTag */: + case 309 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: return 2 /* ExportType */; case 244 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ @@ -53689,7 +53777,7 @@ var ts; case 240 /* ClassDeclaration */: case 243 /* EnumDeclaration */: return 2 /* ExportType */ | 1 /* ExportValue */; - case 279 /* SourceFile */: + case 284 /* SourceFile */: return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; case 254 /* ExportAssignment */: // Export assigned entity name expressions act as aliases and should fall through, otherwise they export values @@ -54330,7 +54418,7 @@ var ts; checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 279 /* SourceFile */: + case 284 /* SourceFile */: case 244 /* ModuleDeclaration */: case 218 /* Block */: case 246 /* CaseBlock */: @@ -54677,7 +54765,7 @@ var ts; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 279 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 284 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -54692,7 +54780,7 @@ var ts; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 279 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { + if (parent.kind === 284 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { // If the declaration happens to be in external module, report error that Promise is a reserved identifier. error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -54749,7 +54837,7 @@ var ts; (container.kind === 218 /* Block */ && ts.isFunctionLike(container.parent) || container.kind === 245 /* ModuleBlock */ || container.kind === 244 /* ModuleDeclaration */ || - container.kind === 279 /* SourceFile */); + container.kind === 284 /* SourceFile */); // here we know that function scoped variable is shadowed by block scoped one // if they are defined in the same scope - binder has already reported redeclaration error // otherwise if variable has an initializer - show error that initialization will fail @@ -56599,7 +56687,7 @@ var ts; return false; } var inAmbientExternalModule = node.parent.kind === 245 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 279 /* SourceFile */ && !inAmbientExternalModule) { + if (node.parent.kind !== 284 /* SourceFile */ && !inAmbientExternalModule) { error(moduleName, node.kind === 255 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); @@ -56730,7 +56818,7 @@ var ts; var inAmbientExternalModule = node.parent.kind === 245 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 245 /* ModuleBlock */ && !node.moduleSpecifier && node.flags & 4194304 /* Ambient */; - if (node.parent.kind !== 279 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + if (node.parent.kind !== 284 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -56747,7 +56835,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 279 /* SourceFile */ || node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 244 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 284 /* SourceFile */ || node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 244 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -56776,7 +56864,7 @@ var ts; // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 279 /* SourceFile */ ? node.parent : node.parent.parent; + var container = node.parent.kind === 284 /* SourceFile */ ? node.parent : node.parent.parent; if (container.kind === 244 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); @@ -56946,32 +57034,32 @@ var ts; return checkInferType(node); case 183 /* ImportType */: return checkImportType(node); - case 295 /* JSDocAugmentsTag */: + case 300 /* JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 304 /* JSDocTypedefTag */: - case 297 /* JSDocCallbackTag */: + case 309 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: return checkJSDocTypeAliasTag(node); - case 303 /* JSDocTemplateTag */: + case 308 /* JSDocTemplateTag */: return checkJSDocTemplateTag(node); - case 302 /* JSDocTypeTag */: + case 307 /* JSDocTypeTag */: return checkJSDocTypeTag(node); - case 299 /* JSDocParameterTag */: + case 304 /* JSDocParameterTag */: return checkJSDocParameterTag(node); - case 289 /* JSDocFunctionType */: + case 294 /* JSDocFunctionType */: checkJSDocFunctionType(node); // falls through - case 287 /* JSDocNonNullableType */: - case 286 /* JSDocNullableType */: - case 284 /* JSDocAllType */: - case 285 /* JSDocUnknownType */: - case 292 /* JSDocTypeLiteral */: + case 292 /* JSDocNonNullableType */: + case 291 /* JSDocNullableType */: + case 289 /* JSDocAllType */: + case 290 /* JSDocUnknownType */: + case 297 /* JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 290 /* JSDocVariadicType */: + case 295 /* JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 283 /* JSDocTypeExpression */: + case 288 /* JSDocTypeExpression */: return checkSourceElement(node.type); case 180 /* IndexedAccessType */: return checkIndexedAccessType(node); @@ -57279,7 +57367,7 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; // falls through @@ -57498,10 +57586,10 @@ var ts; return entityNameSymbol; } } - if (entityName.parent.kind === 299 /* JSDocParameterTag */) { + if (entityName.parent.kind === 304 /* JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(entityName.parent); } - if (entityName.parent.kind === 150 /* TypeParameter */ && entityName.parent.parent.kind === 303 /* JSDocTemplateTag */) { + if (entityName.parent.kind === 150 /* TypeParameter */ && entityName.parent.parent.kind === 308 /* JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJSFile(entityName)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(entityName.parent); return typeParameter && typeParameter.symbol; @@ -57543,7 +57631,7 @@ var ts; return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 279 /* SourceFile */) { + if (node.kind === 284 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; @@ -57885,7 +57973,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 279 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 284 /* SourceFile */) { var symbolFile = parentSymbol_1.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); // If `node` accesses an export and that export isn't in the same file, then symbol is a namespace export, so return undefined. @@ -58000,7 +58088,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 279 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 284 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -58429,7 +58517,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 279 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 284 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -58462,7 +58550,7 @@ var ts; if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 279 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 284 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -58694,7 +58782,7 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 279 /* SourceFile */) { + else if (node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 284 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128 /* Abstract */) { @@ -58717,7 +58805,7 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 279 /* SourceFile */) { + else if (node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 284 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } else if (node.kind === 151 /* Parameter */) { @@ -58762,7 +58850,7 @@ var ts; flags |= 1 /* Export */; break; case 80 /* DefaultKeyword */: - var container = node.parent.kind === 279 /* SourceFile */ ? node.parent : node.parent.parent; + var container = node.parent.kind === 284 /* SourceFile */ ? node.parent : node.parent.parent; if (container.kind === 244 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } @@ -58885,7 +58973,7 @@ var ts; case 151 /* Parameter */: return false; default: - if (node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 279 /* SourceFile */) { + if (node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 284 /* SourceFile */) { return false; } switch (node.kind) { @@ -59808,7 +59896,7 @@ var ts; // to prevent noisiness. So use a bit on the block to indicate if // this has already been reported, and don't report if it has. // - if (node.parent.kind === 218 /* Block */ || node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 279 /* SourceFile */) { + if (node.parent.kind === 218 /* Block */ || node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 284 /* SourceFile */) { var links_2 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_2.hasReportedStatementInAmbientContext) { @@ -61862,14 +61950,14 @@ var ts; // JSDoc /* @internal */ function createJSDocTypeExpression(type) { - var node = createSynthesizedNode(283 /* JSDocTypeExpression */); + var node = createSynthesizedNode(288 /* JSDocTypeExpression */); node.type = type; return node; } ts.createJSDocTypeExpression = createJSDocTypeExpression; /* @internal */ function createJSDocTypeTag(typeExpression, comment) { - var tag = createJSDocTag(302 /* JSDocTypeTag */, "type"); + var tag = createJSDocTag(307 /* JSDocTypeTag */, "type"); tag.typeExpression = typeExpression; tag.comment = comment; return tag; @@ -61877,7 +61965,7 @@ var ts; ts.createJSDocTypeTag = createJSDocTypeTag; /* @internal */ function createJSDocReturnTag(typeExpression, comment) { - var tag = createJSDocTag(300 /* JSDocReturnTag */, "returns"); + var tag = createJSDocTag(305 /* JSDocReturnTag */, "returns"); tag.typeExpression = typeExpression; tag.comment = comment; return tag; @@ -61885,7 +61973,7 @@ var ts; ts.createJSDocReturnTag = createJSDocReturnTag; /* @internal */ function createJSDocParamTag(name, isBracketed, typeExpression, comment) { - var tag = createJSDocTag(299 /* JSDocParameterTag */, "param"); + var tag = createJSDocTag(304 /* JSDocParameterTag */, "param"); tag.typeExpression = typeExpression; tag.name = name; tag.isBracketed = isBracketed; @@ -61895,7 +61983,7 @@ var ts; ts.createJSDocParamTag = createJSDocParamTag; /* @internal */ function createJSDocComment(comment, tags) { - var node = createSynthesizedNode(291 /* JSDocComment */); + var node = createSynthesizedNode(296 /* JSDocComment */); node.comment = comment; node.tags = tags; return node; @@ -62154,7 +62242,7 @@ var ts; (typeReferences !== undefined && node.typeReferenceDirectives !== typeReferences) || (libReferences !== undefined && node.libReferenceDirectives !== libReferences) || (hasNoDefaultLib !== undefined && node.hasNoDefaultLib !== hasNoDefaultLib)) { - var updated = createSynthesizedNode(279 /* SourceFile */); + var updated = createSynthesizedNode(284 /* SourceFile */); updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; @@ -62238,7 +62326,7 @@ var ts; * @param original The original statement. */ function createNotEmittedStatement(original) { - var node = createSynthesizedNode(307 /* NotEmittedStatement */); + var node = createSynthesizedNode(312 /* NotEmittedStatement */); node.original = original; setTextRange(node, original); return node; @@ -62250,7 +62338,7 @@ var ts; */ /* @internal */ function createEndOfDeclarationMarker(original) { - var node = createSynthesizedNode(311 /* EndOfDeclarationMarker */); + var node = createSynthesizedNode(316 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -62262,7 +62350,7 @@ var ts; */ /* @internal */ function createMergeDeclarationMarker(original) { - var node = createSynthesizedNode(310 /* MergeDeclarationMarker */); + var node = createSynthesizedNode(315 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -62277,7 +62365,7 @@ var ts; * @param location The location for the expression. Defaults to the positions from "original" if provided. */ function createPartiallyEmittedExpression(expression, original) { - var node = createSynthesizedNode(308 /* PartiallyEmittedExpression */); + var node = createSynthesizedNode(313 /* PartiallyEmittedExpression */); node.expression = expression; node.original = original; setTextRange(node, original); @@ -62293,7 +62381,7 @@ var ts; ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; function flattenCommaElements(node) { if (ts.nodeIsSynthesized(node) && !ts.isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) { - if (node.kind === 309 /* CommaListExpression */) { + if (node.kind === 314 /* CommaListExpression */) { return node.elements; } if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27 /* CommaToken */) { @@ -62303,7 +62391,7 @@ var ts; return node; } function createCommaList(elements) { - var node = createSynthesizedNode(309 /* CommaListExpression */); + var node = createSynthesizedNode(314 /* CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); return node; } @@ -62316,33 +62404,197 @@ var ts; ts.updateCommaList = updateCommaList; function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = ts.createNode(280 /* Bundle */); + var node = ts.createNode(285 /* Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; } ts.createBundle = createBundle; - function createUnparsedSourceFile(textOrInputFiles, mapPathOrType, map) { - var node = ts.createNode(281 /* UnparsedSource */); + var allUnscopedEmitHelpers; + function getAllUnscopedEmitHelpers() { + return allUnscopedEmitHelpers || (allUnscopedEmitHelpers = ts.arrayToMap([ + ts.valuesHelper, + ts.readHelper, + ts.spreadHelper, + ts.restHelper, + ts.decorateHelper, + ts.metadataHelper, + ts.paramHelper, + ts.awaiterHelper, + ts.assignHelper, + ts.awaitHelper, + ts.asyncGeneratorHelper, + ts.asyncDelegator, + ts.asyncValues, + ts.extendsHelper, + ts.templateObjectHelper, + ts.generatorHelper, + ts.importStarHelper, + ts.importDefaultHelper + ], function (helper) { return helper.name; })); + } + function createUnparsedSource() { + var node = ts.createNode(286 /* UnparsedSource */); + node.prologues = ts.emptyArray; + node.referencedFiles = ts.emptyArray; + node.libReferenceDirectives = ts.emptyArray; + node.getLineAndCharacterOfPosition = function (pos) { return ts.getLineAndCharacterOfPosition(node, pos); }; + return node; + } + function createUnparsedSourceFile(textOrInputFiles, mapPathOrType, mapTextOrStripInternal) { + var node = createUnparsedSource(); + var stripInternal; + var bundleFileInfo; if (!ts.isString(textOrInputFiles)) { ts.Debug.assert(mapPathOrType === "js" || mapPathOrType === "dts"); - node.fileName = mapPathOrType === "js" ? textOrInputFiles.javascriptPath : textOrInputFiles.declarationPath; + node.fileName = (mapPathOrType === "js" ? textOrInputFiles.javascriptPath : textOrInputFiles.declarationPath) || ""; node.sourceMapPath = mapPathOrType === "js" ? textOrInputFiles.javascriptMapPath : textOrInputFiles.declarationMapPath; Object.defineProperties(node, { text: { get: function () { return mapPathOrType === "js" ? textOrInputFiles.javascriptText : textOrInputFiles.declarationText; } }, sourceMapText: { get: function () { return mapPathOrType === "js" ? textOrInputFiles.javascriptMapText : textOrInputFiles.declarationMapText; } }, }); + if (textOrInputFiles.buildInfo && textOrInputFiles.buildInfo.bundle) { + node.oldFileOfCurrentEmit = textOrInputFiles.oldFileOfCurrentEmit; + ts.Debug.assert(mapTextOrStripInternal === undefined || typeof mapTextOrStripInternal === "boolean"); + stripInternal = mapTextOrStripInternal; + bundleFileInfo = mapPathOrType === "js" ? textOrInputFiles.buildInfo.bundle.js : textOrInputFiles.buildInfo.bundle.dts; + if (node.oldFileOfCurrentEmit) { + parseOldFileOfCurrentEmit(node, ts.Debug.assertDefined(bundleFileInfo)); + return node; + } + } } else { + node.fileName = ""; node.text = textOrInputFiles; node.sourceMapPath = mapPathOrType; - node.sourceMapText = map; + node.sourceMapText = mapTextOrStripInternal; } + ts.Debug.assert(!node.oldFileOfCurrentEmit); + parseUnparsedSourceFile(node, bundleFileInfo, stripInternal); return node; } ts.createUnparsedSourceFile = createUnparsedSourceFile; - function createInputFiles(javascriptTextOrReadFileText, declarationTextOrJavascriptPath, javascriptMapPath, javascriptMapTextOrDeclarationPath, declarationMapPath, declarationMapText) { - var node = ts.createNode(282 /* InputFiles */); + function parseUnparsedSourceFile(node, bundleFileInfo, stripInternal) { + var prologues; + var helpers; + var referencedFiles; + var typeReferenceDirectives; + var libReferenceDirectives; + var texts; + for (var _i = 0, _a = bundleFileInfo ? bundleFileInfo.sections : ts.emptyArray; _i < _a.length; _i++) { + var section = _a[_i]; + switch (section.kind) { + case "prologue" /* Prologue */: + (prologues || (prologues = [])).push(createUnparsedNode(section, node)); + break; + case "emitHelpers" /* EmitHelpers */: + (helpers || (helpers = [])).push(getAllUnscopedEmitHelpers().get(section.data)); + break; + case "no-default-lib" /* NoDefaultLib */: + node.hasNoDefaultLib = true; + break; + case "reference" /* Reference */: + (referencedFiles || (referencedFiles = [])).push({ pos: -1, end: -1, fileName: section.data }); + break; + case "type" /* Type */: + (typeReferenceDirectives || (typeReferenceDirectives = [])).push(section.data); + break; + case "lib" /* Lib */: + (libReferenceDirectives || (libReferenceDirectives = [])).push({ pos: -1, end: -1, fileName: section.data }); + break; + case "prepend" /* Prepend */: + var prependNode = createUnparsedNode(section, node); + var prependTexts = void 0; + for (var _b = 0, _c = section.texts; _b < _c.length; _b++) { + var text = _c[_b]; + if (!stripInternal || text.kind !== "internal" /* Internal */) { + (prependTexts || (prependTexts = [])).push(createUnparsedNode(text, node)); + } + } + prependNode.texts = prependTexts || ts.emptyArray; + (texts || (texts = [])).push(prependNode); + break; + case "internal" /* Internal */: + if (stripInternal) + break; + // falls through + case "text" /* Text */: + (texts || (texts = [])).push(createUnparsedNode(section, node)); + break; + default: + ts.Debug.assertNever(section); + } + } + node.prologues = prologues || ts.emptyArray; + node.helpers = helpers; + node.referencedFiles = referencedFiles || ts.emptyArray; + node.typeReferenceDirectives = typeReferenceDirectives; + node.libReferenceDirectives = libReferenceDirectives || ts.emptyArray; + node.texts = texts || [createUnparsedNode({ kind: "text" /* Text */, pos: 0, end: node.text.length }, node)]; + } + function parseOldFileOfCurrentEmit(node, bundleFileInfo) { + ts.Debug.assert(!!node.oldFileOfCurrentEmit); + var texts; + var syntheticReferences; + for (var _i = 0, _a = bundleFileInfo.sections; _i < _a.length; _i++) { + var section = _a[_i]; + switch (section.kind) { + case "internal" /* Internal */: + case "text" /* Text */: + (texts || (texts = [])).push(createUnparsedNode(section, node)); + break; + case "no-default-lib" /* NoDefaultLib */: + case "reference" /* Reference */: + case "type" /* Type */: + case "lib" /* Lib */: + (syntheticReferences || (syntheticReferences = [])).push(createUnparsedSyntheticReference(section, node)); + break; + // Ignore + case "prologue" /* Prologue */: + case "emitHelpers" /* EmitHelpers */: + case "prepend" /* Prepend */: + break; + default: + ts.Debug.assertNever(section); + } + } + node.texts = texts || ts.emptyArray; + node.helpers = ts.map(bundleFileInfo.sources && bundleFileInfo.sources.helpers, function (name) { return getAllUnscopedEmitHelpers().get(name); }); + node.syntheticReferences = syntheticReferences; + return node; + } + function mapBundleFileSectionKindToSyntaxKind(kind) { + switch (kind) { + case "prologue" /* Prologue */: return 279 /* UnparsedPrologue */; + case "prepend" /* Prepend */: return 280 /* UnparsedPrepend */; + case "internal" /* Internal */: return 282 /* UnparsedInternalText */; + case "text" /* Text */: return 281 /* UnparsedText */; + case "emitHelpers" /* EmitHelpers */: + case "no-default-lib" /* NoDefaultLib */: + case "reference" /* Reference */: + case "type" /* Type */: + case "lib" /* Lib */: + return ts.Debug.fail("BundleFileSectionKind: " + kind + " not yet mapped to SyntaxKind"); + default: + return ts.Debug.assertNever(kind); + } + } + function createUnparsedNode(section, parent) { + var node = ts.createNode(mapBundleFileSectionKindToSyntaxKind(section.kind), section.pos, section.end); + node.parent = parent; + node.data = section.data; + return node; + } + function createUnparsedSyntheticReference(section, parent) { + var node = ts.createNode(283 /* UnparsedSyntheticReference */, section.pos, section.end); + node.parent = parent; + node.data = section.data; + node.section = section; + return node; + } + function createInputFiles(javascriptTextOrReadFileText, declarationTextOrJavascriptPath, javascriptMapPath, javascriptMapTextOrDeclarationPath, declarationMapPath, declarationMapTextOrBuildInfoPath, javascriptPath, declarationPath, buildInfoPath, buildInfo, oldFileOfCurrentEmit) { + var node = ts.createNode(287 /* InputFiles */); if (!ts.isString(javascriptTextOrReadFileText)) { var cache_1 = ts.createMap(); var textGetter_1 = function (path) { @@ -62359,15 +62611,25 @@ var ts; var result = textGetter_1(path); return result !== undefined ? result : "/* Input file " + path + " was missing */\r\n"; }; + var buildInfo_1; + var getBuildInfo_1 = function (getText) { + if (buildInfo_1 === undefined) { + var result = getText(); + buildInfo_1 = result !== undefined ? JSON.parse(result) : false; + } + return buildInfo_1 || undefined; + }; node.javascriptPath = declarationTextOrJavascriptPath; node.javascriptMapPath = javascriptMapPath; node.declarationPath = ts.Debug.assertDefined(javascriptMapTextOrDeclarationPath); node.declarationMapPath = declarationMapPath; + node.buildInfoPath = declarationMapTextOrBuildInfoPath; Object.defineProperties(node, { javascriptText: { get: function () { return definedTextGetter_1(declarationTextOrJavascriptPath); } }, javascriptMapText: { get: function () { return textGetter_1(javascriptMapPath); } }, declarationText: { get: function () { return definedTextGetter_1(ts.Debug.assertDefined(javascriptMapTextOrDeclarationPath)); } }, - declarationMapText: { get: function () { return textGetter_1(declarationMapPath); } } // TODO:: if there is inline sourceMap in dtsFile, use that + declarationMapText: { get: function () { return textGetter_1(declarationMapPath); } }, + buildInfo: { get: function () { return getBuildInfo_1(function () { return textGetter_1(declarationMapTextOrBuildInfoPath); }); } } }); } else { @@ -62376,7 +62638,12 @@ var ts; node.javascriptMapText = javascriptMapTextOrDeclarationPath; node.declarationText = declarationTextOrJavascriptPath; node.declarationMapPath = declarationMapPath; - node.declarationMapText = declarationMapText; + node.declarationMapText = declarationMapTextOrBuildInfoPath; + node.javascriptPath = javascriptPath; + node.declarationPath = declarationPath, + node.buildInfoPath = buildInfoPath; + node.buildInfo = buildInfo; + node.oldFileOfCurrentEmit = oldFileOfCurrentEmit; } return node; } @@ -62514,7 +62781,7 @@ var ts; // To avoid holding onto transformation artifacts, we keep track of any // parse tree node we are annotating. This allows us to clean them up after // all transformations have completed. - if (node.kind === 279 /* SourceFile */) { + if (node.kind === 284 /* SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(ts.getParseTreeNode(ts.getSourceFileOfNode(node))); @@ -62960,38 +63227,38 @@ var ts; return ts.setEmitFlags(ts.createIdentifier(name), 4096 /* HelperName */ | 2 /* AdviseOnEmitNode */); } ts.getHelperName = getHelperName; - var valuesHelper = { + ts.valuesHelper = { name: "typescript:values", scoped: false, text: "\n var __values = (this && this.__values) || function (o) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator], i = 0;\n if (m) return m.call(o);\n return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n };" }; function createValuesHelper(context, expression, location) { - context.requestEmitHelper(valuesHelper); + context.requestEmitHelper(ts.valuesHelper); return ts.setTextRange(ts.createCall(getHelperName("__values"), /*typeArguments*/ undefined, [expression]), location); } ts.createValuesHelper = createValuesHelper; - var readHelper = { + ts.readHelper = { name: "typescript:read", scoped: false, text: "\n var __read = (this && this.__read) || function (o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n };" }; function createReadHelper(context, iteratorRecord, count, location) { - context.requestEmitHelper(readHelper); + context.requestEmitHelper(ts.readHelper); return ts.setTextRange(ts.createCall(getHelperName("__read"), /*typeArguments*/ undefined, count !== undefined ? [iteratorRecord, ts.createLiteral(count)] : [iteratorRecord]), location); } ts.createReadHelper = createReadHelper; - var spreadHelper = { + ts.spreadHelper = { name: "typescript:spread", scoped: false, text: "\n var __spread = (this && this.__spread) || function () {\n for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));\n return ar;\n };" }; function createSpreadHelper(context, argumentList, location) { - context.requestEmitHelper(readHelper); - context.requestEmitHelper(spreadHelper); + context.requestEmitHelper(ts.readHelper); + context.requestEmitHelper(ts.spreadHelper); return ts.setTextRange(ts.createCall(getHelperName("__spread"), /*typeArguments*/ undefined, argumentList), location); } @@ -63837,7 +64104,7 @@ var ts; case 190 /* ElementAccessExpression */: case 189 /* PropertyAccessExpression */: case 213 /* NonNullExpression */: - case 308 /* PartiallyEmittedExpression */: + case 313 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -63853,7 +64120,7 @@ var ts; ts.parenthesizeConciseBody = parenthesizeConciseBody; function isCommaSequence(node) { return node.kind === 204 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || - node.kind === 309 /* CommaListExpression */; + node.kind === 314 /* CommaListExpression */; } ts.isCommaSequence = isCommaSequence; var OuterExpressionKinds; @@ -63872,7 +64139,7 @@ var ts; case 212 /* AsExpression */: case 213 /* NonNullExpression */: return (kinds & 2 /* Assertions */) !== 0; - case 308 /* PartiallyEmittedExpression */: + case 313 /* PartiallyEmittedExpression */: return (kinds & 4 /* PartiallyEmittedExpressions */) !== 0; } return false; @@ -63909,7 +64176,7 @@ var ts; case 194 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); case 212 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); case 213 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); - case 308 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); + case 313 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -64701,12 +64968,12 @@ var ts; case 278 /* EnumMember */: return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); // Top-level nodes - case 279 /* SourceFile */: + case 284 /* SourceFile */: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 308 /* PartiallyEmittedExpression */: + case 313 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 309 /* CommaListExpression */: + case 314 /* CommaListExpression */: return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: // No need to visit nodes with no children. @@ -64762,7 +65029,7 @@ var ts; case 220 /* EmptyStatement */: case 210 /* OmittedExpression */: case 236 /* DebuggerStatement */: - case 307 /* NotEmittedStatement */: + case 312 /* NotEmittedStatement */: // No need to visit nodes with no children. break; // Names @@ -65139,14 +65406,14 @@ var ts; result = reduceNode(node.initializer, cbNode, result); break; // Top-level nodes - case 279 /* SourceFile */: + case 284 /* SourceFile */: result = reduceNodes(node.statements, cbNodes, result); break; // Transformation nodes - case 308 /* PartiallyEmittedExpression */: + case 313 /* PartiallyEmittedExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 309 /* CommaListExpression */: + case 314 /* CommaListExpression */: result = reduceNodes(node.elements, cbNodes, result); break; default: @@ -65427,7 +65694,7 @@ var ts; } exit(); } - function appendSourceMap(generatedLine, generatedCharacter, map, sourceMapPath) { + function appendSourceMap(generatedLine, generatedCharacter, map, sourceMapPath, start, end) { var _a; ts.Debug.assert(generatedLine >= pendingGeneratedLine, "generatedLine cannot backtrack"); ts.Debug.assert(generatedCharacter >= 0, "generatedCharacter cannot be negative"); @@ -65437,6 +65704,14 @@ var ts; var nameIndexToNewNameIndexMap; var mappingIterator = decodeMappings(map.mappings); for (var _b = mappingIterator.next(), raw = _b.value, done = _b.done; !done; _a = mappingIterator.next(), raw = _a.value, done = _a.done, _a) { + if (end && (raw.generatedLine > end.line || + (raw.generatedLine === end.line && raw.generatedCharacter > end.character))) { + break; + } + if (start && (raw.generatedLine < start.line || + (start.line === raw.generatedLine && raw.generatedCharacter < start.character))) { + continue; + } // Then reencode all the updated mappings into the overall map var newSourceIndex = void 0; var newSourceLine = void 0; @@ -65465,8 +65740,10 @@ var ts; } } } - var newGeneratedLine = raw.generatedLine + generatedLine; - var newGeneratedCharacter = raw.generatedLine === 0 ? raw.generatedCharacter + generatedCharacter : raw.generatedCharacter; + var rawGeneratedLine = raw.generatedLine - (start ? start.line : 0); + var newGeneratedLine = rawGeneratedLine + generatedLine; + var rawGeneratedCharacter = start && start.line === raw.generatedLine ? raw.generatedCharacter - start.character : raw.generatedCharacter; + var newGeneratedCharacter = rawGeneratedLine === 0 ? rawGeneratedCharacter + generatedCharacter : rawGeneratedCharacter; addMapping(newGeneratedLine, newGeneratedCharacter, newSourceIndex, newSourceLine, newSourceCharacter, newNameIndex); } exit(); @@ -65949,7 +66226,7 @@ var ts; function chainBundle(transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 279 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 284 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return ts.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -66610,7 +66887,7 @@ var ts; function makeAssignmentElement(name) { return name; } - var restHelper = { + ts.restHelper = { name: "typescript:rest", scoped: false, text: "\n var __rest = (this && this.__rest) || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)\n t[p[i]] = s[p[i]];\n return t;\n };" @@ -66619,7 +66896,7 @@ var ts; * `{ a, b, ...p } = o`, create `p = __rest(o, ["a", "b"]);` */ function createRestCall(context, value, elements, computedTempVariables, location) { - context.requestEmitHelper(restHelper); + context.requestEmitHelper(ts.restHelper); var propertyNames = []; var computedTempVariableOffset = 0; for (var i = 0; i < elements.length - 1; i++) { @@ -66720,14 +66997,14 @@ var ts; var pendingExpressions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 280 /* Bundle */) { + if (node.kind === 285 /* Bundle */) { return transformBundle(node); } return transformSourceFile(node); } function transformBundle(node) { return ts.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 282 /* InputFiles */) { + if (prepend.kind === 287 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend, "js"); } return prepend; @@ -66776,7 +67053,7 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: case 246 /* CaseBlock */: case 245 /* ModuleBlock */: case 218 /* Block */: @@ -69007,7 +69284,7 @@ var ts; // enums in any other scope are emitted as a `let` declaration. var statement = ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ ts.createVariableDeclaration(ts.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true)) - ], currentLexicalScope.kind === 279 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentLexicalScope.kind === 284 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { @@ -69572,7 +69849,7 @@ var ts; // If we are nested within a namespace declaration, we may need to qualifiy // an identifier that is exported from a merged namespace. var container = resolver.getReferencedExportContainer(node, /*prefixLocals*/ false); - if (container && container.kind !== 279 /* SourceFile */) { + if (container && container.kind !== 284 /* SourceFile */) { var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 244 /* ModuleDeclaration */) || (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 243 /* EnumDeclaration */); if (substitute) { @@ -69623,39 +69900,39 @@ var ts; argumentsArray.push(descriptor); } } - context.requestEmitHelper(decorateHelper); + context.requestEmitHelper(ts.decorateHelper); return ts.setTextRange(ts.createCall(ts.getHelperName("__decorate"), /*typeArguments*/ undefined, argumentsArray), location); } - var decorateHelper = { + ts.decorateHelper = { name: "typescript:decorate", scoped: false, priority: 2, text: "\n var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n };" }; function createMetadataHelper(context, metadataKey, metadataValue) { - context.requestEmitHelper(metadataHelper); + context.requestEmitHelper(ts.metadataHelper); return ts.createCall(ts.getHelperName("__metadata"), /*typeArguments*/ undefined, [ ts.createLiteral(metadataKey), metadataValue ]); } - var metadataHelper = { + ts.metadataHelper = { name: "typescript:metadata", scoped: false, priority: 3, text: "\n var __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n };" }; function createParamHelper(context, expression, parameterOffset, location) { - context.requestEmitHelper(paramHelper); + context.requestEmitHelper(ts.paramHelper); return ts.setTextRange(ts.createCall(ts.getHelperName("__param"), /*typeArguments*/ undefined, [ ts.createLiteral(parameterOffset), expression ]), location); } - var paramHelper = { + ts.paramHelper = { name: "typescript:param", scoped: false, priority: 4, @@ -70206,14 +70483,14 @@ var ts; ], 2 /* Const */)); } ts.createSuperAccessVariableStatement = createSuperAccessVariableStatement; - var awaiterHelper = { + ts.awaiterHelper = { name: "typescript:awaiter", scoped: false, priority: 5, text: "\n var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n };" }; function createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, body) { - context.requestEmitHelper(awaiterHelper); + context.requestEmitHelper(ts.awaiterHelper); var generatorFunc = ts.createFunctionExpression( /*modifiers*/ undefined, ts.createToken(40 /* AsteriskToken */), /*name*/ undefined, @@ -70845,7 +71122,7 @@ var ts; } } ts.transformES2018 = transformES2018; - var assignHelper = { + ts.assignHelper = { name: "typescript:assign", scoped: false, priority: 1, @@ -70856,28 +71133,28 @@ var ts; return ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "assign"), /*typeArguments*/ undefined, attributesSegments); } - context.requestEmitHelper(assignHelper); + context.requestEmitHelper(ts.assignHelper); return ts.createCall(ts.getHelperName("__assign"), /*typeArguments*/ undefined, attributesSegments); } ts.createAssignHelper = createAssignHelper; - var awaitHelper = { + ts.awaitHelper = { name: "typescript:await", scoped: false, text: "\n var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }" }; function createAwaitHelper(context, expression) { - context.requestEmitHelper(awaitHelper); + context.requestEmitHelper(ts.awaitHelper); return ts.createCall(ts.getHelperName("__await"), /*typeArguments*/ undefined, [expression]); } - var asyncGeneratorHelper = { + ts.asyncGeneratorHelper = { name: "typescript:asyncGenerator", scoped: false, text: "\n var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n };" }; function createAsyncGeneratorHelper(context, generatorFunc) { - context.requestEmitHelper(awaitHelper); - context.requestEmitHelper(asyncGeneratorHelper); + context.requestEmitHelper(ts.awaitHelper); + context.requestEmitHelper(ts.asyncGeneratorHelper); // Mark this node as originally an async function (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* AsyncFunctionBody */; return ts.createCall(ts.getHelperName("__asyncGenerator"), @@ -70887,24 +71164,24 @@ var ts; generatorFunc ]); } - var asyncDelegator = { + ts.asyncDelegator = { name: "typescript:asyncDelegator", scoped: false, text: "\n var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {\n var i, p;\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\n };" }; function createAsyncDelegatorHelper(context, expression, location) { - context.requestEmitHelper(awaitHelper); - context.requestEmitHelper(asyncDelegator); + context.requestEmitHelper(ts.awaitHelper); + context.requestEmitHelper(ts.asyncDelegator); return ts.setTextRange(ts.createCall(ts.getHelperName("__asyncDelegator"), /*typeArguments*/ undefined, [expression]), location); } - var asyncValues = { + ts.asyncValues = { name: "typescript:asyncValues", scoped: false, text: "\n var __asyncValues = (this && this.__asyncValues) || function (o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator], i;\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\n };" }; function createAsyncValuesHelper(context, expression, location) { - context.requestEmitHelper(asyncValues); + context.requestEmitHelper(ts.asyncValues); return ts.setTextRange(ts.createCall(ts.getHelperName("__asyncValues"), /*typeArguments*/ undefined, [expression]), location); } @@ -74716,7 +74993,7 @@ var ts; } ts.transformES2015 = transformES2015; function createExtendsHelper(context, name) { - context.requestEmitHelper(extendsHelper); + context.requestEmitHelper(ts.extendsHelper); return ts.createCall(ts.getHelperName("__extends"), /*typeArguments*/ undefined, [ name, @@ -74724,20 +75001,20 @@ var ts; ]); } function createTemplateObjectHelper(context, cooked, raw) { - context.requestEmitHelper(templateObjectHelper); + context.requestEmitHelper(ts.templateObjectHelper); return ts.createCall(ts.getHelperName("__makeTemplateObject"), /*typeArguments*/ undefined, [ cooked, raw ]); } - var extendsHelper = { + ts.extendsHelper = { name: "typescript:extends", scoped: false, priority: 0, text: "\n var __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n })();" }; - var templateObjectHelper = { + ts.templateObjectHelper = { name: "typescript:makeTemplateObject", scoped: false, priority: 0, @@ -77431,7 +77708,7 @@ var ts; } ts.transformGenerators = transformGenerators; function createGeneratorHelper(context, body) { - context.requestEmitHelper(generatorHelper); + context.requestEmitHelper(ts.generatorHelper); return ts.createCall(ts.getHelperName("__generator"), /*typeArguments*/ undefined, [ts.createThis(), body]); } @@ -77494,7 +77771,7 @@ var ts; // entering a finally block. // // For examples of how these are used, see the comments in ./transformers/generators.ts - var generatorHelper = { + ts.generatorHelper = { name: "typescript:generator", scoped: false, priority: 6, @@ -77527,7 +77804,7 @@ var ts; context.enableSubstitution(202 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. context.enableSubstitution(203 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. context.enableSubstitution(276 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(279 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableEmitNotification(284 /* SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var currentSourceFile; // The current file. @@ -77869,9 +78146,9 @@ var ts; return visitFunctionDeclaration(node); case 240 /* ClassDeclaration */: return visitClassDeclaration(node); - case 310 /* MergeDeclarationMarker */: + case 315 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 311 /* EndOfDeclarationMarker */: + case 316 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); @@ -78029,7 +78306,7 @@ var ts; } var promise = ts.createNew(ts.createIdentifier("Promise"), /*typeArguments*/ undefined, [func]); if (compilerOptions.esModuleInterop) { - context.requestEmitHelper(importStarHelper); + context.requestEmitHelper(ts.importStarHelper); return ts.createCall(ts.createPropertyAccess(promise, ts.createIdentifier("then")), /*typeArguments*/ undefined, [ts.getHelperName("__importStar")]); } return promise; @@ -78043,7 +78320,7 @@ var ts; var promiseResolveCall = ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Promise"), "resolve"), /*typeArguments*/ undefined, /*argumentsArray*/ []); var requireCall = ts.createCall(ts.createIdentifier("require"), /*typeArguments*/ undefined, arg ? [arg] : []); if (compilerOptions.esModuleInterop) { - context.requestEmitHelper(importStarHelper); + context.requestEmitHelper(ts.importStarHelper); requireCall = ts.createCall(ts.getHelperName("__importStar"), /*typeArguments*/ undefined, [requireCall]); } var func; @@ -78077,11 +78354,11 @@ var ts; return innerExpr; } if (ts.getImportNeedsImportStarHelper(node)) { - context.requestEmitHelper(importStarHelper); + context.requestEmitHelper(ts.importStarHelper); return ts.createCall(ts.getHelperName("__importStar"), /*typeArguments*/ undefined, [innerExpr]); } if (ts.getImportNeedsImportDefaultHelper(node)) { - context.requestEmitHelper(importDefaultHelper); + context.requestEmitHelper(ts.importDefaultHelper); return ts.createCall(ts.getHelperName("__importDefault"), /*typeArguments*/ undefined, [innerExpr]); } return innerExpr; @@ -78650,7 +78927,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 279 /* SourceFile */) { + if (node.kind === 284 /* SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -78738,7 +79015,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 279 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 284 /* SourceFile */) { return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), /*location*/ node); } @@ -78864,13 +79141,13 @@ var ts; text: "\n var __syncRequire = typeof module === \"object\" && typeof module.exports === \"object\";" }; // emit helper for `import * as Name from "foo"` - var importStarHelper = { + ts.importStarHelper = { name: "typescript:commonjsimportstar", scoped: false, text: "\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\n result[\"default\"] = mod;\n return result;\n};" }; // emit helper for `import Name from "foo"` - var importDefaultHelper = { + ts.importDefaultHelper = { name: "typescript:commonjsimportdefault", scoped: false, text: "\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};" @@ -78893,7 +79170,7 @@ var ts; context.enableSubstitution(204 /* BinaryExpression */); // Substitutes assignments to exported symbols. context.enableSubstitution(202 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. context.enableSubstitution(203 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableEmitNotification(279 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableEmitNotification(284 /* SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var exportFunctionsMap = []; // The export function associated with a source file. @@ -79463,7 +79740,7 @@ var ts; function shouldHoistVariableDeclarationList(node) { // hoist only non-block scoped declarations or block scoped declarations parented by source file return (ts.getEmitFlags(node) & 2097152 /* NoHoisting */) === 0 - && (enclosingBlockScopedContainer.kind === 279 /* SourceFile */ + && (enclosingBlockScopedContainer.kind === 284 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -79806,9 +80083,9 @@ var ts; return visitCatchClause(node); case 218 /* Block */: return visitBlock(node); - case 310 /* MergeDeclarationMarker */: + case 315 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 311 /* EndOfDeclarationMarker */: + case 316 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -80056,7 +80333,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 279 /* SourceFile */; + return container !== undefined && container.kind === 284 /* SourceFile */; } else { return false; @@ -80089,7 +80366,7 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 279 /* SourceFile */) { + if (node.kind === 284 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -80298,7 +80575,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 279 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 284 /* SourceFile */) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -80337,7 +80614,7 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(279 /* SourceFile */); + context.enableEmitNotification(284 /* SourceFile */); context.enableSubstitution(72 /* Identifier */); var currentSourceFile; return ts.chainBundle(transformSourceFile); @@ -80850,6 +81127,15 @@ var ts; return result.diagnostics; } ts.getDeclarationDiagnostics = getDeclarationDiagnostics; + function isInternalDeclaration(node, currentSourceFile) { + var parseTreeNode = ts.getParseTreeNode(node); + var leadingCommentRanges = parseTreeNode && ts.getLeadingCommentRangesOfNode(parseTreeNode, currentSourceFile); + return !!ts.forEach(leadingCommentRanges, function (range) { + var comment = currentSourceFile.text.substring(range.pos, range.end); + return ts.stringContains(comment, "@internal"); + }); + } + ts.isInternalDeclaration = isInternalDeclaration; var declarationEmitNodeBuilderFlags = 1024 /* MultilineObjectLiterals */ | 2048 /* WriteClassExpressionAsTypeLiteral */ | 4096 /* UseTypeOfFunction */ | @@ -80978,10 +81264,10 @@ var ts; } } function transformRoot(node) { - if (node.kind === 279 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJS(node))) { + if (node.kind === 284 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJS(node))) { return node; } - if (node.kind === 280 /* Bundle */) { + if (node.kind === 285 /* Bundle */) { isBundledEmit = true; refs = ts.createMap(); libs = ts.createMap(); @@ -81011,9 +81297,15 @@ var ts; var updated = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); return ts.updateSourceFileNode(sourceFile, transformAndReplaceLatePaintedStatements(updated), /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); }), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 282 /* InputFiles */) { - return ts.createUnparsedSourceFile(prepend, "dts"); + if (prepend.kind === 287 /* InputFiles */) { + var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal); + hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib; + collectReferences(sourceFile, refs); + recordTypeReferenceDirectivesIfNecessary(sourceFile.typeReferenceDirectives); + collectLibs(sourceFile, libs); + return sourceFile; } + return prepend; })); bundle.syntheticFileReferences = []; bundle.syntheticTypeReferences = getFileReferencesForUsedTypeReferences(); @@ -81105,7 +81397,7 @@ var ts; } } function collectReferences(sourceFile, ret) { - if (noResolve || ts.isSourceFileJS(sourceFile)) + if (noResolve || (!ts.isUnparsedSource(sourceFile) && ts.isSourceFileJS(sourceFile))) return ret; ts.forEach(sourceFile.referencedFiles, function (f) { var elem = ts.tryResolveScriptReference(host, sourceFile, f); @@ -81833,18 +82125,8 @@ var ts; } errorNameNode = undefined; } - function hasInternalAnnotation(range) { - var comment = currentSourceFile.text.substring(range.pos, range.end); - return ts.stringContains(comment, "@internal"); - } function shouldStripInternal(node) { - if (stripInternal && node) { - var leadingCommentRanges = ts.getLeadingCommentRangesOfNode(ts.getParseTreeNode(node), currentSourceFile); - if (ts.forEach(leadingCommentRanges, hasInternalAnnotation)) { - return true; - } - } - return false; + return !!stripInternal && !!node && isInternalDeclaration(node, currentSourceFile); } function isScopeMarker(node) { return ts.isExportAssignment(node) || ts.isExportDeclaration(node); @@ -81866,7 +82148,7 @@ var ts; function ensureModifierFlags(node, privateDeclaration) { var mask = 3071 /* All */ ^ (4 /* Public */ | 256 /* Async */); // No async modifiers in declaration files var additions = (needsDeclare && !isAlwaysType(node)) ? 2 /* Ambient */ : 0 /* None */; - var parentIsFile = node.parent.kind === 279 /* SourceFile */; + var parentIsFile = node.parent.kind === 284 /* SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= ((privateDeclaration || (isBundledEmit && parentIsFile) || hasScopeMarker(node.parent) ? 0 : 1 /* Export */) | 2 /* Ambient */); additions = 0 /* None */; @@ -82083,7 +82365,7 @@ var ts; * @param allowDtsFiles A value indicating whether to allow the transformation of .d.ts files. */ function transformNodes(resolver, host, options, nodes, transformers, allowDtsFiles) { - var enabledSyntaxKindFeatures = new Array(312 /* Count */); + var enabledSyntaxKindFeatures = new Array(317 /* Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentVariableDeclarationsStack = []; @@ -82343,10 +82625,14 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - var infoExtension = ".tsbundleinfo"; var brackets = createBracketsMap(); var syntheticParent = { pos: -1, end: -1 }; /*@internal*/ + function isBuildInfoFile(file) { + return ts.fileExtensionIs(file, ".tsbuildinfo" /* TsBuildInfo */); + } + ts.isBuildInfoFile = isBuildInfoFile; + /*@internal*/ /** * Iterates over the source files that are expected to have an emit output. * @@ -82356,13 +82642,14 @@ var ts; * If an array, the full list of source files to emit. * Else, calls `getSourceFilesToEmit` with the (optional) target source file to determine the list of source files to emit. */ - function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, emitOnlyDtsFiles) { + function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, emitOnlyDtsFiles, onlyBuildInfo, includeBuildInfo) { if (emitOnlyDtsFiles === void 0) { emitOnlyDtsFiles = false; } var sourceFiles = ts.isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : ts.getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile); var options = host.getCompilerOptions(); if (options.outFile || options.out) { - if (sourceFiles.length) { - var bundle = ts.createBundle(sourceFiles, host.getPrependNodes()); + var prepends = host.getPrependNodes(); + if (sourceFiles.length || prepends.length) { + var bundle = ts.createBundle(sourceFiles, prepends); var result = action(getOutputPathsFor(bundle, host, emitOnlyDtsFiles), bundle); if (result) { return result; @@ -82370,31 +82657,61 @@ var ts; } } else { - for (var _a = 0, sourceFiles_1 = sourceFiles; _a < sourceFiles_1.length; _a++) { - var sourceFile = sourceFiles_1[_a]; - var result = action(getOutputPathsFor(sourceFile, host, emitOnlyDtsFiles), sourceFile); - if (result) { - return result; + if (!onlyBuildInfo) { + for (var _a = 0, sourceFiles_1 = sourceFiles; _a < sourceFiles_1.length; _a++) { + var sourceFile = sourceFiles_1[_a]; + var result = action(getOutputPathsFor(sourceFile, host, emitOnlyDtsFiles), sourceFile); + if (result) { + return result; + } } } + if (includeBuildInfo) { + var buildInfoPath = getOutputPathForBuildInfo(host.getCompilerOptions()); + if (buildInfoPath) + return action({ buildInfoPath: buildInfoPath }, /*sourceFileOrBundle*/ undefined); + } } } ts.forEachEmittedFile = forEachEmittedFile; /*@internal*/ + function getOutputPathForBuildInfo(options) { + var configFile = options.configFilePath; + if (!configFile || !ts.isIncrementalCompilation(options)) + return undefined; + if (options.tsBuildInfoFile) + return options.tsBuildInfoFile; + var outPath = options.outFile || options.out; + var buildInfoExtensionLess; + if (outPath) { + buildInfoExtensionLess = ts.removeFileExtension(outPath); + } + else { + var configFileExtensionLess = ts.removeFileExtension(configFile); + buildInfoExtensionLess = options.outDir ? + options.rootDir ? + ts.resolvePath(options.outDir, ts.getRelativePathFromDirectory(options.rootDir, configFileExtensionLess, /*ignoreCase*/ true)) : + ts.combinePaths(options.outDir, ts.getBaseFileName(configFileExtensionLess)) : + configFileExtensionLess; + } + return buildInfoExtensionLess + ".tsbuildinfo" /* TsBuildInfo */; + } + ts.getOutputPathForBuildInfo = getOutputPathForBuildInfo; + /*@internal*/ function getOutputPathsForBundle(options, forceDtsPaths) { var outPath = options.outFile || options.out; var jsFilePath = options.emitDeclarationOnly ? undefined : outPath; var sourceMapFilePath = jsFilePath && getSourceMapFilePath(jsFilePath, options); var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.removeFileExtension(outPath) + ".d.ts" /* Dts */ : undefined; var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; - var bundleInfoPath = options.references && jsFilePath ? (ts.removeFileExtension(jsFilePath) + infoExtension) : undefined; - return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, bundleInfoPath: bundleInfoPath }; + var buildInfoPath = getOutputPathForBuildInfo(options); + return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: buildInfoPath }; } ts.getOutputPathsForBundle = getOutputPathsForBundle; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 280 /* Bundle */) { + if (sourceFile.kind === 285 /* Bundle */) { return getOutputPathsForBundle(options, forceDtsPaths); } else { @@ -82408,19 +82725,13 @@ var ts; var isJs = ts.isSourceFileJS(sourceFile); var declarationFilePath = ((forceDtsPaths || ts.getEmitDeclarations(options)) && !isJs) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; - return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, bundleInfoPath: undefined }; + return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: undefined }; } } ts.getOutputPathsFor = getOutputPathsFor; function getSourceMapFilePath(jsFilePath, options) { return (options.sourceMap && !options.inlineSourceMap) ? jsFilePath + ".map" : undefined; } - function createDefaultBundleInfo() { - return { - originalOffset: -1, - totalLength: -1 - }; - } // JavaScript files are always LanguageVariant.JSX, as JSX syntax is allowed in .js files also. // So for JavaScript files, '.jsx' is only emitted if the input was '.jsx', and JsxEmit.Preserve. // For TypeScript, the only time to emit with a '.jsx' extension, is on JSX input, and JsxEmit.Preserve @@ -82445,7 +82756,7 @@ var ts; ts.getOutputExtension = getOutputExtension; /*@internal*/ // targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature - function emitFiles(resolver, host, targetSourceFile, emitOnlyDtsFiles, transformers, declarationTransformers) { + function emitFiles(resolver, host, targetSourceFile, emitOnlyDtsFiles, transformers, declarationTransformers, onlyBuildInfo) { var compilerOptions = host.getCompilerOptions(); var sourceMapDataList = (compilerOptions.sourceMap || compilerOptions.inlineSourceMap || ts.getAreDeclarationMapsEnabled(compilerOptions)) ? [] : undefined; var emittedFilesList = compilerOptions.listEmittedFiles ? [] : undefined; @@ -82453,12 +82764,12 @@ var ts; var newLine = ts.getNewLineCharacter(compilerOptions, function () { return host.getNewLine(); }); var writer = ts.createTextWriter(newLine); var _a = ts.performance.createTimer("printTime", "beforePrint", "afterPrint"), enter = _a.enter, exit = _a.exit; - var bundleInfo = createDefaultBundleInfo(); + var bundleBuildInfo; var emitSkipped = false; var exportedModulesFromDeclarationEmit; // Emit each output file enter(); - forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), emitOnlyDtsFiles); + forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), emitOnlyDtsFiles, onlyBuildInfo, !targetSourceFile); exit(); return { emitSkipped: emitSkipped, @@ -82468,9 +82779,16 @@ var ts; exportedModulesFromDeclarationEmit: exportedModulesFromDeclarationEmit }; function emitSourceFileOrBundle(_a, sourceFileOrBundle) { - var jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, bundleInfoPath = _a.bundleInfoPath; - emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, bundleInfoPath); + var jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath; + if (buildInfoPath && sourceFileOrBundle && ts.isBundle(sourceFileOrBundle)) { + bundleBuildInfo = { + commonSourceDirectory: host.getCommonSourceDirectory(), + sourceFiles: sourceFileOrBundle.sourceFiles.map(function (file) { return file.fileName; }) + }; + } + emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath); emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath); + emitBuildInfo(bundleBuildInfo, buildInfoPath); if (!emitSkipped && emittedFilesList) { if (!emitOnlyDtsFiles) { if (jsFilePath) { @@ -82479,8 +82797,8 @@ var ts; if (sourceMapFilePath) { emittedFilesList.push(sourceMapFilePath); } - if (bundleInfoPath) { - emittedFilesList.push(bundleInfoPath); + if (buildInfoPath) { + emittedFilesList.push(buildInfoPath); } } if (declarationFilePath) { @@ -82491,8 +82809,21 @@ var ts; } } } - function emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, bundleInfoPath) { - if (emitOnlyDtsFiles || !jsFilePath) { + function emitBuildInfo(bundle, buildInfoPath) { + // Write build information if applicable + if (!buildInfoPath || targetSourceFile || emitSkipped) + return; + var program = host.getProgramBuildInfo(); + if (!bundle && !program) + return; + if (host.isEmitBlocked(buildInfoPath) || compilerOptions.noEmit) { + emitSkipped = true; + return; + } + ts.writeFile(host, emitterDiagnostics, buildInfoPath, getBuildInfoText({ bundle: bundle, program: program }), /*writeByteOrderMark*/ false); + } + function emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath) { + if (!sourceFileOrBundle || emitOnlyDtsFiles || !jsFilePath) { return; } // Make sure not to write js file and source map file if any of them cannot be written @@ -82512,6 +82843,7 @@ var ts; inlineSourceMap: compilerOptions.inlineSourceMap, inlineSources: compilerOptions.inlineSources, extendedDiagnostics: compilerOptions.extendedDiagnostics, + writeBundleFileInfo: !!bundleBuildInfo }; // Create a printer to print the nodes var printer = createPrinter(printerOptions, { @@ -82522,12 +82854,14 @@ var ts; substituteNode: transform.substituteNode, }); ts.Debug.assert(transform.transformed.length === 1, "Should only see one output from the transform"); - printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform.transformed[0], bundleInfoPath, printer, compilerOptions); + printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform.transformed[0], printer, compilerOptions); // Clean up emit nodes on parse tree transform.dispose(); + if (bundleBuildInfo) + bundleBuildInfo.js = printer.bundleFileInfo; } function emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath) { - if (!(declarationFilePath && !ts.isInJSFile(sourceFileOrBundle))) { + if (!sourceFileOrBundle || !(declarationFilePath && !ts.isInJSFile(sourceFileOrBundle))) { return; } var sourceFiles = ts.isSourceFile(sourceFileOrBundle) ? [sourceFileOrBundle] : sourceFileOrBundle.sourceFiles; @@ -82556,6 +82890,8 @@ var ts; inlineSourceMap: compilerOptions.inlineSourceMap, extendedDiagnostics: compilerOptions.extendedDiagnostics, onlyPrintJsDocStyle: true, + writeBundleFileInfo: !!bundleBuildInfo, + recordInternalSection: !!bundleBuildInfo }; var declarationPrinter = createPrinter(printerOptions, { // resolver hooks @@ -82568,18 +82904,20 @@ var ts; emitSkipped = emitSkipped || declBlocked; if (!declBlocked || emitOnlyDtsFiles) { ts.Debug.assert(declarationTransform.transformed.length === 1, "Should only see one output from the decl transform"); - printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], /* bundleInfopath*/ undefined, declarationPrinter, { + printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], declarationPrinter, { sourceMap: compilerOptions.declarationMap, sourceRoot: compilerOptions.sourceRoot, mapRoot: compilerOptions.mapRoot, extendedDiagnostics: compilerOptions.extendedDiagnostics, }); - if (emitOnlyDtsFiles && declarationTransform.transformed[0].kind === 279 /* SourceFile */) { + if (emitOnlyDtsFiles && declarationTransform.transformed[0].kind === 284 /* SourceFile */) { var sourceFile = declarationTransform.transformed[0]; exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit; } } declarationTransform.dispose(); + if (bundleBuildInfo) + bundleBuildInfo.dts = declarationPrinter.bundleFileInfo; } function collectLinkedAliases(node) { if (ts.isExportAssignment(node)) { @@ -82594,16 +82932,16 @@ var ts; } ts.forEachChild(node, collectLinkedAliases); } - function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, bundleInfoPath, printer, mapOptions) { - var bundle = sourceFileOrBundle.kind === 280 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 279 /* SourceFile */ ? sourceFileOrBundle : undefined; + function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) { + var bundle = sourceFileOrBundle.kind === 285 /* Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 284 /* SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; var sourceMapGenerator; if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) { sourceMapGenerator = ts.createSourceMapGenerator(host, ts.getBaseFileName(ts.normalizeSlashes(jsFilePath)), getSourceRoot(mapOptions), getSourceMapDirectory(mapOptions, jsFilePath, sourceFile), mapOptions); } if (bundle) { - printer.writeBundle(bundle, bundleInfo, writer, sourceMapGenerator); + printer.writeBundle(bundle, writer, sourceMapGenerator); } else { printer.writeFile(sourceFile, writer, sourceMapGenerator); @@ -82632,18 +82970,12 @@ var ts; } // Write the output file ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles); - // Write bundled offset information if applicable - if (bundleInfoPath) { - bundleInfo.totalLength = writer.getTextPos(); - ts.writeFile(host, emitterDiagnostics, bundleInfoPath, JSON.stringify(bundleInfo, undefined, 2), /*writeByteOrderMark*/ false); - } // Reset state writer.clear(); - bundleInfo = createDefaultBundleInfo(); } function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) { return (mapOptions.sourceMap || mapOptions.inlineSourceMap) - && (sourceFileOrBundle.kind !== 279 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); + && (sourceFileOrBundle.kind !== 284 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); } function getSourceRoot(mapOptions) { // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the @@ -82700,6 +83032,161 @@ var ts; } } ts.emitFiles = emitFiles; + /*@internal*/ + function getBuildInfoText(buildInfo) { + return JSON.stringify(buildInfo, undefined, 2); + } + ts.getBuildInfoText = getBuildInfoText; + /*@internal*/ + ts.notImplementedResolver = { + hasGlobalName: ts.notImplemented, + getReferencedExportContainer: ts.notImplemented, + getReferencedImportDeclaration: ts.notImplemented, + getReferencedDeclarationWithCollidingName: ts.notImplemented, + isDeclarationWithCollidingName: ts.notImplemented, + isValueAliasDeclaration: ts.notImplemented, + isReferencedAliasDeclaration: ts.notImplemented, + isTopLevelValueImportEqualsWithEntityName: ts.notImplemented, + getNodeCheckFlags: ts.notImplemented, + isDeclarationVisible: ts.notImplemented, + isLateBound: function (_node) { return false; }, + collectLinkedAliases: ts.notImplemented, + isImplementationOfOverload: ts.notImplemented, + isRequiredInitializedParameter: ts.notImplemented, + isOptionalUninitializedParameterProperty: ts.notImplemented, + isExpandoFunctionDeclaration: ts.notImplemented, + getPropertiesOfContainerFunction: ts.notImplemented, + createTypeOfDeclaration: ts.notImplemented, + createReturnTypeOfSignatureDeclaration: ts.notImplemented, + createTypeOfExpression: ts.notImplemented, + createLiteralConstValue: ts.notImplemented, + isSymbolAccessible: ts.notImplemented, + isEntityNameVisible: ts.notImplemented, + // Returns the constant value this property access resolves to: notImplemented, or 'undefined' for a non-constant + getConstantValue: ts.notImplemented, + getReferencedValueDeclaration: ts.notImplemented, + getTypeReferenceSerializationKind: ts.notImplemented, + isOptionalParameter: ts.notImplemented, + moduleExportsSomeValue: ts.notImplemented, + isArgumentsLocalBinding: ts.notImplemented, + getExternalModuleFileFromDeclaration: ts.notImplemented, + getTypeReferenceDirectivesForEntityName: ts.notImplemented, + getTypeReferenceDirectivesForSymbol: ts.notImplemented, + isLiteralConstDeclaration: ts.notImplemented, + getJsxFactoryEntity: ts.notImplemented, + getAllAccessorDeclarations: ts.notImplemented, + getSymbolOfExternalModuleSpecifier: ts.notImplemented, + isBindingCapturedByNode: ts.notImplemented, + }; + function createSourceFilesFromBundleBuildInfo(bundle) { + var sourceFiles = bundle.sourceFiles.map(function (fileName) { + var sourceFile = ts.createNode(284 /* SourceFile */, 0, 0); + sourceFile.fileName = fileName; + sourceFile.text = ""; + sourceFile.statements = ts.createNodeArray(); + return sourceFile; + }); + var jsBundle = ts.Debug.assertDefined(bundle.js); + ts.forEach(jsBundle.sources && jsBundle.sources.prologues, function (prologueInfo) { + var sourceFile = sourceFiles[prologueInfo.file]; + sourceFile.text = prologueInfo.text; + sourceFile.end = prologueInfo.text.length; + sourceFile.statements = ts.createNodeArray(prologueInfo.directives.map(function (directive) { + var statement = ts.createNode(221 /* ExpressionStatement */, directive.pos, directive.end); + statement.expression = ts.createNode(10 /* StringLiteral */, directive.expression.pos, directive.expression.end); + statement.expression.text = directive.expression.text; + return statement; + })); + }); + return sourceFiles; + } + /*@internal*/ + function emitUsingBuildInfo(config, host, getCommandLine) { + var _a = getOutputPathsForBundle(config.options, /*forceDtsPaths*/ false), buildInfoPath = _a.buildInfoPath, jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath; + var buildInfoText = host.readFile(ts.Debug.assertDefined(buildInfoPath)); + if (!buildInfoText) + return buildInfoPath; + var jsFileText = host.readFile(ts.Debug.assertDefined(jsFilePath)); + if (!jsFileText) + return jsFilePath; + var sourceMapText = sourceMapFilePath && host.readFile(sourceMapFilePath); + // error if no source map or for now if inline sourcemap + if ((sourceMapFilePath && !sourceMapText) || config.options.inlineSourceMap) + return sourceMapFilePath || "inline sourcemap decoding"; + // read declaration text + var declarationText = declarationFilePath && host.readFile(declarationFilePath); + if (declarationFilePath && !declarationText) + return declarationFilePath; + var declarationMapText = declarationMapPath && host.readFile(declarationMapPath); + // error if no source map or for now if inline sourcemap + if ((declarationMapPath && !declarationMapText) || config.options.inlineSourceMap) + return declarationMapPath || "inline sourcemap decoding"; + var buildInfo = JSON.parse(buildInfoText); + if (!buildInfo.bundle || !buildInfo.bundle.js || (declarationText && !buildInfo.bundle.dts)) + return buildInfoPath; + var ownPrependInput = ts.createInputFiles(jsFileText, declarationText, sourceMapFilePath, sourceMapText, declarationMapPath, declarationMapText, jsFilePath, declarationFilePath, buildInfoPath, buildInfo, + /*onlyOwnText*/ true); + var outputFiles = []; + var prependNodes = ts.createPrependNodes(config.projectReferences, getCommandLine, function (f) { return host.readFile(f); }); + var sourceFilesForJsEmit = createSourceFilesFromBundleBuildInfo(buildInfo.bundle); + var emitHost = { + getPrependNodes: ts.memoize(function () { return prependNodes.concat([ownPrependInput]); }), + getCanonicalFileName: host.getCanonicalFileName, + getCommonSourceDirectory: function () { return buildInfo.bundle.commonSourceDirectory; }, + getCompilerOptions: function () { return config.options; }, + getCurrentDirectory: function () { return host.getCurrentDirectory(); }, + getNewLine: function () { return host.getNewLine(); }, + getSourceFile: function () { return undefined; }, + getSourceFileByPath: function () { return undefined; }, + getSourceFiles: function () { return sourceFilesForJsEmit; }, + getLibFileFromReference: ts.notImplemented, + isSourceFileFromExternalLibrary: ts.returnFalse, + writeFile: function (name, text, writeByteOrderMark) { + switch (name) { + case jsFilePath: + if (jsFileText === text) + return; + break; + case sourceMapFilePath: + if (sourceMapText === text) + return; + break; + case buildInfoPath: + var newBuildInfo = JSON.parse(text); + newBuildInfo.program = buildInfo.program; + // Update sourceFileInfo + var _a = buildInfo.bundle, js = _a.js, dts = _a.dts, sourceFiles = _a.sourceFiles; + newBuildInfo.bundle.js.sources = js.sources; + if (dts) { + newBuildInfo.bundle.dts.sources = dts.sources; + } + newBuildInfo.bundle.sourceFiles = sourceFiles; + outputFiles.push({ name: name, text: getBuildInfoText(newBuildInfo), writeByteOrderMark: writeByteOrderMark }); + return; + case declarationFilePath: + if (declarationText === text) + return; + break; + case declarationMapPath: + if (declarationMapText === text) + return; + break; + default: + ts.Debug.assertNever(name); + } + outputFiles.push({ name: name, text: text, writeByteOrderMark: writeByteOrderMark }); + }, + isEmitBlocked: ts.returnFalse, + readFile: function (f) { return host.readFile(f); }, + fileExists: function (f) { return host.fileExists(f); }, + directoryExists: host.directoryExists && (function (f) { return host.directoryExists(f); }), + useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, + getProgramBuildInfo: function () { return undefined; } + }; + emitFiles(ts.notImplementedResolver, emitHost, /*targetSourceFile*/ undefined, /*emitOnlyDtsFiles*/ false, ts.getTransformers(config.options)); + return outputFiles; + } + ts.emitUsingBuildInfo = emitUsingBuildInfo; var PipelinePhase; (function (PipelinePhase) { PipelinePhase[PipelinePhase["Notification"] = 0] = "Notification"; @@ -82728,6 +83215,10 @@ var ts; var ownWriter; // Reusable `EmitTextWriter` for basic printing. var write = writeBase; var isOwnFileEmit; + var bundleFileInfo = printerOptions.writeBundleFileInfo ? { sections: [] } : undefined; + var recordInternalSection = printerOptions.recordInternalSection; + var sourceFileTextPos = 0; + var sourceFileTextKind = "text" /* Text */; // Source Maps var sourceMapsDisabled = true; var sourceMapGenerator; @@ -82753,7 +83244,8 @@ var ts; writeNode: writeNode, writeList: writeList, writeFile: writeFile, - writeBundle: writeBundle + writeBundle: writeBundle, + bundleFileInfo: bundleFileInfo }; function printNode(hint, node, sourceFile) { switch (hint) { @@ -82768,9 +83260,9 @@ var ts; break; } switch (node.kind) { - case 279 /* SourceFile */: return printFile(node); - case 280 /* Bundle */: return printBundle(node); - case 281 /* UnparsedSource */: return printUnparsedSource(node); + case 284 /* SourceFile */: return printFile(node); + case 285 /* Bundle */: return printBundle(node); + case 286 /* UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -82780,7 +83272,7 @@ var ts; return endPrint(); } function printBundle(bundle) { - writeBundle(bundle, /*bundleInfo*/ undefined, beginPrint(), /*sourceMapEmitter*/ undefined); + writeBundle(bundle, beginPrint(), /*sourceMapEmitter*/ undefined); return endPrint(); } function printFile(sourceFile) { @@ -82808,7 +83300,49 @@ var ts; reset(); writer = previousWriter; } - function writeBundle(bundle, bundleInfo, output, sourceMapGenerator) { + function getTextPosWithWriteLine() { + return writer.getTextPosWithWriteLine ? writer.getTextPosWithWriteLine() : writer.getTextPos(); + } + function updateOrPushBundleFileTextLike(pos, end, kind) { + var last = ts.lastOrUndefined(bundleFileInfo.sections); + if (last && last.kind === kind) { + last.end = end; + } + else { + bundleFileInfo.sections.push({ pos: pos, end: end, kind: kind }); + } + } + function recordBundleFileInternalSectionStart(node) { + if (recordInternalSection && + bundleFileInfo && + currentSourceFile && + (ts.isDeclaration(node) || ts.isVariableStatement(node)) && + ts.isInternalDeclaration(node, currentSourceFile) && + sourceFileTextKind !== "internal" /* Internal */) { + var prevSourceFileTextKind = sourceFileTextKind; + recordBundleFileTextLikeSection(writer.getTextPos()); + sourceFileTextPos = getTextPosWithWriteLine(); + sourceFileTextKind = "internal" /* Internal */; + return prevSourceFileTextKind; + } + return undefined; + } + function recordBundleFileInternalSectionEnd(prevSourceFileTextKind) { + if (prevSourceFileTextKind) { + recordBundleFileTextLikeSection(writer.getTextPos()); + sourceFileTextPos = getTextPosWithWriteLine(); + sourceFileTextKind = prevSourceFileTextKind; + } + } + function recordBundleFileTextLikeSection(end) { + if (sourceFileTextPos < end) { + updateOrPushBundleFileTextLike(sourceFileTextPos, end, sourceFileTextKind); + return true; + } + return false; + } + function writeBundle(bundle, output, sourceMapGenerator) { + var _a; isOwnFileEmit = false; var previousWriter = writer; setWriter(output, sourceMapGenerator); @@ -82816,18 +83350,49 @@ var ts; emitPrologueDirectivesIfNeeded(bundle); emitHelpers(bundle); emitSyntheticTripleSlashReferencesIfNeeded(bundle); - for (var _a = 0, _b = bundle.prepends; _a < _b.length; _a++) { - var prepend = _b[_a]; + for (var _b = 0, _c = bundle.prepends; _b < _c.length; _b++) { + var prepend = _c[_b]; writeLine(); + var pos = writer.getTextPos(); + var savedSections = bundleFileInfo && bundleFileInfo.sections; + if (savedSections) + bundleFileInfo.sections = []; print(4 /* Unspecified */, prepend, /*sourceFile*/ undefined); + if (bundleFileInfo) { + var newSections = bundleFileInfo.sections; + bundleFileInfo.sections = savedSections; + if (prepend.oldFileOfCurrentEmit) + (_a = bundleFileInfo.sections).push.apply(_a, newSections); + else { + newSections.forEach(function (section) { return ts.Debug.assert(ts.isBundleFileTextLike(section)); }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prepend" /* Prepend */, data: prepend.fileName, texts: newSections }); + } + } } - if (bundleInfo) { - bundleInfo.originalOffset = writer.getTextPos(); - } - for (var _c = 0, _d = bundle.sourceFiles; _c < _d.length; _c++) { - var sourceFile = _d[_c]; + sourceFileTextPos = getTextPosWithWriteLine(); + for (var _d = 0, _e = bundle.sourceFiles; _d < _e.length; _d++) { + var sourceFile = _e[_d]; print(0 /* SourceFile */, sourceFile, sourceFile); } + if (bundleFileInfo && bundle.sourceFiles.length) { + var end = writer.getTextPos(); + if (recordBundleFileTextLikeSection(end)) { + // Store prologues + var prologues = getPrologueDirectivesFromBundledSourceFiles(bundle); + if (prologues) { + if (!bundleFileInfo.sources) + bundleFileInfo.sources = {}; + bundleFileInfo.sources.prologues = prologues; + } + // Store helpes + var helpers = getHelpersFromBundledSourceFiles(bundle); + if (helpers) { + if (!bundleFileInfo.sources) + bundleFileInfo.sources = {}; + bundleFileInfo.sources.helpers = helpers; + } + } + } reset(); writer = previousWriter; } @@ -82897,8 +83462,10 @@ var ts; function emit(node) { if (node === undefined) return; + var prevSourceFileTextKind = recordBundleFileInternalSectionStart(node); var pipelinePhase = getPipelinePhase(0 /* Notification */, node); pipelinePhase(4 /* Unspecified */, node); + recordBundleFileInternalSectionEnd(prevSourceFileTextKind); } function emitIdentifierName(node) { if (node === undefined) @@ -82925,12 +83492,12 @@ var ts; } // falls through case 2 /* Comments */: - if (!commentsDisabled && node.kind !== 279 /* SourceFile */) { + if (!commentsDisabled && node.kind !== 284 /* SourceFile */) { return pipelineEmitWithComments; } // falls through case 3 /* SourceMaps */: - if (!sourceMapsDisabled && node.kind !== 279 /* SourceFile */ && !ts.isInJsonFile(node)) { + if (!sourceMapsDisabled && node.kind !== 284 /* SourceFile */ && !ts.isInJsonFile(node)) { return pipelineEmitWithSourceMap; } // falls through @@ -82967,8 +83534,16 @@ var ts; case 16 /* TemplateMiddle */: case 17 /* TemplateTail */: return emitLiteral(node); - case 281 /* UnparsedSource */: - return emitUnparsedSource(node); + case 286 /* UnparsedSource */: + case 280 /* UnparsedPrepend */: + return emitUnparsedSourceOrPrepend(node); + case 279 /* UnparsedPrologue */: + return writeUnparsedNode(node); + case 281 /* UnparsedText */: + case 282 /* UnparsedInternalText */: + return emitUnparsedTextLike(node); + case 283 /* UnparsedSyntheticReference */: + return emitUnparsedSyntheticReference(node); // Identifiers case 72 /* Identifier */: return emitIdentifier(node); @@ -83012,7 +83587,7 @@ var ts; return emitTypeReference(node); case 165 /* FunctionType */: return emitFunctionType(node); - case 289 /* JSDocFunctionType */: + case 294 /* JSDocFunctionType */: return emitJSDocFunctionType(node); case 166 /* ConstructorType */: return emitConstructorType(node); @@ -83050,20 +83625,20 @@ var ts; return emitLiteralType(node); case 183 /* ImportType */: return emitImportTypeNode(node); - case 284 /* JSDocAllType */: + case 289 /* JSDocAllType */: writePunctuation("*"); return; - case 285 /* JSDocUnknownType */: + case 290 /* JSDocUnknownType */: writePunctuation("?"); return; - case 286 /* JSDocNullableType */: + case 291 /* JSDocNullableType */: return emitJSDocNullableType(node); - case 287 /* JSDocNonNullableType */: + case 292 /* JSDocNonNullableType */: return emitJSDocNonNullableType(node); - case 288 /* JSDocOptionalType */: + case 293 /* JSDocOptionalType */: return emitJSDocOptionalType(node); case 172 /* RestType */: - case 290 /* JSDocVariadicType */: + case 295 /* JSDocVariadicType */: return emitRestOrJSDocVariadicType(node); // Binding patterns case 184 /* ObjectBindingPattern */: @@ -83201,30 +83776,30 @@ var ts; case 278 /* EnumMember */: return emitEnumMember(node); // JSDoc nodes (only used in codefixes currently) - case 299 /* JSDocParameterTag */: - case 305 /* JSDocPropertyTag */: + case 304 /* JSDocParameterTag */: + case 310 /* JSDocPropertyTag */: return emitJSDocPropertyLikeTag(node); - case 300 /* JSDocReturnTag */: - case 302 /* JSDocTypeTag */: - case 301 /* JSDocThisTag */: - case 298 /* JSDocEnumTag */: + case 305 /* JSDocReturnTag */: + case 307 /* JSDocTypeTag */: + case 306 /* JSDocThisTag */: + case 303 /* JSDocEnumTag */: return emitJSDocSimpleTypedTag(node); - case 295 /* JSDocAugmentsTag */: + case 300 /* JSDocAugmentsTag */: return emitJSDocAugmentsTag(node); - case 303 /* JSDocTemplateTag */: + case 308 /* JSDocTemplateTag */: return emitJSDocTemplateTag(node); - case 304 /* JSDocTypedefTag */: + case 309 /* JSDocTypedefTag */: return emitJSDocTypedefTag(node); - case 297 /* JSDocCallbackTag */: + case 302 /* JSDocCallbackTag */: return emitJSDocCallbackTag(node); - case 293 /* JSDocSignature */: + case 298 /* JSDocSignature */: return emitJSDocSignature(node); - case 292 /* JSDocTypeLiteral */: + case 297 /* JSDocTypeLiteral */: return emitJSDocTypeLiteral(node); - case 296 /* JSDocClassTag */: - case 294 /* JSDocTag */: + case 301 /* JSDocClassTag */: + case 299 /* JSDocTag */: return emitJSDocSimpleTag(node); - case 291 /* JSDocComment */: + case 296 /* JSDocComment */: return emitJSDoc(node); // Transformation nodes (ignored) } @@ -83323,9 +83898,9 @@ var ts; case 264 /* JsxFragment */: return emitJsxFragment(node); // Transformation nodes - case 308 /* PartiallyEmittedExpression */: + case 313 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 309 /* CommaListExpression */: + case 314 /* CommaListExpression */: return emitCommaList(node); } } @@ -83341,22 +83916,45 @@ var ts; var pipelinePhase = getNextPipelinePhase(1 /* Substitution */, node); pipelinePhase(hint, substituteNode(hint, node)); } + function getHelpersFromBundledSourceFiles(bundle) { + var result; + if (moduleKind === ts.ModuleKind.None || printerOptions.noEmitHelpers) { + return undefined; + } + var bundledHelpers = ts.createMap(); + for (var _a = 0, _b = bundle.sourceFiles; _a < _b.length; _a++) { + var sourceFile = _b[_a]; + var shouldSkip = ts.getExternalHelpersModuleName(sourceFile) !== undefined; + var helpers = getSortedEmitHelpers(sourceFile); + if (!helpers) + continue; + for (var _c = 0, helpers_3 = helpers; _c < helpers_3.length; _c++) { + var helper = helpers_3[_c]; + if (!helper.scoped && !shouldSkip && !bundledHelpers.get(helper.name)) { + bundledHelpers.set(helper.name, true); + (result || (result = [])).push(helper.name); + } + } + } + return result; + } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 280 /* Bundle */ ? node : undefined; + var bundle = node.kind === 285 /* Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } - var numNodes = bundle ? bundle.sourceFiles.length : 1; + var numPrepends = bundle ? bundle.prepends.length : 0; + var numNodes = bundle ? bundle.sourceFiles.length + numPrepends : 1; for (var i = 0; i < numNodes; i++) { - var currentNode = bundle ? bundle.sourceFiles[i] : node; - var sourceFile = ts.isSourceFile(currentNode) ? currentNode : currentSourceFile; - var shouldSkip = printerOptions.noEmitHelpers || ts.getExternalHelpersModuleName(sourceFile) !== undefined; - var shouldBundle = ts.isSourceFile(currentNode) && !isOwnFileEmit; - var helpers = ts.getEmitHelpers(currentNode); + var currentNode = bundle ? i < numPrepends ? bundle.prepends[i] : bundle.sourceFiles[i - numPrepends] : node; + var sourceFile = ts.isSourceFile(currentNode) ? currentNode : ts.isUnparsedSource(currentNode) ? undefined : currentSourceFile; + var shouldSkip = printerOptions.noEmitHelpers || (!!sourceFile && ts.getExternalHelpersModuleName(sourceFile) !== undefined); + var shouldBundle = (ts.isSourceFile(currentNode) || ts.isUnparsedSource(currentNode)) && !isOwnFileEmit; + var helpers = ts.isUnparsedSource(currentNode) ? currentNode.helpers : getSortedEmitHelpers(currentNode); if (helpers) { - for (var _a = 0, _b = ts.stableSort(helpers, ts.compareEmitHelpers); _a < _b.length; _a++) { - var helper = _b[_a]; + for (var _a = 0, helpers_4 = helpers; _a < helpers_4.length; _a++) { + var helper = helpers_4[_a]; if (!helper.scoped) { // Skip the helper if it can be skipped and the noEmitHelpers compiler // option is set, or if it can be imported and the importHelpers compiler @@ -83376,18 +83974,25 @@ var ts; // Skip the helper if it is scoped and we are emitting bundled helpers continue; } + var pos = getTextPosWithWriteLine(); if (typeof helper.text === "string") { writeLines(helper.text); } else { writeLines(helper.text(makeFileLevelOptimisticUniqueName)); } + if (bundleFileInfo) + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "emitHelpers" /* EmitHelpers */, data: helper.name }); helpersEmitted = true; } } } return helpersEmitted; } + function getSortedEmitHelpers(node) { + var helpers = ts.getEmitHelpers(node); + return helpers && ts.stableSort(helpers, ts.compareEmitHelpers); + } // // Literals/Pseudo-literals // @@ -83414,8 +84019,42 @@ var ts; } } // SyntaxKind.UnparsedSource - function emitUnparsedSource(unparsed) { - writer.rawWrite(unparsed.text); + // SyntaxKind.UnparsedPrepend + function emitUnparsedSourceOrPrepend(unparsed) { + for (var _a = 0, _b = unparsed.texts; _a < _b.length; _a++) { + var text = _b[_a]; + writeLine(); + emit(text); + } + } + // SyntaxKind.UnparsedPrologue + // SyntaxKind.UnparsedText + // SyntaxKind.UnparsedInternal + // SyntaxKind.UnparsedSyntheticReference + function writeUnparsedNode(unparsed) { + writer.rawWrite(unparsed.parent.text.substring(unparsed.pos, unparsed.end)); + } + // SyntaxKind.UnparsedText + // SyntaxKind.UnparsedInternal + function emitUnparsedTextLike(unparsed) { + var pos = getTextPosWithWriteLine(); + writeUnparsedNode(unparsed); + if (bundleFileInfo) { + updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 281 /* UnparsedText */ ? + "text" /* Text */ : + "internal" /* Internal */); + } + } + // SyntaxKind.UnparsedSyntheticReference + function emitUnparsedSyntheticReference(unparsed) { + var pos = getTextPosWithWriteLine(); + writeUnparsedNode(unparsed); + if (bundleFileInfo) { + var section = ts.clone(unparsed.section); + section.pos = pos; + section.end = writer.getTextPos(); + bundleFileInfo.sections.push(section); + } } // // Identifiers @@ -83470,7 +84109,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 289 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 294 /* JSDocFunctionType */ && !node.name) { emit(node.type); } else { @@ -84350,7 +84989,7 @@ var ts; } function emitBlockFunctionBodyWorker(body, emitBlockFunctionBodyOnSingleLine) { // Emit all the prologue directives (like "use strict"). - var statementOffset = emitPrologueDirectives(body.statements, /*startWithNewLine*/ true); + var statementOffset = emitPrologueDirectives(body.statements); var pos = writer.getTextPos(); emitHelpers(body); if (statementOffset === 0 && pos === writer.getTextPos() && emitBlockFunctionBodyOnSingleLine) { @@ -84755,7 +85394,7 @@ var ts; } } if (node.tags) { - if (node.tags.length === 1 && node.tags[0].kind === 302 /* JSDocTypeTag */ && !node.comment) { + if (node.tags.length === 1 && node.tags[0].kind === 307 /* JSDocTypeTag */ && !node.comment) { writeSpace(); emit(node.tags[0]); } @@ -84789,7 +85428,7 @@ var ts; function emitJSDocTypedefTag(tag) { emitJSDocTagName(tag.tagName); if (tag.typeExpression) { - if (tag.typeExpression.kind === 283 /* JSDocTypeExpression */) { + if (tag.typeExpression.kind === 288 /* JSDocTypeExpression */) { emitJSDocTypeExpression(tag.typeExpression); } else { @@ -84808,7 +85447,7 @@ var ts; emit(tag.fullName); } emitJSDocComment(tag.comment); - if (tag.typeExpression && tag.typeExpression.kind === 292 /* JSDocTypeLiteral */) { + if (tag.typeExpression && tag.typeExpression.kind === 297 /* JSDocTypeLiteral */) { emitJSDocTypeLiteral(tag.typeExpression); } } @@ -84895,6 +85534,16 @@ var ts; } function emitSyntheticTripleSlashReferencesIfNeeded(node) { emitTripleSlashDirectives(!!node.hasNoDefaultLib, node.syntheticFileReferences || [], node.syntheticTypeReferences || [], node.syntheticLibReferences || []); + for (var _a = 0, _b = node.prepends; _a < _b.length; _a++) { + var prepend = _b[_a]; + if (ts.isUnparsedSource(prepend) && prepend.syntheticReferences) { + for (var _c = 0, _d = prepend.syntheticReferences; _c < _d.length; _c++) { + var ref = _d[_c]; + emit(ref); + writeLine(); + } + } + } } function emitTripleSlashDirectivesIfNeeded(node) { if (node.isDeclarationFile) @@ -84902,7 +85551,10 @@ var ts; } function emitTripleSlashDirectives(hasNoDefaultLib, files, types, libs) { if (hasNoDefaultLib) { + var pos = writer.getTextPos(); writeComment("/// "); + if (bundleFileInfo) + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "no-default-lib" /* NoDefaultLib */ }); writeLine(); } if (currentSourceFile && currentSourceFile.moduleName) { @@ -84923,17 +85575,26 @@ var ts; } for (var _c = 0, files_1 = files; _c < files_1.length; _c++) { var directive = files_1[_c]; + var pos = writer.getTextPos(); writeComment("/// "); + if (bundleFileInfo) + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference" /* Reference */, data: directive.fileName }); writeLine(); } for (var _d = 0, types_19 = types; _d < types_19.length; _d++) { var directive = types_19[_d]; + var pos = writer.getTextPos(); writeComment("/// "); + if (bundleFileInfo) + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "type" /* Type */, data: directive.fileName }); writeLine(); } for (var _e = 0, libs_1 = libs; _e < libs_1.length; _e++) { var directive = libs_1[_e]; + var pos = writer.getTextPos(); writeComment("/// "); + if (bundleFileInfo) + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "lib" /* Lib */, data: directive.fileName }); writeLine(); } } @@ -84958,16 +85619,22 @@ var ts; * Emits any prologue directives at the start of a Statement list, returning the * number of prologue directives written to the output. */ - function emitPrologueDirectives(statements, startWithNewLine, seenPrologueDirectives) { + function emitPrologueDirectives(statements, sourceFile, seenPrologueDirectives) { + var needsToSetSourceFile = !!sourceFile; for (var i = 0; i < statements.length; i++) { var statement = statements[i]; if (ts.isPrologueDirective(statement)) { var shouldEmitPrologueDirective = seenPrologueDirectives ? !seenPrologueDirectives.has(statement.expression.text) : true; if (shouldEmitPrologueDirective) { - if (startWithNewLine || i > 0) { - writeLine(); + if (needsToSetSourceFile) { + needsToSetSourceFile = false; + setSourceFile(sourceFile); } + writeLine(); + var pos = writer.getTextPos(); emit(statement); + if (bundleFileInfo) + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* Prologue */, data: statement.expression.text }); if (seenPrologueDirectives) { seenPrologueDirectives.set(statement.expression.text, true); } @@ -84980,23 +85647,70 @@ var ts; } return statements.length; } + function emitUnparsedPrologues(prologues, seenPrologueDirectives) { + for (var _a = 0, prologues_1 = prologues; _a < prologues_1.length; _a++) { + var prologue = prologues_1[_a]; + if (!seenPrologueDirectives.has(prologue.data)) { + writeLine(); + var pos = writer.getTextPos(); + emit(prologue); + if (bundleFileInfo) + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* Prologue */, data: prologue.data }); + if (seenPrologueDirectives) { + seenPrologueDirectives.set(prologue.data, true); + } + } + } + } function emitPrologueDirectivesIfNeeded(sourceFileOrBundle) { if (ts.isSourceFile(sourceFileOrBundle)) { - setSourceFile(sourceFileOrBundle); - emitPrologueDirectives(sourceFileOrBundle.statements); + emitPrologueDirectives(sourceFileOrBundle.statements, sourceFileOrBundle); } else { var seenPrologueDirectives = ts.createMap(); - for (var _a = 0, _b = sourceFileOrBundle.sourceFiles; _a < _b.length; _a++) { - var sourceFile = _b[_a]; - setSourceFile(sourceFile); - emitPrologueDirectives(sourceFile.statements, /*startWithNewLine*/ true, seenPrologueDirectives); + for (var _a = 0, _b = sourceFileOrBundle.prepends; _a < _b.length; _a++) { + var prepend = _b[_a]; + emitUnparsedPrologues(prepend.prologues, seenPrologueDirectives); + } + for (var _c = 0, _d = sourceFileOrBundle.sourceFiles; _c < _d.length; _c++) { + var sourceFile = _d[_c]; + emitPrologueDirectives(sourceFile.statements, sourceFile, seenPrologueDirectives); } setSourceFile(undefined); } } + function getPrologueDirectivesFromBundledSourceFiles(bundle) { + var seenPrologueDirectives = ts.createMap(); + var prologues; + for (var index = 0; index < bundle.sourceFiles.length; index++) { + var sourceFile = bundle.sourceFiles[index]; + var directives = void 0; + var end = 0; + for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { + var statement = _b[_a]; + if (!ts.isPrologueDirective(statement)) + break; + if (seenPrologueDirectives.has(statement.expression.text)) + continue; + seenPrologueDirectives.set(statement.expression.text, true); + (directives || (directives = [])).push({ + pos: statement.pos, + end: statement.end, + expression: { + pos: statement.expression.pos, + end: statement.expression.end, + text: statement.expression.text + } + }); + end = end < statement.end ? statement.end : end; + } + if (directives) + (prologues || (prologues = [])).push({ file: index, text: sourceFile.text.substring(0, end), directives: directives }); + } + return prologues; + } function emitShebangIfNeeded(sourceFileOrBundle) { - if (ts.isSourceFile(sourceFileOrBundle)) { + if (ts.isSourceFile(sourceFileOrBundle) || ts.isUnparsedSource(sourceFileOrBundle)) { var shebang = ts.getShebang(sourceFileOrBundle.text); if (shebang) { writeComment(shebang); @@ -85005,11 +85719,18 @@ var ts; } } else { - for (var _a = 0, _b = sourceFileOrBundle.sourceFiles; _a < _b.length; _a++) { - var sourceFile = _b[_a]; + for (var _a = 0, _b = sourceFileOrBundle.prepends; _a < _b.length; _a++) { + var prepend = _b[_a]; + ts.Debug.assertNode(prepend, ts.isUnparsedSource); + if (emitShebangIfNeeded(prepend)) { + return true; + } + } + for (var _c = 0, _d = sourceFileOrBundle.sourceFiles; _c < _d.length; _c++) { + var sourceFile = _d[_c]; // Emit only the first encountered shebang if (emitShebangIfNeeded(sourceFile)) { - break; + return true; } } } @@ -85212,6 +85933,7 @@ var ts; } // Emit each child. var previousSibling = void 0; + var previousSourceFileTextKind = void 0; var shouldDecreaseIndentAfterEmit = false; for (var i = 0; i < count; i++) { var child = children[start + i]; @@ -85232,6 +85954,7 @@ var ts; emitLeadingCommentsOfPosition(previousSibling.end); } writeDelimiter(format); + recordBundleFileInternalSectionEnd(previousSourceFileTextKind); // Write either a line terminator or whitespace to separate the elements. if (shouldWriteSeparatingLineTerminator(previousSibling, child, format)) { // If a synthesized node in a single-line list starts on a new @@ -85248,6 +85971,7 @@ var ts; } } // Emit this child. + previousSourceFileTextKind = recordBundleFileInternalSectionStart(child); if (shouldEmitInterveningComments) { if (emitTrailingCommentsOfPosition) { var commentRange = ts.getCommentRange(child); @@ -85282,6 +86006,7 @@ var ts; if (format & 128 /* Indented */) { decreaseIndent(); } + recordBundleFileInternalSectionEnd(previousSourceFileTextKind); // Write the closing line terminator or closing whitespace. if (shouldWriteClosingLineTerminator(parentNode, children, format)) { writeLine(); @@ -85383,7 +86108,6 @@ var ts; if (line.length) { writeLine(); write(line); - writer.rawWrite(newLine); } } } @@ -85897,7 +86621,7 @@ var ts; hasWrittenComment = false; var emitFlags = ts.getEmitFlags(node); var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end; - var isEmittedNode = node.kind !== 307 /* NotEmittedStatement */; + var isEmittedNode = node.kind !== 312 /* NotEmittedStatement */; // We have to explicitly check that the node is JsxText because if the compilerOptions.jsx is "preserve" we will not do any transformation. // It is expensive to walk entire tree just to set one kind of node to have no comments. var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0 || node.kind === 11 /* JsxText */; @@ -86157,19 +86881,28 @@ var ts; return ts.isRecognizedTripleSlashComment(currentSourceFile.text, commentPos, commentEnd); } // Source Maps + function getParsedSourceMap(node) { + if (node.parsedSourceMap === undefined && node.sourceMapText !== undefined) { + node.parsedSourceMap = ts.tryParseRawSourceMap(node.sourceMapText) || false; + } + return node.parsedSourceMap || undefined; + } function pipelineEmitWithSourceMap(hint, node) { var pipelinePhase = getNextPipelinePhase(3 /* SourceMaps */, node); - if (ts.isUnparsedSource(node) && node.sourceMapText !== undefined) { - var parsed = ts.tryParseRawSourceMap(node.sourceMapText); - if (parsed) { - sourceMapGenerator.appendSourceMap(writer.getLine(), writer.getColumn(), parsed, node.sourceMapPath); + if (ts.isUnparsedSource(node) || ts.isUnparsedPrepend(node)) { + pipelinePhase(hint, node); + } + else if (ts.isUnparsedNode(node)) { + var parsed = getParsedSourceMap(node.parent); + if (parsed && sourceMapGenerator) { + sourceMapGenerator.appendSourceMap(writer.getLine(), writer.getColumn(), parsed, node.parent.sourceMapPath, node.parent.getLineAndCharacterOfPosition(node.pos), node.parent.getLineAndCharacterOfPosition(node.end)); } pipelinePhase(hint, node); } else { var _a = ts.getSourceMapRange(node), pos = _a.pos, end = _a.end, _b = _a.source, source = _b === void 0 ? sourceMapSource : _b; var emitFlags = ts.getEmitFlags(node); - if (node.kind !== 307 /* NotEmittedStatement */ + if (node.kind !== 312 /* NotEmittedStatement */ && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 && pos >= 0) { emitSourcePos(source, skipSourceTrivia(source, pos)); @@ -86182,7 +86915,7 @@ var ts; else { pipelinePhase(hint, node); } - if (node.kind !== 307 /* NotEmittedStatement */ + if (node.kind !== 312 /* NotEmittedStatement */ && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 && end >= 0) { emitSourcePos(source, end); @@ -86830,7 +87563,8 @@ var ts; var value = readFileCache.get(key); if (value !== undefined) return value !== false ? value : undefined; // could be .d.ts from output - if (!ts.fileExtensionIs(fileName, ".json" /* Json */)) { + // Cache json or buildInfo + if (!ts.fileExtensionIs(fileName, ".json" /* Json */) && !ts.isBuildInfoFile(fileName)) { return originalReadFile.call(host, fileName); } return setReadFileCache(key, fileName); @@ -86861,7 +87595,7 @@ var ts; var key = toPath(fileName); fileExistsCache.delete(key); var value = readFileCache.get(key); - if (value && value !== data) { + if (value !== undefined && value !== data) { readFileCache.delete(key); sourceFileCache.delete(key); } @@ -87416,7 +88150,8 @@ var ts; getProjectReferenceRedirect: getProjectReferenceRedirect, getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, getResolvedProjectReferenceByPath: getResolvedProjectReferenceByPath, - forEachResolvedProjectReference: forEachResolvedProjectReference + forEachResolvedProjectReference: forEachResolvedProjectReference, + emitBuildInfo: emitBuildInfo }; verifyCompilerOptions(); ts.performance.mark("afterProgram"); @@ -87843,7 +88578,20 @@ var ts; return false; // Before falling back to the host return host.fileExists(f); - } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {}), { useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); } }); + } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {}), { useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, getProgramBuildInfo: function () { return program.getProgramBuildInfo && program.getProgramBuildInfo(); } }); + } + function emitBuildInfo(writeFileCallback) { + ts.Debug.assert(!options.out && !options.outFile); + ts.performance.mark("beforeEmit"); + var emitResult = ts.emitFiles(ts.notImplementedResolver, getEmitHost(writeFileCallback), + /*targetSourceFile*/ undefined, + /*emitOnlyDtsFiles*/ false, + /*transformers*/ undefined, + /*declaraitonTransformers*/ undefined, + /*onlyBuildInfo*/ true); + ts.performance.mark("afterEmit"); + ts.performance.measure("Emit", "beforeEmit", "afterEmit"); + return emitResult; } function getResolvedProjectReferences() { return resolvedProjectReferences; @@ -87852,28 +88600,11 @@ var ts; return projectReferences; } function getPrependNodes() { - if (!projectReferences) { - return ts.emptyArray; - } - var nodes = []; - for (var i = 0; i < projectReferences.length; i++) { - var ref = projectReferences[i]; - var resolvedRefOpts = resolvedProjectReferences[i].commandLine; - if (ref.prepend && resolvedRefOpts && resolvedRefOpts.options) { - var out = resolvedRefOpts.options.outFile || resolvedRefOpts.options.out; - // Upstream project didn't have outFile set -- skip (error will have been issued earlier) - if (!out) - continue; - var _a = ts.getOutputPathsForBundle(resolvedRefOpts.options, /*forceDtsPaths*/ true), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath; - var node = ts.createInputFiles(function (fileName) { - var path = toPath(fileName); - var sourceFile = getSourceFileByPath(path); - return sourceFile ? sourceFile.text : filesByName.has(path) ? undefined : host.readFile(path); - }, jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath); - nodes.push(node); - } - } - return nodes; + return createPrependNodes(projectReferences, function (_ref, index) { return resolvedProjectReferences[index].commandLine; }, function (fileName) { + var path = toPath(fileName); + var sourceFile = getSourceFileByPath(path); + return sourceFile ? sourceFile.text : filesByName.has(path) ? undefined : host.readFile(path); + }); } function isSourceFileFromExternalLibrary(file) { return !!sourceFilesFoundSearchingNodeModules.get(file.path); @@ -87945,8 +88676,7 @@ var ts; var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile, cancellationToken); ts.performance.mark("beforeEmit"); var transformers = emitOnlyDtsFiles ? [] : ts.getTransformers(options, customTransformers); - var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, // TODO: GH#18217 - emitOnlyDtsFiles, transformers, customTransformers && customTransformers.afterDeclarations); + var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, emitOnlyDtsFiles, transformers, customTransformers && customTransformers.afterDeclarations); ts.performance.mark("afterEmit"); ts.performance.measure("Emit", "beforeEmit", "afterEmit"); return emitResult; @@ -88948,6 +89678,14 @@ var ts; if (options.declaration === false) { createDiagnosticForOptionName(ts.Diagnostics.Composite_projects_may_not_disable_declaration_emit, "declaration"); } + if (options.incremental === false) { + createDiagnosticForOptionName(ts.Diagnostics.Composite_projects_may_not_disable_incremental_compilation, "declaration"); + } + } + if (options.tsBuildInfoFile) { + if (!ts.isIncrementalCompilation(options)) { + createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "tsBuildInfoFile", "incremental", "composite"); + } } verifyProjectReferences(); // List of collected files is complete; validate exhautiveness if this is a project with a file list @@ -89142,6 +89880,7 @@ var ts; } } function verifyProjectReferences() { + var buildInfoPath = !options.noEmit && !options.suppressOutputPathCheck ? ts.getOutputPathForBuildInfo(options) : undefined; forEachProjectReference(projectReferences, resolvedProjectReferences, function (resolvedRef, index, parent) { var ref = (parent ? parent.commandLine.projectReferences : projectReferences)[index]; var parentFile = parent && parent.sourceFile; @@ -89168,6 +89907,10 @@ var ts; createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_prepend_project_0_because_it_does_not_have_outFile_set, ref.path); } } + if (!parent && buildInfoPath && buildInfoPath === ts.getOutputPathForBuildInfo(options)) { + createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_write_file_0_because_it_will_overwrite_tsbuildinfo_file_generated_by_referenced_project_1, buildInfoPath, ref.path); + hasEmitBlockingDiagnostics.set(toPath(buildInfoPath), true); + } }); } function createDiagnosticForOptionPathKeyValue(key, valueIndex, message, arg0, arg1, arg2) { @@ -89317,6 +90060,27 @@ var ts; }; } ts.parseConfigHostFromCompilerHostLike = parseConfigHostFromCompilerHostLike; + /* @internal */ + function createPrependNodes(projectReferences, getCommandLine, readFile) { + if (!projectReferences) + return ts.emptyArray; + var nodes; + for (var i = 0; i < projectReferences.length; i++) { + var ref = projectReferences[i]; + var resolvedRefOpts = getCommandLine(ref, i); + if (ref.prepend && resolvedRefOpts && resolvedRefOpts.options) { + var out = resolvedRefOpts.options.outFile || resolvedRefOpts.options.out; + // Upstream project didn't have outFile set -- skip (error will have been issued earlier) + if (!out) + continue; + var _a = ts.getOutputPathsForBundle(resolvedRefOpts.options, /*forceDtsPaths*/ true), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath; + var node = ts.createInputFiles(readFile, jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, buildInfoPath); + (nodes || (nodes = [])).push(node); + } + } + return nodes || ts.emptyArray; + } + ts.createPrependNodes = createPrependNodes; function resolveProjectReferencePath(hostOrRef, ref) { var passedInRef = ref ? ref : hostOrRef; return ts.resolveConfigFileProjectName(passedInRef.path); @@ -89860,11 +90624,14 @@ var ts; var affectedSignatures = oldState.currentAffectedFilesSignatures; ts.Debug.assert(!oldState.affectedFiles && (!affectedSignatures || !affectedSignatures.size), "Cannot reuse if only few affected files of currentChangedFile were iterated"); } + var changedFilesSet = oldState.changedFilesSet; if (canCopySemanticDiagnostics) { - ts.Debug.assert(!ts.forEachKey(oldState.changedFilesSet, function (path) { return oldState.semanticDiagnosticsPerFile.has(path); }), "Semantic diagnostics shouldnt be available for changed files"); + ts.Debug.assert(!changedFilesSet || !ts.forEachKey(changedFilesSet, function (path) { return oldState.semanticDiagnosticsPerFile.has(path); }), "Semantic diagnostics shouldnt be available for changed files"); } // Copy old state's changed files set - ts.copyEntries(oldState.changedFilesSet, state.changedFilesSet); + if (changedFilesSet) { + ts.copyEntries(changedFilesSet, state.changedFilesSet); + } if (!compilerOptions.outFile && !compilerOptions.out && oldState.affectedFilesPendingEmit) { state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit; state.affectedFilesPendingEmitIndex = oldState.affectedFilesPendingEmitIndex; @@ -89910,6 +90677,18 @@ var ts; } } }); + if (oldCompilerOptions && + (oldCompilerOptions.outDir !== compilerOptions.outDir || + oldCompilerOptions.declarationDir !== compilerOptions.declarationDir || + (oldCompilerOptions.outFile || oldCompilerOptions.out) !== (compilerOptions.outFile || compilerOptions.out))) { + // Add all files to affectedFilesPendingEmit since emit changed + state.affectedFilesPendingEmit = ts.concatenate(state.affectedFilesPendingEmit, newProgram.getSourceFiles().map(function (f) { return f.path; })); + if (state.affectedFilesPendingEmitIndex === undefined) { + state.affectedFilesPendingEmitIndex = 0; + } + ts.Debug.assert(state.seenAffectedFiles === undefined); + state.seenAffectedFiles = ts.createMap(); + } return state; } /** @@ -90131,8 +90910,11 @@ var ts; * This is called after completing operation on the next affected file. * The operations here are postponed to ensure that cancellation during the iteration is handled correctly */ - function doneWithAffectedFile(state, affected, isPendingEmit) { - if (affected === state.program) { + function doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit) { + if (isBuildInfoEmit) { + state.emittedBuildInfo = true; + } + else if (affected === state.program) { state.changedFilesSet.clear(); state.programEmitComplete = true; } @@ -90149,8 +90931,8 @@ var ts; /** * Returns the result with affected file */ - function toAffectedFileResult(state, result, affected, isPendingEmit) { - doneWithAffectedFile(state, affected, isPendingEmit); + function toAffectedFileResult(state, result, affected, isPendingEmit, isBuildInfoEmit) { + doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit); return { result: result, affected: affected }; } /** @@ -90173,6 +90955,46 @@ var ts; } return diagnostics; } + /** + * Gets the program information to be emitted in buildInfo so that we can use it to create new program + */ + function getProgramBuildInfo(state) { + if (state.compilerOptions.outFile || state.compilerOptions.out) + return undefined; + var fileInfos = {}; + state.fileInfos.forEach(function (value, key) { + var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key); + fileInfos[key] = signature === undefined ? value : { version: value.version, signature: signature }; + }); + var result = { fileInfos: fileInfos, options: state.compilerOptions }; + if (state.referencedMap) { + var referencedMap_1 = {}; + state.referencedMap.forEach(function (value, key) { + referencedMap_1[key] = ts.arrayFrom(value.keys()); + }); + result.referencedMap = referencedMap_1; + } + if (state.exportedModulesMap) { + var exportedModulesMap_1 = {}; + state.exportedModulesMap.forEach(function (value, key) { + var newValue = state.currentAffectedFilesExportedModulesMap && state.currentAffectedFilesExportedModulesMap.get(key); + // Not in temporary cache, use existing value + if (newValue === undefined) + exportedModulesMap_1[key] = ts.arrayFrom(value.keys()); + // Value in cache and has updated value map, use that + else if (newValue) + exportedModulesMap_1[key] = ts.arrayFrom(newValue.keys()); + }); + result.exportedModulesMap = exportedModulesMap_1; + } + if (state.semanticDiagnosticsPerFile) { + var semanticDiagnosticsPerFile_1 = []; + // Currently not recording actual errors since those mean no emit for tsc --build + state.semanticDiagnosticsPerFile.forEach(function (_value, key) { return semanticDiagnosticsPerFile_1.push(key); }); + result.semanticDiagnosticsPerFile = semanticDiagnosticsPerFile_1; + } + return result; + } var BuilderProgramKind; (function (BuilderProgramKind) { BuilderProgramKind[BuilderProgramKind["SemanticDiagnosticsBuilderProgram"] = 0] = "SemanticDiagnosticsBuilderProgram"; @@ -90229,6 +91051,7 @@ var ts; var computeHash = host.createHash || ts.generateDjb2Hash; var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState); var backupState; + newProgram.getProgramBuildInfo = function () { return result.getProgramBuildInfo(); }; // To ensure that we arent storing any references to old program or new program without state newProgram = undefined; // TODO: GH#18217 oldProgram = undefined; @@ -90250,6 +91073,7 @@ var ts; releaseCache(state); backupState = undefined; }; + result.getProgramBuildInfo = function () { return getProgramBuildInfo(state); }; if (kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram) { result.getSemanticDiagnosticsOfNextAffectedFile = getSemanticDiagnosticsOfNextAffectedFile; } @@ -90272,7 +91096,16 @@ var ts; if (!state.compilerOptions.out && !state.compilerOptions.outFile) { affected = getNextAffectedFilePendingEmit(state); if (!affected) { - return undefined; + if (state.emittedBuildInfo) { + return undefined; + } + var affected_1 = ts.Debug.assertDefined(state.program); + return toAffectedFileResult(state, + // When whole program is affected, do emit only once (eg when --out or --outFile is specified) + // Otherwise just affected file + affected_1.emitBuildInfo(writeFile || host.writeFile, cancellationToken), affected_1, + /*isPendingEmitFile*/ false, + /*isBuildInfoEmit*/ true); } isPendingEmitFile = true; } @@ -90405,6 +91238,53 @@ var ts; } } ts.createBuilderProgram = createBuilderProgram; + function getMapOfReferencedSet(mapLike) { + if (!mapLike) + return undefined; + var map = ts.createMap(); + // Copies keys/values from template. Note that for..in will not throw if + // template is undefined, and instead will just exit the loop. + for (var key in mapLike) { + if (ts.hasProperty(mapLike, key)) { + map.set(key, ts.arrayToSet(mapLike[key])); + } + } + return map; + } + function createBuildProgramUsingProgramBuildInfo(program) { + var fileInfos = ts.createMapFromTemplate(program.fileInfos); + var state = { + fileInfos: fileInfos, + compilerOptions: program.options, + referencedMap: getMapOfReferencedSet(program.referencedMap), + exportedModulesMap: getMapOfReferencedSet(program.exportedModulesMap), + semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && ts.arrayToMap(program.semanticDiagnosticsPerFile, ts.identity, function () { return ts.emptyArray; }) + }; + return { + getState: function () { return state; }, + backupState: ts.noop, + restoreState: ts.noop, + getProgram: ts.notImplemented, + getProgramOrUndefined: function () { return undefined; }, + releaseProgram: ts.noop, + getCompilerOptions: function () { return state.compilerOptions; }, + getSourceFile: ts.notImplemented, + getSourceFiles: ts.notImplemented, + getOptionsDiagnostics: ts.notImplemented, + getGlobalDiagnostics: ts.notImplemented, + getConfigFileParsingDiagnostics: ts.notImplemented, + getSyntacticDiagnostics: ts.notImplemented, + getDeclarationDiagnostics: ts.notImplemented, + getSemanticDiagnostics: ts.notImplemented, + emit: ts.notImplemented, + getAllDependencies: ts.notImplemented, + getCurrentDirectory: ts.notImplemented, + emitNextAffectedFile: ts.notImplemented, + getSemanticDiagnosticsOfNextAffectedFile: ts.notImplemented, + getProgramBuildInfo: ts.notImplemented + }; + } + ts.createBuildProgramUsingProgramBuildInfo = createBuildProgramUsingProgramBuildInfo; function createRedirectedBuilderProgram(state, configFileParsingDiagnostics) { return { getState: ts.notImplemented, @@ -90424,7 +91304,8 @@ var ts; getSemanticDiagnostics: function (sourceFile, cancellationToken) { return getProgram().getSemanticDiagnostics(sourceFile, cancellationToken); }, emit: function (sourceFile, writeFile, cancellationToken, emitOnlyDts, customTransformers) { return getProgram().emit(sourceFile, writeFile, cancellationToken, emitOnlyDts, customTransformers); }, getAllDependencies: ts.notImplemented, - getCurrentDirectory: function () { return getProgram().getCurrentDirectory(); } + getCurrentDirectory: function () { return getProgram().getCurrentDirectory(); }, + getProgramBuildInfo: function () { return undefined; } }; function getProgram() { return ts.Debug.assertDefined(state.program); @@ -91452,6 +92333,8 @@ var ts; case ".jsx" /* Jsx */: case ".json" /* Json */: return ext; + case ".tsbuildinfo" /* TsBuildInfo */: + return ts.Debug.fail("Extension " + ".tsbuildinfo" /* TsBuildInfo */ + " is unsupported:: FileName:: " + fileName); default: return ts.Debug.assertNever(ext); } @@ -91733,7 +92616,7 @@ var ts; writeFile: function (path, data, writeByteOrderMark) { return system.writeFile(path, data, writeByteOrderMark); }, onCachedDirectoryStructureHostCreate: function (cacheHost) { return host = cacheHost || system; }, createHash: ts.maybeBind(system, system.createHash), - createProgram: createProgram + createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram }; } ts.createProgramHost = createProgramHost; @@ -91743,7 +92626,7 @@ var ts; function createWatchCompilerHost(system, createProgram, reportDiagnostic, reportWatchStatus) { if (system === void 0) { system = ts.sys; } var writeFileName = function (s) { return system.write(s + system.newLine); }; - var result = createProgramHost(system, createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram); + var result = createProgramHost(system, createProgram); ts.copyProperties(result, createWatchHost(system, reportWatchStatus)); result.afterProgramCreate = function (builderProgram) { var compilerOptions = builderProgram.getCompilerOptions(); @@ -92226,16 +93109,22 @@ var ts; * This means we can Pseudo-build (just touch timestamps), as if we had actually built this project. */ UpToDateStatusType[UpToDateStatusType["UpToDateWithUpstreamTypes"] = 2] = "UpToDateWithUpstreamTypes"; - UpToDateStatusType[UpToDateStatusType["OutputMissing"] = 3] = "OutputMissing"; - UpToDateStatusType[UpToDateStatusType["OutOfDateWithSelf"] = 4] = "OutOfDateWithSelf"; - UpToDateStatusType[UpToDateStatusType["OutOfDateWithUpstream"] = 5] = "OutOfDateWithUpstream"; - UpToDateStatusType[UpToDateStatusType["UpstreamOutOfDate"] = 6] = "UpstreamOutOfDate"; - UpToDateStatusType[UpToDateStatusType["UpstreamBlocked"] = 7] = "UpstreamBlocked"; - UpToDateStatusType[UpToDateStatusType["ComputingUpstream"] = 8] = "ComputingUpstream"; + /** + * The project appears out of date because its upstream inputs are newer than its outputs, + * but all of its outputs are actually newer than the previous identical outputs of its (.d.ts) inputs. + * This means we can Pseudo-build (just manipulate outputs), as if we had actually built this project. + */ + UpToDateStatusType[UpToDateStatusType["OutOfDateWithPrepend"] = 3] = "OutOfDateWithPrepend"; + UpToDateStatusType[UpToDateStatusType["OutputMissing"] = 4] = "OutputMissing"; + UpToDateStatusType[UpToDateStatusType["OutOfDateWithSelf"] = 5] = "OutOfDateWithSelf"; + UpToDateStatusType[UpToDateStatusType["OutOfDateWithUpstream"] = 6] = "OutOfDateWithUpstream"; + UpToDateStatusType[UpToDateStatusType["UpstreamOutOfDate"] = 7] = "UpstreamOutOfDate"; + UpToDateStatusType[UpToDateStatusType["UpstreamBlocked"] = 8] = "UpstreamBlocked"; + UpToDateStatusType[UpToDateStatusType["ComputingUpstream"] = 9] = "ComputingUpstream"; /** * Projects with no outputs (i.e. "solution" files) */ - UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 9] = "ContainerOnly"; + UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 10] = "ContainerOnly"; })(UpToDateStatusType = ts.UpToDateStatusType || (ts.UpToDateStatusType = {})); function createFileMap(toPath) { // tslint:disable-next-line:no-null-keyword @@ -92316,24 +93205,18 @@ var ts; } return outputs; } - function getOutFileOutputs(project) { - var out = project.options.outFile || project.options.out; - if (!out) { - return ts.Debug.fail("outFile must be set"); - } + function getOutFileOutputs(project, ignoreBuildInfo) { + ts.Debug.assert(!!project.options.outFile || !!project.options.out, "outFile must be set"); + var _a = ts.getOutputPathsForBundle(project.options, /*forceDtsPaths*/ false), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath; var outputs = []; - outputs.push(out); - if (project.options.sourceMap) { - outputs.push(out + ".map"); - } - if (ts.getEmitDeclarations(project.options)) { - var dts = ts.changeExtension(out, ".d.ts" /* Dts */); - outputs.push(dts); - if (project.options.declarationMap) { - outputs.push(dts + ".map"); - } - } - return outputs; + var addOutput = function (path) { return path && (outputs || (outputs = [])).push(path); }; + addOutput(jsFilePath); + addOutput(sourceMapFilePath); + addOutput(declarationFilePath); + addOutput(declarationMapPath); + if (!ignoreBuildInfo) + addOutput(buildInfoPath); + return outputs || ts.emptyArray; } function rootDirOfOptions(opts, configFileName) { return opts.rootDir || ts.getDirectoryPath(configFileName); @@ -92366,14 +93249,14 @@ var ts; } function createSolutionBuilderHost(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus, reportErrorSummary) { if (system === void 0) { system = ts.sys; } - var host = createSolutionBuilderHostBase(system, createProgram || ts.createAbstractBuilder, reportDiagnostic, reportSolutionBuilderStatus); + var host = createSolutionBuilderHostBase(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus); host.reportErrorSummary = reportErrorSummary; return host; } ts.createSolutionBuilderHost = createSolutionBuilderHost; function createSolutionBuilderWithWatchHost(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus, reportWatchStatus) { if (system === void 0) { system = ts.sys; } - var host = createSolutionBuilderHostBase(system, createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram, reportDiagnostic, reportSolutionBuilderStatus); + var host = createSolutionBuilderHostBase(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus); var watchHost = ts.createWatchHost(system, reportWatchStatus); ts.copyProperties(host, watchHost); return host; @@ -92407,7 +93290,17 @@ var ts; var compilerHost = ts.createCompilerHostFromProgramHost(host, function () { return projectCompilerOptions; }); var originalGetSourceFile = compilerHost.getSourceFile; var computeHash = host.createHash || ts.generateDjb2Hash; - updateGetSourceFile(); + compilerHost.getSourceFile = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var result = originalGetSourceFile.call.apply(originalGetSourceFile, [compilerHost].concat(args)); + if (result) { + result.version = computeHash.call(host, result.text); + } + return result; + }; // Watch state var builderPrograms = createFileMap(toPath); var diagnostics = createFileMap(toPath); @@ -92459,29 +93352,6 @@ var ts; ts.clearMap(allWatchedInputFiles, function (inputFileWatches) { return ts.clearMap(inputFileWatches, ts.closeFileWatcher); }); ts.clearMap(allWatchedConfigFiles, ts.closeFileWatcher); builderPrograms.clear(); - updateGetSourceFile(); - } - function updateGetSourceFile() { - if (options.watch) { - if (compilerHost.getSourceFile === originalGetSourceFile) { - compilerHost.getSourceFile = function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - var result = originalGetSourceFile.call.apply(originalGetSourceFile, [compilerHost].concat(args)); - if (result && options.watch) { - result.version = computeHash.call(host, result.text); - } - return result; - }; - } - } - else { - if (compilerHost.getSourceFile !== originalGetSourceFile) { - compilerHost.getSourceFile = originalGetSourceFile; - } - } } function isParsedCommandLine(entry) { return !!entry.options; @@ -92713,25 +93583,28 @@ var ts; upstreamProjectName: ref.path }; } - // If the upstream project's newest file is older than our oldest output, we - // can't be out of date because of it - if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) { - continue; + // Check oldest output file name only if there is no missing output file name + if (!missingOutputFileName) { + // If the upstream project's newest file is older than our oldest output, we + // can't be out of date because of it + if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) { + continue; + } + // If the upstream project has only change .d.ts files, and we've built + // *after* those files, then we're "psuedo up to date" and eligible for a fast rebuild + if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) { + pseudoUpToDate = true; + upstreamChangedProject = ref.path; + continue; + } + // We have an output older than an upstream output - we are out of date + ts.Debug.assert(oldestOutputFileName !== undefined, "Should have an oldest output filename here"); + return { + type: UpToDateStatusType.OutOfDateWithUpstream, + outOfDateOutputFileName: oldestOutputFileName, + newerProjectName: ref.path + }; } - // If the upstream project has only change .d.ts files, and we've built - // *after* those files, then we're "psuedo up to date" and eligible for a fast rebuild - if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) { - pseudoUpToDate = true; - upstreamChangedProject = ref.path; - continue; - } - // We have an output older than an upstream output - we are out of date - ts.Debug.assert(oldestOutputFileName !== undefined, "Should have an oldest output filename here"); - return { - type: UpToDateStatusType.OutOfDateWithUpstream, - outOfDateOutputFileName: oldestOutputFileName, - newerProjectName: ref.path - }; } } if (missingOutputFileName !== undefined) { @@ -92749,7 +93622,7 @@ var ts; } if (usesPrepend && pseudoUpToDate) { return { - type: UpToDateStatusType.OutOfDateWithUpstream, + type: UpToDateStatusType.OutOfDateWithPrepend, outOfDateOutputFileName: oldestOutputFileName, newerProjectName: upstreamChangedProject }; @@ -92883,7 +93756,9 @@ var ts; updateOutputTimestamps(proj); return; } - var buildResult = buildSingleProject(resolved); + var buildResult = status.type === UpToDateStatusType.OutOfDateWithPrepend ? + updateBundle(resolved) : // Fake that files have been built by manipulating prepend and existing output + buildSingleProject(resolved); // Actual build if (buildResult & BuildResultFlags.AnyErrors) return; var _a = getGlobalDependencyGraph(), referencingProjectsMap = _a.referencingProjectsMap, buildQueue = _a.buildQueue; @@ -92899,17 +93774,26 @@ var ts; // If declaration output is changed, build the project // otherwise mark the project UpToDateWithUpstreamTypes so it updates output time stamps var status_1 = projectStatus.getValue(project); - if (prepend || !(buildResult & BuildResultFlags.DeclarationOutputUnchanged)) { - if (status_1 && (status_1.type === UpToDateStatusType.UpToDate || status_1.type === UpToDateStatusType.UpToDateWithUpstreamTypes)) { + if (!(buildResult & BuildResultFlags.DeclarationOutputUnchanged)) { + if (status_1 && (status_1.type === UpToDateStatusType.UpToDate || status_1.type === UpToDateStatusType.UpToDateWithUpstreamTypes || status_1.type === UpToDateStatusType.OutOfDateWithPrepend)) { projectStatus.setValue(project, { type: UpToDateStatusType.OutOfDateWithUpstream, - outOfDateOutputFileName: status_1.oldestOutputFileName, + outOfDateOutputFileName: status_1.type === UpToDateStatusType.OutOfDateWithPrepend ? status_1.outOfDateOutputFileName : status_1.oldestOutputFileName, newerProjectName: resolved }); } } else if (status_1 && status_1.type === UpToDateStatusType.UpToDate) { - status_1.type = UpToDateStatusType.UpToDateWithUpstreamTypes; + if (prepend) { + projectStatus.setValue(project, { + type: UpToDateStatusType.OutOfDateWithPrepend, + outOfDateOutputFileName: status_1.oldestOutputFileName, + newerProjectName: resolved + }); + } + else { + status_1.type = UpToDateStatusType.UpToDateWithUpstreamTypes; + } } addProjToQueue(project); } @@ -92966,8 +93850,7 @@ var ts; } if (options.verbose) reportStatus(ts.Diagnostics.Building_project_0, proj); - var resultFlags = BuildResultFlags.None; - resultFlags |= BuildResultFlags.DeclarationOutputUnchanged; + var resultFlags = BuildResultFlags.DeclarationOutputUnchanged; var configFile = parseConfigFile(proj); if (!configFile) { // Failed to read the config file @@ -92983,8 +93866,7 @@ var ts; } // TODO: handle resolve module name to cache result in project reference redirect projectCompilerOptions = configFile.options; - var program = host.createProgram(configFile.fileNames, configFile.options, compilerHost, builderPrograms.getValue(proj), configFile.errors, configFile.projectReferences); - projectCompilerOptions = baseCompilerOptions; + var program = host.createProgram(configFile.fileNames, configFile.options, compilerHost, getOldProgram(proj, configFile), configFile.errors, configFile.projectReferences); // Don't emit anything in the presence of syntactic errors or options diagnostics var syntaxDiagnostics = program.getConfigFileParsingDiagnostics().concat(program.getOptionsDiagnostics(), program.getGlobalDiagnostics(), program.getSyntacticDiagnostics()); if (syntaxDiagnostics.length) { @@ -93045,12 +93927,14 @@ var ts; diagnostics.removeKey(proj); projectStatus.setValue(proj, status); afterProgramCreate(proj, program); + projectCompilerOptions = baseCompilerOptions; return resultFlags; function buildErrors(diagnostics, errorFlags, errorType) { resultFlags |= errorFlags; reportAndStoreErrors(proj, diagnostics); projectStatus.setValue(proj, { type: UpToDateStatusType.Unbuildable, reason: errorType + " errors" }); afterProgramCreate(proj, program); + projectCompilerOptions = baseCompilerOptions; return resultFlags; } } @@ -93063,9 +93947,65 @@ var ts; builderPrograms.setValue(proj, program); } } + function getOldProgram(proj, parsed) { + var value = builderPrograms.getValue(proj); + if (value) + return value; + var buildInfoPath = ts.getOutputPathForBuildInfo(parsed.options); + if (!buildInfoPath) + return undefined; + var content = readFileWithCache(buildInfoPath); + if (!content) + return undefined; + var buildInfo = JSON.parse(content); + return buildInfo.program && ts.createBuildProgramUsingProgramBuildInfo(buildInfo.program); + } + function updateBundle(proj) { + if (options.dry) { + reportStatus(ts.Diagnostics.A_non_dry_build_would_update_output_of_project_0, proj); + return BuildResultFlags.Success; + } + if (options.verbose) + reportStatus(ts.Diagnostics.Updating_output_of_project_0, proj); + // Update js, and source map + var config = ts.Debug.assertDefined(parseConfigFile(proj)); + projectCompilerOptions = config.options; + var outputFiles = ts.emitUsingBuildInfo(config, compilerHost, function (ref) { return parseConfigFile(resolveProjectName(ref.path)); }); + if (ts.isString(outputFiles)) { + reportStatus(ts.Diagnostics.Cannot_update_output_of_project_0_because_there_was_error_reading_file_1, proj, relName(outputFiles)); + return buildSingleProject(proj); + } + // Actual Emit + ts.Debug.assert(!!outputFiles.length); + var emitterDiagnostics = ts.createDiagnosticCollection(); + var emittedOutputs = createFileMap(toPath); + outputFiles.forEach(function (_a) { + var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark; + emittedOutputs.setValue(name, true); + ts.writeFile(compilerHost, emitterDiagnostics, name, text, writeByteOrderMark); + }); + var emitDiagnostics = emitterDiagnostics.getDiagnostics(); + if (emitDiagnostics.length) { + reportAndStoreErrors(proj, emitDiagnostics); + projectStatus.setValue(proj, { type: UpToDateStatusType.Unbuildable, reason: "Emit errors" }); + projectCompilerOptions = baseCompilerOptions; + return BuildResultFlags.DeclarationOutputUnchanged | BuildResultFlags.EmitErrors; + } + // Update timestamps for dts + var newestDeclarationFileContentChangedTime = updateOutputTimestampsWorker(config, minimumDate, ts.Diagnostics.Updating_unchanged_output_timestamps_of_project_0, emittedOutputs); + var status = { + type: UpToDateStatusType.UpToDate, + newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTime, + oldestOutputFileName: outputFiles[0].name + }; + diagnostics.removeKey(proj); + projectStatus.setValue(proj, status); + projectCompilerOptions = baseCompilerOptions; + return BuildResultFlags.DeclarationOutputUnchanged; + } function updateOutputTimestamps(proj) { if (options.dry) { - return reportStatus(ts.Diagnostics.A_non_dry_build_would_build_project_0, proj.options.configFilePath); + return reportStatus(ts.Diagnostics.A_non_dry_build_would_update_timestamps_for_output_of_project_0, proj.options.configFilePath); } var priorNewestUpdateTime = updateOutputTimestampsWorker(proj, minimumDate, ts.Diagnostics.Updating_output_timestamps_of_project_0); projectStatus.setValue(proj.options.configFilePath, { type: UpToDateStatusType.UpToDate, newestDeclarationFileContentChangedTime: priorNewestUpdateTime }); @@ -93192,7 +94132,9 @@ var ts; // Do nothing continue; } - var buildResult = buildSingleProject(next); + var buildResult = status.type === UpToDateStatusType.OutOfDateWithPrepend && !options.force ? + updateBundle(next) : // Fake that files have been built by manipulating prepend and existing output + buildSingleProject(next); // Actual build anyFailed = anyFailed || !!(buildResult & BuildResultFlags.AnyErrors); } reportErrorSummary(); @@ -93254,6 +94196,9 @@ var ts; var inputFile = _a[_i]; outputs.push.apply(outputs, getOutputFileNames(inputFile, project)); } + var buildInfoPath = ts.getOutputPathForBuildInfo(project.options); + if (buildInfoPath) + outputs.push(buildInfoPath); return outputs; } } @@ -93285,6 +94230,8 @@ var ts; } // Don't report anything for "up to date because it was already built" -- too verbose break; + case UpToDateStatusType.OutOfDateWithPrepend: + return formatMessage(ts.Diagnostics.Project_0_is_out_of_date_because_output_of_its_dependency_1_has_changed, relName(configFileName), relName(status.newerProjectName)); case UpToDateStatusType.UpToDateWithUpstreamTypes: return formatMessage(ts.Diagnostics.Project_0_is_up_to_date_with_d_ts_files_from_its_dependencies, relName(configFileName)); case UpToDateStatusType.UpstreamOutOfDate: @@ -94099,7 +95046,7 @@ var ts; case 242 /* TypeAliasDeclaration */: case 168 /* TypeLiteral */: return 2 /* Type */; - case 304 /* JSDocTypedefTag */: + case 309 /* JSDocTypedefTag */: // If it has no name node, it shares the name with the value declaration below it. return node.name === undefined ? 1 /* Value */ | 2 /* Type */ : 2 /* Type */; case 278 /* EnumMember */: @@ -94124,14 +95071,14 @@ var ts; case 255 /* ExportDeclaration */: return 7 /* All */; // An external module can be a Value - case 279 /* SourceFile */: + case 284 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 7 /* All */; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.kind === 279 /* SourceFile */) { + if (node.kind === 284 /* SourceFile */) { return 1 /* Value */; } else if (node.parent.kind === 254 /* ExportAssignment */ || node.parent.kind === 259 /* ExternalModuleReference */) { @@ -94337,7 +95284,7 @@ var ts; return undefined; } switch (node.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: case 156 /* MethodDeclaration */: case 155 /* MethodSignature */: case 239 /* FunctionDeclaration */: @@ -94355,7 +95302,7 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: return ts.isExternalModule(node) ? "module" /* moduleElement */ : "script" /* scriptElement */; case 244 /* ModuleDeclaration */: return "module" /* moduleElement */; @@ -94364,8 +95311,8 @@ var ts; return "class" /* classElement */; case 241 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; case 242 /* TypeAliasDeclaration */: - case 297 /* JSDocCallbackTag */: - case 304 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: + case 309 /* JSDocTypedefTag */: return "type" /* typeElement */; case 243 /* EnumDeclaration */: return "enum" /* enumElement */; case 237 /* VariableDeclaration */: @@ -94791,7 +95738,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 279 /* SourceFile */ || n.kind === 1 /* EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); + ts.Debug.assert(startNode !== undefined || n.kind === 284 /* SourceFile */ || n.kind === 1 /* EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); // Here we know that none of child token nodes embrace the position, // the only known case is when position is at the end of the file. // Try to find the rightmost token in the file without filtering. @@ -96536,18 +97483,18 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); // e.g. "param" pos = tag.tagName.end; switch (tag.kind) { - case 299 /* JSDocParameterTag */: + case 304 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 303 /* JSDocTemplateTag */: + case 308 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); pos = tag.end; break; - case 302 /* JSDocTypeTag */: + case 307 /* JSDocTypeTag */: processElement(tag.typeExpression); pos = tag.end; break; - case 300 /* JSDocReturnTag */: + case 305 /* JSDocReturnTag */: processElement(tag.typeExpression); pos = tag.end; break; @@ -96851,6 +97798,7 @@ var ts; case ".jsx" /* Jsx */: return ".jsx" /* jsxModifier */; case ".ts" /* Ts */: return ".ts" /* tsModifier */; case ".tsx" /* Tsx */: return ".tsx" /* tsxModifier */; + case ".tsbuildinfo" /* TsBuildInfo */: return ts.Debug.fail("Extension " + ".tsbuildinfo" /* TsBuildInfo */ + " is unsupported."); case undefined: return "" /* none */; default: return ts.Debug.assertNever(extension); @@ -97875,7 +98823,7 @@ var ts; return symbol.parent && (isModuleSymbol(symbol.parent) ? symbol : getFirstSymbolInChain(symbol.parent, enclosingDeclaration, checker)); } function isModuleSymbol(symbol) { - return symbol.declarations.some(function (d) { return d.kind === 279 /* SourceFile */; }); + return symbol.declarations.some(function (d) { return d.kind === 284 /* SourceFile */; }); } function getCompletionData(program, log, sourceFile, isUncheckedFile, position, preferences, detailsEntryId) { var typeChecker = program.getTypeChecker(); @@ -97926,11 +98874,11 @@ var ts; if (tag.tagName.pos <= position && position <= tag.tagName.end) { return { kind: 1 /* JsDocTagName */ }; } - if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 283 /* JSDocTypeExpression */) { + if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 288 /* JSDocTypeExpression */) { currentToken = ts.getTokenAtPosition(sourceFile, position); if (!currentToken || (!ts.isDeclarationName(currentToken) && - (currentToken.parent.kind !== 305 /* JSDocPropertyTag */ || + (currentToken.parent.kind !== 310 /* JSDocPropertyTag */ || currentToken.parent.name !== currentToken))) { // Use as type location if inside tag's type expression insideJsDocTagTypeExpression = isCurrentlyEditingNode(tag.typeExpression); @@ -98101,11 +99049,11 @@ var ts; return { kind: 0 /* Data */, symbols: symbols, completionKind: completionKind, isInSnippetScope: isInSnippetScope, propertyAccessToConvert: propertyAccessToConvert, isNewIdentifierLocation: isNewIdentifierLocation, location: location, keywordFilters: keywordFilters, literals: literals, symbolToOriginInfoMap: symbolToOriginInfoMap, recommendedCompletion: recommendedCompletion, previousToken: previousToken, isJsxInitializer: isJsxInitializer }; function isTagWithTypeExpression(tag) { switch (tag.kind) { - case 299 /* JSDocParameterTag */: - case 305 /* JSDocPropertyTag */: - case 300 /* JSDocReturnTag */: - case 302 /* JSDocTypeTag */: - case 304 /* JSDocTypedefTag */: + case 304 /* JSDocParameterTag */: + case 310 /* JSDocPropertyTag */: + case 305 /* JSDocReturnTag */: + case 307 /* JSDocTypeTag */: + case 309 /* JSDocTypedefTag */: return true; default: return false; @@ -98145,7 +99093,7 @@ var ts; } } // If the module is merged with a value, we must get the type of the class and add its propertes (for inherited static methods). - if (!isTypeLocation && symbol.declarations.some(function (d) { return d.kind !== 279 /* SourceFile */ && d.kind !== 244 /* ModuleDeclaration */ && d.kind !== 243 /* EnumDeclaration */; })) { + if (!isTypeLocation && symbol.declarations.some(function (d) { return d.kind !== 284 /* SourceFile */ && d.kind !== 244 /* ModuleDeclaration */ && d.kind !== 243 /* EnumDeclaration */; })) { addTypeProperties(typeChecker.getTypeOfSymbolAtLocation(symbol, node)); } return; @@ -98278,7 +99226,7 @@ var ts; var symbolMeanings = (isTypeOnly ? 0 /* None */ : 67220415 /* Value */) | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */; symbols = ts.Debug.assertEachDefined(typeChecker.getSymbolsInScope(scopeNode, symbolMeanings), "getSymbolsInScope() should all be defined"); // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions` - if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 279 /* SourceFile */) { + if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 284 /* SourceFile */) { var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false); if (thisType) { for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker); _i < _a.length; _i++) { @@ -98311,7 +99259,7 @@ var ts; } function isSnippetScope(scopeNode) { switch (scopeNode.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: case 206 /* TemplateExpression */: case 270 /* JsxExpression */: case 218 /* Block */: @@ -99143,7 +100091,7 @@ var ts; function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location) { // class c { method() { } | method2() { } } switch (location.kind) { - case 306 /* SyntaxList */: + case 311 /* SyntaxList */: return ts.tryCast(location.parent, ts.isObjectTypeDeclaration); case 1 /* EndOfFileToken */: var cls = ts.tryCast(ts.lastOrUndefined(ts.cast(location.parent, ts.isSourceFile).statements), ts.isObjectTypeDeclaration); @@ -99328,7 +100276,7 @@ var ts; var child = throwStatement; while (child.parent) { var parent = child.parent; - if (ts.isFunctionBlock(parent) || parent.kind === 279 /* SourceFile */) { + if (ts.isFunctionBlock(parent) || parent.kind === 284 /* SourceFile */) { return parent; } // A throw-statement is only owned by a try-statement if the try-statement has @@ -99386,7 +100334,7 @@ var ts; var container = declaration.parent; switch (container.kind) { case 245 /* ModuleBlock */: - case 279 /* SourceFile */: + case 284 /* SourceFile */: case 218 /* Block */: case 271 /* CaseClause */: case 272 /* DefaultClause */: @@ -99884,7 +100832,7 @@ var ts; } else if (!isAvailableThroughGlobal) { var sourceFileLike = getSourceFileLikeForImportDeclaration(importDeclaration); - ts.Debug.assert(sourceFileLike.kind === 279 /* SourceFile */ || sourceFileLike.kind === 244 /* ModuleDeclaration */); + ts.Debug.assert(sourceFileLike.kind === 284 /* SourceFile */ || sourceFileLike.kind === 244 /* ModuleDeclaration */); if (isReExport || findNamespaceReExports(sourceFileLike, name, checker)) { addIndirectUsers(sourceFileLike); } @@ -100053,7 +101001,7 @@ var ts; for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { var referencingFile = sourceFiles_3[_i]; var searchSourceFile = searchModuleSymbol.valueDeclaration; - if (searchSourceFile.kind === 279 /* SourceFile */) { + if (searchSourceFile.kind === 284 /* SourceFile */) { for (var _a = 0, _b = referencingFile.referencedFiles; _a < _b.length; _a++) { var ref = _b[_a]; if (program.getSourceFileFromReference(referencingFile, ref) === searchSourceFile) { @@ -100101,7 +101049,7 @@ var ts; } /** Iterates over all statements at the top level or in module declarations. Returns the first truthy result. */ function forEachPossibleImportOrExportStatement(sourceFileLike, action) { - return ts.forEach(sourceFileLike.kind === 279 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { + return ts.forEach(sourceFileLike.kind === 284 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { return action(statement) || (isAmbientModuleDeclaration(statement) && ts.forEach(statement.body && statement.body.statements, action)); }); } @@ -100325,7 +101273,7 @@ var ts; return node.getSourceFile(); } var parent = node.parent; - if (parent.kind === 279 /* SourceFile */) { + if (parent.kind === 284 /* SourceFile */) { return parent; } ts.Debug.assert(parent.kind === 245 /* ModuleBlock */); @@ -100387,7 +101335,7 @@ var ts; } FindAllReferences.getImplementationsAtPosition = getImplementationsAtPosition; function getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position) { - if (node.kind === 279 /* SourceFile */) { + if (node.kind === 284 /* SourceFile */) { return undefined; } var checker = program.getTypeChecker(); @@ -100607,8 +101555,8 @@ var ts; case 248 /* ImportEqualsDeclaration */: case 253 /* ImportSpecifier */: case 241 /* InterfaceDeclaration */: - case 297 /* JSDocCallbackTag */: - case 304 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: + case 309 /* JSDocTypedefTag */: case 267 /* JsxAttribute */: case 244 /* ModuleDeclaration */: case 247 /* NamespaceExportDeclaration */: @@ -100633,8 +101581,8 @@ var ts; return !!decl.initializer || ts.isCatchClause(decl.parent); case 155 /* MethodSignature */: case 153 /* PropertySignature */: - case 305 /* JSDocPropertyTag */: - case 299 /* JSDocParameterTag */: + case 310 /* JSDocPropertyTag */: + case 304 /* JSDocParameterTag */: return false; default: return ts.Debug.failBadSyntaxKind(decl); @@ -100794,7 +101742,7 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; switch (decl.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: // Don't include the source file itself. (This may not be ideal behavior, but awkward to include an entire file as a reference.) break; case 244 /* ModuleDeclaration */: @@ -101165,7 +102113,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (!container || container.kind === 279 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { + if (!container || container.kind === 284 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { // This is a global variable and not an external module, any declaration defined // within this scope is visible outside the file return undefined; @@ -101724,7 +102672,7 @@ var ts; staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 279 /* SourceFile */: + case 284 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode) || isParameterName(thisOrSuperKeyword)) { return undefined; } @@ -101737,7 +102685,7 @@ var ts; default: return undefined; } - var references = ts.flatMap(searchSpaceNode.kind === 279 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { + var references = ts.flatMap(searchSpaceNode.kind === 284 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return getPossibleSymbolReferenceNodes(sourceFile, "this", ts.isSourceFile(searchSpaceNode) ? sourceFile : searchSpaceNode).filter(function (node) { if (!ts.isThis(node)) { @@ -101756,8 +102704,8 @@ var ts; // Make sure the container belongs to the same class // and has the appropriate static modifier from the original container. return container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getModifierFlags(container) & 32 /* Static */) === staticFlag; - case 279 /* SourceFile */: - return container.kind === 279 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); + case 284 /* SourceFile */: + return container.kind === 284 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); } }); }).map(function (n) { return FindAllReferences.nodeEntry(n); }); @@ -102611,11 +103559,11 @@ var ts; JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations; function getCommentHavingNodes(declaration) { switch (declaration.kind) { - case 299 /* JSDocParameterTag */: - case 305 /* JSDocPropertyTag */: + case 304 /* JSDocParameterTag */: + case 310 /* JSDocPropertyTag */: return [declaration]; - case 297 /* JSDocCallbackTag */: - case 304 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: + case 309 /* JSDocTypedefTag */: return [declaration, declaration.parent]; default: return ts.getJSDocCommentsAndTags(declaration); @@ -102636,16 +103584,16 @@ var ts; function getCommentText(tag) { var comment = tag.comment; switch (tag.kind) { - case 295 /* JSDocAugmentsTag */: + case 300 /* JSDocAugmentsTag */: return withNode(tag.class); - case 303 /* JSDocTemplateTag */: + case 308 /* JSDocTemplateTag */: return withList(tag.typeParameters); - case 302 /* JSDocTypeTag */: + case 307 /* JSDocTypeTag */: return withNode(tag.typeExpression); - case 304 /* JSDocTypedefTag */: - case 297 /* JSDocCallbackTag */: - case 305 /* JSDocPropertyTag */: - case 299 /* JSDocParameterTag */: + case 309 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: + case 310 /* JSDocPropertyTag */: + case 304 /* JSDocParameterTag */: var name = tag.name; return name ? withNode(name) : comment; default: @@ -102856,7 +103804,7 @@ var ts; : undefined; return { commentOwner: commentOwner, parameters: parameters_1 }; } - case 279 /* SourceFile */: + case 284 /* SourceFile */: return "quit"; case 244 /* ModuleDeclaration */: // If in walking up the tree, we hit a a nested namespace declaration, @@ -103416,7 +104364,7 @@ var ts; } } switch (node.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" @@ -103468,10 +104416,10 @@ var ts; case 243 /* EnumDeclaration */: case 241 /* InterfaceDeclaration */: case 244 /* ModuleDeclaration */: - case 279 /* SourceFile */: + case 284 /* SourceFile */: case 242 /* TypeAliasDeclaration */: - case 304 /* JSDocTypedefTag */: - case 297 /* JSDocCallbackTag */: + case 309 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: return true; case 157 /* Constructor */: case 156 /* MethodDeclaration */: @@ -103492,7 +104440,7 @@ var ts; } switch (navigationBarNodeKind(item.parent)) { case 245 /* ModuleBlock */: - case 279 /* SourceFile */: + case 284 /* SourceFile */: case 156 /* MethodDeclaration */: case 157 /* Constructor */: return true; @@ -103577,7 +104525,7 @@ var ts; return !member.name || member.name.kind === 149 /* ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 279 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); + return node.kind === 284 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); } function getModifiers(node) { if (node.parent && node.parent.kind === 237 /* VariableDeclaration */) { @@ -106395,7 +107343,7 @@ var ts; // For some special property access expressions like `exports.foo = foo` or `module.exports.foo = foo` // there documentation comments might be attached to the right hand side symbol of their declarations. // The pattern of such special property access is that the parent symbol is the symbol of the file. - if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 279 /* SourceFile */; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 284 /* SourceFile */; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; if (!declaration.parent || declaration.parent.kind !== 204 /* BinaryExpression */) { @@ -106520,7 +107468,7 @@ var ts; // If the parent is not sourceFile or module block it is local variable for (var parent = declaration.parent; !ts.isFunctionBlock(parent); parent = parent.parent) { // Reached source file or module block - if (parent.kind === 279 /* SourceFile */ || parent.kind === 245 /* ModuleBlock */) { + if (parent.kind === 284 /* SourceFile */ || parent.kind === 245 /* ModuleBlock */) { return false; } } @@ -107845,7 +108793,7 @@ var ts; case 244 /* ModuleDeclaration */: var body = parent.body; return !!body && body.kind === 245 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 279 /* SourceFile */: + case 284 /* SourceFile */: case 218 /* Block */: case 245 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); @@ -108964,7 +109912,7 @@ var ts; // - parent is SourceFile - by default immediate children of SourceFile are not indented except when user indents them manually // - parent and child are not on the same line var useActualIndentation = (ts.isDeclaration(current) || ts.isStatementButNotDeclaration(current)) && - (parent.kind === 279 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 284 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -109052,7 +110000,7 @@ var ts; case 209 /* ClassExpression */: case 241 /* InterfaceDeclaration */: case 242 /* TypeAliasDeclaration */: - case 303 /* JSDocTemplateTag */: + case 308 /* JSDocTemplateTag */: return getList(node.typeParameters); case 192 /* NewExpression */: case 191 /* CallExpression */: @@ -110615,18 +111563,18 @@ var ts; } function transformJSDocType(node) { switch (node.kind) { - case 284 /* JSDocAllType */: - case 285 /* JSDocUnknownType */: + case 289 /* JSDocAllType */: + case 290 /* JSDocUnknownType */: return ts.createTypeReferenceNode("any", ts.emptyArray); - case 288 /* JSDocOptionalType */: + case 293 /* JSDocOptionalType */: return transformJSDocOptionalType(node); - case 287 /* JSDocNonNullableType */: + case 292 /* JSDocNonNullableType */: return transformJSDocType(node.type); - case 286 /* JSDocNullableType */: + case 291 /* JSDocNullableType */: return transformJSDocNullableType(node); - case 290 /* JSDocVariadicType */: + case 295 /* JSDocVariadicType */: return transformJSDocVariadicType(node); - case 289 /* JSDocFunctionType */: + case 294 /* JSDocFunctionType */: return transformJSDocFunctionType(node); case 164 /* TypeReference */: return transformJSDocTypeReference(node); @@ -110650,7 +111598,7 @@ var ts; } function transformJSDocParameter(node) { var index = node.parent.parameters.indexOf(node); - var isRest = node.type.kind === 290 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 + var isRest = node.type.kind === 295 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 var name = node.name || (isRest ? "rest" : "arg" + index); var dotdotdot = isRest ? ts.createToken(25 /* DotDotDotToken */) : node.dotDotDotToken; return ts.createParameter(node.decorators, node.modifiers, dotdotdot, name, node.questionToken, ts.visitNode(node.type, transformJSDocType), node.initializer); @@ -110969,14 +111917,14 @@ var ts; return undefined; } switch (oldTag.kind) { - case 299 /* JSDocParameterTag */: { + case 304 /* JSDocParameterTag */: { var oldParam = oldTag; var newParam = newTag; return ts.isIdentifier(oldParam.name) && ts.isIdentifier(newParam.name) && oldParam.name.escapedText === newParam.name.escapedText ? ts.createJSDocParamTag(newParam.name, newParam.isBracketed, newParam.typeExpression, oldParam.comment) : undefined; } - case 300 /* JSDocReturnTag */: + case 305 /* JSDocReturnTag */: return ts.createJSDocReturnTag(newTag.typeExpression, oldTag.comment); } } @@ -114356,7 +115304,7 @@ var ts; var typeNode = info.typeNode, type = info.type; var original = typeNode.getText(sourceFile); var actions = [fix(type, fixIdPlain, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript)]; - if (typeNode.kind === 286 /* JSDocNullableType */) { + if (typeNode.kind === 291 /* JSDocNullableType */) { // for nullable types, suggest the flow-compatible `T | null | undefined` // in addition to the jsdoc/closure-compatible `T | null` actions.push(fix(checker.getNullableType(type, 32768 /* Undefined */), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types)); @@ -114376,7 +115324,7 @@ var ts; if (!info) return; var typeNode = info.typeNode, type = info.type; - var fixedType = typeNode.kind === 286 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; + var fixedType = typeNode.kind === 291 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; doChange(changes, sourceFile, typeNode, fixedType, checker); }); } @@ -115008,6 +115956,7 @@ var ts; return ts.textChanges.getNewFileText(toStatements(valueInfo, outputKind), 3 /* TS */, formatSettings.newLineCharacter || "\n", ts.formatting.getFormatContext(formatSettings)); } ts.valueInfoToDeclarationFileText = valueInfoToDeclarationFileText; + /* @internal */ var OutputKind; (function (OutputKind) { OutputKind[OutputKind["ExportEquals"] = 0] = "ExportEquals"; @@ -116175,7 +117124,7 @@ var ts; // * Module/namespace or source file if (isScope(current)) { scopes.push(current); - if (current.kind === 279 /* SourceFile */) { + if (current.kind === 284 /* SourceFile */) { return scopes; } } @@ -117189,7 +118138,7 @@ var ts; function isBlockLike(node) { switch (node.kind) { case 218 /* Block */: - case 279 /* SourceFile */: + case 284 /* SourceFile */: case 245 /* ModuleBlock */: case 271 /* CaseClause */: return true; @@ -118253,7 +119202,7 @@ var ts; if (!children.length) { return undefined; } - var child = ts.find(children, function (kid) { return kid.kind < 283 /* FirstJSDocNode */ || kid.kind > 305 /* LastJSDocNode */; }); + var child = ts.find(children, function (kid) { return kid.kind < 288 /* FirstJSDocNode */ || kid.kind > 310 /* LastJSDocNode */; }); return child.kind < 148 /* FirstNode */ ? child : child.getFirstToken(sourceFile); @@ -118323,7 +119272,7 @@ var ts; } } function createSyntaxList(nodes, parent) { - var list = createNode(306 /* SyntaxList */, nodes.pos, nodes.end, parent); + var list = createNode(311 /* SyntaxList */, nodes.pos, nodes.end, parent); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_7 = nodes; _i < nodes_7.length; _i++) { diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js index 1503cb0420a..d8950e7ff0a 100644 --- a/lib/typingsInstaller.js +++ b/lib/typingsInstaller.js @@ -2880,47 +2880,53 @@ var ts; SyntaxKind[SyntaxKind["SpreadAssignment"] = 277] = "SpreadAssignment"; // Enum SyntaxKind[SyntaxKind["EnumMember"] = 278] = "EnumMember"; + // Unparsed + SyntaxKind[SyntaxKind["UnparsedPrologue"] = 279] = "UnparsedPrologue"; + SyntaxKind[SyntaxKind["UnparsedPrepend"] = 280] = "UnparsedPrepend"; + SyntaxKind[SyntaxKind["UnparsedText"] = 281] = "UnparsedText"; + SyntaxKind[SyntaxKind["UnparsedInternalText"] = 282] = "UnparsedInternalText"; + SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 283] = "UnparsedSyntheticReference"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 279] = "SourceFile"; - SyntaxKind[SyntaxKind["Bundle"] = 280] = "Bundle"; - SyntaxKind[SyntaxKind["UnparsedSource"] = 281] = "UnparsedSource"; - SyntaxKind[SyntaxKind["InputFiles"] = 282] = "InputFiles"; + SyntaxKind[SyntaxKind["SourceFile"] = 284] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 285] = "Bundle"; + SyntaxKind[SyntaxKind["UnparsedSource"] = 286] = "UnparsedSource"; + SyntaxKind[SyntaxKind["InputFiles"] = 287] = "InputFiles"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 283] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 288] = "JSDocTypeExpression"; // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 284] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 289] = "JSDocAllType"; // The ? type - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 285] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 286] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 287] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 288] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 289] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 290] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 291] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 292] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocSignature"] = 293] = "JSDocSignature"; - SyntaxKind[SyntaxKind["JSDocTag"] = 294] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 295] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocClassTag"] = 296] = "JSDocClassTag"; - SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 297] = "JSDocCallbackTag"; - SyntaxKind[SyntaxKind["JSDocEnumTag"] = 298] = "JSDocEnumTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 299] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 300] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocThisTag"] = 301] = "JSDocThisTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 302] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 303] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 304] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 305] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 290] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 291] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 292] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 293] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 294] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 295] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 296] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 297] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocSignature"] = 298] = "JSDocSignature"; + SyntaxKind[SyntaxKind["JSDocTag"] = 299] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 300] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocClassTag"] = 301] = "JSDocClassTag"; + SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 302] = "JSDocCallbackTag"; + SyntaxKind[SyntaxKind["JSDocEnumTag"] = 303] = "JSDocEnumTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 304] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 305] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocThisTag"] = 306] = "JSDocThisTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 307] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 308] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 309] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 310] = "JSDocPropertyTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 306] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 311] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 307] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 308] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["CommaListExpression"] = 309] = "CommaListExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 310] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 311] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 312] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 313] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["CommaListExpression"] = 314] = "CommaListExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 315] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 316] = "EndOfDeclarationMarker"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 312] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 317] = "Count"; // Markers SyntaxKind[SyntaxKind["FirstAssignment"] = 59] = "FirstAssignment"; SyntaxKind[SyntaxKind["LastAssignment"] = 71] = "LastAssignment"; @@ -2947,10 +2953,10 @@ var ts; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 28] = "FirstBinaryOperator"; SyntaxKind[SyntaxKind["LastBinaryOperator"] = 71] = "LastBinaryOperator"; SyntaxKind[SyntaxKind["FirstNode"] = 148] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 283] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 305] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 294] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 305] = "LastJSDocTagNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 288] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 310] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 299] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 310] = "LastJSDocTagNode"; /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 118] = "FirstContextualKeyword"; /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 147] = "LastContextualKeyword"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); @@ -3827,6 +3833,7 @@ var ts; Extension["Js"] = ".js"; Extension["Jsx"] = ".jsx"; Extension["Json"] = ".json"; + Extension["TsBuildInfo"] = ".tsbuildinfo"; })(Extension = ts.Extension || (ts.Extension = {})); /* @internal */ var TransformFlags; @@ -3984,6 +3991,20 @@ var ts; EmitHint[EmitHint["Unspecified"] = 4] = "Unspecified"; EmitHint[EmitHint["EmbeddedStatement"] = 5] = "EmbeddedStatement"; })(EmitHint = ts.EmitHint || (ts.EmitHint = {})); + /*@internal*/ + var BundleFileSectionKind; + (function (BundleFileSectionKind) { + BundleFileSectionKind["Prologue"] = "prologue"; + BundleFileSectionKind["EmitHelpers"] = "emitHelpers"; + BundleFileSectionKind["NoDefaultLib"] = "no-default-lib"; + BundleFileSectionKind["Reference"] = "reference"; + BundleFileSectionKind["Type"] = "type"; + BundleFileSectionKind["Lib"] = "lib"; + BundleFileSectionKind["Prepend"] = "prepend"; + BundleFileSectionKind["Text"] = "text"; + BundleFileSectionKind["Internal"] = "internal"; + // comments? + })(BundleFileSectionKind = ts.BundleFileSectionKind || (ts.BundleFileSectionKind = {})); var ListFormat; (function (ListFormat) { ListFormat[ListFormat["None"] = 0] = "None"; @@ -6113,6 +6134,15 @@ var ts; Option_build_must_be_the_first_command_line_argument: diag(6369, ts.DiagnosticCategory.Error, "Option_build_must_be_the_first_command_line_argument_6369", "Option '--build' must be the first command line argument."), Options_0_and_1_cannot_be_combined: diag(6370, ts.DiagnosticCategory.Error, "Options_0_and_1_cannot_be_combined_6370", "Options '{0}' and '{1}' cannot be combined."), Updating_unchanged_output_timestamps_of_project_0: diag(6371, ts.DiagnosticCategory.Message, "Updating_unchanged_output_timestamps_of_project_0_6371", "Updating unchanged output timestamps of project '{0}'..."), + Project_0_is_out_of_date_because_output_of_its_dependency_1_has_changed: diag(6372, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_output_of_its_dependency_1_has_changed_6372", "Project '{0}' is out of date because output of its dependency '{1}' has changed"), + Updating_output_of_project_0: diag(6373, ts.DiagnosticCategory.Message, "Updating_output_of_project_0_6373", "Updating output of project '{0}'..."), + A_non_dry_build_would_update_timestamps_for_output_of_project_0: diag(6374, ts.DiagnosticCategory.Message, "A_non_dry_build_would_update_timestamps_for_output_of_project_0_6374", "A non-dry build would update timestamps for output of project '{0}'"), + A_non_dry_build_would_update_output_of_project_0: diag(6375, ts.DiagnosticCategory.Message, "A_non_dry_build_would_update_output_of_project_0_6375", "A non-dry build would update output of project '{0}'"), + Cannot_update_output_of_project_0_because_there_was_error_reading_file_1: diag(6376, ts.DiagnosticCategory.Message, "Cannot_update_output_of_project_0_because_there_was_error_reading_file_1_6376", "Cannot update output of project '{0}' because there was error reading file '{1}'"), + Cannot_write_file_0_because_it_will_overwrite_tsbuildinfo_file_generated_by_referenced_project_1: diag(6377, ts.DiagnosticCategory.Error, "Cannot_write_file_0_because_it_will_overwrite_tsbuildinfo_file_generated_by_referenced_project_1_6377", "Cannot write file '{0}' because it will overwrite '.tsbuildinfo' file generated by referenced project '{1}'"), + Enable_incremental_compilation: diag(6378, ts.DiagnosticCategory.Message, "Enable_incremental_compilation_6378", "Enable incremental compilation"), + Composite_projects_may_not_disable_incremental_compilation: diag(6379, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_incremental_compilation_6379", "Composite projects may not disable incremental compilation."), + Specify_file_to_store_incremental_compilation_information: diag(6380, ts.DiagnosticCategory.Message, "Specify_file_to_store_incremental_compilation_information_6380", "Specify file to store incremental compilation information"), The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: diag(6500, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1_6500", "The expected type comes from property '{0}' which is declared here on type '{1}'"), The_expected_type_comes_from_this_index_signature: diag(6501, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_this_index_signature_6501", "The expected type comes from this index signature."), The_expected_type_comes_from_the_return_type_of_this_signature: diag(6502, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_the_return_type_of_this_signature_6502", "The expected type comes from the return type of this signature."), @@ -6816,16 +6846,20 @@ var ts; return pos; } var shebangTriviaRegex = /^#!.*/; + /*@internal*/ function isShebangTrivia(text, pos) { // Shebangs check must only be done at the start of the file ts.Debug.assert(pos === 0); return shebangTriviaRegex.test(text); } + ts.isShebangTrivia = isShebangTrivia; + /*@internal*/ function scanShebangTrivia(text, pos) { var shebang = shebangTriviaRegex.exec(text)[0]; pos = pos + shebang.length; return pos; } + ts.scanShebangTrivia = scanShebangTrivia; /** * Invokes a callback for each comment range following the provided position. * @@ -8535,7 +8569,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 279 /* SourceFile */) { + while (node && node.kind !== 284 /* SourceFile */) { node = node.parent; } return node; @@ -8681,7 +8715,7 @@ var ts; // the syntax list itself considers them as normal trivia. Therefore if we simply skip // trivia for the list, we may have skipped the JSDocComment as well. So we should process its // first child to determine the actual position of its first token. - if (node.kind === 306 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 311 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); @@ -8700,7 +8734,7 @@ var ts; } ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; function isJSDocTypeExpressionOrChild(node) { - return node.kind === 283 /* JSDocTypeExpression */ || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); + return node.kind === 288 /* JSDocTypeExpression */ || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); } function getTextOfNodeFromSourceText(sourceText, node, includeTrivia) { if (includeTrivia === void 0) { includeTrivia = false; } @@ -8827,7 +8861,7 @@ var ts; return node && node.kind === 244 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 279 /* SourceFile */ || + return node.kind === 284 /* SourceFile */ || node.kind === 244 /* ModuleDeclaration */ || ts.isFunctionLike(node); } @@ -8845,7 +8879,7 @@ var ts; // - defined in the top level scope and source file is an external module // - defined inside ambient module declaration located in the top level scope and source file not an external module switch (node.parent.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: return ts.isExternalModule(node.parent); case 245 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); @@ -8863,7 +8897,7 @@ var ts; ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: case 246 /* CaseBlock */: case 274 /* CatchClause */: case 244 /* ModuleDeclaration */: @@ -8888,9 +8922,9 @@ var ts; ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 297 /* JSDocCallbackTag */: - case 304 /* JSDocTypedefTag */: - case 293 /* JSDocSignature */: + case 302 /* JSDocCallbackTag */: + case 309 /* JSDocTypedefTag */: + case 298 /* JSDocSignature */: return true; default: ts.assertType(node); @@ -8906,12 +8940,12 @@ var ts; case 162 /* IndexSignature */: case 165 /* FunctionType */: case 166 /* ConstructorType */: - case 289 /* JSDocFunctionType */: + case 294 /* JSDocFunctionType */: case 240 /* ClassDeclaration */: case 209 /* ClassExpression */: case 241 /* InterfaceDeclaration */: case 242 /* TypeAliasDeclaration */: - case 303 /* JSDocTemplateTag */: + case 308 /* JSDocTemplateTag */: case 239 /* FunctionDeclaration */: case 156 /* MethodDeclaration */: case 157 /* Constructor */: @@ -9056,7 +9090,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: var pos_1 = ts.skipTrivia(sourceFile.text, 0, /*stopAfterLineBreak*/ false); if (pos_1 === sourceFile.text.length) { // file is empty - return span for the beginning of the file @@ -9231,7 +9265,7 @@ var ts; return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); case 150 /* TypeParameter */: return node === parent.constraint; - case 303 /* JSDocTemplateTag */: + case 308 /* JSDocTemplateTag */: return node === parent.constraint; case 154 /* PropertyDeclaration */: case 153 /* PropertySignature */: @@ -9491,7 +9525,7 @@ var ts; } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 279 /* SourceFile */); + ts.Debug.assert(node.kind !== 284 /* SourceFile */); while (true) { node = node.parent; if (!node) { @@ -9545,7 +9579,7 @@ var ts; case 161 /* ConstructSignature */: case 162 /* IndexSignature */: case 243 /* EnumDeclaration */: - case 279 /* SourceFile */: + case 284 /* SourceFile */: return node; } } @@ -10253,7 +10287,7 @@ var ts; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 304 /* JSDocTypedefTag */ || node.kind === 297 /* JSDocCallbackTag */; + return node.kind === 309 /* JSDocTypedefTag */ || node.kind === 302 /* JSDocCallbackTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -10397,7 +10431,7 @@ var ts; ts.hasRestParameter = hasRestParameter; function isRestParameter(node) { var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type; - return node.dotDotDotToken !== undefined || !!type && type.kind === 290 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 295 /* JSDocVariadicType */; } ts.isRestParameter = isRestParameter; var AssignmentKind; @@ -10882,7 +10916,7 @@ var ts; || kind === 158 /* GetAccessor */ || kind === 159 /* SetAccessor */ || kind === 244 /* ModuleDeclaration */ - || kind === 279 /* SourceFile */; + || kind === 284 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -10959,7 +10993,7 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 309 /* CommaListExpression */: + case 314 /* CommaListExpression */: return 0; case 208 /* SpreadElement */: return 1; @@ -11277,6 +11311,9 @@ var ts; lineStart = true; } } + function getTextPosWithWriteLine() { + return lineStart ? output.length : (output.length + newLine.length); + } reset(); return { write: write, @@ -11305,7 +11342,8 @@ var ts; writeStringLiteral: write, writeSymbol: function (s, _) { return write(s); }, writeTrailingSemicolon: write, - writeComment: write + writeComment: write, + getTextPosWithWriteLine: getTextPosWithWriteLine }; } ts.createTextWriter = createTextWriter; @@ -11596,7 +11634,7 @@ var ts; ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations; /** template tags are only available when a typedef isn't already using them */ function isNonTypeAliasTemplate(tag) { - return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 291 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 296 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node @@ -12568,19 +12606,29 @@ var ts; || kind === 96 /* NullKeyword */ || kind === 132 /* NeverKeyword */ || kind === 211 /* ExpressionWithTypeArguments */ - || kind === 284 /* JSDocAllType */ - || kind === 285 /* JSDocUnknownType */ - || kind === 286 /* JSDocNullableType */ - || kind === 287 /* JSDocNonNullableType */ - || kind === 288 /* JSDocOptionalType */ - || kind === 289 /* JSDocFunctionType */ - || kind === 290 /* JSDocVariadicType */; + || kind === 289 /* JSDocAllType */ + || kind === 290 /* JSDocUnknownType */ + || kind === 291 /* JSDocNullableType */ + || kind === 292 /* JSDocNonNullableType */ + || kind === 293 /* JSDocOptionalType */ + || kind === 294 /* JSDocFunctionType */ + || kind === 295 /* JSDocVariadicType */; } ts.isTypeNodeKind = isTypeNodeKind; function isAccessExpression(node) { return node.kind === 189 /* PropertyAccessExpression */ || node.kind === 190 /* ElementAccessExpression */; } ts.isAccessExpression = isAccessExpression; + function isBundleFileTextLike(section) { + switch (section.kind) { + case "text" /* Text */: + case "internal" /* Internal */: + return true; + default: + return false; + } + } + ts.isBundleFileTextLike = isBundleFileTextLike; })(ts || (ts = {})); (function (ts) { function getDefaultLibFileName(options) { @@ -13042,8 +13090,8 @@ var ts; switch (declaration.kind) { case 72 /* Identifier */: return declaration; - case 305 /* JSDocPropertyTag */: - case 299 /* JSDocParameterTag */: { + case 310 /* JSDocPropertyTag */: + case 304 /* JSDocParameterTag */: { var name = declaration.name; if (name.kind === 148 /* QualifiedName */) { return name.right; @@ -13067,7 +13115,7 @@ var ts; return undefined; } } - case 304 /* JSDocTypedefTag */: + case 309 /* JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); case 254 /* ExportAssignment */: { var expression = declaration.expression; @@ -13271,7 +13319,7 @@ var ts; return ts.emptyArray; } if (ts.isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 291 /* JSDocComment */); + ts.Debug.assert(node.parent.kind === 296 /* JSDocComment */); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } if (node.typeParameters) { @@ -13543,7 +13591,7 @@ var ts; } ts.isParenthesizedExpression = isParenthesizedExpression; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 308 /* PartiallyEmittedExpression */) { + while (node.kind === 313 /* PartiallyEmittedExpression */) { node = node.expression; } return node; @@ -13890,108 +13938,128 @@ var ts; ts.isEnumMember = isEnumMember; // Top-level nodes function isSourceFile(node) { - return node.kind === 279 /* SourceFile */; + return node.kind === 284 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 280 /* Bundle */; + return node.kind === 285 /* Bundle */; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 281 /* UnparsedSource */; + return node.kind === 286 /* UnparsedSource */; } ts.isUnparsedSource = isUnparsedSource; + function isUnparsedPrepend(node) { + return node.kind === 280 /* UnparsedPrepend */; + } + ts.isUnparsedPrepend = isUnparsedPrepend; + function isUnparsedTextLike(node) { + switch (node.kind) { + case 281 /* UnparsedText */: + case 282 /* UnparsedInternalText */: + return true; + default: + return false; + } + } + ts.isUnparsedTextLike = isUnparsedTextLike; + function isUnparsedNode(node) { + return isUnparsedTextLike(node) || + node.kind === 279 /* UnparsedPrologue */ || + node.kind === 283 /* UnparsedSyntheticReference */; + } + ts.isUnparsedNode = isUnparsedNode; // JSDoc function isJSDocTypeExpression(node) { - return node.kind === 283 /* JSDocTypeExpression */; + return node.kind === 288 /* JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocAllType(node) { - return node.kind === 284 /* JSDocAllType */; + return node.kind === 289 /* JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 285 /* JSDocUnknownType */; + return node.kind === 290 /* JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 286 /* JSDocNullableType */; + return node.kind === 291 /* JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 287 /* JSDocNonNullableType */; + return node.kind === 292 /* JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 288 /* JSDocOptionalType */; + return node.kind === 293 /* JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 289 /* JSDocFunctionType */; + return node.kind === 294 /* JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 290 /* JSDocVariadicType */; + return node.kind === 295 /* JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDoc(node) { - return node.kind === 291 /* JSDocComment */; + return node.kind === 296 /* JSDocComment */; } ts.isJSDoc = isJSDoc; function isJSDocAugmentsTag(node) { - return node.kind === 295 /* JSDocAugmentsTag */; + return node.kind === 300 /* JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocClassTag(node) { - return node.kind === 296 /* JSDocClassTag */; + return node.kind === 301 /* JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocEnumTag(node) { - return node.kind === 298 /* JSDocEnumTag */; + return node.kind === 303 /* JSDocEnumTag */; } ts.isJSDocEnumTag = isJSDocEnumTag; function isJSDocThisTag(node) { - return node.kind === 301 /* JSDocThisTag */; + return node.kind === 306 /* JSDocThisTag */; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocParameterTag(node) { - return node.kind === 299 /* JSDocParameterTag */; + return node.kind === 304 /* JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 300 /* JSDocReturnTag */; + return node.kind === 305 /* JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocTypeTag(node) { - return node.kind === 302 /* JSDocTypeTag */; + return node.kind === 307 /* JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 303 /* JSDocTemplateTag */; + return node.kind === 308 /* JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 304 /* JSDocTypedefTag */; + return node.kind === 309 /* JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocPropertyTag(node) { - return node.kind === 305 /* JSDocPropertyTag */; + return node.kind === 310 /* JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocPropertyLikeTag(node) { - return node.kind === 305 /* JSDocPropertyTag */ || node.kind === 299 /* JSDocParameterTag */; + return node.kind === 310 /* JSDocPropertyTag */ || node.kind === 304 /* JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; function isJSDocTypeLiteral(node) { - return node.kind === 292 /* JSDocTypeLiteral */; + return node.kind === 297 /* JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocCallbackTag(node) { - return node.kind === 297 /* JSDocCallbackTag */; + return node.kind === 302 /* JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocSignature(node) { - return node.kind === 293 /* JSDocSignature */; + return node.kind === 298 /* JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; })(ts || (ts = {})); @@ -14002,7 +14070,7 @@ var ts; (function (ts) { /* @internal */ function isSyntaxList(n) { - return n.kind === 306 /* SyntaxList */; + return n.kind === 311 /* SyntaxList */; } ts.isSyntaxList = isSyntaxList; /* @internal */ @@ -14154,11 +14222,11 @@ var ts; switch (kind) { case 155 /* MethodSignature */: case 160 /* CallSignature */: - case 293 /* JSDocSignature */: + case 298 /* JSDocSignature */: case 161 /* ConstructSignature */: case 162 /* IndexSignature */: case 165 /* FunctionType */: - case 289 /* JSDocFunctionType */: + case 294 /* JSDocFunctionType */: case 166 /* ConstructorType */: return true; default: @@ -14449,8 +14517,8 @@ var ts; case 208 /* SpreadElement */: case 212 /* AsExpression */: case 210 /* OmittedExpression */: - case 309 /* CommaListExpression */: - case 308 /* PartiallyEmittedExpression */: + case 314 /* CommaListExpression */: + case 313 /* PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -14464,12 +14532,12 @@ var ts; ts.isAssertionExpression = isAssertionExpression; /* @internal */ function isPartiallyEmittedExpression(node) { - return node.kind === 308 /* PartiallyEmittedExpression */; + return node.kind === 313 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; /* @internal */ function isNotEmittedStatement(node) { - return node.kind === 307 /* NotEmittedStatement */; + return node.kind === 312 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ @@ -14580,9 +14648,9 @@ var ts; || kind === 242 /* TypeAliasDeclaration */ || kind === 150 /* TypeParameter */ || kind === 237 /* VariableDeclaration */ - || kind === 304 /* JSDocTypedefTag */ - || kind === 297 /* JSDocCallbackTag */ - || kind === 305 /* JSDocPropertyTag */; + || kind === 309 /* JSDocTypedefTag */ + || kind === 302 /* JSDocCallbackTag */ + || kind === 310 /* JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { return kind === 239 /* FunctionDeclaration */ @@ -14617,14 +14685,14 @@ var ts; || kind === 219 /* VariableStatement */ || kind === 224 /* WhileStatement */ || kind === 231 /* WithStatement */ - || kind === 307 /* NotEmittedStatement */ - || kind === 311 /* EndOfDeclarationMarker */ - || kind === 310 /* MergeDeclarationMarker */; + || kind === 312 /* NotEmittedStatement */ + || kind === 316 /* EndOfDeclarationMarker */ + || kind === 315 /* MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { if (node.kind === 150 /* TypeParameter */) { - return node.parent.kind !== 303 /* JSDocTemplateTag */ || ts.isInJSFile(node); + return (node.parent && node.parent.kind !== 308 /* JSDocTemplateTag */) || ts.isInJSFile(node); } return isDeclarationKind(node.kind); } @@ -14719,18 +14787,18 @@ var ts; /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 283 /* FirstJSDocNode */ && node.kind <= 305 /* LastJSDocNode */; + return node.kind >= 288 /* FirstJSDocNode */ && node.kind <= 310 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 291 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 296 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); } ts.isJSDocCommentContainingNode = isJSDocCommentContainingNode; // TODO: determine what this does before making it public. /* @internal */ function isJSDocTag(node) { - return node.kind >= 294 /* FirstJSDocTagNode */ && node.kind <= 305 /* LastJSDocTagNode */; + return node.kind >= 299 /* FirstJSDocTagNode */ && node.kind <= 310 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { @@ -15047,6 +15115,10 @@ var ts; return !!(compilerOptions.declaration || compilerOptions.composite); } ts.getEmitDeclarations = getEmitDeclarations; + function isIncrementalCompilation(options) { + return !!(options.incremental || options.composite); + } + ts.isIncrementalCompilation = isIncrementalCompilation; function getStrictOptionValue(compilerOptions, flag) { return compilerOptions[flag] === undefined ? !!compilerOptions.strict : !!compilerOptions[flag]; } @@ -16331,7 +16403,7 @@ var ts; var SourceFileConstructor; // tslint:enable variable-name function createNode(kind, pos, end) { - if (kind === 279 /* SourceFile */) { + if (kind === 284 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else if (kind === 72 /* Identifier */) { @@ -16582,7 +16654,7 @@ var ts; case 218 /* Block */: case 245 /* ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 279 /* SourceFile */: + case 284 /* SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); case 219 /* VariableStatement */: @@ -16731,7 +16803,7 @@ var ts; return visitNode(cbNode, node.expression); case 258 /* MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators); - case 309 /* CommaListExpression */: + case 314 /* CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); case 260 /* JsxElement */: return visitNode(cbNode, node.openingElement) || @@ -16760,60 +16832,60 @@ var ts; return visitNode(cbNode, node.tagName); case 171 /* OptionalType */: case 172 /* RestType */: - case 283 /* JSDocTypeExpression */: - case 287 /* JSDocNonNullableType */: - case 286 /* JSDocNullableType */: - case 288 /* JSDocOptionalType */: - case 290 /* JSDocVariadicType */: + case 288 /* JSDocTypeExpression */: + case 292 /* JSDocNonNullableType */: + case 291 /* JSDocNullableType */: + case 293 /* JSDocOptionalType */: + case 295 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 289 /* JSDocFunctionType */: + case 294 /* JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 291 /* JSDocComment */: + case 296 /* JSDocComment */: return visitNodes(cbNode, cbNodes, node.tags); - case 299 /* JSDocParameterTag */: - case 305 /* JSDocPropertyTag */: + case 304 /* JSDocParameterTag */: + case 310 /* JSDocPropertyTag */: return visitNode(cbNode, node.tagName) || (node.isNameFirst ? visitNode(cbNode, node.name) || visitNode(cbNode, node.typeExpression) : visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name)); - case 295 /* JSDocAugmentsTag */: + case 300 /* JSDocAugmentsTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.class); - case 303 /* JSDocTemplateTag */: + case 308 /* JSDocTemplateTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.constraint) || visitNodes(cbNode, cbNodes, node.typeParameters); - case 304 /* JSDocTypedefTag */: + case 309 /* JSDocTypedefTag */: return visitNode(cbNode, node.tagName) || (node.typeExpression && - node.typeExpression.kind === 283 /* JSDocTypeExpression */ + node.typeExpression.kind === 288 /* JSDocTypeExpression */ ? visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) : visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression)); - case 297 /* JSDocCallbackTag */: + case 302 /* JSDocCallbackTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); - case 300 /* JSDocReturnTag */: - case 302 /* JSDocTypeTag */: - case 301 /* JSDocThisTag */: - case 298 /* JSDocEnumTag */: + case 305 /* JSDocReturnTag */: + case 307 /* JSDocTypeTag */: + case 306 /* JSDocThisTag */: + case 303 /* JSDocEnumTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.typeExpression); - case 293 /* JSDocSignature */: + case 298 /* JSDocSignature */: return ts.forEach(node.typeParameters, cbNode) || ts.forEach(node.parameters, cbNode) || visitNode(cbNode, node.type); - case 292 /* JSDocTypeLiteral */: + case 297 /* JSDocTypeLiteral */: return ts.forEach(node.jsDocPropertyTags, cbNode); - case 294 /* JSDocTag */: - case 296 /* JSDocClassTag */: + case 299 /* JSDocTag */: + case 301 /* JSDocClassTag */: return visitNode(cbNode, node.tagName); - case 308 /* PartiallyEmittedExpression */: + case 313 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -17187,7 +17259,7 @@ var ts; function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile) { // code from createNode is inlined here so createNode won't have to deal with special case of creating source files // this is quite rare comparing to other nodes and createNode should be as fast as possible - var sourceFile = new SourceFileConstructor(279 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); + var sourceFile = new SourceFileConstructor(284 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -18387,9 +18459,9 @@ var ts; return finishNode(node); } function parseJSDocAllType(postFixEquals) { - var result = createNode(284 /* JSDocAllType */); + var result = createNode(289 /* JSDocAllType */); if (postFixEquals) { - return createPostfixType(288 /* JSDocOptionalType */, result); + return createPostfixType(293 /* JSDocOptionalType */, result); } else { nextToken(); @@ -18397,7 +18469,7 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(287 /* JSDocNonNullableType */); + var result = createNode(292 /* JSDocNonNullableType */); nextToken(); result.type = parseNonArrayType(); return finishNode(result); @@ -18421,18 +18493,18 @@ var ts; token() === 30 /* GreaterThanToken */ || token() === 59 /* EqualsToken */ || token() === 50 /* BarToken */) { - var result = createNode(285 /* JSDocUnknownType */, pos); + var result = createNode(290 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(286 /* JSDocNullableType */, pos); + var result = createNode(291 /* JSDocNullableType */, pos); result.type = parseType(); return finishNode(result); } } function parseJSDocFunctionType() { if (lookAhead(nextTokenIsOpenParen)) { - var result = createNodeWithJSDoc(289 /* JSDocFunctionType */); + var result = createNodeWithJSDoc(294 /* JSDocFunctionType */); nextToken(); fillSignature(57 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result); return finishNode(result); @@ -18456,12 +18528,12 @@ var ts; var type = parseTypeOrTypePredicate(); scanner.setInJSDocType(false); if (dotdotdot) { - var variadic = createNode(290 /* JSDocVariadicType */, dotdotdot.pos); + var variadic = createNode(295 /* JSDocVariadicType */, dotdotdot.pos); variadic.type = type; type = finishNode(variadic); } if (token() === 59 /* EqualsToken */) { - return createPostfixType(288 /* JSDocOptionalType */, type); + return createPostfixType(293 /* JSDocOptionalType */, type); } return type; } @@ -18833,7 +18905,7 @@ var ts; return finishNode(node); } var type = parseType(); - if (!(contextFlags & 2097152 /* JSDoc */) && type.kind === 286 /* JSDocNullableType */ && type.pos === type.type.pos) { + if (!(contextFlags & 2097152 /* JSDoc */) && type.kind === 291 /* JSDocNullableType */ && type.pos === type.type.pos) { type.kind = 171 /* OptionalType */; } return type; @@ -19020,14 +19092,14 @@ var ts; while (!scanner.hasPrecedingLineBreak()) { switch (token()) { case 52 /* ExclamationToken */: - type = createPostfixType(287 /* JSDocNonNullableType */, type); + type = createPostfixType(292 /* JSDocNonNullableType */, type); break; case 56 /* QuestionToken */: // If not in JSDoc and next token is start of a type we have a conditional type if (!(contextFlags & 2097152 /* JSDoc */) && lookAhead(nextTokenIsStartOfType)) { return type; } - type = createPostfixType(286 /* JSDocNullableType */, type); + type = createPostfixType(291 /* JSDocNullableType */, type); break; case 22 /* OpenBracketToken */: parseExpected(22 /* OpenBracketToken */); @@ -21964,7 +22036,7 @@ var ts; JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; // Parses out a JSDoc type expression. function parseJSDocTypeExpression(mayOmitBraces) { - var result = createNode(283 /* JSDocTypeExpression */); + var result = createNode(288 /* JSDocTypeExpression */); var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* OpenBraceToken */); result.type = doInsideOfContext(2097152 /* JSDoc */, parseJSDocType); if (!mayOmitBraces || hasBrace) { @@ -22127,7 +22199,7 @@ var ts; } } function createJSDocComment() { - var result = createNode(291 /* JSDocComment */, start); + var result = createNode(296 /* JSDocComment */, start); result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -22294,7 +22366,7 @@ var ts; return comments.length === 0 ? undefined : comments.join(""); } function parseUnknownTag(start, tagName) { - var result = createNode(294 /* JSDocTag */, start); + var result = createNode(299 /* JSDocTag */, start); result.tagName = tagName; return finishNode(result); } @@ -22353,8 +22425,8 @@ var ts; typeExpression = tryParseTypeExpression(); } var result = target === 1 /* Property */ ? - createNode(305 /* JSDocPropertyTag */, start) : - createNode(299 /* JSDocParameterTag */, start); + createNode(310 /* JSDocPropertyTag */, start) : + createNode(304 /* JSDocParameterTag */, start); var comment = parseTagComments(indent + scanner.getStartPos() - start); var nestedTypeLiteral = target !== 4 /* CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target, indent); if (nestedTypeLiteral) { @@ -22371,18 +22443,18 @@ var ts; } function parseNestedTypeLiteral(typeExpression, name, target, indent) { if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) { - var typeLiteralExpression = createNode(283 /* JSDocTypeExpression */, scanner.getTokenPos()); + var typeLiteralExpression = createNode(288 /* JSDocTypeExpression */, scanner.getTokenPos()); var child = void 0; var jsdocTypeLiteral = void 0; var start_2 = scanner.getStartPos(); var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) { - if (child.kind === 299 /* JSDocParameterTag */ || child.kind === 305 /* JSDocPropertyTag */) { + if (child.kind === 304 /* JSDocParameterTag */ || child.kind === 310 /* JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - jsdocTypeLiteral = createNode(292 /* JSDocTypeLiteral */, start_2); + jsdocTypeLiteral = createNode(297 /* JSDocTypeLiteral */, start_2); jsdocTypeLiteral.jsDocPropertyTags = children; if (typeExpression.type.kind === 169 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; @@ -22393,25 +22465,25 @@ var ts; } } function parseReturnTag(start, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 300 /* JSDocReturnTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 305 /* JSDocReturnTag */; })) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(300 /* JSDocReturnTag */, start); + var result = createNode(305 /* JSDocReturnTag */, start); result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); } function parseTypeTag(start, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 302 /* JSDocTypeTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 307 /* JSDocTypeTag */; })) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(302 /* JSDocTypeTag */, start); + var result = createNode(307 /* JSDocTypeTag */, start); result.tagName = tagName; result.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); return finishNode(result); } function parseAugmentsTag(start, tagName) { - var result = createNode(295 /* JSDocAugmentsTag */, start); + var result = createNode(300 /* JSDocAugmentsTag */, start); result.tagName = tagName; result.class = parseExpressionWithTypeArgumentsForAugments(); return finishNode(result); @@ -22438,19 +22510,19 @@ var ts; return node; } function parseClassTag(start, tagName) { - var tag = createNode(296 /* JSDocClassTag */, start); + var tag = createNode(301 /* JSDocClassTag */, start); tag.tagName = tagName; return finishNode(tag); } function parseThisTag(start, tagName) { - var tag = createNode(301 /* JSDocThisTag */, start); + var tag = createNode(306 /* JSDocThisTag */, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); return finishNode(tag); } function parseEnumTag(start, tagName) { - var tag = createNode(298 /* JSDocEnumTag */, start); + var tag = createNode(303 /* JSDocEnumTag */, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); @@ -22459,7 +22531,7 @@ var ts; function parseTypedefTag(start, tagName, indent) { var typeExpression = tryParseTypeExpression(); skipWhitespaceOrAsterisk(); - var typedefTag = createNode(304 /* JSDocTypedefTag */, start); + var typedefTag = createNode(309 /* JSDocTypedefTag */, start); typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(); typedefTag.name = getJSDocTypeAliasName(typedefTag.fullName); @@ -22473,9 +22545,9 @@ var ts; var childTypeTag = void 0; while (child = tryParse(function () { return parseChildPropertyTag(indent); })) { if (!jsdocTypeLiteral) { - jsdocTypeLiteral = createNode(292 /* JSDocTypeLiteral */, start); + jsdocTypeLiteral = createNode(297 /* JSDocTypeLiteral */, start); } - if (child.kind === 302 /* JSDocTypeTag */) { + if (child.kind === 307 /* JSDocTypeTag */) { if (childTypeTag) { break; } @@ -22521,14 +22593,14 @@ var ts; return typeNameOrNamespaceName; } function parseCallbackTag(start, tagName, indent) { - var callbackTag = createNode(297 /* JSDocCallbackTag */, start); + var callbackTag = createNode(302 /* JSDocCallbackTag */, start); callbackTag.tagName = tagName; callbackTag.fullName = parseJSDocTypeNameWithNamespace(); callbackTag.name = getJSDocTypeAliasName(callbackTag.fullName); skipWhitespace(); callbackTag.comment = parseTagComments(indent); var child; - var jsdocSignature = createNode(293 /* JSDocSignature */, start); + var jsdocSignature = createNode(298 /* JSDocSignature */, start); jsdocSignature.parameters = []; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* CallbackParameter */, indent); })) { jsdocSignature.parameters = ts.append(jsdocSignature.parameters, child); @@ -22536,7 +22608,7 @@ var ts; var returnTag = tryParse(function () { if (parseOptionalJsdoc(58 /* AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 300 /* JSDocReturnTag */) { + if (tag && tag.kind === 305 /* JSDocReturnTag */) { return tag; } } @@ -22581,7 +22653,7 @@ var ts; case 58 /* AtToken */: if (canParseTag) { var child = tryParseChildTag(target, indent); - if (child && (child.kind === 299 /* JSDocParameterTag */ || child.kind === 305 /* JSDocPropertyTag */) && + if (child && (child.kind === 304 /* JSDocParameterTag */ || child.kind === 310 /* JSDocPropertyTag */) && target !== 4 /* CallbackParameter */ && name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; @@ -22651,7 +22723,7 @@ var ts; skipWhitespace(); typeParameters.push(typeParameter); } while (parseOptionalJsdoc(27 /* CommaToken */)); - var result = createNode(303 /* JSDocTemplateTag */, start); + var result = createNode(308 /* JSDocTemplateTag */, start); result.tagName = tagName; result.constraint = constraint; result.typeParameters = createNodeArray(typeParameters, typeParametersPos); @@ -23737,6 +23809,22 @@ var ts; category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Enable_project_compilation, }, + { + name: "incremental", + type: "boolean", + isTSConfigOnly: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Enable_incremental_compilation, + }, + { + name: "tsBuildInfoFile", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.FILE, + isTSConfigOnly: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Specify_file_to_store_incremental_compilation_information, + }, { name: "removeComments", type: "boolean", @@ -27455,7 +27543,7 @@ var ts; return "__constructor" /* Constructor */; case 165 /* FunctionType */: case 160 /* CallSignature */: - case 293 /* JSDocSignature */: + case 298 /* JSDocSignature */: return "__call" /* Call */; case 166 /* ConstructorType */: case 161 /* ConstructSignature */: @@ -27464,7 +27552,7 @@ var ts; return "__index" /* Index */; case 255 /* ExportDeclaration */: return "__export" /* ExportStar */; - case 279 /* SourceFile */: + case 284 /* SourceFile */: // json file should behave as // module.exports = ... return "export=" /* ExportEquals */; @@ -27475,12 +27563,12 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 289 /* JSDocFunctionType */: + case 294 /* JSDocFunctionType */: return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); case 151 /* Parameter */: // Parameters with names are handled at the top of this function. Parameters // without names can only come from JSDocFunctionTypes. - ts.Debug.assert(node.parent.kind === 289 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); + ts.Debug.assert(node.parent.kind === 294 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); var functionType = node.parent; var index = functionType.parameters.indexOf(node); return "arg" + index; @@ -27719,7 +27807,7 @@ var ts; if (hasExplicitReturn) node.flags |= 256 /* HasExplicitReturn */; } - if (node.kind === 279 /* SourceFile */) { + if (node.kind === 284 /* SourceFile */) { node.flags |= emitFlags; } if (currentReturnTarget) { @@ -27863,12 +27951,12 @@ var ts; case 191 /* CallExpression */: bindCallExpressionFlow(node); break; - case 304 /* JSDocTypedefTag */: - case 297 /* JSDocCallbackTag */: + case 309 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: bindJSDocTypeAlias(node); break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 279 /* SourceFile */: { + case 284 /* SourceFile */: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; @@ -28555,7 +28643,7 @@ var ts; case 243 /* EnumDeclaration */: case 188 /* ObjectLiteralExpression */: case 168 /* TypeLiteral */: - case 292 /* JSDocTypeLiteral */: + case 297 /* JSDocTypeLiteral */: case 268 /* JsxAttributes */: return 1 /* IsContainer */; case 241 /* InterfaceDeclaration */: @@ -28564,7 +28652,7 @@ var ts; case 242 /* TypeAliasDeclaration */: case 181 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 279 /* SourceFile */: + case 284 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; case 156 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { @@ -28577,8 +28665,8 @@ var ts; case 158 /* GetAccessor */: case 159 /* SetAccessor */: case 160 /* CallSignature */: - case 293 /* JSDocSignature */: - case 289 /* JSDocFunctionType */: + case 298 /* JSDocSignature */: + case 294 /* JSDocFunctionType */: case 165 /* FunctionType */: case 161 /* ConstructSignature */: case 162 /* IndexSignature */: @@ -28632,7 +28720,7 @@ var ts; // handlers to take care of declaring these child members. case 244 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 279 /* SourceFile */: + case 284 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); case 209 /* ClassExpression */: case 240 /* ClassDeclaration */: @@ -28640,7 +28728,7 @@ var ts; case 243 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); case 168 /* TypeLiteral */: - case 292 /* JSDocTypeLiteral */: + case 297 /* JSDocTypeLiteral */: case 188 /* ObjectLiteralExpression */: case 241 /* InterfaceDeclaration */: case 268 /* JsxAttributes */: @@ -28654,7 +28742,7 @@ var ts; case 166 /* ConstructorType */: case 160 /* CallSignature */: case 161 /* ConstructSignature */: - case 293 /* JSDocSignature */: + case 298 /* JSDocSignature */: case 162 /* IndexSignature */: case 156 /* MethodDeclaration */: case 155 /* MethodSignature */: @@ -28664,9 +28752,9 @@ var ts; case 239 /* FunctionDeclaration */: case 196 /* FunctionExpression */: case 197 /* ArrowFunction */: - case 289 /* JSDocFunctionType */: - case 304 /* JSDocTypedefTag */: - case 297 /* JSDocCallbackTag */: + case 294 /* JSDocFunctionType */: + case 309 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: case 242 /* TypeAliasDeclaration */: case 181 /* MappedType */: // All the children of these container types are never visible through another @@ -28689,8 +28777,8 @@ var ts; : declareSymbol(file.locals, /*parent*/ undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 279 /* SourceFile */ ? node : node.body; - if (body && (body.kind === 279 /* SourceFile */ || body.kind === 245 /* ModuleBlock */)) { + var body = node.kind === 284 /* SourceFile */ ? node : node.body; + if (body && (body.kind === 284 /* SourceFile */ || body.kind === 245 /* ModuleBlock */)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; if (stat.kind === 255 /* ExportDeclaration */ || stat.kind === 254 /* ExportAssignment */) { @@ -28824,7 +28912,7 @@ var ts; case 244 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 279 /* SourceFile */: + case 284 /* SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -28962,7 +29050,7 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 279 /* SourceFile */ && + if (blockScopeContainer.kind !== 284 /* SourceFile */ && blockScopeContainer.kind !== 244 /* ModuleDeclaration */ && !ts.isFunctionLike(blockScopeContainer)) { // We check first if the name is inside class declaration or class expression; if so give explicit message @@ -29237,12 +29325,12 @@ var ts; case 159 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 67187647 /* SetAccessorExcludes */); case 165 /* FunctionType */: - case 289 /* JSDocFunctionType */: - case 293 /* JSDocSignature */: + case 294 /* JSDocFunctionType */: + case 298 /* JSDocSignature */: case 166 /* ConstructorType */: return bindFunctionOrConstructorType(node); case 168 /* TypeLiteral */: - case 292 /* JSDocTypeLiteral */: + case 297 /* JSDocTypeLiteral */: case 181 /* MappedType */: return bindAnonymousTypeWorker(node); case 188 /* ObjectLiteralExpression */: @@ -29301,7 +29389,7 @@ var ts; return bindExportDeclaration(node); case 254 /* ExportAssignment */: return bindExportAssignment(node); - case 279 /* SourceFile */: + case 284 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); case 218 /* Block */: @@ -29311,22 +29399,22 @@ var ts; // falls through case 245 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 299 /* JSDocParameterTag */: - if (node.parent.kind === 293 /* JSDocSignature */) { + case 304 /* JSDocParameterTag */: + if (node.parent.kind === 298 /* JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 292 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 297 /* JSDocTypeLiteral */) { break; } // falls through - case 305 /* JSDocPropertyTag */: + case 310 /* JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 288 /* JSDocOptionalType */ ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 293 /* JSDocOptionalType */ ? 4 /* Property */ | 16777216 /* Optional */ : 4 /* Property */; return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 304 /* JSDocTypedefTag */: - case 297 /* JSDocCallbackTag */: + case 309 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -29498,7 +29586,7 @@ var ts; var symbolTable = ts.hasModifier(thisContainer, 32 /* Static */) ? containingClass.symbol.exports : containingClass.symbol.members; declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */, 0 /* None */, /*isReplaceableByMethod*/ true); break; - case 279 /* SourceFile */: + case 284 /* SourceFile */: // this.property = assignment in a source file -- declare symbol in exports for a module, in locals for a script if (thisContainer.commonJsModuleIndicator) { declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 /* Property */ | 1048576 /* ExportValue */, 0 /* None */); @@ -29515,7 +29603,7 @@ var ts; if (node.expression.kind === 100 /* ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 279 /* SourceFile */) { + else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 284 /* SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -29552,7 +29640,7 @@ var ts; } function bindObjectDefinePropertyAssignment(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]); - var isToplevel = node.parent.parent.kind === 279 /* SourceFile */; + var isToplevel = node.parent.parent.kind === 284 /* SourceFile */; namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false); bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ false); } @@ -29619,8 +29707,8 @@ var ts; function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty) { var namespaceSymbol = lookupSymbolForPropertyAccess(name); var isToplevel = ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 279 /* SourceFile */ - : propertyAccess.parent.parent.kind === 279 /* SourceFile */; + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 284 /* SourceFile */ + : propertyAccess.parent.parent.kind === 284 /* SourceFile */; namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty); bindPotentiallyNewExpandoMemberToNamespace(propertyAccess, namespaceSymbol, isPrototypeProperty); } @@ -29758,7 +29846,7 @@ var ts; } } function bindParameter(node) { - if (node.kind === 299 /* JSDocParameterTag */ && container.kind !== 293 /* JSDocSignature */) { + if (node.kind === 304 /* JSDocParameterTag */ && container.kind !== 298 /* JSDocSignature */) { return; } if (inStrictMode && !(node.flags & 4194304 /* Ambient */)) { @@ -30501,7 +30589,7 @@ var ts; break; case 194 /* TypeAssertionExpression */: case 212 /* AsExpression */: - case 308 /* PartiallyEmittedExpression */: + case 313 /* PartiallyEmittedExpression */: // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; excludeFlags = 536872257 /* OuterExpressionExcludes */; @@ -30702,7 +30790,7 @@ var ts; transformFlags |= 192 /* AssertES2015 */; } break; - case 279 /* SourceFile */: + case 284 /* SourceFile */: if (subtreeFlags & 16384 /* ContainsCapturedLexicalThis */) { transformFlags |= 192 /* AssertES2015 */; } @@ -30782,7 +30870,7 @@ var ts; return 637666625 /* BindingPatternExcludes */; case 194 /* TypeAssertionExpression */: case 212 /* AsExpression */: - case 308 /* PartiallyEmittedExpression */: + case 313 /* PartiallyEmittedExpression */: case 195 /* ParenthesizedExpression */: case 98 /* SuperKeyword */: return 536872257 /* OuterExpressionExcludes */; @@ -31959,7 +32047,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); } function isGlobalSourceFile(node) { - return node.kind === 279 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 284 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -32133,7 +32221,7 @@ var ts; // - parameters are only in the scope of function body // This restriction does not apply to JSDoc comment types because they are parented // at a higher level than type parameters would normally be - if (meaning & result.flags & 67897832 /* Type */ && lastLocation.kind !== 291 /* JSDocComment */) { + if (meaning & result.flags & 67897832 /* Type */ && lastLocation.kind !== 296 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || @@ -32175,14 +32263,14 @@ var ts; } } switch (location.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through case 244 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 279 /* SourceFile */ || ts.isAmbientModule(location)) { + if (location.kind === 284 /* SourceFile */ || ts.isAmbientModule(location)) { // It's an external module. First see if the module has an export default and if the local // name of that export default matches. if (result = moduleExports.get("default" /* Default */)) { @@ -32354,8 +32442,8 @@ var ts; location = location.parent; } break; - case 304 /* JSDocTypedefTag */: - case 297 /* JSDocCallbackTag */: + case 309 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: // js type aliases do not resolve names from their host, so skip past it location = ts.getJSDocHost(location); break; @@ -32374,7 +32462,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 279 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 284 /* SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) { return lastLocation.symbol; } @@ -33230,7 +33318,7 @@ var ts; function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias) { var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 279 /* SourceFile */)) { + if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 284 /* SourceFile */)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; @@ -33581,7 +33669,7 @@ var ts; } } switch (location.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } @@ -33821,10 +33909,10 @@ var ts; return node && getSymbolOfNode(node); } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 279 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 284 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 279 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 284 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -34281,7 +34369,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 279 /* SourceFile */ || declaration.parent.kind === 245 /* ModuleBlock */; + return declaration.parent.kind === 284 /* SourceFile */ || declaration.parent.kind === 245 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -34666,7 +34754,7 @@ var ts; function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) { var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 151 /* Parameter */); if (!parameterDeclaration && !isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 299 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 304 /* JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { @@ -34824,7 +34912,7 @@ var ts; return top; } function getSpecifierForModuleSymbol(symbol, context) { - var file = ts.getDeclarationOfKind(symbol, 279 /* SourceFile */); + var file = ts.getDeclarationOfKind(symbol, 284 /* SourceFile */); if (file && file.moduleName !== undefined) { // Use the amd name if it is available return file.moduleName; @@ -35077,7 +35165,7 @@ var ts; ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 279 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 284 /* SourceFile */ || ts.isAmbientModule(location); } function getNameOfSymbolFromNameType(symbol, context) { var nameType = symbol.nameType; @@ -35154,8 +35242,8 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 297 /* JSDocCallbackTag */: - case 304 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: + case 309 /* JSDocTypedefTag */: // Top-level jsdoc type aliases are considered exported // First parent is comment node, second is hosting declaration or token; we only care about those tokens or declarations whose parent is a source file return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent)); @@ -35182,7 +35270,7 @@ var ts; var parent = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) if (!(ts.getCombinedModifierFlags(node) & 1 /* Export */) && - !(node.kind !== 248 /* ImportEqualsDeclaration */ && parent.kind !== 279 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { + !(node.kind !== 248 /* ImportEqualsDeclaration */ && parent.kind !== 284 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible @@ -35224,7 +35312,7 @@ var ts; // Type parameters are always visible case 150 /* TypeParameter */: // Source file and namespace export are always visible - case 279 /* SourceFile */: + case 284 /* SourceFile */: case 247 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module @@ -36334,15 +36422,15 @@ var ts; case 155 /* MethodSignature */: case 165 /* FunctionType */: case 166 /* ConstructorType */: - case 289 /* JSDocFunctionType */: + case 294 /* JSDocFunctionType */: case 239 /* FunctionDeclaration */: case 156 /* MethodDeclaration */: case 196 /* FunctionExpression */: case 197 /* ArrowFunction */: case 242 /* TypeAliasDeclaration */: - case 303 /* JSDocTemplateTag */: - case 304 /* JSDocTypedefTag */: - case 297 /* JSDocCallbackTag */: + case 308 /* JSDocTemplateTag */: + case 309 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: case 181 /* MappedType */: case 175 /* ConditionalType */: var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); @@ -38334,10 +38422,10 @@ var ts; function isJSDocOptionalParameter(node) { return ts.isInJSFile(node) && ( // node.type should only be a JSDocOptionalType when node is a parameter of a JSDocFunctionType - node.type && node.type.kind === 288 /* JSDocOptionalType */ + node.type && node.type.kind === 293 /* JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 288 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 293 /* JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -38371,7 +38459,7 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 288 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 293 /* JSDocOptionalType */; } function createIdentifierTypePredicate(parameterName, parameterIndex, type) { return { kind: 1 /* Identifier */, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; @@ -39111,7 +39199,7 @@ var ts; } function getConstrainedTypeVariable(typeVariable, node) { var constraints; - while (node && !ts.isStatement(node) && node.kind !== 291 /* JSDocComment */) { + while (node && !ts.isStatement(node) && node.kind !== 296 /* JSDocComment */) { var parent = node.parent; if (parent.kind === 175 /* ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(typeVariable, parent.checkType, parent.extendsType); @@ -40684,8 +40772,8 @@ var ts; function getTypeFromTypeNode(node) { switch (node.kind) { case 120 /* AnyKeyword */: - case 284 /* JSDocAllType */: - case 285 /* JSDocUnknownType */: + case 289 /* JSDocAllType */: + case 290 /* JSDocUnknownType */: return anyType; case 143 /* UnknownKeyword */: return unknownType; @@ -40732,23 +40820,23 @@ var ts; return getTypeFromUnionTypeNode(node); case 174 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 286 /* JSDocNullableType */: + case 291 /* JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 288 /* JSDocOptionalType */: + case 293 /* JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); case 177 /* ParenthesizedType */: case 172 /* RestType */: - case 287 /* JSDocNonNullableType */: - case 283 /* JSDocTypeExpression */: + case 292 /* JSDocNonNullableType */: + case 288 /* JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 290 /* JSDocVariadicType */: + case 295 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); case 165 /* FunctionType */: case 166 /* ConstructorType */: case 168 /* TypeLiteral */: - case 292 /* JSDocTypeLiteral */: - case 289 /* JSDocFunctionType */: - case 293 /* JSDocSignature */: + case 297 /* JSDocTypeLiteral */: + case 294 /* JSDocFunctionType */: + case 298 /* JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); case 179 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); @@ -44109,7 +44197,7 @@ var ts; return; } break; - case 289 /* JSDocFunctionType */: + case 294 /* JSDocFunctionType */: error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; case 239 /* FunctionDeclaration */: @@ -46390,7 +46478,7 @@ var ts; return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || node.kind === 245 /* ModuleBlock */ || - node.kind === 279 /* SourceFile */ || + node.kind === 284 /* SourceFile */ || node.kind === 154 /* PropertyDeclaration */; }); } @@ -46511,7 +46599,7 @@ var ts; // to the constructor in the initializer, we will need to substitute that // binding with an alias as the class name is not in scope. var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); - while (container.kind !== 279 /* SourceFile */) { + while (container.kind !== 284 /* SourceFile */) { if (container.parent === declaration) { if (container.kind === 154 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; @@ -46934,7 +47022,7 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 289 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 294 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -52936,7 +53024,7 @@ var ts; checkAsyncFunctionReturnType(node, returnTypeNode); } } - if (node.kind !== 162 /* IndexSignature */ && node.kind !== 289 /* JSDocFunctionType */) { + if (node.kind !== 162 /* IndexSignature */ && node.kind !== 294 /* JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } @@ -53692,8 +53780,8 @@ var ts; case 241 /* InterfaceDeclaration */: case 242 /* TypeAliasDeclaration */: // A jsdoc typedef and callback are, by definition, type aliases - case 304 /* JSDocTypedefTag */: - case 297 /* JSDocCallbackTag */: + case 309 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: return 2 /* ExportType */; case 244 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ @@ -53702,7 +53790,7 @@ var ts; case 240 /* ClassDeclaration */: case 243 /* EnumDeclaration */: return 2 /* ExportType */ | 1 /* ExportValue */; - case 279 /* SourceFile */: + case 284 /* SourceFile */: return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; case 254 /* ExportAssignment */: // Export assigned entity name expressions act as aliases and should fall through, otherwise they export values @@ -54343,7 +54431,7 @@ var ts; checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 279 /* SourceFile */: + case 284 /* SourceFile */: case 244 /* ModuleDeclaration */: case 218 /* Block */: case 246 /* CaseBlock */: @@ -54690,7 +54778,7 @@ var ts; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 279 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 284 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -54705,7 +54793,7 @@ var ts; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 279 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { + if (parent.kind === 284 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { // If the declaration happens to be in external module, report error that Promise is a reserved identifier. error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -54762,7 +54850,7 @@ var ts; (container.kind === 218 /* Block */ && ts.isFunctionLike(container.parent) || container.kind === 245 /* ModuleBlock */ || container.kind === 244 /* ModuleDeclaration */ || - container.kind === 279 /* SourceFile */); + container.kind === 284 /* SourceFile */); // here we know that function scoped variable is shadowed by block scoped one // if they are defined in the same scope - binder has already reported redeclaration error // otherwise if variable has an initializer - show error that initialization will fail @@ -56612,7 +56700,7 @@ var ts; return false; } var inAmbientExternalModule = node.parent.kind === 245 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 279 /* SourceFile */ && !inAmbientExternalModule) { + if (node.parent.kind !== 284 /* SourceFile */ && !inAmbientExternalModule) { error(moduleName, node.kind === 255 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); @@ -56743,7 +56831,7 @@ var ts; var inAmbientExternalModule = node.parent.kind === 245 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 245 /* ModuleBlock */ && !node.moduleSpecifier && node.flags & 4194304 /* Ambient */; - if (node.parent.kind !== 279 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + if (node.parent.kind !== 284 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -56760,7 +56848,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 279 /* SourceFile */ || node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 244 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 284 /* SourceFile */ || node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 244 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -56789,7 +56877,7 @@ var ts; // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 279 /* SourceFile */ ? node.parent : node.parent.parent; + var container = node.parent.kind === 284 /* SourceFile */ ? node.parent : node.parent.parent; if (container.kind === 244 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); @@ -56959,32 +57047,32 @@ var ts; return checkInferType(node); case 183 /* ImportType */: return checkImportType(node); - case 295 /* JSDocAugmentsTag */: + case 300 /* JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 304 /* JSDocTypedefTag */: - case 297 /* JSDocCallbackTag */: + case 309 /* JSDocTypedefTag */: + case 302 /* JSDocCallbackTag */: return checkJSDocTypeAliasTag(node); - case 303 /* JSDocTemplateTag */: + case 308 /* JSDocTemplateTag */: return checkJSDocTemplateTag(node); - case 302 /* JSDocTypeTag */: + case 307 /* JSDocTypeTag */: return checkJSDocTypeTag(node); - case 299 /* JSDocParameterTag */: + case 304 /* JSDocParameterTag */: return checkJSDocParameterTag(node); - case 289 /* JSDocFunctionType */: + case 294 /* JSDocFunctionType */: checkJSDocFunctionType(node); // falls through - case 287 /* JSDocNonNullableType */: - case 286 /* JSDocNullableType */: - case 284 /* JSDocAllType */: - case 285 /* JSDocUnknownType */: - case 292 /* JSDocTypeLiteral */: + case 292 /* JSDocNonNullableType */: + case 291 /* JSDocNullableType */: + case 289 /* JSDocAllType */: + case 290 /* JSDocUnknownType */: + case 297 /* JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 290 /* JSDocVariadicType */: + case 295 /* JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 283 /* JSDocTypeExpression */: + case 288 /* JSDocTypeExpression */: return checkSourceElement(node.type); case 180 /* IndexedAccessType */: return checkIndexedAccessType(node); @@ -57292,7 +57380,7 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; // falls through @@ -57511,10 +57599,10 @@ var ts; return entityNameSymbol; } } - if (entityName.parent.kind === 299 /* JSDocParameterTag */) { + if (entityName.parent.kind === 304 /* JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(entityName.parent); } - if (entityName.parent.kind === 150 /* TypeParameter */ && entityName.parent.parent.kind === 303 /* JSDocTemplateTag */) { + if (entityName.parent.kind === 150 /* TypeParameter */ && entityName.parent.parent.kind === 308 /* JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJSFile(entityName)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(entityName.parent); return typeParameter && typeParameter.symbol; @@ -57556,7 +57644,7 @@ var ts; return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 279 /* SourceFile */) { + if (node.kind === 284 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; @@ -57898,7 +57986,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 279 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 284 /* SourceFile */) { var symbolFile = parentSymbol_1.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); // If `node` accesses an export and that export isn't in the same file, then symbol is a namespace export, so return undefined. @@ -58013,7 +58101,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 279 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 284 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -58442,7 +58530,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 279 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 284 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -58475,7 +58563,7 @@ var ts; if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 279 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 284 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -58707,7 +58795,7 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 279 /* SourceFile */) { + else if (node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 284 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128 /* Abstract */) { @@ -58730,7 +58818,7 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 279 /* SourceFile */) { + else if (node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 284 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } else if (node.kind === 151 /* Parameter */) { @@ -58775,7 +58863,7 @@ var ts; flags |= 1 /* Export */; break; case 80 /* DefaultKeyword */: - var container = node.parent.kind === 279 /* SourceFile */ ? node.parent : node.parent.parent; + var container = node.parent.kind === 284 /* SourceFile */ ? node.parent : node.parent.parent; if (container.kind === 244 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } @@ -58898,7 +58986,7 @@ var ts; case 151 /* Parameter */: return false; default: - if (node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 279 /* SourceFile */) { + if (node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 284 /* SourceFile */) { return false; } switch (node.kind) { @@ -59821,7 +59909,7 @@ var ts; // to prevent noisiness. So use a bit on the block to indicate if // this has already been reported, and don't report if it has. // - if (node.parent.kind === 218 /* Block */ || node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 279 /* SourceFile */) { + if (node.parent.kind === 218 /* Block */ || node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 284 /* SourceFile */) { var links_2 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_2.hasReportedStatementInAmbientContext) { @@ -61875,14 +61963,14 @@ var ts; // JSDoc /* @internal */ function createJSDocTypeExpression(type) { - var node = createSynthesizedNode(283 /* JSDocTypeExpression */); + var node = createSynthesizedNode(288 /* JSDocTypeExpression */); node.type = type; return node; } ts.createJSDocTypeExpression = createJSDocTypeExpression; /* @internal */ function createJSDocTypeTag(typeExpression, comment) { - var tag = createJSDocTag(302 /* JSDocTypeTag */, "type"); + var tag = createJSDocTag(307 /* JSDocTypeTag */, "type"); tag.typeExpression = typeExpression; tag.comment = comment; return tag; @@ -61890,7 +61978,7 @@ var ts; ts.createJSDocTypeTag = createJSDocTypeTag; /* @internal */ function createJSDocReturnTag(typeExpression, comment) { - var tag = createJSDocTag(300 /* JSDocReturnTag */, "returns"); + var tag = createJSDocTag(305 /* JSDocReturnTag */, "returns"); tag.typeExpression = typeExpression; tag.comment = comment; return tag; @@ -61898,7 +61986,7 @@ var ts; ts.createJSDocReturnTag = createJSDocReturnTag; /* @internal */ function createJSDocParamTag(name, isBracketed, typeExpression, comment) { - var tag = createJSDocTag(299 /* JSDocParameterTag */, "param"); + var tag = createJSDocTag(304 /* JSDocParameterTag */, "param"); tag.typeExpression = typeExpression; tag.name = name; tag.isBracketed = isBracketed; @@ -61908,7 +61996,7 @@ var ts; ts.createJSDocParamTag = createJSDocParamTag; /* @internal */ function createJSDocComment(comment, tags) { - var node = createSynthesizedNode(291 /* JSDocComment */); + var node = createSynthesizedNode(296 /* JSDocComment */); node.comment = comment; node.tags = tags; return node; @@ -62167,7 +62255,7 @@ var ts; (typeReferences !== undefined && node.typeReferenceDirectives !== typeReferences) || (libReferences !== undefined && node.libReferenceDirectives !== libReferences) || (hasNoDefaultLib !== undefined && node.hasNoDefaultLib !== hasNoDefaultLib)) { - var updated = createSynthesizedNode(279 /* SourceFile */); + var updated = createSynthesizedNode(284 /* SourceFile */); updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; @@ -62251,7 +62339,7 @@ var ts; * @param original The original statement. */ function createNotEmittedStatement(original) { - var node = createSynthesizedNode(307 /* NotEmittedStatement */); + var node = createSynthesizedNode(312 /* NotEmittedStatement */); node.original = original; setTextRange(node, original); return node; @@ -62263,7 +62351,7 @@ var ts; */ /* @internal */ function createEndOfDeclarationMarker(original) { - var node = createSynthesizedNode(311 /* EndOfDeclarationMarker */); + var node = createSynthesizedNode(316 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -62275,7 +62363,7 @@ var ts; */ /* @internal */ function createMergeDeclarationMarker(original) { - var node = createSynthesizedNode(310 /* MergeDeclarationMarker */); + var node = createSynthesizedNode(315 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -62290,7 +62378,7 @@ var ts; * @param location The location for the expression. Defaults to the positions from "original" if provided. */ function createPartiallyEmittedExpression(expression, original) { - var node = createSynthesizedNode(308 /* PartiallyEmittedExpression */); + var node = createSynthesizedNode(313 /* PartiallyEmittedExpression */); node.expression = expression; node.original = original; setTextRange(node, original); @@ -62306,7 +62394,7 @@ var ts; ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; function flattenCommaElements(node) { if (ts.nodeIsSynthesized(node) && !ts.isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) { - if (node.kind === 309 /* CommaListExpression */) { + if (node.kind === 314 /* CommaListExpression */) { return node.elements; } if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27 /* CommaToken */) { @@ -62316,7 +62404,7 @@ var ts; return node; } function createCommaList(elements) { - var node = createSynthesizedNode(309 /* CommaListExpression */); + var node = createSynthesizedNode(314 /* CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); return node; } @@ -62329,33 +62417,197 @@ var ts; ts.updateCommaList = updateCommaList; function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = ts.createNode(280 /* Bundle */); + var node = ts.createNode(285 /* Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; } ts.createBundle = createBundle; - function createUnparsedSourceFile(textOrInputFiles, mapPathOrType, map) { - var node = ts.createNode(281 /* UnparsedSource */); + var allUnscopedEmitHelpers; + function getAllUnscopedEmitHelpers() { + return allUnscopedEmitHelpers || (allUnscopedEmitHelpers = ts.arrayToMap([ + ts.valuesHelper, + ts.readHelper, + ts.spreadHelper, + ts.restHelper, + ts.decorateHelper, + ts.metadataHelper, + ts.paramHelper, + ts.awaiterHelper, + ts.assignHelper, + ts.awaitHelper, + ts.asyncGeneratorHelper, + ts.asyncDelegator, + ts.asyncValues, + ts.extendsHelper, + ts.templateObjectHelper, + ts.generatorHelper, + ts.importStarHelper, + ts.importDefaultHelper + ], function (helper) { return helper.name; })); + } + function createUnparsedSource() { + var node = ts.createNode(286 /* UnparsedSource */); + node.prologues = ts.emptyArray; + node.referencedFiles = ts.emptyArray; + node.libReferenceDirectives = ts.emptyArray; + node.getLineAndCharacterOfPosition = function (pos) { return ts.getLineAndCharacterOfPosition(node, pos); }; + return node; + } + function createUnparsedSourceFile(textOrInputFiles, mapPathOrType, mapTextOrStripInternal) { + var node = createUnparsedSource(); + var stripInternal; + var bundleFileInfo; if (!ts.isString(textOrInputFiles)) { ts.Debug.assert(mapPathOrType === "js" || mapPathOrType === "dts"); - node.fileName = mapPathOrType === "js" ? textOrInputFiles.javascriptPath : textOrInputFiles.declarationPath; + node.fileName = (mapPathOrType === "js" ? textOrInputFiles.javascriptPath : textOrInputFiles.declarationPath) || ""; node.sourceMapPath = mapPathOrType === "js" ? textOrInputFiles.javascriptMapPath : textOrInputFiles.declarationMapPath; Object.defineProperties(node, { text: { get: function () { return mapPathOrType === "js" ? textOrInputFiles.javascriptText : textOrInputFiles.declarationText; } }, sourceMapText: { get: function () { return mapPathOrType === "js" ? textOrInputFiles.javascriptMapText : textOrInputFiles.declarationMapText; } }, }); + if (textOrInputFiles.buildInfo && textOrInputFiles.buildInfo.bundle) { + node.oldFileOfCurrentEmit = textOrInputFiles.oldFileOfCurrentEmit; + ts.Debug.assert(mapTextOrStripInternal === undefined || typeof mapTextOrStripInternal === "boolean"); + stripInternal = mapTextOrStripInternal; + bundleFileInfo = mapPathOrType === "js" ? textOrInputFiles.buildInfo.bundle.js : textOrInputFiles.buildInfo.bundle.dts; + if (node.oldFileOfCurrentEmit) { + parseOldFileOfCurrentEmit(node, ts.Debug.assertDefined(bundleFileInfo)); + return node; + } + } } else { + node.fileName = ""; node.text = textOrInputFiles; node.sourceMapPath = mapPathOrType; - node.sourceMapText = map; + node.sourceMapText = mapTextOrStripInternal; } + ts.Debug.assert(!node.oldFileOfCurrentEmit); + parseUnparsedSourceFile(node, bundleFileInfo, stripInternal); return node; } ts.createUnparsedSourceFile = createUnparsedSourceFile; - function createInputFiles(javascriptTextOrReadFileText, declarationTextOrJavascriptPath, javascriptMapPath, javascriptMapTextOrDeclarationPath, declarationMapPath, declarationMapText) { - var node = ts.createNode(282 /* InputFiles */); + function parseUnparsedSourceFile(node, bundleFileInfo, stripInternal) { + var prologues; + var helpers; + var referencedFiles; + var typeReferenceDirectives; + var libReferenceDirectives; + var texts; + for (var _i = 0, _a = bundleFileInfo ? bundleFileInfo.sections : ts.emptyArray; _i < _a.length; _i++) { + var section = _a[_i]; + switch (section.kind) { + case "prologue" /* Prologue */: + (prologues || (prologues = [])).push(createUnparsedNode(section, node)); + break; + case "emitHelpers" /* EmitHelpers */: + (helpers || (helpers = [])).push(getAllUnscopedEmitHelpers().get(section.data)); + break; + case "no-default-lib" /* NoDefaultLib */: + node.hasNoDefaultLib = true; + break; + case "reference" /* Reference */: + (referencedFiles || (referencedFiles = [])).push({ pos: -1, end: -1, fileName: section.data }); + break; + case "type" /* Type */: + (typeReferenceDirectives || (typeReferenceDirectives = [])).push(section.data); + break; + case "lib" /* Lib */: + (libReferenceDirectives || (libReferenceDirectives = [])).push({ pos: -1, end: -1, fileName: section.data }); + break; + case "prepend" /* Prepend */: + var prependNode = createUnparsedNode(section, node); + var prependTexts = void 0; + for (var _b = 0, _c = section.texts; _b < _c.length; _b++) { + var text = _c[_b]; + if (!stripInternal || text.kind !== "internal" /* Internal */) { + (prependTexts || (prependTexts = [])).push(createUnparsedNode(text, node)); + } + } + prependNode.texts = prependTexts || ts.emptyArray; + (texts || (texts = [])).push(prependNode); + break; + case "internal" /* Internal */: + if (stripInternal) + break; + // falls through + case "text" /* Text */: + (texts || (texts = [])).push(createUnparsedNode(section, node)); + break; + default: + ts.Debug.assertNever(section); + } + } + node.prologues = prologues || ts.emptyArray; + node.helpers = helpers; + node.referencedFiles = referencedFiles || ts.emptyArray; + node.typeReferenceDirectives = typeReferenceDirectives; + node.libReferenceDirectives = libReferenceDirectives || ts.emptyArray; + node.texts = texts || [createUnparsedNode({ kind: "text" /* Text */, pos: 0, end: node.text.length }, node)]; + } + function parseOldFileOfCurrentEmit(node, bundleFileInfo) { + ts.Debug.assert(!!node.oldFileOfCurrentEmit); + var texts; + var syntheticReferences; + for (var _i = 0, _a = bundleFileInfo.sections; _i < _a.length; _i++) { + var section = _a[_i]; + switch (section.kind) { + case "internal" /* Internal */: + case "text" /* Text */: + (texts || (texts = [])).push(createUnparsedNode(section, node)); + break; + case "no-default-lib" /* NoDefaultLib */: + case "reference" /* Reference */: + case "type" /* Type */: + case "lib" /* Lib */: + (syntheticReferences || (syntheticReferences = [])).push(createUnparsedSyntheticReference(section, node)); + break; + // Ignore + case "prologue" /* Prologue */: + case "emitHelpers" /* EmitHelpers */: + case "prepend" /* Prepend */: + break; + default: + ts.Debug.assertNever(section); + } + } + node.texts = texts || ts.emptyArray; + node.helpers = ts.map(bundleFileInfo.sources && bundleFileInfo.sources.helpers, function (name) { return getAllUnscopedEmitHelpers().get(name); }); + node.syntheticReferences = syntheticReferences; + return node; + } + function mapBundleFileSectionKindToSyntaxKind(kind) { + switch (kind) { + case "prologue" /* Prologue */: return 279 /* UnparsedPrologue */; + case "prepend" /* Prepend */: return 280 /* UnparsedPrepend */; + case "internal" /* Internal */: return 282 /* UnparsedInternalText */; + case "text" /* Text */: return 281 /* UnparsedText */; + case "emitHelpers" /* EmitHelpers */: + case "no-default-lib" /* NoDefaultLib */: + case "reference" /* Reference */: + case "type" /* Type */: + case "lib" /* Lib */: + return ts.Debug.fail("BundleFileSectionKind: " + kind + " not yet mapped to SyntaxKind"); + default: + return ts.Debug.assertNever(kind); + } + } + function createUnparsedNode(section, parent) { + var node = ts.createNode(mapBundleFileSectionKindToSyntaxKind(section.kind), section.pos, section.end); + node.parent = parent; + node.data = section.data; + return node; + } + function createUnparsedSyntheticReference(section, parent) { + var node = ts.createNode(283 /* UnparsedSyntheticReference */, section.pos, section.end); + node.parent = parent; + node.data = section.data; + node.section = section; + return node; + } + function createInputFiles(javascriptTextOrReadFileText, declarationTextOrJavascriptPath, javascriptMapPath, javascriptMapTextOrDeclarationPath, declarationMapPath, declarationMapTextOrBuildInfoPath, javascriptPath, declarationPath, buildInfoPath, buildInfo, oldFileOfCurrentEmit) { + var node = ts.createNode(287 /* InputFiles */); if (!ts.isString(javascriptTextOrReadFileText)) { var cache_1 = ts.createMap(); var textGetter_1 = function (path) { @@ -62372,15 +62624,25 @@ var ts; var result = textGetter_1(path); return result !== undefined ? result : "/* Input file " + path + " was missing */\r\n"; }; + var buildInfo_1; + var getBuildInfo_1 = function (getText) { + if (buildInfo_1 === undefined) { + var result = getText(); + buildInfo_1 = result !== undefined ? JSON.parse(result) : false; + } + return buildInfo_1 || undefined; + }; node.javascriptPath = declarationTextOrJavascriptPath; node.javascriptMapPath = javascriptMapPath; node.declarationPath = ts.Debug.assertDefined(javascriptMapTextOrDeclarationPath); node.declarationMapPath = declarationMapPath; + node.buildInfoPath = declarationMapTextOrBuildInfoPath; Object.defineProperties(node, { javascriptText: { get: function () { return definedTextGetter_1(declarationTextOrJavascriptPath); } }, javascriptMapText: { get: function () { return textGetter_1(javascriptMapPath); } }, declarationText: { get: function () { return definedTextGetter_1(ts.Debug.assertDefined(javascriptMapTextOrDeclarationPath)); } }, - declarationMapText: { get: function () { return textGetter_1(declarationMapPath); } } // TODO:: if there is inline sourceMap in dtsFile, use that + declarationMapText: { get: function () { return textGetter_1(declarationMapPath); } }, + buildInfo: { get: function () { return getBuildInfo_1(function () { return textGetter_1(declarationMapTextOrBuildInfoPath); }); } } }); } else { @@ -62389,7 +62651,12 @@ var ts; node.javascriptMapText = javascriptMapTextOrDeclarationPath; node.declarationText = declarationTextOrJavascriptPath; node.declarationMapPath = declarationMapPath; - node.declarationMapText = declarationMapText; + node.declarationMapText = declarationMapTextOrBuildInfoPath; + node.javascriptPath = javascriptPath; + node.declarationPath = declarationPath, + node.buildInfoPath = buildInfoPath; + node.buildInfo = buildInfo; + node.oldFileOfCurrentEmit = oldFileOfCurrentEmit; } return node; } @@ -62527,7 +62794,7 @@ var ts; // To avoid holding onto transformation artifacts, we keep track of any // parse tree node we are annotating. This allows us to clean them up after // all transformations have completed. - if (node.kind === 279 /* SourceFile */) { + if (node.kind === 284 /* SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(ts.getParseTreeNode(ts.getSourceFileOfNode(node))); @@ -62973,38 +63240,38 @@ var ts; return ts.setEmitFlags(ts.createIdentifier(name), 4096 /* HelperName */ | 2 /* AdviseOnEmitNode */); } ts.getHelperName = getHelperName; - var valuesHelper = { + ts.valuesHelper = { name: "typescript:values", scoped: false, text: "\n var __values = (this && this.__values) || function (o) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator], i = 0;\n if (m) return m.call(o);\n return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n };" }; function createValuesHelper(context, expression, location) { - context.requestEmitHelper(valuesHelper); + context.requestEmitHelper(ts.valuesHelper); return ts.setTextRange(ts.createCall(getHelperName("__values"), /*typeArguments*/ undefined, [expression]), location); } ts.createValuesHelper = createValuesHelper; - var readHelper = { + ts.readHelper = { name: "typescript:read", scoped: false, text: "\n var __read = (this && this.__read) || function (o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n };" }; function createReadHelper(context, iteratorRecord, count, location) { - context.requestEmitHelper(readHelper); + context.requestEmitHelper(ts.readHelper); return ts.setTextRange(ts.createCall(getHelperName("__read"), /*typeArguments*/ undefined, count !== undefined ? [iteratorRecord, ts.createLiteral(count)] : [iteratorRecord]), location); } ts.createReadHelper = createReadHelper; - var spreadHelper = { + ts.spreadHelper = { name: "typescript:spread", scoped: false, text: "\n var __spread = (this && this.__spread) || function () {\n for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));\n return ar;\n };" }; function createSpreadHelper(context, argumentList, location) { - context.requestEmitHelper(readHelper); - context.requestEmitHelper(spreadHelper); + context.requestEmitHelper(ts.readHelper); + context.requestEmitHelper(ts.spreadHelper); return ts.setTextRange(ts.createCall(getHelperName("__spread"), /*typeArguments*/ undefined, argumentList), location); } @@ -63850,7 +64117,7 @@ var ts; case 190 /* ElementAccessExpression */: case 189 /* PropertyAccessExpression */: case 213 /* NonNullExpression */: - case 308 /* PartiallyEmittedExpression */: + case 313 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -63866,7 +64133,7 @@ var ts; ts.parenthesizeConciseBody = parenthesizeConciseBody; function isCommaSequence(node) { return node.kind === 204 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || - node.kind === 309 /* CommaListExpression */; + node.kind === 314 /* CommaListExpression */; } ts.isCommaSequence = isCommaSequence; var OuterExpressionKinds; @@ -63885,7 +64152,7 @@ var ts; case 212 /* AsExpression */: case 213 /* NonNullExpression */: return (kinds & 2 /* Assertions */) !== 0; - case 308 /* PartiallyEmittedExpression */: + case 313 /* PartiallyEmittedExpression */: return (kinds & 4 /* PartiallyEmittedExpressions */) !== 0; } return false; @@ -63922,7 +64189,7 @@ var ts; case 194 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); case 212 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); case 213 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); - case 308 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); + case 313 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -64714,12 +64981,12 @@ var ts; case 278 /* EnumMember */: return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); // Top-level nodes - case 279 /* SourceFile */: + case 284 /* SourceFile */: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 308 /* PartiallyEmittedExpression */: + case 313 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 309 /* CommaListExpression */: + case 314 /* CommaListExpression */: return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: // No need to visit nodes with no children. @@ -64775,7 +65042,7 @@ var ts; case 220 /* EmptyStatement */: case 210 /* OmittedExpression */: case 236 /* DebuggerStatement */: - case 307 /* NotEmittedStatement */: + case 312 /* NotEmittedStatement */: // No need to visit nodes with no children. break; // Names @@ -65152,14 +65419,14 @@ var ts; result = reduceNode(node.initializer, cbNode, result); break; // Top-level nodes - case 279 /* SourceFile */: + case 284 /* SourceFile */: result = reduceNodes(node.statements, cbNodes, result); break; // Transformation nodes - case 308 /* PartiallyEmittedExpression */: + case 313 /* PartiallyEmittedExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 309 /* CommaListExpression */: + case 314 /* CommaListExpression */: result = reduceNodes(node.elements, cbNodes, result); break; default: @@ -65440,7 +65707,7 @@ var ts; } exit(); } - function appendSourceMap(generatedLine, generatedCharacter, map, sourceMapPath) { + function appendSourceMap(generatedLine, generatedCharacter, map, sourceMapPath, start, end) { var _a; ts.Debug.assert(generatedLine >= pendingGeneratedLine, "generatedLine cannot backtrack"); ts.Debug.assert(generatedCharacter >= 0, "generatedCharacter cannot be negative"); @@ -65450,6 +65717,14 @@ var ts; var nameIndexToNewNameIndexMap; var mappingIterator = decodeMappings(map.mappings); for (var _b = mappingIterator.next(), raw = _b.value, done = _b.done; !done; _a = mappingIterator.next(), raw = _a.value, done = _a.done, _a) { + if (end && (raw.generatedLine > end.line || + (raw.generatedLine === end.line && raw.generatedCharacter > end.character))) { + break; + } + if (start && (raw.generatedLine < start.line || + (start.line === raw.generatedLine && raw.generatedCharacter < start.character))) { + continue; + } // Then reencode all the updated mappings into the overall map var newSourceIndex = void 0; var newSourceLine = void 0; @@ -65478,8 +65753,10 @@ var ts; } } } - var newGeneratedLine = raw.generatedLine + generatedLine; - var newGeneratedCharacter = raw.generatedLine === 0 ? raw.generatedCharacter + generatedCharacter : raw.generatedCharacter; + var rawGeneratedLine = raw.generatedLine - (start ? start.line : 0); + var newGeneratedLine = rawGeneratedLine + generatedLine; + var rawGeneratedCharacter = start && start.line === raw.generatedLine ? raw.generatedCharacter - start.character : raw.generatedCharacter; + var newGeneratedCharacter = rawGeneratedLine === 0 ? rawGeneratedCharacter + generatedCharacter : rawGeneratedCharacter; addMapping(newGeneratedLine, newGeneratedCharacter, newSourceIndex, newSourceLine, newSourceCharacter, newNameIndex); } exit(); @@ -65962,7 +66239,7 @@ var ts; function chainBundle(transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 279 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 284 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return ts.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -66623,7 +66900,7 @@ var ts; function makeAssignmentElement(name) { return name; } - var restHelper = { + ts.restHelper = { name: "typescript:rest", scoped: false, text: "\n var __rest = (this && this.__rest) || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)\n t[p[i]] = s[p[i]];\n return t;\n };" @@ -66632,7 +66909,7 @@ var ts; * `{ a, b, ...p } = o`, create `p = __rest(o, ["a", "b"]);` */ function createRestCall(context, value, elements, computedTempVariables, location) { - context.requestEmitHelper(restHelper); + context.requestEmitHelper(ts.restHelper); var propertyNames = []; var computedTempVariableOffset = 0; for (var i = 0; i < elements.length - 1; i++) { @@ -66733,14 +67010,14 @@ var ts; var pendingExpressions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 280 /* Bundle */) { + if (node.kind === 285 /* Bundle */) { return transformBundle(node); } return transformSourceFile(node); } function transformBundle(node) { return ts.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 282 /* InputFiles */) { + if (prepend.kind === 287 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend, "js"); } return prepend; @@ -66789,7 +67066,7 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 279 /* SourceFile */: + case 284 /* SourceFile */: case 246 /* CaseBlock */: case 245 /* ModuleBlock */: case 218 /* Block */: @@ -69020,7 +69297,7 @@ var ts; // enums in any other scope are emitted as a `let` declaration. var statement = ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ ts.createVariableDeclaration(ts.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true)) - ], currentLexicalScope.kind === 279 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentLexicalScope.kind === 284 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { @@ -69585,7 +69862,7 @@ var ts; // If we are nested within a namespace declaration, we may need to qualifiy // an identifier that is exported from a merged namespace. var container = resolver.getReferencedExportContainer(node, /*prefixLocals*/ false); - if (container && container.kind !== 279 /* SourceFile */) { + if (container && container.kind !== 284 /* SourceFile */) { var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 244 /* ModuleDeclaration */) || (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 243 /* EnumDeclaration */); if (substitute) { @@ -69636,39 +69913,39 @@ var ts; argumentsArray.push(descriptor); } } - context.requestEmitHelper(decorateHelper); + context.requestEmitHelper(ts.decorateHelper); return ts.setTextRange(ts.createCall(ts.getHelperName("__decorate"), /*typeArguments*/ undefined, argumentsArray), location); } - var decorateHelper = { + ts.decorateHelper = { name: "typescript:decorate", scoped: false, priority: 2, text: "\n var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n };" }; function createMetadataHelper(context, metadataKey, metadataValue) { - context.requestEmitHelper(metadataHelper); + context.requestEmitHelper(ts.metadataHelper); return ts.createCall(ts.getHelperName("__metadata"), /*typeArguments*/ undefined, [ ts.createLiteral(metadataKey), metadataValue ]); } - var metadataHelper = { + ts.metadataHelper = { name: "typescript:metadata", scoped: false, priority: 3, text: "\n var __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n };" }; function createParamHelper(context, expression, parameterOffset, location) { - context.requestEmitHelper(paramHelper); + context.requestEmitHelper(ts.paramHelper); return ts.setTextRange(ts.createCall(ts.getHelperName("__param"), /*typeArguments*/ undefined, [ ts.createLiteral(parameterOffset), expression ]), location); } - var paramHelper = { + ts.paramHelper = { name: "typescript:param", scoped: false, priority: 4, @@ -70219,14 +70496,14 @@ var ts; ], 2 /* Const */)); } ts.createSuperAccessVariableStatement = createSuperAccessVariableStatement; - var awaiterHelper = { + ts.awaiterHelper = { name: "typescript:awaiter", scoped: false, priority: 5, text: "\n var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n };" }; function createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, body) { - context.requestEmitHelper(awaiterHelper); + context.requestEmitHelper(ts.awaiterHelper); var generatorFunc = ts.createFunctionExpression( /*modifiers*/ undefined, ts.createToken(40 /* AsteriskToken */), /*name*/ undefined, @@ -70858,7 +71135,7 @@ var ts; } } ts.transformES2018 = transformES2018; - var assignHelper = { + ts.assignHelper = { name: "typescript:assign", scoped: false, priority: 1, @@ -70869,28 +71146,28 @@ var ts; return ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "assign"), /*typeArguments*/ undefined, attributesSegments); } - context.requestEmitHelper(assignHelper); + context.requestEmitHelper(ts.assignHelper); return ts.createCall(ts.getHelperName("__assign"), /*typeArguments*/ undefined, attributesSegments); } ts.createAssignHelper = createAssignHelper; - var awaitHelper = { + ts.awaitHelper = { name: "typescript:await", scoped: false, text: "\n var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }" }; function createAwaitHelper(context, expression) { - context.requestEmitHelper(awaitHelper); + context.requestEmitHelper(ts.awaitHelper); return ts.createCall(ts.getHelperName("__await"), /*typeArguments*/ undefined, [expression]); } - var asyncGeneratorHelper = { + ts.asyncGeneratorHelper = { name: "typescript:asyncGenerator", scoped: false, text: "\n var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n };" }; function createAsyncGeneratorHelper(context, generatorFunc) { - context.requestEmitHelper(awaitHelper); - context.requestEmitHelper(asyncGeneratorHelper); + context.requestEmitHelper(ts.awaitHelper); + context.requestEmitHelper(ts.asyncGeneratorHelper); // Mark this node as originally an async function (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* AsyncFunctionBody */; return ts.createCall(ts.getHelperName("__asyncGenerator"), @@ -70900,24 +71177,24 @@ var ts; generatorFunc ]); } - var asyncDelegator = { + ts.asyncDelegator = { name: "typescript:asyncDelegator", scoped: false, text: "\n var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {\n var i, p;\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\n };" }; function createAsyncDelegatorHelper(context, expression, location) { - context.requestEmitHelper(awaitHelper); - context.requestEmitHelper(asyncDelegator); + context.requestEmitHelper(ts.awaitHelper); + context.requestEmitHelper(ts.asyncDelegator); return ts.setTextRange(ts.createCall(ts.getHelperName("__asyncDelegator"), /*typeArguments*/ undefined, [expression]), location); } - var asyncValues = { + ts.asyncValues = { name: "typescript:asyncValues", scoped: false, text: "\n var __asyncValues = (this && this.__asyncValues) || function (o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator], i;\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\n };" }; function createAsyncValuesHelper(context, expression, location) { - context.requestEmitHelper(asyncValues); + context.requestEmitHelper(ts.asyncValues); return ts.setTextRange(ts.createCall(ts.getHelperName("__asyncValues"), /*typeArguments*/ undefined, [expression]), location); } @@ -74729,7 +75006,7 @@ var ts; } ts.transformES2015 = transformES2015; function createExtendsHelper(context, name) { - context.requestEmitHelper(extendsHelper); + context.requestEmitHelper(ts.extendsHelper); return ts.createCall(ts.getHelperName("__extends"), /*typeArguments*/ undefined, [ name, @@ -74737,20 +75014,20 @@ var ts; ]); } function createTemplateObjectHelper(context, cooked, raw) { - context.requestEmitHelper(templateObjectHelper); + context.requestEmitHelper(ts.templateObjectHelper); return ts.createCall(ts.getHelperName("__makeTemplateObject"), /*typeArguments*/ undefined, [ cooked, raw ]); } - var extendsHelper = { + ts.extendsHelper = { name: "typescript:extends", scoped: false, priority: 0, text: "\n var __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n })();" }; - var templateObjectHelper = { + ts.templateObjectHelper = { name: "typescript:makeTemplateObject", scoped: false, priority: 0, @@ -77444,7 +77721,7 @@ var ts; } ts.transformGenerators = transformGenerators; function createGeneratorHelper(context, body) { - context.requestEmitHelper(generatorHelper); + context.requestEmitHelper(ts.generatorHelper); return ts.createCall(ts.getHelperName("__generator"), /*typeArguments*/ undefined, [ts.createThis(), body]); } @@ -77507,7 +77784,7 @@ var ts; // entering a finally block. // // For examples of how these are used, see the comments in ./transformers/generators.ts - var generatorHelper = { + ts.generatorHelper = { name: "typescript:generator", scoped: false, priority: 6, @@ -77540,7 +77817,7 @@ var ts; context.enableSubstitution(202 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. context.enableSubstitution(203 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. context.enableSubstitution(276 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(279 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableEmitNotification(284 /* SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var currentSourceFile; // The current file. @@ -77882,9 +78159,9 @@ var ts; return visitFunctionDeclaration(node); case 240 /* ClassDeclaration */: return visitClassDeclaration(node); - case 310 /* MergeDeclarationMarker */: + case 315 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 311 /* EndOfDeclarationMarker */: + case 316 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); @@ -78042,7 +78319,7 @@ var ts; } var promise = ts.createNew(ts.createIdentifier("Promise"), /*typeArguments*/ undefined, [func]); if (compilerOptions.esModuleInterop) { - context.requestEmitHelper(importStarHelper); + context.requestEmitHelper(ts.importStarHelper); return ts.createCall(ts.createPropertyAccess(promise, ts.createIdentifier("then")), /*typeArguments*/ undefined, [ts.getHelperName("__importStar")]); } return promise; @@ -78056,7 +78333,7 @@ var ts; var promiseResolveCall = ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Promise"), "resolve"), /*typeArguments*/ undefined, /*argumentsArray*/ []); var requireCall = ts.createCall(ts.createIdentifier("require"), /*typeArguments*/ undefined, arg ? [arg] : []); if (compilerOptions.esModuleInterop) { - context.requestEmitHelper(importStarHelper); + context.requestEmitHelper(ts.importStarHelper); requireCall = ts.createCall(ts.getHelperName("__importStar"), /*typeArguments*/ undefined, [requireCall]); } var func; @@ -78090,11 +78367,11 @@ var ts; return innerExpr; } if (ts.getImportNeedsImportStarHelper(node)) { - context.requestEmitHelper(importStarHelper); + context.requestEmitHelper(ts.importStarHelper); return ts.createCall(ts.getHelperName("__importStar"), /*typeArguments*/ undefined, [innerExpr]); } if (ts.getImportNeedsImportDefaultHelper(node)) { - context.requestEmitHelper(importDefaultHelper); + context.requestEmitHelper(ts.importDefaultHelper); return ts.createCall(ts.getHelperName("__importDefault"), /*typeArguments*/ undefined, [innerExpr]); } return innerExpr; @@ -78663,7 +78940,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 279 /* SourceFile */) { + if (node.kind === 284 /* SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -78751,7 +79028,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 279 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 284 /* SourceFile */) { return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), /*location*/ node); } @@ -78877,13 +79154,13 @@ var ts; text: "\n var __syncRequire = typeof module === \"object\" && typeof module.exports === \"object\";" }; // emit helper for `import * as Name from "foo"` - var importStarHelper = { + ts.importStarHelper = { name: "typescript:commonjsimportstar", scoped: false, text: "\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\n result[\"default\"] = mod;\n return result;\n};" }; // emit helper for `import Name from "foo"` - var importDefaultHelper = { + ts.importDefaultHelper = { name: "typescript:commonjsimportdefault", scoped: false, text: "\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};" @@ -78906,7 +79183,7 @@ var ts; context.enableSubstitution(204 /* BinaryExpression */); // Substitutes assignments to exported symbols. context.enableSubstitution(202 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. context.enableSubstitution(203 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableEmitNotification(279 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableEmitNotification(284 /* SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var exportFunctionsMap = []; // The export function associated with a source file. @@ -79476,7 +79753,7 @@ var ts; function shouldHoistVariableDeclarationList(node) { // hoist only non-block scoped declarations or block scoped declarations parented by source file return (ts.getEmitFlags(node) & 2097152 /* NoHoisting */) === 0 - && (enclosingBlockScopedContainer.kind === 279 /* SourceFile */ + && (enclosingBlockScopedContainer.kind === 284 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -79819,9 +80096,9 @@ var ts; return visitCatchClause(node); case 218 /* Block */: return visitBlock(node); - case 310 /* MergeDeclarationMarker */: + case 315 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 311 /* EndOfDeclarationMarker */: + case 316 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -80069,7 +80346,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 279 /* SourceFile */; + return container !== undefined && container.kind === 284 /* SourceFile */; } else { return false; @@ -80102,7 +80379,7 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 279 /* SourceFile */) { + if (node.kind === 284 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -80311,7 +80588,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 279 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 284 /* SourceFile */) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -80350,7 +80627,7 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(279 /* SourceFile */); + context.enableEmitNotification(284 /* SourceFile */); context.enableSubstitution(72 /* Identifier */); var currentSourceFile; return ts.chainBundle(transformSourceFile); @@ -80863,6 +81140,15 @@ var ts; return result.diagnostics; } ts.getDeclarationDiagnostics = getDeclarationDiagnostics; + function isInternalDeclaration(node, currentSourceFile) { + var parseTreeNode = ts.getParseTreeNode(node); + var leadingCommentRanges = parseTreeNode && ts.getLeadingCommentRangesOfNode(parseTreeNode, currentSourceFile); + return !!ts.forEach(leadingCommentRanges, function (range) { + var comment = currentSourceFile.text.substring(range.pos, range.end); + return ts.stringContains(comment, "@internal"); + }); + } + ts.isInternalDeclaration = isInternalDeclaration; var declarationEmitNodeBuilderFlags = 1024 /* MultilineObjectLiterals */ | 2048 /* WriteClassExpressionAsTypeLiteral */ | 4096 /* UseTypeOfFunction */ | @@ -80991,10 +81277,10 @@ var ts; } } function transformRoot(node) { - if (node.kind === 279 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJS(node))) { + if (node.kind === 284 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJS(node))) { return node; } - if (node.kind === 280 /* Bundle */) { + if (node.kind === 285 /* Bundle */) { isBundledEmit = true; refs = ts.createMap(); libs = ts.createMap(); @@ -81024,9 +81310,15 @@ var ts; var updated = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); return ts.updateSourceFileNode(sourceFile, transformAndReplaceLatePaintedStatements(updated), /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); }), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 282 /* InputFiles */) { - return ts.createUnparsedSourceFile(prepend, "dts"); + if (prepend.kind === 287 /* InputFiles */) { + var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal); + hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib; + collectReferences(sourceFile, refs); + recordTypeReferenceDirectivesIfNecessary(sourceFile.typeReferenceDirectives); + collectLibs(sourceFile, libs); + return sourceFile; } + return prepend; })); bundle.syntheticFileReferences = []; bundle.syntheticTypeReferences = getFileReferencesForUsedTypeReferences(); @@ -81118,7 +81410,7 @@ var ts; } } function collectReferences(sourceFile, ret) { - if (noResolve || ts.isSourceFileJS(sourceFile)) + if (noResolve || (!ts.isUnparsedSource(sourceFile) && ts.isSourceFileJS(sourceFile))) return ret; ts.forEach(sourceFile.referencedFiles, function (f) { var elem = ts.tryResolveScriptReference(host, sourceFile, f); @@ -81846,18 +82138,8 @@ var ts; } errorNameNode = undefined; } - function hasInternalAnnotation(range) { - var comment = currentSourceFile.text.substring(range.pos, range.end); - return ts.stringContains(comment, "@internal"); - } function shouldStripInternal(node) { - if (stripInternal && node) { - var leadingCommentRanges = ts.getLeadingCommentRangesOfNode(ts.getParseTreeNode(node), currentSourceFile); - if (ts.forEach(leadingCommentRanges, hasInternalAnnotation)) { - return true; - } - } - return false; + return !!stripInternal && !!node && isInternalDeclaration(node, currentSourceFile); } function isScopeMarker(node) { return ts.isExportAssignment(node) || ts.isExportDeclaration(node); @@ -81879,7 +82161,7 @@ var ts; function ensureModifierFlags(node, privateDeclaration) { var mask = 3071 /* All */ ^ (4 /* Public */ | 256 /* Async */); // No async modifiers in declaration files var additions = (needsDeclare && !isAlwaysType(node)) ? 2 /* Ambient */ : 0 /* None */; - var parentIsFile = node.parent.kind === 279 /* SourceFile */; + var parentIsFile = node.parent.kind === 284 /* SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= ((privateDeclaration || (isBundledEmit && parentIsFile) || hasScopeMarker(node.parent) ? 0 : 1 /* Export */) | 2 /* Ambient */); additions = 0 /* None */; @@ -82096,7 +82378,7 @@ var ts; * @param allowDtsFiles A value indicating whether to allow the transformation of .d.ts files. */ function transformNodes(resolver, host, options, nodes, transformers, allowDtsFiles) { - var enabledSyntaxKindFeatures = new Array(312 /* Count */); + var enabledSyntaxKindFeatures = new Array(317 /* Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentVariableDeclarationsStack = []; @@ -82356,10 +82638,14 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - var infoExtension = ".tsbundleinfo"; var brackets = createBracketsMap(); var syntheticParent = { pos: -1, end: -1 }; /*@internal*/ + function isBuildInfoFile(file) { + return ts.fileExtensionIs(file, ".tsbuildinfo" /* TsBuildInfo */); + } + ts.isBuildInfoFile = isBuildInfoFile; + /*@internal*/ /** * Iterates over the source files that are expected to have an emit output. * @@ -82369,13 +82655,14 @@ var ts; * If an array, the full list of source files to emit. * Else, calls `getSourceFilesToEmit` with the (optional) target source file to determine the list of source files to emit. */ - function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, emitOnlyDtsFiles) { + function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, emitOnlyDtsFiles, onlyBuildInfo, includeBuildInfo) { if (emitOnlyDtsFiles === void 0) { emitOnlyDtsFiles = false; } var sourceFiles = ts.isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : ts.getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile); var options = host.getCompilerOptions(); if (options.outFile || options.out) { - if (sourceFiles.length) { - var bundle = ts.createBundle(sourceFiles, host.getPrependNodes()); + var prepends = host.getPrependNodes(); + if (sourceFiles.length || prepends.length) { + var bundle = ts.createBundle(sourceFiles, prepends); var result = action(getOutputPathsFor(bundle, host, emitOnlyDtsFiles), bundle); if (result) { return result; @@ -82383,31 +82670,61 @@ var ts; } } else { - for (var _a = 0, sourceFiles_1 = sourceFiles; _a < sourceFiles_1.length; _a++) { - var sourceFile = sourceFiles_1[_a]; - var result = action(getOutputPathsFor(sourceFile, host, emitOnlyDtsFiles), sourceFile); - if (result) { - return result; + if (!onlyBuildInfo) { + for (var _a = 0, sourceFiles_1 = sourceFiles; _a < sourceFiles_1.length; _a++) { + var sourceFile = sourceFiles_1[_a]; + var result = action(getOutputPathsFor(sourceFile, host, emitOnlyDtsFiles), sourceFile); + if (result) { + return result; + } } } + if (includeBuildInfo) { + var buildInfoPath = getOutputPathForBuildInfo(host.getCompilerOptions()); + if (buildInfoPath) + return action({ buildInfoPath: buildInfoPath }, /*sourceFileOrBundle*/ undefined); + } } } ts.forEachEmittedFile = forEachEmittedFile; /*@internal*/ + function getOutputPathForBuildInfo(options) { + var configFile = options.configFilePath; + if (!configFile || !ts.isIncrementalCompilation(options)) + return undefined; + if (options.tsBuildInfoFile) + return options.tsBuildInfoFile; + var outPath = options.outFile || options.out; + var buildInfoExtensionLess; + if (outPath) { + buildInfoExtensionLess = ts.removeFileExtension(outPath); + } + else { + var configFileExtensionLess = ts.removeFileExtension(configFile); + buildInfoExtensionLess = options.outDir ? + options.rootDir ? + ts.resolvePath(options.outDir, ts.getRelativePathFromDirectory(options.rootDir, configFileExtensionLess, /*ignoreCase*/ true)) : + ts.combinePaths(options.outDir, ts.getBaseFileName(configFileExtensionLess)) : + configFileExtensionLess; + } + return buildInfoExtensionLess + ".tsbuildinfo" /* TsBuildInfo */; + } + ts.getOutputPathForBuildInfo = getOutputPathForBuildInfo; + /*@internal*/ function getOutputPathsForBundle(options, forceDtsPaths) { var outPath = options.outFile || options.out; var jsFilePath = options.emitDeclarationOnly ? undefined : outPath; var sourceMapFilePath = jsFilePath && getSourceMapFilePath(jsFilePath, options); var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.removeFileExtension(outPath) + ".d.ts" /* Dts */ : undefined; var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; - var bundleInfoPath = options.references && jsFilePath ? (ts.removeFileExtension(jsFilePath) + infoExtension) : undefined; - return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, bundleInfoPath: bundleInfoPath }; + var buildInfoPath = getOutputPathForBuildInfo(options); + return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: buildInfoPath }; } ts.getOutputPathsForBundle = getOutputPathsForBundle; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 280 /* Bundle */) { + if (sourceFile.kind === 285 /* Bundle */) { return getOutputPathsForBundle(options, forceDtsPaths); } else { @@ -82421,19 +82738,13 @@ var ts; var isJs = ts.isSourceFileJS(sourceFile); var declarationFilePath = ((forceDtsPaths || ts.getEmitDeclarations(options)) && !isJs) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; - return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, bundleInfoPath: undefined }; + return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: undefined }; } } ts.getOutputPathsFor = getOutputPathsFor; function getSourceMapFilePath(jsFilePath, options) { return (options.sourceMap && !options.inlineSourceMap) ? jsFilePath + ".map" : undefined; } - function createDefaultBundleInfo() { - return { - originalOffset: -1, - totalLength: -1 - }; - } // JavaScript files are always LanguageVariant.JSX, as JSX syntax is allowed in .js files also. // So for JavaScript files, '.jsx' is only emitted if the input was '.jsx', and JsxEmit.Preserve. // For TypeScript, the only time to emit with a '.jsx' extension, is on JSX input, and JsxEmit.Preserve @@ -82458,7 +82769,7 @@ var ts; ts.getOutputExtension = getOutputExtension; /*@internal*/ // targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature - function emitFiles(resolver, host, targetSourceFile, emitOnlyDtsFiles, transformers, declarationTransformers) { + function emitFiles(resolver, host, targetSourceFile, emitOnlyDtsFiles, transformers, declarationTransformers, onlyBuildInfo) { var compilerOptions = host.getCompilerOptions(); var sourceMapDataList = (compilerOptions.sourceMap || compilerOptions.inlineSourceMap || ts.getAreDeclarationMapsEnabled(compilerOptions)) ? [] : undefined; var emittedFilesList = compilerOptions.listEmittedFiles ? [] : undefined; @@ -82466,12 +82777,12 @@ var ts; var newLine = ts.getNewLineCharacter(compilerOptions, function () { return host.getNewLine(); }); var writer = ts.createTextWriter(newLine); var _a = ts.performance.createTimer("printTime", "beforePrint", "afterPrint"), enter = _a.enter, exit = _a.exit; - var bundleInfo = createDefaultBundleInfo(); + var bundleBuildInfo; var emitSkipped = false; var exportedModulesFromDeclarationEmit; // Emit each output file enter(); - forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), emitOnlyDtsFiles); + forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), emitOnlyDtsFiles, onlyBuildInfo, !targetSourceFile); exit(); return { emitSkipped: emitSkipped, @@ -82481,9 +82792,16 @@ var ts; exportedModulesFromDeclarationEmit: exportedModulesFromDeclarationEmit }; function emitSourceFileOrBundle(_a, sourceFileOrBundle) { - var jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, bundleInfoPath = _a.bundleInfoPath; - emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, bundleInfoPath); + var jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath; + if (buildInfoPath && sourceFileOrBundle && ts.isBundle(sourceFileOrBundle)) { + bundleBuildInfo = { + commonSourceDirectory: host.getCommonSourceDirectory(), + sourceFiles: sourceFileOrBundle.sourceFiles.map(function (file) { return file.fileName; }) + }; + } + emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath); emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath); + emitBuildInfo(bundleBuildInfo, buildInfoPath); if (!emitSkipped && emittedFilesList) { if (!emitOnlyDtsFiles) { if (jsFilePath) { @@ -82492,8 +82810,8 @@ var ts; if (sourceMapFilePath) { emittedFilesList.push(sourceMapFilePath); } - if (bundleInfoPath) { - emittedFilesList.push(bundleInfoPath); + if (buildInfoPath) { + emittedFilesList.push(buildInfoPath); } } if (declarationFilePath) { @@ -82504,8 +82822,21 @@ var ts; } } } - function emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, bundleInfoPath) { - if (emitOnlyDtsFiles || !jsFilePath) { + function emitBuildInfo(bundle, buildInfoPath) { + // Write build information if applicable + if (!buildInfoPath || targetSourceFile || emitSkipped) + return; + var program = host.getProgramBuildInfo(); + if (!bundle && !program) + return; + if (host.isEmitBlocked(buildInfoPath) || compilerOptions.noEmit) { + emitSkipped = true; + return; + } + ts.writeFile(host, emitterDiagnostics, buildInfoPath, getBuildInfoText({ bundle: bundle, program: program }), /*writeByteOrderMark*/ false); + } + function emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath) { + if (!sourceFileOrBundle || emitOnlyDtsFiles || !jsFilePath) { return; } // Make sure not to write js file and source map file if any of them cannot be written @@ -82525,6 +82856,7 @@ var ts; inlineSourceMap: compilerOptions.inlineSourceMap, inlineSources: compilerOptions.inlineSources, extendedDiagnostics: compilerOptions.extendedDiagnostics, + writeBundleFileInfo: !!bundleBuildInfo }; // Create a printer to print the nodes var printer = createPrinter(printerOptions, { @@ -82535,12 +82867,14 @@ var ts; substituteNode: transform.substituteNode, }); ts.Debug.assert(transform.transformed.length === 1, "Should only see one output from the transform"); - printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform.transformed[0], bundleInfoPath, printer, compilerOptions); + printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform.transformed[0], printer, compilerOptions); // Clean up emit nodes on parse tree transform.dispose(); + if (bundleBuildInfo) + bundleBuildInfo.js = printer.bundleFileInfo; } function emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath) { - if (!(declarationFilePath && !ts.isInJSFile(sourceFileOrBundle))) { + if (!sourceFileOrBundle || !(declarationFilePath && !ts.isInJSFile(sourceFileOrBundle))) { return; } var sourceFiles = ts.isSourceFile(sourceFileOrBundle) ? [sourceFileOrBundle] : sourceFileOrBundle.sourceFiles; @@ -82569,6 +82903,8 @@ var ts; inlineSourceMap: compilerOptions.inlineSourceMap, extendedDiagnostics: compilerOptions.extendedDiagnostics, onlyPrintJsDocStyle: true, + writeBundleFileInfo: !!bundleBuildInfo, + recordInternalSection: !!bundleBuildInfo }; var declarationPrinter = createPrinter(printerOptions, { // resolver hooks @@ -82581,18 +82917,20 @@ var ts; emitSkipped = emitSkipped || declBlocked; if (!declBlocked || emitOnlyDtsFiles) { ts.Debug.assert(declarationTransform.transformed.length === 1, "Should only see one output from the decl transform"); - printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], /* bundleInfopath*/ undefined, declarationPrinter, { + printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], declarationPrinter, { sourceMap: compilerOptions.declarationMap, sourceRoot: compilerOptions.sourceRoot, mapRoot: compilerOptions.mapRoot, extendedDiagnostics: compilerOptions.extendedDiagnostics, }); - if (emitOnlyDtsFiles && declarationTransform.transformed[0].kind === 279 /* SourceFile */) { + if (emitOnlyDtsFiles && declarationTransform.transformed[0].kind === 284 /* SourceFile */) { var sourceFile = declarationTransform.transformed[0]; exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit; } } declarationTransform.dispose(); + if (bundleBuildInfo) + bundleBuildInfo.dts = declarationPrinter.bundleFileInfo; } function collectLinkedAliases(node) { if (ts.isExportAssignment(node)) { @@ -82607,16 +82945,16 @@ var ts; } ts.forEachChild(node, collectLinkedAliases); } - function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, bundleInfoPath, printer, mapOptions) { - var bundle = sourceFileOrBundle.kind === 280 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 279 /* SourceFile */ ? sourceFileOrBundle : undefined; + function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) { + var bundle = sourceFileOrBundle.kind === 285 /* Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 284 /* SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; var sourceMapGenerator; if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) { sourceMapGenerator = ts.createSourceMapGenerator(host, ts.getBaseFileName(ts.normalizeSlashes(jsFilePath)), getSourceRoot(mapOptions), getSourceMapDirectory(mapOptions, jsFilePath, sourceFile), mapOptions); } if (bundle) { - printer.writeBundle(bundle, bundleInfo, writer, sourceMapGenerator); + printer.writeBundle(bundle, writer, sourceMapGenerator); } else { printer.writeFile(sourceFile, writer, sourceMapGenerator); @@ -82645,18 +82983,12 @@ var ts; } // Write the output file ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles); - // Write bundled offset information if applicable - if (bundleInfoPath) { - bundleInfo.totalLength = writer.getTextPos(); - ts.writeFile(host, emitterDiagnostics, bundleInfoPath, JSON.stringify(bundleInfo, undefined, 2), /*writeByteOrderMark*/ false); - } // Reset state writer.clear(); - bundleInfo = createDefaultBundleInfo(); } function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) { return (mapOptions.sourceMap || mapOptions.inlineSourceMap) - && (sourceFileOrBundle.kind !== 279 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); + && (sourceFileOrBundle.kind !== 284 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); } function getSourceRoot(mapOptions) { // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the @@ -82713,6 +83045,161 @@ var ts; } } ts.emitFiles = emitFiles; + /*@internal*/ + function getBuildInfoText(buildInfo) { + return JSON.stringify(buildInfo, undefined, 2); + } + ts.getBuildInfoText = getBuildInfoText; + /*@internal*/ + ts.notImplementedResolver = { + hasGlobalName: ts.notImplemented, + getReferencedExportContainer: ts.notImplemented, + getReferencedImportDeclaration: ts.notImplemented, + getReferencedDeclarationWithCollidingName: ts.notImplemented, + isDeclarationWithCollidingName: ts.notImplemented, + isValueAliasDeclaration: ts.notImplemented, + isReferencedAliasDeclaration: ts.notImplemented, + isTopLevelValueImportEqualsWithEntityName: ts.notImplemented, + getNodeCheckFlags: ts.notImplemented, + isDeclarationVisible: ts.notImplemented, + isLateBound: function (_node) { return false; }, + collectLinkedAliases: ts.notImplemented, + isImplementationOfOverload: ts.notImplemented, + isRequiredInitializedParameter: ts.notImplemented, + isOptionalUninitializedParameterProperty: ts.notImplemented, + isExpandoFunctionDeclaration: ts.notImplemented, + getPropertiesOfContainerFunction: ts.notImplemented, + createTypeOfDeclaration: ts.notImplemented, + createReturnTypeOfSignatureDeclaration: ts.notImplemented, + createTypeOfExpression: ts.notImplemented, + createLiteralConstValue: ts.notImplemented, + isSymbolAccessible: ts.notImplemented, + isEntityNameVisible: ts.notImplemented, + // Returns the constant value this property access resolves to: notImplemented, or 'undefined' for a non-constant + getConstantValue: ts.notImplemented, + getReferencedValueDeclaration: ts.notImplemented, + getTypeReferenceSerializationKind: ts.notImplemented, + isOptionalParameter: ts.notImplemented, + moduleExportsSomeValue: ts.notImplemented, + isArgumentsLocalBinding: ts.notImplemented, + getExternalModuleFileFromDeclaration: ts.notImplemented, + getTypeReferenceDirectivesForEntityName: ts.notImplemented, + getTypeReferenceDirectivesForSymbol: ts.notImplemented, + isLiteralConstDeclaration: ts.notImplemented, + getJsxFactoryEntity: ts.notImplemented, + getAllAccessorDeclarations: ts.notImplemented, + getSymbolOfExternalModuleSpecifier: ts.notImplemented, + isBindingCapturedByNode: ts.notImplemented, + }; + function createSourceFilesFromBundleBuildInfo(bundle) { + var sourceFiles = bundle.sourceFiles.map(function (fileName) { + var sourceFile = ts.createNode(284 /* SourceFile */, 0, 0); + sourceFile.fileName = fileName; + sourceFile.text = ""; + sourceFile.statements = ts.createNodeArray(); + return sourceFile; + }); + var jsBundle = ts.Debug.assertDefined(bundle.js); + ts.forEach(jsBundle.sources && jsBundle.sources.prologues, function (prologueInfo) { + var sourceFile = sourceFiles[prologueInfo.file]; + sourceFile.text = prologueInfo.text; + sourceFile.end = prologueInfo.text.length; + sourceFile.statements = ts.createNodeArray(prologueInfo.directives.map(function (directive) { + var statement = ts.createNode(221 /* ExpressionStatement */, directive.pos, directive.end); + statement.expression = ts.createNode(10 /* StringLiteral */, directive.expression.pos, directive.expression.end); + statement.expression.text = directive.expression.text; + return statement; + })); + }); + return sourceFiles; + } + /*@internal*/ + function emitUsingBuildInfo(config, host, getCommandLine) { + var _a = getOutputPathsForBundle(config.options, /*forceDtsPaths*/ false), buildInfoPath = _a.buildInfoPath, jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath; + var buildInfoText = host.readFile(ts.Debug.assertDefined(buildInfoPath)); + if (!buildInfoText) + return buildInfoPath; + var jsFileText = host.readFile(ts.Debug.assertDefined(jsFilePath)); + if (!jsFileText) + return jsFilePath; + var sourceMapText = sourceMapFilePath && host.readFile(sourceMapFilePath); + // error if no source map or for now if inline sourcemap + if ((sourceMapFilePath && !sourceMapText) || config.options.inlineSourceMap) + return sourceMapFilePath || "inline sourcemap decoding"; + // read declaration text + var declarationText = declarationFilePath && host.readFile(declarationFilePath); + if (declarationFilePath && !declarationText) + return declarationFilePath; + var declarationMapText = declarationMapPath && host.readFile(declarationMapPath); + // error if no source map or for now if inline sourcemap + if ((declarationMapPath && !declarationMapText) || config.options.inlineSourceMap) + return declarationMapPath || "inline sourcemap decoding"; + var buildInfo = JSON.parse(buildInfoText); + if (!buildInfo.bundle || !buildInfo.bundle.js || (declarationText && !buildInfo.bundle.dts)) + return buildInfoPath; + var ownPrependInput = ts.createInputFiles(jsFileText, declarationText, sourceMapFilePath, sourceMapText, declarationMapPath, declarationMapText, jsFilePath, declarationFilePath, buildInfoPath, buildInfo, + /*onlyOwnText*/ true); + var outputFiles = []; + var prependNodes = ts.createPrependNodes(config.projectReferences, getCommandLine, function (f) { return host.readFile(f); }); + var sourceFilesForJsEmit = createSourceFilesFromBundleBuildInfo(buildInfo.bundle); + var emitHost = { + getPrependNodes: ts.memoize(function () { return prependNodes.concat([ownPrependInput]); }), + getCanonicalFileName: host.getCanonicalFileName, + getCommonSourceDirectory: function () { return buildInfo.bundle.commonSourceDirectory; }, + getCompilerOptions: function () { return config.options; }, + getCurrentDirectory: function () { return host.getCurrentDirectory(); }, + getNewLine: function () { return host.getNewLine(); }, + getSourceFile: function () { return undefined; }, + getSourceFileByPath: function () { return undefined; }, + getSourceFiles: function () { return sourceFilesForJsEmit; }, + getLibFileFromReference: ts.notImplemented, + isSourceFileFromExternalLibrary: ts.returnFalse, + writeFile: function (name, text, writeByteOrderMark) { + switch (name) { + case jsFilePath: + if (jsFileText === text) + return; + break; + case sourceMapFilePath: + if (sourceMapText === text) + return; + break; + case buildInfoPath: + var newBuildInfo = JSON.parse(text); + newBuildInfo.program = buildInfo.program; + // Update sourceFileInfo + var _a = buildInfo.bundle, js = _a.js, dts = _a.dts, sourceFiles = _a.sourceFiles; + newBuildInfo.bundle.js.sources = js.sources; + if (dts) { + newBuildInfo.bundle.dts.sources = dts.sources; + } + newBuildInfo.bundle.sourceFiles = sourceFiles; + outputFiles.push({ name: name, text: getBuildInfoText(newBuildInfo), writeByteOrderMark: writeByteOrderMark }); + return; + case declarationFilePath: + if (declarationText === text) + return; + break; + case declarationMapPath: + if (declarationMapText === text) + return; + break; + default: + ts.Debug.assertNever(name); + } + outputFiles.push({ name: name, text: text, writeByteOrderMark: writeByteOrderMark }); + }, + isEmitBlocked: ts.returnFalse, + readFile: function (f) { return host.readFile(f); }, + fileExists: function (f) { return host.fileExists(f); }, + directoryExists: host.directoryExists && (function (f) { return host.directoryExists(f); }), + useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, + getProgramBuildInfo: function () { return undefined; } + }; + emitFiles(ts.notImplementedResolver, emitHost, /*targetSourceFile*/ undefined, /*emitOnlyDtsFiles*/ false, ts.getTransformers(config.options)); + return outputFiles; + } + ts.emitUsingBuildInfo = emitUsingBuildInfo; var PipelinePhase; (function (PipelinePhase) { PipelinePhase[PipelinePhase["Notification"] = 0] = "Notification"; @@ -82741,6 +83228,10 @@ var ts; var ownWriter; // Reusable `EmitTextWriter` for basic printing. var write = writeBase; var isOwnFileEmit; + var bundleFileInfo = printerOptions.writeBundleFileInfo ? { sections: [] } : undefined; + var recordInternalSection = printerOptions.recordInternalSection; + var sourceFileTextPos = 0; + var sourceFileTextKind = "text" /* Text */; // Source Maps var sourceMapsDisabled = true; var sourceMapGenerator; @@ -82766,7 +83257,8 @@ var ts; writeNode: writeNode, writeList: writeList, writeFile: writeFile, - writeBundle: writeBundle + writeBundle: writeBundle, + bundleFileInfo: bundleFileInfo }; function printNode(hint, node, sourceFile) { switch (hint) { @@ -82781,9 +83273,9 @@ var ts; break; } switch (node.kind) { - case 279 /* SourceFile */: return printFile(node); - case 280 /* Bundle */: return printBundle(node); - case 281 /* UnparsedSource */: return printUnparsedSource(node); + case 284 /* SourceFile */: return printFile(node); + case 285 /* Bundle */: return printBundle(node); + case 286 /* UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -82793,7 +83285,7 @@ var ts; return endPrint(); } function printBundle(bundle) { - writeBundle(bundle, /*bundleInfo*/ undefined, beginPrint(), /*sourceMapEmitter*/ undefined); + writeBundle(bundle, beginPrint(), /*sourceMapEmitter*/ undefined); return endPrint(); } function printFile(sourceFile) { @@ -82821,7 +83313,49 @@ var ts; reset(); writer = previousWriter; } - function writeBundle(bundle, bundleInfo, output, sourceMapGenerator) { + function getTextPosWithWriteLine() { + return writer.getTextPosWithWriteLine ? writer.getTextPosWithWriteLine() : writer.getTextPos(); + } + function updateOrPushBundleFileTextLike(pos, end, kind) { + var last = ts.lastOrUndefined(bundleFileInfo.sections); + if (last && last.kind === kind) { + last.end = end; + } + else { + bundleFileInfo.sections.push({ pos: pos, end: end, kind: kind }); + } + } + function recordBundleFileInternalSectionStart(node) { + if (recordInternalSection && + bundleFileInfo && + currentSourceFile && + (ts.isDeclaration(node) || ts.isVariableStatement(node)) && + ts.isInternalDeclaration(node, currentSourceFile) && + sourceFileTextKind !== "internal" /* Internal */) { + var prevSourceFileTextKind = sourceFileTextKind; + recordBundleFileTextLikeSection(writer.getTextPos()); + sourceFileTextPos = getTextPosWithWriteLine(); + sourceFileTextKind = "internal" /* Internal */; + return prevSourceFileTextKind; + } + return undefined; + } + function recordBundleFileInternalSectionEnd(prevSourceFileTextKind) { + if (prevSourceFileTextKind) { + recordBundleFileTextLikeSection(writer.getTextPos()); + sourceFileTextPos = getTextPosWithWriteLine(); + sourceFileTextKind = prevSourceFileTextKind; + } + } + function recordBundleFileTextLikeSection(end) { + if (sourceFileTextPos < end) { + updateOrPushBundleFileTextLike(sourceFileTextPos, end, sourceFileTextKind); + return true; + } + return false; + } + function writeBundle(bundle, output, sourceMapGenerator) { + var _a; isOwnFileEmit = false; var previousWriter = writer; setWriter(output, sourceMapGenerator); @@ -82829,18 +83363,49 @@ var ts; emitPrologueDirectivesIfNeeded(bundle); emitHelpers(bundle); emitSyntheticTripleSlashReferencesIfNeeded(bundle); - for (var _a = 0, _b = bundle.prepends; _a < _b.length; _a++) { - var prepend = _b[_a]; + for (var _b = 0, _c = bundle.prepends; _b < _c.length; _b++) { + var prepend = _c[_b]; writeLine(); + var pos = writer.getTextPos(); + var savedSections = bundleFileInfo && bundleFileInfo.sections; + if (savedSections) + bundleFileInfo.sections = []; print(4 /* Unspecified */, prepend, /*sourceFile*/ undefined); + if (bundleFileInfo) { + var newSections = bundleFileInfo.sections; + bundleFileInfo.sections = savedSections; + if (prepend.oldFileOfCurrentEmit) + (_a = bundleFileInfo.sections).push.apply(_a, newSections); + else { + newSections.forEach(function (section) { return ts.Debug.assert(ts.isBundleFileTextLike(section)); }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prepend" /* Prepend */, data: prepend.fileName, texts: newSections }); + } + } } - if (bundleInfo) { - bundleInfo.originalOffset = writer.getTextPos(); - } - for (var _c = 0, _d = bundle.sourceFiles; _c < _d.length; _c++) { - var sourceFile = _d[_c]; + sourceFileTextPos = getTextPosWithWriteLine(); + for (var _d = 0, _e = bundle.sourceFiles; _d < _e.length; _d++) { + var sourceFile = _e[_d]; print(0 /* SourceFile */, sourceFile, sourceFile); } + if (bundleFileInfo && bundle.sourceFiles.length) { + var end = writer.getTextPos(); + if (recordBundleFileTextLikeSection(end)) { + // Store prologues + var prologues = getPrologueDirectivesFromBundledSourceFiles(bundle); + if (prologues) { + if (!bundleFileInfo.sources) + bundleFileInfo.sources = {}; + bundleFileInfo.sources.prologues = prologues; + } + // Store helpes + var helpers = getHelpersFromBundledSourceFiles(bundle); + if (helpers) { + if (!bundleFileInfo.sources) + bundleFileInfo.sources = {}; + bundleFileInfo.sources.helpers = helpers; + } + } + } reset(); writer = previousWriter; } @@ -82910,8 +83475,10 @@ var ts; function emit(node) { if (node === undefined) return; + var prevSourceFileTextKind = recordBundleFileInternalSectionStart(node); var pipelinePhase = getPipelinePhase(0 /* Notification */, node); pipelinePhase(4 /* Unspecified */, node); + recordBundleFileInternalSectionEnd(prevSourceFileTextKind); } function emitIdentifierName(node) { if (node === undefined) @@ -82938,12 +83505,12 @@ var ts; } // falls through case 2 /* Comments */: - if (!commentsDisabled && node.kind !== 279 /* SourceFile */) { + if (!commentsDisabled && node.kind !== 284 /* SourceFile */) { return pipelineEmitWithComments; } // falls through case 3 /* SourceMaps */: - if (!sourceMapsDisabled && node.kind !== 279 /* SourceFile */ && !ts.isInJsonFile(node)) { + if (!sourceMapsDisabled && node.kind !== 284 /* SourceFile */ && !ts.isInJsonFile(node)) { return pipelineEmitWithSourceMap; } // falls through @@ -82980,8 +83547,16 @@ var ts; case 16 /* TemplateMiddle */: case 17 /* TemplateTail */: return emitLiteral(node); - case 281 /* UnparsedSource */: - return emitUnparsedSource(node); + case 286 /* UnparsedSource */: + case 280 /* UnparsedPrepend */: + return emitUnparsedSourceOrPrepend(node); + case 279 /* UnparsedPrologue */: + return writeUnparsedNode(node); + case 281 /* UnparsedText */: + case 282 /* UnparsedInternalText */: + return emitUnparsedTextLike(node); + case 283 /* UnparsedSyntheticReference */: + return emitUnparsedSyntheticReference(node); // Identifiers case 72 /* Identifier */: return emitIdentifier(node); @@ -83025,7 +83600,7 @@ var ts; return emitTypeReference(node); case 165 /* FunctionType */: return emitFunctionType(node); - case 289 /* JSDocFunctionType */: + case 294 /* JSDocFunctionType */: return emitJSDocFunctionType(node); case 166 /* ConstructorType */: return emitConstructorType(node); @@ -83063,20 +83638,20 @@ var ts; return emitLiteralType(node); case 183 /* ImportType */: return emitImportTypeNode(node); - case 284 /* JSDocAllType */: + case 289 /* JSDocAllType */: writePunctuation("*"); return; - case 285 /* JSDocUnknownType */: + case 290 /* JSDocUnknownType */: writePunctuation("?"); return; - case 286 /* JSDocNullableType */: + case 291 /* JSDocNullableType */: return emitJSDocNullableType(node); - case 287 /* JSDocNonNullableType */: + case 292 /* JSDocNonNullableType */: return emitJSDocNonNullableType(node); - case 288 /* JSDocOptionalType */: + case 293 /* JSDocOptionalType */: return emitJSDocOptionalType(node); case 172 /* RestType */: - case 290 /* JSDocVariadicType */: + case 295 /* JSDocVariadicType */: return emitRestOrJSDocVariadicType(node); // Binding patterns case 184 /* ObjectBindingPattern */: @@ -83214,30 +83789,30 @@ var ts; case 278 /* EnumMember */: return emitEnumMember(node); // JSDoc nodes (only used in codefixes currently) - case 299 /* JSDocParameterTag */: - case 305 /* JSDocPropertyTag */: + case 304 /* JSDocParameterTag */: + case 310 /* JSDocPropertyTag */: return emitJSDocPropertyLikeTag(node); - case 300 /* JSDocReturnTag */: - case 302 /* JSDocTypeTag */: - case 301 /* JSDocThisTag */: - case 298 /* JSDocEnumTag */: + case 305 /* JSDocReturnTag */: + case 307 /* JSDocTypeTag */: + case 306 /* JSDocThisTag */: + case 303 /* JSDocEnumTag */: return emitJSDocSimpleTypedTag(node); - case 295 /* JSDocAugmentsTag */: + case 300 /* JSDocAugmentsTag */: return emitJSDocAugmentsTag(node); - case 303 /* JSDocTemplateTag */: + case 308 /* JSDocTemplateTag */: return emitJSDocTemplateTag(node); - case 304 /* JSDocTypedefTag */: + case 309 /* JSDocTypedefTag */: return emitJSDocTypedefTag(node); - case 297 /* JSDocCallbackTag */: + case 302 /* JSDocCallbackTag */: return emitJSDocCallbackTag(node); - case 293 /* JSDocSignature */: + case 298 /* JSDocSignature */: return emitJSDocSignature(node); - case 292 /* JSDocTypeLiteral */: + case 297 /* JSDocTypeLiteral */: return emitJSDocTypeLiteral(node); - case 296 /* JSDocClassTag */: - case 294 /* JSDocTag */: + case 301 /* JSDocClassTag */: + case 299 /* JSDocTag */: return emitJSDocSimpleTag(node); - case 291 /* JSDocComment */: + case 296 /* JSDocComment */: return emitJSDoc(node); // Transformation nodes (ignored) } @@ -83336,9 +83911,9 @@ var ts; case 264 /* JsxFragment */: return emitJsxFragment(node); // Transformation nodes - case 308 /* PartiallyEmittedExpression */: + case 313 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 309 /* CommaListExpression */: + case 314 /* CommaListExpression */: return emitCommaList(node); } } @@ -83354,22 +83929,45 @@ var ts; var pipelinePhase = getNextPipelinePhase(1 /* Substitution */, node); pipelinePhase(hint, substituteNode(hint, node)); } + function getHelpersFromBundledSourceFiles(bundle) { + var result; + if (moduleKind === ts.ModuleKind.None || printerOptions.noEmitHelpers) { + return undefined; + } + var bundledHelpers = ts.createMap(); + for (var _a = 0, _b = bundle.sourceFiles; _a < _b.length; _a++) { + var sourceFile = _b[_a]; + var shouldSkip = ts.getExternalHelpersModuleName(sourceFile) !== undefined; + var helpers = getSortedEmitHelpers(sourceFile); + if (!helpers) + continue; + for (var _c = 0, helpers_3 = helpers; _c < helpers_3.length; _c++) { + var helper = helpers_3[_c]; + if (!helper.scoped && !shouldSkip && !bundledHelpers.get(helper.name)) { + bundledHelpers.set(helper.name, true); + (result || (result = [])).push(helper.name); + } + } + } + return result; + } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 280 /* Bundle */ ? node : undefined; + var bundle = node.kind === 285 /* Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } - var numNodes = bundle ? bundle.sourceFiles.length : 1; + var numPrepends = bundle ? bundle.prepends.length : 0; + var numNodes = bundle ? bundle.sourceFiles.length + numPrepends : 1; for (var i = 0; i < numNodes; i++) { - var currentNode = bundle ? bundle.sourceFiles[i] : node; - var sourceFile = ts.isSourceFile(currentNode) ? currentNode : currentSourceFile; - var shouldSkip = printerOptions.noEmitHelpers || ts.getExternalHelpersModuleName(sourceFile) !== undefined; - var shouldBundle = ts.isSourceFile(currentNode) && !isOwnFileEmit; - var helpers = ts.getEmitHelpers(currentNode); + var currentNode = bundle ? i < numPrepends ? bundle.prepends[i] : bundle.sourceFiles[i - numPrepends] : node; + var sourceFile = ts.isSourceFile(currentNode) ? currentNode : ts.isUnparsedSource(currentNode) ? undefined : currentSourceFile; + var shouldSkip = printerOptions.noEmitHelpers || (!!sourceFile && ts.getExternalHelpersModuleName(sourceFile) !== undefined); + var shouldBundle = (ts.isSourceFile(currentNode) || ts.isUnparsedSource(currentNode)) && !isOwnFileEmit; + var helpers = ts.isUnparsedSource(currentNode) ? currentNode.helpers : getSortedEmitHelpers(currentNode); if (helpers) { - for (var _a = 0, _b = ts.stableSort(helpers, ts.compareEmitHelpers); _a < _b.length; _a++) { - var helper = _b[_a]; + for (var _a = 0, helpers_4 = helpers; _a < helpers_4.length; _a++) { + var helper = helpers_4[_a]; if (!helper.scoped) { // Skip the helper if it can be skipped and the noEmitHelpers compiler // option is set, or if it can be imported and the importHelpers compiler @@ -83389,18 +83987,25 @@ var ts; // Skip the helper if it is scoped and we are emitting bundled helpers continue; } + var pos = getTextPosWithWriteLine(); if (typeof helper.text === "string") { writeLines(helper.text); } else { writeLines(helper.text(makeFileLevelOptimisticUniqueName)); } + if (bundleFileInfo) + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "emitHelpers" /* EmitHelpers */, data: helper.name }); helpersEmitted = true; } } } return helpersEmitted; } + function getSortedEmitHelpers(node) { + var helpers = ts.getEmitHelpers(node); + return helpers && ts.stableSort(helpers, ts.compareEmitHelpers); + } // // Literals/Pseudo-literals // @@ -83427,8 +84032,42 @@ var ts; } } // SyntaxKind.UnparsedSource - function emitUnparsedSource(unparsed) { - writer.rawWrite(unparsed.text); + // SyntaxKind.UnparsedPrepend + function emitUnparsedSourceOrPrepend(unparsed) { + for (var _a = 0, _b = unparsed.texts; _a < _b.length; _a++) { + var text = _b[_a]; + writeLine(); + emit(text); + } + } + // SyntaxKind.UnparsedPrologue + // SyntaxKind.UnparsedText + // SyntaxKind.UnparsedInternal + // SyntaxKind.UnparsedSyntheticReference + function writeUnparsedNode(unparsed) { + writer.rawWrite(unparsed.parent.text.substring(unparsed.pos, unparsed.end)); + } + // SyntaxKind.UnparsedText + // SyntaxKind.UnparsedInternal + function emitUnparsedTextLike(unparsed) { + var pos = getTextPosWithWriteLine(); + writeUnparsedNode(unparsed); + if (bundleFileInfo) { + updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 281 /* UnparsedText */ ? + "text" /* Text */ : + "internal" /* Internal */); + } + } + // SyntaxKind.UnparsedSyntheticReference + function emitUnparsedSyntheticReference(unparsed) { + var pos = getTextPosWithWriteLine(); + writeUnparsedNode(unparsed); + if (bundleFileInfo) { + var section = ts.clone(unparsed.section); + section.pos = pos; + section.end = writer.getTextPos(); + bundleFileInfo.sections.push(section); + } } // // Identifiers @@ -83483,7 +84122,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 289 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 294 /* JSDocFunctionType */ && !node.name) { emit(node.type); } else { @@ -84363,7 +85002,7 @@ var ts; } function emitBlockFunctionBodyWorker(body, emitBlockFunctionBodyOnSingleLine) { // Emit all the prologue directives (like "use strict"). - var statementOffset = emitPrologueDirectives(body.statements, /*startWithNewLine*/ true); + var statementOffset = emitPrologueDirectives(body.statements); var pos = writer.getTextPos(); emitHelpers(body); if (statementOffset === 0 && pos === writer.getTextPos() && emitBlockFunctionBodyOnSingleLine) { @@ -84768,7 +85407,7 @@ var ts; } } if (node.tags) { - if (node.tags.length === 1 && node.tags[0].kind === 302 /* JSDocTypeTag */ && !node.comment) { + if (node.tags.length === 1 && node.tags[0].kind === 307 /* JSDocTypeTag */ && !node.comment) { writeSpace(); emit(node.tags[0]); } @@ -84802,7 +85441,7 @@ var ts; function emitJSDocTypedefTag(tag) { emitJSDocTagName(tag.tagName); if (tag.typeExpression) { - if (tag.typeExpression.kind === 283 /* JSDocTypeExpression */) { + if (tag.typeExpression.kind === 288 /* JSDocTypeExpression */) { emitJSDocTypeExpression(tag.typeExpression); } else { @@ -84821,7 +85460,7 @@ var ts; emit(tag.fullName); } emitJSDocComment(tag.comment); - if (tag.typeExpression && tag.typeExpression.kind === 292 /* JSDocTypeLiteral */) { + if (tag.typeExpression && tag.typeExpression.kind === 297 /* JSDocTypeLiteral */) { emitJSDocTypeLiteral(tag.typeExpression); } } @@ -84908,6 +85547,16 @@ var ts; } function emitSyntheticTripleSlashReferencesIfNeeded(node) { emitTripleSlashDirectives(!!node.hasNoDefaultLib, node.syntheticFileReferences || [], node.syntheticTypeReferences || [], node.syntheticLibReferences || []); + for (var _a = 0, _b = node.prepends; _a < _b.length; _a++) { + var prepend = _b[_a]; + if (ts.isUnparsedSource(prepend) && prepend.syntheticReferences) { + for (var _c = 0, _d = prepend.syntheticReferences; _c < _d.length; _c++) { + var ref = _d[_c]; + emit(ref); + writeLine(); + } + } + } } function emitTripleSlashDirectivesIfNeeded(node) { if (node.isDeclarationFile) @@ -84915,7 +85564,10 @@ var ts; } function emitTripleSlashDirectives(hasNoDefaultLib, files, types, libs) { if (hasNoDefaultLib) { + var pos = writer.getTextPos(); writeComment("/// "); + if (bundleFileInfo) + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "no-default-lib" /* NoDefaultLib */ }); writeLine(); } if (currentSourceFile && currentSourceFile.moduleName) { @@ -84936,17 +85588,26 @@ var ts; } for (var _c = 0, files_1 = files; _c < files_1.length; _c++) { var directive = files_1[_c]; + var pos = writer.getTextPos(); writeComment("/// "); + if (bundleFileInfo) + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference" /* Reference */, data: directive.fileName }); writeLine(); } for (var _d = 0, types_19 = types; _d < types_19.length; _d++) { var directive = types_19[_d]; + var pos = writer.getTextPos(); writeComment("/// "); + if (bundleFileInfo) + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "type" /* Type */, data: directive.fileName }); writeLine(); } for (var _e = 0, libs_1 = libs; _e < libs_1.length; _e++) { var directive = libs_1[_e]; + var pos = writer.getTextPos(); writeComment("/// "); + if (bundleFileInfo) + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "lib" /* Lib */, data: directive.fileName }); writeLine(); } } @@ -84971,16 +85632,22 @@ var ts; * Emits any prologue directives at the start of a Statement list, returning the * number of prologue directives written to the output. */ - function emitPrologueDirectives(statements, startWithNewLine, seenPrologueDirectives) { + function emitPrologueDirectives(statements, sourceFile, seenPrologueDirectives) { + var needsToSetSourceFile = !!sourceFile; for (var i = 0; i < statements.length; i++) { var statement = statements[i]; if (ts.isPrologueDirective(statement)) { var shouldEmitPrologueDirective = seenPrologueDirectives ? !seenPrologueDirectives.has(statement.expression.text) : true; if (shouldEmitPrologueDirective) { - if (startWithNewLine || i > 0) { - writeLine(); + if (needsToSetSourceFile) { + needsToSetSourceFile = false; + setSourceFile(sourceFile); } + writeLine(); + var pos = writer.getTextPos(); emit(statement); + if (bundleFileInfo) + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* Prologue */, data: statement.expression.text }); if (seenPrologueDirectives) { seenPrologueDirectives.set(statement.expression.text, true); } @@ -84993,23 +85660,70 @@ var ts; } return statements.length; } + function emitUnparsedPrologues(prologues, seenPrologueDirectives) { + for (var _a = 0, prologues_1 = prologues; _a < prologues_1.length; _a++) { + var prologue = prologues_1[_a]; + if (!seenPrologueDirectives.has(prologue.data)) { + writeLine(); + var pos = writer.getTextPos(); + emit(prologue); + if (bundleFileInfo) + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* Prologue */, data: prologue.data }); + if (seenPrologueDirectives) { + seenPrologueDirectives.set(prologue.data, true); + } + } + } + } function emitPrologueDirectivesIfNeeded(sourceFileOrBundle) { if (ts.isSourceFile(sourceFileOrBundle)) { - setSourceFile(sourceFileOrBundle); - emitPrologueDirectives(sourceFileOrBundle.statements); + emitPrologueDirectives(sourceFileOrBundle.statements, sourceFileOrBundle); } else { var seenPrologueDirectives = ts.createMap(); - for (var _a = 0, _b = sourceFileOrBundle.sourceFiles; _a < _b.length; _a++) { - var sourceFile = _b[_a]; - setSourceFile(sourceFile); - emitPrologueDirectives(sourceFile.statements, /*startWithNewLine*/ true, seenPrologueDirectives); + for (var _a = 0, _b = sourceFileOrBundle.prepends; _a < _b.length; _a++) { + var prepend = _b[_a]; + emitUnparsedPrologues(prepend.prologues, seenPrologueDirectives); + } + for (var _c = 0, _d = sourceFileOrBundle.sourceFiles; _c < _d.length; _c++) { + var sourceFile = _d[_c]; + emitPrologueDirectives(sourceFile.statements, sourceFile, seenPrologueDirectives); } setSourceFile(undefined); } } + function getPrologueDirectivesFromBundledSourceFiles(bundle) { + var seenPrologueDirectives = ts.createMap(); + var prologues; + for (var index = 0; index < bundle.sourceFiles.length; index++) { + var sourceFile = bundle.sourceFiles[index]; + var directives = void 0; + var end = 0; + for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { + var statement = _b[_a]; + if (!ts.isPrologueDirective(statement)) + break; + if (seenPrologueDirectives.has(statement.expression.text)) + continue; + seenPrologueDirectives.set(statement.expression.text, true); + (directives || (directives = [])).push({ + pos: statement.pos, + end: statement.end, + expression: { + pos: statement.expression.pos, + end: statement.expression.end, + text: statement.expression.text + } + }); + end = end < statement.end ? statement.end : end; + } + if (directives) + (prologues || (prologues = [])).push({ file: index, text: sourceFile.text.substring(0, end), directives: directives }); + } + return prologues; + } function emitShebangIfNeeded(sourceFileOrBundle) { - if (ts.isSourceFile(sourceFileOrBundle)) { + if (ts.isSourceFile(sourceFileOrBundle) || ts.isUnparsedSource(sourceFileOrBundle)) { var shebang = ts.getShebang(sourceFileOrBundle.text); if (shebang) { writeComment(shebang); @@ -85018,11 +85732,18 @@ var ts; } } else { - for (var _a = 0, _b = sourceFileOrBundle.sourceFiles; _a < _b.length; _a++) { - var sourceFile = _b[_a]; + for (var _a = 0, _b = sourceFileOrBundle.prepends; _a < _b.length; _a++) { + var prepend = _b[_a]; + ts.Debug.assertNode(prepend, ts.isUnparsedSource); + if (emitShebangIfNeeded(prepend)) { + return true; + } + } + for (var _c = 0, _d = sourceFileOrBundle.sourceFiles; _c < _d.length; _c++) { + var sourceFile = _d[_c]; // Emit only the first encountered shebang if (emitShebangIfNeeded(sourceFile)) { - break; + return true; } } } @@ -85225,6 +85946,7 @@ var ts; } // Emit each child. var previousSibling = void 0; + var previousSourceFileTextKind = void 0; var shouldDecreaseIndentAfterEmit = false; for (var i = 0; i < count; i++) { var child = children[start + i]; @@ -85245,6 +85967,7 @@ var ts; emitLeadingCommentsOfPosition(previousSibling.end); } writeDelimiter(format); + recordBundleFileInternalSectionEnd(previousSourceFileTextKind); // Write either a line terminator or whitespace to separate the elements. if (shouldWriteSeparatingLineTerminator(previousSibling, child, format)) { // If a synthesized node in a single-line list starts on a new @@ -85261,6 +85984,7 @@ var ts; } } // Emit this child. + previousSourceFileTextKind = recordBundleFileInternalSectionStart(child); if (shouldEmitInterveningComments) { if (emitTrailingCommentsOfPosition) { var commentRange = ts.getCommentRange(child); @@ -85295,6 +86019,7 @@ var ts; if (format & 128 /* Indented */) { decreaseIndent(); } + recordBundleFileInternalSectionEnd(previousSourceFileTextKind); // Write the closing line terminator or closing whitespace. if (shouldWriteClosingLineTerminator(parentNode, children, format)) { writeLine(); @@ -85396,7 +86121,6 @@ var ts; if (line.length) { writeLine(); write(line); - writer.rawWrite(newLine); } } } @@ -85910,7 +86634,7 @@ var ts; hasWrittenComment = false; var emitFlags = ts.getEmitFlags(node); var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end; - var isEmittedNode = node.kind !== 307 /* NotEmittedStatement */; + var isEmittedNode = node.kind !== 312 /* NotEmittedStatement */; // We have to explicitly check that the node is JsxText because if the compilerOptions.jsx is "preserve" we will not do any transformation. // It is expensive to walk entire tree just to set one kind of node to have no comments. var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0 || node.kind === 11 /* JsxText */; @@ -86170,19 +86894,28 @@ var ts; return ts.isRecognizedTripleSlashComment(currentSourceFile.text, commentPos, commentEnd); } // Source Maps + function getParsedSourceMap(node) { + if (node.parsedSourceMap === undefined && node.sourceMapText !== undefined) { + node.parsedSourceMap = ts.tryParseRawSourceMap(node.sourceMapText) || false; + } + return node.parsedSourceMap || undefined; + } function pipelineEmitWithSourceMap(hint, node) { var pipelinePhase = getNextPipelinePhase(3 /* SourceMaps */, node); - if (ts.isUnparsedSource(node) && node.sourceMapText !== undefined) { - var parsed = ts.tryParseRawSourceMap(node.sourceMapText); - if (parsed) { - sourceMapGenerator.appendSourceMap(writer.getLine(), writer.getColumn(), parsed, node.sourceMapPath); + if (ts.isUnparsedSource(node) || ts.isUnparsedPrepend(node)) { + pipelinePhase(hint, node); + } + else if (ts.isUnparsedNode(node)) { + var parsed = getParsedSourceMap(node.parent); + if (parsed && sourceMapGenerator) { + sourceMapGenerator.appendSourceMap(writer.getLine(), writer.getColumn(), parsed, node.parent.sourceMapPath, node.parent.getLineAndCharacterOfPosition(node.pos), node.parent.getLineAndCharacterOfPosition(node.end)); } pipelinePhase(hint, node); } else { var _a = ts.getSourceMapRange(node), pos = _a.pos, end = _a.end, _b = _a.source, source = _b === void 0 ? sourceMapSource : _b; var emitFlags = ts.getEmitFlags(node); - if (node.kind !== 307 /* NotEmittedStatement */ + if (node.kind !== 312 /* NotEmittedStatement */ && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 && pos >= 0) { emitSourcePos(source, skipSourceTrivia(source, pos)); @@ -86195,7 +86928,7 @@ var ts; else { pipelinePhase(hint, node); } - if (node.kind !== 307 /* NotEmittedStatement */ + if (node.kind !== 312 /* NotEmittedStatement */ && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 && end >= 0) { emitSourcePos(source, end); @@ -86843,7 +87576,8 @@ var ts; var value = readFileCache.get(key); if (value !== undefined) return value !== false ? value : undefined; // could be .d.ts from output - if (!ts.fileExtensionIs(fileName, ".json" /* Json */)) { + // Cache json or buildInfo + if (!ts.fileExtensionIs(fileName, ".json" /* Json */) && !ts.isBuildInfoFile(fileName)) { return originalReadFile.call(host, fileName); } return setReadFileCache(key, fileName); @@ -86874,7 +87608,7 @@ var ts; var key = toPath(fileName); fileExistsCache.delete(key); var value = readFileCache.get(key); - if (value && value !== data) { + if (value !== undefined && value !== data) { readFileCache.delete(key); sourceFileCache.delete(key); } @@ -87429,7 +88163,8 @@ var ts; getProjectReferenceRedirect: getProjectReferenceRedirect, getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, getResolvedProjectReferenceByPath: getResolvedProjectReferenceByPath, - forEachResolvedProjectReference: forEachResolvedProjectReference + forEachResolvedProjectReference: forEachResolvedProjectReference, + emitBuildInfo: emitBuildInfo }; verifyCompilerOptions(); ts.performance.mark("afterProgram"); @@ -87856,7 +88591,20 @@ var ts; return false; // Before falling back to the host return host.fileExists(f); - } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {}), { useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); } }); + } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {}), { useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, getProgramBuildInfo: function () { return program.getProgramBuildInfo && program.getProgramBuildInfo(); } }); + } + function emitBuildInfo(writeFileCallback) { + ts.Debug.assert(!options.out && !options.outFile); + ts.performance.mark("beforeEmit"); + var emitResult = ts.emitFiles(ts.notImplementedResolver, getEmitHost(writeFileCallback), + /*targetSourceFile*/ undefined, + /*emitOnlyDtsFiles*/ false, + /*transformers*/ undefined, + /*declaraitonTransformers*/ undefined, + /*onlyBuildInfo*/ true); + ts.performance.mark("afterEmit"); + ts.performance.measure("Emit", "beforeEmit", "afterEmit"); + return emitResult; } function getResolvedProjectReferences() { return resolvedProjectReferences; @@ -87865,28 +88613,11 @@ var ts; return projectReferences; } function getPrependNodes() { - if (!projectReferences) { - return ts.emptyArray; - } - var nodes = []; - for (var i = 0; i < projectReferences.length; i++) { - var ref = projectReferences[i]; - var resolvedRefOpts = resolvedProjectReferences[i].commandLine; - if (ref.prepend && resolvedRefOpts && resolvedRefOpts.options) { - var out = resolvedRefOpts.options.outFile || resolvedRefOpts.options.out; - // Upstream project didn't have outFile set -- skip (error will have been issued earlier) - if (!out) - continue; - var _a = ts.getOutputPathsForBundle(resolvedRefOpts.options, /*forceDtsPaths*/ true), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath; - var node = ts.createInputFiles(function (fileName) { - var path = toPath(fileName); - var sourceFile = getSourceFileByPath(path); - return sourceFile ? sourceFile.text : filesByName.has(path) ? undefined : host.readFile(path); - }, jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath); - nodes.push(node); - } - } - return nodes; + return createPrependNodes(projectReferences, function (_ref, index) { return resolvedProjectReferences[index].commandLine; }, function (fileName) { + var path = toPath(fileName); + var sourceFile = getSourceFileByPath(path); + return sourceFile ? sourceFile.text : filesByName.has(path) ? undefined : host.readFile(path); + }); } function isSourceFileFromExternalLibrary(file) { return !!sourceFilesFoundSearchingNodeModules.get(file.path); @@ -87958,8 +88689,7 @@ var ts; var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile, cancellationToken); ts.performance.mark("beforeEmit"); var transformers = emitOnlyDtsFiles ? [] : ts.getTransformers(options, customTransformers); - var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, // TODO: GH#18217 - emitOnlyDtsFiles, transformers, customTransformers && customTransformers.afterDeclarations); + var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, emitOnlyDtsFiles, transformers, customTransformers && customTransformers.afterDeclarations); ts.performance.mark("afterEmit"); ts.performance.measure("Emit", "beforeEmit", "afterEmit"); return emitResult; @@ -88961,6 +89691,14 @@ var ts; if (options.declaration === false) { createDiagnosticForOptionName(ts.Diagnostics.Composite_projects_may_not_disable_declaration_emit, "declaration"); } + if (options.incremental === false) { + createDiagnosticForOptionName(ts.Diagnostics.Composite_projects_may_not_disable_incremental_compilation, "declaration"); + } + } + if (options.tsBuildInfoFile) { + if (!ts.isIncrementalCompilation(options)) { + createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "tsBuildInfoFile", "incremental", "composite"); + } } verifyProjectReferences(); // List of collected files is complete; validate exhautiveness if this is a project with a file list @@ -89155,6 +89893,7 @@ var ts; } } function verifyProjectReferences() { + var buildInfoPath = !options.noEmit && !options.suppressOutputPathCheck ? ts.getOutputPathForBuildInfo(options) : undefined; forEachProjectReference(projectReferences, resolvedProjectReferences, function (resolvedRef, index, parent) { var ref = (parent ? parent.commandLine.projectReferences : projectReferences)[index]; var parentFile = parent && parent.sourceFile; @@ -89181,6 +89920,10 @@ var ts; createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_prepend_project_0_because_it_does_not_have_outFile_set, ref.path); } } + if (!parent && buildInfoPath && buildInfoPath === ts.getOutputPathForBuildInfo(options)) { + createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_write_file_0_because_it_will_overwrite_tsbuildinfo_file_generated_by_referenced_project_1, buildInfoPath, ref.path); + hasEmitBlockingDiagnostics.set(toPath(buildInfoPath), true); + } }); } function createDiagnosticForOptionPathKeyValue(key, valueIndex, message, arg0, arg1, arg2) { @@ -89330,6 +90073,27 @@ var ts; }; } ts.parseConfigHostFromCompilerHostLike = parseConfigHostFromCompilerHostLike; + /* @internal */ + function createPrependNodes(projectReferences, getCommandLine, readFile) { + if (!projectReferences) + return ts.emptyArray; + var nodes; + for (var i = 0; i < projectReferences.length; i++) { + var ref = projectReferences[i]; + var resolvedRefOpts = getCommandLine(ref, i); + if (ref.prepend && resolvedRefOpts && resolvedRefOpts.options) { + var out = resolvedRefOpts.options.outFile || resolvedRefOpts.options.out; + // Upstream project didn't have outFile set -- skip (error will have been issued earlier) + if (!out) + continue; + var _a = ts.getOutputPathsForBundle(resolvedRefOpts.options, /*forceDtsPaths*/ true), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath; + var node = ts.createInputFiles(readFile, jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, buildInfoPath); + (nodes || (nodes = [])).push(node); + } + } + return nodes || ts.emptyArray; + } + ts.createPrependNodes = createPrependNodes; function resolveProjectReferencePath(hostOrRef, ref) { var passedInRef = ref ? ref : hostOrRef; return ts.resolveConfigFileProjectName(passedInRef.path); @@ -89873,11 +90637,14 @@ var ts; var affectedSignatures = oldState.currentAffectedFilesSignatures; ts.Debug.assert(!oldState.affectedFiles && (!affectedSignatures || !affectedSignatures.size), "Cannot reuse if only few affected files of currentChangedFile were iterated"); } + var changedFilesSet = oldState.changedFilesSet; if (canCopySemanticDiagnostics) { - ts.Debug.assert(!ts.forEachKey(oldState.changedFilesSet, function (path) { return oldState.semanticDiagnosticsPerFile.has(path); }), "Semantic diagnostics shouldnt be available for changed files"); + ts.Debug.assert(!changedFilesSet || !ts.forEachKey(changedFilesSet, function (path) { return oldState.semanticDiagnosticsPerFile.has(path); }), "Semantic diagnostics shouldnt be available for changed files"); } // Copy old state's changed files set - ts.copyEntries(oldState.changedFilesSet, state.changedFilesSet); + if (changedFilesSet) { + ts.copyEntries(changedFilesSet, state.changedFilesSet); + } if (!compilerOptions.outFile && !compilerOptions.out && oldState.affectedFilesPendingEmit) { state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit; state.affectedFilesPendingEmitIndex = oldState.affectedFilesPendingEmitIndex; @@ -89923,6 +90690,18 @@ var ts; } } }); + if (oldCompilerOptions && + (oldCompilerOptions.outDir !== compilerOptions.outDir || + oldCompilerOptions.declarationDir !== compilerOptions.declarationDir || + (oldCompilerOptions.outFile || oldCompilerOptions.out) !== (compilerOptions.outFile || compilerOptions.out))) { + // Add all files to affectedFilesPendingEmit since emit changed + state.affectedFilesPendingEmit = ts.concatenate(state.affectedFilesPendingEmit, newProgram.getSourceFiles().map(function (f) { return f.path; })); + if (state.affectedFilesPendingEmitIndex === undefined) { + state.affectedFilesPendingEmitIndex = 0; + } + ts.Debug.assert(state.seenAffectedFiles === undefined); + state.seenAffectedFiles = ts.createMap(); + } return state; } /** @@ -90144,8 +90923,11 @@ var ts; * This is called after completing operation on the next affected file. * The operations here are postponed to ensure that cancellation during the iteration is handled correctly */ - function doneWithAffectedFile(state, affected, isPendingEmit) { - if (affected === state.program) { + function doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit) { + if (isBuildInfoEmit) { + state.emittedBuildInfo = true; + } + else if (affected === state.program) { state.changedFilesSet.clear(); state.programEmitComplete = true; } @@ -90162,8 +90944,8 @@ var ts; /** * Returns the result with affected file */ - function toAffectedFileResult(state, result, affected, isPendingEmit) { - doneWithAffectedFile(state, affected, isPendingEmit); + function toAffectedFileResult(state, result, affected, isPendingEmit, isBuildInfoEmit) { + doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit); return { result: result, affected: affected }; } /** @@ -90186,6 +90968,46 @@ var ts; } return diagnostics; } + /** + * Gets the program information to be emitted in buildInfo so that we can use it to create new program + */ + function getProgramBuildInfo(state) { + if (state.compilerOptions.outFile || state.compilerOptions.out) + return undefined; + var fileInfos = {}; + state.fileInfos.forEach(function (value, key) { + var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key); + fileInfos[key] = signature === undefined ? value : { version: value.version, signature: signature }; + }); + var result = { fileInfos: fileInfos, options: state.compilerOptions }; + if (state.referencedMap) { + var referencedMap_1 = {}; + state.referencedMap.forEach(function (value, key) { + referencedMap_1[key] = ts.arrayFrom(value.keys()); + }); + result.referencedMap = referencedMap_1; + } + if (state.exportedModulesMap) { + var exportedModulesMap_1 = {}; + state.exportedModulesMap.forEach(function (value, key) { + var newValue = state.currentAffectedFilesExportedModulesMap && state.currentAffectedFilesExportedModulesMap.get(key); + // Not in temporary cache, use existing value + if (newValue === undefined) + exportedModulesMap_1[key] = ts.arrayFrom(value.keys()); + // Value in cache and has updated value map, use that + else if (newValue) + exportedModulesMap_1[key] = ts.arrayFrom(newValue.keys()); + }); + result.exportedModulesMap = exportedModulesMap_1; + } + if (state.semanticDiagnosticsPerFile) { + var semanticDiagnosticsPerFile_1 = []; + // Currently not recording actual errors since those mean no emit for tsc --build + state.semanticDiagnosticsPerFile.forEach(function (_value, key) { return semanticDiagnosticsPerFile_1.push(key); }); + result.semanticDiagnosticsPerFile = semanticDiagnosticsPerFile_1; + } + return result; + } var BuilderProgramKind; (function (BuilderProgramKind) { BuilderProgramKind[BuilderProgramKind["SemanticDiagnosticsBuilderProgram"] = 0] = "SemanticDiagnosticsBuilderProgram"; @@ -90242,6 +91064,7 @@ var ts; var computeHash = host.createHash || ts.generateDjb2Hash; var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState); var backupState; + newProgram.getProgramBuildInfo = function () { return result.getProgramBuildInfo(); }; // To ensure that we arent storing any references to old program or new program without state newProgram = undefined; // TODO: GH#18217 oldProgram = undefined; @@ -90263,6 +91086,7 @@ var ts; releaseCache(state); backupState = undefined; }; + result.getProgramBuildInfo = function () { return getProgramBuildInfo(state); }; if (kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram) { result.getSemanticDiagnosticsOfNextAffectedFile = getSemanticDiagnosticsOfNextAffectedFile; } @@ -90285,7 +91109,16 @@ var ts; if (!state.compilerOptions.out && !state.compilerOptions.outFile) { affected = getNextAffectedFilePendingEmit(state); if (!affected) { - return undefined; + if (state.emittedBuildInfo) { + return undefined; + } + var affected_1 = ts.Debug.assertDefined(state.program); + return toAffectedFileResult(state, + // When whole program is affected, do emit only once (eg when --out or --outFile is specified) + // Otherwise just affected file + affected_1.emitBuildInfo(writeFile || host.writeFile, cancellationToken), affected_1, + /*isPendingEmitFile*/ false, + /*isBuildInfoEmit*/ true); } isPendingEmitFile = true; } @@ -90418,6 +91251,53 @@ var ts; } } ts.createBuilderProgram = createBuilderProgram; + function getMapOfReferencedSet(mapLike) { + if (!mapLike) + return undefined; + var map = ts.createMap(); + // Copies keys/values from template. Note that for..in will not throw if + // template is undefined, and instead will just exit the loop. + for (var key in mapLike) { + if (ts.hasProperty(mapLike, key)) { + map.set(key, ts.arrayToSet(mapLike[key])); + } + } + return map; + } + function createBuildProgramUsingProgramBuildInfo(program) { + var fileInfos = ts.createMapFromTemplate(program.fileInfos); + var state = { + fileInfos: fileInfos, + compilerOptions: program.options, + referencedMap: getMapOfReferencedSet(program.referencedMap), + exportedModulesMap: getMapOfReferencedSet(program.exportedModulesMap), + semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && ts.arrayToMap(program.semanticDiagnosticsPerFile, ts.identity, function () { return ts.emptyArray; }) + }; + return { + getState: function () { return state; }, + backupState: ts.noop, + restoreState: ts.noop, + getProgram: ts.notImplemented, + getProgramOrUndefined: function () { return undefined; }, + releaseProgram: ts.noop, + getCompilerOptions: function () { return state.compilerOptions; }, + getSourceFile: ts.notImplemented, + getSourceFiles: ts.notImplemented, + getOptionsDiagnostics: ts.notImplemented, + getGlobalDiagnostics: ts.notImplemented, + getConfigFileParsingDiagnostics: ts.notImplemented, + getSyntacticDiagnostics: ts.notImplemented, + getDeclarationDiagnostics: ts.notImplemented, + getSemanticDiagnostics: ts.notImplemented, + emit: ts.notImplemented, + getAllDependencies: ts.notImplemented, + getCurrentDirectory: ts.notImplemented, + emitNextAffectedFile: ts.notImplemented, + getSemanticDiagnosticsOfNextAffectedFile: ts.notImplemented, + getProgramBuildInfo: ts.notImplemented + }; + } + ts.createBuildProgramUsingProgramBuildInfo = createBuildProgramUsingProgramBuildInfo; function createRedirectedBuilderProgram(state, configFileParsingDiagnostics) { return { getState: ts.notImplemented, @@ -90437,7 +91317,8 @@ var ts; getSemanticDiagnostics: function (sourceFile, cancellationToken) { return getProgram().getSemanticDiagnostics(sourceFile, cancellationToken); }, emit: function (sourceFile, writeFile, cancellationToken, emitOnlyDts, customTransformers) { return getProgram().emit(sourceFile, writeFile, cancellationToken, emitOnlyDts, customTransformers); }, getAllDependencies: ts.notImplemented, - getCurrentDirectory: function () { return getProgram().getCurrentDirectory(); } + getCurrentDirectory: function () { return getProgram().getCurrentDirectory(); }, + getProgramBuildInfo: function () { return undefined; } }; function getProgram() { return ts.Debug.assertDefined(state.program); @@ -91465,6 +92346,8 @@ var ts; case ".jsx" /* Jsx */: case ".json" /* Json */: return ext; + case ".tsbuildinfo" /* TsBuildInfo */: + return ts.Debug.fail("Extension " + ".tsbuildinfo" /* TsBuildInfo */ + " is unsupported:: FileName:: " + fileName); default: return ts.Debug.assertNever(ext); } @@ -91746,7 +92629,7 @@ var ts; writeFile: function (path, data, writeByteOrderMark) { return system.writeFile(path, data, writeByteOrderMark); }, onCachedDirectoryStructureHostCreate: function (cacheHost) { return host = cacheHost || system; }, createHash: ts.maybeBind(system, system.createHash), - createProgram: createProgram + createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram }; } ts.createProgramHost = createProgramHost; @@ -91756,7 +92639,7 @@ var ts; function createWatchCompilerHost(system, createProgram, reportDiagnostic, reportWatchStatus) { if (system === void 0) { system = ts.sys; } var writeFileName = function (s) { return system.write(s + system.newLine); }; - var result = createProgramHost(system, createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram); + var result = createProgramHost(system, createProgram); ts.copyProperties(result, createWatchHost(system, reportWatchStatus)); result.afterProgramCreate = function (builderProgram) { var compilerOptions = builderProgram.getCompilerOptions(); @@ -92239,16 +93122,22 @@ var ts; * This means we can Pseudo-build (just touch timestamps), as if we had actually built this project. */ UpToDateStatusType[UpToDateStatusType["UpToDateWithUpstreamTypes"] = 2] = "UpToDateWithUpstreamTypes"; - UpToDateStatusType[UpToDateStatusType["OutputMissing"] = 3] = "OutputMissing"; - UpToDateStatusType[UpToDateStatusType["OutOfDateWithSelf"] = 4] = "OutOfDateWithSelf"; - UpToDateStatusType[UpToDateStatusType["OutOfDateWithUpstream"] = 5] = "OutOfDateWithUpstream"; - UpToDateStatusType[UpToDateStatusType["UpstreamOutOfDate"] = 6] = "UpstreamOutOfDate"; - UpToDateStatusType[UpToDateStatusType["UpstreamBlocked"] = 7] = "UpstreamBlocked"; - UpToDateStatusType[UpToDateStatusType["ComputingUpstream"] = 8] = "ComputingUpstream"; + /** + * The project appears out of date because its upstream inputs are newer than its outputs, + * but all of its outputs are actually newer than the previous identical outputs of its (.d.ts) inputs. + * This means we can Pseudo-build (just manipulate outputs), as if we had actually built this project. + */ + UpToDateStatusType[UpToDateStatusType["OutOfDateWithPrepend"] = 3] = "OutOfDateWithPrepend"; + UpToDateStatusType[UpToDateStatusType["OutputMissing"] = 4] = "OutputMissing"; + UpToDateStatusType[UpToDateStatusType["OutOfDateWithSelf"] = 5] = "OutOfDateWithSelf"; + UpToDateStatusType[UpToDateStatusType["OutOfDateWithUpstream"] = 6] = "OutOfDateWithUpstream"; + UpToDateStatusType[UpToDateStatusType["UpstreamOutOfDate"] = 7] = "UpstreamOutOfDate"; + UpToDateStatusType[UpToDateStatusType["UpstreamBlocked"] = 8] = "UpstreamBlocked"; + UpToDateStatusType[UpToDateStatusType["ComputingUpstream"] = 9] = "ComputingUpstream"; /** * Projects with no outputs (i.e. "solution" files) */ - UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 9] = "ContainerOnly"; + UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 10] = "ContainerOnly"; })(UpToDateStatusType = ts.UpToDateStatusType || (ts.UpToDateStatusType = {})); function createFileMap(toPath) { // tslint:disable-next-line:no-null-keyword @@ -92329,24 +93218,18 @@ var ts; } return outputs; } - function getOutFileOutputs(project) { - var out = project.options.outFile || project.options.out; - if (!out) { - return ts.Debug.fail("outFile must be set"); - } + function getOutFileOutputs(project, ignoreBuildInfo) { + ts.Debug.assert(!!project.options.outFile || !!project.options.out, "outFile must be set"); + var _a = ts.getOutputPathsForBundle(project.options, /*forceDtsPaths*/ false), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath; var outputs = []; - outputs.push(out); - if (project.options.sourceMap) { - outputs.push(out + ".map"); - } - if (ts.getEmitDeclarations(project.options)) { - var dts = ts.changeExtension(out, ".d.ts" /* Dts */); - outputs.push(dts); - if (project.options.declarationMap) { - outputs.push(dts + ".map"); - } - } - return outputs; + var addOutput = function (path) { return path && (outputs || (outputs = [])).push(path); }; + addOutput(jsFilePath); + addOutput(sourceMapFilePath); + addOutput(declarationFilePath); + addOutput(declarationMapPath); + if (!ignoreBuildInfo) + addOutput(buildInfoPath); + return outputs || ts.emptyArray; } function rootDirOfOptions(opts, configFileName) { return opts.rootDir || ts.getDirectoryPath(configFileName); @@ -92379,14 +93262,14 @@ var ts; } function createSolutionBuilderHost(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus, reportErrorSummary) { if (system === void 0) { system = ts.sys; } - var host = createSolutionBuilderHostBase(system, createProgram || ts.createAbstractBuilder, reportDiagnostic, reportSolutionBuilderStatus); + var host = createSolutionBuilderHostBase(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus); host.reportErrorSummary = reportErrorSummary; return host; } ts.createSolutionBuilderHost = createSolutionBuilderHost; function createSolutionBuilderWithWatchHost(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus, reportWatchStatus) { if (system === void 0) { system = ts.sys; } - var host = createSolutionBuilderHostBase(system, createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram, reportDiagnostic, reportSolutionBuilderStatus); + var host = createSolutionBuilderHostBase(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus); var watchHost = ts.createWatchHost(system, reportWatchStatus); ts.copyProperties(host, watchHost); return host; @@ -92420,7 +93303,17 @@ var ts; var compilerHost = ts.createCompilerHostFromProgramHost(host, function () { return projectCompilerOptions; }); var originalGetSourceFile = compilerHost.getSourceFile; var computeHash = host.createHash || ts.generateDjb2Hash; - updateGetSourceFile(); + compilerHost.getSourceFile = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var result = originalGetSourceFile.call.apply(originalGetSourceFile, [compilerHost].concat(args)); + if (result) { + result.version = computeHash.call(host, result.text); + } + return result; + }; // Watch state var builderPrograms = createFileMap(toPath); var diagnostics = createFileMap(toPath); @@ -92472,29 +93365,6 @@ var ts; ts.clearMap(allWatchedInputFiles, function (inputFileWatches) { return ts.clearMap(inputFileWatches, ts.closeFileWatcher); }); ts.clearMap(allWatchedConfigFiles, ts.closeFileWatcher); builderPrograms.clear(); - updateGetSourceFile(); - } - function updateGetSourceFile() { - if (options.watch) { - if (compilerHost.getSourceFile === originalGetSourceFile) { - compilerHost.getSourceFile = function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - var result = originalGetSourceFile.call.apply(originalGetSourceFile, [compilerHost].concat(args)); - if (result && options.watch) { - result.version = computeHash.call(host, result.text); - } - return result; - }; - } - } - else { - if (compilerHost.getSourceFile !== originalGetSourceFile) { - compilerHost.getSourceFile = originalGetSourceFile; - } - } } function isParsedCommandLine(entry) { return !!entry.options; @@ -92726,25 +93596,28 @@ var ts; upstreamProjectName: ref.path }; } - // If the upstream project's newest file is older than our oldest output, we - // can't be out of date because of it - if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) { - continue; + // Check oldest output file name only if there is no missing output file name + if (!missingOutputFileName) { + // If the upstream project's newest file is older than our oldest output, we + // can't be out of date because of it + if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) { + continue; + } + // If the upstream project has only change .d.ts files, and we've built + // *after* those files, then we're "psuedo up to date" and eligible for a fast rebuild + if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) { + pseudoUpToDate = true; + upstreamChangedProject = ref.path; + continue; + } + // We have an output older than an upstream output - we are out of date + ts.Debug.assert(oldestOutputFileName !== undefined, "Should have an oldest output filename here"); + return { + type: UpToDateStatusType.OutOfDateWithUpstream, + outOfDateOutputFileName: oldestOutputFileName, + newerProjectName: ref.path + }; } - // If the upstream project has only change .d.ts files, and we've built - // *after* those files, then we're "psuedo up to date" and eligible for a fast rebuild - if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) { - pseudoUpToDate = true; - upstreamChangedProject = ref.path; - continue; - } - // We have an output older than an upstream output - we are out of date - ts.Debug.assert(oldestOutputFileName !== undefined, "Should have an oldest output filename here"); - return { - type: UpToDateStatusType.OutOfDateWithUpstream, - outOfDateOutputFileName: oldestOutputFileName, - newerProjectName: ref.path - }; } } if (missingOutputFileName !== undefined) { @@ -92762,7 +93635,7 @@ var ts; } if (usesPrepend && pseudoUpToDate) { return { - type: UpToDateStatusType.OutOfDateWithUpstream, + type: UpToDateStatusType.OutOfDateWithPrepend, outOfDateOutputFileName: oldestOutputFileName, newerProjectName: upstreamChangedProject }; @@ -92896,7 +93769,9 @@ var ts; updateOutputTimestamps(proj); return; } - var buildResult = buildSingleProject(resolved); + var buildResult = status.type === UpToDateStatusType.OutOfDateWithPrepend ? + updateBundle(resolved) : // Fake that files have been built by manipulating prepend and existing output + buildSingleProject(resolved); // Actual build if (buildResult & BuildResultFlags.AnyErrors) return; var _a = getGlobalDependencyGraph(), referencingProjectsMap = _a.referencingProjectsMap, buildQueue = _a.buildQueue; @@ -92912,17 +93787,26 @@ var ts; // If declaration output is changed, build the project // otherwise mark the project UpToDateWithUpstreamTypes so it updates output time stamps var status_1 = projectStatus.getValue(project); - if (prepend || !(buildResult & BuildResultFlags.DeclarationOutputUnchanged)) { - if (status_1 && (status_1.type === UpToDateStatusType.UpToDate || status_1.type === UpToDateStatusType.UpToDateWithUpstreamTypes)) { + if (!(buildResult & BuildResultFlags.DeclarationOutputUnchanged)) { + if (status_1 && (status_1.type === UpToDateStatusType.UpToDate || status_1.type === UpToDateStatusType.UpToDateWithUpstreamTypes || status_1.type === UpToDateStatusType.OutOfDateWithPrepend)) { projectStatus.setValue(project, { type: UpToDateStatusType.OutOfDateWithUpstream, - outOfDateOutputFileName: status_1.oldestOutputFileName, + outOfDateOutputFileName: status_1.type === UpToDateStatusType.OutOfDateWithPrepend ? status_1.outOfDateOutputFileName : status_1.oldestOutputFileName, newerProjectName: resolved }); } } else if (status_1 && status_1.type === UpToDateStatusType.UpToDate) { - status_1.type = UpToDateStatusType.UpToDateWithUpstreamTypes; + if (prepend) { + projectStatus.setValue(project, { + type: UpToDateStatusType.OutOfDateWithPrepend, + outOfDateOutputFileName: status_1.oldestOutputFileName, + newerProjectName: resolved + }); + } + else { + status_1.type = UpToDateStatusType.UpToDateWithUpstreamTypes; + } } addProjToQueue(project); } @@ -92979,8 +93863,7 @@ var ts; } if (options.verbose) reportStatus(ts.Diagnostics.Building_project_0, proj); - var resultFlags = BuildResultFlags.None; - resultFlags |= BuildResultFlags.DeclarationOutputUnchanged; + var resultFlags = BuildResultFlags.DeclarationOutputUnchanged; var configFile = parseConfigFile(proj); if (!configFile) { // Failed to read the config file @@ -92996,8 +93879,7 @@ var ts; } // TODO: handle resolve module name to cache result in project reference redirect projectCompilerOptions = configFile.options; - var program = host.createProgram(configFile.fileNames, configFile.options, compilerHost, builderPrograms.getValue(proj), configFile.errors, configFile.projectReferences); - projectCompilerOptions = baseCompilerOptions; + var program = host.createProgram(configFile.fileNames, configFile.options, compilerHost, getOldProgram(proj, configFile), configFile.errors, configFile.projectReferences); // Don't emit anything in the presence of syntactic errors or options diagnostics var syntaxDiagnostics = program.getConfigFileParsingDiagnostics().concat(program.getOptionsDiagnostics(), program.getGlobalDiagnostics(), program.getSyntacticDiagnostics()); if (syntaxDiagnostics.length) { @@ -93058,12 +93940,14 @@ var ts; diagnostics.removeKey(proj); projectStatus.setValue(proj, status); afterProgramCreate(proj, program); + projectCompilerOptions = baseCompilerOptions; return resultFlags; function buildErrors(diagnostics, errorFlags, errorType) { resultFlags |= errorFlags; reportAndStoreErrors(proj, diagnostics); projectStatus.setValue(proj, { type: UpToDateStatusType.Unbuildable, reason: errorType + " errors" }); afterProgramCreate(proj, program); + projectCompilerOptions = baseCompilerOptions; return resultFlags; } } @@ -93076,9 +93960,65 @@ var ts; builderPrograms.setValue(proj, program); } } + function getOldProgram(proj, parsed) { + var value = builderPrograms.getValue(proj); + if (value) + return value; + var buildInfoPath = ts.getOutputPathForBuildInfo(parsed.options); + if (!buildInfoPath) + return undefined; + var content = readFileWithCache(buildInfoPath); + if (!content) + return undefined; + var buildInfo = JSON.parse(content); + return buildInfo.program && ts.createBuildProgramUsingProgramBuildInfo(buildInfo.program); + } + function updateBundle(proj) { + if (options.dry) { + reportStatus(ts.Diagnostics.A_non_dry_build_would_update_output_of_project_0, proj); + return BuildResultFlags.Success; + } + if (options.verbose) + reportStatus(ts.Diagnostics.Updating_output_of_project_0, proj); + // Update js, and source map + var config = ts.Debug.assertDefined(parseConfigFile(proj)); + projectCompilerOptions = config.options; + var outputFiles = ts.emitUsingBuildInfo(config, compilerHost, function (ref) { return parseConfigFile(resolveProjectName(ref.path)); }); + if (ts.isString(outputFiles)) { + reportStatus(ts.Diagnostics.Cannot_update_output_of_project_0_because_there_was_error_reading_file_1, proj, relName(outputFiles)); + return buildSingleProject(proj); + } + // Actual Emit + ts.Debug.assert(!!outputFiles.length); + var emitterDiagnostics = ts.createDiagnosticCollection(); + var emittedOutputs = createFileMap(toPath); + outputFiles.forEach(function (_a) { + var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark; + emittedOutputs.setValue(name, true); + ts.writeFile(compilerHost, emitterDiagnostics, name, text, writeByteOrderMark); + }); + var emitDiagnostics = emitterDiagnostics.getDiagnostics(); + if (emitDiagnostics.length) { + reportAndStoreErrors(proj, emitDiagnostics); + projectStatus.setValue(proj, { type: UpToDateStatusType.Unbuildable, reason: "Emit errors" }); + projectCompilerOptions = baseCompilerOptions; + return BuildResultFlags.DeclarationOutputUnchanged | BuildResultFlags.EmitErrors; + } + // Update timestamps for dts + var newestDeclarationFileContentChangedTime = updateOutputTimestampsWorker(config, minimumDate, ts.Diagnostics.Updating_unchanged_output_timestamps_of_project_0, emittedOutputs); + var status = { + type: UpToDateStatusType.UpToDate, + newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTime, + oldestOutputFileName: outputFiles[0].name + }; + diagnostics.removeKey(proj); + projectStatus.setValue(proj, status); + projectCompilerOptions = baseCompilerOptions; + return BuildResultFlags.DeclarationOutputUnchanged; + } function updateOutputTimestamps(proj) { if (options.dry) { - return reportStatus(ts.Diagnostics.A_non_dry_build_would_build_project_0, proj.options.configFilePath); + return reportStatus(ts.Diagnostics.A_non_dry_build_would_update_timestamps_for_output_of_project_0, proj.options.configFilePath); } var priorNewestUpdateTime = updateOutputTimestampsWorker(proj, minimumDate, ts.Diagnostics.Updating_output_timestamps_of_project_0); projectStatus.setValue(proj.options.configFilePath, { type: UpToDateStatusType.UpToDate, newestDeclarationFileContentChangedTime: priorNewestUpdateTime }); @@ -93205,7 +94145,9 @@ var ts; // Do nothing continue; } - var buildResult = buildSingleProject(next); + var buildResult = status.type === UpToDateStatusType.OutOfDateWithPrepend && !options.force ? + updateBundle(next) : // Fake that files have been built by manipulating prepend and existing output + buildSingleProject(next); // Actual build anyFailed = anyFailed || !!(buildResult & BuildResultFlags.AnyErrors); } reportErrorSummary(); @@ -93267,6 +94209,9 @@ var ts; var inputFile = _a[_i]; outputs.push.apply(outputs, getOutputFileNames(inputFile, project)); } + var buildInfoPath = ts.getOutputPathForBuildInfo(project.options); + if (buildInfoPath) + outputs.push(buildInfoPath); return outputs; } } @@ -93298,6 +94243,8 @@ var ts; } // Don't report anything for "up to date because it was already built" -- too verbose break; + case UpToDateStatusType.OutOfDateWithPrepend: + return formatMessage(ts.Diagnostics.Project_0_is_out_of_date_because_output_of_its_dependency_1_has_changed, relName(configFileName), relName(status.newerProjectName)); case UpToDateStatusType.UpToDateWithUpstreamTypes: return formatMessage(ts.Diagnostics.Project_0_is_up_to_date_with_d_ts_files_from_its_dependencies, relName(configFileName)); case UpToDateStatusType.UpstreamOutOfDate: