diff --git a/lib/tsc.js b/lib/tsc.js index 83f54758acd6c..676a6234c8d91 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -65,7 +65,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { var ts; (function (ts) { ts.versionMajorMinor = "4.3"; - ts.version = "4.3.2"; + ts.version = "4.3.3"; var NativeCollections; (function (NativeCollections) { function tryGetNativeMap() { @@ -23614,8 +23614,8 @@ var ts; visitNode(cbNode, node.typeExpression) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) : visitNode(cbNode, node.typeExpression) || - visitNode(cbNode, node.name)) || - (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + visitNode(cbNode, node.name) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment))); case 320: return visitNode(cbNode, node.tagName) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); @@ -49122,8 +49122,7 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.kind === 158 || - node.parent.kind === 174 && node.parent.typeArguments && node === node.parent.typeName || + return !(node.parent.kind === 174 && node.parent.typeArguments && node === node.parent.typeName || node.parent.kind === 196 && node.parent.typeArguments && node === node.parent.qualifier); } function isTypeParameterPossiblyReferenced(tp, node) { @@ -49148,7 +49147,10 @@ var ts; return true; case 166: case 165: - return (!node.type && !!node.body) || !!ts.forEachChild(node, containsReference); + return !node.type && !!node.body || + ts.some(node.typeParameters, containsReference) || + ts.some(node.parameters, containsReference) || + !!node.type && containsReference(node.type); } return !!ts.forEachChild(node, containsReference); } @@ -53779,12 +53781,13 @@ var ts; applyToReturnTypes(source, target, inferFromTypes); } function inferFromIndexTypes(source, target) { + var priority = (ts.getObjectFlags(source) & ts.getObjectFlags(target) & 32) ? 8 : 0; var targetStringIndexType = getIndexTypeOfType(target, 0); if (targetStringIndexType) { var sourceIndexType = getIndexTypeOfType(source, 0) || getImplicitIndexTypeOfType(source, 0); if (sourceIndexType) { - inferFromTypes(sourceIndexType, targetStringIndexType); + inferWithPriority(sourceIndexType, targetStringIndexType, priority); } } var targetNumberIndexType = getIndexTypeOfType(target, 1); @@ -53793,7 +53796,7 @@ var ts; getIndexTypeOfType(source, 0) || getImplicitIndexTypeOfType(source, 1); if (sourceIndexType) { - inferFromTypes(sourceIndexType, targetNumberIndexType); + inferWithPriority(sourceIndexType, targetNumberIndexType, priority); } } } @@ -72176,6 +72179,7 @@ var ts; case 120: case 121: case 125: + case 156: case 84: case 133: case 142: @@ -87991,11 +87995,14 @@ var ts; if (nextNode.kind === 11) { return 0; } - else if (preserveSourceNewlines && siblingNodePositionsAreComparable(previousNode, nextNode)) { - return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); }); - } - else if (!preserveSourceNewlines && !ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) { - return ts.rangeEndIsOnSameLineAsRangeStart(previousNode, nextNode, currentSourceFile) ? 0 : 1; + else if (!ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) { + if (preserveSourceNewlines && siblingNodePositionsAreComparable(previousNode, nextNode)) { + return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); }); + } + else if (!preserveSourceNewlines && originalNodesHaveSameParent(previousNode, nextNode)) { + return ts.rangeEndIsOnSameLineAsRangeStart(previousNode, nextNode, currentSourceFile) ? 0 : 1; + } + return format & 65536 ? 1 : 0; } else if (synthesizedNodeStartsOnNewLine(previousNode, format) || synthesizedNodeStartsOnNewLine(nextNode, format)) { return 1; @@ -88541,10 +88548,11 @@ var ts; } exitComment(); } + function originalNodesHaveSameParent(nodeA, nodeB) { + nodeA = ts.getOriginalNode(nodeA); + return nodeA.parent && nodeA.parent === ts.getOriginalNode(nodeB).parent; + } function siblingNodePositionsAreComparable(previousNode, nextNode) { - if (ts.nodeIsSynthesized(previousNode) || ts.nodeIsSynthesized(nextNode)) { - return false; - } if (nextNode.pos < previousNode.end) { return false; } @@ -93180,8 +93188,11 @@ var ts; var optionsNameMap = ts.getOptionsNameMap().optionsNameMap; for (var _i = 0, _a = ts.getOwnKeys(options).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) { var name = _a[_i]; - var optionInfo = optionsNameMap.get(name.toLowerCase()); - if ((optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsEmit) || (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsSemanticDiagnostics) || name === "skipLibCheck" || name === "skipDefaultLibCheck") { + var optionKey = name.toLowerCase(); + var optionInfo = optionsNameMap.get(optionKey); + if ((optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsEmit) || (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsSemanticDiagnostics) || + optionKey === "strict" || + optionKey === "skiplibcheck" || optionKey === "skipdefaultlibcheck") { (result || (result = {}))[name] = convertToReusableCompilerOptionValue(optionInfo, options[name], relativeToBuildInfo); } } diff --git a/lib/tsserver.js b/lib/tsserver.js index 58028943d1d1f..6ff08da17dfb1 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -96,7 +96,7 @@ var ts; // The following is baselined as a literal template type without intervention /** The version of the TypeScript compiler release */ // eslint-disable-next-line @typescript-eslint/no-inferrable-types - ts.version = "4.3.2"; + ts.version = "4.3.3"; /* @internal */ var Comparison; (function (Comparison) { @@ -29268,8 +29268,8 @@ var ts; visitNode(cbNode, node.typeExpression) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) : visitNode(cbNode, node.typeExpression) || - visitNode(cbNode, node.name)) || - (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + visitNode(cbNode, node.name) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment))); case 320 /* JSDocAuthorTag */: return visitNode(cbNode, node.tagName) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); @@ -37382,6 +37382,8 @@ var ts; { name: "strict", type: "boolean", + // Though this affects semantic diagnostics, affectsSemanticDiagnostics is not set here + // The value of each strictFlag depends on own strictFlag value or this and never accessed directly. showInSimplifiedHelpView: true, category: ts.Diagnostics.Strict_Type_Checking_Options, description: ts.Diagnostics.Enable_all_strict_type_checking_options @@ -59168,8 +59170,7 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.kind === 158 /* QualifiedName */ || - node.parent.kind === 174 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || + return !(node.parent.kind === 174 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || node.parent.kind === 196 /* ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); } function isTypeParameterPossiblyReferenced(tp, node) { @@ -59197,7 +59198,10 @@ var ts; return true; case 166 /* MethodDeclaration */: case 165 /* MethodSignature */: - return (!node.type && !!node.body) || !!ts.forEachChild(node, containsReference); + return !node.type && !!node.body || + ts.some(node.typeParameters, containsReference) || + ts.some(node.parameters, containsReference) || + !!node.type && containsReference(node.type); } return !!ts.forEachChild(node, containsReference); } @@ -64580,12 +64584,14 @@ var ts; applyToReturnTypes(source, target, inferFromTypes); } function inferFromIndexTypes(source, target) { + // Inferences across mapped type index signatures are pretty much the same a inferences to homomorphic variables + var priority = (ts.getObjectFlags(source) & ts.getObjectFlags(target) & 32 /* Mapped */) ? 8 /* HomomorphicMappedType */ : 0; var targetStringIndexType = getIndexTypeOfType(target, 0 /* String */); if (targetStringIndexType) { var sourceIndexType = getIndexTypeOfType(source, 0 /* String */) || getImplicitIndexTypeOfType(source, 0 /* String */); if (sourceIndexType) { - inferFromTypes(sourceIndexType, targetStringIndexType); + inferWithPriority(sourceIndexType, targetStringIndexType, priority); } } var targetNumberIndexType = getIndexTypeOfType(target, 1 /* Number */); @@ -64594,7 +64600,7 @@ var ts; getIndexTypeOfType(source, 0 /* String */) || getImplicitIndexTypeOfType(source, 1 /* Number */); if (sourceIndexType) { - inferFromTypes(sourceIndexType, targetNumberIndexType); + inferWithPriority(sourceIndexType, targetNumberIndexType, priority); } } } @@ -85910,6 +85916,7 @@ var ts; case 120 /* PrivateKeyword */: case 121 /* ProtectedKeyword */: case 125 /* AbstractKeyword */: + case 156 /* OverrideKeyword */: case 84 /* ConstKeyword */: case 133 /* DeclareKeyword */: case 142 /* ReadonlyKeyword */: @@ -107102,11 +107109,21 @@ var ts; // JsxText will be written with its leading whitespace, so don't add more manually. return 0; } - else if (preserveSourceNewlines && siblingNodePositionsAreComparable(previousNode, nextNode)) { - return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); }); - } - else if (!preserveSourceNewlines && !ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) { - return ts.rangeEndIsOnSameLineAsRangeStart(previousNode, nextNode, currentSourceFile) ? 0 : 1; + else if (!ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) { + if (preserveSourceNewlines && siblingNodePositionsAreComparable(previousNode, nextNode)) { + return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); }); + } + // If `preserveSourceNewlines` is `false` we do not intend to preserve the effective lines between the + // previous and next node. Instead we naively check whether nodes are on separate lines within the + // same node parent. If so, we intend to preserve a single line terminator. This is less precise and + // expensive than checking with `preserveSourceNewlines` as above, but the goal is not to preserve the + // effective source lines between two sibling nodes. + else if (!preserveSourceNewlines && originalNodesHaveSameParent(previousNode, nextNode)) { + return ts.rangeEndIsOnSameLineAsRangeStart(previousNode, nextNode, currentSourceFile) ? 0 : 1; + } + // If the two nodes are not comparable, add a line terminator based on the format that can indicate + // whether new lines are preferred or not. + return format & 65536 /* PreferNewLine */ ? 1 : 0; } else if (synthesizedNodeStartsOnNewLine(previousNode, format) || synthesizedNodeStartsOnNewLine(nextNode, format)) { return 1; @@ -107746,10 +107763,13 @@ var ts; } exitComment(); } + function originalNodesHaveSameParent(nodeA, nodeB) { + nodeA = ts.getOriginalNode(nodeA); + // For performance, do not call `getOriginalNode` for `nodeB` if `nodeA` doesn't even + // have a parent node. + return nodeA.parent && nodeA.parent === ts.getOriginalNode(nodeB).parent; + } function siblingNodePositionsAreComparable(previousNode, nextNode) { - if (ts.nodeIsSynthesized(previousNode) || ts.nodeIsSynthesized(nextNode)) { - return false; - } if (nextNode.pos < previousNode.end) { return false; } @@ -113122,8 +113142,14 @@ var ts; var optionsNameMap = ts.getOptionsNameMap().optionsNameMap; for (var _i = 0, _a = ts.getOwnKeys(options).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) { var name = _a[_i]; - var optionInfo = optionsNameMap.get(name.toLowerCase()); - if ((optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsEmit) || (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsSemanticDiagnostics) || name === "skipLibCheck" || name === "skipDefaultLibCheck") { + var optionKey = name.toLowerCase(); + var optionInfo = optionsNameMap.get(optionKey); + if ((optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsEmit) || (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsSemanticDiagnostics) || + // We need to store `strict`, even though it won't be examined directly, so that the + // flags it controls (e.g. `strictNullChecks`) will be retrieved correctly from the buildinfo + optionKey === "strict" || + // We need to store these to determine whether `lib` files need to be rechecked. + optionKey === "skiplibcheck" || optionKey === "skipdefaultlibcheck") { (result || (result = {}))[name] = convertToReusableCompilerOptionValue(optionInfo, options[name], relativeToBuildInfo); } } diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js index ee78ce982fd11..f4f612b263875 100644 --- a/lib/tsserverlibrary.js +++ b/lib/tsserverlibrary.js @@ -290,7 +290,7 @@ var ts; // The following is baselined as a literal template type without intervention /** The version of the TypeScript compiler release */ // eslint-disable-next-line @typescript-eslint/no-inferrable-types - ts.version = "4.3.2"; + ts.version = "4.3.3"; /* @internal */ var Comparison; (function (Comparison) { @@ -29462,8 +29462,8 @@ var ts; visitNode(cbNode, node.typeExpression) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) : visitNode(cbNode, node.typeExpression) || - visitNode(cbNode, node.name)) || - (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + visitNode(cbNode, node.name) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment))); case 320 /* JSDocAuthorTag */: return visitNode(cbNode, node.tagName) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); @@ -37576,6 +37576,8 @@ var ts; { name: "strict", type: "boolean", + // Though this affects semantic diagnostics, affectsSemanticDiagnostics is not set here + // The value of each strictFlag depends on own strictFlag value or this and never accessed directly. showInSimplifiedHelpView: true, category: ts.Diagnostics.Strict_Type_Checking_Options, description: ts.Diagnostics.Enable_all_strict_type_checking_options @@ -59362,8 +59364,7 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.kind === 158 /* QualifiedName */ || - node.parent.kind === 174 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || + return !(node.parent.kind === 174 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || node.parent.kind === 196 /* ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); } function isTypeParameterPossiblyReferenced(tp, node) { @@ -59391,7 +59392,10 @@ var ts; return true; case 166 /* MethodDeclaration */: case 165 /* MethodSignature */: - return (!node.type && !!node.body) || !!ts.forEachChild(node, containsReference); + return !node.type && !!node.body || + ts.some(node.typeParameters, containsReference) || + ts.some(node.parameters, containsReference) || + !!node.type && containsReference(node.type); } return !!ts.forEachChild(node, containsReference); } @@ -64774,12 +64778,14 @@ var ts; applyToReturnTypes(source, target, inferFromTypes); } function inferFromIndexTypes(source, target) { + // Inferences across mapped type index signatures are pretty much the same a inferences to homomorphic variables + var priority = (ts.getObjectFlags(source) & ts.getObjectFlags(target) & 32 /* Mapped */) ? 8 /* HomomorphicMappedType */ : 0; var targetStringIndexType = getIndexTypeOfType(target, 0 /* String */); if (targetStringIndexType) { var sourceIndexType = getIndexTypeOfType(source, 0 /* String */) || getImplicitIndexTypeOfType(source, 0 /* String */); if (sourceIndexType) { - inferFromTypes(sourceIndexType, targetStringIndexType); + inferWithPriority(sourceIndexType, targetStringIndexType, priority); } } var targetNumberIndexType = getIndexTypeOfType(target, 1 /* Number */); @@ -64788,7 +64794,7 @@ var ts; getIndexTypeOfType(source, 0 /* String */) || getImplicitIndexTypeOfType(source, 1 /* Number */); if (sourceIndexType) { - inferFromTypes(sourceIndexType, targetNumberIndexType); + inferWithPriority(sourceIndexType, targetNumberIndexType, priority); } } } @@ -86104,6 +86110,7 @@ var ts; case 120 /* PrivateKeyword */: case 121 /* ProtectedKeyword */: case 125 /* AbstractKeyword */: + case 156 /* OverrideKeyword */: case 84 /* ConstKeyword */: case 133 /* DeclareKeyword */: case 142 /* ReadonlyKeyword */: @@ -107296,11 +107303,21 @@ var ts; // JsxText will be written with its leading whitespace, so don't add more manually. return 0; } - else if (preserveSourceNewlines && siblingNodePositionsAreComparable(previousNode, nextNode)) { - return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); }); - } - else if (!preserveSourceNewlines && !ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) { - return ts.rangeEndIsOnSameLineAsRangeStart(previousNode, nextNode, currentSourceFile) ? 0 : 1; + else if (!ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) { + if (preserveSourceNewlines && siblingNodePositionsAreComparable(previousNode, nextNode)) { + return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); }); + } + // If `preserveSourceNewlines` is `false` we do not intend to preserve the effective lines between the + // previous and next node. Instead we naively check whether nodes are on separate lines within the + // same node parent. If so, we intend to preserve a single line terminator. This is less precise and + // expensive than checking with `preserveSourceNewlines` as above, but the goal is not to preserve the + // effective source lines between two sibling nodes. + else if (!preserveSourceNewlines && originalNodesHaveSameParent(previousNode, nextNode)) { + return ts.rangeEndIsOnSameLineAsRangeStart(previousNode, nextNode, currentSourceFile) ? 0 : 1; + } + // If the two nodes are not comparable, add a line terminator based on the format that can indicate + // whether new lines are preferred or not. + return format & 65536 /* PreferNewLine */ ? 1 : 0; } else if (synthesizedNodeStartsOnNewLine(previousNode, format) || synthesizedNodeStartsOnNewLine(nextNode, format)) { return 1; @@ -107940,10 +107957,13 @@ var ts; } exitComment(); } + function originalNodesHaveSameParent(nodeA, nodeB) { + nodeA = ts.getOriginalNode(nodeA); + // For performance, do not call `getOriginalNode` for `nodeB` if `nodeA` doesn't even + // have a parent node. + return nodeA.parent && nodeA.parent === ts.getOriginalNode(nodeB).parent; + } function siblingNodePositionsAreComparable(previousNode, nextNode) { - if (ts.nodeIsSynthesized(previousNode) || ts.nodeIsSynthesized(nextNode)) { - return false; - } if (nextNode.pos < previousNode.end) { return false; } @@ -113316,8 +113336,14 @@ var ts; var optionsNameMap = ts.getOptionsNameMap().optionsNameMap; for (var _i = 0, _a = ts.getOwnKeys(options).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) { var name = _a[_i]; - var optionInfo = optionsNameMap.get(name.toLowerCase()); - if ((optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsEmit) || (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsSemanticDiagnostics) || name === "skipLibCheck" || name === "skipDefaultLibCheck") { + var optionKey = name.toLowerCase(); + var optionInfo = optionsNameMap.get(optionKey); + if ((optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsEmit) || (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsSemanticDiagnostics) || + // We need to store `strict`, even though it won't be examined directly, so that the + // flags it controls (e.g. `strictNullChecks`) will be retrieved correctly from the buildinfo + optionKey === "strict" || + // We need to store these to determine whether `lib` files need to be rechecked. + optionKey === "skiplibcheck" || optionKey === "skipdefaultlibcheck") { (result || (result = {}))[name] = convertToReusableCompilerOptionValue(optionInfo, options[name], relativeToBuildInfo); } } diff --git a/lib/typescript.js b/lib/typescript.js index 615ad27f3f7d9..b3f80f1a315b2 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -290,7 +290,7 @@ var ts; // The following is baselined as a literal template type without intervention /** The version of the TypeScript compiler release */ // eslint-disable-next-line @typescript-eslint/no-inferrable-types - ts.version = "4.3.2"; + ts.version = "4.3.3"; /* @internal */ var Comparison; (function (Comparison) { @@ -29462,8 +29462,8 @@ var ts; visitNode(cbNode, node.typeExpression) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) : visitNode(cbNode, node.typeExpression) || - visitNode(cbNode, node.name)) || - (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + visitNode(cbNode, node.name) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment))); case 320 /* JSDocAuthorTag */: return visitNode(cbNode, node.tagName) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); @@ -37576,6 +37576,8 @@ var ts; { name: "strict", type: "boolean", + // Though this affects semantic diagnostics, affectsSemanticDiagnostics is not set here + // The value of each strictFlag depends on own strictFlag value or this and never accessed directly. showInSimplifiedHelpView: true, category: ts.Diagnostics.Strict_Type_Checking_Options, description: ts.Diagnostics.Enable_all_strict_type_checking_options @@ -59362,8 +59364,7 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.kind === 158 /* QualifiedName */ || - node.parent.kind === 174 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || + return !(node.parent.kind === 174 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || node.parent.kind === 196 /* ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); } function isTypeParameterPossiblyReferenced(tp, node) { @@ -59391,7 +59392,10 @@ var ts; return true; case 166 /* MethodDeclaration */: case 165 /* MethodSignature */: - return (!node.type && !!node.body) || !!ts.forEachChild(node, containsReference); + return !node.type && !!node.body || + ts.some(node.typeParameters, containsReference) || + ts.some(node.parameters, containsReference) || + !!node.type && containsReference(node.type); } return !!ts.forEachChild(node, containsReference); } @@ -64774,12 +64778,14 @@ var ts; applyToReturnTypes(source, target, inferFromTypes); } function inferFromIndexTypes(source, target) { + // Inferences across mapped type index signatures are pretty much the same a inferences to homomorphic variables + var priority = (ts.getObjectFlags(source) & ts.getObjectFlags(target) & 32 /* Mapped */) ? 8 /* HomomorphicMappedType */ : 0; var targetStringIndexType = getIndexTypeOfType(target, 0 /* String */); if (targetStringIndexType) { var sourceIndexType = getIndexTypeOfType(source, 0 /* String */) || getImplicitIndexTypeOfType(source, 0 /* String */); if (sourceIndexType) { - inferFromTypes(sourceIndexType, targetStringIndexType); + inferWithPriority(sourceIndexType, targetStringIndexType, priority); } } var targetNumberIndexType = getIndexTypeOfType(target, 1 /* Number */); @@ -64788,7 +64794,7 @@ var ts; getIndexTypeOfType(source, 0 /* String */) || getImplicitIndexTypeOfType(source, 1 /* Number */); if (sourceIndexType) { - inferFromTypes(sourceIndexType, targetNumberIndexType); + inferWithPriority(sourceIndexType, targetNumberIndexType, priority); } } } @@ -86104,6 +86110,7 @@ var ts; case 120 /* PrivateKeyword */: case 121 /* ProtectedKeyword */: case 125 /* AbstractKeyword */: + case 156 /* OverrideKeyword */: case 84 /* ConstKeyword */: case 133 /* DeclareKeyword */: case 142 /* ReadonlyKeyword */: @@ -107296,11 +107303,21 @@ var ts; // JsxText will be written with its leading whitespace, so don't add more manually. return 0; } - else if (preserveSourceNewlines && siblingNodePositionsAreComparable(previousNode, nextNode)) { - return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); }); - } - else if (!preserveSourceNewlines && !ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) { - return ts.rangeEndIsOnSameLineAsRangeStart(previousNode, nextNode, currentSourceFile) ? 0 : 1; + else if (!ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) { + if (preserveSourceNewlines && siblingNodePositionsAreComparable(previousNode, nextNode)) { + return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); }); + } + // If `preserveSourceNewlines` is `false` we do not intend to preserve the effective lines between the + // previous and next node. Instead we naively check whether nodes are on separate lines within the + // same node parent. If so, we intend to preserve a single line terminator. This is less precise and + // expensive than checking with `preserveSourceNewlines` as above, but the goal is not to preserve the + // effective source lines between two sibling nodes. + else if (!preserveSourceNewlines && originalNodesHaveSameParent(previousNode, nextNode)) { + return ts.rangeEndIsOnSameLineAsRangeStart(previousNode, nextNode, currentSourceFile) ? 0 : 1; + } + // If the two nodes are not comparable, add a line terminator based on the format that can indicate + // whether new lines are preferred or not. + return format & 65536 /* PreferNewLine */ ? 1 : 0; } else if (synthesizedNodeStartsOnNewLine(previousNode, format) || synthesizedNodeStartsOnNewLine(nextNode, format)) { return 1; @@ -107940,10 +107957,13 @@ var ts; } exitComment(); } + function originalNodesHaveSameParent(nodeA, nodeB) { + nodeA = ts.getOriginalNode(nodeA); + // For performance, do not call `getOriginalNode` for `nodeB` if `nodeA` doesn't even + // have a parent node. + return nodeA.parent && nodeA.parent === ts.getOriginalNode(nodeB).parent; + } function siblingNodePositionsAreComparable(previousNode, nextNode) { - if (ts.nodeIsSynthesized(previousNode) || ts.nodeIsSynthesized(nextNode)) { - return false; - } if (nextNode.pos < previousNode.end) { return false; } @@ -113316,8 +113336,14 @@ var ts; var optionsNameMap = ts.getOptionsNameMap().optionsNameMap; for (var _i = 0, _a = ts.getOwnKeys(options).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) { var name = _a[_i]; - var optionInfo = optionsNameMap.get(name.toLowerCase()); - if ((optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsEmit) || (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsSemanticDiagnostics) || name === "skipLibCheck" || name === "skipDefaultLibCheck") { + var optionKey = name.toLowerCase(); + var optionInfo = optionsNameMap.get(optionKey); + if ((optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsEmit) || (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsSemanticDiagnostics) || + // We need to store `strict`, even though it won't be examined directly, so that the + // flags it controls (e.g. `strictNullChecks`) will be retrieved correctly from the buildinfo + optionKey === "strict" || + // We need to store these to determine whether `lib` files need to be rechecked. + optionKey === "skiplibcheck" || optionKey === "skipdefaultlibcheck") { (result || (result = {}))[name] = convertToReusableCompilerOptionValue(optionInfo, options[name], relativeToBuildInfo); } } diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index 59f7d01b56ae8..78539cc744019 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -290,7 +290,7 @@ var ts; // The following is baselined as a literal template type without intervention /** The version of the TypeScript compiler release */ // eslint-disable-next-line @typescript-eslint/no-inferrable-types - ts.version = "4.3.2"; + ts.version = "4.3.3"; /* @internal */ var Comparison; (function (Comparison) { @@ -29462,8 +29462,8 @@ var ts; visitNode(cbNode, node.typeExpression) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) : visitNode(cbNode, node.typeExpression) || - visitNode(cbNode, node.name)) || - (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + visitNode(cbNode, node.name) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment))); case 320 /* JSDocAuthorTag */: return visitNode(cbNode, node.tagName) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); @@ -37576,6 +37576,8 @@ var ts; { name: "strict", type: "boolean", + // Though this affects semantic diagnostics, affectsSemanticDiagnostics is not set here + // The value of each strictFlag depends on own strictFlag value or this and never accessed directly. showInSimplifiedHelpView: true, category: ts.Diagnostics.Strict_Type_Checking_Options, description: ts.Diagnostics.Enable_all_strict_type_checking_options @@ -59362,8 +59364,7 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.kind === 158 /* QualifiedName */ || - node.parent.kind === 174 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || + return !(node.parent.kind === 174 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || node.parent.kind === 196 /* ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); } function isTypeParameterPossiblyReferenced(tp, node) { @@ -59391,7 +59392,10 @@ var ts; return true; case 166 /* MethodDeclaration */: case 165 /* MethodSignature */: - return (!node.type && !!node.body) || !!ts.forEachChild(node, containsReference); + return !node.type && !!node.body || + ts.some(node.typeParameters, containsReference) || + ts.some(node.parameters, containsReference) || + !!node.type && containsReference(node.type); } return !!ts.forEachChild(node, containsReference); } @@ -64774,12 +64778,14 @@ var ts; applyToReturnTypes(source, target, inferFromTypes); } function inferFromIndexTypes(source, target) { + // Inferences across mapped type index signatures are pretty much the same a inferences to homomorphic variables + var priority = (ts.getObjectFlags(source) & ts.getObjectFlags(target) & 32 /* Mapped */) ? 8 /* HomomorphicMappedType */ : 0; var targetStringIndexType = getIndexTypeOfType(target, 0 /* String */); if (targetStringIndexType) { var sourceIndexType = getIndexTypeOfType(source, 0 /* String */) || getImplicitIndexTypeOfType(source, 0 /* String */); if (sourceIndexType) { - inferFromTypes(sourceIndexType, targetStringIndexType); + inferWithPriority(sourceIndexType, targetStringIndexType, priority); } } var targetNumberIndexType = getIndexTypeOfType(target, 1 /* Number */); @@ -64788,7 +64794,7 @@ var ts; getIndexTypeOfType(source, 0 /* String */) || getImplicitIndexTypeOfType(source, 1 /* Number */); if (sourceIndexType) { - inferFromTypes(sourceIndexType, targetNumberIndexType); + inferWithPriority(sourceIndexType, targetNumberIndexType, priority); } } } @@ -86104,6 +86110,7 @@ var ts; case 120 /* PrivateKeyword */: case 121 /* ProtectedKeyword */: case 125 /* AbstractKeyword */: + case 156 /* OverrideKeyword */: case 84 /* ConstKeyword */: case 133 /* DeclareKeyword */: case 142 /* ReadonlyKeyword */: @@ -107296,11 +107303,21 @@ var ts; // JsxText will be written with its leading whitespace, so don't add more manually. return 0; } - else if (preserveSourceNewlines && siblingNodePositionsAreComparable(previousNode, nextNode)) { - return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); }); - } - else if (!preserveSourceNewlines && !ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) { - return ts.rangeEndIsOnSameLineAsRangeStart(previousNode, nextNode, currentSourceFile) ? 0 : 1; + else if (!ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) { + if (preserveSourceNewlines && siblingNodePositionsAreComparable(previousNode, nextNode)) { + return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); }); + } + // If `preserveSourceNewlines` is `false` we do not intend to preserve the effective lines between the + // previous and next node. Instead we naively check whether nodes are on separate lines within the + // same node parent. If so, we intend to preserve a single line terminator. This is less precise and + // expensive than checking with `preserveSourceNewlines` as above, but the goal is not to preserve the + // effective source lines between two sibling nodes. + else if (!preserveSourceNewlines && originalNodesHaveSameParent(previousNode, nextNode)) { + return ts.rangeEndIsOnSameLineAsRangeStart(previousNode, nextNode, currentSourceFile) ? 0 : 1; + } + // If the two nodes are not comparable, add a line terminator based on the format that can indicate + // whether new lines are preferred or not. + return format & 65536 /* PreferNewLine */ ? 1 : 0; } else if (synthesizedNodeStartsOnNewLine(previousNode, format) || synthesizedNodeStartsOnNewLine(nextNode, format)) { return 1; @@ -107940,10 +107957,13 @@ var ts; } exitComment(); } + function originalNodesHaveSameParent(nodeA, nodeB) { + nodeA = ts.getOriginalNode(nodeA); + // For performance, do not call `getOriginalNode` for `nodeB` if `nodeA` doesn't even + // have a parent node. + return nodeA.parent && nodeA.parent === ts.getOriginalNode(nodeB).parent; + } function siblingNodePositionsAreComparable(previousNode, nextNode) { - if (ts.nodeIsSynthesized(previousNode) || ts.nodeIsSynthesized(nextNode)) { - return false; - } if (nextNode.pos < previousNode.end) { return false; } @@ -113316,8 +113336,14 @@ var ts; var optionsNameMap = ts.getOptionsNameMap().optionsNameMap; for (var _i = 0, _a = ts.getOwnKeys(options).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) { var name = _a[_i]; - var optionInfo = optionsNameMap.get(name.toLowerCase()); - if ((optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsEmit) || (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsSemanticDiagnostics) || name === "skipLibCheck" || name === "skipDefaultLibCheck") { + var optionKey = name.toLowerCase(); + var optionInfo = optionsNameMap.get(optionKey); + if ((optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsEmit) || (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsSemanticDiagnostics) || + // We need to store `strict`, even though it won't be examined directly, so that the + // flags it controls (e.g. `strictNullChecks`) will be retrieved correctly from the buildinfo + optionKey === "strict" || + // We need to store these to determine whether `lib` files need to be rechecked. + optionKey === "skiplibcheck" || optionKey === "skipdefaultlibcheck") { (result || (result = {}))[name] = convertToReusableCompilerOptionValue(optionInfo, options[name], relativeToBuildInfo); } } diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js index 6810860b9c4b6..859392ce380af 100644 --- a/lib/typingsInstaller.js +++ b/lib/typingsInstaller.js @@ -85,7 +85,7 @@ var ts; // The following is baselined as a literal template type without intervention /** The version of the TypeScript compiler release */ // eslint-disable-next-line @typescript-eslint/no-inferrable-types - ts.version = "4.3.2"; + ts.version = "4.3.3"; /* @internal */ var Comparison; (function (Comparison) { @@ -29257,8 +29257,8 @@ var ts; visitNode(cbNode, node.typeExpression) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) : visitNode(cbNode, node.typeExpression) || - visitNode(cbNode, node.name)) || - (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + visitNode(cbNode, node.name) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment))); case 320 /* JSDocAuthorTag */: return visitNode(cbNode, node.tagName) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); @@ -37371,6 +37371,8 @@ var ts; { name: "strict", type: "boolean", + // Though this affects semantic diagnostics, affectsSemanticDiagnostics is not set here + // The value of each strictFlag depends on own strictFlag value or this and never accessed directly. showInSimplifiedHelpView: true, category: ts.Diagnostics.Strict_Type_Checking_Options, description: ts.Diagnostics.Enable_all_strict_type_checking_options @@ -59157,8 +59159,7 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.kind === 158 /* QualifiedName */ || - node.parent.kind === 174 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || + return !(node.parent.kind === 174 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || node.parent.kind === 196 /* ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); } function isTypeParameterPossiblyReferenced(tp, node) { @@ -59186,7 +59187,10 @@ var ts; return true; case 166 /* MethodDeclaration */: case 165 /* MethodSignature */: - return (!node.type && !!node.body) || !!ts.forEachChild(node, containsReference); + return !node.type && !!node.body || + ts.some(node.typeParameters, containsReference) || + ts.some(node.parameters, containsReference) || + !!node.type && containsReference(node.type); } return !!ts.forEachChild(node, containsReference); } @@ -64569,12 +64573,14 @@ var ts; applyToReturnTypes(source, target, inferFromTypes); } function inferFromIndexTypes(source, target) { + // Inferences across mapped type index signatures are pretty much the same a inferences to homomorphic variables + var priority = (ts.getObjectFlags(source) & ts.getObjectFlags(target) & 32 /* Mapped */) ? 8 /* HomomorphicMappedType */ : 0; var targetStringIndexType = getIndexTypeOfType(target, 0 /* String */); if (targetStringIndexType) { var sourceIndexType = getIndexTypeOfType(source, 0 /* String */) || getImplicitIndexTypeOfType(source, 0 /* String */); if (sourceIndexType) { - inferFromTypes(sourceIndexType, targetStringIndexType); + inferWithPriority(sourceIndexType, targetStringIndexType, priority); } } var targetNumberIndexType = getIndexTypeOfType(target, 1 /* Number */); @@ -64583,7 +64589,7 @@ var ts; getIndexTypeOfType(source, 0 /* String */) || getImplicitIndexTypeOfType(source, 1 /* Number */); if (sourceIndexType) { - inferFromTypes(sourceIndexType, targetNumberIndexType); + inferWithPriority(sourceIndexType, targetNumberIndexType, priority); } } } @@ -85899,6 +85905,7 @@ var ts; case 120 /* PrivateKeyword */: case 121 /* ProtectedKeyword */: case 125 /* AbstractKeyword */: + case 156 /* OverrideKeyword */: case 84 /* ConstKeyword */: case 133 /* DeclareKeyword */: case 142 /* ReadonlyKeyword */: @@ -107091,11 +107098,21 @@ var ts; // JsxText will be written with its leading whitespace, so don't add more manually. return 0; } - else if (preserveSourceNewlines && siblingNodePositionsAreComparable(previousNode, nextNode)) { - return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); }); - } - else if (!preserveSourceNewlines && !ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) { - return ts.rangeEndIsOnSameLineAsRangeStart(previousNode, nextNode, currentSourceFile) ? 0 : 1; + else if (!ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) { + if (preserveSourceNewlines && siblingNodePositionsAreComparable(previousNode, nextNode)) { + return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); }); + } + // If `preserveSourceNewlines` is `false` we do not intend to preserve the effective lines between the + // previous and next node. Instead we naively check whether nodes are on separate lines within the + // same node parent. If so, we intend to preserve a single line terminator. This is less precise and + // expensive than checking with `preserveSourceNewlines` as above, but the goal is not to preserve the + // effective source lines between two sibling nodes. + else if (!preserveSourceNewlines && originalNodesHaveSameParent(previousNode, nextNode)) { + return ts.rangeEndIsOnSameLineAsRangeStart(previousNode, nextNode, currentSourceFile) ? 0 : 1; + } + // If the two nodes are not comparable, add a line terminator based on the format that can indicate + // whether new lines are preferred or not. + return format & 65536 /* PreferNewLine */ ? 1 : 0; } else if (synthesizedNodeStartsOnNewLine(previousNode, format) || synthesizedNodeStartsOnNewLine(nextNode, format)) { return 1; @@ -107735,10 +107752,13 @@ var ts; } exitComment(); } + function originalNodesHaveSameParent(nodeA, nodeB) { + nodeA = ts.getOriginalNode(nodeA); + // For performance, do not call `getOriginalNode` for `nodeB` if `nodeA` doesn't even + // have a parent node. + return nodeA.parent && nodeA.parent === ts.getOriginalNode(nodeB).parent; + } function siblingNodePositionsAreComparable(previousNode, nextNode) { - if (ts.nodeIsSynthesized(previousNode) || ts.nodeIsSynthesized(nextNode)) { - return false; - } if (nextNode.pos < previousNode.end) { return false; } @@ -113111,8 +113131,14 @@ var ts; var optionsNameMap = ts.getOptionsNameMap().optionsNameMap; for (var _i = 0, _a = ts.getOwnKeys(options).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) { var name = _a[_i]; - var optionInfo = optionsNameMap.get(name.toLowerCase()); - if ((optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsEmit) || (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsSemanticDiagnostics) || name === "skipLibCheck" || name === "skipDefaultLibCheck") { + var optionKey = name.toLowerCase(); + var optionInfo = optionsNameMap.get(optionKey); + if ((optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsEmit) || (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsSemanticDiagnostics) || + // We need to store `strict`, even though it won't be examined directly, so that the + // flags it controls (e.g. `strictNullChecks`) will be retrieved correctly from the buildinfo + optionKey === "strict" || + // We need to store these to determine whether `lib` files need to be rechecked. + optionKey === "skiplibcheck" || optionKey === "skipdefaultlibcheck") { (result || (result = {}))[name] = convertToReusableCompilerOptionValue(optionInfo, options[name], relativeToBuildInfo); } } diff --git a/package.json b/package.json index 2f3518663a299..0f515e9766e5d 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "typescript", "author": "Microsoft Corp.", "homepage": "https://www.typescriptlang.org/", - "version": "4.3.2", + "version": "4.3.3", "license": "Apache-2.0", "description": "TypeScript is a language for application scale JavaScript development", "keywords": [ diff --git a/src/compiler/corePublic.ts b/src/compiler/corePublic.ts index ec1ec375ff1d3..8d3e8d5c8a4d7 100644 --- a/src/compiler/corePublic.ts +++ b/src/compiler/corePublic.ts @@ -5,7 +5,7 @@ namespace ts { // The following is baselined as a literal template type without intervention /** The version of the TypeScript compiler release */ // eslint-disable-next-line @typescript-eslint/no-inferrable-types - export const version = "4.3.2" as string; + export const version = "4.3.3" as string; /** * Type of objects whose values are all of the same type.