From f94406bc10be650eec2e87a4b9f740efa2c8f926 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 21 Jan 2022 11:01:36 +0000 Subject: [PATCH 1/2] chore(deps-dev): bump typescript from 4.5.4 to 4.5.5 Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.5.4 to 4.5.5. - [Release notes](https://github.com/Microsoft/TypeScript/releases) - [Commits](https://github.com/Microsoft/TypeScript/compare/v4.5.4...v4.5.5) --- updated-dependencies: - dependency-name: typescript dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- package-lock.json | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 13c0c5d86..cecfa234f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7420,9 +7420,9 @@ } }, "typescript": { - "version": "4.5.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.4.tgz", - "integrity": "sha512-VgYs2A2QIRuGphtzFV7aQJduJ2gyfTljngLzjpfW9FoYZF6xuw1W0vW9ghCKLfcWrCFxK81CSGRAvS1pn4fIUg==", + "version": "4.5.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.5.tgz", + "integrity": "sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==", "dev": true }, "union-value": { diff --git a/package.json b/package.json index 1f1c9170a..2f704da48 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "semver-regex": "^4.0.2", "set-value": "^4.1.0", "ts-jest": "^26.5.6", - "typescript": "^4.5.4" + "typescript": "^4.5.5" }, "husky": { "skipCI": true, From f3075cea113128a1df53fb91029d1ae69727826b Mon Sep 17 00:00:00 2001 From: jiro4989 Date: Fri, 21 Jan 2022 21:15:20 +0900 Subject: [PATCH 2/2] npm ci --- node_modules/.bin/tsc | 1 + node_modules/.bin/tsserver | 1 + node_modules/.package-lock.json | 15 ++- node_modules/typescript/lib/tsc.js | 29 ++++-- node_modules/typescript/lib/tsserver.js | 94 ++++++++++--------- .../typescript/lib/tsserverlibrary.js | 94 ++++++++++--------- node_modules/typescript/lib/typescript.js | 94 ++++++++++--------- .../typescript/lib/typescriptServices.js | 94 ++++++++++--------- .../typescript/lib/typingsInstaller.js | 32 +++++-- node_modules/typescript/package.json | 2 +- 10 files changed, 247 insertions(+), 209 deletions(-) create mode 120000 node_modules/.bin/tsc create mode 120000 node_modules/.bin/tsserver diff --git a/node_modules/.bin/tsc b/node_modules/.bin/tsc new file mode 120000 index 000000000..0863208a6 --- /dev/null +++ b/node_modules/.bin/tsc @@ -0,0 +1 @@ +../typescript/bin/tsc \ No newline at end of file diff --git a/node_modules/.bin/tsserver b/node_modules/.bin/tsserver new file mode 120000 index 000000000..f8f8f1a0c --- /dev/null +++ b/node_modules/.bin/tsserver @@ -0,0 +1 @@ +../typescript/bin/tsserver \ No newline at end of file diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json index bafe9687a..118cebd55 100644 --- a/node_modules/.package-lock.json +++ b/node_modules/.package-lock.json @@ -9234,10 +9234,17 @@ } }, "node_modules/typescript": { - "version": "4.5.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.4.tgz", - "integrity": "sha512-VgYs2A2QIRuGphtzFV7aQJduJ2gyfTljngLzjpfW9FoYZF6xuw1W0vW9ghCKLfcWrCFxK81CSGRAvS1pn4fIUg==", - "dev": true + "version": "4.5.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.5.tgz", + "integrity": "sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } }, "node_modules/union-value": { "version": "1.0.1", diff --git a/node_modules/typescript/lib/tsc.js b/node_modules/typescript/lib/tsc.js index e843aa177..e144201b5 100644 --- a/node_modules/typescript/lib/tsc.js +++ b/node_modules/typescript/lib/tsc.js @@ -69,7 +69,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { var ts; (function (ts) { ts.versionMajorMinor = "4.5"; - ts.version = "4.5.4"; + ts.version = "4.5.5"; var NativeCollections; (function (NativeCollections) { function tryGetNativeMap() { @@ -12247,7 +12247,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function getExternalModuleRequireArgument(node) { - return isRequireVariableDeclaration(node) && getLeftmostAccessExpression(node.initializer).arguments[0]; + return isVariableDeclarationInitializedToBareOrAccessedRequire(node) && getLeftmostAccessExpression(node.initializer).arguments[0]; } ts.getExternalModuleRequireArgument = getExternalModuleRequireArgument; function isInternalModuleImportEqualsDeclaration(node) { @@ -12301,17 +12301,26 @@ var ts; return !requireStringLiteralLikeArgument || ts.isStringLiteralLike(arg); } ts.isRequireCall = isRequireCall; - function isRequireVariableDeclaration(node) { + function isVariableDeclarationInitializedToRequire(node) { + return isVariableDeclarationInitializedWithRequireHelper(node, false); + } + ts.isVariableDeclarationInitializedToRequire = isVariableDeclarationInitializedToRequire; + function isVariableDeclarationInitializedToBareOrAccessedRequire(node) { + return isVariableDeclarationInitializedWithRequireHelper(node, true); + } + ts.isVariableDeclarationInitializedToBareOrAccessedRequire = isVariableDeclarationInitializedToBareOrAccessedRequire; + function isVariableDeclarationInitializedWithRequireHelper(node, allowAccessedRequire) { if (node.kind === 202) { node = node.parent.parent; } - return ts.isVariableDeclaration(node) && !!node.initializer && isRequireCall(getLeftmostAccessExpression(node.initializer), true); + return ts.isVariableDeclaration(node) && + !!node.initializer && + isRequireCall(allowAccessedRequire ? getLeftmostAccessExpression(node.initializer) : node.initializer, true); } - ts.isRequireVariableDeclaration = isRequireVariableDeclaration; function isRequireVariableStatement(node) { return ts.isVariableStatement(node) && node.declarationList.declarations.length > 0 - && ts.every(node.declarationList.declarations, function (decl) { return isRequireVariableDeclaration(decl); }); + && ts.every(node.declarationList.declarations, function (decl) { return isVariableDeclarationInitializedToRequire(decl); }); } ts.isRequireVariableStatement = isRequireVariableStatement; function isSingleOrDoubleQuote(charCode) { @@ -37770,7 +37779,7 @@ var ts; checkStrictModeEvalOrArguments(node, node.name); } if (!ts.isBindingPattern(node.name)) { - if (ts.isInJSFile(node) && ts.isRequireVariableDeclaration(node) && !ts.getJSDocTypeTag(node)) { + if (ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) && !ts.getJSDocTypeTag(node)) { declareSymbolAndAddToSymbolTable(node, 2097152, 2097152); } else if (ts.isBlockOrCatchScoped(node)) { @@ -40045,7 +40054,7 @@ var ts; && isAliasableOrJsExpression(node.parent.right) || node.kind === 295 || node.kind === 294 && isAliasableOrJsExpression(node.initializer) - || ts.isRequireVariableDeclaration(node); + || ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node); } function isAliasableOrJsExpression(e) { return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e); @@ -40901,7 +40910,7 @@ var ts; if (!sigs || !sigs.length) { sigs = getSignaturesOfStructuredType(type, 1); } - if ((sigs && sigs.length) || getPropertyOfType(type, "default")) { + if ((sigs && sigs.length) || getPropertyOfType(type, "default", true)) { var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol, reference); return cloneTypeAsModuleType(symbol, moduleType, referenceParent); } @@ -67235,7 +67244,7 @@ var ts; return; } var symbol = getSymbolOfNode(node); - if (symbol.flags & 2097152 && ts.isRequireVariableDeclaration(node)) { + if (symbol.flags & 2097152 && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)) { checkAliasSymbol(node); return; } diff --git a/node_modules/typescript/lib/tsserver.js b/node_modules/typescript/lib/tsserver.js index 028346841..6499e34af 100644 --- a/node_modules/typescript/lib/tsserver.js +++ b/node_modules/typescript/lib/tsserver.js @@ -100,7 +100,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.5.4"; + ts.version = "4.5.5"; /* @internal */ var Comparison; (function (Comparison) { @@ -15839,7 +15839,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function getExternalModuleRequireArgument(node) { - return isRequireVariableDeclaration(node) && getLeftmostAccessExpression(node.initializer).arguments[0]; + return isVariableDeclarationInitializedToBareOrAccessedRequire(node) && getLeftmostAccessExpression(node.initializer).arguments[0]; } ts.getExternalModuleRequireArgument = getExternalModuleRequireArgument; function isInternalModuleImportEqualsDeclaration(node) { @@ -15897,17 +15897,29 @@ var ts; * Returns true if the node is a VariableDeclaration initialized to a require call (see `isRequireCall`). * This function does not test if the node is in a JavaScript file or not. */ - function isRequireVariableDeclaration(node) { + function isVariableDeclarationInitializedToRequire(node) { + return isVariableDeclarationInitializedWithRequireHelper(node, /*allowAccessedRequire*/ false); + } + ts.isVariableDeclarationInitializedToRequire = isVariableDeclarationInitializedToRequire; + /** + * Like {@link isVariableDeclarationInitializedToRequire} but allows things like `require("...").foo.bar` or `require("...")["baz"]`. + */ + function isVariableDeclarationInitializedToBareOrAccessedRequire(node) { + return isVariableDeclarationInitializedWithRequireHelper(node, /*allowAccessedRequire*/ true); + } + ts.isVariableDeclarationInitializedToBareOrAccessedRequire = isVariableDeclarationInitializedToBareOrAccessedRequire; + function isVariableDeclarationInitializedWithRequireHelper(node, allowAccessedRequire) { if (node.kind === 202 /* BindingElement */) { node = node.parent.parent; } - return ts.isVariableDeclaration(node) && !!node.initializer && isRequireCall(getLeftmostAccessExpression(node.initializer), /*requireStringLiteralLikeArgument*/ true); + return ts.isVariableDeclaration(node) && + !!node.initializer && + isRequireCall(allowAccessedRequire ? getLeftmostAccessExpression(node.initializer) : node.initializer, /*requireStringLiteralLikeArgument*/ true); } - ts.isRequireVariableDeclaration = isRequireVariableDeclaration; function isRequireVariableStatement(node) { return ts.isVariableStatement(node) && node.declarationList.declarations.length > 0 - && ts.every(node.declarationList.declarations, function (decl) { return isRequireVariableDeclaration(decl); }); + && ts.every(node.declarationList.declarations, function (decl) { return isVariableDeclarationInitializedToRequire(decl); }); } ts.isRequireVariableStatement = isRequireVariableStatement; function isSingleOrDoubleQuote(charCode) { @@ -46064,7 +46076,7 @@ var ts; checkStrictModeEvalOrArguments(node, node.name); } if (!ts.isBindingPattern(node.name)) { - if (ts.isInJSFile(node) && ts.isRequireVariableDeclaration(node) && !ts.getJSDocTypeTag(node)) { + if (ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) && !ts.getJSDocTypeTag(node)) { declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); } else if (ts.isBlockOrCatchScoped(node)) { @@ -48843,7 +48855,7 @@ var ts; && isAliasableOrJsExpression(node.parent.right) || node.kind === 295 /* ShorthandPropertyAssignment */ || node.kind === 294 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer) - || ts.isRequireVariableDeclaration(node); + || ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node); } function isAliasableOrJsExpression(e) { return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e); @@ -49814,7 +49826,7 @@ var ts; if (!sigs || !sigs.length) { sigs = getSignaturesOfStructuredType(type, 1 /* Construct */); } - if ((sigs && sigs.length) || getPropertyOfType(type, "default" /* Default */)) { + if ((sigs && sigs.length) || getPropertyOfType(type, "default" /* Default */, /*skipObjectFunctionPropertyAugment*/ true)) { var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol, reference); return cloneTypeAsModuleType(symbol, moduleType, referenceParent); } @@ -80246,7 +80258,7 @@ var ts; } // For a commonjs `const x = require`, validate the alias and exit var symbol = getSymbolOfNode(node); - if (symbol.flags & 2097152 /* Alias */ && ts.isRequireVariableDeclaration(node)) { + if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)) { checkAliasSymbol(node); return; } @@ -123955,7 +123967,7 @@ var ts; isWhiteSpaceOnlyJsxText(child); if (lookInPreviousChild) { // actual start of the node is past the position - previous token should be at the end of previous child - var candidate_1 = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i, sourceFile); + var candidate_1 = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i, sourceFile, n.kind); return candidate_1 && findRightmostToken(candidate_1, sourceFile); } else { @@ -123969,7 +123981,7 @@ var ts; // 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. // Namely we are skipping the check: 'position < node.end' - var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length, sourceFile); + var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length, sourceFile, n.kind); return candidate && findRightmostToken(candidate, sourceFile); } } @@ -123985,17 +123997,19 @@ var ts; if (children.length === 0) { return n; } - var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length, sourceFile); + var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length, sourceFile, n.kind); return candidate && findRightmostToken(candidate, sourceFile); } /** * Finds the rightmost child to the left of `children[exclusiveStartPosition]` which is a non-all-whitespace token or has constituent tokens. */ - function findRightmostChildNodeWithTokens(children, exclusiveStartPosition, sourceFile) { + function findRightmostChildNodeWithTokens(children, exclusiveStartPosition, sourceFile, parentKind) { for (var i = exclusiveStartPosition - 1; i >= 0; i--) { var child = children[i]; if (isWhiteSpaceOnlyJsxText(child)) { - ts.Debug.assert(i > 0, "`JsxText` tokens should not be the first child of `JsxElement | JsxSelfClosingElement`"); + if (i === 0 && (parentKind === 11 /* JsxText */ || parentKind === 278 /* JsxSelfClosingElement */)) { + ts.Debug.fail("`JsxText` tokens should not be the first child of `JsxElement | JsxSelfClosingElement`"); + } } else if (nodeHasTokens(children[i], sourceFile)) { return children[i]; @@ -128412,7 +128426,7 @@ var ts; return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined; } function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences) { - var symbols = completionData.symbols, contextToken = completionData.contextToken, completionKind = completionData.completionKind, isInSnippetScope = completionData.isInSnippetScope, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, propertyAccessToConvert = completionData.propertyAccessToConvert, keywordFilters = completionData.keywordFilters, literals = completionData.literals, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, recommendedCompletion = completionData.recommendedCompletion, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation, isJsxIdentifierExpected = completionData.isJsxIdentifierExpected, importCompletionNode = completionData.importCompletionNode, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextIdMap = completionData.symbolToSortTextIdMap, hasUnresolvedAutoImports = completionData.hasUnresolvedAutoImports; + var symbols = completionData.symbols, contextToken = completionData.contextToken, completionKind = completionData.completionKind, isInSnippetScope = completionData.isInSnippetScope, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, propertyAccessToConvert = completionData.propertyAccessToConvert, keywordFilters = completionData.keywordFilters, literals = completionData.literals, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, recommendedCompletion = completionData.recommendedCompletion, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation, isJsxIdentifierExpected = completionData.isJsxIdentifierExpected, isRightOfOpenTag = completionData.isRightOfOpenTag, importCompletionNode = completionData.importCompletionNode, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextIdMap = completionData.symbolToSortTextIdMap, hasUnresolvedAutoImports = completionData.hasUnresolvedAutoImports; // Verify if the file is JSX language variant if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* JSX */) { var completionInfo = getJsxClosingTagCompletion(location, sourceFile); @@ -128423,7 +128437,7 @@ var ts; var entries = []; if (isUncheckedFile(sourceFile, compilerOptions)) { var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, - /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap); + /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap, isJsxIdentifierExpected, isRightOfOpenTag); getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries); // TODO: GH#18217 } else { @@ -128431,7 +128445,7 @@ var ts; return undefined; } getCompletionEntriesFromSymbols(symbols, entries, - /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap); + /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap, isJsxIdentifierExpected, isRightOfOpenTag); } if (keywordFilters !== 0 /* None */) { var entryNames = new ts.Set(entries.map(function (e) { return e.name; })); @@ -128537,7 +128551,7 @@ var ts; function createCompletionEntryForLiteral(sourceFile, preferences, literal) { return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: SortText.LocationPriority }; } - function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences, completionKind) { + function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences, completionKind, isJsxIdentifierExpected, isRightOfOpenTag) { var _a, _b; var insertText; var replacementSpan = ts.getReplacementSpanForContextToken(replacementToken); @@ -128608,24 +128622,7 @@ var ts; source = CompletionSource.ClassMemberSnippet; } } - // Before offering up a JSX attribute snippet, ensure that we aren't potentially completing - // a tag name; this may appear as an attribute after the "<" when the tag has not yet been - // closed, as in: - // - // return <> - // foo - // - // We can detect this case by checking if both: - // - // 1. The location is "<", so we are completing immediately after it. - // 2. The "<" has the same position as its parent, so is not a binary expression. - var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location); - if (kind === "JSX attribute" /* jsxAttribute */ - && (location.kind !== 29 /* LessThanToken */ || location.pos !== location.parent.pos) - && preferences.includeCompletionsWithSnippetText - && preferences.jsxAttributeCompletionStyle - && preferences.jsxAttributeCompletionStyle !== "none") { + if (isJsxIdentifierExpected && !isRightOfOpenTag && preferences.includeCompletionsWithSnippetText && preferences.jsxAttributeCompletionStyle && preferences.jsxAttributeCompletionStyle !== "none") { var useBraces_1 = preferences.jsxAttributeCompletionStyle === "braces"; var type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); // If is boolean like or undefined, don't return a snippet we want just to return the completion. @@ -128663,7 +128660,7 @@ var ts; // entries (like JavaScript identifier entries). return { name: name, - kind: kind, + kind: ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location), kindModifiers: ts.SymbolDisplay.getSymbolModifiers(typeChecker, symbol), sortText: sortText, source: source, @@ -128938,7 +128935,7 @@ var ts; return CompletionSource.ThisProperty; } } - function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap) { + function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap, isJsxIdentifierExpected, isRightOfOpenTag) { var _a; var start = ts.timestamp(); var variableDeclaration = getVariableDeclaration(location); @@ -128959,7 +128956,7 @@ var ts; var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess; var sortTextId = (_a = symbolToSortTextIdMap === null || symbolToSortTextIdMap === void 0 ? void 0 : symbolToSortTextIdMap[ts.getSymbolId(symbol)]) !== null && _a !== void 0 ? _a : 11 /* LocationPriority */; var sortText = (isDeprecated(symbol, typeChecker) ? 8 /* DeprecatedOffset */ + sortTextId : sortTextId).toString(); - var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences, kind); + var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences, kind, isJsxIdentifierExpected, isRightOfOpenTag); if (!entry) { continue; } @@ -129553,6 +129550,7 @@ var ts; symbolToSortTextIdMap: symbolToSortTextIdMap, isTypeOnlyLocation: isTypeOnlyLocation, isJsxIdentifierExpected: isJsxIdentifierExpected, + isRightOfOpenTag: isRightOfOpenTag, importCompletionNode: importCompletionNode, hasUnresolvedAutoImports: hasUnresolvedAutoImports, }; @@ -132484,7 +132482,7 @@ var ts; ts.Debug.assert(parent.name === node); return true; case 202 /* BindingElement */: - return ts.isInJSFile(node) && ts.isRequireVariableDeclaration(parent); + return ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(parent); default: return false; } @@ -133884,7 +133882,7 @@ var ts; // Use the parent symbol if the location is commonjs require syntax on javascript files only. if (ts.isInJSFile(referenceLocation) && referenceLocation.parent.kind === 202 /* BindingElement */ - && ts.isRequireVariableDeclaration(referenceLocation.parent)) { + && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent)) { referenceSymbol = referenceLocation.parent.symbol; // The parent will not have a symbol if it's an ObjectBindingPattern (when destructuring is used). In // this case, just skip it, since the bound identifiers are not an alias of the import. @@ -135591,7 +135589,7 @@ var ts; return declaration.parent.kind === 268 /* NamedImports */; case 202 /* BindingElement */: case 253 /* VariableDeclaration */: - return ts.isInJSFile(declaration) && ts.isRequireVariableDeclaration(declaration); + return ts.isInJSFile(declaration) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(declaration); default: return false; } @@ -136874,6 +136872,9 @@ var ts; // We use 1 NavNode to represent 'A.B.C', but there are multiple source nodes. // Only merge module nodes that have the same chain. Don't merge 'A.B.C' with 'A'! function areSameModule(a, b) { + if (!a.body || !b.body) { + return a.body === b.body; + } return a.body.kind === b.body.kind && (a.body.kind !== 260 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); } /** Merge source into target. Source should be thrown away after this is called. */ @@ -148623,7 +148624,7 @@ var ts; var importKind = getImportKind(importingFile, exportKind, compilerOptions); return ts.mapDefined(importingFile.imports, function (moduleSpecifier) { var i = ts.importFromModuleSpecifier(moduleSpecifier); - if (ts.isRequireVariableDeclaration(i.parent)) { + if (ts.isVariableDeclarationInitializedToRequire(i.parent)) { return checker.resolveExternalModuleName(moduleSpecifier) === moduleSymbol ? { declaration: i.parent, importKind: importKind, symbol: symbol, targetFlags: targetFlags } : undefined; } if (i.kind === 265 /* ImportDeclaration */ || i.kind === 264 /* ImportEqualsDeclaration */) { @@ -156683,11 +156684,12 @@ var ts; var result = []; return visitor(selection) ? undefined : result; function visitor(node) { + var _a; if (ts.isTypeReferenceNode(node)) { if (ts.isIdentifier(node.typeName)) { var symbol = checker.resolveName(node.typeName.text, node.typeName, 262144 /* TypeParameter */, /* excludeGlobals */ true); - if (symbol === null || symbol === void 0 ? void 0 : symbol.declarations) { - var declaration = ts.cast(ts.first(symbol.declarations), ts.isTypeParameterDeclaration); + var declaration = ts.tryCast((_a = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _a === void 0 ? void 0 : _a[0], ts.isTypeParameterDeclaration); + if (declaration) { if (rangeContainsSkipTrivia(statement, declaration, file) && !rangeContainsSkipTrivia(selection, declaration, file)) { ts.pushIfUnique(result, declaration); } diff --git a/node_modules/typescript/lib/tsserverlibrary.js b/node_modules/typescript/lib/tsserverlibrary.js index 1db4e4a04..160c6c94d 100644 --- a/node_modules/typescript/lib/tsserverlibrary.js +++ b/node_modules/typescript/lib/tsserverlibrary.js @@ -294,7 +294,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.5.4"; + ts.version = "4.5.5"; /* @internal */ var Comparison; (function (Comparison) { @@ -16033,7 +16033,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function getExternalModuleRequireArgument(node) { - return isRequireVariableDeclaration(node) && getLeftmostAccessExpression(node.initializer).arguments[0]; + return isVariableDeclarationInitializedToBareOrAccessedRequire(node) && getLeftmostAccessExpression(node.initializer).arguments[0]; } ts.getExternalModuleRequireArgument = getExternalModuleRequireArgument; function isInternalModuleImportEqualsDeclaration(node) { @@ -16091,17 +16091,29 @@ var ts; * Returns true if the node is a VariableDeclaration initialized to a require call (see `isRequireCall`). * This function does not test if the node is in a JavaScript file or not. */ - function isRequireVariableDeclaration(node) { + function isVariableDeclarationInitializedToRequire(node) { + return isVariableDeclarationInitializedWithRequireHelper(node, /*allowAccessedRequire*/ false); + } + ts.isVariableDeclarationInitializedToRequire = isVariableDeclarationInitializedToRequire; + /** + * Like {@link isVariableDeclarationInitializedToRequire} but allows things like `require("...").foo.bar` or `require("...")["baz"]`. + */ + function isVariableDeclarationInitializedToBareOrAccessedRequire(node) { + return isVariableDeclarationInitializedWithRequireHelper(node, /*allowAccessedRequire*/ true); + } + ts.isVariableDeclarationInitializedToBareOrAccessedRequire = isVariableDeclarationInitializedToBareOrAccessedRequire; + function isVariableDeclarationInitializedWithRequireHelper(node, allowAccessedRequire) { if (node.kind === 202 /* BindingElement */) { node = node.parent.parent; } - return ts.isVariableDeclaration(node) && !!node.initializer && isRequireCall(getLeftmostAccessExpression(node.initializer), /*requireStringLiteralLikeArgument*/ true); + return ts.isVariableDeclaration(node) && + !!node.initializer && + isRequireCall(allowAccessedRequire ? getLeftmostAccessExpression(node.initializer) : node.initializer, /*requireStringLiteralLikeArgument*/ true); } - ts.isRequireVariableDeclaration = isRequireVariableDeclaration; function isRequireVariableStatement(node) { return ts.isVariableStatement(node) && node.declarationList.declarations.length > 0 - && ts.every(node.declarationList.declarations, function (decl) { return isRequireVariableDeclaration(decl); }); + && ts.every(node.declarationList.declarations, function (decl) { return isVariableDeclarationInitializedToRequire(decl); }); } ts.isRequireVariableStatement = isRequireVariableStatement; function isSingleOrDoubleQuote(charCode) { @@ -46258,7 +46270,7 @@ var ts; checkStrictModeEvalOrArguments(node, node.name); } if (!ts.isBindingPattern(node.name)) { - if (ts.isInJSFile(node) && ts.isRequireVariableDeclaration(node) && !ts.getJSDocTypeTag(node)) { + if (ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) && !ts.getJSDocTypeTag(node)) { declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); } else if (ts.isBlockOrCatchScoped(node)) { @@ -49037,7 +49049,7 @@ var ts; && isAliasableOrJsExpression(node.parent.right) || node.kind === 295 /* ShorthandPropertyAssignment */ || node.kind === 294 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer) - || ts.isRequireVariableDeclaration(node); + || ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node); } function isAliasableOrJsExpression(e) { return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e); @@ -50008,7 +50020,7 @@ var ts; if (!sigs || !sigs.length) { sigs = getSignaturesOfStructuredType(type, 1 /* Construct */); } - if ((sigs && sigs.length) || getPropertyOfType(type, "default" /* Default */)) { + if ((sigs && sigs.length) || getPropertyOfType(type, "default" /* Default */, /*skipObjectFunctionPropertyAugment*/ true)) { var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol, reference); return cloneTypeAsModuleType(symbol, moduleType, referenceParent); } @@ -80440,7 +80452,7 @@ var ts; } // For a commonjs `const x = require`, validate the alias and exit var symbol = getSymbolOfNode(node); - if (symbol.flags & 2097152 /* Alias */ && ts.isRequireVariableDeclaration(node)) { + if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)) { checkAliasSymbol(node); return; } @@ -124537,7 +124549,7 @@ var ts; isWhiteSpaceOnlyJsxText(child); if (lookInPreviousChild) { // actual start of the node is past the position - previous token should be at the end of previous child - var candidate_1 = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i, sourceFile); + var candidate_1 = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i, sourceFile, n.kind); return candidate_1 && findRightmostToken(candidate_1, sourceFile); } else { @@ -124551,7 +124563,7 @@ var ts; // 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. // Namely we are skipping the check: 'position < node.end' - var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length, sourceFile); + var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length, sourceFile, n.kind); return candidate && findRightmostToken(candidate, sourceFile); } } @@ -124567,17 +124579,19 @@ var ts; if (children.length === 0) { return n; } - var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length, sourceFile); + var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length, sourceFile, n.kind); return candidate && findRightmostToken(candidate, sourceFile); } /** * Finds the rightmost child to the left of `children[exclusiveStartPosition]` which is a non-all-whitespace token or has constituent tokens. */ - function findRightmostChildNodeWithTokens(children, exclusiveStartPosition, sourceFile) { + function findRightmostChildNodeWithTokens(children, exclusiveStartPosition, sourceFile, parentKind) { for (var i = exclusiveStartPosition - 1; i >= 0; i--) { var child = children[i]; if (isWhiteSpaceOnlyJsxText(child)) { - ts.Debug.assert(i > 0, "`JsxText` tokens should not be the first child of `JsxElement | JsxSelfClosingElement`"); + if (i === 0 && (parentKind === 11 /* JsxText */ || parentKind === 278 /* JsxSelfClosingElement */)) { + ts.Debug.fail("`JsxText` tokens should not be the first child of `JsxElement | JsxSelfClosingElement`"); + } } else if (nodeHasTokens(children[i], sourceFile)) { return children[i]; @@ -128994,7 +129008,7 @@ var ts; return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined; } function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences) { - var symbols = completionData.symbols, contextToken = completionData.contextToken, completionKind = completionData.completionKind, isInSnippetScope = completionData.isInSnippetScope, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, propertyAccessToConvert = completionData.propertyAccessToConvert, keywordFilters = completionData.keywordFilters, literals = completionData.literals, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, recommendedCompletion = completionData.recommendedCompletion, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation, isJsxIdentifierExpected = completionData.isJsxIdentifierExpected, importCompletionNode = completionData.importCompletionNode, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextIdMap = completionData.symbolToSortTextIdMap, hasUnresolvedAutoImports = completionData.hasUnresolvedAutoImports; + var symbols = completionData.symbols, contextToken = completionData.contextToken, completionKind = completionData.completionKind, isInSnippetScope = completionData.isInSnippetScope, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, propertyAccessToConvert = completionData.propertyAccessToConvert, keywordFilters = completionData.keywordFilters, literals = completionData.literals, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, recommendedCompletion = completionData.recommendedCompletion, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation, isJsxIdentifierExpected = completionData.isJsxIdentifierExpected, isRightOfOpenTag = completionData.isRightOfOpenTag, importCompletionNode = completionData.importCompletionNode, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextIdMap = completionData.symbolToSortTextIdMap, hasUnresolvedAutoImports = completionData.hasUnresolvedAutoImports; // Verify if the file is JSX language variant if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* JSX */) { var completionInfo = getJsxClosingTagCompletion(location, sourceFile); @@ -129005,7 +129019,7 @@ var ts; var entries = []; if (isUncheckedFile(sourceFile, compilerOptions)) { var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, - /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap); + /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap, isJsxIdentifierExpected, isRightOfOpenTag); getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries); // TODO: GH#18217 } else { @@ -129013,7 +129027,7 @@ var ts; return undefined; } getCompletionEntriesFromSymbols(symbols, entries, - /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap); + /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap, isJsxIdentifierExpected, isRightOfOpenTag); } if (keywordFilters !== 0 /* None */) { var entryNames = new ts.Set(entries.map(function (e) { return e.name; })); @@ -129119,7 +129133,7 @@ var ts; function createCompletionEntryForLiteral(sourceFile, preferences, literal) { return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: SortText.LocationPriority }; } - function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences, completionKind) { + function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences, completionKind, isJsxIdentifierExpected, isRightOfOpenTag) { var _a, _b; var insertText; var replacementSpan = ts.getReplacementSpanForContextToken(replacementToken); @@ -129190,24 +129204,7 @@ var ts; source = CompletionSource.ClassMemberSnippet; } } - // Before offering up a JSX attribute snippet, ensure that we aren't potentially completing - // a tag name; this may appear as an attribute after the "<" when the tag has not yet been - // closed, as in: - // - // return <> - // foo - // - // We can detect this case by checking if both: - // - // 1. The location is "<", so we are completing immediately after it. - // 2. The "<" has the same position as its parent, so is not a binary expression. - var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location); - if (kind === "JSX attribute" /* jsxAttribute */ - && (location.kind !== 29 /* LessThanToken */ || location.pos !== location.parent.pos) - && preferences.includeCompletionsWithSnippetText - && preferences.jsxAttributeCompletionStyle - && preferences.jsxAttributeCompletionStyle !== "none") { + if (isJsxIdentifierExpected && !isRightOfOpenTag && preferences.includeCompletionsWithSnippetText && preferences.jsxAttributeCompletionStyle && preferences.jsxAttributeCompletionStyle !== "none") { var useBraces_1 = preferences.jsxAttributeCompletionStyle === "braces"; var type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); // If is boolean like or undefined, don't return a snippet we want just to return the completion. @@ -129245,7 +129242,7 @@ var ts; // entries (like JavaScript identifier entries). return { name: name, - kind: kind, + kind: ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location), kindModifiers: ts.SymbolDisplay.getSymbolModifiers(typeChecker, symbol), sortText: sortText, source: source, @@ -129520,7 +129517,7 @@ var ts; return CompletionSource.ThisProperty; } } - function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap) { + function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap, isJsxIdentifierExpected, isRightOfOpenTag) { var _a; var start = ts.timestamp(); var variableDeclaration = getVariableDeclaration(location); @@ -129541,7 +129538,7 @@ var ts; var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess; var sortTextId = (_a = symbolToSortTextIdMap === null || symbolToSortTextIdMap === void 0 ? void 0 : symbolToSortTextIdMap[ts.getSymbolId(symbol)]) !== null && _a !== void 0 ? _a : 11 /* LocationPriority */; var sortText = (isDeprecated(symbol, typeChecker) ? 8 /* DeprecatedOffset */ + sortTextId : sortTextId).toString(); - var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences, kind); + var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences, kind, isJsxIdentifierExpected, isRightOfOpenTag); if (!entry) { continue; } @@ -130135,6 +130132,7 @@ var ts; symbolToSortTextIdMap: symbolToSortTextIdMap, isTypeOnlyLocation: isTypeOnlyLocation, isJsxIdentifierExpected: isJsxIdentifierExpected, + isRightOfOpenTag: isRightOfOpenTag, importCompletionNode: importCompletionNode, hasUnresolvedAutoImports: hasUnresolvedAutoImports, }; @@ -133066,7 +133064,7 @@ var ts; ts.Debug.assert(parent.name === node); return true; case 202 /* BindingElement */: - return ts.isInJSFile(node) && ts.isRequireVariableDeclaration(parent); + return ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(parent); default: return false; } @@ -134466,7 +134464,7 @@ var ts; // Use the parent symbol if the location is commonjs require syntax on javascript files only. if (ts.isInJSFile(referenceLocation) && referenceLocation.parent.kind === 202 /* BindingElement */ - && ts.isRequireVariableDeclaration(referenceLocation.parent)) { + && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent)) { referenceSymbol = referenceLocation.parent.symbol; // The parent will not have a symbol if it's an ObjectBindingPattern (when destructuring is used). In // this case, just skip it, since the bound identifiers are not an alias of the import. @@ -136173,7 +136171,7 @@ var ts; return declaration.parent.kind === 268 /* NamedImports */; case 202 /* BindingElement */: case 253 /* VariableDeclaration */: - return ts.isInJSFile(declaration) && ts.isRequireVariableDeclaration(declaration); + return ts.isInJSFile(declaration) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(declaration); default: return false; } @@ -137456,6 +137454,9 @@ var ts; // We use 1 NavNode to represent 'A.B.C', but there are multiple source nodes. // Only merge module nodes that have the same chain. Don't merge 'A.B.C' with 'A'! function areSameModule(a, b) { + if (!a.body || !b.body) { + return a.body === b.body; + } return a.body.kind === b.body.kind && (a.body.kind !== 260 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); } /** Merge source into target. Source should be thrown away after this is called. */ @@ -149205,7 +149206,7 @@ var ts; var importKind = getImportKind(importingFile, exportKind, compilerOptions); return ts.mapDefined(importingFile.imports, function (moduleSpecifier) { var i = ts.importFromModuleSpecifier(moduleSpecifier); - if (ts.isRequireVariableDeclaration(i.parent)) { + if (ts.isVariableDeclarationInitializedToRequire(i.parent)) { return checker.resolveExternalModuleName(moduleSpecifier) === moduleSymbol ? { declaration: i.parent, importKind: importKind, symbol: symbol, targetFlags: targetFlags } : undefined; } if (i.kind === 265 /* ImportDeclaration */ || i.kind === 264 /* ImportEqualsDeclaration */) { @@ -157265,11 +157266,12 @@ var ts; var result = []; return visitor(selection) ? undefined : result; function visitor(node) { + var _a; if (ts.isTypeReferenceNode(node)) { if (ts.isIdentifier(node.typeName)) { var symbol = checker.resolveName(node.typeName.text, node.typeName, 262144 /* TypeParameter */, /* excludeGlobals */ true); - if (symbol === null || symbol === void 0 ? void 0 : symbol.declarations) { - var declaration = ts.cast(ts.first(symbol.declarations), ts.isTypeParameterDeclaration); + var declaration = ts.tryCast((_a = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _a === void 0 ? void 0 : _a[0], ts.isTypeParameterDeclaration); + if (declaration) { if (rangeContainsSkipTrivia(statement, declaration, file) && !rangeContainsSkipTrivia(selection, declaration, file)) { ts.pushIfUnique(result, declaration); } diff --git a/node_modules/typescript/lib/typescript.js b/node_modules/typescript/lib/typescript.js index cc9dd7d83..0b317307b 100644 --- a/node_modules/typescript/lib/typescript.js +++ b/node_modules/typescript/lib/typescript.js @@ -294,7 +294,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.5.4"; + ts.version = "4.5.5"; /* @internal */ var Comparison; (function (Comparison) { @@ -16033,7 +16033,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function getExternalModuleRequireArgument(node) { - return isRequireVariableDeclaration(node) && getLeftmostAccessExpression(node.initializer).arguments[0]; + return isVariableDeclarationInitializedToBareOrAccessedRequire(node) && getLeftmostAccessExpression(node.initializer).arguments[0]; } ts.getExternalModuleRequireArgument = getExternalModuleRequireArgument; function isInternalModuleImportEqualsDeclaration(node) { @@ -16091,17 +16091,29 @@ var ts; * Returns true if the node is a VariableDeclaration initialized to a require call (see `isRequireCall`). * This function does not test if the node is in a JavaScript file or not. */ - function isRequireVariableDeclaration(node) { + function isVariableDeclarationInitializedToRequire(node) { + return isVariableDeclarationInitializedWithRequireHelper(node, /*allowAccessedRequire*/ false); + } + ts.isVariableDeclarationInitializedToRequire = isVariableDeclarationInitializedToRequire; + /** + * Like {@link isVariableDeclarationInitializedToRequire} but allows things like `require("...").foo.bar` or `require("...")["baz"]`. + */ + function isVariableDeclarationInitializedToBareOrAccessedRequire(node) { + return isVariableDeclarationInitializedWithRequireHelper(node, /*allowAccessedRequire*/ true); + } + ts.isVariableDeclarationInitializedToBareOrAccessedRequire = isVariableDeclarationInitializedToBareOrAccessedRequire; + function isVariableDeclarationInitializedWithRequireHelper(node, allowAccessedRequire) { if (node.kind === 202 /* BindingElement */) { node = node.parent.parent; } - return ts.isVariableDeclaration(node) && !!node.initializer && isRequireCall(getLeftmostAccessExpression(node.initializer), /*requireStringLiteralLikeArgument*/ true); + return ts.isVariableDeclaration(node) && + !!node.initializer && + isRequireCall(allowAccessedRequire ? getLeftmostAccessExpression(node.initializer) : node.initializer, /*requireStringLiteralLikeArgument*/ true); } - ts.isRequireVariableDeclaration = isRequireVariableDeclaration; function isRequireVariableStatement(node) { return ts.isVariableStatement(node) && node.declarationList.declarations.length > 0 - && ts.every(node.declarationList.declarations, function (decl) { return isRequireVariableDeclaration(decl); }); + && ts.every(node.declarationList.declarations, function (decl) { return isVariableDeclarationInitializedToRequire(decl); }); } ts.isRequireVariableStatement = isRequireVariableStatement; function isSingleOrDoubleQuote(charCode) { @@ -46258,7 +46270,7 @@ var ts; checkStrictModeEvalOrArguments(node, node.name); } if (!ts.isBindingPattern(node.name)) { - if (ts.isInJSFile(node) && ts.isRequireVariableDeclaration(node) && !ts.getJSDocTypeTag(node)) { + if (ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) && !ts.getJSDocTypeTag(node)) { declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); } else if (ts.isBlockOrCatchScoped(node)) { @@ -49037,7 +49049,7 @@ var ts; && isAliasableOrJsExpression(node.parent.right) || node.kind === 295 /* ShorthandPropertyAssignment */ || node.kind === 294 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer) - || ts.isRequireVariableDeclaration(node); + || ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node); } function isAliasableOrJsExpression(e) { return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e); @@ -50008,7 +50020,7 @@ var ts; if (!sigs || !sigs.length) { sigs = getSignaturesOfStructuredType(type, 1 /* Construct */); } - if ((sigs && sigs.length) || getPropertyOfType(type, "default" /* Default */)) { + if ((sigs && sigs.length) || getPropertyOfType(type, "default" /* Default */, /*skipObjectFunctionPropertyAugment*/ true)) { var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol, reference); return cloneTypeAsModuleType(symbol, moduleType, referenceParent); } @@ -80440,7 +80452,7 @@ var ts; } // For a commonjs `const x = require`, validate the alias and exit var symbol = getSymbolOfNode(node); - if (symbol.flags & 2097152 /* Alias */ && ts.isRequireVariableDeclaration(node)) { + if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)) { checkAliasSymbol(node); return; } @@ -124537,7 +124549,7 @@ var ts; isWhiteSpaceOnlyJsxText(child); if (lookInPreviousChild) { // actual start of the node is past the position - previous token should be at the end of previous child - var candidate_1 = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i, sourceFile); + var candidate_1 = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i, sourceFile, n.kind); return candidate_1 && findRightmostToken(candidate_1, sourceFile); } else { @@ -124551,7 +124563,7 @@ var ts; // 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. // Namely we are skipping the check: 'position < node.end' - var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length, sourceFile); + var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length, sourceFile, n.kind); return candidate && findRightmostToken(candidate, sourceFile); } } @@ -124567,17 +124579,19 @@ var ts; if (children.length === 0) { return n; } - var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length, sourceFile); + var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length, sourceFile, n.kind); return candidate && findRightmostToken(candidate, sourceFile); } /** * Finds the rightmost child to the left of `children[exclusiveStartPosition]` which is a non-all-whitespace token or has constituent tokens. */ - function findRightmostChildNodeWithTokens(children, exclusiveStartPosition, sourceFile) { + function findRightmostChildNodeWithTokens(children, exclusiveStartPosition, sourceFile, parentKind) { for (var i = exclusiveStartPosition - 1; i >= 0; i--) { var child = children[i]; if (isWhiteSpaceOnlyJsxText(child)) { - ts.Debug.assert(i > 0, "`JsxText` tokens should not be the first child of `JsxElement | JsxSelfClosingElement`"); + if (i === 0 && (parentKind === 11 /* JsxText */ || parentKind === 278 /* JsxSelfClosingElement */)) { + ts.Debug.fail("`JsxText` tokens should not be the first child of `JsxElement | JsxSelfClosingElement`"); + } } else if (nodeHasTokens(children[i], sourceFile)) { return children[i]; @@ -128994,7 +129008,7 @@ var ts; return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined; } function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences) { - var symbols = completionData.symbols, contextToken = completionData.contextToken, completionKind = completionData.completionKind, isInSnippetScope = completionData.isInSnippetScope, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, propertyAccessToConvert = completionData.propertyAccessToConvert, keywordFilters = completionData.keywordFilters, literals = completionData.literals, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, recommendedCompletion = completionData.recommendedCompletion, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation, isJsxIdentifierExpected = completionData.isJsxIdentifierExpected, importCompletionNode = completionData.importCompletionNode, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextIdMap = completionData.symbolToSortTextIdMap, hasUnresolvedAutoImports = completionData.hasUnresolvedAutoImports; + var symbols = completionData.symbols, contextToken = completionData.contextToken, completionKind = completionData.completionKind, isInSnippetScope = completionData.isInSnippetScope, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, propertyAccessToConvert = completionData.propertyAccessToConvert, keywordFilters = completionData.keywordFilters, literals = completionData.literals, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, recommendedCompletion = completionData.recommendedCompletion, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation, isJsxIdentifierExpected = completionData.isJsxIdentifierExpected, isRightOfOpenTag = completionData.isRightOfOpenTag, importCompletionNode = completionData.importCompletionNode, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextIdMap = completionData.symbolToSortTextIdMap, hasUnresolvedAutoImports = completionData.hasUnresolvedAutoImports; // Verify if the file is JSX language variant if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* JSX */) { var completionInfo = getJsxClosingTagCompletion(location, sourceFile); @@ -129005,7 +129019,7 @@ var ts; var entries = []; if (isUncheckedFile(sourceFile, compilerOptions)) { var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, - /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap); + /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap, isJsxIdentifierExpected, isRightOfOpenTag); getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries); // TODO: GH#18217 } else { @@ -129013,7 +129027,7 @@ var ts; return undefined; } getCompletionEntriesFromSymbols(symbols, entries, - /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap); + /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap, isJsxIdentifierExpected, isRightOfOpenTag); } if (keywordFilters !== 0 /* None */) { var entryNames = new ts.Set(entries.map(function (e) { return e.name; })); @@ -129119,7 +129133,7 @@ var ts; function createCompletionEntryForLiteral(sourceFile, preferences, literal) { return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: SortText.LocationPriority }; } - function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences, completionKind) { + function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences, completionKind, isJsxIdentifierExpected, isRightOfOpenTag) { var _a, _b; var insertText; var replacementSpan = ts.getReplacementSpanForContextToken(replacementToken); @@ -129190,24 +129204,7 @@ var ts; source = CompletionSource.ClassMemberSnippet; } } - // Before offering up a JSX attribute snippet, ensure that we aren't potentially completing - // a tag name; this may appear as an attribute after the "<" when the tag has not yet been - // closed, as in: - // - // return <> - // foo - // - // We can detect this case by checking if both: - // - // 1. The location is "<", so we are completing immediately after it. - // 2. The "<" has the same position as its parent, so is not a binary expression. - var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location); - if (kind === "JSX attribute" /* jsxAttribute */ - && (location.kind !== 29 /* LessThanToken */ || location.pos !== location.parent.pos) - && preferences.includeCompletionsWithSnippetText - && preferences.jsxAttributeCompletionStyle - && preferences.jsxAttributeCompletionStyle !== "none") { + if (isJsxIdentifierExpected && !isRightOfOpenTag && preferences.includeCompletionsWithSnippetText && preferences.jsxAttributeCompletionStyle && preferences.jsxAttributeCompletionStyle !== "none") { var useBraces_1 = preferences.jsxAttributeCompletionStyle === "braces"; var type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); // If is boolean like or undefined, don't return a snippet we want just to return the completion. @@ -129245,7 +129242,7 @@ var ts; // entries (like JavaScript identifier entries). return { name: name, - kind: kind, + kind: ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location), kindModifiers: ts.SymbolDisplay.getSymbolModifiers(typeChecker, symbol), sortText: sortText, source: source, @@ -129520,7 +129517,7 @@ var ts; return CompletionSource.ThisProperty; } } - function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap) { + function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap, isJsxIdentifierExpected, isRightOfOpenTag) { var _a; var start = ts.timestamp(); var variableDeclaration = getVariableDeclaration(location); @@ -129541,7 +129538,7 @@ var ts; var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess; var sortTextId = (_a = symbolToSortTextIdMap === null || symbolToSortTextIdMap === void 0 ? void 0 : symbolToSortTextIdMap[ts.getSymbolId(symbol)]) !== null && _a !== void 0 ? _a : 11 /* LocationPriority */; var sortText = (isDeprecated(symbol, typeChecker) ? 8 /* DeprecatedOffset */ + sortTextId : sortTextId).toString(); - var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences, kind); + var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences, kind, isJsxIdentifierExpected, isRightOfOpenTag); if (!entry) { continue; } @@ -130135,6 +130132,7 @@ var ts; symbolToSortTextIdMap: symbolToSortTextIdMap, isTypeOnlyLocation: isTypeOnlyLocation, isJsxIdentifierExpected: isJsxIdentifierExpected, + isRightOfOpenTag: isRightOfOpenTag, importCompletionNode: importCompletionNode, hasUnresolvedAutoImports: hasUnresolvedAutoImports, }; @@ -133066,7 +133064,7 @@ var ts; ts.Debug.assert(parent.name === node); return true; case 202 /* BindingElement */: - return ts.isInJSFile(node) && ts.isRequireVariableDeclaration(parent); + return ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(parent); default: return false; } @@ -134466,7 +134464,7 @@ var ts; // Use the parent symbol if the location is commonjs require syntax on javascript files only. if (ts.isInJSFile(referenceLocation) && referenceLocation.parent.kind === 202 /* BindingElement */ - && ts.isRequireVariableDeclaration(referenceLocation.parent)) { + && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent)) { referenceSymbol = referenceLocation.parent.symbol; // The parent will not have a symbol if it's an ObjectBindingPattern (when destructuring is used). In // this case, just skip it, since the bound identifiers are not an alias of the import. @@ -136173,7 +136171,7 @@ var ts; return declaration.parent.kind === 268 /* NamedImports */; case 202 /* BindingElement */: case 253 /* VariableDeclaration */: - return ts.isInJSFile(declaration) && ts.isRequireVariableDeclaration(declaration); + return ts.isInJSFile(declaration) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(declaration); default: return false; } @@ -137456,6 +137454,9 @@ var ts; // We use 1 NavNode to represent 'A.B.C', but there are multiple source nodes. // Only merge module nodes that have the same chain. Don't merge 'A.B.C' with 'A'! function areSameModule(a, b) { + if (!a.body || !b.body) { + return a.body === b.body; + } return a.body.kind === b.body.kind && (a.body.kind !== 260 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); } /** Merge source into target. Source should be thrown away after this is called. */ @@ -149205,7 +149206,7 @@ var ts; var importKind = getImportKind(importingFile, exportKind, compilerOptions); return ts.mapDefined(importingFile.imports, function (moduleSpecifier) { var i = ts.importFromModuleSpecifier(moduleSpecifier); - if (ts.isRequireVariableDeclaration(i.parent)) { + if (ts.isVariableDeclarationInitializedToRequire(i.parent)) { return checker.resolveExternalModuleName(moduleSpecifier) === moduleSymbol ? { declaration: i.parent, importKind: importKind, symbol: symbol, targetFlags: targetFlags } : undefined; } if (i.kind === 265 /* ImportDeclaration */ || i.kind === 264 /* ImportEqualsDeclaration */) { @@ -157265,11 +157266,12 @@ var ts; var result = []; return visitor(selection) ? undefined : result; function visitor(node) { + var _a; if (ts.isTypeReferenceNode(node)) { if (ts.isIdentifier(node.typeName)) { var symbol = checker.resolveName(node.typeName.text, node.typeName, 262144 /* TypeParameter */, /* excludeGlobals */ true); - if (symbol === null || symbol === void 0 ? void 0 : symbol.declarations) { - var declaration = ts.cast(ts.first(symbol.declarations), ts.isTypeParameterDeclaration); + var declaration = ts.tryCast((_a = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _a === void 0 ? void 0 : _a[0], ts.isTypeParameterDeclaration); + if (declaration) { if (rangeContainsSkipTrivia(statement, declaration, file) && !rangeContainsSkipTrivia(selection, declaration, file)) { ts.pushIfUnique(result, declaration); } diff --git a/node_modules/typescript/lib/typescriptServices.js b/node_modules/typescript/lib/typescriptServices.js index 1f85972b8..bdd26eb4e 100644 --- a/node_modules/typescript/lib/typescriptServices.js +++ b/node_modules/typescript/lib/typescriptServices.js @@ -294,7 +294,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.5.4"; + ts.version = "4.5.5"; /* @internal */ var Comparison; (function (Comparison) { @@ -16033,7 +16033,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function getExternalModuleRequireArgument(node) { - return isRequireVariableDeclaration(node) && getLeftmostAccessExpression(node.initializer).arguments[0]; + return isVariableDeclarationInitializedToBareOrAccessedRequire(node) && getLeftmostAccessExpression(node.initializer).arguments[0]; } ts.getExternalModuleRequireArgument = getExternalModuleRequireArgument; function isInternalModuleImportEqualsDeclaration(node) { @@ -16091,17 +16091,29 @@ var ts; * Returns true if the node is a VariableDeclaration initialized to a require call (see `isRequireCall`). * This function does not test if the node is in a JavaScript file or not. */ - function isRequireVariableDeclaration(node) { + function isVariableDeclarationInitializedToRequire(node) { + return isVariableDeclarationInitializedWithRequireHelper(node, /*allowAccessedRequire*/ false); + } + ts.isVariableDeclarationInitializedToRequire = isVariableDeclarationInitializedToRequire; + /** + * Like {@link isVariableDeclarationInitializedToRequire} but allows things like `require("...").foo.bar` or `require("...")["baz"]`. + */ + function isVariableDeclarationInitializedToBareOrAccessedRequire(node) { + return isVariableDeclarationInitializedWithRequireHelper(node, /*allowAccessedRequire*/ true); + } + ts.isVariableDeclarationInitializedToBareOrAccessedRequire = isVariableDeclarationInitializedToBareOrAccessedRequire; + function isVariableDeclarationInitializedWithRequireHelper(node, allowAccessedRequire) { if (node.kind === 202 /* BindingElement */) { node = node.parent.parent; } - return ts.isVariableDeclaration(node) && !!node.initializer && isRequireCall(getLeftmostAccessExpression(node.initializer), /*requireStringLiteralLikeArgument*/ true); + return ts.isVariableDeclaration(node) && + !!node.initializer && + isRequireCall(allowAccessedRequire ? getLeftmostAccessExpression(node.initializer) : node.initializer, /*requireStringLiteralLikeArgument*/ true); } - ts.isRequireVariableDeclaration = isRequireVariableDeclaration; function isRequireVariableStatement(node) { return ts.isVariableStatement(node) && node.declarationList.declarations.length > 0 - && ts.every(node.declarationList.declarations, function (decl) { return isRequireVariableDeclaration(decl); }); + && ts.every(node.declarationList.declarations, function (decl) { return isVariableDeclarationInitializedToRequire(decl); }); } ts.isRequireVariableStatement = isRequireVariableStatement; function isSingleOrDoubleQuote(charCode) { @@ -46258,7 +46270,7 @@ var ts; checkStrictModeEvalOrArguments(node, node.name); } if (!ts.isBindingPattern(node.name)) { - if (ts.isInJSFile(node) && ts.isRequireVariableDeclaration(node) && !ts.getJSDocTypeTag(node)) { + if (ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) && !ts.getJSDocTypeTag(node)) { declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); } else if (ts.isBlockOrCatchScoped(node)) { @@ -49037,7 +49049,7 @@ var ts; && isAliasableOrJsExpression(node.parent.right) || node.kind === 295 /* ShorthandPropertyAssignment */ || node.kind === 294 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer) - || ts.isRequireVariableDeclaration(node); + || ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node); } function isAliasableOrJsExpression(e) { return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e); @@ -50008,7 +50020,7 @@ var ts; if (!sigs || !sigs.length) { sigs = getSignaturesOfStructuredType(type, 1 /* Construct */); } - if ((sigs && sigs.length) || getPropertyOfType(type, "default" /* Default */)) { + if ((sigs && sigs.length) || getPropertyOfType(type, "default" /* Default */, /*skipObjectFunctionPropertyAugment*/ true)) { var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol, reference); return cloneTypeAsModuleType(symbol, moduleType, referenceParent); } @@ -80440,7 +80452,7 @@ var ts; } // For a commonjs `const x = require`, validate the alias and exit var symbol = getSymbolOfNode(node); - if (symbol.flags & 2097152 /* Alias */ && ts.isRequireVariableDeclaration(node)) { + if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)) { checkAliasSymbol(node); return; } @@ -124537,7 +124549,7 @@ var ts; isWhiteSpaceOnlyJsxText(child); if (lookInPreviousChild) { // actual start of the node is past the position - previous token should be at the end of previous child - var candidate_1 = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i, sourceFile); + var candidate_1 = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i, sourceFile, n.kind); return candidate_1 && findRightmostToken(candidate_1, sourceFile); } else { @@ -124551,7 +124563,7 @@ var ts; // 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. // Namely we are skipping the check: 'position < node.end' - var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length, sourceFile); + var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length, sourceFile, n.kind); return candidate && findRightmostToken(candidate, sourceFile); } } @@ -124567,17 +124579,19 @@ var ts; if (children.length === 0) { return n; } - var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length, sourceFile); + var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length, sourceFile, n.kind); return candidate && findRightmostToken(candidate, sourceFile); } /** * Finds the rightmost child to the left of `children[exclusiveStartPosition]` which is a non-all-whitespace token or has constituent tokens. */ - function findRightmostChildNodeWithTokens(children, exclusiveStartPosition, sourceFile) { + function findRightmostChildNodeWithTokens(children, exclusiveStartPosition, sourceFile, parentKind) { for (var i = exclusiveStartPosition - 1; i >= 0; i--) { var child = children[i]; if (isWhiteSpaceOnlyJsxText(child)) { - ts.Debug.assert(i > 0, "`JsxText` tokens should not be the first child of `JsxElement | JsxSelfClosingElement`"); + if (i === 0 && (parentKind === 11 /* JsxText */ || parentKind === 278 /* JsxSelfClosingElement */)) { + ts.Debug.fail("`JsxText` tokens should not be the first child of `JsxElement | JsxSelfClosingElement`"); + } } else if (nodeHasTokens(children[i], sourceFile)) { return children[i]; @@ -128994,7 +129008,7 @@ var ts; return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined; } function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences) { - var symbols = completionData.symbols, contextToken = completionData.contextToken, completionKind = completionData.completionKind, isInSnippetScope = completionData.isInSnippetScope, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, propertyAccessToConvert = completionData.propertyAccessToConvert, keywordFilters = completionData.keywordFilters, literals = completionData.literals, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, recommendedCompletion = completionData.recommendedCompletion, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation, isJsxIdentifierExpected = completionData.isJsxIdentifierExpected, importCompletionNode = completionData.importCompletionNode, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextIdMap = completionData.symbolToSortTextIdMap, hasUnresolvedAutoImports = completionData.hasUnresolvedAutoImports; + var symbols = completionData.symbols, contextToken = completionData.contextToken, completionKind = completionData.completionKind, isInSnippetScope = completionData.isInSnippetScope, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, propertyAccessToConvert = completionData.propertyAccessToConvert, keywordFilters = completionData.keywordFilters, literals = completionData.literals, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, recommendedCompletion = completionData.recommendedCompletion, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation, isJsxIdentifierExpected = completionData.isJsxIdentifierExpected, isRightOfOpenTag = completionData.isRightOfOpenTag, importCompletionNode = completionData.importCompletionNode, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextIdMap = completionData.symbolToSortTextIdMap, hasUnresolvedAutoImports = completionData.hasUnresolvedAutoImports; // Verify if the file is JSX language variant if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* JSX */) { var completionInfo = getJsxClosingTagCompletion(location, sourceFile); @@ -129005,7 +129019,7 @@ var ts; var entries = []; if (isUncheckedFile(sourceFile, compilerOptions)) { var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, - /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap); + /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap, isJsxIdentifierExpected, isRightOfOpenTag); getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries); // TODO: GH#18217 } else { @@ -129013,7 +129027,7 @@ var ts; return undefined; } getCompletionEntriesFromSymbols(symbols, entries, - /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap); + /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap, isJsxIdentifierExpected, isRightOfOpenTag); } if (keywordFilters !== 0 /* None */) { var entryNames = new ts.Set(entries.map(function (e) { return e.name; })); @@ -129119,7 +129133,7 @@ var ts; function createCompletionEntryForLiteral(sourceFile, preferences, literal) { return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: SortText.LocationPriority }; } - function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences, completionKind) { + function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences, completionKind, isJsxIdentifierExpected, isRightOfOpenTag) { var _a, _b; var insertText; var replacementSpan = ts.getReplacementSpanForContextToken(replacementToken); @@ -129190,24 +129204,7 @@ var ts; source = CompletionSource.ClassMemberSnippet; } } - // Before offering up a JSX attribute snippet, ensure that we aren't potentially completing - // a tag name; this may appear as an attribute after the "<" when the tag has not yet been - // closed, as in: - // - // return <> - // foo - // - // We can detect this case by checking if both: - // - // 1. The location is "<", so we are completing immediately after it. - // 2. The "<" has the same position as its parent, so is not a binary expression. - var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location); - if (kind === "JSX attribute" /* jsxAttribute */ - && (location.kind !== 29 /* LessThanToken */ || location.pos !== location.parent.pos) - && preferences.includeCompletionsWithSnippetText - && preferences.jsxAttributeCompletionStyle - && preferences.jsxAttributeCompletionStyle !== "none") { + if (isJsxIdentifierExpected && !isRightOfOpenTag && preferences.includeCompletionsWithSnippetText && preferences.jsxAttributeCompletionStyle && preferences.jsxAttributeCompletionStyle !== "none") { var useBraces_1 = preferences.jsxAttributeCompletionStyle === "braces"; var type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); // If is boolean like or undefined, don't return a snippet we want just to return the completion. @@ -129245,7 +129242,7 @@ var ts; // entries (like JavaScript identifier entries). return { name: name, - kind: kind, + kind: ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location), kindModifiers: ts.SymbolDisplay.getSymbolModifiers(typeChecker, symbol), sortText: sortText, source: source, @@ -129520,7 +129517,7 @@ var ts; return CompletionSource.ThisProperty; } } - function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap) { + function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap, isJsxIdentifierExpected, isRightOfOpenTag) { var _a; var start = ts.timestamp(); var variableDeclaration = getVariableDeclaration(location); @@ -129541,7 +129538,7 @@ var ts; var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess; var sortTextId = (_a = symbolToSortTextIdMap === null || symbolToSortTextIdMap === void 0 ? void 0 : symbolToSortTextIdMap[ts.getSymbolId(symbol)]) !== null && _a !== void 0 ? _a : 11 /* LocationPriority */; var sortText = (isDeprecated(symbol, typeChecker) ? 8 /* DeprecatedOffset */ + sortTextId : sortTextId).toString(); - var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences, kind); + var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences, kind, isJsxIdentifierExpected, isRightOfOpenTag); if (!entry) { continue; } @@ -130135,6 +130132,7 @@ var ts; symbolToSortTextIdMap: symbolToSortTextIdMap, isTypeOnlyLocation: isTypeOnlyLocation, isJsxIdentifierExpected: isJsxIdentifierExpected, + isRightOfOpenTag: isRightOfOpenTag, importCompletionNode: importCompletionNode, hasUnresolvedAutoImports: hasUnresolvedAutoImports, }; @@ -133066,7 +133064,7 @@ var ts; ts.Debug.assert(parent.name === node); return true; case 202 /* BindingElement */: - return ts.isInJSFile(node) && ts.isRequireVariableDeclaration(parent); + return ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(parent); default: return false; } @@ -134466,7 +134464,7 @@ var ts; // Use the parent symbol if the location is commonjs require syntax on javascript files only. if (ts.isInJSFile(referenceLocation) && referenceLocation.parent.kind === 202 /* BindingElement */ - && ts.isRequireVariableDeclaration(referenceLocation.parent)) { + && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent)) { referenceSymbol = referenceLocation.parent.symbol; // The parent will not have a symbol if it's an ObjectBindingPattern (when destructuring is used). In // this case, just skip it, since the bound identifiers are not an alias of the import. @@ -136173,7 +136171,7 @@ var ts; return declaration.parent.kind === 268 /* NamedImports */; case 202 /* BindingElement */: case 253 /* VariableDeclaration */: - return ts.isInJSFile(declaration) && ts.isRequireVariableDeclaration(declaration); + return ts.isInJSFile(declaration) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(declaration); default: return false; } @@ -137456,6 +137454,9 @@ var ts; // We use 1 NavNode to represent 'A.B.C', but there are multiple source nodes. // Only merge module nodes that have the same chain. Don't merge 'A.B.C' with 'A'! function areSameModule(a, b) { + if (!a.body || !b.body) { + return a.body === b.body; + } return a.body.kind === b.body.kind && (a.body.kind !== 260 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); } /** Merge source into target. Source should be thrown away after this is called. */ @@ -149205,7 +149206,7 @@ var ts; var importKind = getImportKind(importingFile, exportKind, compilerOptions); return ts.mapDefined(importingFile.imports, function (moduleSpecifier) { var i = ts.importFromModuleSpecifier(moduleSpecifier); - if (ts.isRequireVariableDeclaration(i.parent)) { + if (ts.isVariableDeclarationInitializedToRequire(i.parent)) { return checker.resolveExternalModuleName(moduleSpecifier) === moduleSymbol ? { declaration: i.parent, importKind: importKind, symbol: symbol, targetFlags: targetFlags } : undefined; } if (i.kind === 265 /* ImportDeclaration */ || i.kind === 264 /* ImportEqualsDeclaration */) { @@ -157265,11 +157266,12 @@ var ts; var result = []; return visitor(selection) ? undefined : result; function visitor(node) { + var _a; if (ts.isTypeReferenceNode(node)) { if (ts.isIdentifier(node.typeName)) { var symbol = checker.resolveName(node.typeName.text, node.typeName, 262144 /* TypeParameter */, /* excludeGlobals */ true); - if (symbol === null || symbol === void 0 ? void 0 : symbol.declarations) { - var declaration = ts.cast(ts.first(symbol.declarations), ts.isTypeParameterDeclaration); + var declaration = ts.tryCast((_a = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _a === void 0 ? void 0 : _a[0], ts.isTypeParameterDeclaration); + if (declaration) { if (rangeContainsSkipTrivia(statement, declaration, file) && !rangeContainsSkipTrivia(selection, declaration, file)) { ts.pushIfUnique(result, declaration); } diff --git a/node_modules/typescript/lib/typingsInstaller.js b/node_modules/typescript/lib/typingsInstaller.js index 17e9323ed..7a0fd43fa 100644 --- a/node_modules/typescript/lib/typingsInstaller.js +++ b/node_modules/typescript/lib/typingsInstaller.js @@ -89,7 +89,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.5.4"; + ts.version = "4.5.5"; /* @internal */ var Comparison; (function (Comparison) { @@ -15828,7 +15828,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function getExternalModuleRequireArgument(node) { - return isRequireVariableDeclaration(node) && getLeftmostAccessExpression(node.initializer).arguments[0]; + return isVariableDeclarationInitializedToBareOrAccessedRequire(node) && getLeftmostAccessExpression(node.initializer).arguments[0]; } ts.getExternalModuleRequireArgument = getExternalModuleRequireArgument; function isInternalModuleImportEqualsDeclaration(node) { @@ -15886,17 +15886,29 @@ var ts; * Returns true if the node is a VariableDeclaration initialized to a require call (see `isRequireCall`). * This function does not test if the node is in a JavaScript file or not. */ - function isRequireVariableDeclaration(node) { + function isVariableDeclarationInitializedToRequire(node) { + return isVariableDeclarationInitializedWithRequireHelper(node, /*allowAccessedRequire*/ false); + } + ts.isVariableDeclarationInitializedToRequire = isVariableDeclarationInitializedToRequire; + /** + * Like {@link isVariableDeclarationInitializedToRequire} but allows things like `require("...").foo.bar` or `require("...")["baz"]`. + */ + function isVariableDeclarationInitializedToBareOrAccessedRequire(node) { + return isVariableDeclarationInitializedWithRequireHelper(node, /*allowAccessedRequire*/ true); + } + ts.isVariableDeclarationInitializedToBareOrAccessedRequire = isVariableDeclarationInitializedToBareOrAccessedRequire; + function isVariableDeclarationInitializedWithRequireHelper(node, allowAccessedRequire) { if (node.kind === 202 /* BindingElement */) { node = node.parent.parent; } - return ts.isVariableDeclaration(node) && !!node.initializer && isRequireCall(getLeftmostAccessExpression(node.initializer), /*requireStringLiteralLikeArgument*/ true); + return ts.isVariableDeclaration(node) && + !!node.initializer && + isRequireCall(allowAccessedRequire ? getLeftmostAccessExpression(node.initializer) : node.initializer, /*requireStringLiteralLikeArgument*/ true); } - ts.isRequireVariableDeclaration = isRequireVariableDeclaration; function isRequireVariableStatement(node) { return ts.isVariableStatement(node) && node.declarationList.declarations.length > 0 - && ts.every(node.declarationList.declarations, function (decl) { return isRequireVariableDeclaration(decl); }); + && ts.every(node.declarationList.declarations, function (decl) { return isVariableDeclarationInitializedToRequire(decl); }); } ts.isRequireVariableStatement = isRequireVariableStatement; function isSingleOrDoubleQuote(charCode) { @@ -46053,7 +46065,7 @@ var ts; checkStrictModeEvalOrArguments(node, node.name); } if (!ts.isBindingPattern(node.name)) { - if (ts.isInJSFile(node) && ts.isRequireVariableDeclaration(node) && !ts.getJSDocTypeTag(node)) { + if (ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) && !ts.getJSDocTypeTag(node)) { declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); } else if (ts.isBlockOrCatchScoped(node)) { @@ -48832,7 +48844,7 @@ var ts; && isAliasableOrJsExpression(node.parent.right) || node.kind === 295 /* ShorthandPropertyAssignment */ || node.kind === 294 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer) - || ts.isRequireVariableDeclaration(node); + || ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node); } function isAliasableOrJsExpression(e) { return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e); @@ -49803,7 +49815,7 @@ var ts; if (!sigs || !sigs.length) { sigs = getSignaturesOfStructuredType(type, 1 /* Construct */); } - if ((sigs && sigs.length) || getPropertyOfType(type, "default" /* Default */)) { + if ((sigs && sigs.length) || getPropertyOfType(type, "default" /* Default */, /*skipObjectFunctionPropertyAugment*/ true)) { var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol, reference); return cloneTypeAsModuleType(symbol, moduleType, referenceParent); } @@ -80235,7 +80247,7 @@ var ts; } // For a commonjs `const x = require`, validate the alias and exit var symbol = getSymbolOfNode(node); - if (symbol.flags & 2097152 /* Alias */ && ts.isRequireVariableDeclaration(node)) { + if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)) { checkAliasSymbol(node); return; } diff --git a/node_modules/typescript/package.json b/node_modules/typescript/package.json index 84cb41b00..05d1d0839 100644 --- a/node_modules/typescript/package.json +++ b/node_modules/typescript/package.json @@ -2,7 +2,7 @@ "name": "typescript", "author": "Microsoft Corp.", "homepage": "https://www.typescriptlang.org/", - "version": "4.5.4", + "version": "4.5.5", "license": "Apache-2.0", "description": "TypeScript is a language for application scale JavaScript development", "keywords": [