- if (token.kind === 29 /* SyntaxKind.LessThanToken */ && token.parent.kind === 288 /* SyntaxKind.JsxExpression */) {
+ if (token.kind === 29 /* SyntaxKind.LessThanToken */ && token.parent.kind === 291 /* SyntaxKind.JsxExpression */) {
return true;
}
//
{
// |
// } < /div>
- if (token && token.kind === 19 /* SyntaxKind.CloseBraceToken */ && token.parent.kind === 288 /* SyntaxKind.JsxExpression */) {
+ if (token && token.kind === 19 /* SyntaxKind.CloseBraceToken */ && token.parent.kind === 291 /* SyntaxKind.JsxExpression */) {
return true;
}
//
|
- if (token.kind === 29 /* SyntaxKind.LessThanToken */ && token.parent.kind === 281 /* SyntaxKind.JsxClosingElement */) {
+ if (token.kind === 29 /* SyntaxKind.LessThanToken */ && token.parent.kind === 284 /* SyntaxKind.JsxClosingElement */) {
return true;
}
return false;
@@ -417001,7 +418201,7 @@ var ts;
function isInsideJsxElement(sourceFile, position) {
function isInsideJsxElementTraversal(node) {
while (node) {
- if (node.kind >= 279 /* SyntaxKind.JsxSelfClosingElement */ && node.kind <= 288 /* SyntaxKind.JsxExpression */
+ if (node.kind >= 282 /* SyntaxKind.JsxSelfClosingElement */ && node.kind <= 291 /* SyntaxKind.JsxExpression */
|| node.kind === 11 /* SyntaxKind.JsxText */
|| node.kind === 29 /* SyntaxKind.LessThanToken */
|| node.kind === 31 /* SyntaxKind.GreaterThanToken */
@@ -417011,7 +418211,7 @@ var ts;
|| node.kind === 43 /* SyntaxKind.SlashToken */) {
node = node.parent;
}
- else if (node.kind === 278 /* SyntaxKind.JsxElement */) {
+ else if (node.kind === 281 /* SyntaxKind.JsxElement */) {
if (position > node.getStart(sourceFile))
return true;
node = node.parent;
@@ -417159,7 +418359,7 @@ var ts;
// falls through
case 112 /* SyntaxKind.TypeOfKeyword */:
case 94 /* SyntaxKind.ExtendsKeyword */:
- case 140 /* SyntaxKind.KeyOfKeyword */:
+ case 141 /* SyntaxKind.KeyOfKeyword */:
case 24 /* SyntaxKind.DotToken */:
case 51 /* SyntaxKind.BarToken */:
case 57 /* SyntaxKind.QuestionToken */:
@@ -417180,7 +418380,7 @@ var ts;
/**
* Returns true if the cursor at position in sourceFile is within a comment.
*
- * @param tokenAtPosition Must equal `getTokenAtPosition(sourceFile, position)
+ * @param tokenAtPosition Must equal `getTokenAtPosition(sourceFile, position)`
* @param predicate Additional predicate to test on the comment range.
*/
function isInComment(sourceFile, position, tokenAtPosition) {
@@ -417211,7 +418411,7 @@ var ts;
result.push("public" /* ScriptElementKindModifier.publicMemberModifier */);
if (flags & 32 /* ModifierFlags.Static */ || ts.isClassStaticBlockDeclaration(node))
result.push("static" /* ScriptElementKindModifier.staticModifier */);
- if (flags & 128 /* ModifierFlags.Abstract */)
+ if (flags & 256 /* ModifierFlags.Abstract */)
result.push("abstract" /* ScriptElementKindModifier.abstractModifier */);
if (flags & 1 /* ModifierFlags.Export */)
result.push("export" /* ScriptElementKindModifier.exportedModifier */);
@@ -417219,16 +418419,16 @@ var ts;
result.push("deprecated" /* ScriptElementKindModifier.deprecatedModifier */);
if (node.flags & 16777216 /* NodeFlags.Ambient */)
result.push("declare" /* ScriptElementKindModifier.ambientModifier */);
- if (node.kind === 271 /* SyntaxKind.ExportAssignment */)
+ if (node.kind === 274 /* SyntaxKind.ExportAssignment */)
result.push("export" /* ScriptElementKindModifier.exportedModifier */);
return result.length > 0 ? result.join(",") : "" /* ScriptElementKindModifier.none */;
}
ts.getNodeModifiers = getNodeModifiers;
function getTypeArgumentOrTypeParameterList(node) {
- if (node.kind === 178 /* SyntaxKind.TypeReference */ || node.kind === 208 /* SyntaxKind.CallExpression */) {
+ if (node.kind === 180 /* SyntaxKind.TypeReference */ || node.kind === 210 /* SyntaxKind.CallExpression */) {
return node.typeArguments;
}
- if (ts.isFunctionLike(node) || node.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 258 /* SyntaxKind.InterfaceDeclaration */) {
+ if (ts.isFunctionLike(node) || node.kind === 260 /* SyntaxKind.ClassDeclaration */ || node.kind === 261 /* SyntaxKind.InterfaceDeclaration */) {
return node.typeParameters;
}
return undefined;
@@ -417273,18 +418473,18 @@ var ts;
}
ts.cloneCompilerOptions = cloneCompilerOptions;
function isArrayLiteralOrObjectLiteralDestructuringPattern(node) {
- if (node.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ ||
- node.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) {
+ if (node.kind === 206 /* SyntaxKind.ArrayLiteralExpression */ ||
+ node.kind === 207 /* SyntaxKind.ObjectLiteralExpression */) {
// [a,b,c] from:
// [a, b, c] = someExpression;
- if (node.parent.kind === 221 /* SyntaxKind.BinaryExpression */ &&
+ if (node.parent.kind === 223 /* SyntaxKind.BinaryExpression */ &&
node.parent.left === node &&
node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) {
return true;
}
// [a, b, c] from:
// for([a, b, c] of expression)
- if (node.parent.kind === 244 /* SyntaxKind.ForOfStatement */ &&
+ if (node.parent.kind === 247 /* SyntaxKind.ForOfStatement */ &&
node.parent.initializer === node) {
return true;
}
@@ -417292,7 +418492,7 @@ var ts;
// [x, [a, b, c] ] = someExpression
// or
// {x, a: {a, b, c} } = someExpression
- if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 296 /* SyntaxKind.PropertyAssignment */ ? node.parent.parent : node.parent)) {
+ if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 299 /* SyntaxKind.PropertyAssignment */ ? node.parent.parent : node.parent)) {
return true;
}
}
@@ -417354,32 +418554,32 @@ var ts;
}
ts.createTextChange = createTextChange;
ts.typeKeywords = [
- 130 /* SyntaxKind.AnyKeyword */,
- 128 /* SyntaxKind.AssertsKeyword */,
- 158 /* SyntaxKind.BigIntKeyword */,
- 133 /* SyntaxKind.BooleanKeyword */,
+ 131 /* SyntaxKind.AnyKeyword */,
+ 129 /* SyntaxKind.AssertsKeyword */,
+ 160 /* SyntaxKind.BigIntKeyword */,
+ 134 /* SyntaxKind.BooleanKeyword */,
95 /* SyntaxKind.FalseKeyword */,
- 137 /* SyntaxKind.InferKeyword */,
- 140 /* SyntaxKind.KeyOfKeyword */,
- 143 /* SyntaxKind.NeverKeyword */,
+ 138 /* SyntaxKind.InferKeyword */,
+ 141 /* SyntaxKind.KeyOfKeyword */,
+ 144 /* SyntaxKind.NeverKeyword */,
104 /* SyntaxKind.NullKeyword */,
- 147 /* SyntaxKind.NumberKeyword */,
- 148 /* SyntaxKind.ObjectKeyword */,
- 145 /* SyntaxKind.ReadonlyKeyword */,
- 150 /* SyntaxKind.StringKeyword */,
- 151 /* SyntaxKind.SymbolKeyword */,
+ 148 /* SyntaxKind.NumberKeyword */,
+ 149 /* SyntaxKind.ObjectKeyword */,
+ 146 /* SyntaxKind.ReadonlyKeyword */,
+ 152 /* SyntaxKind.StringKeyword */,
+ 153 /* SyntaxKind.SymbolKeyword */,
110 /* SyntaxKind.TrueKeyword */,
114 /* SyntaxKind.VoidKeyword */,
- 153 /* SyntaxKind.UndefinedKeyword */,
- 154 /* SyntaxKind.UniqueKeyword */,
- 155 /* SyntaxKind.UnknownKeyword */,
+ 155 /* SyntaxKind.UndefinedKeyword */,
+ 156 /* SyntaxKind.UniqueKeyword */,
+ 157 /* SyntaxKind.UnknownKeyword */,
];
function isTypeKeyword(kind) {
return ts.contains(ts.typeKeywords, kind);
}
ts.isTypeKeyword = isTypeKeyword;
function isTypeKeywordToken(node) {
- return node.kind === 152 /* SyntaxKind.TypeKeyword */;
+ return node.kind === 154 /* SyntaxKind.TypeKeyword */;
}
ts.isTypeKeywordToken = isTypeKeywordToken;
function isTypeKeywordTokenOrIdentifier(node) {
@@ -417416,7 +418616,7 @@ var ts;
}
ts.skipConstraint = skipConstraint;
function getNameFromPropertyName(name) {
- return name.kind === 162 /* SyntaxKind.ComputedPropertyName */
+ return name.kind === 164 /* SyntaxKind.ComputedPropertyName */
// treat computed property names where expression is string/numeric literal as just string/numeric literal
? ts.isStringOrNumericLiteralLike(name.expression) ? name.expression.text : undefined
: ts.isPrivateIdentifier(name) ? ts.idText(name) : ts.getTextOfIdentifierOrLiteral(name);
@@ -417566,7 +418766,7 @@ var ts;
ts.findModifier = findModifier;
function insertImports(changes, sourceFile, imports, blankLineBetween) {
var decl = ts.isArray(imports) ? imports[0] : imports;
- var importKindPredicate = decl.kind === 237 /* SyntaxKind.VariableStatement */ ? ts.isRequireVariableStatement : ts.isAnyImportSyntax;
+ var importKindPredicate = decl.kind === 240 /* SyntaxKind.VariableStatement */ ? ts.isRequireVariableStatement : ts.isAnyImportSyntax;
var existingImportStatements = ts.filter(sourceFile.statements, importKindPredicate);
var sortedNewImports = ts.isArray(imports) ? ts.stableSort(imports, ts.OrganizeImports.compareImportsOrRequireStatements) : [imports];
if (!existingImportStatements.length) {
@@ -418240,15 +419440,15 @@ var ts;
function getContextualTypeFromParent(node, checker) {
var parent = node.parent;
switch (parent.kind) {
- case 209 /* SyntaxKind.NewExpression */:
+ case 211 /* SyntaxKind.NewExpression */:
return checker.getContextualType(parent);
- case 221 /* SyntaxKind.BinaryExpression */: {
+ case 223 /* SyntaxKind.BinaryExpression */: {
var _a = parent, left = _a.left, operatorToken = _a.operatorToken, right = _a.right;
return isEqualityOperatorKind(operatorToken.kind)
? checker.getTypeAtLocation(node === right ? left : right)
: checker.getContextualType(node);
}
- case 289 /* SyntaxKind.CaseClause */:
+ case 292 /* SyntaxKind.CaseClause */:
return parent.expression === node ? getSwitchedType(parent, checker) : undefined;
default:
return checker.getContextualType(node);
@@ -418278,8 +419478,8 @@ var ts;
switch (node.kind) {
case 10 /* SyntaxKind.StringLiteral */:
case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */:
- case 223 /* SyntaxKind.TemplateExpression */:
- case 210 /* SyntaxKind.TaggedTemplateExpression */:
+ case 225 /* SyntaxKind.TemplateExpression */:
+ case 212 /* SyntaxKind.TaggedTemplateExpression */:
return true;
default:
return false;
@@ -418313,38 +419513,38 @@ var ts;
}
ts.getTypeNodeIfAccessible = getTypeNodeIfAccessible;
function syntaxRequiresTrailingCommaOrSemicolonOrASI(kind) {
- return kind === 174 /* SyntaxKind.CallSignature */
- || kind === 175 /* SyntaxKind.ConstructSignature */
- || kind === 176 /* SyntaxKind.IndexSignature */
- || kind === 166 /* SyntaxKind.PropertySignature */
- || kind === 168 /* SyntaxKind.MethodSignature */;
+ return kind === 176 /* SyntaxKind.CallSignature */
+ || kind === 177 /* SyntaxKind.ConstructSignature */
+ || kind === 178 /* SyntaxKind.IndexSignature */
+ || kind === 168 /* SyntaxKind.PropertySignature */
+ || kind === 170 /* SyntaxKind.MethodSignature */;
}
function syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI(kind) {
- return kind === 256 /* SyntaxKind.FunctionDeclaration */
- || kind === 171 /* SyntaxKind.Constructor */
- || kind === 169 /* SyntaxKind.MethodDeclaration */
- || kind === 172 /* SyntaxKind.GetAccessor */
- || kind === 173 /* SyntaxKind.SetAccessor */;
+ return kind === 259 /* SyntaxKind.FunctionDeclaration */
+ || kind === 173 /* SyntaxKind.Constructor */
+ || kind === 171 /* SyntaxKind.MethodDeclaration */
+ || kind === 174 /* SyntaxKind.GetAccessor */
+ || kind === 175 /* SyntaxKind.SetAccessor */;
}
function syntaxRequiresTrailingModuleBlockOrSemicolonOrASI(kind) {
- return kind === 261 /* SyntaxKind.ModuleDeclaration */;
+ return kind === 264 /* SyntaxKind.ModuleDeclaration */;
}
function syntaxRequiresTrailingSemicolonOrASI(kind) {
- return kind === 237 /* SyntaxKind.VariableStatement */
- || kind === 238 /* SyntaxKind.ExpressionStatement */
- || kind === 240 /* SyntaxKind.DoStatement */
- || kind === 245 /* SyntaxKind.ContinueStatement */
- || kind === 246 /* SyntaxKind.BreakStatement */
- || kind === 247 /* SyntaxKind.ReturnStatement */
- || kind === 251 /* SyntaxKind.ThrowStatement */
- || kind === 253 /* SyntaxKind.DebuggerStatement */
- || kind === 167 /* SyntaxKind.PropertyDeclaration */
- || kind === 259 /* SyntaxKind.TypeAliasDeclaration */
- || kind === 266 /* SyntaxKind.ImportDeclaration */
- || kind === 265 /* SyntaxKind.ImportEqualsDeclaration */
- || kind === 272 /* SyntaxKind.ExportDeclaration */
- || kind === 264 /* SyntaxKind.NamespaceExportDeclaration */
- || kind === 271 /* SyntaxKind.ExportAssignment */;
+ return kind === 240 /* SyntaxKind.VariableStatement */
+ || kind === 241 /* SyntaxKind.ExpressionStatement */
+ || kind === 243 /* SyntaxKind.DoStatement */
+ || kind === 248 /* SyntaxKind.ContinueStatement */
+ || kind === 249 /* SyntaxKind.BreakStatement */
+ || kind === 250 /* SyntaxKind.ReturnStatement */
+ || kind === 254 /* SyntaxKind.ThrowStatement */
+ || kind === 256 /* SyntaxKind.DebuggerStatement */
+ || kind === 169 /* SyntaxKind.PropertyDeclaration */
+ || kind === 262 /* SyntaxKind.TypeAliasDeclaration */
+ || kind === 269 /* SyntaxKind.ImportDeclaration */
+ || kind === 268 /* SyntaxKind.ImportEqualsDeclaration */
+ || kind === 275 /* SyntaxKind.ExportDeclaration */
+ || kind === 267 /* SyntaxKind.NamespaceExportDeclaration */
+ || kind === 274 /* SyntaxKind.ExportAssignment */;
}
ts.syntaxRequiresTrailingSemicolonOrASI = syntaxRequiresTrailingSemicolonOrASI;
ts.syntaxMayBeASICandidate = ts.or(syntaxRequiresTrailingCommaOrSemicolonOrASI, syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI, syntaxRequiresTrailingModuleBlockOrSemicolonOrASI, syntaxRequiresTrailingSemicolonOrASI);
@@ -418374,7 +419574,7 @@ var ts;
return false;
}
// See comment in parser’s `parseDoStatement`
- if (node.kind === 240 /* SyntaxKind.DoStatement */) {
+ if (node.kind === 243 /* SyntaxKind.DoStatement */) {
return true;
}
var topNode = ts.findAncestor(node, function (ancestor) { return !ancestor.parent; });
@@ -418863,6 +420063,10 @@ var ts;
return jsx === 2 /* JsxEmit.React */ || jsx === 3 /* JsxEmit.ReactNative */;
}
ts.jsxModeNeedsExplicitImport = jsxModeNeedsExplicitImport;
+ function isSourceFileFromLibrary(program, node) {
+ return program.isSourceFileFromExternalLibrary(node) || program.isSourceFileDefaultLibrary(node);
+ }
+ ts.isSourceFileFromLibrary = isSourceFileFromLibrary;
// #endregion
})(ts || (ts = {}));
/*@internal*/
@@ -418978,14 +420182,16 @@ var ts;
search: function (importingFile, preferCapitalized, matches, action) {
if (importingFile !== usableByFileName)
return;
- exportInfo.forEach(function (info, key) {
+ return ts.forEachEntry(exportInfo, function (info, key) {
var _a = parseKey(key), symbolName = _a.symbolName, ambientModuleName = _a.ambientModuleName;
var name = preferCapitalized && info[0].capitalizedSymbolName || symbolName;
if (matches(name, info[0].targetFlags)) {
var rehydrated = info.map(rehydrateCachedInfo);
var filtered = rehydrated.filter(function (r, i) { return isNotShadowedByDeeperNodeModulesPackage(r, info[i].packageName); });
if (filtered.length) {
- action(filtered, name, !!ambientModuleName, key);
+ var res = action(filtered, name, !!ambientModuleName, key);
+ if (res !== undefined)
+ return res;
}
}
});
@@ -419373,11 +420579,11 @@ var ts;
angleBracketStack--;
}
break;
- case 130 /* SyntaxKind.AnyKeyword */:
- case 150 /* SyntaxKind.StringKeyword */:
- case 147 /* SyntaxKind.NumberKeyword */:
- case 133 /* SyntaxKind.BooleanKeyword */:
- case 151 /* SyntaxKind.SymbolKeyword */:
+ case 131 /* SyntaxKind.AnyKeyword */:
+ case 152 /* SyntaxKind.StringKeyword */:
+ case 148 /* SyntaxKind.NumberKeyword */:
+ case 134 /* SyntaxKind.BooleanKeyword */:
+ case 153 /* SyntaxKind.SymbolKeyword */:
if (angleBracketStack > 0 && !syntacticClassifierAbsent) {
// If it looks like we're could be in something generic, don't classify this
// as a keyword. We may just get overwritten by the syntactic classifier,
@@ -419566,10 +420772,11 @@ var ts;
return true;
}
switch (keyword2) {
- case 136 /* SyntaxKind.GetKeyword */:
- case 149 /* SyntaxKind.SetKeyword */:
- case 134 /* SyntaxKind.ConstructorKeyword */:
+ case 137 /* SyntaxKind.GetKeyword */:
+ case 151 /* SyntaxKind.SetKeyword */:
+ case 135 /* SyntaxKind.ConstructorKeyword */:
case 124 /* SyntaxKind.StaticKeyword */:
+ case 127 /* SyntaxKind.AccessorKeyword */:
return true; // Allow things like "public get", "public constructor" and "public static".
default:
return false; // Any other keyword following "public" is actually an identifier, not a real keyword.
@@ -419616,7 +420823,8 @@ var ts;
case 33 /* SyntaxKind.GreaterThanEqualsToken */:
case 102 /* SyntaxKind.InstanceOfKeyword */:
case 101 /* SyntaxKind.InKeyword */:
- case 127 /* SyntaxKind.AsKeyword */:
+ case 128 /* SyntaxKind.AsKeyword */:
+ case 150 /* SyntaxKind.SatisfiesKeyword */:
case 34 /* SyntaxKind.EqualsEqualsToken */:
case 35 /* SyntaxKind.ExclamationEqualsToken */:
case 36 /* SyntaxKind.EqualsEqualsEqualsToken */:
@@ -419712,13 +420920,13 @@ var ts;
// That means we're calling back into the host around every 1.2k of the file we process.
// Lib.d.ts has similar numbers.
switch (kind) {
- case 261 /* SyntaxKind.ModuleDeclaration */:
- case 257 /* SyntaxKind.ClassDeclaration */:
- case 258 /* SyntaxKind.InterfaceDeclaration */:
- case 256 /* SyntaxKind.FunctionDeclaration */:
- case 226 /* SyntaxKind.ClassExpression */:
- case 213 /* SyntaxKind.FunctionExpression */:
- case 214 /* SyntaxKind.ArrowFunction */:
+ case 264 /* SyntaxKind.ModuleDeclaration */:
+ case 260 /* SyntaxKind.ClassDeclaration */:
+ case 261 /* SyntaxKind.InterfaceDeclaration */:
+ case 259 /* SyntaxKind.FunctionDeclaration */:
+ case 228 /* SyntaxKind.ClassExpression */:
+ case 215 /* SyntaxKind.FunctionExpression */:
+ case 216 /* SyntaxKind.ArrowFunction */:
cancellationToken.throwIfCancellationRequested();
}
}
@@ -419940,46 +421148,46 @@ var ts;
pos = tag.tagName.end;
var commentStart = tag.tagName.end;
switch (tag.kind) {
- case 340 /* SyntaxKind.JSDocParameterTag */:
+ case 343 /* SyntaxKind.JSDocParameterTag */:
var param = tag;
processJSDocParameterTag(param);
commentStart = param.isNameFirst && ((_a = param.typeExpression) === null || _a === void 0 ? void 0 : _a.end) || param.name.end;
break;
- case 347 /* SyntaxKind.JSDocPropertyTag */:
+ case 350 /* SyntaxKind.JSDocPropertyTag */:
var prop = tag;
commentStart = prop.isNameFirst && ((_b = prop.typeExpression) === null || _b === void 0 ? void 0 : _b.end) || prop.name.end;
break;
- case 344 /* SyntaxKind.JSDocTemplateTag */:
+ case 347 /* SyntaxKind.JSDocTemplateTag */:
processJSDocTemplateTag(tag);
pos = tag.end;
commentStart = tag.typeParameters.end;
break;
- case 345 /* SyntaxKind.JSDocTypedefTag */:
+ case 348 /* SyntaxKind.JSDocTypedefTag */:
var type = tag;
- commentStart = ((_c = type.typeExpression) === null || _c === void 0 ? void 0 : _c.kind) === 309 /* SyntaxKind.JSDocTypeExpression */ && ((_d = type.fullName) === null || _d === void 0 ? void 0 : _d.end) || ((_e = type.typeExpression) === null || _e === void 0 ? void 0 : _e.end) || commentStart;
+ commentStart = ((_c = type.typeExpression) === null || _c === void 0 ? void 0 : _c.kind) === 312 /* SyntaxKind.JSDocTypeExpression */ && ((_d = type.fullName) === null || _d === void 0 ? void 0 : _d.end) || ((_e = type.typeExpression) === null || _e === void 0 ? void 0 : _e.end) || commentStart;
break;
- case 338 /* SyntaxKind.JSDocCallbackTag */:
+ case 341 /* SyntaxKind.JSDocCallbackTag */:
commentStart = tag.typeExpression.end;
break;
- case 343 /* SyntaxKind.JSDocTypeTag */:
+ case 346 /* SyntaxKind.JSDocTypeTag */:
processElement(tag.typeExpression);
pos = tag.end;
commentStart = tag.typeExpression.end;
break;
- case 342 /* SyntaxKind.JSDocThisTag */:
- case 339 /* SyntaxKind.JSDocEnumTag */:
+ case 345 /* SyntaxKind.JSDocThisTag */:
+ case 342 /* SyntaxKind.JSDocEnumTag */:
commentStart = tag.typeExpression.end;
break;
- case 341 /* SyntaxKind.JSDocReturnTag */:
+ case 344 /* SyntaxKind.JSDocReturnTag */:
processElement(tag.typeExpression);
pos = tag.end;
commentStart = ((_f = tag.typeExpression) === null || _f === void 0 ? void 0 : _f.end) || commentStart;
break;
- case 346 /* SyntaxKind.JSDocSeeTag */:
+ case 349 /* SyntaxKind.JSDocSeeTag */:
commentStart = ((_g = tag.name) === null || _g === void 0 ? void 0 : _g.end) || commentStart;
break;
- case 328 /* SyntaxKind.JSDocAugmentsTag */:
- case 329 /* SyntaxKind.JSDocImplementsTag */:
+ case 331 /* SyntaxKind.JSDocAugmentsTag */:
+ case 332 /* SyntaxKind.JSDocImplementsTag */:
commentStart = tag.class.end;
break;
}
@@ -420026,7 +421234,7 @@ var ts;
// defined in `ts.commentPragmas` would be excessive, but we can avoid
// some obvious false positives (e.g. in XML-like doc comments) by
// checking the element name.
- // eslint-disable-next-line no-in-operator
+ // eslint-disable-next-line local/no-in-operator
if (!match[3] || !(match[3] in ts.commentPragmas)) {
return false;
}
@@ -420136,22 +421344,22 @@ var ts;
}
function tryClassifyJsxElementName(token) {
switch (token.parent && token.parent.kind) {
- case 280 /* SyntaxKind.JsxOpeningElement */:
+ case 283 /* SyntaxKind.JsxOpeningElement */:
if (token.parent.tagName === token) {
return 19 /* ClassificationType.jsxOpenTagName */;
}
break;
- case 281 /* SyntaxKind.JsxClosingElement */:
+ case 284 /* SyntaxKind.JsxClosingElement */:
if (token.parent.tagName === token) {
return 20 /* ClassificationType.jsxCloseTagName */;
}
break;
- case 279 /* SyntaxKind.JsxSelfClosingElement */:
+ case 282 /* SyntaxKind.JsxSelfClosingElement */:
if (token.parent.tagName === token) {
return 21 /* ClassificationType.jsxSelfClosingTagName */;
}
break;
- case 285 /* SyntaxKind.JsxAttribute */:
+ case 288 /* SyntaxKind.JsxAttribute */:
if (token.parent.name === token) {
return 22 /* ClassificationType.jsxAttribute */;
}
@@ -420180,17 +421388,17 @@ var ts;
var parent = token.parent;
if (tokenKind === 63 /* SyntaxKind.EqualsToken */) {
// the '=' in a variable declaration is special cased here.
- if (parent.kind === 254 /* SyntaxKind.VariableDeclaration */ ||
- parent.kind === 167 /* SyntaxKind.PropertyDeclaration */ ||
- parent.kind === 164 /* SyntaxKind.Parameter */ ||
- parent.kind === 285 /* SyntaxKind.JsxAttribute */) {
+ if (parent.kind === 257 /* SyntaxKind.VariableDeclaration */ ||
+ parent.kind === 169 /* SyntaxKind.PropertyDeclaration */ ||
+ parent.kind === 166 /* SyntaxKind.Parameter */ ||
+ parent.kind === 288 /* SyntaxKind.JsxAttribute */) {
return 5 /* ClassificationType.operator */;
}
}
- if (parent.kind === 221 /* SyntaxKind.BinaryExpression */ ||
- parent.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ ||
- parent.kind === 220 /* SyntaxKind.PostfixUnaryExpression */ ||
- parent.kind === 222 /* SyntaxKind.ConditionalExpression */) {
+ if (parent.kind === 223 /* SyntaxKind.BinaryExpression */ ||
+ parent.kind === 221 /* SyntaxKind.PrefixUnaryExpression */ ||
+ parent.kind === 222 /* SyntaxKind.PostfixUnaryExpression */ ||
+ parent.kind === 224 /* SyntaxKind.ConditionalExpression */) {
return 5 /* ClassificationType.operator */;
}
}
@@ -420203,7 +421411,7 @@ var ts;
return 25 /* ClassificationType.bigintLiteral */;
}
else if (tokenKind === 10 /* SyntaxKind.StringLiteral */) {
- return token && token.parent.kind === 285 /* SyntaxKind.JsxAttribute */ ? 24 /* ClassificationType.jsxAttributeStringLiteralValue */ : 6 /* ClassificationType.stringLiteral */;
+ return token && token.parent.kind === 288 /* SyntaxKind.JsxAttribute */ ? 24 /* ClassificationType.jsxAttributeStringLiteralValue */ : 6 /* ClassificationType.stringLiteral */;
}
else if (tokenKind === 13 /* SyntaxKind.RegularExpressionLiteral */) {
// TODO: we should get another classification type for these literals.
@@ -420219,32 +421427,32 @@ var ts;
else if (tokenKind === 79 /* SyntaxKind.Identifier */) {
if (token) {
switch (token.parent.kind) {
- case 257 /* SyntaxKind.ClassDeclaration */:
+ case 260 /* SyntaxKind.ClassDeclaration */:
if (token.parent.name === token) {
return 11 /* ClassificationType.className */;
}
return;
- case 163 /* SyntaxKind.TypeParameter */:
+ case 165 /* SyntaxKind.TypeParameter */:
if (token.parent.name === token) {
return 15 /* ClassificationType.typeParameterName */;
}
return;
- case 258 /* SyntaxKind.InterfaceDeclaration */:
+ case 261 /* SyntaxKind.InterfaceDeclaration */:
if (token.parent.name === token) {
return 13 /* ClassificationType.interfaceName */;
}
return;
- case 260 /* SyntaxKind.EnumDeclaration */:
+ case 263 /* SyntaxKind.EnumDeclaration */:
if (token.parent.name === token) {
return 12 /* ClassificationType.enumName */;
}
return;
- case 261 /* SyntaxKind.ModuleDeclaration */:
+ case 264 /* SyntaxKind.ModuleDeclaration */:
if (token.parent.name === token) {
return 14 /* ClassificationType.moduleName */;
}
return;
- case 164 /* SyntaxKind.Parameter */:
+ case 166 /* SyntaxKind.Parameter */:
if (token.parent.name === token) {
return ts.isThisIdentifier(token) ? 3 /* ClassificationType.keyword */ : 17 /* ClassificationType.parameterName */;
}
@@ -420349,13 +421557,13 @@ var ts;
var inJSXElement = false;
function visit(node) {
switch (node.kind) {
- case 261 /* SyntaxKind.ModuleDeclaration */:
- case 257 /* SyntaxKind.ClassDeclaration */:
- case 258 /* SyntaxKind.InterfaceDeclaration */:
- case 256 /* SyntaxKind.FunctionDeclaration */:
- case 226 /* SyntaxKind.ClassExpression */:
- case 213 /* SyntaxKind.FunctionExpression */:
- case 214 /* SyntaxKind.ArrowFunction */:
+ case 264 /* SyntaxKind.ModuleDeclaration */:
+ case 260 /* SyntaxKind.ClassDeclaration */:
+ case 261 /* SyntaxKind.InterfaceDeclaration */:
+ case 259 /* SyntaxKind.FunctionDeclaration */:
+ case 228 /* SyntaxKind.ClassExpression */:
+ case 215 /* SyntaxKind.FunctionExpression */:
+ case 216 /* SyntaxKind.ArrowFunction */:
cancellationToken.throwIfCancellationRequested();
}
if (!node || !ts.textSpanIntersectsWith(span, node.pos, node.getFullWidth()) || node.getFullWidth() === 0) {
@@ -420395,7 +421603,7 @@ var ts;
if (modifiers & 32 /* ModifierFlags.Static */) {
modifierSet |= 1 << 1 /* TokenModifier.static */;
}
- if (modifiers & 256 /* ModifierFlags.Async */) {
+ if (modifiers & 512 /* ModifierFlags.Async */) {
modifierSet |= 1 << 2 /* TokenModifier.async */;
}
if (typeIdx !== 0 /* TokenType.class */ && typeIdx !== 2 /* TokenType.interface */) {
@@ -420501,25 +421709,25 @@ var ts;
return (ts.isQualifiedName(node.parent) && node.parent.right === node) || (ts.isPropertyAccessExpression(node.parent) && node.parent.name === node);
}
var tokenFromDeclarationMapping = new ts.Map([
- [254 /* SyntaxKind.VariableDeclaration */, 7 /* TokenType.variable */],
- [164 /* SyntaxKind.Parameter */, 6 /* TokenType.parameter */],
- [167 /* SyntaxKind.PropertyDeclaration */, 9 /* TokenType.property */],
- [261 /* SyntaxKind.ModuleDeclaration */, 3 /* TokenType.namespace */],
- [260 /* SyntaxKind.EnumDeclaration */, 1 /* TokenType.enum */],
- [299 /* SyntaxKind.EnumMember */, 8 /* TokenType.enumMember */],
- [257 /* SyntaxKind.ClassDeclaration */, 0 /* TokenType.class */],
- [169 /* SyntaxKind.MethodDeclaration */, 11 /* TokenType.member */],
- [256 /* SyntaxKind.FunctionDeclaration */, 10 /* TokenType.function */],
- [213 /* SyntaxKind.FunctionExpression */, 10 /* TokenType.function */],
- [168 /* SyntaxKind.MethodSignature */, 11 /* TokenType.member */],
- [172 /* SyntaxKind.GetAccessor */, 9 /* TokenType.property */],
- [173 /* SyntaxKind.SetAccessor */, 9 /* TokenType.property */],
- [166 /* SyntaxKind.PropertySignature */, 9 /* TokenType.property */],
- [258 /* SyntaxKind.InterfaceDeclaration */, 2 /* TokenType.interface */],
- [259 /* SyntaxKind.TypeAliasDeclaration */, 5 /* TokenType.type */],
- [163 /* SyntaxKind.TypeParameter */, 4 /* TokenType.typeParameter */],
- [296 /* SyntaxKind.PropertyAssignment */, 9 /* TokenType.property */],
- [297 /* SyntaxKind.ShorthandPropertyAssignment */, 9 /* TokenType.property */]
+ [257 /* SyntaxKind.VariableDeclaration */, 7 /* TokenType.variable */],
+ [166 /* SyntaxKind.Parameter */, 6 /* TokenType.parameter */],
+ [169 /* SyntaxKind.PropertyDeclaration */, 9 /* TokenType.property */],
+ [264 /* SyntaxKind.ModuleDeclaration */, 3 /* TokenType.namespace */],
+ [263 /* SyntaxKind.EnumDeclaration */, 1 /* TokenType.enum */],
+ [302 /* SyntaxKind.EnumMember */, 8 /* TokenType.enumMember */],
+ [260 /* SyntaxKind.ClassDeclaration */, 0 /* TokenType.class */],
+ [171 /* SyntaxKind.MethodDeclaration */, 11 /* TokenType.member */],
+ [259 /* SyntaxKind.FunctionDeclaration */, 10 /* TokenType.function */],
+ [215 /* SyntaxKind.FunctionExpression */, 10 /* TokenType.function */],
+ [170 /* SyntaxKind.MethodSignature */, 11 /* TokenType.member */],
+ [174 /* SyntaxKind.GetAccessor */, 9 /* TokenType.property */],
+ [175 /* SyntaxKind.SetAccessor */, 9 /* TokenType.property */],
+ [168 /* SyntaxKind.PropertySignature */, 9 /* TokenType.property */],
+ [261 /* SyntaxKind.InterfaceDeclaration */, 2 /* TokenType.interface */],
+ [262 /* SyntaxKind.TypeAliasDeclaration */, 5 /* TokenType.type */],
+ [165 /* SyntaxKind.TypeParameter */, 4 /* TokenType.typeParameter */],
+ [299 /* SyntaxKind.PropertyAssignment */, 9 /* TokenType.property */],
+ [300 /* SyntaxKind.ShorthandPropertyAssignment */, 9 /* TokenType.property */]
]);
})(v2020 = classifier.v2020 || (classifier.v2020 = {}));
})(classifier = ts.classifier || (ts.classifier = {}));
@@ -420653,18 +421861,18 @@ var ts;
function getStringLiteralCompletionEntries(sourceFile, node, position, typeChecker, compilerOptions, host, preferences) {
var parent = walkUpParentheses(node.parent);
switch (parent.kind) {
- case 196 /* SyntaxKind.LiteralType */: {
+ case 198 /* SyntaxKind.LiteralType */: {
var grandParent_1 = walkUpParentheses(parent.parent);
switch (grandParent_1.kind) {
- case 228 /* SyntaxKind.ExpressionWithTypeArguments */:
- case 178 /* SyntaxKind.TypeReference */: {
+ case 230 /* SyntaxKind.ExpressionWithTypeArguments */:
+ case 180 /* SyntaxKind.TypeReference */: {
var typeArgument = ts.findAncestor(parent, function (n) { return n.parent === grandParent_1; });
if (typeArgument) {
return { kind: 2 /* StringLiteralCompletionKind.Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(typeArgument)), isNewIdentifier: false };
}
return undefined;
}
- case 194 /* SyntaxKind.IndexedAccessType */:
+ case 196 /* SyntaxKind.IndexedAccessType */:
// Get all apparent property names
// i.e. interface Foo {
// foo: string;
@@ -420676,9 +421884,9 @@ var ts;
return undefined;
}
return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode(objectType));
- case 200 /* SyntaxKind.ImportType */:
+ case 202 /* SyntaxKind.ImportType */:
return { kind: 0 /* StringLiteralCompletionKind.Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) };
- case 187 /* SyntaxKind.UnionType */: {
+ case 189 /* SyntaxKind.UnionType */: {
if (!ts.isTypeReferenceNode(grandParent_1.parent)) {
return undefined;
}
@@ -420690,7 +421898,7 @@ var ts;
return undefined;
}
}
- case 296 /* SyntaxKind.PropertyAssignment */:
+ case 299 /* SyntaxKind.PropertyAssignment */:
if (ts.isObjectLiteralExpression(parent.parent) && parent.name === node) {
// Get quoted name of properties of the object literal expression
// i.e. interface ConfigFiles {
@@ -420707,7 +421915,7 @@ var ts;
return stringLiteralCompletionsForObjectLiteral(typeChecker, parent.parent);
}
return fromContextualType();
- case 207 /* SyntaxKind.ElementAccessExpression */: {
+ case 209 /* SyntaxKind.ElementAccessExpression */: {
var _b = parent, expression = _b.expression, argumentExpression = _b.argumentExpression;
if (node === ts.skipParentheses(argumentExpression)) {
// Get all names of properties on the expression
@@ -420720,20 +421928,20 @@ var ts;
}
return undefined;
}
- case 208 /* SyntaxKind.CallExpression */:
- case 209 /* SyntaxKind.NewExpression */:
- case 285 /* SyntaxKind.JsxAttribute */:
+ case 210 /* SyntaxKind.CallExpression */:
+ case 211 /* SyntaxKind.NewExpression */:
+ case 288 /* SyntaxKind.JsxAttribute */:
if (!isRequireCallArgument(node) && !ts.isImportCall(parent)) {
- var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(parent.kind === 285 /* SyntaxKind.JsxAttribute */ ? parent.parent : node, position, sourceFile);
+ var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(parent.kind === 288 /* SyntaxKind.JsxAttribute */ ? parent.parent : node, position, sourceFile);
// Get string literal completions from specialized signatures of the target
// i.e. declare function f(a: 'A');
// f("/*completion position*/")
- return argumentInfo ? getStringLiteralCompletionsFromSignature(argumentInfo.invocation, node, argumentInfo, typeChecker) : fromContextualType();
+ return argumentInfo && getStringLiteralCompletionsFromSignature(argumentInfo.invocation, node, argumentInfo, typeChecker) || fromContextualType();
}
// falls through (is `require("")` or `require(""` or `import("")`)
- case 266 /* SyntaxKind.ImportDeclaration */:
- case 272 /* SyntaxKind.ExportDeclaration */:
- case 277 /* SyntaxKind.ExternalModuleReference */:
+ case 269 /* SyntaxKind.ImportDeclaration */:
+ case 275 /* SyntaxKind.ExportDeclaration */:
+ case 280 /* SyntaxKind.ExternalModuleReference */:
// Get all known external module names or complete a path to a module
// i.e. import * as ns from "/*completion position*/";
// var y = import("/*completion position*/");
@@ -420752,9 +421960,9 @@ var ts;
}
function walkUpParentheses(node) {
switch (node.kind) {
- case 191 /* SyntaxKind.ParenthesizedType */:
+ case 193 /* SyntaxKind.ParenthesizedType */:
return ts.walkUpParenthesizedTypes(node);
- case 212 /* SyntaxKind.ParenthesizedExpression */:
+ case 214 /* SyntaxKind.ParenthesizedExpression */:
return ts.walkUpParenthesizedExpressions(node);
default:
return node;
@@ -420784,7 +421992,7 @@ var ts;
isNewIdentifier = isNewIdentifier || !!(type.flags & 4 /* TypeFlags.String */);
return getStringLiteralTypes(type, uniques);
});
- return { kind: 2 /* StringLiteralCompletionKind.Types */, types: types, isNewIdentifier: isNewIdentifier };
+ return ts.length(types) ? { kind: 2 /* StringLiteralCompletionKind.Types */, types: types, isNewIdentifier: isNewIdentifier } : undefined;
}
function stringLiteralCompletionsFromProperties(type) {
return type && {
@@ -421302,7 +422510,7 @@ var ts;
if (!dependencies)
continue;
for (var dep in dependencies) {
- if (dependencies.hasOwnProperty(dep) && !ts.startsWith(dep, "@types/")) {
+ if (ts.hasProperty(dependencies, dep) && !ts.startsWith(dep, "@types/")) {
result.push(dep);
}
}
@@ -421677,7 +422885,7 @@ var ts;
}
function keywordFiltersFromSyntaxKind(keywordCompletion) {
switch (keywordCompletion) {
- case 152 /* SyntaxKind.TypeKeyword */: return 8 /* KeywordCompletionFilters.TypeKeyword */;
+ case 154 /* SyntaxKind.TypeKeyword */: return 8 /* KeywordCompletionFilters.TypeKeyword */;
default: ts.Debug.fail("Unknown mapping from SyntaxKind to KeywordCompletionFilters");
}
}
@@ -421686,7 +422894,7 @@ var ts;
return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* SyntaxKind.Identifier */ ? ts.createTextSpanFromNode(location) : undefined;
}
function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext, position) {
- 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, symbolToSortTextMap = completionData.symbolToSortTextMap, 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, importStatementCompletion = completionData.importStatementCompletion, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextMap = completionData.symbolToSortTextMap, hasUnresolvedAutoImports = completionData.hasUnresolvedAutoImports;
// Verify if the file is JSX language variant
if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* LanguageVariant.JSX */) {
var completionInfo = getJsxClosingTagCompletion(location, sourceFile);
@@ -421700,7 +422908,7 @@ var ts;
return undefined;
}
var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries,
- /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap, isJsxIdentifierExpected, isRightOfOpenTag);
+ /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importStatementCompletion, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap, isJsxIdentifierExpected, isRightOfOpenTag);
if (keywordFilters !== 0 /* KeywordCompletionFilters.None */) {
for (var _i = 0, _a = getKeywordCompletions(keywordFilters, !insideJsDocTagTypeExpression && ts.isSourceFileJS(sourceFile)); _i < _a.length; _i++) {
var keywordEntry = _a[_i];
@@ -421753,12 +422961,12 @@ var ts;
// We wanna walk up the tree till we find a JSX closing element
var jsxClosingElement = ts.findAncestor(location, function (node) {
switch (node.kind) {
- case 281 /* SyntaxKind.JsxClosingElement */:
+ case 284 /* SyntaxKind.JsxClosingElement */:
return true;
case 43 /* SyntaxKind.SlashToken */:
case 31 /* SyntaxKind.GreaterThanToken */:
case 79 /* SyntaxKind.Identifier */:
- case 206 /* SyntaxKind.PropertyAccessExpression */:
+ case 208 /* SyntaxKind.PropertyAccessExpression */:
return false;
default:
return "quit";
@@ -421818,7 +423026,7 @@ var ts;
function createCompletionEntryForLiteral(sourceFile, preferences, literal) {
return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* ScriptElementKind.string */, kindModifiers: "" /* ScriptElementKindModifier.none */, sortText: Completions.SortText.LocationPriority };
}
- function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences, completionKind, formatContext, isJsxIdentifierExpected, isRightOfOpenTag) {
+ function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importStatementCompletion, useSemicolons, options, preferences, completionKind, formatContext, isJsxIdentifierExpected, isRightOfOpenTag) {
var _a, _b;
var insertText;
var replacementSpan = ts.getReplacementSpanForContextToken(replacementToken);
@@ -421874,8 +423082,8 @@ var ts;
}
if (originIsResolvedExport(origin)) {
sourceDisplay = [ts.textPart(origin.moduleSpecifier)];
- if (importCompletionNode) {
- (_a = getInsertTextAndReplacementSpanForImportCompletion(name, importCompletionNode, contextToken, origin, useSemicolons, options, preferences), insertText = _a.insertText, replacementSpan = _a.replacementSpan);
+ if (importStatementCompletion) {
+ (_a = getInsertTextAndReplacementSpanForImportCompletion(name, importStatementCompletion, origin, useSemicolons, sourceFile, options, preferences), insertText = _a.insertText, replacementSpan = _a.replacementSpan);
isSnippet = preferences.includeCompletionsWithSnippetText ? true : undefined;
}
}
@@ -421885,7 +423093,7 @@ var ts;
if (preferences.includeCompletionsWithClassMemberSnippets &&
preferences.includeCompletionsWithInsertText &&
completionKind === 3 /* CompletionKind.MemberLike */ &&
- isClassLikeMemberCompletion(symbol, location)) {
+ isClassLikeMemberCompletion(symbol, location, sourceFile)) {
var importAdder = void 0;
(_b = getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken, formatContext), insertText = _b.insertText, isSnippet = _b.isSnippet, importAdder = _b.importAdder, replacementSpan = _b.replacementSpan);
sortText = Completions.SortText.ClassMemberSnippets; // sortText has to be lower priority than the sortText for keywords. See #47852.
@@ -421930,7 +423138,7 @@ var ts;
}
if (originIsExport(origin) || originIsResolvedExport(origin)) {
data = originToCompletionEntryData(origin);
- hasAction = !importCompletionNode;
+ hasAction = !importStatementCompletion;
}
// TODO(drosen): Right now we just permit *all* semantic meanings when calling
// 'getSymbolKind' which is permissible given that it is backwards compatible; but
@@ -421953,11 +423161,11 @@ var ts;
labelDetails: labelDetails,
isSnippet: isSnippet,
isPackageJsonImport: originIsPackageJsonImport(origin) || undefined,
- isImportStatementCompletion: !!importCompletionNode || undefined,
+ isImportStatementCompletion: !!importStatementCompletion || undefined,
data: data,
};
}
- function isClassLikeMemberCompletion(symbol, location) {
+ function isClassLikeMemberCompletion(symbol, location, sourceFile) {
// TODO: support JS files.
if (ts.isInJSFile(location)) {
return false;
@@ -421991,6 +423199,7 @@ var ts;
location.parent.parent &&
ts.isClassElement(location.parent) &&
location === location.parent.name &&
+ location.parent.getLastToken(sourceFile) === location.parent.name &&
ts.isClassLike(location.parent.parent)) ||
(location.parent &&
ts.isSyntaxList(location) &&
@@ -422032,7 +423241,7 @@ var ts;
// Whether the suggested member should be abstract.
// e.g. in `abstract class C { abstract | }`, we should offer abstract method signatures at position `|`.
var _a = getPresentModifiers(contextToken), presentModifiers = _a.modifiers, modifiersSpan = _a.span;
- var isAbstract = !!(presentModifiers & 128 /* ModifierFlags.Abstract */);
+ var isAbstract = !!(presentModifiers & 256 /* ModifierFlags.Abstract */);
var completionNodes = [];
ts.codefix.addNewNodeForMemberSymbol(symbol, classLikeDeclaration, sourceFile, { program: program, host: host }, preferences, importAdder,
// `addNewNodeForMemberSymbol` calls this callback function for each new member node
@@ -422045,7 +423254,7 @@ var ts;
function (node) {
var requiredModifiers = 0 /* ModifierFlags.None */;
if (isAbstract) {
- requiredModifiers |= 128 /* ModifierFlags.Abstract */;
+ requiredModifiers |= 256 /* ModifierFlags.Abstract */;
}
if (ts.isClassElement(node)
&& checker.getMemberOverrideModifierStatus(classLikeDeclaration, node) === 1 /* MemberOverrideStatus.NeedsOverride */) {
@@ -422106,7 +423315,7 @@ var ts;
span = ts.createTextSpanFromNode(contextToken);
}
if (ts.isPropertyDeclaration(contextToken.parent)) {
- modifiers |= ts.modifiersToFlags(contextToken.parent.modifiers) & 125951 /* ModifierFlags.Modifier */;
+ modifiers |= ts.modifiersToFlags(contextToken.parent.modifiers) & 126975 /* ModifierFlags.Modifier */;
span = ts.createTextSpanFromNode(contextToken.parent);
}
return { modifiers: modifiers, span: span };
@@ -422155,7 +423364,6 @@ var ts;
var labelDetails = { detail: signaturePrinter.printNode(4 /* EmitHint.Unspecified */, methodSignature, sourceFile) };
return { isSnippet: isSnippet, insertText: insertText, labelDetails: labelDetails };
}
- ;
function createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences) {
var declarations = symbol.getDeclarations();
if (!(declarations && declarations.length)) {
@@ -422168,10 +423376,10 @@ var ts;
var quotePreference = ts.getQuotePreference(sourceFile, preferences);
var builderFlags = 33554432 /* NodeBuilderFlags.OmitThisParameter */ | (quotePreference === 0 /* QuotePreference.Single */ ? 268435456 /* NodeBuilderFlags.UseSingleQuotesForStringLiteralType */ : 0 /* NodeBuilderFlags.None */);
switch (declaration.kind) {
- case 166 /* SyntaxKind.PropertySignature */:
- case 167 /* SyntaxKind.PropertyDeclaration */:
- case 168 /* SyntaxKind.MethodSignature */:
- case 169 /* SyntaxKind.MethodDeclaration */: {
+ case 168 /* SyntaxKind.PropertySignature */:
+ case 169 /* SyntaxKind.PropertyDeclaration */:
+ case 170 /* SyntaxKind.MethodSignature */:
+ case 171 /* SyntaxKind.MethodDeclaration */: {
var effectiveType = type.flags & 1048576 /* TypeFlags.Union */ && type.types.length < 10
? checker.getUnionType(type.types, 2 /* UnionReduction.Subtype */)
: type;
@@ -422205,7 +423413,8 @@ var ts;
}
var parameters = typeNode.parameters.map(function (typedParam) {
return ts.factory.createParameterDeclaration(
- /*modifiers*/ undefined, typedParam.dotDotDotToken, typedParam.name, typedParam.questionToken,
+ /*modifiers*/ undefined, typedParam.dotDotDotToken, typedParam.name,
+ /*questionToken*/ undefined,
/*type*/ undefined, typedParam.initializer);
});
return ts.factory.createMethodDeclaration(
@@ -422325,20 +423534,17 @@ var ts;
};
return unresolvedOrigin;
}
- function getInsertTextAndReplacementSpanForImportCompletion(name, importCompletionNode, contextToken, origin, useSemicolons, options, preferences) {
- var _a, _b, _c;
- var sourceFile = importCompletionNode.getSourceFile();
- var replacementSpan = ts.createTextSpanFromNode(ts.findAncestor(importCompletionNode, ts.or(ts.isImportDeclaration, ts.isImportEqualsDeclaration)) || importCompletionNode, sourceFile);
+ function getInsertTextAndReplacementSpanForImportCompletion(name, importStatementCompletion, origin, useSemicolons, sourceFile, options, preferences) {
+ var replacementSpan = importStatementCompletion.replacementSpan;
var quotedModuleSpecifier = ts.quote(sourceFile, preferences, origin.moduleSpecifier);
var exportKind = origin.isDefaultExport ? 1 /* ExportKind.Default */ :
origin.exportName === "export=" /* InternalSymbolName.ExportEquals */ ? 2 /* ExportKind.ExportEquals */ :
0 /* ExportKind.Named */;
var tabStop = preferences.includeCompletionsWithSnippetText ? "$1" : "";
var importKind = ts.codefix.getImportKind(sourceFile, exportKind, options, /*forceImportKeyword*/ true);
- var isTopLevelTypeOnly = ((_b = (_a = ts.tryCast(importCompletionNode, ts.isImportDeclaration)) === null || _a === void 0 ? void 0 : _a.importClause) === null || _b === void 0 ? void 0 : _b.isTypeOnly) || ((_c = ts.tryCast(importCompletionNode, ts.isImportEqualsDeclaration)) === null || _c === void 0 ? void 0 : _c.isTypeOnly);
- var isImportSpecifierTypeOnly = couldBeTypeOnlyImportSpecifier(importCompletionNode, contextToken);
- var topLevelTypeOnlyText = isTopLevelTypeOnly ? " ".concat(ts.tokenToString(152 /* SyntaxKind.TypeKeyword */), " ") : " ";
- var importSpecifierTypeOnlyText = isImportSpecifierTypeOnly ? "".concat(ts.tokenToString(152 /* SyntaxKind.TypeKeyword */), " ") : "";
+ var isImportSpecifierTypeOnly = importStatementCompletion.couldBeTypeOnlyImportSpecifier;
+ var topLevelTypeOnlyText = importStatementCompletion.isTopLevelTypeOnly ? " ".concat(ts.tokenToString(154 /* SyntaxKind.TypeKeyword */), " ") : " ";
+ var importSpecifierTypeOnlyText = isImportSpecifierTypeOnly ? "".concat(ts.tokenToString(154 /* SyntaxKind.TypeKeyword */), " ") : "";
var suffix = useSemicolons ? ";" : "";
switch (importKind) {
case 3 /* ImportKind.CommonJS */: return { replacementSpan: replacementSpan, insertText: "import".concat(topLevelTypeOnlyText).concat(ts.escapeSnippetText(name)).concat(tabStop, " = require(").concat(quotedModuleSpecifier, ")").concat(suffix) };
@@ -422371,7 +423577,7 @@ var ts;
return CompletionSource.TypeOnlyAlias;
}
}
- function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap, isJsxIdentifierExpected, isRightOfOpenTag) {
+ function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importStatementCompletion, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap, isJsxIdentifierExpected, isRightOfOpenTag) {
var _a;
var start = ts.timestamp();
var variableDeclaration = getVariableDeclaration(location);
@@ -422392,7 +423598,7 @@ var ts;
var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess;
var originalSortText = (_a = symbolToSortTextMap === null || symbolToSortTextMap === void 0 ? void 0 : symbolToSortTextMap[ts.getSymbolId(symbol)]) !== null && _a !== void 0 ? _a : Completions.SortText.LocationPriority;
var sortText = (isDeprecated(symbol, typeChecker) ? Completions.SortText.Deprecated(originalSortText) : originalSortText);
- var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences, kind, formatContext, isJsxIdentifierExpected, isRightOfOpenTag);
+ var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importStatementCompletion, useSemicolons, compilerOptions, preferences, kind, formatContext, isJsxIdentifierExpected, isRightOfOpenTag);
if (!entry) {
continue;
}
@@ -422552,7 +423758,7 @@ var ts;
}
case "symbol": {
var symbol = symbolCompletion.symbol, location = symbolCompletion.location, contextToken_2 = symbolCompletion.contextToken, origin = symbolCompletion.origin, previousToken = symbolCompletion.previousToken;
- var _a = getCompletionEntryCodeActionsAndSourceDisplay(name, location, contextToken_2, origin, symbol, program, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences, data, source), codeActions = _a.codeActions, sourceDisplay = _a.sourceDisplay;
+ var _a = getCompletionEntryCodeActionsAndSourceDisplay(name, location, contextToken_2, origin, symbol, program, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences, data, source, cancellationToken), codeActions = _a.codeActions, sourceDisplay = _a.sourceDisplay;
return createCompletionDetailsForSymbol(symbol, typeChecker, sourceFile, location, cancellationToken, codeActions, sourceDisplay); // TODO: GH#18217
}
case "literal": {
@@ -422581,9 +423787,9 @@ var ts;
return { name: name, kindModifiers: kindModifiers, kind: kind, displayParts: displayParts, documentation: documentation, tags: tags, codeActions: codeActions, source: source, sourceDisplay: source };
}
Completions.createCompletionDetails = createCompletionDetails;
- function getCompletionEntryCodeActionsAndSourceDisplay(name, location, contextToken, origin, symbol, program, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences, data, source) {
+ function getCompletionEntryCodeActionsAndSourceDisplay(name, location, contextToken, origin, symbol, program, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences, data, source, cancellationToken) {
if (data === null || data === void 0 ? void 0 : data.moduleSpecifier) {
- if (previousToken && getImportStatementCompletionInfo(contextToken || previousToken).replacementNode) {
+ if (previousToken && getImportStatementCompletionInfo(contextToken || previousToken).replacementSpan) {
// Import statement completion: 'import c|'
return { codeActions: undefined, sourceDisplay: [ts.textPart(data.moduleSpecifier)] };
}
@@ -422613,7 +423819,7 @@ var ts;
var moduleSymbol = origin.moduleSymbol;
var targetSymbol = checker.getMergedSymbol(ts.skipAlias(symbol.exportSymbol || symbol, checker));
var isJsxOpeningTagName = (contextToken === null || contextToken === void 0 ? void 0 : contextToken.kind) === 29 /* SyntaxKind.LessThanToken */ && ts.isJsxOpeningLikeElement(contextToken.parent);
- var _a = ts.codefix.getImportCompletionAction(targetSymbol, moduleSymbol, sourceFile, ts.getNameForExportedSymbol(symbol, ts.getEmitScriptTarget(compilerOptions), isJsxOpeningTagName), isJsxOpeningTagName, host, program, formatContext, previousToken && ts.isIdentifier(previousToken) ? previousToken.getStart(sourceFile) : position, preferences), moduleSpecifier = _a.moduleSpecifier, codeAction = _a.codeAction;
+ var _a = ts.codefix.getImportCompletionAction(targetSymbol, moduleSymbol, sourceFile, ts.getNameForExportedSymbol(symbol, ts.getEmitScriptTarget(compilerOptions), isJsxOpeningTagName), isJsxOpeningTagName, host, program, formatContext, previousToken && ts.isIdentifier(previousToken) ? previousToken.getStart(sourceFile) : position, preferences, cancellationToken), moduleSpecifier = _a.moduleSpecifier, codeAction = _a.codeAction;
ts.Debug.assert(!(data === null || data === void 0 ? void 0 : data.moduleSpecifier) || moduleSpecifier === data.moduleSpecifier);
return { sourceDisplay: [ts.textPart(moduleSpecifier)], codeActions: [codeAction] };
}
@@ -422656,11 +423862,11 @@ var ts;
return ts.getContextualTypeFromParent(previousToken, checker);
case 63 /* SyntaxKind.EqualsToken */:
switch (parent.kind) {
- case 254 /* SyntaxKind.VariableDeclaration */:
+ case 257 /* SyntaxKind.VariableDeclaration */:
return checker.getContextualType(parent.initializer); // TODO: GH#18217
- case 221 /* SyntaxKind.BinaryExpression */:
+ case 223 /* SyntaxKind.BinaryExpression */:
return checker.getTypeAtLocation(parent.left);
- case 285 /* SyntaxKind.JsxAttribute */:
+ case 288 /* SyntaxKind.JsxAttribute */:
return checker.getContextualTypeForJsxAttribute(parent);
default:
return undefined;
@@ -422691,7 +423897,7 @@ var ts;
}
function isModuleSymbol(symbol) {
var _a;
- return !!((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d.kind === 305 /* SyntaxKind.SourceFile */; }));
+ return !!((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d.kind === 308 /* SyntaxKind.SourceFile */; }));
}
function getCompletionData(program, log, sourceFile, compilerOptions, position, preferences, detailsEntryId, host, formatContext, cancellationToken) {
var typeChecker = program.getTypeChecker();
@@ -422748,7 +423954,7 @@ var ts;
currentToken = ts.getTokenAtPosition(sourceFile, position);
if (!currentToken ||
(!ts.isDeclarationName(currentToken) &&
- (currentToken.parent.kind !== 347 /* SyntaxKind.JSDocPropertyTag */ ||
+ (currentToken.parent.kind !== 350 /* SyntaxKind.JSDocPropertyTag */ ||
currentToken.parent.name !== currentToken))) {
// Use as type location if inside tag's type expression
insideJsDocTagTypeExpression = isCurrentlyEditingNode(typeExpression);
@@ -422784,34 +423990,34 @@ var ts;
var isStartingCloseTag = false;
var isJsxInitializer = false;
var isJsxIdentifierExpected = false;
- var importCompletionNode;
+ var importStatementCompletion;
var location = ts.getTouchingPropertyName(sourceFile, position);
var keywordFilters = 0 /* KeywordCompletionFilters.None */;
var isNewIdentifierLocation = false;
var flags = 0 /* CompletionInfoFlags.None */;
if (contextToken) {
- var importStatementCompletion = getImportStatementCompletionInfo(contextToken);
- isNewIdentifierLocation = importStatementCompletion.isNewIdentifierLocation;
- if (importStatementCompletion.keywordCompletion) {
- if (importStatementCompletion.isKeywordOnlyCompletion) {
+ var importStatementCompletionInfo = getImportStatementCompletionInfo(contextToken);
+ if (importStatementCompletionInfo.keywordCompletion) {
+ if (importStatementCompletionInfo.isKeywordOnlyCompletion) {
return {
kind: 4 /* CompletionDataKind.Keywords */,
- keywordCompletions: [keywordToCompletionEntry(importStatementCompletion.keywordCompletion)],
- isNewIdentifierLocation: isNewIdentifierLocation,
+ keywordCompletions: [keywordToCompletionEntry(importStatementCompletionInfo.keywordCompletion)],
+ isNewIdentifierLocation: importStatementCompletionInfo.isNewIdentifierLocation,
};
}
- keywordFilters = keywordFiltersFromSyntaxKind(importStatementCompletion.keywordCompletion);
+ keywordFilters = keywordFiltersFromSyntaxKind(importStatementCompletionInfo.keywordCompletion);
}
- if (importStatementCompletion.replacementNode && preferences.includeCompletionsForImportStatements && preferences.includeCompletionsWithInsertText) {
+ if (importStatementCompletionInfo.replacementSpan && preferences.includeCompletionsForImportStatements && preferences.includeCompletionsWithInsertText) {
// Import statement completions use `insertText`, and also require the `data` property of `CompletionEntryIdentifier`
// added in TypeScript 4.3 to be sent back from the client during `getCompletionEntryDetails`. Since this feature
// is not backward compatible with older clients, the language service defaults to disabling it, allowing newer clients
// to opt in with the `includeCompletionsForImportStatements` user preference.
- importCompletionNode = importStatementCompletion.replacementNode;
flags |= 2 /* CompletionInfoFlags.IsImportStatementCompletion */;
+ importStatementCompletion = importStatementCompletionInfo;
+ isNewIdentifierLocation = importStatementCompletionInfo.isNewIdentifierLocation;
}
// Bail out if this is a known invalid completion location
- if (!importCompletionNode && isCompletionListBlocker(contextToken)) {
+ if (!importStatementCompletionInfo.replacementSpan && isCompletionListBlocker(contextToken)) {
log("Returning an empty list because completion was requested in an invalid position.");
return keywordFilters
? keywordCompletionData(keywordFilters, isJsOnlyLocation, isNewIdentifierDefinitionLocation())
@@ -422822,7 +424028,7 @@ var ts;
isRightOfDot = contextToken.kind === 24 /* SyntaxKind.DotToken */;
isRightOfQuestionDot = contextToken.kind === 28 /* SyntaxKind.QuestionDotToken */;
switch (parent.kind) {
- case 206 /* SyntaxKind.PropertyAccessExpression */:
+ case 208 /* SyntaxKind.PropertyAccessExpression */:
propertyAccessToConvert = parent;
node = propertyAccessToConvert.expression;
var leftmostAccessExpression = ts.getLeftmostAccessExpression(propertyAccessToConvert);
@@ -422838,16 +424044,16 @@ var ts;
return undefined;
}
break;
- case 161 /* SyntaxKind.QualifiedName */:
+ case 163 /* SyntaxKind.QualifiedName */:
node = parent.left;
break;
- case 261 /* SyntaxKind.ModuleDeclaration */:
+ case 264 /* SyntaxKind.ModuleDeclaration */:
node = parent.name;
break;
- case 200 /* SyntaxKind.ImportType */:
+ case 202 /* SyntaxKind.ImportType */:
node = parent;
break;
- case 231 /* SyntaxKind.MetaProperty */:
+ case 233 /* SyntaxKind.MetaProperty */:
node = parent.getFirstToken(sourceFile);
ts.Debug.assert(node.kind === 100 /* SyntaxKind.ImportKeyword */ || node.kind === 103 /* SyntaxKind.NewKeyword */);
break;
@@ -422857,11 +424063,11 @@ var ts;
return undefined;
}
}
- else if (!importCompletionNode && sourceFile.languageVariant === 1 /* LanguageVariant.JSX */) {
+ else if (!importStatementCompletion) {
//
// If the tagname is a property access expression, we will then walk up to the top most of property access expression.
// Then, try to get a JSX container and its associated attributes type.
- if (parent && parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) {
+ if (parent && parent.kind === 208 /* SyntaxKind.PropertyAccessExpression */) {
contextToken = parent;
parent = parent.parent;
}
@@ -422869,46 +424075,46 @@ var ts;
if (currentToken.parent === location) {
switch (currentToken.kind) {
case 31 /* SyntaxKind.GreaterThanToken */:
- if (currentToken.parent.kind === 278 /* SyntaxKind.JsxElement */ || currentToken.parent.kind === 280 /* SyntaxKind.JsxOpeningElement */) {
+ if (currentToken.parent.kind === 281 /* SyntaxKind.JsxElement */ || currentToken.parent.kind === 283 /* SyntaxKind.JsxOpeningElement */) {
location = currentToken;
}
break;
case 43 /* SyntaxKind.SlashToken */:
- if (currentToken.parent.kind === 279 /* SyntaxKind.JsxSelfClosingElement */) {
+ if (currentToken.parent.kind === 282 /* SyntaxKind.JsxSelfClosingElement */) {
location = currentToken;
}
break;
}
}
switch (parent.kind) {
- case 281 /* SyntaxKind.JsxClosingElement */:
+ case 284 /* SyntaxKind.JsxClosingElement */:
if (contextToken.kind === 43 /* SyntaxKind.SlashToken */) {
isStartingCloseTag = true;
location = contextToken;
}
break;
- case 221 /* SyntaxKind.BinaryExpression */:
+ case 223 /* SyntaxKind.BinaryExpression */:
if (!binaryExpressionMayBeOpenTag(parent)) {
break;
}
// falls through
- case 279 /* SyntaxKind.JsxSelfClosingElement */:
- case 278 /* SyntaxKind.JsxElement */:
- case 280 /* SyntaxKind.JsxOpeningElement */:
+ case 282 /* SyntaxKind.JsxSelfClosingElement */:
+ case 281 /* SyntaxKind.JsxElement */:
+ case 283 /* SyntaxKind.JsxOpeningElement */:
isJsxIdentifierExpected = true;
if (contextToken.kind === 29 /* SyntaxKind.LessThanToken */) {
isRightOfOpenTag = true;
location = contextToken;
}
break;
- case 288 /* SyntaxKind.JsxExpression */:
- case 287 /* SyntaxKind.JsxSpreadAttribute */:
+ case 291 /* SyntaxKind.JsxExpression */:
+ case 290 /* SyntaxKind.JsxSpreadAttribute */:
// For `
`, `parent` will be `{true}` and `previousToken` will be `}`
if (previousToken.kind === 19 /* SyntaxKind.CloseBraceToken */ && currentToken.kind === 31 /* SyntaxKind.GreaterThanToken */) {
isJsxIdentifierExpected = true;
}
break;
- case 285 /* SyntaxKind.JsxAttribute */:
+ case 288 /* SyntaxKind.JsxAttribute */:
// For `
`, `parent` will be JsxAttribute and `previousToken` will be its initializer
if (parent.initializer === previousToken &&
previousToken.end < position) {
@@ -423000,19 +424206,19 @@ var ts;
isTypeOnlyLocation: isTypeOnlyLocation,
isJsxIdentifierExpected: isJsxIdentifierExpected,
isRightOfOpenTag: isRightOfOpenTag,
- importCompletionNode: importCompletionNode,
+ importStatementCompletion: importStatementCompletion,
hasUnresolvedAutoImports: hasUnresolvedAutoImports,
flags: flags,
};
function isTagWithTypeExpression(tag) {
switch (tag.kind) {
- case 340 /* SyntaxKind.JSDocParameterTag */:
- case 347 /* SyntaxKind.JSDocPropertyTag */:
- case 341 /* SyntaxKind.JSDocReturnTag */:
- case 343 /* SyntaxKind.JSDocTypeTag */:
- case 345 /* SyntaxKind.JSDocTypedefTag */:
+ case 343 /* SyntaxKind.JSDocParameterTag */:
+ case 350 /* SyntaxKind.JSDocPropertyTag */:
+ case 344 /* SyntaxKind.JSDocReturnTag */:
+ case 346 /* SyntaxKind.JSDocTypeTag */:
+ case 348 /* SyntaxKind.JSDocTypedefTag */:
return true;
- case 344 /* SyntaxKind.JSDocTemplateTag */:
+ case 347 /* SyntaxKind.JSDocTemplateTag */:
return !!tag.constraint;
default:
return false;
@@ -423021,7 +424227,7 @@ var ts;
function tryGetTypeExpressionFromTag(tag) {
if (isTagWithTypeExpression(tag)) {
var typeExpression = ts.isJSDocTemplateTag(tag) ? tag.constraint : tag.typeExpression;
- return typeExpression && typeExpression.kind === 309 /* SyntaxKind.JSDocTypeExpression */ ? typeExpression : undefined;
+ return typeExpression && typeExpression.kind === 312 /* SyntaxKind.JSDocTypeExpression */ ? typeExpression : undefined;
}
return undefined;
}
@@ -423064,7 +424270,7 @@ var ts;
// If the module is merged with a value, we must get the type of the class and add its propertes (for inherited static methods).
if (!isTypeLocation &&
symbol.declarations &&
- symbol.declarations.some(function (d) { return d.kind !== 305 /* SyntaxKind.SourceFile */ && d.kind !== 261 /* SyntaxKind.ModuleDeclaration */ && d.kind !== 260 /* SyntaxKind.EnumDeclaration */; })) {
+ symbol.declarations.some(function (d) { return d.kind !== 308 /* SyntaxKind.SourceFile */ && d.kind !== 264 /* SyntaxKind.ModuleDeclaration */ && d.kind !== 263 /* SyntaxKind.EnumDeclaration */; })) {
var type = typeChecker.getTypeOfSymbolAtLocation(symbol, node).getNonOptionalType();
var insertQuestionDot = false;
if (type.isNullableType()) {
@@ -423110,7 +424316,7 @@ var ts;
if (isRightOfQuestionDot && ts.some(type.getCallSignatures())) {
isNewIdentifierLocation = true;
}
- var propertyAccess = node.kind === 200 /* SyntaxKind.ImportType */ ? node : node.parent;
+ var propertyAccess = node.kind === 202 /* SyntaxKind.ImportType */ ? node : node.parent;
if (inCheckedFile) {
for (var _i = 0, _a = type.getApparentProperties(); _i < _a.length; _i++) {
var symbol = _a[_i];
@@ -423254,7 +424460,7 @@ var ts;
return 1 /* GlobalsSearch.Success */;
}
function tryGetImportCompletionSymbols() {
- if (!importCompletionNode)
+ if (!importStatementCompletion)
return 0 /* GlobalsSearch.Continue */;
isNewIdentifierLocation = true;
collectAutoImports();
@@ -423317,7 +424523,7 @@ var ts;
}
}
// Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions`
- if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 305 /* SyntaxKind.SourceFile */) {
+ if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 308 /* SyntaxKind.SourceFile */) {
var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false, ts.isClassLike(scopeNode.parent) ? scopeNode : undefined);
if (thisType && !isProbablyGlobalType(thisType, sourceFile, typeChecker)) {
for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker); _i < _a.length; _i++) {
@@ -423337,7 +424543,7 @@ var ts;
}
function shouldOfferImportCompletions() {
// If already typing an import statement, provide completions for it.
- if (importCompletionNode)
+ if (importStatementCompletion)
return true;
// If current completion is for non-contextual Object literal shortahands, ignore auto-import symbols
if (isNonContextualObjectLiteral)
@@ -423356,10 +424562,10 @@ var ts;
}
function isSnippetScope(scopeNode) {
switch (scopeNode.kind) {
- case 305 /* SyntaxKind.SourceFile */:
- case 223 /* SyntaxKind.TemplateExpression */:
- case 288 /* SyntaxKind.JsxExpression */:
- case 235 /* SyntaxKind.Block */:
+ case 308 /* SyntaxKind.SourceFile */:
+ case 225 /* SyntaxKind.TemplateExpression */:
+ case 291 /* SyntaxKind.JsxExpression */:
+ case 238 /* SyntaxKind.Block */:
return true;
default:
return ts.isStatement(scopeNode);
@@ -423367,7 +424573,7 @@ var ts;
}
function isTypeOnlyCompletion() {
return insideJsDocTagTypeExpression
- || !!importCompletionNode && ts.isTypeOnlyImportOrExportDeclaration(location.parent)
+ || !!importStatementCompletion && ts.isTypeOnlyImportOrExportDeclaration(location.parent)
|| !isContextTokenValueLocation(contextToken) &&
(ts.isPossiblyTypeArgumentPosition(contextToken, sourceFile, typeChecker)
|| ts.isPartOfTypeNode(location)
@@ -423376,28 +424582,30 @@ var ts;
function isContextTokenValueLocation(contextToken) {
return contextToken &&
((contextToken.kind === 112 /* SyntaxKind.TypeOfKeyword */ &&
- (contextToken.parent.kind === 181 /* SyntaxKind.TypeQuery */ || ts.isTypeOfExpression(contextToken.parent))) ||
- (contextToken.kind === 128 /* SyntaxKind.AssertsKeyword */ && contextToken.parent.kind === 177 /* SyntaxKind.TypePredicate */));
+ (contextToken.parent.kind === 183 /* SyntaxKind.TypeQuery */ || ts.isTypeOfExpression(contextToken.parent))) ||
+ (contextToken.kind === 129 /* SyntaxKind.AssertsKeyword */ && contextToken.parent.kind === 179 /* SyntaxKind.TypePredicate */));
}
function isContextTokenTypeLocation(contextToken) {
if (contextToken) {
var parentKind = contextToken.parent.kind;
switch (contextToken.kind) {
case 58 /* SyntaxKind.ColonToken */:
- return parentKind === 167 /* SyntaxKind.PropertyDeclaration */ ||
- parentKind === 166 /* SyntaxKind.PropertySignature */ ||
- parentKind === 164 /* SyntaxKind.Parameter */ ||
- parentKind === 254 /* SyntaxKind.VariableDeclaration */ ||
+ return parentKind === 169 /* SyntaxKind.PropertyDeclaration */ ||
+ parentKind === 168 /* SyntaxKind.PropertySignature */ ||
+ parentKind === 166 /* SyntaxKind.Parameter */ ||
+ parentKind === 257 /* SyntaxKind.VariableDeclaration */ ||
ts.isFunctionLikeKind(parentKind);
case 63 /* SyntaxKind.EqualsToken */:
- return parentKind === 259 /* SyntaxKind.TypeAliasDeclaration */;
- case 127 /* SyntaxKind.AsKeyword */:
- return parentKind === 229 /* SyntaxKind.AsExpression */;
+ return parentKind === 262 /* SyntaxKind.TypeAliasDeclaration */;
+ case 128 /* SyntaxKind.AsKeyword */:
+ return parentKind === 231 /* SyntaxKind.AsExpression */;
case 29 /* SyntaxKind.LessThanToken */:
- return parentKind === 178 /* SyntaxKind.TypeReference */ ||
- parentKind === 211 /* SyntaxKind.TypeAssertionExpression */;
+ return parentKind === 180 /* SyntaxKind.TypeReference */ ||
+ parentKind === 213 /* SyntaxKind.TypeAssertionExpression */;
case 94 /* SyntaxKind.ExtendsKeyword */:
- return parentKind === 163 /* SyntaxKind.TypeParameter */;
+ return parentKind === 165 /* SyntaxKind.TypeParameter */;
+ case 150 /* SyntaxKind.SatisfiesKeyword */:
+ return parentKind === 235 /* SyntaxKind.SatisfiesExpression */;
}
}
return false;
@@ -423415,8 +424623,7 @@ var ts;
flags |= 1 /* CompletionInfoFlags.MayIncludeAutoImports */;
// import { type | -> token text should be blank
var isAfterTypeOnlyImportSpecifierModifier = previousToken === contextToken
- && importCompletionNode
- && couldBeTypeOnlyImportSpecifier(importCompletionNode, contextToken);
+ && importStatementCompletion;
var lowerCaseTokenText = isAfterTypeOnlyImportSpecifierModifier ? "" :
previousToken && ts.isIdentifier(previousToken) ? previousToken.text.toLowerCase() :
"";
@@ -423424,14 +424631,14 @@ var ts;
var exportInfo = ts.getExportInfoMap(sourceFile, host, program, preferences, cancellationToken);
var packageJsonAutoImportProvider = (_b = host.getPackageJsonAutoImportProvider) === null || _b === void 0 ? void 0 : _b.call(host);
var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, preferences, host);
- resolvingModuleSpecifiers("collectAutoImports", host, importSpecifierResolver || (importSpecifierResolver = ts.codefix.createImportSpecifierResolver(sourceFile, program, host, preferences)), program, position, preferences, !!importCompletionNode, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
+ resolvingModuleSpecifiers("collectAutoImports", host, importSpecifierResolver || (importSpecifierResolver = ts.codefix.createImportSpecifierResolver(sourceFile, program, host, preferences)), program, position, preferences, !!importStatementCompletion, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
exportInfo.search(sourceFile.path,
/*preferCapitalized*/ isRightOfOpenTag, function (symbolName, targetFlags) {
if (!ts.isIdentifierText(symbolName, ts.getEmitScriptTarget(host.getCompilationSettings())))
return false;
if (!detailsEntryId && ts.isStringANonContextualKeyword(symbolName))
return false;
- if (!isTypeOnlyLocation && !importCompletionNode && !(targetFlags & 111551 /* SymbolFlags.Value */))
+ if (!isTypeOnlyLocation && !importStatementCompletion && !(targetFlags & 111551 /* SymbolFlags.Value */))
return false;
if (isTypeOnlyLocation && !(targetFlags & (1536 /* SymbolFlags.Module */ | 788968 /* SymbolFlags.Type */)))
return false;
@@ -423512,7 +424719,7 @@ var ts;
return;
}
symbolToOriginInfoMap[symbols.length] = origin;
- symbolToSortTextMap[symbolId] = importCompletionNode ? Completions.SortText.LocationPriority : Completions.SortText.AutoImportSuggestions;
+ symbolToSortTextMap[symbolId] = importStatementCompletion ? Completions.SortText.LocationPriority : Completions.SortText.AutoImportSuggestions;
symbols.push(symbol);
}
/* Mutates `symbols` and `symbolToOriginInfoMap`. */
@@ -423588,18 +424795,18 @@ var ts;
// - contextToken: GreaterThanToken (before cursor)
// - location: JsxSelfClosingElement or JsxOpeningElement
// - contextToken.parent === location
- if (location === contextToken.parent && (location.kind === 280 /* SyntaxKind.JsxOpeningElement */ || location.kind === 279 /* SyntaxKind.JsxSelfClosingElement */)) {
+ if (location === contextToken.parent && (location.kind === 283 /* SyntaxKind.JsxOpeningElement */ || location.kind === 282 /* SyntaxKind.JsxSelfClosingElement */)) {
return false;
}
- if (contextToken.parent.kind === 280 /* SyntaxKind.JsxOpeningElement */) {
+ if (contextToken.parent.kind === 283 /* SyntaxKind.JsxOpeningElement */) {
//
/**/
// - contextToken: GreaterThanToken (before cursor)
// - location: JSXElement
// - different parents (JSXOpeningElement, JSXElement)
- return location.parent.kind !== 280 /* SyntaxKind.JsxOpeningElement */;
+ return location.parent.kind !== 283 /* SyntaxKind.JsxOpeningElement */;
}
- if (contextToken.parent.kind === 281 /* SyntaxKind.JsxClosingElement */ || contextToken.parent.kind === 279 /* SyntaxKind.JsxSelfClosingElement */) {
- return !!contextToken.parent.parent && contextToken.parent.parent.kind === 278 /* SyntaxKind.JsxElement */;
+ if (contextToken.parent.kind === 284 /* SyntaxKind.JsxClosingElement */ || contextToken.parent.kind === 282 /* SyntaxKind.JsxSelfClosingElement */) {
+ return !!contextToken.parent.parent && contextToken.parent.parent.kind === 281 /* SyntaxKind.JsxElement */;
}
}
return false;
@@ -423611,44 +424818,44 @@ var ts;
// Previous token may have been a keyword that was converted to an identifier.
switch (tokenKind) {
case 27 /* SyntaxKind.CommaToken */:
- return containingNodeKind === 208 /* SyntaxKind.CallExpression */ // func( a, |
- || containingNodeKind === 171 /* SyntaxKind.Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */
- || containingNodeKind === 209 /* SyntaxKind.NewExpression */ // new C(a, |
- || containingNodeKind === 204 /* SyntaxKind.ArrayLiteralExpression */ // [a, |
- || containingNodeKind === 221 /* SyntaxKind.BinaryExpression */ // const x = (a, |
- || containingNodeKind === 179 /* SyntaxKind.FunctionType */ // var x: (s: string, list|
- || containingNodeKind === 205 /* SyntaxKind.ObjectLiteralExpression */; // const obj = { x, |
+ return containingNodeKind === 210 /* SyntaxKind.CallExpression */ // func( a, |
+ || containingNodeKind === 173 /* SyntaxKind.Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */
+ || containingNodeKind === 211 /* SyntaxKind.NewExpression */ // new C(a, |
+ || containingNodeKind === 206 /* SyntaxKind.ArrayLiteralExpression */ // [a, |
+ || containingNodeKind === 223 /* SyntaxKind.BinaryExpression */ // const x = (a, |
+ || containingNodeKind === 181 /* SyntaxKind.FunctionType */ // var x: (s: string, list|
+ || containingNodeKind === 207 /* SyntaxKind.ObjectLiteralExpression */; // const obj = { x, |
case 20 /* SyntaxKind.OpenParenToken */:
- return containingNodeKind === 208 /* SyntaxKind.CallExpression */ // func( |
- || containingNodeKind === 171 /* SyntaxKind.Constructor */ // constructor( |
- || containingNodeKind === 209 /* SyntaxKind.NewExpression */ // new C(a|
- || containingNodeKind === 212 /* SyntaxKind.ParenthesizedExpression */ // const x = (a|
- || containingNodeKind === 191 /* SyntaxKind.ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */
+ return containingNodeKind === 210 /* SyntaxKind.CallExpression */ // func( |
+ || containingNodeKind === 173 /* SyntaxKind.Constructor */ // constructor( |
+ || containingNodeKind === 211 /* SyntaxKind.NewExpression */ // new C(a|
+ || containingNodeKind === 214 /* SyntaxKind.ParenthesizedExpression */ // const x = (a|
+ || containingNodeKind === 193 /* SyntaxKind.ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */
case 22 /* SyntaxKind.OpenBracketToken */:
- return containingNodeKind === 204 /* SyntaxKind.ArrayLiteralExpression */ // [ |
- || containingNodeKind === 176 /* SyntaxKind.IndexSignature */ // [ | : string ]
- || containingNodeKind === 162 /* SyntaxKind.ComputedPropertyName */; // [ | /* this can become an index signature */
- case 141 /* SyntaxKind.ModuleKeyword */: // module |
- case 142 /* SyntaxKind.NamespaceKeyword */: // namespace |
+ return containingNodeKind === 206 /* SyntaxKind.ArrayLiteralExpression */ // [ |
+ || containingNodeKind === 178 /* SyntaxKind.IndexSignature */ // [ | : string ]
+ || containingNodeKind === 164 /* SyntaxKind.ComputedPropertyName */; // [ | /* this can become an index signature */
+ case 142 /* SyntaxKind.ModuleKeyword */: // module |
+ case 143 /* SyntaxKind.NamespaceKeyword */: // namespace |
case 100 /* SyntaxKind.ImportKeyword */: // import |
return true;
case 24 /* SyntaxKind.DotToken */:
- return containingNodeKind === 261 /* SyntaxKind.ModuleDeclaration */; // module A.|
+ return containingNodeKind === 264 /* SyntaxKind.ModuleDeclaration */; // module A.|
case 18 /* SyntaxKind.OpenBraceToken */:
- return containingNodeKind === 257 /* SyntaxKind.ClassDeclaration */ // class A { |
- || containingNodeKind === 205 /* SyntaxKind.ObjectLiteralExpression */; // const obj = { |
+ return containingNodeKind === 260 /* SyntaxKind.ClassDeclaration */ // class A { |
+ || containingNodeKind === 207 /* SyntaxKind.ObjectLiteralExpression */; // const obj = { |
case 63 /* SyntaxKind.EqualsToken */:
- return containingNodeKind === 254 /* SyntaxKind.VariableDeclaration */ // const x = a|
- || containingNodeKind === 221 /* SyntaxKind.BinaryExpression */; // x = a|
+ return containingNodeKind === 257 /* SyntaxKind.VariableDeclaration */ // const x = a|
+ || containingNodeKind === 223 /* SyntaxKind.BinaryExpression */; // x = a|
case 15 /* SyntaxKind.TemplateHead */:
- return containingNodeKind === 223 /* SyntaxKind.TemplateExpression */; // `aa ${|
+ return containingNodeKind === 225 /* SyntaxKind.TemplateExpression */; // `aa ${|
case 16 /* SyntaxKind.TemplateMiddle */:
- return containingNodeKind === 233 /* SyntaxKind.TemplateSpan */; // `aa ${10} dd ${|
- case 131 /* SyntaxKind.AsyncKeyword */:
- return containingNodeKind === 169 /* SyntaxKind.MethodDeclaration */ // const obj = { async c|()
- || containingNodeKind === 297 /* SyntaxKind.ShorthandPropertyAssignment */; // const obj = { async c|
+ return containingNodeKind === 236 /* SyntaxKind.TemplateSpan */; // `aa ${10} dd ${|
+ case 132 /* SyntaxKind.AsyncKeyword */:
+ return containingNodeKind === 171 /* SyntaxKind.MethodDeclaration */ // const obj = { async c|()
+ || containingNodeKind === 300 /* SyntaxKind.ShorthandPropertyAssignment */; // const obj = { async c|
case 41 /* SyntaxKind.AsteriskToken */:
- return containingNodeKind === 169 /* SyntaxKind.MethodDeclaration */; // const obj = { * c|
+ return containingNodeKind === 171 /* SyntaxKind.MethodDeclaration */; // const obj = { * c|
}
if (isClassMemberCompletionKeyword(tokenKind)) {
return true;
@@ -423698,7 +424905,7 @@ var ts;
completionKind = 0 /* CompletionKind.ObjectPropertyDeclaration */;
var typeMembers;
var existingMembers;
- if (objectLikeContainer.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) {
+ if (objectLikeContainer.kind === 207 /* SyntaxKind.ObjectLiteralExpression */) {
var instantiatedType = tryGetObjectLiteralContextualType(objectLikeContainer, typeChecker);
// Check completions for Object property value shorthand
if (instantiatedType === undefined) {
@@ -423723,7 +424930,7 @@ var ts;
}
}
else {
- ts.Debug.assert(objectLikeContainer.kind === 201 /* SyntaxKind.ObjectBindingPattern */);
+ ts.Debug.assert(objectLikeContainer.kind === 203 /* SyntaxKind.ObjectBindingPattern */);
// We are *only* completing on properties from the type being destructured.
isNewIdentifierLocation = false;
var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent);
@@ -423734,12 +424941,12 @@ var ts;
// through type declaration or inference.
// Also proceed if rootDeclaration is a parameter and if its containing function expression/arrow function is contextually typed -
// type of parameter will flow in from the contextual type of the function
- var canGetType = ts.hasInitializer(rootDeclaration) || !!ts.getEffectiveTypeAnnotationNode(rootDeclaration) || rootDeclaration.parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */;
- if (!canGetType && rootDeclaration.kind === 164 /* SyntaxKind.Parameter */) {
+ var canGetType = ts.hasInitializer(rootDeclaration) || !!ts.getEffectiveTypeAnnotationNode(rootDeclaration) || rootDeclaration.parent.parent.kind === 247 /* SyntaxKind.ForOfStatement */;
+ if (!canGetType && rootDeclaration.kind === 166 /* SyntaxKind.Parameter */) {
if (ts.isExpression(rootDeclaration.parent)) {
canGetType = !!typeChecker.getContextualType(rootDeclaration.parent);
}
- else if (rootDeclaration.parent.kind === 169 /* SyntaxKind.MethodDeclaration */ || rootDeclaration.parent.kind === 173 /* SyntaxKind.SetAccessor */) {
+ else if (rootDeclaration.parent.kind === 171 /* SyntaxKind.MethodDeclaration */ || rootDeclaration.parent.kind === 175 /* SyntaxKind.SetAccessor */) {
canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent);
}
}
@@ -423758,7 +424965,7 @@ var ts;
var filteredMembers = filterObjectMembersList(typeMembers, ts.Debug.checkDefined(existingMembers));
symbols = ts.concatenate(symbols, filteredMembers);
setSortTextToOptionalMember();
- if (objectLikeContainer.kind === 205 /* SyntaxKind.ObjectLiteralExpression */
+ if (objectLikeContainer.kind === 207 /* SyntaxKind.ObjectLiteralExpression */
&& preferences.includeCompletionsWithObjectLiteralMethodSnippets
&& preferences.includeCompletionsWithInsertText) {
transformObjectLiteralMembersSortText(symbolsStartIndex);
@@ -423793,10 +425000,10 @@ var ts;
keywordFilters = 8 /* KeywordCompletionFilters.TypeKeyword */;
}
// try to show exported member for imported/re-exported module
- var moduleSpecifier = (namedImportsOrExports.kind === 269 /* SyntaxKind.NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier;
+ var moduleSpecifier = (namedImportsOrExports.kind === 272 /* SyntaxKind.NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier;
if (!moduleSpecifier) {
isNewIdentifierLocation = true;
- return namedImportsOrExports.kind === 269 /* SyntaxKind.NamedImports */ ? 2 /* GlobalsSearch.Fail */ : 0 /* GlobalsSearch.Continue */;
+ return namedImportsOrExports.kind === 272 /* SyntaxKind.NamedImports */ ? 2 /* GlobalsSearch.Fail */ : 0 /* GlobalsSearch.Continue */;
}
var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); // TODO: GH#18217
if (!moduleSpecifierSymbol) {
@@ -423941,11 +425148,11 @@ var ts;
case 30 /* SyntaxKind.LessThanSlashToken */:
case 43 /* SyntaxKind.SlashToken */:
case 79 /* SyntaxKind.Identifier */:
- case 206 /* SyntaxKind.PropertyAccessExpression */:
- case 286 /* SyntaxKind.JsxAttributes */:
- case 285 /* SyntaxKind.JsxAttribute */:
- case 287 /* SyntaxKind.JsxSpreadAttribute */:
- if (parent && (parent.kind === 279 /* SyntaxKind.JsxSelfClosingElement */ || parent.kind === 280 /* SyntaxKind.JsxOpeningElement */)) {
+ case 208 /* SyntaxKind.PropertyAccessExpression */:
+ case 289 /* SyntaxKind.JsxAttributes */:
+ case 288 /* SyntaxKind.JsxAttribute */:
+ case 290 /* SyntaxKind.JsxSpreadAttribute */:
+ if (parent && (parent.kind === 282 /* SyntaxKind.JsxSelfClosingElement */ || parent.kind === 283 /* SyntaxKind.JsxOpeningElement */)) {
if (contextToken.kind === 31 /* SyntaxKind.GreaterThanToken */) {
var precedingToken = ts.findPrecedingToken(contextToken.pos, sourceFile, /*startNode*/ undefined);
if (!parent.typeArguments || (precedingToken && precedingToken.kind === 43 /* SyntaxKind.SlashToken */))
@@ -423953,7 +425160,7 @@ var ts;
}
return parent;
}
- else if (parent.kind === 285 /* SyntaxKind.JsxAttribute */) {
+ else if (parent.kind === 288 /* SyntaxKind.JsxAttribute */) {
// Currently we parse JsxOpeningLikeElement as:
// JsxOpeningLikeElement
// attributes: JsxAttributes
@@ -423965,7 +425172,7 @@ var ts;
// its parent is a JsxExpression, whose parent is a JsxAttribute,
// whose parent is a JsxOpeningLikeElement
case 10 /* SyntaxKind.StringLiteral */:
- if (parent && ((parent.kind === 285 /* SyntaxKind.JsxAttribute */) || (parent.kind === 287 /* SyntaxKind.JsxSpreadAttribute */))) {
+ if (parent && ((parent.kind === 288 /* SyntaxKind.JsxAttribute */) || (parent.kind === 290 /* SyntaxKind.JsxSpreadAttribute */))) {
// Currently we parse JsxOpeningLikeElement as:
// JsxOpeningLikeElement
// attributes: JsxAttributes
@@ -423975,8 +425182,8 @@ var ts;
break;
case 19 /* SyntaxKind.CloseBraceToken */:
if (parent &&
- parent.kind === 288 /* SyntaxKind.JsxExpression */ &&
- parent.parent && parent.parent.kind === 285 /* SyntaxKind.JsxAttribute */) {
+ parent.kind === 291 /* SyntaxKind.JsxExpression */ &&
+ parent.parent && parent.parent.kind === 288 /* SyntaxKind.JsxAttribute */) {
// Currently we parse JsxOpeningLikeElement as:
// JsxOpeningLikeElement
// attributes: JsxAttributes
@@ -423984,7 +425191,7 @@ var ts;
// each JsxAttribute can have initializer as JsxExpression
return parent.parent.parent.parent;
}
- if (parent && parent.kind === 287 /* SyntaxKind.JsxSpreadAttribute */) {
+ if (parent && parent.kind === 290 /* SyntaxKind.JsxSpreadAttribute */) {
// Currently we parse JsxOpeningLikeElement as:
// JsxOpeningLikeElement
// attributes: JsxAttributes
@@ -424004,54 +425211,54 @@ var ts;
var containingNodeKind = parent.kind;
switch (contextToken.kind) {
case 27 /* SyntaxKind.CommaToken */:
- return containingNodeKind === 254 /* SyntaxKind.VariableDeclaration */ ||
+ return containingNodeKind === 257 /* SyntaxKind.VariableDeclaration */ ||
isVariableDeclarationListButNotTypeArgument(contextToken) ||
- containingNodeKind === 237 /* SyntaxKind.VariableStatement */ ||
- containingNodeKind === 260 /* SyntaxKind.EnumDeclaration */ || // enum a { foo, |
+ containingNodeKind === 240 /* SyntaxKind.VariableStatement */ ||
+ containingNodeKind === 263 /* SyntaxKind.EnumDeclaration */ || // enum a { foo, |
isFunctionLikeButNotConstructor(containingNodeKind) ||
- containingNodeKind === 258 /* SyntaxKind.InterfaceDeclaration */ || // interface A= contextToken.pos);
case 24 /* SyntaxKind.DotToken */:
- return containingNodeKind === 202 /* SyntaxKind.ArrayBindingPattern */; // var [.|
+ return containingNodeKind === 204 /* SyntaxKind.ArrayBindingPattern */; // var [.|
case 58 /* SyntaxKind.ColonToken */:
- return containingNodeKind === 203 /* SyntaxKind.BindingElement */; // var {x :html|
+ return containingNodeKind === 205 /* SyntaxKind.BindingElement */; // var {x :html|
case 22 /* SyntaxKind.OpenBracketToken */:
- return containingNodeKind === 202 /* SyntaxKind.ArrayBindingPattern */; // var [x|
+ return containingNodeKind === 204 /* SyntaxKind.ArrayBindingPattern */; // var [x|
case 20 /* SyntaxKind.OpenParenToken */:
- return containingNodeKind === 292 /* SyntaxKind.CatchClause */ ||
+ return containingNodeKind === 295 /* SyntaxKind.CatchClause */ ||
isFunctionLikeButNotConstructor(containingNodeKind);
case 18 /* SyntaxKind.OpenBraceToken */:
- return containingNodeKind === 260 /* SyntaxKind.EnumDeclaration */; // enum a { |
+ return containingNodeKind === 263 /* SyntaxKind.EnumDeclaration */; // enum a { |
case 29 /* SyntaxKind.LessThanToken */:
- return containingNodeKind === 257 /* SyntaxKind.ClassDeclaration */ || // class A< |
- containingNodeKind === 226 /* SyntaxKind.ClassExpression */ || // var C = class D< |
- containingNodeKind === 258 /* SyntaxKind.InterfaceDeclaration */ || // interface A< |
- containingNodeKind === 259 /* SyntaxKind.TypeAliasDeclaration */ || // type List< |
+ return containingNodeKind === 260 /* SyntaxKind.ClassDeclaration */ || // class A< |
+ containingNodeKind === 228 /* SyntaxKind.ClassExpression */ || // var C = class D< |
+ containingNodeKind === 261 /* SyntaxKind.InterfaceDeclaration */ || // interface A< |
+ containingNodeKind === 262 /* SyntaxKind.TypeAliasDeclaration */ || // type List< |
ts.isFunctionLikeKind(containingNodeKind);
case 124 /* SyntaxKind.StaticKeyword */:
- return containingNodeKind === 167 /* SyntaxKind.PropertyDeclaration */ && !ts.isClassLike(parent.parent);
+ return containingNodeKind === 169 /* SyntaxKind.PropertyDeclaration */ && !ts.isClassLike(parent.parent);
case 25 /* SyntaxKind.DotDotDotToken */:
- return containingNodeKind === 164 /* SyntaxKind.Parameter */ ||
- (!!parent.parent && parent.parent.kind === 202 /* SyntaxKind.ArrayBindingPattern */); // var [...z|
+ return containingNodeKind === 166 /* SyntaxKind.Parameter */ ||
+ (!!parent.parent && parent.parent.kind === 204 /* SyntaxKind.ArrayBindingPattern */); // var [...z|
case 123 /* SyntaxKind.PublicKeyword */:
case 121 /* SyntaxKind.PrivateKeyword */:
case 122 /* SyntaxKind.ProtectedKeyword */:
- return containingNodeKind === 164 /* SyntaxKind.Parameter */ && !ts.isConstructorDeclaration(parent.parent);
- case 127 /* SyntaxKind.AsKeyword */:
- return containingNodeKind === 270 /* SyntaxKind.ImportSpecifier */ ||
- containingNodeKind === 275 /* SyntaxKind.ExportSpecifier */ ||
- containingNodeKind === 268 /* SyntaxKind.NamespaceImport */;
- case 136 /* SyntaxKind.GetKeyword */:
- case 149 /* SyntaxKind.SetKeyword */:
+ return containingNodeKind === 166 /* SyntaxKind.Parameter */ && !ts.isConstructorDeclaration(parent.parent);
+ case 128 /* SyntaxKind.AsKeyword */:
+ return containingNodeKind === 273 /* SyntaxKind.ImportSpecifier */ ||
+ containingNodeKind === 278 /* SyntaxKind.ExportSpecifier */ ||
+ containingNodeKind === 271 /* SyntaxKind.NamespaceImport */;
+ case 137 /* SyntaxKind.GetKeyword */:
+ case 151 /* SyntaxKind.SetKeyword */:
return !isFromObjectTypeDeclaration(contextToken);
case 79 /* SyntaxKind.Identifier */:
- if (containingNodeKind === 270 /* SyntaxKind.ImportSpecifier */ &&
+ if (containingNodeKind === 273 /* SyntaxKind.ImportSpecifier */ &&
contextToken === parent.name &&
contextToken.text === "type") {
// import { type | }
@@ -424066,11 +425273,11 @@ var ts;
case 100 /* SyntaxKind.ImportKeyword */:
case 119 /* SyntaxKind.LetKeyword */:
case 85 /* SyntaxKind.ConstKeyword */:
- case 137 /* SyntaxKind.InferKeyword */:
+ case 138 /* SyntaxKind.InferKeyword */:
return true;
- case 152 /* SyntaxKind.TypeKeyword */:
+ case 154 /* SyntaxKind.TypeKeyword */:
// import { type foo| }
- return containingNodeKind !== 270 /* SyntaxKind.ImportSpecifier */;
+ return containingNodeKind !== 273 /* SyntaxKind.ImportSpecifier */;
case 41 /* SyntaxKind.AsteriskToken */:
return ts.isFunctionLike(contextToken.parent) && !ts.isMethodDeclaration(contextToken.parent);
}
@@ -424095,7 +425302,7 @@ var ts;
case 126 /* SyntaxKind.AbstractKeyword */:
case 84 /* SyntaxKind.ClassKeyword */:
case 85 /* SyntaxKind.ConstKeyword */:
- case 135 /* SyntaxKind.DeclareKeyword */:
+ case 136 /* SyntaxKind.DeclareKeyword */:
case 92 /* SyntaxKind.EnumKeyword */:
case 98 /* SyntaxKind.FunctionKeyword */:
case 118 /* SyntaxKind.InterfaceKeyword */:
@@ -424106,7 +425313,7 @@ var ts;
case 124 /* SyntaxKind.StaticKeyword */:
case 113 /* SyntaxKind.VarKeyword */:
return true;
- case 131 /* SyntaxKind.AsyncKeyword */:
+ case 132 /* SyntaxKind.AsyncKeyword */:
return ts.isPropertyDeclaration(contextToken.parent);
}
// If we are inside a class declaration, and `constructor` is totally not present,
@@ -424115,7 +425322,7 @@ var ts;
if (ancestorClassLike && contextToken === previousToken && isPreviousPropertyDeclarationTerminated(contextToken, position)) {
return false; // Don't block completions.
}
- var ancestorPropertyDeclaraion = ts.getAncestor(contextToken.parent, 167 /* SyntaxKind.PropertyDeclaration */);
+ var ancestorPropertyDeclaraion = ts.getAncestor(contextToken.parent, 169 /* SyntaxKind.PropertyDeclaration */);
// If we are inside a class declaration and typing `constructor` after property declaration...
if (ancestorPropertyDeclaraion
&& contextToken !== previousToken
@@ -424147,7 +425354,7 @@ var ts;
|| !ts.positionsAreOnSameLine(contextToken.end, position, sourceFile));
}
function isFunctionLikeButNotConstructor(kind) {
- return ts.isFunctionLikeKind(kind) && kind !== 171 /* SyntaxKind.Constructor */;
+ return ts.isFunctionLikeKind(kind) && kind !== 173 /* SyntaxKind.Constructor */;
}
function isDotOfNumericLiteral(contextToken) {
if (contextToken.kind === 8 /* SyntaxKind.NumericLiteral */) {
@@ -424157,7 +425364,7 @@ var ts;
return false;
}
function isVariableDeclarationListButNotTypeArgument(node) {
- return node.parent.kind === 255 /* SyntaxKind.VariableDeclarationList */
+ return node.parent.kind === 258 /* SyntaxKind.VariableDeclarationList */
&& !ts.isPossiblyTypeArgumentPosition(node, sourceFile, typeChecker);
}
/**
@@ -424175,13 +425382,13 @@ var ts;
for (var _i = 0, existingMembers_1 = existingMembers; _i < existingMembers_1.length; _i++) {
var m = existingMembers_1[_i];
// Ignore omitted expressions for missing members
- if (m.kind !== 296 /* SyntaxKind.PropertyAssignment */ &&
- m.kind !== 297 /* SyntaxKind.ShorthandPropertyAssignment */ &&
- m.kind !== 203 /* SyntaxKind.BindingElement */ &&
- m.kind !== 169 /* SyntaxKind.MethodDeclaration */ &&
- m.kind !== 172 /* SyntaxKind.GetAccessor */ &&
- m.kind !== 173 /* SyntaxKind.SetAccessor */ &&
- m.kind !== 298 /* SyntaxKind.SpreadAssignment */) {
+ if (m.kind !== 299 /* SyntaxKind.PropertyAssignment */ &&
+ m.kind !== 300 /* SyntaxKind.ShorthandPropertyAssignment */ &&
+ m.kind !== 205 /* SyntaxKind.BindingElement */ &&
+ m.kind !== 171 /* SyntaxKind.MethodDeclaration */ &&
+ m.kind !== 174 /* SyntaxKind.GetAccessor */ &&
+ m.kind !== 175 /* SyntaxKind.SetAccessor */ &&
+ m.kind !== 301 /* SyntaxKind.SpreadAssignment */) {
continue;
}
// If this is the current item we are editing right now, do not filter it out
@@ -424272,10 +425479,10 @@ var ts;
for (var _i = 0, existingMembers_2 = existingMembers; _i < existingMembers_2.length; _i++) {
var m = existingMembers_2[_i];
// Ignore omitted expressions for missing members
- if (m.kind !== 167 /* SyntaxKind.PropertyDeclaration */ &&
- m.kind !== 169 /* SyntaxKind.MethodDeclaration */ &&
- m.kind !== 172 /* SyntaxKind.GetAccessor */ &&
- m.kind !== 173 /* SyntaxKind.SetAccessor */) {
+ if (m.kind !== 169 /* SyntaxKind.PropertyDeclaration */ &&
+ m.kind !== 171 /* SyntaxKind.MethodDeclaration */ &&
+ m.kind !== 174 /* SyntaxKind.GetAccessor */ &&
+ m.kind !== 175 /* SyntaxKind.SetAccessor */) {
continue;
}
// If this is the current item we are editing right now, do not filter it out
@@ -424317,7 +425524,7 @@ var ts;
if (isCurrentlyEditingNode(attr)) {
continue;
}
- if (attr.kind === 285 /* SyntaxKind.JsxAttribute */) {
+ if (attr.kind === 288 /* SyntaxKind.JsxAttribute */) {
seenNames.add(attr.name.escapedText);
}
else if (ts.isJsxSpreadAttribute(attr)) {
@@ -424415,7 +425622,7 @@ var ts;
var _keywordCompletions = [];
var allKeywordsCompletions = ts.memoize(function () {
var res = [];
- for (var i = 81 /* SyntaxKind.FirstKeyword */; i <= 160 /* SyntaxKind.LastKeyword */; i++) {
+ for (var i = 81 /* SyntaxKind.FirstKeyword */; i <= 162 /* SyntaxKind.LastKeyword */; i++) {
res.push({
name: ts.tokenToString(i),
kind: "keyword" /* ScriptElementKind.keyword */,
@@ -424441,12 +425648,12 @@ var ts;
return false;
case 1 /* KeywordCompletionFilters.All */:
return isFunctionLikeBodyKeyword(kind)
- || kind === 135 /* SyntaxKind.DeclareKeyword */
- || kind === 141 /* SyntaxKind.ModuleKeyword */
- || kind === 152 /* SyntaxKind.TypeKeyword */
- || kind === 142 /* SyntaxKind.NamespaceKeyword */
+ || kind === 136 /* SyntaxKind.DeclareKeyword */
+ || kind === 142 /* SyntaxKind.ModuleKeyword */
+ || kind === 154 /* SyntaxKind.TypeKeyword */
+ || kind === 143 /* SyntaxKind.NamespaceKeyword */
|| kind === 126 /* SyntaxKind.AbstractKeyword */
- || ts.isTypeKeyword(kind) && kind !== 153 /* SyntaxKind.UndefinedKeyword */;
+ || ts.isTypeKeyword(kind) && kind !== 155 /* SyntaxKind.UndefinedKeyword */;
case 5 /* KeywordCompletionFilters.FunctionLikeBodyKeywords */:
return isFunctionLikeBodyKeyword(kind);
case 2 /* KeywordCompletionFilters.ClassElementKeywords */:
@@ -424460,7 +425667,7 @@ var ts;
case 7 /* KeywordCompletionFilters.TypeKeywords */:
return ts.isTypeKeyword(kind);
case 8 /* KeywordCompletionFilters.TypeKeyword */:
- return kind === 152 /* SyntaxKind.TypeKeyword */;
+ return kind === 154 /* SyntaxKind.TypeKeyword */;
default:
return ts.Debug.assertNever(keywordFilter);
}
@@ -424469,59 +425676,61 @@ var ts;
function isTypeScriptOnlyKeyword(kind) {
switch (kind) {
case 126 /* SyntaxKind.AbstractKeyword */:
- case 130 /* SyntaxKind.AnyKeyword */:
- case 158 /* SyntaxKind.BigIntKeyword */:
- case 133 /* SyntaxKind.BooleanKeyword */:
- case 135 /* SyntaxKind.DeclareKeyword */:
+ case 131 /* SyntaxKind.AnyKeyword */:
+ case 160 /* SyntaxKind.BigIntKeyword */:
+ case 134 /* SyntaxKind.BooleanKeyword */:
+ case 136 /* SyntaxKind.DeclareKeyword */:
case 92 /* SyntaxKind.EnumKeyword */:
- case 157 /* SyntaxKind.GlobalKeyword */:
+ case 159 /* SyntaxKind.GlobalKeyword */:
case 117 /* SyntaxKind.ImplementsKeyword */:
- case 137 /* SyntaxKind.InferKeyword */:
+ case 138 /* SyntaxKind.InferKeyword */:
case 118 /* SyntaxKind.InterfaceKeyword */:
- case 139 /* SyntaxKind.IsKeyword */:
- case 140 /* SyntaxKind.KeyOfKeyword */:
- case 141 /* SyntaxKind.ModuleKeyword */:
- case 142 /* SyntaxKind.NamespaceKeyword */:
- case 143 /* SyntaxKind.NeverKeyword */:
- case 147 /* SyntaxKind.NumberKeyword */:
- case 148 /* SyntaxKind.ObjectKeyword */:
- case 159 /* SyntaxKind.OverrideKeyword */:
+ case 140 /* SyntaxKind.IsKeyword */:
+ case 141 /* SyntaxKind.KeyOfKeyword */:
+ case 142 /* SyntaxKind.ModuleKeyword */:
+ case 143 /* SyntaxKind.NamespaceKeyword */:
+ case 144 /* SyntaxKind.NeverKeyword */:
+ case 148 /* SyntaxKind.NumberKeyword */:
+ case 149 /* SyntaxKind.ObjectKeyword */:
+ case 161 /* SyntaxKind.OverrideKeyword */:
case 121 /* SyntaxKind.PrivateKeyword */:
case 122 /* SyntaxKind.ProtectedKeyword */:
case 123 /* SyntaxKind.PublicKeyword */:
- case 145 /* SyntaxKind.ReadonlyKeyword */:
- case 150 /* SyntaxKind.StringKeyword */:
- case 151 /* SyntaxKind.SymbolKeyword */:
- case 152 /* SyntaxKind.TypeKeyword */:
- case 154 /* SyntaxKind.UniqueKeyword */:
- case 155 /* SyntaxKind.UnknownKeyword */:
+ case 146 /* SyntaxKind.ReadonlyKeyword */:
+ case 152 /* SyntaxKind.StringKeyword */:
+ case 153 /* SyntaxKind.SymbolKeyword */:
+ case 154 /* SyntaxKind.TypeKeyword */:
+ case 156 /* SyntaxKind.UniqueKeyword */:
+ case 157 /* SyntaxKind.UnknownKeyword */:
return true;
default:
return false;
}
}
function isInterfaceOrTypeLiteralCompletionKeyword(kind) {
- return kind === 145 /* SyntaxKind.ReadonlyKeyword */;
+ return kind === 146 /* SyntaxKind.ReadonlyKeyword */;
}
function isClassMemberCompletionKeyword(kind) {
switch (kind) {
case 126 /* SyntaxKind.AbstractKeyword */:
- case 134 /* SyntaxKind.ConstructorKeyword */:
- case 136 /* SyntaxKind.GetKeyword */:
- case 149 /* SyntaxKind.SetKeyword */:
- case 131 /* SyntaxKind.AsyncKeyword */:
- case 135 /* SyntaxKind.DeclareKeyword */:
- case 159 /* SyntaxKind.OverrideKeyword */:
+ case 127 /* SyntaxKind.AccessorKeyword */:
+ case 135 /* SyntaxKind.ConstructorKeyword */:
+ case 137 /* SyntaxKind.GetKeyword */:
+ case 151 /* SyntaxKind.SetKeyword */:
+ case 132 /* SyntaxKind.AsyncKeyword */:
+ case 136 /* SyntaxKind.DeclareKeyword */:
+ case 161 /* SyntaxKind.OverrideKeyword */:
return true;
default:
return ts.isClassMemberModifier(kind);
}
}
function isFunctionLikeBodyKeyword(kind) {
- return kind === 131 /* SyntaxKind.AsyncKeyword */
- || kind === 132 /* SyntaxKind.AwaitKeyword */
- || kind === 127 /* SyntaxKind.AsKeyword */
- || kind === 152 /* SyntaxKind.TypeKeyword */
+ return kind === 132 /* SyntaxKind.AsyncKeyword */
+ || kind === 133 /* SyntaxKind.AwaitKeyword */
+ || kind === 128 /* SyntaxKind.AsKeyword */
+ || kind === 150 /* SyntaxKind.SatisfiesKeyword */
+ || kind === 154 /* SyntaxKind.TypeKeyword */
|| !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind);
}
function keywordForNode(node) {
@@ -424546,7 +425755,7 @@ var ts;
&& contextToken === parent.moduleSpecifier
&& tokenLine === currentLine) {
entries.push({
- name: ts.tokenToString(129 /* SyntaxKind.AssertKeyword */),
+ name: ts.tokenToString(130 /* SyntaxKind.AssertKeyword */),
kind: "keyword" /* ScriptElementKind.keyword */,
kindModifiers: "" /* ScriptElementKindModifier.none */,
sortText: Completions.SortText.GlobalsOrKeywords,
@@ -424612,7 +425821,7 @@ var ts;
function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location, position) {
// class c { method() { } | method2() { } }
switch (location.kind) {
- case 348 /* SyntaxKind.SyntaxList */:
+ case 351 /* SyntaxKind.SyntaxList */:
return ts.tryCast(location.parent, ts.isObjectTypeDeclaration);
case 1 /* SyntaxKind.EndOfFileToken */:
var cls = ts.tryCast(ts.lastOrUndefined(ts.cast(location.parent, ts.isSourceFile).statements), ts.isObjectTypeDeclaration);
@@ -424638,7 +425847,7 @@ var ts;
if (!contextToken)
return undefined;
// class C { blah; constructor/**/ } and so on
- if (location.kind === 134 /* SyntaxKind.ConstructorKeyword */
+ if (location.kind === 135 /* SyntaxKind.ConstructorKeyword */
// class C { blah \n constructor/**/ }
|| (ts.isIdentifier(contextToken) && ts.isPropertyDeclaration(contextToken.parent) && ts.isClassLike(location))) {
return ts.findAncestor(contextToken, ts.isClassLike);
@@ -424681,7 +425890,7 @@ var ts;
case 26 /* SyntaxKind.SemicolonToken */:
case 27 /* SyntaxKind.CommaToken */:
case 79 /* SyntaxKind.Identifier */:
- if (parent.kind === 166 /* SyntaxKind.PropertySignature */ && ts.isTypeLiteralNode(parent.parent)) {
+ if (parent.kind === 168 /* SyntaxKind.PropertySignature */ && ts.isTypeLiteralNode(parent.parent)) {
return parent.parent;
}
break;
@@ -424698,11 +425907,11 @@ var ts;
if (!t)
return undefined;
switch (node.kind) {
- case 166 /* SyntaxKind.PropertySignature */:
+ case 168 /* SyntaxKind.PropertySignature */:
return checker.getTypeOfPropertyOfContextualType(t, node.symbol.escapedName);
- case 188 /* SyntaxKind.IntersectionType */:
- case 182 /* SyntaxKind.TypeLiteral */:
- case 187 /* SyntaxKind.UnionType */:
+ case 190 /* SyntaxKind.IntersectionType */:
+ case 184 /* SyntaxKind.TypeLiteral */:
+ case 189 /* SyntaxKind.UnionType */:
return t;
}
}
@@ -424730,7 +425939,7 @@ var ts;
? !!ts.tryGetImportFromModuleSpecifier(contextToken)
: contextToken.kind === 43 /* SyntaxKind.SlashToken */ && ts.isJsxClosingElement(contextToken.parent));
case " ":
- return !!contextToken && ts.isImportKeyword(contextToken) && contextToken.parent.kind === 305 /* SyntaxKind.SourceFile */;
+ return !!contextToken && ts.isImportKeyword(contextToken) && contextToken.parent.kind === 308 /* SyntaxKind.SourceFile */;
default:
return ts.Debug.assertNever(triggerCharacter);
}
@@ -424777,21 +425986,22 @@ var ts;
return undefined;
}
function getImportStatementCompletionInfo(contextToken) {
+ var _a, _b, _c;
var keywordCompletion;
var isKeywordOnlyCompletion = false;
var candidate = getCandidate();
return {
isKeywordOnlyCompletion: isKeywordOnlyCompletion,
keywordCompletion: keywordCompletion,
- isNewIdentifierLocation: !!(candidate || keywordCompletion === 152 /* SyntaxKind.TypeKeyword */),
- replacementNode: candidate && ts.rangeIsOnSingleLine(candidate, candidate.getSourceFile())
- ? candidate
- : undefined
+ isNewIdentifierLocation: !!(candidate || keywordCompletion === 154 /* SyntaxKind.TypeKeyword */),
+ isTopLevelTypeOnly: !!((_b = (_a = ts.tryCast(candidate, ts.isImportDeclaration)) === null || _a === void 0 ? void 0 : _a.importClause) === null || _b === void 0 ? void 0 : _b.isTypeOnly) || !!((_c = ts.tryCast(candidate, ts.isImportEqualsDeclaration)) === null || _c === void 0 ? void 0 : _c.isTypeOnly),
+ couldBeTypeOnlyImportSpecifier: !!candidate && couldBeTypeOnlyImportSpecifier(candidate, contextToken),
+ replacementSpan: getSingleLineReplacementSpanForImportCompletionNode(candidate),
};
function getCandidate() {
var parent = contextToken.parent;
if (ts.isImportEqualsDeclaration(parent)) {
- keywordCompletion = contextToken.kind === 152 /* SyntaxKind.TypeKeyword */ ? undefined : 152 /* SyntaxKind.TypeKeyword */;
+ keywordCompletion = contextToken.kind === 154 /* SyntaxKind.TypeKeyword */ ? undefined : 154 /* SyntaxKind.TypeKeyword */;
return isModuleSpecifierMissingOrEmpty(parent.moduleReference) ? parent : undefined;
}
if (couldBeTypeOnlyImportSpecifier(parent, contextToken) && canCompleteFromNamedBindings(parent.parent)) {
@@ -424801,13 +426011,13 @@ var ts;
if (!parent.parent.isTypeOnly && (contextToken.kind === 18 /* SyntaxKind.OpenBraceToken */ ||
contextToken.kind === 100 /* SyntaxKind.ImportKeyword */ ||
contextToken.kind === 27 /* SyntaxKind.CommaToken */)) {
- keywordCompletion = 152 /* SyntaxKind.TypeKeyword */;
+ keywordCompletion = 154 /* SyntaxKind.TypeKeyword */;
}
if (canCompleteFromNamedBindings(parent)) {
// At `import { ... } |` or `import * as Foo |`, the only possible completion is `from`
if (contextToken.kind === 19 /* SyntaxKind.CloseBraceToken */ || contextToken.kind === 79 /* SyntaxKind.Identifier */) {
isKeywordOnlyCompletion = true;
- keywordCompletion = 156 /* SyntaxKind.FromKeyword */;
+ keywordCompletion = 158 /* SyntaxKind.FromKeyword */;
}
else {
return parent.parent.parent;
@@ -424817,25 +426027,82 @@ var ts;
}
if (ts.isImportKeyword(contextToken) && ts.isSourceFile(parent)) {
// A lone import keyword with nothing following it does not parse as a statement at all
- keywordCompletion = 152 /* SyntaxKind.TypeKeyword */;
+ keywordCompletion = 154 /* SyntaxKind.TypeKeyword */;
return contextToken;
}
if (ts.isImportKeyword(contextToken) && ts.isImportDeclaration(parent)) {
// `import s| from`
- keywordCompletion = 152 /* SyntaxKind.TypeKeyword */;
+ keywordCompletion = 154 /* SyntaxKind.TypeKeyword */;
return isModuleSpecifierMissingOrEmpty(parent.moduleSpecifier) ? parent : undefined;
}
return undefined;
}
}
+ function getSingleLineReplacementSpanForImportCompletionNode(node) {
+ var _a, _b, _c;
+ if (!node)
+ return undefined;
+ var top = (_a = ts.findAncestor(node, ts.or(ts.isImportDeclaration, ts.isImportEqualsDeclaration))) !== null && _a !== void 0 ? _a : node;
+ var sourceFile = top.getSourceFile();
+ if (ts.rangeIsOnSingleLine(top, sourceFile)) {
+ return ts.createTextSpanFromNode(top, sourceFile);
+ }
+ // ImportKeyword was necessarily on one line; ImportSpecifier was necessarily parented in an ImportDeclaration
+ ts.Debug.assert(top.kind !== 100 /* SyntaxKind.ImportKeyword */ && top.kind !== 273 /* SyntaxKind.ImportSpecifier */);
+ // Guess which point in the import might actually be a later statement parsed as part of the import
+ // during parser recovery - either in the middle of named imports, or the module specifier.
+ var potentialSplitPoint = top.kind === 269 /* SyntaxKind.ImportDeclaration */
+ ? (_c = getPotentiallyInvalidImportSpecifier((_b = top.importClause) === null || _b === void 0 ? void 0 : _b.namedBindings)) !== null && _c !== void 0 ? _c : top.moduleSpecifier
+ : top.moduleReference;
+ var withoutModuleSpecifier = {
+ pos: top.getFirstToken().getStart(),
+ end: potentialSplitPoint.pos,
+ };
+ // The module specifier/reference was previously found to be missing, empty, or
+ // not a string literal - in this last case, it's likely that statement on a following
+ // line was parsed as the module specifier of a partially-typed import, e.g.
+ // import Foo|
+ // interface Blah {}
+ // This appears to be a multiline-import, and editors can't replace multiple lines.
+ // But if everything but the "module specifier" is on one line, by this point we can
+ // assume that the "module specifier" is actually just another statement, and return
+ // the single-line range of the import excluding that probable statement.
+ if (ts.rangeIsOnSingleLine(withoutModuleSpecifier, sourceFile)) {
+ return ts.createTextSpanFromRange(withoutModuleSpecifier);
+ }
+ }
+ // Tries to identify the first named import that is not really a named import, but rather
+ // just parser recovery for a situation like:
+ // import { Foo|
+ // interface Bar {}
+ // in which `Foo`, `interface`, and `Bar` are all parsed as import specifiers. The caller
+ // will also check if this token is on a separate line from the rest of the import.
+ function getPotentiallyInvalidImportSpecifier(namedBindings) {
+ var _a;
+ return ts.find((_a = ts.tryCast(namedBindings, ts.isNamedImports)) === null || _a === void 0 ? void 0 : _a.elements, function (e) {
+ var _a;
+ return !e.propertyName &&
+ ts.isStringANonContextualKeyword(e.name.text) &&
+ ((_a = ts.findPrecedingToken(e.name.pos, namedBindings.getSourceFile(), namedBindings)) === null || _a === void 0 ? void 0 : _a.kind) !== 27 /* SyntaxKind.CommaToken */;
+ });
+ }
function couldBeTypeOnlyImportSpecifier(importSpecifier, contextToken) {
return ts.isImportSpecifier(importSpecifier)
&& (importSpecifier.isTypeOnly || contextToken === importSpecifier.name && ts.isTypeKeywordTokenOrIdentifier(contextToken));
}
function canCompleteFromNamedBindings(namedBindings) {
- return isModuleSpecifierMissingOrEmpty(namedBindings.parent.parent.moduleSpecifier)
- && (ts.isNamespaceImport(namedBindings) || namedBindings.elements.length < 2)
- && !namedBindings.parent.name;
+ if (!isModuleSpecifierMissingOrEmpty(namedBindings.parent.parent.moduleSpecifier) || namedBindings.parent.name) {
+ return false;
+ }
+ if (ts.isNamedImports(namedBindings)) {
+ // We can only complete on named imports if there are no other named imports already,
+ // but parser recovery sometimes puts later statements in the named imports list, so
+ // we try to only consider the probably-valid ones.
+ var invalidNamedImport = getPotentiallyInvalidImportSpecifier(namedBindings);
+ var validImports = invalidNamedImport ? namedBindings.elements.indexOf(invalidNamedImport) : namedBindings.elements.length;
+ return validImports < 2;
+ }
+ return true;
}
function isModuleSpecifierMissingOrEmpty(specifier) {
var _a;
@@ -424854,7 +426121,6 @@ var ts;
function isArrowFunctionBody(node) {
return node.parent && ts.isArrowFunction(node.parent) && node.parent.body === node;
}
- ;
/** True if symbol is a type or a module containing at least one type. */
function symbolCanBeReferencedAtTypeLocation(symbol, checker, seenModules) {
if (seenModules === void 0) { seenModules = new ts.Map(); }
@@ -425003,14 +426269,14 @@ var ts;
case 115 /* SyntaxKind.WhileKeyword */:
case 90 /* SyntaxKind.DoKeyword */:
return useParent(node.parent, function (n) { return ts.isIterationStatement(n, /*lookInLabeledStatements*/ true); }, getLoopBreakContinueOccurrences);
- case 134 /* SyntaxKind.ConstructorKeyword */:
- return getFromAllDeclarations(ts.isConstructorDeclaration, [134 /* SyntaxKind.ConstructorKeyword */]);
- case 136 /* SyntaxKind.GetKeyword */:
- case 149 /* SyntaxKind.SetKeyword */:
- return getFromAllDeclarations(ts.isAccessor, [136 /* SyntaxKind.GetKeyword */, 149 /* SyntaxKind.SetKeyword */]);
- case 132 /* SyntaxKind.AwaitKeyword */:
+ case 135 /* SyntaxKind.ConstructorKeyword */:
+ return getFromAllDeclarations(ts.isConstructorDeclaration, [135 /* SyntaxKind.ConstructorKeyword */]);
+ case 137 /* SyntaxKind.GetKeyword */:
+ case 151 /* SyntaxKind.SetKeyword */:
+ return getFromAllDeclarations(ts.isAccessor, [137 /* SyntaxKind.GetKeyword */, 151 /* SyntaxKind.SetKeyword */]);
+ case 133 /* SyntaxKind.AwaitKeyword */:
return useParent(node.parent, ts.isAwaitExpression, getAsyncAndAwaitOccurrences);
- case 131 /* SyntaxKind.AsyncKeyword */:
+ case 132 /* SyntaxKind.AsyncKeyword */:
return highlightSpans(getAsyncAndAwaitOccurrences(node));
case 125 /* SyntaxKind.YieldKeyword */:
return highlightSpans(getYieldOccurrences(node));
@@ -425057,7 +426323,7 @@ var ts;
var child = throwStatement;
while (child.parent) {
var parent = child.parent;
- if (ts.isFunctionBlock(parent) || parent.kind === 305 /* SyntaxKind.SourceFile */) {
+ if (ts.isFunctionBlock(parent) || parent.kind === 308 /* SyntaxKind.SourceFile */) {
return parent;
}
// A throw-statement is only owned by a try-statement if the try-statement has
@@ -425089,16 +426355,16 @@ var ts;
function getBreakOrContinueOwner(statement) {
return ts.findAncestor(statement, function (node) {
switch (node.kind) {
- case 249 /* SyntaxKind.SwitchStatement */:
- if (statement.kind === 245 /* SyntaxKind.ContinueStatement */) {
+ case 252 /* SyntaxKind.SwitchStatement */:
+ if (statement.kind === 248 /* SyntaxKind.ContinueStatement */) {
return false;
}
// falls through
- case 242 /* SyntaxKind.ForStatement */:
- case 243 /* SyntaxKind.ForInStatement */:
- case 244 /* SyntaxKind.ForOfStatement */:
- case 241 /* SyntaxKind.WhileStatement */:
- case 240 /* SyntaxKind.DoStatement */:
+ case 245 /* SyntaxKind.ForStatement */:
+ case 246 /* SyntaxKind.ForInStatement */:
+ case 247 /* SyntaxKind.ForOfStatement */:
+ case 244 /* SyntaxKind.WhileStatement */:
+ case 243 /* SyntaxKind.DoStatement */:
return !statement.label || isLabeledBy(node, statement.label.escapedText);
default:
// Don't cross function boundaries.
@@ -425114,26 +426380,26 @@ var ts;
// Types of node whose children might have modifiers.
var container = declaration.parent;
switch (container.kind) {
- case 262 /* SyntaxKind.ModuleBlock */:
- case 305 /* SyntaxKind.SourceFile */:
- case 235 /* SyntaxKind.Block */:
- case 289 /* SyntaxKind.CaseClause */:
- case 290 /* SyntaxKind.DefaultClause */:
+ case 265 /* SyntaxKind.ModuleBlock */:
+ case 308 /* SyntaxKind.SourceFile */:
+ case 238 /* SyntaxKind.Block */:
+ case 292 /* SyntaxKind.CaseClause */:
+ case 293 /* SyntaxKind.DefaultClause */:
// Container is either a class declaration or the declaration is a classDeclaration
- if (modifierFlag & 128 /* ModifierFlags.Abstract */ && ts.isClassDeclaration(declaration)) {
+ if (modifierFlag & 256 /* ModifierFlags.Abstract */ && ts.isClassDeclaration(declaration)) {
return __spreadArray(__spreadArray([], declaration.members, true), [declaration], false);
}
else {
return container.statements;
}
- case 171 /* SyntaxKind.Constructor */:
- case 169 /* SyntaxKind.MethodDeclaration */:
- case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 173 /* SyntaxKind.Constructor */:
+ case 171 /* SyntaxKind.MethodDeclaration */:
+ case 259 /* SyntaxKind.FunctionDeclaration */:
return __spreadArray(__spreadArray([], container.parameters, true), (ts.isClassLike(container.parent) ? container.parent.members : []), true);
- case 257 /* SyntaxKind.ClassDeclaration */:
- case 226 /* SyntaxKind.ClassExpression */:
- case 258 /* SyntaxKind.InterfaceDeclaration */:
- case 182 /* SyntaxKind.TypeLiteral */:
+ case 260 /* SyntaxKind.ClassDeclaration */:
+ case 228 /* SyntaxKind.ClassExpression */:
+ case 261 /* SyntaxKind.InterfaceDeclaration */:
+ case 184 /* SyntaxKind.TypeLiteral */:
var nodes = container.members;
// If we're an accessibility modifier, we're in an instance member and should search
// the constructor's parameter list for instance members as well.
@@ -425143,12 +426409,12 @@ var ts;
return __spreadArray(__spreadArray([], nodes, true), constructor.parameters, true);
}
}
- else if (modifierFlag & 128 /* ModifierFlags.Abstract */) {
+ else if (modifierFlag & 256 /* ModifierFlags.Abstract */) {
return __spreadArray(__spreadArray([], nodes, true), [container], false);
}
return nodes;
// Syntactically invalid positions that the parser might produce anyway
- case 205 /* SyntaxKind.ObjectLiteralExpression */:
+ case 207 /* SyntaxKind.ObjectLiteralExpression */:
return undefined;
default:
ts.Debug.assertNever(container, "Invalid container kind.");
@@ -425169,7 +426435,7 @@ var ts;
var keywords = [];
if (pushKeywordIf(keywords, loopNode.getFirstToken(), 97 /* SyntaxKind.ForKeyword */, 115 /* SyntaxKind.WhileKeyword */, 90 /* SyntaxKind.DoKeyword */)) {
// If we succeeded and got a do-while loop, then start looking for a 'while' keyword.
- if (loopNode.kind === 240 /* SyntaxKind.DoStatement */) {
+ if (loopNode.kind === 243 /* SyntaxKind.DoStatement */) {
var loopTokens = loopNode.getChildren();
for (var i = loopTokens.length - 1; i >= 0; i--) {
if (pushKeywordIf(keywords, loopTokens[i], 115 /* SyntaxKind.WhileKeyword */)) {
@@ -425189,13 +426455,13 @@ var ts;
var owner = getBreakOrContinueOwner(breakOrContinueStatement);
if (owner) {
switch (owner.kind) {
- case 242 /* SyntaxKind.ForStatement */:
- case 243 /* SyntaxKind.ForInStatement */:
- case 244 /* SyntaxKind.ForOfStatement */:
- case 240 /* SyntaxKind.DoStatement */:
- case 241 /* SyntaxKind.WhileStatement */:
+ case 245 /* SyntaxKind.ForStatement */:
+ case 246 /* SyntaxKind.ForInStatement */:
+ case 247 /* SyntaxKind.ForOfStatement */:
+ case 243 /* SyntaxKind.DoStatement */:
+ case 244 /* SyntaxKind.WhileStatement */:
return getLoopBreakContinueOccurrences(owner);
- case 249 /* SyntaxKind.SwitchStatement */:
+ case 252 /* SyntaxKind.SwitchStatement */:
return getSwitchCaseDefaultOccurrences(owner);
}
}
@@ -425268,13 +426534,13 @@ var ts;
var keywords = [];
if (func.modifiers) {
func.modifiers.forEach(function (modifier) {
- pushKeywordIf(keywords, modifier, 131 /* SyntaxKind.AsyncKeyword */);
+ pushKeywordIf(keywords, modifier, 132 /* SyntaxKind.AsyncKeyword */);
});
}
ts.forEachChild(func, function (child) {
traverseWithoutCrossingFunction(child, function (node) {
if (ts.isAwaitExpression(node)) {
- pushKeywordIf(keywords, node.getFirstToken(), 132 /* SyntaxKind.AwaitKeyword */);
+ pushKeywordIf(keywords, node.getFirstToken(), 133 /* SyntaxKind.AwaitKeyword */);
}
});
});
@@ -425658,14 +426924,14 @@ var ts;
if (cancellationToken)
cancellationToken.throwIfCancellationRequested();
switch (direct.kind) {
- case 208 /* SyntaxKind.CallExpression */:
+ case 210 /* SyntaxKind.CallExpression */:
if (ts.isImportCall(direct)) {
handleImportCall(direct);
break;
}
if (!isAvailableThroughGlobal) {
var parent = direct.parent;
- if (exportKind === 2 /* ExportKind.ExportEquals */ && parent.kind === 254 /* SyntaxKind.VariableDeclaration */) {
+ if (exportKind === 2 /* ExportKind.ExportEquals */ && parent.kind === 257 /* SyntaxKind.VariableDeclaration */) {
var name = parent.name;
if (name.kind === 79 /* SyntaxKind.Identifier */) {
directImports.push(name);
@@ -425676,25 +426942,25 @@ var ts;
break;
case 79 /* SyntaxKind.Identifier */: // for 'const x = require("y");
break; // TODO: GH#23879
- case 265 /* SyntaxKind.ImportEqualsDeclaration */:
+ case 268 /* SyntaxKind.ImportEqualsDeclaration */:
handleNamespaceImport(direct, direct.name, ts.hasSyntacticModifier(direct, 1 /* ModifierFlags.Export */), /*alreadyAddedDirect*/ false);
break;
- case 266 /* SyntaxKind.ImportDeclaration */:
+ case 269 /* SyntaxKind.ImportDeclaration */:
directImports.push(direct);
var namedBindings = direct.importClause && direct.importClause.namedBindings;
- if (namedBindings && namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) {
+ if (namedBindings && namedBindings.kind === 271 /* SyntaxKind.NamespaceImport */) {
handleNamespaceImport(direct, namedBindings.name, /*isReExport*/ false, /*alreadyAddedDirect*/ true);
}
else if (!isAvailableThroughGlobal && ts.isDefaultImport(direct)) {
addIndirectUser(getSourceFileLikeForImportDeclaration(direct)); // Add a check for indirect uses to handle synthetic default imports
}
break;
- case 272 /* SyntaxKind.ExportDeclaration */:
+ case 275 /* SyntaxKind.ExportDeclaration */:
if (!direct.exportClause) {
// This is `export * from "foo"`, so imports of this module may import the export too.
handleDirectImports(getContainingModuleSymbol(direct, checker));
}
- else if (direct.exportClause.kind === 274 /* SyntaxKind.NamespaceExport */) {
+ else if (direct.exportClause.kind === 277 /* SyntaxKind.NamespaceExport */) {
// `export * as foo from "foo"` add to indirect uses
addIndirectUser(getSourceFileLikeForImportDeclaration(direct), /** addTransitiveDependencies */ true);
}
@@ -425703,9 +426969,9 @@ var ts;
directImports.push(direct);
}
break;
- case 200 /* SyntaxKind.ImportType */:
+ case 202 /* SyntaxKind.ImportType */:
// Only check for typeof import('xyz')
- if (direct.isTypeOf && !direct.qualifier && isExported(direct)) {
+ if (!isAvailableThroughGlobal && direct.isTypeOf && !direct.qualifier && isExported(direct)) {
addIndirectUser(direct.getSourceFile(), /** addTransitiveDependencies */ true);
}
directImports.push(direct);
@@ -425736,7 +427002,7 @@ var ts;
}
else if (!isAvailableThroughGlobal) {
var sourceFileLike = getSourceFileLikeForImportDeclaration(importDeclaration);
- ts.Debug.assert(sourceFileLike.kind === 305 /* SyntaxKind.SourceFile */ || sourceFileLike.kind === 261 /* SyntaxKind.ModuleDeclaration */);
+ ts.Debug.assert(sourceFileLike.kind === 308 /* SyntaxKind.SourceFile */ || sourceFileLike.kind === 264 /* SyntaxKind.ModuleDeclaration */);
if (isReExport || findNamespaceReExports(sourceFileLike, name, checker)) {
addIndirectUser(sourceFileLike, /** addTransitiveDependencies */ true);
}
@@ -425792,7 +427058,7 @@ var ts;
}
return { importSearches: importSearches, singleReferences: singleReferences };
function handleImport(decl) {
- if (decl.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) {
+ if (decl.kind === 268 /* SyntaxKind.ImportEqualsDeclaration */) {
if (isExternalModuleImportEquals(decl)) {
handleNamespaceImportLike(decl.name);
}
@@ -425802,7 +427068,7 @@ var ts;
handleNamespaceImportLike(decl);
return;
}
- if (decl.kind === 200 /* SyntaxKind.ImportType */) {
+ if (decl.kind === 202 /* SyntaxKind.ImportType */) {
if (decl.qualifier) {
var firstIdentifier = ts.getFirstIdentifier(decl.qualifier);
if (firstIdentifier.escapedText === ts.symbolName(exportSymbol)) {
@@ -425818,7 +427084,7 @@ var ts;
if (decl.moduleSpecifier.kind !== 10 /* SyntaxKind.StringLiteral */) {
return;
}
- if (decl.kind === 272 /* SyntaxKind.ExportDeclaration */) {
+ if (decl.kind === 275 /* SyntaxKind.ExportDeclaration */) {
if (decl.exportClause && ts.isNamedExports(decl.exportClause)) {
searchForNamedImport(decl.exportClause);
}
@@ -425827,10 +427093,10 @@ var ts;
var _a = decl.importClause || { name: undefined, namedBindings: undefined }, name = _a.name, namedBindings = _a.namedBindings;
if (namedBindings) {
switch (namedBindings.kind) {
- case 268 /* SyntaxKind.NamespaceImport */:
+ case 271 /* SyntaxKind.NamespaceImport */:
handleNamespaceImportLike(namedBindings.name);
break;
- case 269 /* SyntaxKind.NamedImports */:
+ case 272 /* SyntaxKind.NamedImports */:
// 'default' might be accessed as a named import `{ default as foo }`.
if (exportKind === 0 /* ExportKind.Named */ || exportKind === 1 /* ExportKind.Default */) {
searchForNamedImport(namedBindings);
@@ -425880,7 +427146,7 @@ var ts;
}
}
else {
- var localSymbol = element.kind === 275 /* SyntaxKind.ExportSpecifier */ && element.propertyName
+ var localSymbol = element.kind === 278 /* SyntaxKind.ExportSpecifier */ && element.propertyName
? checker.getExportSpecifierLocalTargetSymbol(element) // For re-exporting under a different name, we want to get the re-exported symbol.
: checker.getSymbolAtLocation(name);
addSearch(name, localSymbol);
@@ -425909,7 +427175,7 @@ var ts;
for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) {
var referencingFile = sourceFiles_1[_i];
var searchSourceFile = searchModuleSymbol.valueDeclaration;
- if ((searchSourceFile === null || searchSourceFile === void 0 ? void 0 : searchSourceFile.kind) === 305 /* SyntaxKind.SourceFile */) {
+ if ((searchSourceFile === null || searchSourceFile === void 0 ? void 0 : searchSourceFile.kind) === 308 /* SyntaxKind.SourceFile */) {
for (var _a = 0, _b = referencingFile.referencedFiles; _a < _b.length; _a++) {
var ref = _b[_a];
if (program.getSourceFileFromReference(referencingFile, ref) === searchSourceFile) {
@@ -425957,7 +427223,7 @@ var ts;
}
/** Iterates over all statements at the top level or in module declarations. Returns the first truthy result. */
function forEachPossibleImportOrExportStatement(sourceFileLike, action) {
- return ts.forEach(sourceFileLike.kind === 305 /* SyntaxKind.SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) {
+ return ts.forEach(sourceFileLike.kind === 308 /* SyntaxKind.SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) {
return action(statement) || (isAmbientModuleDeclaration(statement) && ts.forEach(statement.body && statement.body.statements, action));
});
}
@@ -425972,15 +427238,15 @@ var ts;
else {
forEachPossibleImportOrExportStatement(sourceFile, function (statement) {
switch (statement.kind) {
- case 272 /* SyntaxKind.ExportDeclaration */:
- case 266 /* SyntaxKind.ImportDeclaration */: {
+ case 275 /* SyntaxKind.ExportDeclaration */:
+ case 269 /* SyntaxKind.ImportDeclaration */: {
var decl = statement;
if (decl.moduleSpecifier && ts.isStringLiteral(decl.moduleSpecifier)) {
action(decl, decl.moduleSpecifier);
}
break;
}
- case 265 /* SyntaxKind.ImportEqualsDeclaration */: {
+ case 268 /* SyntaxKind.ImportEqualsDeclaration */: {
var decl = statement;
if (isExternalModuleImportEquals(decl)) {
action(decl, decl.moduleReference.expression);
@@ -426005,7 +427271,7 @@ var ts;
var parent = node.parent;
var grandparent = parent.parent;
if (symbol.exportSymbol) {
- if (parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) {
+ if (parent.kind === 208 /* SyntaxKind.PropertyAccessExpression */) {
// When accessing an export of a JS module, there's no alias. The symbol will still be flagged as an export even though we're at the use.
// So check that we are at the declaration.
return ((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d === parent; })) && ts.isBinaryExpression(grandparent)
@@ -426089,6 +427355,8 @@ var ts;
// Similarly, skip past the symbol for 'export ='
if (importedSymbol.escapedName === "export=") {
importedSymbol = getExportEqualsLocalSymbol(importedSymbol, checker);
+ if (importedSymbol === undefined)
+ return undefined;
}
// If the import has a different name than the export, do not continue searching.
// If `importedName` is undefined, do continue searching as the export is anonymous.
@@ -426104,25 +427372,25 @@ var ts;
}
// Not meant for use with export specifiers or export assignment.
function getExportKindForDeclaration(node) {
- return ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) ? 1 /* ExportKind.Default */ : 0 /* ExportKind.Named */;
+ return ts.hasSyntacticModifier(node, 1024 /* ModifierFlags.Default */) ? 1 /* ExportKind.Default */ : 0 /* ExportKind.Named */;
}
}
FindAllReferences.getImportOrExportSymbol = getImportOrExportSymbol;
function getExportEqualsLocalSymbol(importedSymbol, checker) {
if (importedSymbol.flags & 2097152 /* SymbolFlags.Alias */) {
- return ts.Debug.checkDefined(checker.getImmediateAliasedSymbol(importedSymbol));
+ return checker.getImmediateAliasedSymbol(importedSymbol);
}
var decl = ts.Debug.checkDefined(importedSymbol.valueDeclaration);
if (ts.isExportAssignment(decl)) { // `export = class {}`
- return ts.Debug.checkDefined(decl.expression.symbol);
+ return decl.expression.symbol;
}
else if (ts.isBinaryExpression(decl)) { // `module.exports = class {}`
- return ts.Debug.checkDefined(decl.right.symbol);
+ return decl.right.symbol;
}
else if (ts.isSourceFile(decl)) { // json module
- return ts.Debug.checkDefined(decl.symbol);
+ return decl.symbol;
}
- return ts.Debug.fail();
+ return undefined;
}
// If a reference is a class expression, the exported node would be its parent.
// If a reference is a variable declaration, the exported node would be the variable statement.
@@ -426139,16 +427407,16 @@ var ts;
function isNodeImport(node) {
var parent = node.parent;
switch (parent.kind) {
- case 265 /* SyntaxKind.ImportEqualsDeclaration */:
+ case 268 /* SyntaxKind.ImportEqualsDeclaration */:
return parent.name === node && isExternalModuleImportEquals(parent);
- case 270 /* SyntaxKind.ImportSpecifier */:
+ case 273 /* SyntaxKind.ImportSpecifier */:
// For a rename import `{ foo as bar }`, don't search for the imported symbol. Just find local uses of `bar`.
return !parent.propertyName;
- case 267 /* SyntaxKind.ImportClause */:
- case 268 /* SyntaxKind.NamespaceImport */:
+ case 270 /* SyntaxKind.ImportClause */:
+ case 271 /* SyntaxKind.NamespaceImport */:
ts.Debug.assert(parent.name === node);
return true;
- case 203 /* SyntaxKind.BindingElement */:
+ case 205 /* SyntaxKind.BindingElement */:
return ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(parent.parent.parent);
default:
return false;
@@ -426189,21 +427457,21 @@ var ts;
return checker.getMergedSymbol(getSourceFileLikeForImportDeclaration(importer).symbol);
}
function getSourceFileLikeForImportDeclaration(node) {
- if (node.kind === 208 /* SyntaxKind.CallExpression */) {
+ if (node.kind === 210 /* SyntaxKind.CallExpression */) {
return node.getSourceFile();
}
var parent = node.parent;
- if (parent.kind === 305 /* SyntaxKind.SourceFile */) {
+ if (parent.kind === 308 /* SyntaxKind.SourceFile */) {
return parent;
}
- ts.Debug.assert(parent.kind === 262 /* SyntaxKind.ModuleBlock */);
+ ts.Debug.assert(parent.kind === 265 /* SyntaxKind.ModuleBlock */);
return ts.cast(parent.parent, isAmbientModuleDeclaration);
}
function isAmbientModuleDeclaration(node) {
- return node.kind === 261 /* SyntaxKind.ModuleDeclaration */ && node.name.kind === 10 /* SyntaxKind.StringLiteral */;
+ return node.kind === 264 /* SyntaxKind.ModuleDeclaration */ && node.name.kind === 10 /* SyntaxKind.StringLiteral */;
}
function isExternalModuleImportEquals(eq) {
- return eq.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* SyntaxKind.StringLiteral */;
+ return eq.moduleReference.kind === 280 /* SyntaxKind.ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* SyntaxKind.StringLiteral */;
}
})(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {}));
})(ts || (ts = {}));
@@ -426297,7 +427565,7 @@ var ts;
((ts.isImportOrExportSpecifier(node.parent) || ts.isBindingElement(node.parent))
&& node.parent.propertyName === node) ||
// Is default export
- (node.kind === 88 /* SyntaxKind.DefaultKeyword */ && ts.hasSyntacticModifier(node.parent, 513 /* ModifierFlags.ExportDefault */))) {
+ (node.kind === 88 /* SyntaxKind.DefaultKeyword */ && ts.hasSyntacticModifier(node.parent, 1025 /* ModifierFlags.ExportDefault */))) {
return getContextNode(node.parent);
}
return undefined;
@@ -426306,7 +427574,7 @@ var ts;
if (!node)
return undefined;
switch (node.kind) {
- case 254 /* SyntaxKind.VariableDeclaration */:
+ case 257 /* SyntaxKind.VariableDeclaration */:
return !ts.isVariableDeclarationList(node.parent) || node.parent.declarations.length !== 1 ?
node :
ts.isVariableStatement(node.parent.parent) ?
@@ -426314,28 +427582,28 @@ var ts;
ts.isForInOrOfStatement(node.parent.parent) ?
getContextNode(node.parent.parent) :
node.parent;
- case 203 /* SyntaxKind.BindingElement */:
+ case 205 /* SyntaxKind.BindingElement */:
return getContextNode(node.parent.parent);
- case 270 /* SyntaxKind.ImportSpecifier */:
+ case 273 /* SyntaxKind.ImportSpecifier */:
return node.parent.parent.parent;
- case 275 /* SyntaxKind.ExportSpecifier */:
- case 268 /* SyntaxKind.NamespaceImport */:
+ case 278 /* SyntaxKind.ExportSpecifier */:
+ case 271 /* SyntaxKind.NamespaceImport */:
return node.parent.parent;
- case 267 /* SyntaxKind.ImportClause */:
- case 274 /* SyntaxKind.NamespaceExport */:
+ case 270 /* SyntaxKind.ImportClause */:
+ case 277 /* SyntaxKind.NamespaceExport */:
return node.parent;
- case 221 /* SyntaxKind.BinaryExpression */:
+ case 223 /* SyntaxKind.BinaryExpression */:
return ts.isExpressionStatement(node.parent) ?
node.parent :
node;
- case 244 /* SyntaxKind.ForOfStatement */:
- case 243 /* SyntaxKind.ForInStatement */:
+ case 247 /* SyntaxKind.ForOfStatement */:
+ case 246 /* SyntaxKind.ForInStatement */:
return {
start: node.initializer,
end: node.expression
};
- case 296 /* SyntaxKind.PropertyAssignment */:
- case 297 /* SyntaxKind.ShorthandPropertyAssignment */:
+ case 299 /* SyntaxKind.PropertyAssignment */:
+ case 300 /* SyntaxKind.ShorthandPropertyAssignment */:
return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent) ?
getContextNode(ts.findAncestor(node.parent, function (node) {
return ts.isBinaryExpression(node) || ts.isForInOrOfStatement(node);
@@ -426396,15 +427664,15 @@ var ts;
return node.kind === 88 /* SyntaxKind.DefaultKeyword */
|| !!ts.getDeclarationFromName(node)
|| ts.isLiteralComputedPropertyDeclarationName(node)
- || (node.kind === 134 /* SyntaxKind.ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent));
+ || (node.kind === 135 /* SyntaxKind.ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent));
}
function getImplementationsAtPosition(program, cancellationToken, sourceFiles, sourceFile, position) {
var node = ts.getTouchingPropertyName(sourceFile, position);
var referenceEntries;
var entries = getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position);
- if (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */
- || node.parent.kind === 203 /* SyntaxKind.BindingElement */
- || node.parent.kind === 207 /* SyntaxKind.ElementAccessExpression */
+ if (node.parent.kind === 208 /* SyntaxKind.PropertyAccessExpression */
+ || node.parent.kind === 205 /* SyntaxKind.BindingElement */
+ || node.parent.kind === 209 /* SyntaxKind.ElementAccessExpression */
|| node.kind === 106 /* SyntaxKind.SuperKeyword */) {
referenceEntries = entries && __spreadArray([], entries, true);
}
@@ -426428,13 +427696,13 @@ var ts;
}
FindAllReferences.getImplementationsAtPosition = getImplementationsAtPosition;
function getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position) {
- if (node.kind === 305 /* SyntaxKind.SourceFile */) {
+ if (node.kind === 308 /* SyntaxKind.SourceFile */) {
return undefined;
}
var checker = program.getTypeChecker();
// If invoked directly on a shorthand property assignment, then return
// the declaration of the symbol being assigned (not the symbol being assigned to).
- if (node.parent.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) {
+ if (node.parent.kind === 300 /* SyntaxKind.ShorthandPropertyAssignment */) {
var result_2 = [];
Core.getReferenceEntriesForShorthandPropertyAssignment(node, checker, function (node) { return result_2.push(nodeEntry(node)); });
return result_2;
@@ -426610,13 +427878,13 @@ var ts;
if (symbol) {
return getDefinitionKindAndDisplayParts(symbol, checker, node);
}
- else if (node.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) {
+ else if (node.kind === 207 /* SyntaxKind.ObjectLiteralExpression */) {
return {
kind: "interface" /* ScriptElementKind.interfaceElement */,
displayParts: [ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)]
};
}
- else if (node.kind === 226 /* SyntaxKind.ClassExpression */) {
+ else if (node.kind === 228 /* SyntaxKind.ClassExpression */) {
return {
kind: "local class" /* ScriptElementKind.localClassElement */,
displayParts: [ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)]
@@ -426670,7 +427938,7 @@ var ts;
var source = ts.getDeclarationFromName(node) ||
(node.kind === 88 /* SyntaxKind.DefaultKeyword */ ? node.parent
: ts.isLiteralComputedPropertyDeclarationName(node) ? node.parent.parent
- : node.kind === 134 /* SyntaxKind.ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent) ? node.parent.parent
+ : node.kind === 135 /* SyntaxKind.ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent) ? node.parent.parent
: undefined);
var commonjsSource = source && ts.isBinaryExpression(source) ? source.left : undefined;
return !!(source && ((_a = target.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d === source || d === commonjsSource; })));
@@ -426685,47 +427953,47 @@ var ts;
if (!!(decl.flags & 16777216 /* NodeFlags.Ambient */))
return true;
switch (decl.kind) {
- case 221 /* SyntaxKind.BinaryExpression */:
- case 203 /* SyntaxKind.BindingElement */:
- case 257 /* SyntaxKind.ClassDeclaration */:
- case 226 /* SyntaxKind.ClassExpression */:
+ case 223 /* SyntaxKind.BinaryExpression */:
+ case 205 /* SyntaxKind.BindingElement */:
+ case 260 /* SyntaxKind.ClassDeclaration */:
+ case 228 /* SyntaxKind.ClassExpression */:
case 88 /* SyntaxKind.DefaultKeyword */:
- case 260 /* SyntaxKind.EnumDeclaration */:
- case 299 /* SyntaxKind.EnumMember */:
- case 275 /* SyntaxKind.ExportSpecifier */:
- case 267 /* SyntaxKind.ImportClause */: // default import
- case 265 /* SyntaxKind.ImportEqualsDeclaration */:
- case 270 /* SyntaxKind.ImportSpecifier */:
- case 258 /* SyntaxKind.InterfaceDeclaration */:
- case 338 /* SyntaxKind.JSDocCallbackTag */:
- case 345 /* SyntaxKind.JSDocTypedefTag */:
- case 285 /* SyntaxKind.JsxAttribute */:
- case 261 /* SyntaxKind.ModuleDeclaration */:
- case 264 /* SyntaxKind.NamespaceExportDeclaration */:
- case 268 /* SyntaxKind.NamespaceImport */:
- case 274 /* SyntaxKind.NamespaceExport */:
- case 164 /* SyntaxKind.Parameter */:
- case 297 /* SyntaxKind.ShorthandPropertyAssignment */:
- case 259 /* SyntaxKind.TypeAliasDeclaration */:
- case 163 /* SyntaxKind.TypeParameter */:
+ case 263 /* SyntaxKind.EnumDeclaration */:
+ case 302 /* SyntaxKind.EnumMember */:
+ case 278 /* SyntaxKind.ExportSpecifier */:
+ case 270 /* SyntaxKind.ImportClause */: // default import
+ case 268 /* SyntaxKind.ImportEqualsDeclaration */:
+ case 273 /* SyntaxKind.ImportSpecifier */:
+ case 261 /* SyntaxKind.InterfaceDeclaration */:
+ case 341 /* SyntaxKind.JSDocCallbackTag */:
+ case 348 /* SyntaxKind.JSDocTypedefTag */:
+ case 288 /* SyntaxKind.JsxAttribute */:
+ case 264 /* SyntaxKind.ModuleDeclaration */:
+ case 267 /* SyntaxKind.NamespaceExportDeclaration */:
+ case 271 /* SyntaxKind.NamespaceImport */:
+ case 277 /* SyntaxKind.NamespaceExport */:
+ case 166 /* SyntaxKind.Parameter */:
+ case 300 /* SyntaxKind.ShorthandPropertyAssignment */:
+ case 262 /* SyntaxKind.TypeAliasDeclaration */:
+ case 165 /* SyntaxKind.TypeParameter */:
return true;
- case 296 /* SyntaxKind.PropertyAssignment */:
+ case 299 /* SyntaxKind.PropertyAssignment */:
// In `({ x: y } = 0);`, `x` is not a write access. (Won't call this function for `y`.)
return !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(decl.parent);
- case 256 /* SyntaxKind.FunctionDeclaration */:
- case 213 /* SyntaxKind.FunctionExpression */:
- case 171 /* SyntaxKind.Constructor */:
- case 169 /* SyntaxKind.MethodDeclaration */:
- case 172 /* SyntaxKind.GetAccessor */:
- case 173 /* SyntaxKind.SetAccessor */:
+ case 259 /* SyntaxKind.FunctionDeclaration */:
+ case 215 /* SyntaxKind.FunctionExpression */:
+ case 173 /* SyntaxKind.Constructor */:
+ case 171 /* SyntaxKind.MethodDeclaration */:
+ case 174 /* SyntaxKind.GetAccessor */:
+ case 175 /* SyntaxKind.SetAccessor */:
return !!decl.body;
- case 254 /* SyntaxKind.VariableDeclaration */:
- case 167 /* SyntaxKind.PropertyDeclaration */:
+ case 257 /* SyntaxKind.VariableDeclaration */:
+ case 169 /* SyntaxKind.PropertyDeclaration */:
return !!decl.initializer || ts.isCatchClause(decl.parent);
- case 168 /* SyntaxKind.MethodSignature */:
- case 166 /* SyntaxKind.PropertySignature */:
- case 347 /* SyntaxKind.JSDocPropertyTag */:
- case 340 /* SyntaxKind.JSDocParameterTag */:
+ case 170 /* SyntaxKind.MethodSignature */:
+ case 168 /* SyntaxKind.PropertySignature */:
+ case 350 /* SyntaxKind.JSDocPropertyTag */:
+ case 343 /* SyntaxKind.JSDocParameterTag */:
return false;
default:
return ts.Debug.failBadSyntaxKind(decl);
@@ -426951,10 +428219,10 @@ var ts;
for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
var decl = _a[_i];
switch (decl.kind) {
- case 305 /* SyntaxKind.SourceFile */:
+ case 308 /* SyntaxKind.SourceFile */:
// Don't include the source file itself. (This may not be ideal behavior, but awkward to include an entire file as a reference.)
break;
- case 261 /* SyntaxKind.ModuleDeclaration */:
+ case 264 /* SyntaxKind.ModuleDeclaration */:
if (sourceFilesSet.has(decl.getSourceFile().fileName)) {
references.push(nodeEntry(decl.name));
}
@@ -426983,9 +428251,9 @@ var ts;
}
/** As in a `readonly prop: any` or `constructor(readonly prop: any)`, not a `readonly any[]`. */
function isReadonlyTypeOperator(node) {
- return node.kind === 145 /* SyntaxKind.ReadonlyKeyword */
+ return node.kind === 146 /* SyntaxKind.ReadonlyKeyword */
&& ts.isTypeOperatorNode(node.parent)
- && node.parent.operator === 145 /* SyntaxKind.ReadonlyKeyword */;
+ && node.parent.operator === 146 /* SyntaxKind.ReadonlyKeyword */;
}
/** getReferencedSymbols for special node kinds. */
function getReferencedSymbolsSpecial(node, sourceFiles, cancellationToken) {
@@ -426996,12 +428264,12 @@ var ts;
}
// A modifier readonly (like on a property declaration) is not special;
// a readonly type keyword (like `readonly string[]`) is.
- if (node.kind === 145 /* SyntaxKind.ReadonlyKeyword */ && !isReadonlyTypeOperator(node)) {
+ if (node.kind === 146 /* SyntaxKind.ReadonlyKeyword */ && !isReadonlyTypeOperator(node)) {
return undefined;
}
// Likewise, when we *are* looking for a special keyword, make sure we
// *don’t* include readonly member modifiers.
- return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken, node.kind === 145 /* SyntaxKind.ReadonlyKeyword */ ? isReadonlyTypeOperator : undefined);
+ return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken, node.kind === 146 /* SyntaxKind.ReadonlyKeyword */ ? isReadonlyTypeOperator : undefined);
}
if (ts.isImportMeta(node.parent) && node.parent.name === node) {
return getAllReferencesForImportMeta(sourceFiles, cancellationToken);
@@ -427068,8 +428336,8 @@ var ts;
}
function getSpecialSearchKind(node) {
switch (node.kind) {
- case 171 /* SyntaxKind.Constructor */:
- case 134 /* SyntaxKind.ConstructorKeyword */:
+ case 173 /* SyntaxKind.Constructor */:
+ case 135 /* SyntaxKind.ConstructorKeyword */:
return 1 /* SpecialSearchKind.Constructor */;
case 79 /* SyntaxKind.Identifier */:
if (ts.isClassLike(node.parent)) {
@@ -427317,7 +428585,7 @@ var ts;
// If this is the symbol of a named function expression or named class expression,
// then named references are limited to its own scope.
var declarations = symbol.declarations, flags = symbol.flags, parent = symbol.parent, valueDeclaration = symbol.valueDeclaration;
- if (valueDeclaration && (valueDeclaration.kind === 213 /* SyntaxKind.FunctionExpression */ || valueDeclaration.kind === 226 /* SyntaxKind.ClassExpression */)) {
+ if (valueDeclaration && (valueDeclaration.kind === 215 /* SyntaxKind.FunctionExpression */ || valueDeclaration.kind === 228 /* SyntaxKind.ClassExpression */)) {
return valueDeclaration;
}
if (!declarations) {
@@ -427327,7 +428595,7 @@ var ts;
if (flags & (4 /* SymbolFlags.Property */ | 8192 /* SymbolFlags.Method */)) {
var privateDeclaration = ts.find(declarations, function (d) { return ts.hasEffectiveModifier(d, 8 /* ModifierFlags.Private */) || ts.isPrivateIdentifierClassElementDeclaration(d); });
if (privateDeclaration) {
- return ts.getAncestor(privateDeclaration, 257 /* SyntaxKind.ClassDeclaration */);
+ return ts.getAncestor(privateDeclaration, 260 /* SyntaxKind.ClassDeclaration */);
}
// Else this is a public property and could be accessed from anywhere.
return undefined;
@@ -427356,7 +428624,7 @@ var ts;
// Different declarations have different containers, bail out
return undefined;
}
- if (!container || container.kind === 305 /* SyntaxKind.SourceFile */ && !ts.isExternalOrCommonJsModule(container)) {
+ if (!container || container.kind === 308 /* SyntaxKind.SourceFile */ && !ts.isExternalOrCommonJsModule(container)) {
// This is a global variable and not an external module, any declaration defined
// within this scope is visible outside the file
return undefined;
@@ -427614,7 +428882,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 === 203 /* SyntaxKind.BindingElement */
+ && referenceLocation.parent.kind === 205 /* SyntaxKind.BindingElement */
&& ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent.parent.parent)) {
referenceSymbol = referenceLocation.parent.symbol;
// The parent will not have a symbol if it's an ObjectBindingPattern (when destructuring is used). In
@@ -427721,7 +428989,7 @@ var ts;
}
}
function addReference(referenceLocation, relatedSymbol, state) {
- var _a = "kind" in relatedSymbol ? relatedSymbol : { kind: undefined, symbol: relatedSymbol }, kind = _a.kind, symbol = _a.symbol; // eslint-disable-line no-in-operator
+ var _a = "kind" in relatedSymbol ? relatedSymbol : { kind: undefined, symbol: relatedSymbol }, kind = _a.kind, symbol = _a.symbol; // eslint-disable-line local/no-in-operator
// if rename symbol from default export anonymous function, for example `export default function() {}`, we do not need to add reference
if (state.options.use === 2 /* FindReferencesUse.Rename */ && referenceLocation.kind === 88 /* SyntaxKind.DefaultKeyword */) {
return;
@@ -427787,15 +429055,15 @@ var ts;
if (constructorSymbol && constructorSymbol.declarations) {
for (var _i = 0, _a = constructorSymbol.declarations; _i < _a.length; _i++) {
var decl = _a[_i];
- var ctrKeyword = ts.findChildOfKind(decl, 134 /* SyntaxKind.ConstructorKeyword */, sourceFile);
- ts.Debug.assert(decl.kind === 171 /* SyntaxKind.Constructor */ && !!ctrKeyword);
+ var ctrKeyword = ts.findChildOfKind(decl, 135 /* SyntaxKind.ConstructorKeyword */, sourceFile);
+ ts.Debug.assert(decl.kind === 173 /* SyntaxKind.Constructor */ && !!ctrKeyword);
addNode(ctrKeyword);
}
}
if (classSymbol.exports) {
classSymbol.exports.forEach(function (member) {
var decl = member.valueDeclaration;
- if (decl && decl.kind === 169 /* SyntaxKind.MethodDeclaration */) {
+ if (decl && decl.kind === 171 /* SyntaxKind.MethodDeclaration */) {
var body = decl.body;
if (body) {
forEachDescendantOfKind(body, 108 /* SyntaxKind.ThisKeyword */, function (thisKeyword) {
@@ -427819,7 +429087,7 @@ var ts;
}
for (var _i = 0, _a = constructor.declarations; _i < _a.length; _i++) {
var decl = _a[_i];
- ts.Debug.assert(decl.kind === 171 /* SyntaxKind.Constructor */);
+ ts.Debug.assert(decl.kind === 173 /* SyntaxKind.Constructor */);
var body = decl.body;
if (body) {
forEachDescendantOfKind(body, 106 /* SyntaxKind.SuperKeyword */, function (node) {
@@ -427849,7 +429117,7 @@ var ts;
if (refNode.kind !== 79 /* SyntaxKind.Identifier */) {
return;
}
- if (refNode.parent.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) {
+ if (refNode.parent.kind === 300 /* SyntaxKind.ShorthandPropertyAssignment */) {
// Go ahead and dereference the shorthand assignment by going to its definition
getReferenceEntriesForShorthandPropertyAssignment(refNode, state.checker, addReference);
}
@@ -427869,7 +429137,7 @@ var ts;
}
else if (ts.isFunctionLike(typeHavingNode) && typeHavingNode.body) {
var body = typeHavingNode.body;
- if (body.kind === 235 /* SyntaxKind.Block */) {
+ if (body.kind === 238 /* SyntaxKind.Block */) {
ts.forEachReturnStatement(body, function (returnStatement) {
if (returnStatement.expression)
addIfImplementation(returnStatement.expression);
@@ -427897,13 +429165,13 @@ var ts;
*/
function isImplementationExpression(node) {
switch (node.kind) {
- case 212 /* SyntaxKind.ParenthesizedExpression */:
+ case 214 /* SyntaxKind.ParenthesizedExpression */:
return isImplementationExpression(node.expression);
- case 214 /* SyntaxKind.ArrowFunction */:
- case 213 /* SyntaxKind.FunctionExpression */:
- case 205 /* SyntaxKind.ObjectLiteralExpression */:
- case 226 /* SyntaxKind.ClassExpression */:
- case 204 /* SyntaxKind.ArrayLiteralExpression */:
+ case 216 /* SyntaxKind.ArrowFunction */:
+ case 215 /* SyntaxKind.FunctionExpression */:
+ case 207 /* SyntaxKind.ObjectLiteralExpression */:
+ case 228 /* SyntaxKind.ClassExpression */:
+ case 206 /* SyntaxKind.ArrayLiteralExpression */:
return true;
default:
return false;
@@ -427956,13 +429224,13 @@ var ts;
// Whether 'super' occurs in a static context within a class.
var staticFlag = 32 /* ModifierFlags.Static */;
switch (searchSpaceNode.kind) {
- case 167 /* SyntaxKind.PropertyDeclaration */:
- case 166 /* SyntaxKind.PropertySignature */:
- case 169 /* SyntaxKind.MethodDeclaration */:
- case 168 /* SyntaxKind.MethodSignature */:
- case 171 /* SyntaxKind.Constructor */:
- case 172 /* SyntaxKind.GetAccessor */:
- case 173 /* SyntaxKind.SetAccessor */:
+ case 169 /* SyntaxKind.PropertyDeclaration */:
+ case 168 /* SyntaxKind.PropertySignature */:
+ case 171 /* SyntaxKind.MethodDeclaration */:
+ case 170 /* SyntaxKind.MethodSignature */:
+ case 173 /* SyntaxKind.Constructor */:
+ case 174 /* SyntaxKind.GetAccessor */:
+ case 175 /* SyntaxKind.SetAccessor */:
staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode);
searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class
break;
@@ -427983,43 +429251,43 @@ var ts;
return [{ definition: { type: 0 /* DefinitionKind.Symbol */, symbol: searchSpaceNode.symbol }, references: references }];
}
function isParameterName(node) {
- return node.kind === 79 /* SyntaxKind.Identifier */ && node.parent.kind === 164 /* SyntaxKind.Parameter */ && node.parent.name === node;
+ return node.kind === 79 /* SyntaxKind.Identifier */ && node.parent.kind === 166 /* SyntaxKind.Parameter */ && node.parent.name === node;
}
function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles, cancellationToken) {
var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false);
// Whether 'this' occurs in a static context within a class.
var staticFlag = 32 /* ModifierFlags.Static */;
switch (searchSpaceNode.kind) {
- case 169 /* SyntaxKind.MethodDeclaration */:
- case 168 /* SyntaxKind.MethodSignature */:
+ case 171 /* SyntaxKind.MethodDeclaration */:
+ case 170 /* SyntaxKind.MethodSignature */:
if (ts.isObjectLiteralMethod(searchSpaceNode)) {
staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode);
searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning object literals
break;
}
// falls through
- case 167 /* SyntaxKind.PropertyDeclaration */:
- case 166 /* SyntaxKind.PropertySignature */:
- case 171 /* SyntaxKind.Constructor */:
- case 172 /* SyntaxKind.GetAccessor */:
- case 173 /* SyntaxKind.SetAccessor */:
+ case 169 /* SyntaxKind.PropertyDeclaration */:
+ case 168 /* SyntaxKind.PropertySignature */:
+ case 173 /* SyntaxKind.Constructor */:
+ case 174 /* SyntaxKind.GetAccessor */:
+ case 175 /* SyntaxKind.SetAccessor */:
staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode);
searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class
break;
- case 305 /* SyntaxKind.SourceFile */:
+ case 308 /* SyntaxKind.SourceFile */:
if (ts.isExternalModule(searchSpaceNode) || isParameterName(thisOrSuperKeyword)) {
return undefined;
}
// falls through
- case 256 /* SyntaxKind.FunctionDeclaration */:
- case 213 /* SyntaxKind.FunctionExpression */:
+ case 259 /* SyntaxKind.FunctionDeclaration */:
+ case 215 /* SyntaxKind.FunctionExpression */:
break;
// Computed properties in classes are not handled here because references to this are illegal,
// so there is no point finding references to them.
default:
return undefined;
}
- var references = ts.flatMap(searchSpaceNode.kind === 305 /* SyntaxKind.SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) {
+ var references = ts.flatMap(searchSpaceNode.kind === 308 /* SyntaxKind.SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) {
cancellationToken.throwIfCancellationRequested();
return getPossibleSymbolReferenceNodes(sourceFile, "this", ts.isSourceFile(searchSpaceNode) ? sourceFile : searchSpaceNode).filter(function (node) {
if (!ts.isThis(node)) {
@@ -428027,20 +429295,20 @@ var ts;
}
var container = ts.getThisContainer(node, /* includeArrowFunctions */ false);
switch (searchSpaceNode.kind) {
- case 213 /* SyntaxKind.FunctionExpression */:
- case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 215 /* SyntaxKind.FunctionExpression */:
+ case 259 /* SyntaxKind.FunctionDeclaration */:
return searchSpaceNode.symbol === container.symbol;
- case 169 /* SyntaxKind.MethodDeclaration */:
- case 168 /* SyntaxKind.MethodSignature */:
+ case 171 /* SyntaxKind.MethodDeclaration */:
+ case 170 /* SyntaxKind.MethodSignature */:
return ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol;
- case 226 /* SyntaxKind.ClassExpression */:
- case 257 /* SyntaxKind.ClassDeclaration */:
- case 205 /* SyntaxKind.ObjectLiteralExpression */:
+ case 228 /* SyntaxKind.ClassExpression */:
+ case 260 /* SyntaxKind.ClassDeclaration */:
+ case 207 /* SyntaxKind.ObjectLiteralExpression */:
// Make sure the container belongs to the same class/object literals
// and has the appropriate static modifier from the original container.
return container.parent && searchSpaceNode.symbol === container.parent.symbol && ts.isStatic(container) === !!staticFlag;
- case 305 /* SyntaxKind.SourceFile */:
- return container.kind === 305 /* SyntaxKind.SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node);
+ case 308 /* SyntaxKind.SourceFile */:
+ return container.kind === 308 /* SyntaxKind.SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node);
}
});
}).map(function (n) { return nodeEntry(n); });
@@ -428151,7 +429419,7 @@ var ts;
ts.Debug.assert(paramProps.length === 2 && !!(paramProps[0].flags & 1 /* SymbolFlags.FunctionScopedVariable */) && !!(paramProps[1].flags & 4 /* SymbolFlags.Property */)); // is [parameter, property]
return fromRoot(symbol.flags & 1 /* SymbolFlags.FunctionScopedVariable */ ? paramProps[1] : paramProps[0]);
}
- var exportSpecifier = ts.getDeclarationOfKind(symbol, 275 /* SyntaxKind.ExportSpecifier */);
+ var exportSpecifier = ts.getDeclarationOfKind(symbol, 278 /* SyntaxKind.ExportSpecifier */);
if (!isForRenamePopulateSearchSymbolSet || exportSpecifier && !exportSpecifier.propertyName) {
var localSymbol = exportSpecifier && checker.getExportSpecifierLocalTargetSymbol(exportSpecifier);
if (localSymbol) {
@@ -428196,7 +429464,7 @@ var ts;
});
}
function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker) {
- var bindingElement = ts.getDeclarationOfKind(symbol, 203 /* SyntaxKind.BindingElement */);
+ var bindingElement = ts.getDeclarationOfKind(symbol, 205 /* SyntaxKind.BindingElement */);
if (bindingElement && ts.isObjectBindingElementWithoutPropertyName(bindingElement)) {
return ts.getPropertySymbolFromBindingElement(checker, bindingElement);
}
@@ -428459,16 +429727,16 @@ var ts;
return;
}
switch (node.kind) {
- case 172 /* SyntaxKind.GetAccessor */:
- case 173 /* SyntaxKind.SetAccessor */:
- case 169 /* SyntaxKind.MethodDeclaration */:
- if (node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) {
+ case 174 /* SyntaxKind.GetAccessor */:
+ case 175 /* SyntaxKind.SetAccessor */:
+ case 171 /* SyntaxKind.MethodDeclaration */:
+ if (node.parent.kind === 207 /* SyntaxKind.ObjectLiteralExpression */) {
return (_a = ts.getAssignedName(node.parent)) === null || _a === void 0 ? void 0 : _a.getText();
}
return (_b = ts.getNameOfDeclaration(node.parent)) === null || _b === void 0 ? void 0 : _b.getText();
- case 256 /* SyntaxKind.FunctionDeclaration */:
- case 257 /* SyntaxKind.ClassDeclaration */:
- case 261 /* SyntaxKind.ModuleDeclaration */:
+ case 259 /* SyntaxKind.FunctionDeclaration */:
+ case 260 /* SyntaxKind.ClassDeclaration */:
+ case 264 /* SyntaxKind.ModuleDeclaration */:
if (ts.isModuleBlock(node.parent) && ts.isIdentifier(node.parent.parent.name)) {
return node.parent.parent.name.getText();
}
@@ -428683,61 +429951,65 @@ var ts;
}
switch (node.kind) {
case 79 /* SyntaxKind.Identifier */:
- case 265 /* SyntaxKind.ImportEqualsDeclaration */:
- case 266 /* SyntaxKind.ImportDeclaration */:
- case 272 /* SyntaxKind.ExportDeclaration */:
- case 258 /* SyntaxKind.InterfaceDeclaration */:
- case 259 /* SyntaxKind.TypeAliasDeclaration */:
+ case 268 /* SyntaxKind.ImportEqualsDeclaration */:
+ case 269 /* SyntaxKind.ImportDeclaration */:
+ case 275 /* SyntaxKind.ExportDeclaration */:
+ case 261 /* SyntaxKind.InterfaceDeclaration */:
+ case 262 /* SyntaxKind.TypeAliasDeclaration */:
// do not descend into nodes that cannot contain callable nodes
return;
- case 170 /* SyntaxKind.ClassStaticBlockDeclaration */:
+ case 172 /* SyntaxKind.ClassStaticBlockDeclaration */:
recordCallSite(node);
return;
- case 211 /* SyntaxKind.TypeAssertionExpression */:
- case 229 /* SyntaxKind.AsExpression */:
+ case 213 /* SyntaxKind.TypeAssertionExpression */:
+ case 231 /* SyntaxKind.AsExpression */:
// do not descend into the type side of an assertion
collect(node.expression);
return;
- case 254 /* SyntaxKind.VariableDeclaration */:
- case 164 /* SyntaxKind.Parameter */:
+ case 257 /* SyntaxKind.VariableDeclaration */:
+ case 166 /* SyntaxKind.Parameter */:
// do not descend into the type of a variable or parameter declaration
collect(node.name);
collect(node.initializer);
return;
- case 208 /* SyntaxKind.CallExpression */:
+ case 210 /* SyntaxKind.CallExpression */:
// do not descend into the type arguments of a call expression
recordCallSite(node);
collect(node.expression);
ts.forEach(node.arguments, collect);
return;
- case 209 /* SyntaxKind.NewExpression */:
+ case 211 /* SyntaxKind.NewExpression */:
// do not descend into the type arguments of a new expression
recordCallSite(node);
collect(node.expression);
ts.forEach(node.arguments, collect);
return;
- case 210 /* SyntaxKind.TaggedTemplateExpression */:
+ case 212 /* SyntaxKind.TaggedTemplateExpression */:
// do not descend into the type arguments of a tagged template expression
recordCallSite(node);
collect(node.tag);
collect(node.template);
return;
- case 280 /* SyntaxKind.JsxOpeningElement */:
- case 279 /* SyntaxKind.JsxSelfClosingElement */:
+ case 283 /* SyntaxKind.JsxOpeningElement */:
+ case 282 /* SyntaxKind.JsxSelfClosingElement */:
// do not descend into the type arguments of a JsxOpeningLikeElement
recordCallSite(node);
collect(node.tagName);
collect(node.attributes);
return;
- case 165 /* SyntaxKind.Decorator */:
+ case 167 /* SyntaxKind.Decorator */:
recordCallSite(node);
collect(node.expression);
return;
- case 206 /* SyntaxKind.PropertyAccessExpression */:
- case 207 /* SyntaxKind.ElementAccessExpression */:
+ case 208 /* SyntaxKind.PropertyAccessExpression */:
+ case 209 /* SyntaxKind.ElementAccessExpression */:
recordCallSite(node);
ts.forEachChild(node, collect);
break;
+ case 235 /* SyntaxKind.SatisfiesExpression */:
+ // do not descend into the type side of an assertion
+ collect(node.expression);
+ return;
}
if (ts.isPartOfTypeNode(node)) {
// do not descend into types
@@ -428792,25 +430064,25 @@ var ts;
var callSites = [];
var collect = createCallSiteCollector(program, callSites);
switch (node.kind) {
- case 305 /* SyntaxKind.SourceFile */:
+ case 308 /* SyntaxKind.SourceFile */:
collectCallSitesOfSourceFile(node, collect);
break;
- case 261 /* SyntaxKind.ModuleDeclaration */:
+ case 264 /* SyntaxKind.ModuleDeclaration */:
collectCallSitesOfModuleDeclaration(node, collect);
break;
- case 256 /* SyntaxKind.FunctionDeclaration */:
- case 213 /* SyntaxKind.FunctionExpression */:
- case 214 /* SyntaxKind.ArrowFunction */:
- case 169 /* SyntaxKind.MethodDeclaration */:
- case 172 /* SyntaxKind.GetAccessor */:
- case 173 /* SyntaxKind.SetAccessor */:
+ case 259 /* SyntaxKind.FunctionDeclaration */:
+ case 215 /* SyntaxKind.FunctionExpression */:
+ case 216 /* SyntaxKind.ArrowFunction */:
+ case 171 /* SyntaxKind.MethodDeclaration */:
+ case 174 /* SyntaxKind.GetAccessor */:
+ case 175 /* SyntaxKind.SetAccessor */:
collectCallSitesOfFunctionLikeDeclaration(program.getTypeChecker(), node, collect);
break;
- case 257 /* SyntaxKind.ClassDeclaration */:
- case 226 /* SyntaxKind.ClassExpression */:
+ case 260 /* SyntaxKind.ClassDeclaration */:
+ case 228 /* SyntaxKind.ClassExpression */:
collectCallSitesOfClassLikeDeclaration(node, collect);
break;
- case 170 /* SyntaxKind.ClassStaticBlockDeclaration */:
+ case 172 /* SyntaxKind.ClassStaticBlockDeclaration */:
collectCallSitesOfClassStaticBlockDeclaration(node, collect);
break;
default:
@@ -429081,7 +430353,7 @@ var ts;
}
var parent = node.parent;
var typeChecker = program.getTypeChecker();
- if (node.kind === 159 /* SyntaxKind.OverrideKeyword */ || (ts.isIdentifier(node) && ts.isJSDocOverrideTag(parent) && parent.tagName === node)) {
+ if (node.kind === 161 /* SyntaxKind.OverrideKeyword */ || (ts.isIdentifier(node) && ts.isJSDocOverrideTag(parent) && parent.tagName === node)) {
return getDefinitionFromOverriddenMember(typeChecker, node) || ts.emptyArray;
}
// Labels
@@ -429089,6 +430361,12 @@ var ts;
var label = ts.getTargetLabel(node.parent, node.text);
return label ? [createDefinitionInfoFromName(typeChecker, label, "label" /* ScriptElementKind.label */, node.text, /*containerName*/ undefined)] : undefined; // TODO: GH#18217
}
+ if (node.kind === 105 /* SyntaxKind.ReturnKeyword */) {
+ var functionDeclaration = ts.findAncestor(node.parent, function (n) {
+ return ts.isClassStaticBlockDeclaration(n) ? "quit" : ts.isFunctionLikeDeclaration(n);
+ });
+ return functionDeclaration ? [createDefinitionFromSignatureDeclaration(typeChecker, functionDeclaration)] : undefined;
+ }
if (ts.isStaticModifier(node) && ts.isClassStaticBlockDeclaration(node.parent)) {
var classDecl = node.parent.parent;
var _c = getSymbol(classDecl, typeChecker, stopAtAlias), symbol_1 = _c.symbol, failedAliasResolution_1 = _c.failedAliasResolution;
@@ -429157,7 +430435,7 @@ var ts;
// go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition
// is performed at the location of property access, we would like to go to definition of the property in the short-hand
// assignment. This case and others are handled by the following code.
- if (node.parent.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) {
+ if (node.parent.kind === 300 /* SyntaxKind.ShorthandPropertyAssignment */) {
var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration);
var definitions = (shorthandSymbol_1 === null || shorthandSymbol_1 === void 0 ? void 0 : shorthandSymbol_1.declarations) ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node, /*unverified*/ false, failedAliasResolution); }) : ts.emptyArray;
return ts.concatenate(definitions, getDefinitionFromObjectLiteralElement(typeChecker, node) || ts.emptyArray);
@@ -429224,13 +430502,16 @@ var ts;
if (!baseDeclaration)
return;
var baseTypeNode = ts.getEffectiveBaseTypeNode(baseDeclaration);
- var baseType = baseTypeNode ? typeChecker.getTypeAtLocation(baseTypeNode) : undefined;
- if (!baseType)
+ if (!baseTypeNode)
+ return;
+ var expression = ts.skipParentheses(baseTypeNode.expression);
+ var base = ts.isClassExpression(expression) ? expression.symbol : typeChecker.getSymbolAtLocation(expression);
+ if (!base)
return;
var name = ts.unescapeLeadingUnderscores(ts.getTextOfPropertyName(classElement.name));
var symbol = ts.hasStaticModifier(classElement)
- ? typeChecker.getPropertyOfType(typeChecker.getTypeOfSymbolAtLocation(baseType.symbol, baseDeclaration), name)
- : typeChecker.getPropertyOfType(baseType, name);
+ ? typeChecker.getPropertyOfType(typeChecker.getTypeOfSymbol(base), name)
+ : typeChecker.getPropertyOfType(typeChecker.getDeclaredTypeOfSymbol(base), name);
if (!symbol)
return;
return getDefinitionFromSymbol(typeChecker, symbol, node);
@@ -429363,7 +430644,7 @@ var ts;
if (node.parent === declaration) {
return true;
}
- if (declaration.kind === 268 /* SyntaxKind.NamespaceImport */) {
+ if (declaration.kind === 271 /* SyntaxKind.NamespaceImport */) {
return false;
}
return true;
@@ -429405,7 +430686,7 @@ var ts;
function getConstructSignatureDefinition() {
// Applicable only if we are in a new expression, or we are on a constructor declaration
// and in either case the symbol has a construct signature definition, i.e. class
- if (symbol.flags & 32 /* SymbolFlags.Class */ && !(symbol.flags & (16 /* SymbolFlags.Function */ | 3 /* SymbolFlags.Variable */)) && (ts.isNewExpressionTarget(node) || node.kind === 134 /* SyntaxKind.ConstructorKeyword */)) {
+ if (symbol.flags & 32 /* SymbolFlags.Class */ && !(symbol.flags & (16 /* SymbolFlags.Function */ | 3 /* SymbolFlags.Variable */)) && (ts.isNewExpressionTarget(node) || node.kind === 135 /* SyntaxKind.ConstructorKeyword */)) {
var cls = ts.find(filteredDeclarations, ts.isClassLike) || ts.Debug.fail("Expected declaration to have at least one class-like declaration");
return getSignatureDefinition(cls.members, /*selectConstructors*/ true);
}
@@ -429457,22 +430738,22 @@ var ts;
return isDefinitionVisible(checker, declaration.parent);
// Handle some exceptions here like arrow function, members of class and object literal expression which are technically not visible but we want the definition to be determined by its parent
switch (declaration.kind) {
- case 167 /* SyntaxKind.PropertyDeclaration */:
- case 172 /* SyntaxKind.GetAccessor */:
- case 173 /* SyntaxKind.SetAccessor */:
- case 169 /* SyntaxKind.MethodDeclaration */:
+ case 169 /* SyntaxKind.PropertyDeclaration */:
+ case 174 /* SyntaxKind.GetAccessor */:
+ case 175 /* SyntaxKind.SetAccessor */:
+ case 171 /* SyntaxKind.MethodDeclaration */:
// Private/protected properties/methods are not visible
if (ts.hasEffectiveModifier(declaration, 8 /* ModifierFlags.Private */))
return false;
// Public properties/methods are visible if its parents are visible, so:
// falls through
- case 171 /* SyntaxKind.Constructor */:
- case 296 /* SyntaxKind.PropertyAssignment */:
- case 297 /* SyntaxKind.ShorthandPropertyAssignment */:
- case 205 /* SyntaxKind.ObjectLiteralExpression */:
- case 226 /* SyntaxKind.ClassExpression */:
- case 214 /* SyntaxKind.ArrowFunction */:
- case 213 /* SyntaxKind.FunctionExpression */:
+ case 173 /* SyntaxKind.Constructor */:
+ case 299 /* SyntaxKind.PropertyAssignment */:
+ case 300 /* SyntaxKind.ShorthandPropertyAssignment */:
+ case 207 /* SyntaxKind.ObjectLiteralExpression */:
+ case 228 /* SyntaxKind.ClassExpression */:
+ case 216 /* SyntaxKind.ArrowFunction */:
+ case 215 /* SyntaxKind.FunctionExpression */:
return isDefinitionVisible(checker, declaration.parent);
default:
return false;
@@ -429510,9 +430791,9 @@ var ts;
}
function isConstructorLike(node) {
switch (node.kind) {
- case 171 /* SyntaxKind.Constructor */:
- case 180 /* SyntaxKind.ConstructorType */:
- case 175 /* SyntaxKind.ConstructSignature */:
+ case 173 /* SyntaxKind.Constructor */:
+ case 182 /* SyntaxKind.ConstructorType */:
+ case 177 /* SyntaxKind.ConstructSignature */:
return true;
default:
return false;
@@ -429618,17 +430899,17 @@ var ts;
ts.forEachUnique(declarations, function (declaration) {
for (var _i = 0, _a = getCommentHavingNodes(declaration); _i < _a.length; _i++) {
var jsdoc = _a[_i];
- var inheritDoc = ts.isJSDoc(jsdoc) && jsdoc.tags && ts.find(jsdoc.tags, function (t) { return t.kind === 327 /* SyntaxKind.JSDocTag */ && (t.tagName.escapedText === "inheritDoc" || t.tagName.escapedText === "inheritdoc"); });
+ var inheritDoc = ts.isJSDoc(jsdoc) && jsdoc.tags && ts.find(jsdoc.tags, function (t) { return t.kind === 330 /* SyntaxKind.JSDocTag */ && (t.tagName.escapedText === "inheritDoc" || t.tagName.escapedText === "inheritdoc"); });
// skip comments containing @typedefs since they're not associated with particular declarations
// Exceptions:
// - @typedefs are themselves declarations with associated comments
// - @param or @return indicate that the author thinks of it as a 'local' @typedef that's part of the function documentation
if (jsdoc.comment === undefined && !inheritDoc
|| ts.isJSDoc(jsdoc)
- && declaration.kind !== 345 /* SyntaxKind.JSDocTypedefTag */ && declaration.kind !== 338 /* SyntaxKind.JSDocCallbackTag */
+ && declaration.kind !== 348 /* SyntaxKind.JSDocTypedefTag */ && declaration.kind !== 341 /* SyntaxKind.JSDocCallbackTag */
&& jsdoc.tags
- && jsdoc.tags.some(function (t) { return t.kind === 345 /* SyntaxKind.JSDocTypedefTag */ || t.kind === 338 /* SyntaxKind.JSDocCallbackTag */; })
- && !jsdoc.tags.some(function (t) { return t.kind === 340 /* SyntaxKind.JSDocParameterTag */ || t.kind === 341 /* SyntaxKind.JSDocReturnTag */; })) {
+ && jsdoc.tags.some(function (t) { return t.kind === 348 /* SyntaxKind.JSDocTypedefTag */ || t.kind === 341 /* SyntaxKind.JSDocCallbackTag */; })
+ && !jsdoc.tags.some(function (t) { return t.kind === 343 /* SyntaxKind.JSDocParameterTag */ || t.kind === 344 /* SyntaxKind.JSDocReturnTag */; })) {
continue;
}
var newparts = jsdoc.comment ? getDisplayPartsFromComment(jsdoc.comment, checker) : [];
@@ -429648,11 +430929,11 @@ var ts;
}
function getCommentHavingNodes(declaration) {
switch (declaration.kind) {
- case 340 /* SyntaxKind.JSDocParameterTag */:
- case 347 /* SyntaxKind.JSDocPropertyTag */:
+ case 343 /* SyntaxKind.JSDocParameterTag */:
+ case 350 /* SyntaxKind.JSDocPropertyTag */:
return [declaration];
- case 338 /* SyntaxKind.JSDocCallbackTag */:
- case 345 /* SyntaxKind.JSDocTypedefTag */:
+ case 341 /* SyntaxKind.JSDocCallbackTag */:
+ case 348 /* SyntaxKind.JSDocTypedefTag */:
return [declaration, declaration.parent];
default:
return ts.getJSDocCommentsAndTags(declaration);
@@ -429666,8 +430947,8 @@ var ts;
// skip comments containing @typedefs since they're not associated with particular declarations
// Exceptions:
// - @param or @return indicate that the author thinks of it as a 'local' @typedef that's part of the function documentation
- if (tags.some(function (t) { return t.kind === 345 /* SyntaxKind.JSDocTypedefTag */ || t.kind === 338 /* SyntaxKind.JSDocCallbackTag */; })
- && !tags.some(function (t) { return t.kind === 340 /* SyntaxKind.JSDocParameterTag */ || t.kind === 341 /* SyntaxKind.JSDocReturnTag */; })) {
+ if (tags.some(function (t) { return t.kind === 348 /* SyntaxKind.JSDocTypedefTag */ || t.kind === 341 /* SyntaxKind.JSDocCallbackTag */; })
+ && !tags.some(function (t) { return t.kind === 343 /* SyntaxKind.JSDocParameterTag */ || t.kind === 344 /* SyntaxKind.JSDocReturnTag */; })) {
return;
}
for (var _i = 0, tags_1 = tags; _i < tags_1.length; _i++) {
@@ -429682,17 +430963,17 @@ var ts;
if (typeof comment === "string") {
return [ts.textPart(comment)];
}
- return ts.flatMap(comment, function (node) { return node.kind === 321 /* SyntaxKind.JSDocText */ ? [ts.textPart(node.text)] : ts.buildLinkParts(node, checker); });
+ return ts.flatMap(comment, function (node) { return node.kind === 324 /* SyntaxKind.JSDocText */ ? [ts.textPart(node.text)] : ts.buildLinkParts(node, checker); });
}
function getCommentDisplayParts(tag, checker) {
var comment = tag.comment, kind = tag.kind;
var namePart = getTagNameDisplayPart(kind);
switch (kind) {
- case 329 /* SyntaxKind.JSDocImplementsTag */:
+ case 332 /* SyntaxKind.JSDocImplementsTag */:
return withNode(tag.class);
- case 328 /* SyntaxKind.JSDocAugmentsTag */:
+ case 331 /* SyntaxKind.JSDocAugmentsTag */:
return withNode(tag.class);
- case 344 /* SyntaxKind.JSDocTemplateTag */:
+ case 347 /* SyntaxKind.JSDocTemplateTag */:
var templateTag = tag;
var displayParts_3 = [];
if (templateTag.constraint) {
@@ -429714,13 +430995,13 @@ var ts;
displayParts_3.push.apply(displayParts_3, __spreadArray([ts.spacePart()], getDisplayPartsFromComment(comment, checker), true));
}
return displayParts_3;
- case 343 /* SyntaxKind.JSDocTypeTag */:
+ case 346 /* SyntaxKind.JSDocTypeTag */:
return withNode(tag.typeExpression);
- case 345 /* SyntaxKind.JSDocTypedefTag */:
- case 338 /* SyntaxKind.JSDocCallbackTag */:
- case 347 /* SyntaxKind.JSDocPropertyTag */:
- case 340 /* SyntaxKind.JSDocParameterTag */:
- case 346 /* SyntaxKind.JSDocSeeTag */:
+ case 348 /* SyntaxKind.JSDocTypedefTag */:
+ case 341 /* SyntaxKind.JSDocCallbackTag */:
+ case 350 /* SyntaxKind.JSDocPropertyTag */:
+ case 343 /* SyntaxKind.JSDocParameterTag */:
+ case 349 /* SyntaxKind.JSDocSeeTag */:
var name = tag.name;
return name ? withNode(name)
: comment === undefined ? undefined
@@ -429747,14 +431028,14 @@ var ts;
}
function getTagNameDisplayPart(kind) {
switch (kind) {
- case 340 /* SyntaxKind.JSDocParameterTag */:
+ case 343 /* SyntaxKind.JSDocParameterTag */:
return ts.parameterNamePart;
- case 347 /* SyntaxKind.JSDocPropertyTag */:
+ case 350 /* SyntaxKind.JSDocPropertyTag */:
return ts.propertyNamePart;
- case 344 /* SyntaxKind.JSDocTemplateTag */:
+ case 347 /* SyntaxKind.JSDocTemplateTag */:
return ts.typeParameterNamePart;
- case 345 /* SyntaxKind.JSDocTypedefTag */:
- case 338 /* SyntaxKind.JSDocCallbackTag */:
+ case 348 /* SyntaxKind.JSDocTypedefTag */:
+ case 341 /* SyntaxKind.JSDocCallbackTag */:
return ts.typeAliasNamePart;
default:
return ts.textPart;
@@ -429925,43 +431206,48 @@ var ts;
}
function getCommentOwnerInfoWorker(commentOwner, options) {
switch (commentOwner.kind) {
- case 256 /* SyntaxKind.FunctionDeclaration */:
- case 213 /* SyntaxKind.FunctionExpression */:
- case 169 /* SyntaxKind.MethodDeclaration */:
- case 171 /* SyntaxKind.Constructor */:
- case 168 /* SyntaxKind.MethodSignature */:
- case 214 /* SyntaxKind.ArrowFunction */:
+ case 259 /* SyntaxKind.FunctionDeclaration */:
+ case 215 /* SyntaxKind.FunctionExpression */:
+ case 171 /* SyntaxKind.MethodDeclaration */:
+ case 173 /* SyntaxKind.Constructor */:
+ case 170 /* SyntaxKind.MethodSignature */:
+ case 216 /* SyntaxKind.ArrowFunction */:
var host = commentOwner;
return { commentOwner: commentOwner, parameters: host.parameters, hasReturn: hasReturn(host, options) };
- case 296 /* SyntaxKind.PropertyAssignment */:
+ case 299 /* SyntaxKind.PropertyAssignment */:
return getCommentOwnerInfoWorker(commentOwner.initializer, options);
- case 257 /* SyntaxKind.ClassDeclaration */:
- case 258 /* SyntaxKind.InterfaceDeclaration */:
- case 166 /* SyntaxKind.PropertySignature */:
- case 260 /* SyntaxKind.EnumDeclaration */:
- case 299 /* SyntaxKind.EnumMember */:
- case 259 /* SyntaxKind.TypeAliasDeclaration */:
+ case 260 /* SyntaxKind.ClassDeclaration */:
+ case 261 /* SyntaxKind.InterfaceDeclaration */:
+ case 263 /* SyntaxKind.EnumDeclaration */:
+ case 302 /* SyntaxKind.EnumMember */:
+ case 262 /* SyntaxKind.TypeAliasDeclaration */:
return { commentOwner: commentOwner };
- case 237 /* SyntaxKind.VariableStatement */: {
+ case 168 /* SyntaxKind.PropertySignature */: {
+ var host_1 = commentOwner;
+ return host_1.type && ts.isFunctionTypeNode(host_1.type)
+ ? { commentOwner: commentOwner, parameters: host_1.type.parameters, hasReturn: hasReturn(host_1.type, options) }
+ : { commentOwner: commentOwner };
+ }
+ case 240 /* SyntaxKind.VariableStatement */: {
var varStatement = commentOwner;
var varDeclarations = varStatement.declarationList.declarations;
- var host_1 = varDeclarations.length === 1 && varDeclarations[0].initializer
+ var host_2 = varDeclarations.length === 1 && varDeclarations[0].initializer
? getRightHandSideOfAssignment(varDeclarations[0].initializer)
: undefined;
- return host_1
- ? { commentOwner: commentOwner, parameters: host_1.parameters, hasReturn: hasReturn(host_1, options) }
+ return host_2
+ ? { commentOwner: commentOwner, parameters: host_2.parameters, hasReturn: hasReturn(host_2, options) }
: { commentOwner: commentOwner };
}
- case 305 /* SyntaxKind.SourceFile */:
+ case 308 /* SyntaxKind.SourceFile */:
return "quit";
- case 261 /* SyntaxKind.ModuleDeclaration */:
+ case 264 /* SyntaxKind.ModuleDeclaration */:
// If in walking up the tree, we hit a a nested namespace declaration,
// then we must be somewhere within a dotted namespace name; however we don't
// want to give back a JSDoc template for the 'b' or 'c' in 'namespace a.b.c { }'.
- return commentOwner.parent.kind === 261 /* SyntaxKind.ModuleDeclaration */ ? undefined : { commentOwner: commentOwner };
- case 238 /* SyntaxKind.ExpressionStatement */:
+ return commentOwner.parent.kind === 264 /* SyntaxKind.ModuleDeclaration */ ? undefined : { commentOwner: commentOwner };
+ case 241 /* SyntaxKind.ExpressionStatement */:
return getCommentOwnerInfoWorker(commentOwner.expression, options);
- case 221 /* SyntaxKind.BinaryExpression */: {
+ case 223 /* SyntaxKind.BinaryExpression */: {
var be = commentOwner;
if (ts.getAssignmentDeclarationKind(be) === 0 /* AssignmentDeclarationKind.None */) {
return "quit";
@@ -429970,7 +431256,7 @@ var ts;
? { commentOwner: commentOwner, parameters: be.right.parameters, hasReturn: hasReturn(be.right, options) }
: { commentOwner: commentOwner };
}
- case 167 /* SyntaxKind.PropertyDeclaration */:
+ case 169 /* SyntaxKind.PropertyDeclaration */:
var init = commentOwner.initializer;
if (init && (ts.isFunctionExpression(init) || ts.isArrowFunction(init))) {
return { commentOwner: commentOwner, parameters: init.parameters, hasReturn: hasReturn(init, options) };
@@ -429979,18 +431265,18 @@ var ts;
}
function hasReturn(node, options) {
return !!(options === null || options === void 0 ? void 0 : options.generateReturnInDocTemplate) &&
- (ts.isArrowFunction(node) && ts.isExpression(node.body)
+ (ts.isFunctionTypeNode(node) || ts.isArrowFunction(node) && ts.isExpression(node.body)
|| ts.isFunctionLikeDeclaration(node) && node.body && ts.isBlock(node.body) && !!ts.forEachReturnStatement(node.body, function (n) { return n; }));
}
function getRightHandSideOfAssignment(rightHandSide) {
- while (rightHandSide.kind === 212 /* SyntaxKind.ParenthesizedExpression */) {
+ while (rightHandSide.kind === 214 /* SyntaxKind.ParenthesizedExpression */) {
rightHandSide = rightHandSide.expression;
}
switch (rightHandSide.kind) {
- case 213 /* SyntaxKind.FunctionExpression */:
- case 214 /* SyntaxKind.ArrowFunction */:
+ case 215 /* SyntaxKind.FunctionExpression */:
+ case 216 /* SyntaxKind.ArrowFunction */:
return rightHandSide;
- case 226 /* SyntaxKind.ClassExpression */:
+ case 228 /* SyntaxKind.ClassExpression */:
return ts.find(rightHandSide.members, ts.isConstructorDeclaration);
}
}
@@ -430049,9 +431335,9 @@ var ts;
}
function shouldKeepItem(declaration, checker) {
switch (declaration.kind) {
- case 267 /* SyntaxKind.ImportClause */:
- case 270 /* SyntaxKind.ImportSpecifier */:
- case 265 /* SyntaxKind.ImportEqualsDeclaration */:
+ case 270 /* SyntaxKind.ImportClause */:
+ case 273 /* SyntaxKind.ImportSpecifier */:
+ case 268 /* SyntaxKind.ImportEqualsDeclaration */:
var importer = checker.getSymbolAtLocation(declaration.name); // TODO: GH#18217
var imported = checker.getAliasedSymbol(importer);
return importer.escapedName !== imported.escapedName;
@@ -430061,7 +431347,7 @@ var ts;
}
function tryAddSingleDeclarationName(declaration, containers) {
var name = ts.getNameOfDeclaration(declaration);
- return !!name && (pushLiteral(name, containers) || name.kind === 162 /* SyntaxKind.ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers));
+ return !!name && (pushLiteral(name, containers) || name.kind === 164 /* SyntaxKind.ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers));
}
// Only added the names of computed properties if they're simple dotted expressions, like:
//
@@ -430078,7 +431364,7 @@ var ts;
// First, if we started with a computed property name, then add all but the last
// portion into the container array.
var name = ts.getNameOfDeclaration(declaration);
- if (name && name.kind === 162 /* SyntaxKind.ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) {
+ if (name && name.kind === 164 /* SyntaxKind.ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) {
return ts.emptyArray;
}
// Don't include the last portion.
@@ -430295,7 +431581,7 @@ var ts;
*/
function hasNavigationBarName(node) {
return !ts.hasDynamicName(node) ||
- (node.kind !== 221 /* SyntaxKind.BinaryExpression */ &&
+ (node.kind !== 223 /* SyntaxKind.BinaryExpression */ &&
ts.isPropertyAccessExpression(node.name.expression) &&
ts.isIdentifier(node.name.expression.expression) &&
ts.idText(node.name.expression.expression) === "Symbol");
@@ -430308,7 +431594,7 @@ var ts;
return;
}
switch (node.kind) {
- case 171 /* SyntaxKind.Constructor */:
+ case 173 /* SyntaxKind.Constructor */:
// Get parameter properties, and treat them as being on the *same* level as the constructor, not under it.
var ctr = node;
addNodeWithRecursiveChild(ctr, ctr.body);
@@ -430320,25 +431606,25 @@ var ts;
}
}
break;
- case 169 /* SyntaxKind.MethodDeclaration */:
- case 172 /* SyntaxKind.GetAccessor */:
- case 173 /* SyntaxKind.SetAccessor */:
- case 168 /* SyntaxKind.MethodSignature */:
+ case 171 /* SyntaxKind.MethodDeclaration */:
+ case 174 /* SyntaxKind.GetAccessor */:
+ case 175 /* SyntaxKind.SetAccessor */:
+ case 170 /* SyntaxKind.MethodSignature */:
if (hasNavigationBarName(node)) {
addNodeWithRecursiveChild(node, node.body);
}
break;
- case 167 /* SyntaxKind.PropertyDeclaration */:
+ case 169 /* SyntaxKind.PropertyDeclaration */:
if (hasNavigationBarName(node)) {
addNodeWithRecursiveInitializer(node);
}
break;
- case 166 /* SyntaxKind.PropertySignature */:
+ case 168 /* SyntaxKind.PropertySignature */:
if (hasNavigationBarName(node)) {
addLeafNode(node);
}
break;
- case 267 /* SyntaxKind.ImportClause */:
+ case 270 /* SyntaxKind.ImportClause */:
var importClause = node;
// Handle default import case e.g.:
// import d from "mod";
@@ -430350,7 +431636,7 @@ var ts;
// import {a, b as B} from "mod";
var namedBindings = importClause.namedBindings;
if (namedBindings) {
- if (namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) {
+ if (namedBindings.kind === 271 /* SyntaxKind.NamespaceImport */) {
addLeafNode(namedBindings);
}
else {
@@ -430361,17 +431647,17 @@ var ts;
}
}
break;
- case 297 /* SyntaxKind.ShorthandPropertyAssignment */:
+ case 300 /* SyntaxKind.ShorthandPropertyAssignment */:
addNodeWithRecursiveChild(node, node.name);
break;
- case 298 /* SyntaxKind.SpreadAssignment */:
+ case 301 /* SyntaxKind.SpreadAssignment */:
var expression = node.expression;
// Use the expression as the name of the SpreadAssignment, otherwise show as .
ts.isIdentifier(expression) ? addLeafNode(node, expression) : addLeafNode(node);
break;
- case 203 /* SyntaxKind.BindingElement */:
- case 296 /* SyntaxKind.PropertyAssignment */:
- case 254 /* SyntaxKind.VariableDeclaration */: {
+ case 205 /* SyntaxKind.BindingElement */:
+ case 299 /* SyntaxKind.PropertyAssignment */:
+ case 257 /* SyntaxKind.VariableDeclaration */: {
var child = node;
if (ts.isBindingPattern(child.name)) {
addChildrenRecursively(child.name);
@@ -430381,7 +431667,7 @@ var ts;
}
break;
}
- case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 259 /* SyntaxKind.FunctionDeclaration */:
var nameNode = node.name;
// If we see a function declaration track as a possible ES5 class
if (nameNode && ts.isIdentifier(nameNode)) {
@@ -430389,11 +431675,11 @@ var ts;
}
addNodeWithRecursiveChild(node, node.body);
break;
- case 214 /* SyntaxKind.ArrowFunction */:
- case 213 /* SyntaxKind.FunctionExpression */:
+ case 216 /* SyntaxKind.ArrowFunction */:
+ case 215 /* SyntaxKind.FunctionExpression */:
addNodeWithRecursiveChild(node, node.body);
break;
- case 260 /* SyntaxKind.EnumDeclaration */:
+ case 263 /* SyntaxKind.EnumDeclaration */:
startNode(node);
for (var _e = 0, _f = node.members; _e < _f.length; _e++) {
var member = _f[_e];
@@ -430403,9 +431689,9 @@ var ts;
}
endNode();
break;
- case 257 /* SyntaxKind.ClassDeclaration */:
- case 226 /* SyntaxKind.ClassExpression */:
- case 258 /* SyntaxKind.InterfaceDeclaration */:
+ case 260 /* SyntaxKind.ClassDeclaration */:
+ case 228 /* SyntaxKind.ClassExpression */:
+ case 261 /* SyntaxKind.InterfaceDeclaration */:
startNode(node);
for (var _g = 0, _h = node.members; _g < _h.length; _g++) {
var member = _h[_g];
@@ -430413,10 +431699,10 @@ var ts;
}
endNode();
break;
- case 261 /* SyntaxKind.ModuleDeclaration */:
+ case 264 /* SyntaxKind.ModuleDeclaration */:
addNodeWithRecursiveChild(node, getInteriorModule(node).body);
break;
- case 271 /* SyntaxKind.ExportAssignment */: {
+ case 274 /* SyntaxKind.ExportAssignment */: {
var expression_1 = node.expression;
var child = ts.isObjectLiteralExpression(expression_1) || ts.isCallExpression(expression_1) ? expression_1 :
ts.isArrowFunction(expression_1) || ts.isFunctionExpression(expression_1) ? expression_1.body : undefined;
@@ -430430,16 +431716,16 @@ var ts;
}
break;
}
- case 275 /* SyntaxKind.ExportSpecifier */:
- case 265 /* SyntaxKind.ImportEqualsDeclaration */:
- case 176 /* SyntaxKind.IndexSignature */:
- case 174 /* SyntaxKind.CallSignature */:
- case 175 /* SyntaxKind.ConstructSignature */:
- case 259 /* SyntaxKind.TypeAliasDeclaration */:
+ case 278 /* SyntaxKind.ExportSpecifier */:
+ case 268 /* SyntaxKind.ImportEqualsDeclaration */:
+ case 178 /* SyntaxKind.IndexSignature */:
+ case 176 /* SyntaxKind.CallSignature */:
+ case 177 /* SyntaxKind.ConstructSignature */:
+ case 262 /* SyntaxKind.TypeAliasDeclaration */:
addLeafNode(node);
break;
- case 208 /* SyntaxKind.CallExpression */:
- case 221 /* SyntaxKind.BinaryExpression */: {
+ case 210 /* SyntaxKind.CallExpression */:
+ case 223 /* SyntaxKind.BinaryExpression */: {
var special = ts.getAssignmentDeclarationKind(node);
switch (special) {
case 1 /* AssignmentDeclarationKind.ExportsProperty */:
@@ -430679,12 +431965,12 @@ var ts;
return false;
}
switch (a.kind) {
- case 167 /* SyntaxKind.PropertyDeclaration */:
- case 169 /* SyntaxKind.MethodDeclaration */:
- case 172 /* SyntaxKind.GetAccessor */:
- case 173 /* SyntaxKind.SetAccessor */:
+ case 169 /* SyntaxKind.PropertyDeclaration */:
+ case 171 /* SyntaxKind.MethodDeclaration */:
+ case 174 /* SyntaxKind.GetAccessor */:
+ case 175 /* SyntaxKind.SetAccessor */:
return ts.isStatic(a) === ts.isStatic(b);
- case 261 /* SyntaxKind.ModuleDeclaration */:
+ case 264 /* SyntaxKind.ModuleDeclaration */:
return areSameModule(a, b)
&& getFullyQualifiedModuleName(a) === getFullyQualifiedModuleName(b);
default:
@@ -430706,7 +431992,7 @@ var ts;
if (!a.body || !b.body) {
return a.body === b.body;
}
- return a.body.kind === b.body.kind && (a.body.kind !== 261 /* SyntaxKind.ModuleDeclaration */ || areSameModule(a.body, b.body));
+ return a.body.kind === b.body.kind && (a.body.kind !== 264 /* SyntaxKind.ModuleDeclaration */ || areSameModule(a.body, b.body));
}
/** Merge source into target. Source should be thrown away after this is called. */
function merge(target, source) {
@@ -430736,7 +432022,7 @@ var ts;
* So `new()` can still come before an `aardvark` method.
*/
function tryGetName(node) {
- if (node.kind === 261 /* SyntaxKind.ModuleDeclaration */) {
+ if (node.kind === 264 /* SyntaxKind.ModuleDeclaration */) {
return getModuleName(node);
}
var declName = ts.getNameOfDeclaration(node);
@@ -430745,16 +432031,16 @@ var ts;
return propertyName && ts.unescapeLeadingUnderscores(propertyName);
}
switch (node.kind) {
- case 213 /* SyntaxKind.FunctionExpression */:
- case 214 /* SyntaxKind.ArrowFunction */:
- case 226 /* SyntaxKind.ClassExpression */:
+ case 215 /* SyntaxKind.FunctionExpression */:
+ case 216 /* SyntaxKind.ArrowFunction */:
+ case 228 /* SyntaxKind.ClassExpression */:
return getFunctionOrClassName(node);
default:
return undefined;
}
}
function getItemName(node, name) {
- if (node.kind === 261 /* SyntaxKind.ModuleDeclaration */) {
+ if (node.kind === 264 /* SyntaxKind.ModuleDeclaration */) {
return cleanText(getModuleName(node));
}
if (name) {
@@ -430766,32 +432052,32 @@ var ts;
}
}
switch (node.kind) {
- case 305 /* SyntaxKind.SourceFile */:
+ case 308 /* SyntaxKind.SourceFile */:
var sourceFile = node;
return ts.isExternalModule(sourceFile)
? "\"".concat(ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))), "\"")
: "";
- case 271 /* SyntaxKind.ExportAssignment */:
+ case 274 /* SyntaxKind.ExportAssignment */:
return ts.isExportAssignment(node) && node.isExportEquals ? "export=" /* InternalSymbolName.ExportEquals */ : "default" /* InternalSymbolName.Default */;
- case 214 /* SyntaxKind.ArrowFunction */:
- case 256 /* SyntaxKind.FunctionDeclaration */:
- case 213 /* SyntaxKind.FunctionExpression */:
- case 257 /* SyntaxKind.ClassDeclaration */:
- case 226 /* SyntaxKind.ClassExpression */:
- if (ts.getSyntacticModifierFlags(node) & 512 /* ModifierFlags.Default */) {
+ case 216 /* SyntaxKind.ArrowFunction */:
+ case 259 /* SyntaxKind.FunctionDeclaration */:
+ case 215 /* SyntaxKind.FunctionExpression */:
+ case 260 /* SyntaxKind.ClassDeclaration */:
+ case 228 /* SyntaxKind.ClassExpression */:
+ if (ts.getSyntacticModifierFlags(node) & 1024 /* ModifierFlags.Default */) {
return "default";
}
// We may get a string with newlines or other whitespace in the case of an object dereference
// (eg: "app\n.onactivated"), so we should remove the whitespace for readability in the
// navigation bar.
return getFunctionOrClassName(node);
- case 171 /* SyntaxKind.Constructor */:
+ case 173 /* SyntaxKind.Constructor */:
return "constructor";
- case 175 /* SyntaxKind.ConstructSignature */:
+ case 177 /* SyntaxKind.ConstructSignature */:
return "new()";
- case 174 /* SyntaxKind.CallSignature */:
+ case 176 /* SyntaxKind.CallSignature */:
return "()";
- case 176 /* SyntaxKind.IndexSignature */:
+ case 178 /* SyntaxKind.IndexSignature */:
return "[]";
default:
return "";
@@ -430824,19 +432110,19 @@ var ts;
}
// Some nodes are otherwise important enough to always include in the primary navigation menu.
switch (navigationBarNodeKind(item)) {
- case 257 /* SyntaxKind.ClassDeclaration */:
- case 226 /* SyntaxKind.ClassExpression */:
- case 260 /* SyntaxKind.EnumDeclaration */:
- case 258 /* SyntaxKind.InterfaceDeclaration */:
- case 261 /* SyntaxKind.ModuleDeclaration */:
- case 305 /* SyntaxKind.SourceFile */:
- case 259 /* SyntaxKind.TypeAliasDeclaration */:
- case 345 /* SyntaxKind.JSDocTypedefTag */:
- case 338 /* SyntaxKind.JSDocCallbackTag */:
+ case 260 /* SyntaxKind.ClassDeclaration */:
+ case 228 /* SyntaxKind.ClassExpression */:
+ case 263 /* SyntaxKind.EnumDeclaration */:
+ case 261 /* SyntaxKind.InterfaceDeclaration */:
+ case 264 /* SyntaxKind.ModuleDeclaration */:
+ case 308 /* SyntaxKind.SourceFile */:
+ case 262 /* SyntaxKind.TypeAliasDeclaration */:
+ case 348 /* SyntaxKind.JSDocTypedefTag */:
+ case 341 /* SyntaxKind.JSDocCallbackTag */:
return true;
- case 214 /* SyntaxKind.ArrowFunction */:
- case 256 /* SyntaxKind.FunctionDeclaration */:
- case 213 /* SyntaxKind.FunctionExpression */:
+ case 216 /* SyntaxKind.ArrowFunction */:
+ case 259 /* SyntaxKind.FunctionDeclaration */:
+ case 215 /* SyntaxKind.FunctionExpression */:
return isTopLevelFunctionDeclaration(item);
default:
return false;
@@ -430846,10 +432132,10 @@ var ts;
return false;
}
switch (navigationBarNodeKind(item.parent)) {
- case 262 /* SyntaxKind.ModuleBlock */:
- case 305 /* SyntaxKind.SourceFile */:
- case 169 /* SyntaxKind.MethodDeclaration */:
- case 171 /* SyntaxKind.Constructor */:
+ case 265 /* SyntaxKind.ModuleBlock */:
+ case 308 /* SyntaxKind.SourceFile */:
+ case 171 /* SyntaxKind.MethodDeclaration */:
+ case 173 /* SyntaxKind.Constructor */:
return true;
default:
return false;
@@ -430911,7 +432197,7 @@ var ts;
function getFullyQualifiedModuleName(moduleDeclaration) {
// Otherwise, we need to aggregate each identifier to build up the qualified name.
var result = [ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)];
- while (moduleDeclaration.body && moduleDeclaration.body.kind === 261 /* SyntaxKind.ModuleDeclaration */) {
+ while (moduleDeclaration.body && moduleDeclaration.body.kind === 264 /* SyntaxKind.ModuleDeclaration */) {
moduleDeclaration = moduleDeclaration.body;
result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name));
}
@@ -430925,13 +432211,13 @@ var ts;
return decl.body && ts.isModuleDeclaration(decl.body) ? getInteriorModule(decl.body) : decl;
}
function isComputedProperty(member) {
- return !member.name || member.name.kind === 162 /* SyntaxKind.ComputedPropertyName */;
+ return !member.name || member.name.kind === 164 /* SyntaxKind.ComputedPropertyName */;
}
function getNodeSpan(node) {
- return node.kind === 305 /* SyntaxKind.SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile);
+ return node.kind === 308 /* SyntaxKind.SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile);
}
function getModifiers(node) {
- if (node.parent && node.parent.kind === 254 /* SyntaxKind.VariableDeclaration */) {
+ if (node.parent && node.parent.kind === 257 /* SyntaxKind.VariableDeclaration */) {
node = node.parent;
}
return ts.getNodeModifiers(node);
@@ -430954,7 +432240,7 @@ var ts;
return nodeText(parent.name);
}
// Default exports are named "default"
- else if (ts.getSyntacticModifierFlags(node) & 512 /* ModifierFlags.Default */) {
+ else if (ts.getSyntacticModifierFlags(node) & 1024 /* ModifierFlags.Default */) {
return "default";
}
else if (ts.isClassLike(node)) {
@@ -430989,9 +432275,9 @@ var ts;
}
function isFunctionOrClassExpression(node) {
switch (node.kind) {
- case 214 /* SyntaxKind.ArrowFunction */:
- case 213 /* SyntaxKind.FunctionExpression */:
- case 226 /* SyntaxKind.ClassExpression */:
+ case 216 /* SyntaxKind.ArrowFunction */:
+ case 215 /* SyntaxKind.FunctionExpression */:
+ case 228 /* SyntaxKind.ClassExpression */:
return true;
default:
return false;
@@ -431020,23 +432306,39 @@ var ts;
* 2) Coalescing imports from the same module
* 3) Sorting imports
*/
- function organizeImports(sourceFile, formatContext, host, program, preferences, skipDestructiveCodeActions) {
+ function organizeImports(sourceFile, formatContext, host, program, preferences, mode) {
var changeTracker = ts.textChanges.ChangeTracker.fromContext({ host: host, formatContext: formatContext, preferences: preferences });
- var coalesceAndOrganizeImports = function (importGroup) { return ts.stableSort(coalesceImports(removeUnusedImports(importGroup, sourceFile, program, skipDestructiveCodeActions)), function (s1, s2) { return compareImportsOrRequireStatements(s1, s2); }); };
+ var shouldSort = mode === "SortAndCombine" /* OrganizeImportsMode.SortAndCombine */ || mode === "All" /* OrganizeImportsMode.All */;
+ var shouldCombine = shouldSort; // These are currently inseparable, but I draw a distinction for clarity and in case we add modes in the future.
+ var shouldRemove = mode === "RemoveUnused" /* OrganizeImportsMode.RemoveUnused */ || mode === "All" /* OrganizeImportsMode.All */;
+ var maybeRemove = shouldRemove ? removeUnusedImports : ts.identity;
+ var maybeCoalesce = shouldCombine ? coalesceImports : ts.identity;
+ var processImportsOfSameModuleSpecifier = function (importGroup) {
+ var processedDeclarations = maybeCoalesce(maybeRemove(importGroup, sourceFile, program));
+ return shouldSort
+ ? ts.stableSort(processedDeclarations, function (s1, s2) { return compareImportsOrRequireStatements(s1, s2); })
+ : processedDeclarations;
+ };
// All of the old ImportDeclarations in the file, in syntactic order.
var topLevelImportGroupDecls = groupImportsByNewlineContiguous(sourceFile, sourceFile.statements.filter(ts.isImportDeclaration));
- topLevelImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl, coalesceAndOrganizeImports); });
- // All of the old ExportDeclarations in the file, in syntactic order.
- var topLevelExportDecls = sourceFile.statements.filter(ts.isExportDeclaration);
- organizeImportsWorker(topLevelExportDecls, coalesceExports);
+ topLevelImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl, processImportsOfSameModuleSpecifier); });
+ // Exports are always used
+ if (mode !== "RemoveUnused" /* OrganizeImportsMode.RemoveUnused */) {
+ // All of the old ExportDeclarations in the file, in syntactic order.
+ var topLevelExportDecls = sourceFile.statements.filter(ts.isExportDeclaration);
+ organizeImportsWorker(topLevelExportDecls, coalesceExports);
+ }
for (var _i = 0, _a = sourceFile.statements.filter(ts.isAmbientModule); _i < _a.length; _i++) {
var ambientModule = _a[_i];
if (!ambientModule.body)
continue;
var ambientModuleImportGroupDecls = groupImportsByNewlineContiguous(sourceFile, ambientModule.body.statements.filter(ts.isImportDeclaration));
- ambientModuleImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl, coalesceAndOrganizeImports); });
- var ambientModuleExportDecls = ambientModule.body.statements.filter(ts.isExportDeclaration);
- organizeImportsWorker(ambientModuleExportDecls, coalesceExports);
+ ambientModuleImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl, processImportsOfSameModuleSpecifier); });
+ // Exports are always used
+ if (mode !== "RemoveUnused" /* OrganizeImportsMode.RemoveUnused */) {
+ var ambientModuleExportDecls = ambientModule.body.statements.filter(ts.isExportDeclaration);
+ organizeImportsWorker(ambientModuleExportDecls, coalesceExports);
+ }
}
return changeTracker.getChanges();
function organizeImportsWorker(oldImportDecls, coalesce) {
@@ -431049,8 +432351,12 @@ var ts;
// Consider: we could do a more careful check that this trivia is actually a header,
// but the consequences of being wrong are very minor.
ts.suppressLeadingTrivia(oldImportDecls[0]);
- var oldImportGroups = ts.group(oldImportDecls, function (importDecl) { return getExternalModuleName(importDecl.moduleSpecifier); });
- var sortedImportGroups = ts.stableSort(oldImportGroups, function (group1, group2) { return compareModuleSpecifiers(group1[0].moduleSpecifier, group2[0].moduleSpecifier); });
+ var oldImportGroups = shouldCombine
+ ? ts.group(oldImportDecls, function (importDecl) { return getExternalModuleName(importDecl.moduleSpecifier); })
+ : [oldImportDecls];
+ var sortedImportGroups = shouldSort
+ ? ts.stableSort(oldImportGroups, function (group1, group2) { return compareModuleSpecifiers(group1[0].moduleSpecifier, group2[0].moduleSpecifier); })
+ : oldImportGroups;
var newImportDecls = ts.flatMap(sortedImportGroups, function (importGroup) {
return getExternalModuleName(importGroup[0].moduleSpecifier)
? coalesce(importGroup)
@@ -431114,11 +432420,7 @@ var ts;
}
return false;
}
- function removeUnusedImports(oldImports, sourceFile, program, skipDestructiveCodeActions) {
- // As a precaution, consider unused import detection to be destructive (GH #43051)
- if (skipDestructiveCodeActions) {
- return oldImports;
- }
+ function removeUnusedImports(oldImports, sourceFile, program) {
var typeChecker = program.getTypeChecker();
var compilerOptions = program.getCompilerOptions();
var jsxNamespace = typeChecker.getJsxNamespace(sourceFile);
@@ -431392,11 +432694,11 @@ var ts;
function getModuleSpecifierExpression(declaration) {
var _a;
switch (declaration.kind) {
- case 265 /* SyntaxKind.ImportEqualsDeclaration */:
+ case 268 /* SyntaxKind.ImportEqualsDeclaration */:
return (_a = ts.tryCast(declaration.moduleReference, ts.isExternalModuleReference)) === null || _a === void 0 ? void 0 : _a.expression;
- case 266 /* SyntaxKind.ImportDeclaration */:
+ case 269 /* SyntaxKind.ImportDeclaration */:
return declaration.moduleSpecifier;
- case 237 /* SyntaxKind.VariableStatement */:
+ case 240 /* SyntaxKind.VariableStatement */:
return declaration.declarationList.declarations[0].initializer.arguments[0];
}
}
@@ -431435,19 +432737,19 @@ var ts;
function getImportKindOrder(s1) {
var _a;
switch (s1.kind) {
- case 266 /* SyntaxKind.ImportDeclaration */:
+ case 269 /* SyntaxKind.ImportDeclaration */:
if (!s1.importClause)
return 0;
if (s1.importClause.isTypeOnly)
return 1;
- if (((_a = s1.importClause.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 268 /* SyntaxKind.NamespaceImport */)
+ if (((_a = s1.importClause.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 271 /* SyntaxKind.NamespaceImport */)
return 2;
if (s1.importClause.name)
return 3;
return 4;
- case 265 /* SyntaxKind.ImportEqualsDeclaration */:
+ case 268 /* SyntaxKind.ImportEqualsDeclaration */:
return 5;
- case 237 /* SyntaxKind.VariableStatement */:
+ case 240 /* SyntaxKind.VariableStatement */:
return 6;
}
}
@@ -431636,7 +432938,7 @@ var ts;
}
function getOutliningSpanForNode(n, sourceFile) {
switch (n.kind) {
- case 235 /* SyntaxKind.Block */:
+ case 238 /* SyntaxKind.Block */:
if (ts.isFunctionLike(n.parent)) {
return functionSpan(n.parent, n, sourceFile);
}
@@ -431644,16 +432946,16 @@ var ts;
// If the latter, we want to collapse the block, but consider its hint span
// to be the entire span of the parent.
switch (n.parent.kind) {
- case 240 /* SyntaxKind.DoStatement */:
- case 243 /* SyntaxKind.ForInStatement */:
- case 244 /* SyntaxKind.ForOfStatement */:
- case 242 /* SyntaxKind.ForStatement */:
- case 239 /* SyntaxKind.IfStatement */:
- case 241 /* SyntaxKind.WhileStatement */:
- case 248 /* SyntaxKind.WithStatement */:
- case 292 /* SyntaxKind.CatchClause */:
+ case 243 /* SyntaxKind.DoStatement */:
+ case 246 /* SyntaxKind.ForInStatement */:
+ case 247 /* SyntaxKind.ForOfStatement */:
+ case 245 /* SyntaxKind.ForStatement */:
+ case 242 /* SyntaxKind.IfStatement */:
+ case 244 /* SyntaxKind.WhileStatement */:
+ case 251 /* SyntaxKind.WithStatement */:
+ case 295 /* SyntaxKind.CatchClause */:
return spanForNode(n.parent);
- case 252 /* SyntaxKind.TryStatement */:
+ case 255 /* SyntaxKind.TryStatement */:
// Could be the try-block, or the finally-block.
var tryStatement = n.parent;
if (tryStatement.tryBlock === n) {
@@ -431670,42 +432972,42 @@ var ts;
// the span of the block, independent of any parent span.
return createOutliningSpan(ts.createTextSpanFromNode(n, sourceFile), "code" /* OutliningSpanKind.Code */);
}
- case 262 /* SyntaxKind.ModuleBlock */:
+ case 265 /* SyntaxKind.ModuleBlock */:
return spanForNode(n.parent);
- case 257 /* SyntaxKind.ClassDeclaration */:
- case 226 /* SyntaxKind.ClassExpression */:
- case 258 /* SyntaxKind.InterfaceDeclaration */:
- case 260 /* SyntaxKind.EnumDeclaration */:
- case 263 /* SyntaxKind.CaseBlock */:
- case 182 /* SyntaxKind.TypeLiteral */:
- case 201 /* SyntaxKind.ObjectBindingPattern */:
+ case 260 /* SyntaxKind.ClassDeclaration */:
+ case 228 /* SyntaxKind.ClassExpression */:
+ case 261 /* SyntaxKind.InterfaceDeclaration */:
+ case 263 /* SyntaxKind.EnumDeclaration */:
+ case 266 /* SyntaxKind.CaseBlock */:
+ case 184 /* SyntaxKind.TypeLiteral */:
+ case 203 /* SyntaxKind.ObjectBindingPattern */:
return spanForNode(n);
- case 184 /* SyntaxKind.TupleType */:
+ case 186 /* SyntaxKind.TupleType */:
return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isTupleTypeNode(n.parent), 22 /* SyntaxKind.OpenBracketToken */);
- case 289 /* SyntaxKind.CaseClause */:
- case 290 /* SyntaxKind.DefaultClause */:
+ case 292 /* SyntaxKind.CaseClause */:
+ case 293 /* SyntaxKind.DefaultClause */:
return spanForNodeArray(n.statements);
- case 205 /* SyntaxKind.ObjectLiteralExpression */:
+ case 207 /* SyntaxKind.ObjectLiteralExpression */:
return spanForObjectOrArrayLiteral(n);
- case 204 /* SyntaxKind.ArrayLiteralExpression */:
+ case 206 /* SyntaxKind.ArrayLiteralExpression */:
return spanForObjectOrArrayLiteral(n, 22 /* SyntaxKind.OpenBracketToken */);
- case 278 /* SyntaxKind.JsxElement */:
+ case 281 /* SyntaxKind.JsxElement */:
return spanForJSXElement(n);
- case 282 /* SyntaxKind.JsxFragment */:
+ case 285 /* SyntaxKind.JsxFragment */:
return spanForJSXFragment(n);
- case 279 /* SyntaxKind.JsxSelfClosingElement */:
- case 280 /* SyntaxKind.JsxOpeningElement */:
+ case 282 /* SyntaxKind.JsxSelfClosingElement */:
+ case 283 /* SyntaxKind.JsxOpeningElement */:
return spanForJSXAttributes(n.attributes);
- case 223 /* SyntaxKind.TemplateExpression */:
+ case 225 /* SyntaxKind.TemplateExpression */:
case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */:
return spanForTemplateLiteral(n);
- case 202 /* SyntaxKind.ArrayBindingPattern */:
+ case 204 /* SyntaxKind.ArrayBindingPattern */:
return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isBindingElement(n.parent), 22 /* SyntaxKind.OpenBracketToken */);
- case 214 /* SyntaxKind.ArrowFunction */:
+ case 216 /* SyntaxKind.ArrowFunction */:
return spanForArrowFunction(n);
- case 208 /* SyntaxKind.CallExpression */:
+ case 210 /* SyntaxKind.CallExpression */:
return spanForCallExpression(n);
- case 212 /* SyntaxKind.ParenthesizedExpression */:
+ case 214 /* SyntaxKind.ParenthesizedExpression */:
return spanForParenthesizedExpression(n);
}
function spanForCallExpression(node) {
@@ -431778,7 +433080,7 @@ var ts;
function functionSpan(node, body, sourceFile) {
var openToken = tryGetFunctionOpenToken(node, body, sourceFile);
var closeToken = ts.findChildOfKind(body, 19 /* SyntaxKind.CloseBraceToken */, sourceFile);
- return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 214 /* SyntaxKind.ArrowFunction */);
+ return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 216 /* SyntaxKind.ArrowFunction */);
}
function spanBetweenTokens(openToken, closeToken, hintSpanNode, sourceFile, autoCollapse, useFullStart) {
if (autoCollapse === void 0) { autoCollapse = false; }
@@ -431974,7 +433276,7 @@ var ts;
return bestMatch;
}
function betterMatch(a, b) {
- return ts.min(a, b, compareMatches);
+ return ts.min([a, b], compareMatches);
}
function compareMatches(a, b) {
return a === undefined ? 1 /* Comparison.GreaterThan */ : b === undefined ? -1 /* Comparison.LessThan */
@@ -432322,10 +433624,10 @@ var ts;
*/
function tryConsumeDeclare() {
var token = ts.scanner.getToken();
- if (token === 135 /* SyntaxKind.DeclareKeyword */) {
+ if (token === 136 /* SyntaxKind.DeclareKeyword */) {
// declare module "mod"
token = nextToken();
- if (token === 141 /* SyntaxKind.ModuleKeyword */) {
+ if (token === 142 /* SyntaxKind.ModuleKeyword */) {
token = nextToken();
if (token === 10 /* SyntaxKind.StringLiteral */) {
recordAmbientExternalModule();
@@ -432359,10 +433661,10 @@ var ts;
return true;
}
else {
- if (token === 152 /* SyntaxKind.TypeKeyword */) {
+ if (token === 154 /* SyntaxKind.TypeKeyword */) {
var skipTypeKeyword = ts.scanner.lookAhead(function () {
var token = ts.scanner.scan();
- return token !== 156 /* SyntaxKind.FromKeyword */ && (token === 41 /* SyntaxKind.AsteriskToken */ ||
+ return token !== 158 /* SyntaxKind.FromKeyword */ && (token === 41 /* SyntaxKind.AsteriskToken */ ||
token === 18 /* SyntaxKind.OpenBraceToken */ ||
token === 79 /* SyntaxKind.Identifier */ ||
ts.isKeyword(token));
@@ -432373,7 +433675,7 @@ var ts;
}
if (token === 79 /* SyntaxKind.Identifier */ || ts.isKeyword(token)) {
token = nextToken();
- if (token === 156 /* SyntaxKind.FromKeyword */) {
+ if (token === 158 /* SyntaxKind.FromKeyword */) {
token = nextToken();
if (token === 10 /* SyntaxKind.StringLiteral */) {
// import d from "mod";
@@ -432404,7 +433706,7 @@ var ts;
}
if (token === 19 /* SyntaxKind.CloseBraceToken */) {
token = nextToken();
- if (token === 156 /* SyntaxKind.FromKeyword */) {
+ if (token === 158 /* SyntaxKind.FromKeyword */) {
token = nextToken();
if (token === 10 /* SyntaxKind.StringLiteral */) {
// import {a as A} from "mod";
@@ -432416,11 +433718,11 @@ var ts;
}
else if (token === 41 /* SyntaxKind.AsteriskToken */) {
token = nextToken();
- if (token === 127 /* SyntaxKind.AsKeyword */) {
+ if (token === 128 /* SyntaxKind.AsKeyword */) {
token = nextToken();
if (token === 79 /* SyntaxKind.Identifier */ || ts.isKeyword(token)) {
token = nextToken();
- if (token === 156 /* SyntaxKind.FromKeyword */) {
+ if (token === 158 /* SyntaxKind.FromKeyword */) {
token = nextToken();
if (token === 10 /* SyntaxKind.StringLiteral */) {
// import * as NS from "mod"
@@ -432441,7 +433743,7 @@ var ts;
if (token === 93 /* SyntaxKind.ExportKeyword */) {
markAsExternalModuleIfTopLevel();
token = nextToken();
- if (token === 152 /* SyntaxKind.TypeKeyword */) {
+ if (token === 154 /* SyntaxKind.TypeKeyword */) {
var skipTypeKeyword = ts.scanner.lookAhead(function () {
var token = ts.scanner.scan();
return token === 41 /* SyntaxKind.AsteriskToken */ ||
@@ -432460,7 +433762,7 @@ var ts;
}
if (token === 19 /* SyntaxKind.CloseBraceToken */) {
token = nextToken();
- if (token === 156 /* SyntaxKind.FromKeyword */) {
+ if (token === 158 /* SyntaxKind.FromKeyword */) {
token = nextToken();
if (token === 10 /* SyntaxKind.StringLiteral */) {
// export {a as A} from "mod";
@@ -432472,7 +433774,7 @@ var ts;
}
else if (token === 41 /* SyntaxKind.AsteriskToken */) {
token = nextToken();
- if (token === 156 /* SyntaxKind.FromKeyword */) {
+ if (token === 158 /* SyntaxKind.FromKeyword */) {
token = nextToken();
if (token === 10 /* SyntaxKind.StringLiteral */) {
// export * from "mod"
@@ -432482,7 +433784,7 @@ var ts;
}
else if (token === 100 /* SyntaxKind.ImportKeyword */) {
token = nextToken();
- if (token === 152 /* SyntaxKind.TypeKeyword */) {
+ if (token === 154 /* SyntaxKind.TypeKeyword */) {
var skipTypeKeyword = ts.scanner.lookAhead(function () {
var token = ts.scanner.scan();
return token === 79 /* SyntaxKind.Identifier */ ||
@@ -432508,7 +433810,7 @@ var ts;
function tryConsumeRequireCall(skipCurrentToken, allowTemplateLiterals) {
if (allowTemplateLiterals === void 0) { allowTemplateLiterals = false; }
var token = skipCurrentToken ? nextToken() : ts.scanner.getToken();
- if (token === 146 /* SyntaxKind.RequireKeyword */) {
+ if (token === 147 /* SyntaxKind.RequireKeyword */) {
token = nextToken();
if (token === 20 /* SyntaxKind.OpenParenToken */) {
token = nextToken();
@@ -432583,8 +433885,8 @@ var ts;
}
if (ts.scanner.getToken() === 15 /* SyntaxKind.TemplateHead */) {
var stack = [ts.scanner.getToken()];
- var token = ts.scanner.scan();
loop: while (ts.length(stack)) {
+ var token = ts.scanner.scan();
switch (token) {
case 1 /* SyntaxKind.EndOfFileToken */:
break loop;
@@ -432612,7 +433914,6 @@ var ts;
}
break;
}
- token = ts.scanner.scan();
}
nextToken();
}
@@ -432720,7 +434021,7 @@ var ts;
return getRenameInfoError(wouldRenameNodeModules);
}
var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node);
- var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 162 /* SyntaxKind.ComputedPropertyName */)
+ var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 164 /* SyntaxKind.ComputedPropertyName */)
? ts.stripQuotes(ts.getTextOfIdentifierOrLiteral(node))
: undefined;
var displayName = specifierName || typeChecker.symbolToString(symbol);
@@ -432865,6 +434166,10 @@ var ts;
pushSelectionCommentRange(comment.pos, comment.end);
}
if (positionShouldSnapToNode(sourceFile, pos, node)) {
+ if (ts.isFunctionBody(node)
+ && ts.isFunctionLikeDeclaration(parentNode) && !ts.positionsAreOnSameLine(node.getStart(sourceFile), node.getEnd(), sourceFile)) {
+ pushSelectionRange(node.getStart(sourceFile), node.getEnd());
+ }
// 1. Blocks are effectively redundant with SyntaxLists.
// 2. TemplateSpans, along with the SyntaxLists containing them, are a somewhat unintuitive grouping
// of things that should be considered independently.
@@ -433002,14 +434307,14 @@ var ts;
ts.Debug.assertEqual(closeBraceToken.kind, 19 /* SyntaxKind.CloseBraceToken */);
// Group `-/+readonly` and `-/+?`
var groupedWithPlusMinusTokens = groupChildren(children, function (child) {
- return child === node.readonlyToken || child.kind === 145 /* SyntaxKind.ReadonlyKeyword */ ||
+ return child === node.readonlyToken || child.kind === 146 /* SyntaxKind.ReadonlyKeyword */ ||
child === node.questionToken || child.kind === 57 /* SyntaxKind.QuestionToken */;
});
// Group type parameter with surrounding brackets
var groupedWithBrackets = groupChildren(groupedWithPlusMinusTokens, function (_a) {
var kind = _a.kind;
return kind === 22 /* SyntaxKind.OpenBracketToken */ ||
- kind === 163 /* SyntaxKind.TypeParameter */ ||
+ kind === 165 /* SyntaxKind.TypeParameter */ ||
kind === 23 /* SyntaxKind.CloseBracketToken */;
});
return [
@@ -433027,7 +434332,7 @@ var ts;
var children = groupChildren(node.getChildren(), function (child) {
return child === node.name || ts.contains(node.modifiers, child);
});
- var firstJSDocChild = ((_a = children[0]) === null || _a === void 0 ? void 0 : _a.kind) === 320 /* SyntaxKind.JSDoc */ ? children[0] : undefined;
+ var firstJSDocChild = ((_a = children[0]) === null || _a === void 0 ? void 0 : _a.kind) === 323 /* SyntaxKind.JSDoc */ ? children[0] : undefined;
var withJSDocSeparated = firstJSDocChild ? children.slice(1) : children;
var splittedChildren = splitChildren(withJSDocSeparated, function (_a) {
var kind = _a.kind;
@@ -433126,22 +434431,22 @@ var ts;
return kind === 18 /* SyntaxKind.OpenBraceToken */
|| kind === 22 /* SyntaxKind.OpenBracketToken */
|| kind === 20 /* SyntaxKind.OpenParenToken */
- || kind === 280 /* SyntaxKind.JsxOpeningElement */;
+ || kind === 283 /* SyntaxKind.JsxOpeningElement */;
}
function isListCloser(token) {
var kind = token && token.kind;
return kind === 19 /* SyntaxKind.CloseBraceToken */
|| kind === 23 /* SyntaxKind.CloseBracketToken */
|| kind === 21 /* SyntaxKind.CloseParenToken */
- || kind === 281 /* SyntaxKind.JsxClosingElement */;
+ || kind === 284 /* SyntaxKind.JsxClosingElement */;
}
function getEndPos(sourceFile, node) {
switch (node.kind) {
- case 340 /* SyntaxKind.JSDocParameterTag */:
- case 338 /* SyntaxKind.JSDocCallbackTag */:
- case 347 /* SyntaxKind.JSDocPropertyTag */:
- case 345 /* SyntaxKind.JSDocTypedefTag */:
- case 342 /* SyntaxKind.JSDocThisTag */:
+ case 343 /* SyntaxKind.JSDocParameterTag */:
+ case 341 /* SyntaxKind.JSDocCallbackTag */:
+ case 350 /* SyntaxKind.JSDocPropertyTag */:
+ case 348 /* SyntaxKind.JSDocTypedefTag */:
+ case 345 /* SyntaxKind.JSDocThisTag */:
return sourceFile.getLineEndOfPosition(node.getStart());
default:
return node.getEnd();
@@ -433351,10 +434656,10 @@ var ts;
}
return undefined;
}
- else if (ts.isTemplateHead(node) && parent.parent.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) {
+ else if (ts.isTemplateHead(node) && parent.parent.kind === 212 /* SyntaxKind.TaggedTemplateExpression */) {
var templateExpression = parent;
var tagExpression = templateExpression.parent;
- ts.Debug.assert(templateExpression.kind === 223 /* SyntaxKind.TemplateExpression */);
+ ts.Debug.assert(templateExpression.kind === 225 /* SyntaxKind.TemplateExpression */);
var argumentIndex = ts.isInsideTemplateLiteral(node, position, sourceFile) ? 0 : 1;
return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile);
}
@@ -433426,17 +434731,17 @@ var ts;
return undefined;
var parent = startingToken.parent;
switch (parent.kind) {
- case 212 /* SyntaxKind.ParenthesizedExpression */:
- case 169 /* SyntaxKind.MethodDeclaration */:
- case 213 /* SyntaxKind.FunctionExpression */:
- case 214 /* SyntaxKind.ArrowFunction */:
+ case 214 /* SyntaxKind.ParenthesizedExpression */:
+ case 171 /* SyntaxKind.MethodDeclaration */:
+ case 215 /* SyntaxKind.FunctionExpression */:
+ case 216 /* SyntaxKind.ArrowFunction */:
var info = getArgumentOrParameterListInfo(startingToken, position, sourceFile);
if (!info)
return undefined;
var argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan;
var contextualType = ts.isMethodDeclaration(parent) ? checker.getContextualTypeForObjectLiteralElement(parent) : checker.getContextualType(parent);
return contextualType && { contextualType: contextualType, argumentIndex: argumentIndex, argumentCount: argumentCount, argumentsSpan: argumentsSpan };
- case 221 /* SyntaxKind.BinaryExpression */: {
+ case 223 /* SyntaxKind.BinaryExpression */: {
var highestBinary = getHighestBinary(parent);
var contextualType_1 = checker.getContextualType(highestBinary);
var argumentIndex_1 = startingToken.kind === 20 /* SyntaxKind.OpenParenToken */ ? 0 : countBinaryExpressionParameters(parent) - 1;
@@ -433507,11 +434812,11 @@ var ts;
// not enough to put us in the substitution expression; we should consider ourselves part of
// the *next* span's expression by offsetting the index (argIndex = (spanIndex + 1) + 1).
//
- /* eslint-disable no-double-space */
+ /* eslint-disable local/no-double-space */
// Example: f `# abcd $#{# 1 + 1# }# efghi ${ #"#hello"# } # `
// ^ ^ ^ ^ ^ ^ ^ ^ ^
// Case: 1 1 3 2 1 3 2 2 1
- /* eslint-enable no-double-space */
+ /* eslint-enable local/no-double-space */
ts.Debug.assert(position >= node.getStart(), "Assumed 'position' could not occur before node.");
if (ts.isTemplateLiteralToken(node)) {
if (ts.isInsideTemplateLiteral(node, position, sourceFile)) {
@@ -433560,7 +434865,7 @@ var ts;
// | |
// This is because a Missing node has no width. However, what we actually want is to include trivia
// leading up to the next token in case the user is about to type in a TemplateMiddle or TemplateTail.
- if (template.kind === 223 /* SyntaxKind.TemplateExpression */) {
+ if (template.kind === 225 /* SyntaxKind.TemplateExpression */) {
var lastSpan = ts.last(template.templateSpans);
if (lastSpan.literal.getFullWidth() === 0) {
applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false);
@@ -433765,14 +435070,14 @@ var ts;
return;
}
switch (node.kind) {
- case 261 /* SyntaxKind.ModuleDeclaration */:
- case 257 /* SyntaxKind.ClassDeclaration */:
- case 258 /* SyntaxKind.InterfaceDeclaration */:
- case 256 /* SyntaxKind.FunctionDeclaration */:
- case 226 /* SyntaxKind.ClassExpression */:
- case 213 /* SyntaxKind.FunctionExpression */:
- case 169 /* SyntaxKind.MethodDeclaration */:
- case 214 /* SyntaxKind.ArrowFunction */:
+ case 264 /* SyntaxKind.ModuleDeclaration */:
+ case 260 /* SyntaxKind.ClassDeclaration */:
+ case 261 /* SyntaxKind.InterfaceDeclaration */:
+ case 259 /* SyntaxKind.FunctionDeclaration */:
+ case 228 /* SyntaxKind.ClassExpression */:
+ case 215 /* SyntaxKind.FunctionExpression */:
+ case 171 /* SyntaxKind.MethodDeclaration */:
+ case 216 /* SyntaxKind.ArrowFunction */:
cancellationToken.throwIfCancellationRequested();
}
if (!ts.textSpanIntersectsWith(span, node.pos, node.getFullWidth())) {
@@ -433916,7 +435221,7 @@ var ts;
}
function isHintableLiteral(node) {
switch (node.kind) {
- case 219 /* SyntaxKind.PrefixUnaryExpression */: {
+ case 221 /* SyntaxKind.PrefixUnaryExpression */: {
var operand = node.operand;
return ts.isLiteralExpression(operand) || ts.isIdentifier(operand) && ts.isInfinityOrNaNString(operand.escapedText);
}
@@ -433924,7 +435229,7 @@ var ts;
case 95 /* SyntaxKind.FalseKeyword */:
case 104 /* SyntaxKind.NullKeyword */:
case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */:
- case 223 /* SyntaxKind.TemplateExpression */:
+ case 225 /* SyntaxKind.TemplateExpression */:
return true;
case 79 /* SyntaxKind.Identifier */: {
var name = node.escapedText;
@@ -434245,11 +435550,11 @@ var ts;
function containsTopLevelCommonjs(sourceFile) {
return sourceFile.statements.some(function (statement) {
switch (statement.kind) {
- case 237 /* SyntaxKind.VariableStatement */:
+ case 240 /* SyntaxKind.VariableStatement */:
return statement.declarationList.declarations.some(function (decl) {
return !!decl.initializer && ts.isRequireCall(propertyAccessLeftHandSide(decl.initializer), /*checkArgumentIsStringLiteralLike*/ true);
});
- case 238 /* SyntaxKind.ExpressionStatement */: {
+ case 241 /* SyntaxKind.ExpressionStatement */: {
var expression = statement.expression;
if (!ts.isBinaryExpression(expression))
return ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true);
@@ -434266,12 +435571,12 @@ var ts;
}
function importNameForConvertToDefaultImport(node) {
switch (node.kind) {
- case 266 /* SyntaxKind.ImportDeclaration */:
+ case 269 /* SyntaxKind.ImportDeclaration */:
var importClause = node.importClause, moduleSpecifier = node.moduleSpecifier;
- return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */ && ts.isStringLiteral(moduleSpecifier)
+ return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 271 /* SyntaxKind.NamespaceImport */ && ts.isStringLiteral(moduleSpecifier)
? importClause.namedBindings.name
: undefined;
- case 265 /* SyntaxKind.ImportEqualsDeclaration */:
+ case 268 /* SyntaxKind.ImportEqualsDeclaration */:
return node.name;
default:
return undefined;
@@ -434347,20 +435652,20 @@ var ts;
// should be kept up to date with getTransformationBody in convertToAsyncFunction.ts
function isFixablePromiseArgument(arg, checker) {
switch (arg.kind) {
- case 256 /* SyntaxKind.FunctionDeclaration */:
- case 213 /* SyntaxKind.FunctionExpression */:
+ case 259 /* SyntaxKind.FunctionDeclaration */:
+ case 215 /* SyntaxKind.FunctionExpression */:
var functionFlags = ts.getFunctionFlags(arg);
if (functionFlags & 1 /* FunctionFlags.Generator */) {
return false;
}
// falls through
- case 214 /* SyntaxKind.ArrowFunction */:
+ case 216 /* SyntaxKind.ArrowFunction */:
visitedNestedConvertibleFunctions.set(getKeyFromNode(arg), true);
// falls through
case 104 /* SyntaxKind.NullKeyword */:
return true;
case 79 /* SyntaxKind.Identifier */:
- case 206 /* SyntaxKind.PropertyAccessExpression */: {
+ case 208 /* SyntaxKind.PropertyAccessExpression */: {
var symbol = checker.getSymbolAtLocation(arg);
if (!symbol) {
return false;
@@ -434377,24 +435682,24 @@ var ts;
}
function canBeConvertedToClass(node, checker) {
var _a, _b, _c, _d;
- if (node.kind === 213 /* SyntaxKind.FunctionExpression */) {
+ if (node.kind === 215 /* SyntaxKind.FunctionExpression */) {
if (ts.isVariableDeclaration(node.parent) && ((_a = node.symbol.members) === null || _a === void 0 ? void 0 : _a.size)) {
return true;
}
var symbol = checker.getSymbolOfExpando(node, /*allowDeclaration*/ false);
return !!(symbol && (((_b = symbol.exports) === null || _b === void 0 ? void 0 : _b.size) || ((_c = symbol.members) === null || _c === void 0 ? void 0 : _c.size)));
}
- if (node.kind === 256 /* SyntaxKind.FunctionDeclaration */) {
+ if (node.kind === 259 /* SyntaxKind.FunctionDeclaration */) {
return !!((_d = node.symbol.members) === null || _d === void 0 ? void 0 : _d.size);
}
return false;
}
function canBeConvertedToAsync(node) {
switch (node.kind) {
- case 256 /* SyntaxKind.FunctionDeclaration */:
- case 169 /* SyntaxKind.MethodDeclaration */:
- case 213 /* SyntaxKind.FunctionExpression */:
- case 214 /* SyntaxKind.ArrowFunction */:
+ case 259 /* SyntaxKind.FunctionDeclaration */:
+ case 171 /* SyntaxKind.MethodDeclaration */:
+ case 215 /* SyntaxKind.FunctionExpression */:
+ case 216 /* SyntaxKind.ArrowFunction */:
return true;
default:
return false;
@@ -434416,7 +435721,7 @@ var ts;
}
var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol);
if (flags & 32 /* SymbolFlags.Class */) {
- return ts.getDeclarationOfKind(symbol, 226 /* SyntaxKind.ClassExpression */) ?
+ return ts.getDeclarationOfKind(symbol, 228 /* SyntaxKind.ClassExpression */) ?
"local class" /* ScriptElementKind.localClassElement */ : "class" /* ScriptElementKind.classElement */;
}
if (flags & 384 /* SymbolFlags.Enum */)
@@ -434479,6 +435784,8 @@ var ts;
return "method" /* ScriptElementKind.memberFunctionElement */;
if (flags & 16384 /* SymbolFlags.Constructor */)
return "constructor" /* ScriptElementKind.constructorImplementationElement */;
+ if (flags & 131072 /* SymbolFlags.Signature */)
+ return "index" /* ScriptElementKind.indexSignatureElement */;
if (flags & 4 /* SymbolFlags.Property */) {
if (flags & 33554432 /* SymbolFlags.Transient */ && symbol.checkFlags & 6 /* CheckFlags.Synthetic */) {
// If union property is result of union of non method (property/accessors/variables), it is labeled as property
@@ -434562,12 +435869,15 @@ var ts;
var declaration = ts.find(symbol.declarations, function (declaration) { return declaration.name === location; });
if (declaration) {
switch (declaration.kind) {
- case 172 /* SyntaxKind.GetAccessor */:
+ case 174 /* SyntaxKind.GetAccessor */:
symbolKind = "getter" /* ScriptElementKind.memberGetAccessorElement */;
break;
- case 173 /* SyntaxKind.SetAccessor */:
+ case 175 /* SyntaxKind.SetAccessor */:
symbolKind = "setter" /* ScriptElementKind.memberSetAccessorElement */;
break;
+ case 169 /* SyntaxKind.PropertyDeclaration */:
+ symbolKind = "accessor" /* ScriptElementKind.memberAccessorVariableElement */;
+ break;
default:
ts.Debug.assertNever(declaration);
}
@@ -434578,7 +435888,7 @@ var ts;
}
var signature = void 0;
type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location);
- if (location.parent && location.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) {
+ if (location.parent && location.parent.kind === 208 /* SyntaxKind.PropertyAccessExpression */) {
var right = location.parent.name;
// Either the location is on the right of a property access, or on the left and the right is missing
if (right === location || (right && right.getFullWidth() === 0)) {
@@ -434598,7 +435908,7 @@ var ts;
}
if (callExpressionLike) {
signature = typeChecker.getResolvedSignature(callExpressionLike); // TODO: GH#18217
- var useConstructSignatures = callExpressionLike.kind === 209 /* SyntaxKind.NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 106 /* SyntaxKind.SuperKeyword */);
+ var useConstructSignatures = callExpressionLike.kind === 211 /* SyntaxKind.NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 106 /* SyntaxKind.SuperKeyword */);
var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures();
if (signature && !ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) {
// Get the first signature if there is one -- allSignatures may contain
@@ -434662,29 +435972,29 @@ var ts;
}
}
else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304 /* SymbolFlags.Accessor */)) || // name of function declaration
- (location.kind === 134 /* SyntaxKind.ConstructorKeyword */ && location.parent.kind === 171 /* SyntaxKind.Constructor */)) { // At constructor keyword of constructor declaration
+ (location.kind === 135 /* SyntaxKind.ConstructorKeyword */ && location.parent.kind === 173 /* SyntaxKind.Constructor */)) { // At constructor keyword of constructor declaration
// get the signature from the declaration and write it
var functionDeclaration_1 = location.parent;
// Use function declaration to write the signatures only if the symbol corresponding to this declaration
var locationIsSymbolDeclaration = symbol.declarations && ts.find(symbol.declarations, function (declaration) {
- return declaration === (location.kind === 134 /* SyntaxKind.ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1);
+ return declaration === (location.kind === 135 /* SyntaxKind.ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1);
});
if (locationIsSymbolDeclaration) {
- var allSignatures = functionDeclaration_1.kind === 171 /* SyntaxKind.Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures();
+ var allSignatures = functionDeclaration_1.kind === 173 /* SyntaxKind.Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures();
if (!typeChecker.isImplementationOfOverload(functionDeclaration_1)) {
signature = typeChecker.getSignatureFromDeclaration(functionDeclaration_1); // TODO: GH#18217
}
else {
signature = allSignatures[0];
}
- if (functionDeclaration_1.kind === 171 /* SyntaxKind.Constructor */) {
+ if (functionDeclaration_1.kind === 173 /* SyntaxKind.Constructor */) {
// show (constructor) Type(...) signature
symbolKind = "constructor" /* ScriptElementKind.constructorImplementationElement */;
addPrefixForAnyFunctionOrVar(type.symbol, symbolKind);
}
else {
// (function/method) symbol(..signature)
- addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 174 /* SyntaxKind.CallSignature */ &&
+ addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 176 /* SyntaxKind.CallSignature */ &&
!(type.symbol.flags & 2048 /* SymbolFlags.TypeLiteral */ || type.symbol.flags & 4096 /* SymbolFlags.ObjectLiteral */) ? type.symbol : symbol, symbolKind);
}
if (signature) {
@@ -434697,7 +436007,7 @@ var ts;
}
if (symbolFlags & 32 /* SymbolFlags.Class */ && !hasAddedSymbolInfo && !isThisExpression) {
addAliasPrefixIfNecessary();
- if (ts.getDeclarationOfKind(symbol, 226 /* SyntaxKind.ClassExpression */)) {
+ if (ts.getDeclarationOfKind(symbol, 228 /* SyntaxKind.ClassExpression */)) {
// Special case for class expressions because we would like to indicate that
// the class name is local to the class body (similar to function expression)
// (local class) class
@@ -434720,7 +436030,7 @@ var ts;
}
if ((symbolFlags & 524288 /* SymbolFlags.TypeAlias */) && (semanticMeaning & 2 /* SemanticMeaning.Type */)) {
prefixNextMeaning();
- displayParts.push(ts.keywordPart(152 /* SyntaxKind.TypeKeyword */));
+ displayParts.push(ts.keywordPart(154 /* SyntaxKind.TypeKeyword */));
displayParts.push(ts.spacePart());
addFullSymbolName(symbol);
writeTypeParametersOfSymbol(symbol, sourceFile);
@@ -434741,9 +436051,9 @@ var ts;
}
if (symbolFlags & 1536 /* SymbolFlags.Module */ && !isThisExpression) {
prefixNextMeaning();
- var declaration = ts.getDeclarationOfKind(symbol, 261 /* SyntaxKind.ModuleDeclaration */);
+ var declaration = ts.getDeclarationOfKind(symbol, 264 /* SyntaxKind.ModuleDeclaration */);
var isNamespace = declaration && declaration.name && declaration.name.kind === 79 /* SyntaxKind.Identifier */;
- displayParts.push(ts.keywordPart(isNamespace ? 142 /* SyntaxKind.NamespaceKeyword */ : 141 /* SyntaxKind.ModuleKeyword */));
+ displayParts.push(ts.keywordPart(isNamespace ? 143 /* SyntaxKind.NamespaceKeyword */ : 142 /* SyntaxKind.ModuleKeyword */));
displayParts.push(ts.spacePart());
addFullSymbolName(symbol);
}
@@ -434762,7 +436072,7 @@ var ts;
}
else {
// Method/function type parameter
- var decl = ts.getDeclarationOfKind(symbol, 163 /* SyntaxKind.TypeParameter */);
+ var decl = ts.getDeclarationOfKind(symbol, 165 /* SyntaxKind.TypeParameter */);
if (decl === undefined)
return ts.Debug.fail();
var declaration = decl.parent;
@@ -434770,21 +436080,21 @@ var ts;
if (ts.isFunctionLikeKind(declaration.kind)) {
addInPrefix();
var signature = typeChecker.getSignatureFromDeclaration(declaration); // TODO: GH#18217
- if (declaration.kind === 175 /* SyntaxKind.ConstructSignature */) {
+ if (declaration.kind === 177 /* SyntaxKind.ConstructSignature */) {
displayParts.push(ts.keywordPart(103 /* SyntaxKind.NewKeyword */));
displayParts.push(ts.spacePart());
}
- else if (declaration.kind !== 174 /* SyntaxKind.CallSignature */ && declaration.name) {
+ else if (declaration.kind !== 176 /* SyntaxKind.CallSignature */ && declaration.name) {
addFullSymbolName(declaration.symbol);
}
ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* TypeFormatFlags.WriteTypeArgumentsOfSignature */));
}
- else if (declaration.kind === 259 /* SyntaxKind.TypeAliasDeclaration */) {
+ else if (declaration.kind === 262 /* SyntaxKind.TypeAliasDeclaration */) {
// Type alias type parameter
// For example
// type list = T[]; // Both T will go through same code path
addInPrefix();
- displayParts.push(ts.keywordPart(152 /* SyntaxKind.TypeKeyword */));
+ displayParts.push(ts.keywordPart(154 /* SyntaxKind.TypeKeyword */));
displayParts.push(ts.spacePart());
addFullSymbolName(declaration.symbol);
writeTypeParametersOfSymbol(declaration.symbol, sourceFile);
@@ -434796,7 +436106,7 @@ var ts;
symbolKind = "enum member" /* ScriptElementKind.enumMemberElement */;
addPrefixForAnyFunctionOrVar(symbol, "enum member");
var declaration = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a[0];
- if ((declaration === null || declaration === void 0 ? void 0 : declaration.kind) === 299 /* SyntaxKind.EnumMember */) {
+ if ((declaration === null || declaration === void 0 ? void 0 : declaration.kind) === 302 /* SyntaxKind.EnumMember */) {
var constantValue = typeChecker.getConstantValue(declaration);
if (constantValue !== undefined) {
displayParts.push(ts.spacePart());
@@ -434832,17 +436142,17 @@ var ts;
}
if (symbol.declarations) {
switch (symbol.declarations[0].kind) {
- case 264 /* SyntaxKind.NamespaceExportDeclaration */:
+ case 267 /* SyntaxKind.NamespaceExportDeclaration */:
displayParts.push(ts.keywordPart(93 /* SyntaxKind.ExportKeyword */));
displayParts.push(ts.spacePart());
- displayParts.push(ts.keywordPart(142 /* SyntaxKind.NamespaceKeyword */));
+ displayParts.push(ts.keywordPart(143 /* SyntaxKind.NamespaceKeyword */));
break;
- case 271 /* SyntaxKind.ExportAssignment */:
+ case 274 /* SyntaxKind.ExportAssignment */:
displayParts.push(ts.keywordPart(93 /* SyntaxKind.ExportKeyword */));
displayParts.push(ts.spacePart());
displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 63 /* SyntaxKind.EqualsToken */ : 88 /* SyntaxKind.DefaultKeyword */));
break;
- case 275 /* SyntaxKind.ExportSpecifier */:
+ case 278 /* SyntaxKind.ExportSpecifier */:
displayParts.push(ts.keywordPart(93 /* SyntaxKind.ExportKeyword */));
break;
default:
@@ -434852,13 +436162,13 @@ var ts;
displayParts.push(ts.spacePart());
addFullSymbolName(symbol);
ts.forEach(symbol.declarations, function (declaration) {
- if (declaration.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) {
+ if (declaration.kind === 268 /* SyntaxKind.ImportEqualsDeclaration */) {
var importEqualsDeclaration = declaration;
if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) {
displayParts.push(ts.spacePart());
displayParts.push(ts.operatorPart(63 /* SyntaxKind.EqualsToken */));
displayParts.push(ts.spacePart());
- displayParts.push(ts.keywordPart(146 /* SyntaxKind.RequireKeyword */));
+ displayParts.push(ts.keywordPart(147 /* SyntaxKind.RequireKeyword */));
displayParts.push(ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */));
displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), ts.SymbolDisplayPartKind.stringLiteral));
displayParts.push(ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */));
@@ -434888,16 +436198,18 @@ var ts;
}
// For properties, variables and local vars: show the type
if (symbolKind === "property" /* ScriptElementKind.memberVariableElement */ ||
+ symbolKind === "accessor" /* ScriptElementKind.memberAccessorVariableElement */ ||
symbolKind === "getter" /* ScriptElementKind.memberGetAccessorElement */ ||
symbolKind === "setter" /* ScriptElementKind.memberSetAccessorElement */ ||
symbolKind === "JSX attribute" /* ScriptElementKind.jsxAttribute */ ||
symbolFlags & 3 /* SymbolFlags.Variable */ ||
symbolKind === "local var" /* ScriptElementKind.localVariableElement */ ||
+ symbolKind === "index" /* ScriptElementKind.indexSignatureElement */ ||
isThisExpression) {
displayParts.push(ts.punctuationPart(58 /* SyntaxKind.ColonToken */));
displayParts.push(ts.spacePart());
// If the type is type parameter, format it specially
- if (type.symbol && type.symbol.flags & 262144 /* SymbolFlags.TypeParameter */) {
+ if (type.symbol && type.symbol.flags & 262144 /* SymbolFlags.TypeParameter */ && symbolKind !== "index" /* ScriptElementKind.indexSignatureElement */) {
var typeParameterParts = ts.mapToDisplayParts(function (writer) {
var param = typeChecker.typeParameterToDeclaration(type, enclosingDeclaration, symbolDisplayNodeBuilderFlags);
getPrinter().writeNode(4 /* EmitHint.Unspecified */, param, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosingDeclaration)), writer);
@@ -434941,10 +436253,10 @@ var ts;
// For some special property access expressions like `exports.foo = foo` or `module.exports.foo = foo`
// there documentation comments might be attached to the right hand side symbol of their declarations.
// The pattern of such special property access is that the parent symbol is the symbol of the file.
- if (symbol.parent && symbol.declarations && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 305 /* SyntaxKind.SourceFile */; })) {
+ if (symbol.parent && symbol.declarations && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 308 /* SyntaxKind.SourceFile */; })) {
for (var _i = 0, _b = symbol.declarations; _i < _b.length; _i++) {
var declaration = _b[_i];
- if (!declaration.parent || declaration.parent.kind !== 221 /* SyntaxKind.BinaryExpression */) {
+ if (!declaration.parent || declaration.parent.kind !== 223 /* SyntaxKind.BinaryExpression */) {
continue;
}
var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right);
@@ -435005,10 +436317,34 @@ var ts;
displayParts.push(ts.spacePart());
}
function addFullSymbolName(symbolToDisplay, enclosingDeclaration) {
+ var indexInfos;
if (alias && symbolToDisplay === symbol) {
symbolToDisplay = alias;
}
- var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbolToDisplay, enclosingDeclaration || sourceFile, /*meaning*/ undefined, 1 /* SymbolFormatFlags.WriteTypeParametersOrArguments */ | 2 /* SymbolFormatFlags.UseOnlyExternalAliasing */ | 4 /* SymbolFormatFlags.AllowAnyNodeKind */);
+ if (symbolKind === "index" /* ScriptElementKind.indexSignatureElement */) {
+ indexInfos = typeChecker.getIndexInfosOfIndexSymbol(symbolToDisplay);
+ }
+ var fullSymbolDisplayParts = [];
+ if (symbolToDisplay.flags & 131072 /* SymbolFlags.Signature */ && indexInfos) {
+ if (symbolToDisplay.parent) {
+ fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbolToDisplay.parent);
+ }
+ fullSymbolDisplayParts.push(ts.punctuationPart(22 /* SyntaxKind.OpenBracketToken */));
+ //Needed to handle more than one type of index
+ indexInfos.forEach(function (info, i) {
+ //Needed to handle template literals
+ fullSymbolDisplayParts.push.apply(fullSymbolDisplayParts, ts.typeToDisplayParts(typeChecker, info.keyType));
+ if (i !== indexInfos.length - 1) {
+ fullSymbolDisplayParts.push(ts.spacePart());
+ fullSymbolDisplayParts.push(ts.punctuationPart(51 /* SyntaxKind.BarToken */));
+ fullSymbolDisplayParts.push(ts.spacePart());
+ }
+ });
+ fullSymbolDisplayParts.push(ts.punctuationPart(23 /* SyntaxKind.CloseBracketToken */));
+ }
+ else {
+ fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbolToDisplay, enclosingDeclaration || sourceFile, /*meaning*/ undefined, 1 /* SymbolFormatFlags.WriteTypeParametersOrArguments */ | 2 /* SymbolFormatFlags.UseOnlyExternalAliasing */ | 4 /* SymbolFormatFlags.AllowAnyNodeKind */);
+ }
ts.addRange(displayParts, fullSymbolDisplayParts);
if (symbol.flags & 16777216 /* SymbolFlags.Optional */) {
displayParts.push(ts.punctuationPart(57 /* SyntaxKind.QuestionToken */));
@@ -435056,7 +436392,7 @@ var ts;
tags = signature.getJsDocTags();
if (allSignatures.length > 1 && documentation.length === 0 && tags.length === 0) {
documentation = allSignatures[0].getDocumentationComment(typeChecker);
- tags = allSignatures[0].getJsDocTags();
+ tags = allSignatures[0].getJsDocTags().filter(function (tag) { return tag.name !== "deprecated"; }); // should only include @deprecated JSDoc tag on the first overload (#49368)
}
}
function writeTypeParametersOfSymbol(symbol, enclosingDeclaration) {
@@ -435074,16 +436410,16 @@ var ts;
}
return ts.forEach(symbol.declarations, function (declaration) {
// Function expressions are local
- if (declaration.kind === 213 /* SyntaxKind.FunctionExpression */) {
+ if (declaration.kind === 215 /* SyntaxKind.FunctionExpression */) {
return true;
}
- if (declaration.kind !== 254 /* SyntaxKind.VariableDeclaration */ && declaration.kind !== 256 /* SyntaxKind.FunctionDeclaration */) {
+ if (declaration.kind !== 257 /* SyntaxKind.VariableDeclaration */ && declaration.kind !== 259 /* SyntaxKind.FunctionDeclaration */) {
return false;
}
// If the parent is not sourceFile or module block it is local variable
for (var parent = declaration.parent; !ts.isFunctionBlock(parent); parent = parent.parent) {
// Reached source file or module block
- if (parent.kind === 305 /* SyntaxKind.SourceFile */ || parent.kind === 262 /* SyntaxKind.ModuleBlock */) {
+ if (parent.kind === 308 /* SyntaxKind.SourceFile */ || parent.kind === 265 /* SyntaxKind.ModuleBlock */) {
return false;
}
}
@@ -435388,10 +436724,10 @@ var ts;
function shouldRescanJsxIdentifier(node) {
if (node.parent) {
switch (node.parent.kind) {
- case 285 /* SyntaxKind.JsxAttribute */:
- case 280 /* SyntaxKind.JsxOpeningElement */:
- case 281 /* SyntaxKind.JsxClosingElement */:
- case 279 /* SyntaxKind.JsxSelfClosingElement */:
+ case 288 /* SyntaxKind.JsxAttribute */:
+ case 283 /* SyntaxKind.JsxOpeningElement */:
+ case 284 /* SyntaxKind.JsxClosingElement */:
+ case 282 /* SyntaxKind.JsxSelfClosingElement */:
// May parse an identifier like `module-layout`; that will be scanned as a keyword at first, but we should parse the whole thing to get an identifier.
return ts.isKeyword(node.kind) || node.kind === 79 /* SyntaxKind.Identifier */;
}
@@ -435399,7 +436735,7 @@ var ts;
return false;
}
function shouldRescanJsxText(node) {
- return ts.isJsxText(node);
+ return ts.isJsxText(node) || ts.isJsxElement(node) && (lastTokenInfo === null || lastTokenInfo === void 0 ? void 0 : lastTokenInfo.token.kind) === 11 /* SyntaxKind.JsxText */;
}
function shouldRescanSlashToken(container) {
return container.kind === 13 /* SyntaxKind.RegularExpressionLiteral */;
@@ -435584,7 +436920,7 @@ var ts;
(function (formatting) {
function getAllRules() {
var allTokens = [];
- for (var token = 0 /* SyntaxKind.FirstToken */; token <= 160 /* SyntaxKind.LastToken */; token++) {
+ for (var token = 0 /* SyntaxKind.FirstToken */; token <= 162 /* SyntaxKind.LastToken */; token++) {
if (token !== 1 /* SyntaxKind.EndOfFileToken */) {
allTokens.push(token);
}
@@ -435599,9 +436935,9 @@ var ts;
var anyToken = { tokens: allTokens, isSpecific: false };
var anyTokenIncludingMultilineComments = tokenRangeFrom(__spreadArray(__spreadArray([], allTokens, true), [3 /* SyntaxKind.MultiLineCommentTrivia */], false));
var anyTokenIncludingEOF = tokenRangeFrom(__spreadArray(__spreadArray([], allTokens, true), [1 /* SyntaxKind.EndOfFileToken */], false));
- var keywords = tokenRangeFromRange(81 /* SyntaxKind.FirstKeyword */, 160 /* SyntaxKind.LastKeyword */);
+ var keywords = tokenRangeFromRange(81 /* SyntaxKind.FirstKeyword */, 162 /* SyntaxKind.LastKeyword */);
var binaryOperators = tokenRangeFromRange(29 /* SyntaxKind.FirstBinaryOperator */, 78 /* SyntaxKind.LastBinaryOperator */);
- var binaryKeywordOperators = [101 /* SyntaxKind.InKeyword */, 102 /* SyntaxKind.InstanceOfKeyword */, 160 /* SyntaxKind.OfKeyword */, 127 /* SyntaxKind.AsKeyword */, 139 /* SyntaxKind.IsKeyword */];
+ var binaryKeywordOperators = [101 /* SyntaxKind.InKeyword */, 102 /* SyntaxKind.InstanceOfKeyword */, 162 /* SyntaxKind.OfKeyword */, 128 /* SyntaxKind.AsKeyword */, 140 /* SyntaxKind.IsKeyword */];
var unaryPrefixOperators = [45 /* SyntaxKind.PlusPlusToken */, 46 /* SyntaxKind.MinusMinusToken */, 54 /* SyntaxKind.TildeToken */, 53 /* SyntaxKind.ExclamationToken */];
var unaryPrefixExpressions = [
8 /* SyntaxKind.NumericLiteral */, 9 /* SyntaxKind.BigIntLiteral */, 79 /* SyntaxKind.Identifier */, 20 /* SyntaxKind.OpenParenToken */,
@@ -435632,7 +436968,7 @@ var ts;
rule("SpaceAfterQuestionMarkInConditionalOperator", 57 /* SyntaxKind.QuestionToken */, anyToken, [isNonJsxSameLineTokenContext, isConditionalOperatorContext], 4 /* RuleAction.InsertSpace */),
// in other cases there should be no space between '?' and next token
rule("NoSpaceAfterQuestionMark", 57 /* SyntaxKind.QuestionToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */),
- rule("NoSpaceBeforeDot", anyToken, [24 /* SyntaxKind.DotToken */, 28 /* SyntaxKind.QuestionDotToken */], [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */),
+ rule("NoSpaceBeforeDot", anyToken, [24 /* SyntaxKind.DotToken */, 28 /* SyntaxKind.QuestionDotToken */], [isNonJsxSameLineTokenContext, isNotPropertyAccessOnIntegerLiteral], 16 /* RuleAction.DeleteSpace */),
rule("NoSpaceAfterDot", [24 /* SyntaxKind.DotToken */, 28 /* SyntaxKind.QuestionDotToken */], anyToken, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */),
rule("NoSpaceBetweenImportParenInImportType", 100 /* SyntaxKind.ImportKeyword */, 20 /* SyntaxKind.OpenParenToken */, [isNonJsxSameLineTokenContext, isImportTypeContext], 16 /* RuleAction.DeleteSpace */),
// Special handling of unary operators.
@@ -435675,11 +437011,11 @@ var ts;
// Though, we do extra check on the context to make sure we are dealing with get/set node. Example:
// get x() {}
// set x(val) {}
- rule("SpaceAfterGetSetInMember", [136 /* SyntaxKind.GetKeyword */, 149 /* SyntaxKind.SetKeyword */], 79 /* SyntaxKind.Identifier */, [isFunctionDeclContext], 4 /* RuleAction.InsertSpace */),
+ rule("SpaceAfterGetSetInMember", [137 /* SyntaxKind.GetKeyword */, 151 /* SyntaxKind.SetKeyword */], 79 /* SyntaxKind.Identifier */, [isFunctionDeclContext], 4 /* RuleAction.InsertSpace */),
rule("NoSpaceBetweenYieldKeywordAndStar", 125 /* SyntaxKind.YieldKeyword */, 41 /* SyntaxKind.AsteriskToken */, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 16 /* RuleAction.DeleteSpace */),
rule("SpaceBetweenYieldOrYieldStarAndOperand", [125 /* SyntaxKind.YieldKeyword */, 41 /* SyntaxKind.AsteriskToken */], anyToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 4 /* RuleAction.InsertSpace */),
rule("NoSpaceBetweenReturnAndSemicolon", 105 /* SyntaxKind.ReturnKeyword */, 26 /* SyntaxKind.SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */),
- rule("SpaceAfterCertainKeywords", [113 /* SyntaxKind.VarKeyword */, 109 /* SyntaxKind.ThrowKeyword */, 103 /* SyntaxKind.NewKeyword */, 89 /* SyntaxKind.DeleteKeyword */, 105 /* SyntaxKind.ReturnKeyword */, 112 /* SyntaxKind.TypeOfKeyword */, 132 /* SyntaxKind.AwaitKeyword */], anyToken, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */),
+ rule("SpaceAfterCertainKeywords", [113 /* SyntaxKind.VarKeyword */, 109 /* SyntaxKind.ThrowKeyword */, 103 /* SyntaxKind.NewKeyword */, 89 /* SyntaxKind.DeleteKeyword */, 105 /* SyntaxKind.ReturnKeyword */, 112 /* SyntaxKind.TypeOfKeyword */, 133 /* SyntaxKind.AwaitKeyword */], anyToken, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */),
rule("SpaceAfterLetConstInVariableDeclaration", [119 /* SyntaxKind.LetKeyword */, 85 /* SyntaxKind.ConstKeyword */], anyToken, [isNonJsxSameLineTokenContext, isStartOfVariableDeclarationList], 4 /* RuleAction.InsertSpace */),
rule("NoSpaceBeforeOpenParenInFuncCall", anyToken, 20 /* SyntaxKind.OpenParenToken */, [isNonJsxSameLineTokenContext, isFunctionCallOrNewContext, isPreviousTokenNotComma], 16 /* RuleAction.DeleteSpace */),
// Special case for binary operators (that are keywords). For these we have to add a space and shouldn't follow any user options.
@@ -435687,8 +437023,8 @@ var ts;
rule("SpaceAfterBinaryKeywordOperator", binaryKeywordOperators, anyToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */),
rule("SpaceAfterVoidOperator", 114 /* SyntaxKind.VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 4 /* RuleAction.InsertSpace */),
// Async-await
- rule("SpaceBetweenAsyncAndOpenParen", 131 /* SyntaxKind.AsyncKeyword */, 20 /* SyntaxKind.OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */),
- rule("SpaceBetweenAsyncAndFunctionKeyword", 131 /* SyntaxKind.AsyncKeyword */, [98 /* SyntaxKind.FunctionKeyword */, 79 /* SyntaxKind.Identifier */], [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */),
+ rule("SpaceBetweenAsyncAndOpenParen", 132 /* SyntaxKind.AsyncKeyword */, 20 /* SyntaxKind.OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */),
+ rule("SpaceBetweenAsyncAndFunctionKeyword", 132 /* SyntaxKind.AsyncKeyword */, [98 /* SyntaxKind.FunctionKeyword */, 79 /* SyntaxKind.Identifier */], [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */),
// Template string
rule("NoSpaceBetweenTagAndTemplateString", [79 /* SyntaxKind.Identifier */, 21 /* SyntaxKind.CloseParenToken */], [14 /* SyntaxKind.NoSubstitutionTemplateLiteral */, 15 /* SyntaxKind.TemplateHead */], [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */),
// JSX opening elements
@@ -435699,34 +437035,35 @@ var ts;
rule("NoSpaceAfterEqualInJsxAttribute", 63 /* SyntaxKind.EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */),
// TypeScript-specific rules
// Use of module as a function call. e.g.: import m2 = module("m2");
- rule("NoSpaceAfterModuleImport", [141 /* SyntaxKind.ModuleKeyword */, 146 /* SyntaxKind.RequireKeyword */], 20 /* SyntaxKind.OpenParenToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */),
+ rule("NoSpaceAfterModuleImport", [142 /* SyntaxKind.ModuleKeyword */, 147 /* SyntaxKind.RequireKeyword */], 20 /* SyntaxKind.OpenParenToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */),
// Add a space around certain TypeScript keywords
rule("SpaceAfterCertainTypeScriptKeywords", [
126 /* SyntaxKind.AbstractKeyword */,
+ 127 /* SyntaxKind.AccessorKeyword */,
84 /* SyntaxKind.ClassKeyword */,
- 135 /* SyntaxKind.DeclareKeyword */,
+ 136 /* SyntaxKind.DeclareKeyword */,
88 /* SyntaxKind.DefaultKeyword */,
92 /* SyntaxKind.EnumKeyword */,
93 /* SyntaxKind.ExportKeyword */,
94 /* SyntaxKind.ExtendsKeyword */,
- 136 /* SyntaxKind.GetKeyword */,
+ 137 /* SyntaxKind.GetKeyword */,
117 /* SyntaxKind.ImplementsKeyword */,
100 /* SyntaxKind.ImportKeyword */,
118 /* SyntaxKind.InterfaceKeyword */,
- 141 /* SyntaxKind.ModuleKeyword */,
- 142 /* SyntaxKind.NamespaceKeyword */,
+ 142 /* SyntaxKind.ModuleKeyword */,
+ 143 /* SyntaxKind.NamespaceKeyword */,
121 /* SyntaxKind.PrivateKeyword */,
123 /* SyntaxKind.PublicKeyword */,
122 /* SyntaxKind.ProtectedKeyword */,
- 145 /* SyntaxKind.ReadonlyKeyword */,
- 149 /* SyntaxKind.SetKeyword */,
+ 146 /* SyntaxKind.ReadonlyKeyword */,
+ 151 /* SyntaxKind.SetKeyword */,
124 /* SyntaxKind.StaticKeyword */,
- 152 /* SyntaxKind.TypeKeyword */,
- 156 /* SyntaxKind.FromKeyword */,
- 140 /* SyntaxKind.KeyOfKeyword */,
- 137 /* SyntaxKind.InferKeyword */,
+ 154 /* SyntaxKind.TypeKeyword */,
+ 158 /* SyntaxKind.FromKeyword */,
+ 141 /* SyntaxKind.KeyOfKeyword */,
+ 138 /* SyntaxKind.InferKeyword */,
], anyToken, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */),
- rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [94 /* SyntaxKind.ExtendsKeyword */, 117 /* SyntaxKind.ImplementsKeyword */, 156 /* SyntaxKind.FromKeyword */], [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */),
+ rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [94 /* SyntaxKind.ExtendsKeyword */, 117 /* SyntaxKind.ImplementsKeyword */, 158 /* SyntaxKind.FromKeyword */], [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */),
// Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" {
rule("SpaceAfterModuleName", 10 /* SyntaxKind.StringLiteral */, 18 /* SyntaxKind.OpenBraceToken */, [isModuleDeclContext], 4 /* RuleAction.InsertSpace */),
// Lambda expressions
@@ -435757,8 +437094,8 @@ var ts;
123 /* SyntaxKind.PublicKeyword */,
121 /* SyntaxKind.PrivateKeyword */,
122 /* SyntaxKind.ProtectedKeyword */,
- 136 /* SyntaxKind.GetKeyword */,
- 149 /* SyntaxKind.SetKeyword */,
+ 137 /* SyntaxKind.GetKeyword */,
+ 151 /* SyntaxKind.SetKeyword */,
22 /* SyntaxKind.OpenBracketToken */,
41 /* SyntaxKind.AsteriskToken */,
], [isEndOfDecoratorContextOnSameLine], 4 /* RuleAction.InsertSpace */),
@@ -435769,8 +437106,8 @@ var ts;
// These rules are applied after high priority
var userConfigurableRules = [
// Treat constructor as an identifier in a function declaration, and remove spaces between constructor and following left parentheses
- rule("SpaceAfterConstructor", 134 /* SyntaxKind.ConstructorKeyword */, 20 /* SyntaxKind.OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */),
- rule("NoSpaceAfterConstructor", 134 /* SyntaxKind.ConstructorKeyword */, 20 /* SyntaxKind.OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */),
+ rule("SpaceAfterConstructor", 135 /* SyntaxKind.ConstructorKeyword */, 20 /* SyntaxKind.OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */),
+ rule("NoSpaceAfterConstructor", 135 /* SyntaxKind.ConstructorKeyword */, 20 /* SyntaxKind.OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */),
rule("SpaceAfterComma", 27 /* SyntaxKind.CommaToken */, anyToken, [isOptionEnabled("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNextTokenNotCloseBracket, isNextTokenNotCloseParen], 4 /* RuleAction.InsertSpace */),
rule("NoSpaceAfterComma", 27 /* SyntaxKind.CommaToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext], 16 /* RuleAction.DeleteSpace */),
// Insert space after function keyword for anonymous functions
@@ -435844,11 +437181,11 @@ var ts;
rule("SpaceBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* RuleAction.InsertSpace */, 1 /* RuleFlags.CanDeleteNewLines */),
rule("NoSpaceBeforeComma", anyToken, 27 /* SyntaxKind.CommaToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */),
// No space before and after indexer `x[]`
- rule("NoSpaceBeforeOpenBracket", anyTokenExcept(131 /* SyntaxKind.AsyncKeyword */, 82 /* SyntaxKind.CaseKeyword */), 22 /* SyntaxKind.OpenBracketToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */),
+ rule("NoSpaceBeforeOpenBracket", anyTokenExcept(132 /* SyntaxKind.AsyncKeyword */, 82 /* SyntaxKind.CaseKeyword */), 22 /* SyntaxKind.OpenBracketToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */),
rule("NoSpaceAfterCloseBracket", 23 /* SyntaxKind.CloseBracketToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBeforeBlockInFunctionDeclarationContext], 16 /* RuleAction.DeleteSpace */),
rule("SpaceAfterSemicolon", 26 /* SyntaxKind.SemicolonToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */),
// Remove extra space between for and await
- rule("SpaceBetweenForAndAwaitKeyword", 97 /* SyntaxKind.ForKeyword */, 132 /* SyntaxKind.AwaitKeyword */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */),
+ rule("SpaceBetweenForAndAwaitKeyword", 97 /* SyntaxKind.ForKeyword */, 133 /* SyntaxKind.AwaitKeyword */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */),
// Add a space between statements. All keywords except (do,else,case) has open/close parens after them.
// So, we have a rule to add a space for [),Any], [do,Any], [else,Any], and [case,Any]
rule("SpaceBetweenStatements", [21 /* SyntaxKind.CloseParenToken */, 90 /* SyntaxKind.DoKeyword */, 91 /* SyntaxKind.ElseKeyword */, 82 /* SyntaxKind.CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 4 /* RuleAction.InsertSpace */),
@@ -435897,69 +437234,70 @@ var ts;
return function (context) { return context.options && context.options[optionName] === optionValue; };
}
function isOptionEnabled(optionName) {
- return function (context) { return context.options && context.options.hasOwnProperty(optionName) && !!context.options[optionName]; };
+ return function (context) { return context.options && ts.hasProperty(context.options, optionName) && !!context.options[optionName]; };
}
function isOptionDisabled(optionName) {
- return function (context) { return context.options && context.options.hasOwnProperty(optionName) && !context.options[optionName]; };
+ return function (context) { return context.options && ts.hasProperty(context.options, optionName) && !context.options[optionName]; };
}
function isOptionDisabledOrUndefined(optionName) {
- return function (context) { return !context.options || !context.options.hasOwnProperty(optionName) || !context.options[optionName]; };
+ return function (context) { return !context.options || !ts.hasProperty(context.options, optionName) || !context.options[optionName]; };
}
function isOptionDisabledOrUndefinedOrTokensOnSameLine(optionName) {
- return function (context) { return !context.options || !context.options.hasOwnProperty(optionName) || !context.options[optionName] || context.TokensAreOnSameLine(); };
+ return function (context) { return !context.options || !ts.hasProperty(context.options, optionName) || !context.options[optionName] || context.TokensAreOnSameLine(); };
}
function isOptionEnabledOrUndefined(optionName) {
- return function (context) { return !context.options || !context.options.hasOwnProperty(optionName) || !!context.options[optionName]; };
+ return function (context) { return !context.options || !ts.hasProperty(context.options, optionName) || !!context.options[optionName]; };
}
function isForContext(context) {
- return context.contextNode.kind === 242 /* SyntaxKind.ForStatement */;
+ return context.contextNode.kind === 245 /* SyntaxKind.ForStatement */;
}
function isNotForContext(context) {
return !isForContext(context);
}
function isBinaryOpContext(context) {
switch (context.contextNode.kind) {
- case 221 /* SyntaxKind.BinaryExpression */:
+ case 223 /* SyntaxKind.BinaryExpression */:
return context.contextNode.operatorToken.kind !== 27 /* SyntaxKind.CommaToken */;
- case 222 /* SyntaxKind.ConditionalExpression */:
- case 189 /* SyntaxKind.ConditionalType */:
- case 229 /* SyntaxKind.AsExpression */:
- case 275 /* SyntaxKind.ExportSpecifier */:
- case 270 /* SyntaxKind.ImportSpecifier */:
- case 177 /* SyntaxKind.TypePredicate */:
- case 187 /* SyntaxKind.UnionType */:
- case 188 /* SyntaxKind.IntersectionType */:
+ case 224 /* SyntaxKind.ConditionalExpression */:
+ case 191 /* SyntaxKind.ConditionalType */:
+ case 231 /* SyntaxKind.AsExpression */:
+ case 278 /* SyntaxKind.ExportSpecifier */:
+ case 273 /* SyntaxKind.ImportSpecifier */:
+ case 179 /* SyntaxKind.TypePredicate */:
+ case 189 /* SyntaxKind.UnionType */:
+ case 190 /* SyntaxKind.IntersectionType */:
+ case 235 /* SyntaxKind.SatisfiesExpression */:
return true;
// equals in binding elements: function foo([[x, y] = [1, 2]])
- case 203 /* SyntaxKind.BindingElement */:
+ case 205 /* SyntaxKind.BindingElement */:
// equals in type X = ...
// falls through
- case 259 /* SyntaxKind.TypeAliasDeclaration */:
+ case 262 /* SyntaxKind.TypeAliasDeclaration */:
// equal in import a = module('a');
// falls through
- case 265 /* SyntaxKind.ImportEqualsDeclaration */:
+ case 268 /* SyntaxKind.ImportEqualsDeclaration */:
// equal in export = 1
// falls through
- case 271 /* SyntaxKind.ExportAssignment */:
+ case 274 /* SyntaxKind.ExportAssignment */:
// equal in let a = 0
// falls through
- case 254 /* SyntaxKind.VariableDeclaration */:
+ case 257 /* SyntaxKind.VariableDeclaration */:
// equal in p = 0
// falls through
- case 164 /* SyntaxKind.Parameter */:
- case 299 /* SyntaxKind.EnumMember */:
- case 167 /* SyntaxKind.PropertyDeclaration */:
- case 166 /* SyntaxKind.PropertySignature */:
+ case 166 /* SyntaxKind.Parameter */:
+ case 302 /* SyntaxKind.EnumMember */:
+ case 169 /* SyntaxKind.PropertyDeclaration */:
+ case 168 /* SyntaxKind.PropertySignature */:
return context.currentTokenSpan.kind === 63 /* SyntaxKind.EqualsToken */ || context.nextTokenSpan.kind === 63 /* SyntaxKind.EqualsToken */;
// "in" keyword in for (let x in []) { }
- case 243 /* SyntaxKind.ForInStatement */:
+ case 246 /* SyntaxKind.ForInStatement */:
// "in" keyword in [P in keyof T]: T[P]
// falls through
- case 163 /* SyntaxKind.TypeParameter */:
+ case 165 /* SyntaxKind.TypeParameter */:
return context.currentTokenSpan.kind === 101 /* SyntaxKind.InKeyword */ || context.nextTokenSpan.kind === 101 /* SyntaxKind.InKeyword */ || context.currentTokenSpan.kind === 63 /* SyntaxKind.EqualsToken */ || context.nextTokenSpan.kind === 63 /* SyntaxKind.EqualsToken */;
// Technically, "of" is not a binary operator, but format it the same way as "in"
- case 244 /* SyntaxKind.ForOfStatement */:
- return context.currentTokenSpan.kind === 160 /* SyntaxKind.OfKeyword */ || context.nextTokenSpan.kind === 160 /* SyntaxKind.OfKeyword */;
+ case 247 /* SyntaxKind.ForOfStatement */:
+ return context.currentTokenSpan.kind === 162 /* SyntaxKind.OfKeyword */ || context.nextTokenSpan.kind === 162 /* SyntaxKind.OfKeyword */;
}
return false;
}
@@ -435971,22 +437309,22 @@ var ts;
}
function isTypeAnnotationContext(context) {
var contextKind = context.contextNode.kind;
- return contextKind === 167 /* SyntaxKind.PropertyDeclaration */ ||
- contextKind === 166 /* SyntaxKind.PropertySignature */ ||
- contextKind === 164 /* SyntaxKind.Parameter */ ||
- contextKind === 254 /* SyntaxKind.VariableDeclaration */ ||
+ return contextKind === 169 /* SyntaxKind.PropertyDeclaration */ ||
+ contextKind === 168 /* SyntaxKind.PropertySignature */ ||
+ contextKind === 166 /* SyntaxKind.Parameter */ ||
+ contextKind === 257 /* SyntaxKind.VariableDeclaration */ ||
ts.isFunctionLikeKind(contextKind);
}
function isConditionalOperatorContext(context) {
- return context.contextNode.kind === 222 /* SyntaxKind.ConditionalExpression */ ||
- context.contextNode.kind === 189 /* SyntaxKind.ConditionalType */;
+ return context.contextNode.kind === 224 /* SyntaxKind.ConditionalExpression */ ||
+ context.contextNode.kind === 191 /* SyntaxKind.ConditionalType */;
}
function isSameLineTokenOrBeforeBlockContext(context) {
return context.TokensAreOnSameLine() || isBeforeBlockContext(context);
}
function isBraceWrappedContext(context) {
- return context.contextNode.kind === 201 /* SyntaxKind.ObjectBindingPattern */ ||
- context.contextNode.kind === 195 /* SyntaxKind.MappedType */ ||
+ return context.contextNode.kind === 203 /* SyntaxKind.ObjectBindingPattern */ ||
+ context.contextNode.kind === 197 /* SyntaxKind.MappedType */ ||
isSingleLineBlockContext(context);
}
// This check is done before an open brace in a control construct, a function, or a typescript block declaration
@@ -436012,34 +437350,34 @@ var ts;
return true;
}
switch (node.kind) {
- case 235 /* SyntaxKind.Block */:
- case 263 /* SyntaxKind.CaseBlock */:
- case 205 /* SyntaxKind.ObjectLiteralExpression */:
- case 262 /* SyntaxKind.ModuleBlock */:
+ case 238 /* SyntaxKind.Block */:
+ case 266 /* SyntaxKind.CaseBlock */:
+ case 207 /* SyntaxKind.ObjectLiteralExpression */:
+ case 265 /* SyntaxKind.ModuleBlock */:
return true;
}
return false;
}
function isFunctionDeclContext(context) {
switch (context.contextNode.kind) {
- case 256 /* SyntaxKind.FunctionDeclaration */:
- case 169 /* SyntaxKind.MethodDeclaration */:
- case 168 /* SyntaxKind.MethodSignature */:
+ case 259 /* SyntaxKind.FunctionDeclaration */:
+ case 171 /* SyntaxKind.MethodDeclaration */:
+ case 170 /* SyntaxKind.MethodSignature */:
// case SyntaxKind.MemberFunctionDeclaration:
// falls through
- case 172 /* SyntaxKind.GetAccessor */:
- case 173 /* SyntaxKind.SetAccessor */:
+ case 174 /* SyntaxKind.GetAccessor */:
+ case 175 /* SyntaxKind.SetAccessor */:
// case SyntaxKind.MethodSignature:
// falls through
- case 174 /* SyntaxKind.CallSignature */:
- case 213 /* SyntaxKind.FunctionExpression */:
- case 171 /* SyntaxKind.Constructor */:
- case 214 /* SyntaxKind.ArrowFunction */:
+ case 176 /* SyntaxKind.CallSignature */:
+ case 215 /* SyntaxKind.FunctionExpression */:
+ case 173 /* SyntaxKind.Constructor */:
+ case 216 /* SyntaxKind.ArrowFunction */:
// case SyntaxKind.ConstructorDeclaration:
// case SyntaxKind.SimpleArrowFunctionExpression:
// case SyntaxKind.ParenthesizedArrowFunctionExpression:
// falls through
- case 258 /* SyntaxKind.InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one
+ case 261 /* SyntaxKind.InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one
return true;
}
return false;
@@ -436048,40 +437386,40 @@ var ts;
return !isFunctionDeclContext(context);
}
function isFunctionDeclarationOrFunctionExpressionContext(context) {
- return context.contextNode.kind === 256 /* SyntaxKind.FunctionDeclaration */ || context.contextNode.kind === 213 /* SyntaxKind.FunctionExpression */;
+ return context.contextNode.kind === 259 /* SyntaxKind.FunctionDeclaration */ || context.contextNode.kind === 215 /* SyntaxKind.FunctionExpression */;
}
function isTypeScriptDeclWithBlockContext(context) {
return nodeIsTypeScriptDeclWithBlockContext(context.contextNode);
}
function nodeIsTypeScriptDeclWithBlockContext(node) {
switch (node.kind) {
- case 257 /* SyntaxKind.ClassDeclaration */:
- case 226 /* SyntaxKind.ClassExpression */:
- case 258 /* SyntaxKind.InterfaceDeclaration */:
- case 260 /* SyntaxKind.EnumDeclaration */:
- case 182 /* SyntaxKind.TypeLiteral */:
- case 261 /* SyntaxKind.ModuleDeclaration */:
- case 272 /* SyntaxKind.ExportDeclaration */:
- case 273 /* SyntaxKind.NamedExports */:
- case 266 /* SyntaxKind.ImportDeclaration */:
- case 269 /* SyntaxKind.NamedImports */:
+ case 260 /* SyntaxKind.ClassDeclaration */:
+ case 228 /* SyntaxKind.ClassExpression */:
+ case 261 /* SyntaxKind.InterfaceDeclaration */:
+ case 263 /* SyntaxKind.EnumDeclaration */:
+ case 184 /* SyntaxKind.TypeLiteral */:
+ case 264 /* SyntaxKind.ModuleDeclaration */:
+ case 275 /* SyntaxKind.ExportDeclaration */:
+ case 276 /* SyntaxKind.NamedExports */:
+ case 269 /* SyntaxKind.ImportDeclaration */:
+ case 272 /* SyntaxKind.NamedImports */:
return true;
}
return false;
}
function isAfterCodeBlockContext(context) {
switch (context.currentTokenParent.kind) {
- case 257 /* SyntaxKind.ClassDeclaration */:
- case 261 /* SyntaxKind.ModuleDeclaration */:
- case 260 /* SyntaxKind.EnumDeclaration */:
- case 292 /* SyntaxKind.CatchClause */:
- case 262 /* SyntaxKind.ModuleBlock */:
- case 249 /* SyntaxKind.SwitchStatement */:
+ case 260 /* SyntaxKind.ClassDeclaration */:
+ case 264 /* SyntaxKind.ModuleDeclaration */:
+ case 263 /* SyntaxKind.EnumDeclaration */:
+ case 295 /* SyntaxKind.CatchClause */:
+ case 265 /* SyntaxKind.ModuleBlock */:
+ case 252 /* SyntaxKind.SwitchStatement */:
return true;
- case 235 /* SyntaxKind.Block */: {
+ case 238 /* SyntaxKind.Block */: {
var blockParent = context.currentTokenParent.parent;
// In a codefix scenario, we can't rely on parents being set. So just always return true.
- if (!blockParent || blockParent.kind !== 214 /* SyntaxKind.ArrowFunction */ && blockParent.kind !== 213 /* SyntaxKind.FunctionExpression */) {
+ if (!blockParent || blockParent.kind !== 216 /* SyntaxKind.ArrowFunction */ && blockParent.kind !== 215 /* SyntaxKind.FunctionExpression */) {
return true;
}
}
@@ -436090,32 +437428,32 @@ var ts;
}
function isControlDeclContext(context) {
switch (context.contextNode.kind) {
- case 239 /* SyntaxKind.IfStatement */:
- case 249 /* SyntaxKind.SwitchStatement */:
- case 242 /* SyntaxKind.ForStatement */:
- case 243 /* SyntaxKind.ForInStatement */:
- case 244 /* SyntaxKind.ForOfStatement */:
- case 241 /* SyntaxKind.WhileStatement */:
- case 252 /* SyntaxKind.TryStatement */:
- case 240 /* SyntaxKind.DoStatement */:
- case 248 /* SyntaxKind.WithStatement */:
+ case 242 /* SyntaxKind.IfStatement */:
+ case 252 /* SyntaxKind.SwitchStatement */:
+ case 245 /* SyntaxKind.ForStatement */:
+ case 246 /* SyntaxKind.ForInStatement */:
+ case 247 /* SyntaxKind.ForOfStatement */:
+ case 244 /* SyntaxKind.WhileStatement */:
+ case 255 /* SyntaxKind.TryStatement */:
+ case 243 /* SyntaxKind.DoStatement */:
+ case 251 /* SyntaxKind.WithStatement */:
// TODO
// case SyntaxKind.ElseClause:
// falls through
- case 292 /* SyntaxKind.CatchClause */:
+ case 295 /* SyntaxKind.CatchClause */:
return true;
default:
return false;
}
}
function isObjectContext(context) {
- return context.contextNode.kind === 205 /* SyntaxKind.ObjectLiteralExpression */;
+ return context.contextNode.kind === 207 /* SyntaxKind.ObjectLiteralExpression */;
}
function isFunctionCallContext(context) {
- return context.contextNode.kind === 208 /* SyntaxKind.CallExpression */;
+ return context.contextNode.kind === 210 /* SyntaxKind.CallExpression */;
}
function isNewContext(context) {
- return context.contextNode.kind === 209 /* SyntaxKind.NewExpression */;
+ return context.contextNode.kind === 211 /* SyntaxKind.NewExpression */;
}
function isFunctionCallOrNewContext(context) {
return isFunctionCallContext(context) || isNewContext(context);
@@ -436130,10 +437468,10 @@ var ts;
return context.nextTokenSpan.kind !== 21 /* SyntaxKind.CloseParenToken */;
}
function isArrowFunctionContext(context) {
- return context.contextNode.kind === 214 /* SyntaxKind.ArrowFunction */;
+ return context.contextNode.kind === 216 /* SyntaxKind.ArrowFunction */;
}
function isImportTypeContext(context) {
- return context.contextNode.kind === 200 /* SyntaxKind.ImportType */;
+ return context.contextNode.kind === 202 /* SyntaxKind.ImportType */;
}
function isNonJsxSameLineTokenContext(context) {
return context.TokensAreOnSameLine() && context.contextNode.kind !== 11 /* SyntaxKind.JsxText */;
@@ -436142,19 +437480,19 @@ var ts;
return context.contextNode.kind !== 11 /* SyntaxKind.JsxText */;
}
function isNonJsxElementOrFragmentContext(context) {
- return context.contextNode.kind !== 278 /* SyntaxKind.JsxElement */ && context.contextNode.kind !== 282 /* SyntaxKind.JsxFragment */;
+ return context.contextNode.kind !== 281 /* SyntaxKind.JsxElement */ && context.contextNode.kind !== 285 /* SyntaxKind.JsxFragment */;
}
function isJsxExpressionContext(context) {
- return context.contextNode.kind === 288 /* SyntaxKind.JsxExpression */ || context.contextNode.kind === 287 /* SyntaxKind.JsxSpreadAttribute */;
+ return context.contextNode.kind === 291 /* SyntaxKind.JsxExpression */ || context.contextNode.kind === 290 /* SyntaxKind.JsxSpreadAttribute */;
}
function isNextTokenParentJsxAttribute(context) {
- return context.nextTokenParent.kind === 285 /* SyntaxKind.JsxAttribute */;
+ return context.nextTokenParent.kind === 288 /* SyntaxKind.JsxAttribute */;
}
function isJsxAttributeContext(context) {
- return context.contextNode.kind === 285 /* SyntaxKind.JsxAttribute */;
+ return context.contextNode.kind === 288 /* SyntaxKind.JsxAttribute */;
}
function isJsxSelfClosingElementContext(context) {
- return context.contextNode.kind === 279 /* SyntaxKind.JsxSelfClosingElement */;
+ return context.contextNode.kind === 282 /* SyntaxKind.JsxSelfClosingElement */;
}
function isNotBeforeBlockInFunctionDeclarationContext(context) {
return !isFunctionDeclContext(context) && !isBeforeBlockContext(context);
@@ -436166,48 +437504,48 @@ var ts;
!nodeIsInDecoratorContext(context.nextTokenParent);
}
function nodeIsInDecoratorContext(node) {
- while (ts.isExpressionNode(node)) {
+ while (node && ts.isExpression(node)) {
node = node.parent;
}
- return node.kind === 165 /* SyntaxKind.Decorator */;
+ return node && node.kind === 167 /* SyntaxKind.Decorator */;
}
function isStartOfVariableDeclarationList(context) {
- return context.currentTokenParent.kind === 255 /* SyntaxKind.VariableDeclarationList */ &&
+ return context.currentTokenParent.kind === 258 /* SyntaxKind.VariableDeclarationList */ &&
context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos;
}
function isNotFormatOnEnter(context) {
return context.formattingRequestKind !== 2 /* FormattingRequestKind.FormatOnEnter */;
}
function isModuleDeclContext(context) {
- return context.contextNode.kind === 261 /* SyntaxKind.ModuleDeclaration */;
+ return context.contextNode.kind === 264 /* SyntaxKind.ModuleDeclaration */;
}
function isObjectTypeContext(context) {
- return context.contextNode.kind === 182 /* SyntaxKind.TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration;
+ return context.contextNode.kind === 184 /* SyntaxKind.TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration;
}
function isConstructorSignatureContext(context) {
- return context.contextNode.kind === 175 /* SyntaxKind.ConstructSignature */;
+ return context.contextNode.kind === 177 /* SyntaxKind.ConstructSignature */;
}
function isTypeArgumentOrParameterOrAssertion(token, parent) {
if (token.kind !== 29 /* SyntaxKind.LessThanToken */ && token.kind !== 31 /* SyntaxKind.GreaterThanToken */) {
return false;
}
switch (parent.kind) {
- case 178 /* SyntaxKind.TypeReference */:
- case 211 /* SyntaxKind.TypeAssertionExpression */:
- case 259 /* SyntaxKind.TypeAliasDeclaration */:
- case 257 /* SyntaxKind.ClassDeclaration */:
- case 226 /* SyntaxKind.ClassExpression */:
- case 258 /* SyntaxKind.InterfaceDeclaration */:
- case 256 /* SyntaxKind.FunctionDeclaration */:
- case 213 /* SyntaxKind.FunctionExpression */:
- case 214 /* SyntaxKind.ArrowFunction */:
- case 169 /* SyntaxKind.MethodDeclaration */:
- case 168 /* SyntaxKind.MethodSignature */:
- case 174 /* SyntaxKind.CallSignature */:
- case 175 /* SyntaxKind.ConstructSignature */:
- case 208 /* SyntaxKind.CallExpression */:
- case 209 /* SyntaxKind.NewExpression */:
- case 228 /* SyntaxKind.ExpressionWithTypeArguments */:
+ case 180 /* SyntaxKind.TypeReference */:
+ case 213 /* SyntaxKind.TypeAssertionExpression */:
+ case 262 /* SyntaxKind.TypeAliasDeclaration */:
+ case 260 /* SyntaxKind.ClassDeclaration */:
+ case 228 /* SyntaxKind.ClassExpression */:
+ case 261 /* SyntaxKind.InterfaceDeclaration */:
+ case 259 /* SyntaxKind.FunctionDeclaration */:
+ case 215 /* SyntaxKind.FunctionExpression */:
+ case 216 /* SyntaxKind.ArrowFunction */:
+ case 171 /* SyntaxKind.MethodDeclaration */:
+ case 170 /* SyntaxKind.MethodSignature */:
+ case 176 /* SyntaxKind.CallSignature */:
+ case 177 /* SyntaxKind.ConstructSignature */:
+ case 210 /* SyntaxKind.CallExpression */:
+ case 211 /* SyntaxKind.NewExpression */:
+ case 230 /* SyntaxKind.ExpressionWithTypeArguments */:
return true;
default:
return false;
@@ -436218,28 +437556,28 @@ var ts;
isTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent);
}
function isTypeAssertionContext(context) {
- return context.contextNode.kind === 211 /* SyntaxKind.TypeAssertionExpression */;
+ return context.contextNode.kind === 213 /* SyntaxKind.TypeAssertionExpression */;
}
function isVoidOpContext(context) {
- return context.currentTokenSpan.kind === 114 /* SyntaxKind.VoidKeyword */ && context.currentTokenParent.kind === 217 /* SyntaxKind.VoidExpression */;
+ return context.currentTokenSpan.kind === 114 /* SyntaxKind.VoidKeyword */ && context.currentTokenParent.kind === 219 /* SyntaxKind.VoidExpression */;
}
function isYieldOrYieldStarWithOperand(context) {
- return context.contextNode.kind === 224 /* SyntaxKind.YieldExpression */ && context.contextNode.expression !== undefined;
+ return context.contextNode.kind === 226 /* SyntaxKind.YieldExpression */ && context.contextNode.expression !== undefined;
}
function isNonNullAssertionContext(context) {
- return context.contextNode.kind === 230 /* SyntaxKind.NonNullExpression */;
+ return context.contextNode.kind === 232 /* SyntaxKind.NonNullExpression */;
}
function isNotStatementConditionContext(context) {
return !isStatementConditionContext(context);
}
function isStatementConditionContext(context) {
switch (context.contextNode.kind) {
- case 239 /* SyntaxKind.IfStatement */:
- case 242 /* SyntaxKind.ForStatement */:
- case 243 /* SyntaxKind.ForInStatement */:
- case 244 /* SyntaxKind.ForOfStatement */:
- case 240 /* SyntaxKind.DoStatement */:
- case 241 /* SyntaxKind.WhileStatement */:
+ case 242 /* SyntaxKind.IfStatement */:
+ case 245 /* SyntaxKind.ForStatement */:
+ case 246 /* SyntaxKind.ForInStatement */:
+ case 247 /* SyntaxKind.ForOfStatement */:
+ case 243 /* SyntaxKind.DoStatement */:
+ case 244 /* SyntaxKind.WhileStatement */:
return true;
default:
return false;
@@ -436264,12 +437602,12 @@ var ts;
return nextTokenKind === 19 /* SyntaxKind.CloseBraceToken */
|| nextTokenKind === 1 /* SyntaxKind.EndOfFileToken */;
}
- if (nextTokenKind === 234 /* SyntaxKind.SemicolonClassElement */ ||
+ if (nextTokenKind === 237 /* SyntaxKind.SemicolonClassElement */ ||
nextTokenKind === 26 /* SyntaxKind.SemicolonToken */) {
return false;
}
- if (context.contextNode.kind === 258 /* SyntaxKind.InterfaceDeclaration */ ||
- context.contextNode.kind === 259 /* SyntaxKind.TypeAliasDeclaration */) {
+ if (context.contextNode.kind === 261 /* SyntaxKind.InterfaceDeclaration */ ||
+ context.contextNode.kind === 262 /* SyntaxKind.TypeAliasDeclaration */) {
// Can’t remove semicolon after `foo`; it would parse as a method declaration:
//
// interface I {
@@ -436283,9 +437621,9 @@ var ts;
if (ts.isPropertyDeclaration(context.currentTokenParent)) {
return !context.currentTokenParent.initializer;
}
- return context.currentTokenParent.kind !== 242 /* SyntaxKind.ForStatement */
- && context.currentTokenParent.kind !== 236 /* SyntaxKind.EmptyStatement */
- && context.currentTokenParent.kind !== 234 /* SyntaxKind.SemicolonClassElement */
+ return context.currentTokenParent.kind !== 245 /* SyntaxKind.ForStatement */
+ && context.currentTokenParent.kind !== 239 /* SyntaxKind.EmptyStatement */
+ && context.currentTokenParent.kind !== 237 /* SyntaxKind.SemicolonClassElement */
&& nextTokenKind !== 22 /* SyntaxKind.OpenBracketToken */
&& nextTokenKind !== 20 /* SyntaxKind.OpenParenToken */
&& nextTokenKind !== 39 /* SyntaxKind.PlusToken */
@@ -436293,7 +437631,7 @@ var ts;
&& nextTokenKind !== 43 /* SyntaxKind.SlashToken */
&& nextTokenKind !== 13 /* SyntaxKind.RegularExpressionLiteral */
&& nextTokenKind !== 27 /* SyntaxKind.CommaToken */
- && nextTokenKind !== 223 /* SyntaxKind.TemplateExpression */
+ && nextTokenKind !== 225 /* SyntaxKind.TemplateExpression */
&& nextTokenKind !== 15 /* SyntaxKind.TemplateHead */
&& nextTokenKind !== 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */
&& nextTokenKind !== 24 /* SyntaxKind.DotToken */;
@@ -436301,6 +437639,11 @@ var ts;
function isSemicolonInsertionContext(context) {
return ts.positionIsASICandidate(context.currentTokenSpan.end, context.currentTokenParent, context.sourceFile);
}
+ function isNotPropertyAccessOnIntegerLiteral(context) {
+ return !ts.isPropertyAccessExpression(context.contextNode)
+ || !ts.isNumericLiteral(context.contextNode.expression)
+ || context.contextNode.expression.getText().indexOf(".") !== -1;
+ }
})(formatting = ts.formatting || (ts.formatting = {}));
})(ts || (ts = {}));
/* @internal */
@@ -436384,12 +437727,12 @@ var ts;
return map;
}
function getRuleBucketIndex(row, column) {
- ts.Debug.assert(row <= 160 /* SyntaxKind.LastKeyword */ && column <= 160 /* SyntaxKind.LastKeyword */, "Must compute formatting context from tokens");
+ ts.Debug.assert(row <= 162 /* SyntaxKind.LastKeyword */ && column <= 162 /* SyntaxKind.LastKeyword */, "Must compute formatting context from tokens");
return (row * mapRowLength) + column;
}
var maskBitSize = 5;
var mask = 31; // MaskBitSize bits
- var mapRowLength = 160 /* SyntaxKind.LastToken */ + 1;
+ var mapRowLength = 162 /* SyntaxKind.LastToken */ + 1;
var RulesPosition;
(function (RulesPosition) {
RulesPosition[RulesPosition["StopRulesSpecific"] = 0] = "StopRulesSpecific";
@@ -436577,17 +437920,17 @@ var ts;
// i.e. parent is class declaration with the list of members and node is one of members.
function isListElement(parent, node) {
switch (parent.kind) {
- case 257 /* SyntaxKind.ClassDeclaration */:
- case 258 /* SyntaxKind.InterfaceDeclaration */:
+ case 260 /* SyntaxKind.ClassDeclaration */:
+ case 261 /* SyntaxKind.InterfaceDeclaration */:
return ts.rangeContainsRange(parent.members, node);
- case 261 /* SyntaxKind.ModuleDeclaration */:
+ case 264 /* SyntaxKind.ModuleDeclaration */:
var body = parent.body;
- return !!body && body.kind === 262 /* SyntaxKind.ModuleBlock */ && ts.rangeContainsRange(body.statements, node);
- case 305 /* SyntaxKind.SourceFile */:
- case 235 /* SyntaxKind.Block */:
- case 262 /* SyntaxKind.ModuleBlock */:
+ return !!body && body.kind === 265 /* SyntaxKind.ModuleBlock */ && ts.rangeContainsRange(body.statements, node);
+ case 308 /* SyntaxKind.SourceFile */:
+ case 238 /* SyntaxKind.Block */:
+ case 265 /* SyntaxKind.ModuleBlock */:
return ts.rangeContainsRange(parent.statements, node);
- case 292 /* SyntaxKind.CatchClause */:
+ case 295 /* SyntaxKind.CatchClause */:
return ts.rangeContainsRange(parent.block.statements, node);
}
return false;
@@ -436850,19 +438193,19 @@ var ts;
return modifier.kind;
}
switch (node.kind) {
- case 257 /* SyntaxKind.ClassDeclaration */: return 84 /* SyntaxKind.ClassKeyword */;
- case 258 /* SyntaxKind.InterfaceDeclaration */: return 118 /* SyntaxKind.InterfaceKeyword */;
- case 256 /* SyntaxKind.FunctionDeclaration */: return 98 /* SyntaxKind.FunctionKeyword */;
- case 260 /* SyntaxKind.EnumDeclaration */: return 260 /* SyntaxKind.EnumDeclaration */;
- case 172 /* SyntaxKind.GetAccessor */: return 136 /* SyntaxKind.GetKeyword */;
- case 173 /* SyntaxKind.SetAccessor */: return 149 /* SyntaxKind.SetKeyword */;
- case 169 /* SyntaxKind.MethodDeclaration */:
+ case 260 /* SyntaxKind.ClassDeclaration */: return 84 /* SyntaxKind.ClassKeyword */;
+ case 261 /* SyntaxKind.InterfaceDeclaration */: return 118 /* SyntaxKind.InterfaceKeyword */;
+ case 259 /* SyntaxKind.FunctionDeclaration */: return 98 /* SyntaxKind.FunctionKeyword */;
+ case 263 /* SyntaxKind.EnumDeclaration */: return 263 /* SyntaxKind.EnumDeclaration */;
+ case 174 /* SyntaxKind.GetAccessor */: return 137 /* SyntaxKind.GetKeyword */;
+ case 175 /* SyntaxKind.SetAccessor */: return 151 /* SyntaxKind.SetKeyword */;
+ case 171 /* SyntaxKind.MethodDeclaration */:
if (node.asteriskToken) {
return 41 /* SyntaxKind.AsteriskToken */;
}
// falls through
- case 167 /* SyntaxKind.PropertyDeclaration */:
- case 164 /* SyntaxKind.Parameter */:
+ case 169 /* SyntaxKind.PropertyDeclaration */:
+ case 166 /* SyntaxKind.Parameter */:
var name = ts.getNameOfDeclaration(node);
if (name) {
return name.kind;
@@ -436919,15 +438262,15 @@ var ts;
case 43 /* SyntaxKind.SlashToken */:
case 31 /* SyntaxKind.GreaterThanToken */:
switch (container.kind) {
- case 280 /* SyntaxKind.JsxOpeningElement */:
- case 281 /* SyntaxKind.JsxClosingElement */:
- case 279 /* SyntaxKind.JsxSelfClosingElement */:
+ case 283 /* SyntaxKind.JsxOpeningElement */:
+ case 284 /* SyntaxKind.JsxClosingElement */:
+ case 282 /* SyntaxKind.JsxSelfClosingElement */:
return false;
}
break;
case 22 /* SyntaxKind.OpenBracketToken */:
case 23 /* SyntaxKind.CloseBracketToken */:
- if (container.kind !== 195 /* SyntaxKind.MappedType */) {
+ if (container.kind !== 197 /* SyntaxKind.MappedType */) {
return false;
}
break;
@@ -437031,11 +438374,11 @@ var ts;
return inheritedIndentation;
}
}
- var effectiveParentStartLine = child.kind === 165 /* SyntaxKind.Decorator */ ? childStartLine : undecoratedParentStartLine;
+ var effectiveParentStartLine = child.kind === 167 /* SyntaxKind.Decorator */ ? childStartLine : undecoratedParentStartLine;
var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine);
processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta);
childContextNode = node;
- if (isFirstListItem && parent.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ && inheritedIndentation === -1 /* Constants.Unknown */) {
+ if (isFirstListItem && parent.kind === 206 /* SyntaxKind.ArrayLiteralExpression */ && inheritedIndentation === -1 /* Constants.Unknown */) {
inheritedIndentation = childIndentation.indentation;
}
return inheritedIndentation;
@@ -437493,18 +438836,18 @@ var ts;
formatting.getRangeOfEnclosingComment = getRangeOfEnclosingComment;
function getOpenTokenForList(node, list) {
switch (node.kind) {
- case 171 /* SyntaxKind.Constructor */:
- case 256 /* SyntaxKind.FunctionDeclaration */:
- case 213 /* SyntaxKind.FunctionExpression */:
- case 169 /* SyntaxKind.MethodDeclaration */:
- case 168 /* SyntaxKind.MethodSignature */:
- case 214 /* SyntaxKind.ArrowFunction */:
- case 174 /* SyntaxKind.CallSignature */:
- case 175 /* SyntaxKind.ConstructSignature */:
- case 179 /* SyntaxKind.FunctionType */:
- case 180 /* SyntaxKind.ConstructorType */:
- case 172 /* SyntaxKind.GetAccessor */:
- case 173 /* SyntaxKind.SetAccessor */:
+ case 173 /* SyntaxKind.Constructor */:
+ case 259 /* SyntaxKind.FunctionDeclaration */:
+ case 215 /* SyntaxKind.FunctionExpression */:
+ case 171 /* SyntaxKind.MethodDeclaration */:
+ case 170 /* SyntaxKind.MethodSignature */:
+ case 216 /* SyntaxKind.ArrowFunction */:
+ case 176 /* SyntaxKind.CallSignature */:
+ case 177 /* SyntaxKind.ConstructSignature */:
+ case 181 /* SyntaxKind.FunctionType */:
+ case 182 /* SyntaxKind.ConstructorType */:
+ case 174 /* SyntaxKind.GetAccessor */:
+ case 175 /* SyntaxKind.SetAccessor */:
if (node.typeParameters === list) {
return 29 /* SyntaxKind.LessThanToken */;
}
@@ -437512,8 +438855,8 @@ var ts;
return 20 /* SyntaxKind.OpenParenToken */;
}
break;
- case 208 /* SyntaxKind.CallExpression */:
- case 209 /* SyntaxKind.NewExpression */:
+ case 210 /* SyntaxKind.CallExpression */:
+ case 211 /* SyntaxKind.NewExpression */:
if (node.typeArguments === list) {
return 29 /* SyntaxKind.LessThanToken */;
}
@@ -437521,24 +438864,24 @@ var ts;
return 20 /* SyntaxKind.OpenParenToken */;
}
break;
- case 257 /* SyntaxKind.ClassDeclaration */:
- case 226 /* SyntaxKind.ClassExpression */:
- case 258 /* SyntaxKind.InterfaceDeclaration */:
- case 259 /* SyntaxKind.TypeAliasDeclaration */:
+ case 260 /* SyntaxKind.ClassDeclaration */:
+ case 228 /* SyntaxKind.ClassExpression */:
+ case 261 /* SyntaxKind.InterfaceDeclaration */:
+ case 262 /* SyntaxKind.TypeAliasDeclaration */:
if (node.typeParameters === list) {
return 29 /* SyntaxKind.LessThanToken */;
}
break;
- case 178 /* SyntaxKind.TypeReference */:
- case 210 /* SyntaxKind.TaggedTemplateExpression */:
- case 181 /* SyntaxKind.TypeQuery */:
- case 228 /* SyntaxKind.ExpressionWithTypeArguments */:
- case 200 /* SyntaxKind.ImportType */:
+ case 180 /* SyntaxKind.TypeReference */:
+ case 212 /* SyntaxKind.TaggedTemplateExpression */:
+ case 183 /* SyntaxKind.TypeQuery */:
+ case 230 /* SyntaxKind.ExpressionWithTypeArguments */:
+ case 202 /* SyntaxKind.ImportType */:
if (node.typeArguments === list) {
return 29 /* SyntaxKind.LessThanToken */;
}
break;
- case 182 /* SyntaxKind.TypeLiteral */:
+ case 184 /* SyntaxKind.TypeLiteral */:
return 18 /* SyntaxKind.OpenBraceToken */;
}
return 0 /* SyntaxKind.Unknown */;
@@ -437674,11 +439017,11 @@ var ts;
// y: undefined,
// }
// ```
- var isObjectLiteral = currentToken.kind === 18 /* SyntaxKind.OpenBraceToken */ && currentToken.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */;
+ var isObjectLiteral = currentToken.kind === 18 /* SyntaxKind.OpenBraceToken */ && currentToken.parent.kind === 207 /* SyntaxKind.ObjectLiteralExpression */;
if (options.indentStyle === ts.IndentStyle.Block || isObjectLiteral) {
return getBlockIndent(sourceFile, position, options);
}
- if (precedingToken.kind === 27 /* SyntaxKind.CommaToken */ && precedingToken.parent.kind !== 221 /* SyntaxKind.BinaryExpression */) {
+ if (precedingToken.kind === 27 /* SyntaxKind.CommaToken */ && precedingToken.parent.kind !== 223 /* SyntaxKind.BinaryExpression */) {
// previous token is comma that separates items in list - find the previous item and try to derive indentation from it
var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options);
if (actualIndentation !== -1 /* Value.Unknown */) {
@@ -437688,7 +439031,7 @@ var ts;
var containerList = getListByPosition(position, precedingToken.parent, sourceFile);
// use list position if the preceding token is before any list items
if (containerList && !ts.rangeContainsRange(containerList, precedingToken)) {
- var useTheSameBaseIndentation = [213 /* SyntaxKind.FunctionExpression */, 214 /* SyntaxKind.ArrowFunction */].indexOf(currentToken.parent.kind) !== -1;
+ var useTheSameBaseIndentation = [215 /* SyntaxKind.FunctionExpression */, 216 /* SyntaxKind.ArrowFunction */].indexOf(currentToken.parent.kind) !== -1;
var indentSize = useTheSameBaseIndentation ? 0 : options.indentSize;
return getActualIndentationForListStartLine(containerList, sourceFile, options) + indentSize; // TODO: GH#18217
}
@@ -437853,7 +439196,7 @@ var ts;
// - parent is SourceFile - by default immediate children of SourceFile are not indented except when user indents them manually
// - parent and child are not on the same line
var useActualIndentation = (ts.isDeclaration(current) || ts.isStatementButNotDeclaration(current)) &&
- (parent.kind === 305 /* SyntaxKind.SourceFile */ || !parentAndChildShareLine);
+ (parent.kind === 308 /* SyntaxKind.SourceFile */ || !parentAndChildShareLine);
if (!useActualIndentation) {
return -1 /* Value.Unknown */;
}
@@ -437901,7 +439244,7 @@ var ts;
}
SmartIndenter.isArgumentAndStartLineOverlapsExpressionBeingCalled = isArgumentAndStartLineOverlapsExpressionBeingCalled;
function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) {
- if (parent.kind === 239 /* SyntaxKind.IfStatement */ && parent.elseStatement === child) {
+ if (parent.kind === 242 /* SyntaxKind.IfStatement */ && parent.elseStatement === child) {
var elseKeyword = ts.findChildOfKind(parent, 91 /* SyntaxKind.ElseKeyword */, sourceFile);
ts.Debug.assert(elseKeyword !== undefined);
var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line;
@@ -437982,42 +439325,42 @@ var ts;
}
function getListByRange(start, end, node, sourceFile) {
switch (node.kind) {
- case 178 /* SyntaxKind.TypeReference */:
+ case 180 /* SyntaxKind.TypeReference */:
return getList(node.typeArguments);
- case 205 /* SyntaxKind.ObjectLiteralExpression */:
+ case 207 /* SyntaxKind.ObjectLiteralExpression */:
return getList(node.properties);
- case 204 /* SyntaxKind.ArrayLiteralExpression */:
+ case 206 /* SyntaxKind.ArrayLiteralExpression */:
return getList(node.elements);
- case 182 /* SyntaxKind.TypeLiteral */:
+ case 184 /* SyntaxKind.TypeLiteral */:
return getList(node.members);
- case 256 /* SyntaxKind.FunctionDeclaration */:
- case 213 /* SyntaxKind.FunctionExpression */:
- case 214 /* SyntaxKind.ArrowFunction */:
- case 169 /* SyntaxKind.MethodDeclaration */:
- case 168 /* SyntaxKind.MethodSignature */:
- case 174 /* SyntaxKind.CallSignature */:
- case 171 /* SyntaxKind.Constructor */:
- case 180 /* SyntaxKind.ConstructorType */:
- case 175 /* SyntaxKind.ConstructSignature */:
+ case 259 /* SyntaxKind.FunctionDeclaration */:
+ case 215 /* SyntaxKind.FunctionExpression */:
+ case 216 /* SyntaxKind.ArrowFunction */:
+ case 171 /* SyntaxKind.MethodDeclaration */:
+ case 170 /* SyntaxKind.MethodSignature */:
+ case 176 /* SyntaxKind.CallSignature */:
+ case 173 /* SyntaxKind.Constructor */:
+ case 182 /* SyntaxKind.ConstructorType */:
+ case 177 /* SyntaxKind.ConstructSignature */:
return getList(node.typeParameters) || getList(node.parameters);
- case 172 /* SyntaxKind.GetAccessor */:
+ case 174 /* SyntaxKind.GetAccessor */:
return getList(node.parameters);
- case 257 /* SyntaxKind.ClassDeclaration */:
- case 226 /* SyntaxKind.ClassExpression */:
- case 258 /* SyntaxKind.InterfaceDeclaration */:
- case 259 /* SyntaxKind.TypeAliasDeclaration */:
- case 344 /* SyntaxKind.JSDocTemplateTag */:
+ case 260 /* SyntaxKind.ClassDeclaration */:
+ case 228 /* SyntaxKind.ClassExpression */:
+ case 261 /* SyntaxKind.InterfaceDeclaration */:
+ case 262 /* SyntaxKind.TypeAliasDeclaration */:
+ case 347 /* SyntaxKind.JSDocTemplateTag */:
return getList(node.typeParameters);
- case 209 /* SyntaxKind.NewExpression */:
- case 208 /* SyntaxKind.CallExpression */:
+ case 211 /* SyntaxKind.NewExpression */:
+ case 210 /* SyntaxKind.CallExpression */:
return getList(node.typeArguments) || getList(node.arguments);
- case 255 /* SyntaxKind.VariableDeclarationList */:
+ case 258 /* SyntaxKind.VariableDeclarationList */:
return getList(node.declarations);
- case 269 /* SyntaxKind.NamedImports */:
- case 273 /* SyntaxKind.NamedExports */:
+ case 272 /* SyntaxKind.NamedImports */:
+ case 276 /* SyntaxKind.NamedExports */:
return getList(node.elements);
- case 201 /* SyntaxKind.ObjectBindingPattern */:
- case 202 /* SyntaxKind.ArrayBindingPattern */:
+ case 203 /* SyntaxKind.ObjectBindingPattern */:
+ case 204 /* SyntaxKind.ArrayBindingPattern */:
return getList(node.elements);
}
function getList(list) {
@@ -438040,7 +439383,7 @@ var ts;
return findColumnForFirstNonWhitespaceCharacterInLine(sourceFile.getLineAndCharacterOfPosition(list.pos), sourceFile, options);
}
function getActualIndentationForListItem(node, sourceFile, options, listIndentsChild) {
- if (node.parent && node.parent.kind === 255 /* SyntaxKind.VariableDeclarationList */) {
+ if (node.parent && node.parent.kind === 258 /* SyntaxKind.VariableDeclarationList */) {
// VariableDeclarationList has no wrapping tokens
return -1 /* Value.Unknown */;
}
@@ -438113,96 +439456,96 @@ var ts;
function nodeWillIndentChild(settings, parent, child, sourceFile, indentByDefault) {
var childKind = child ? child.kind : 0 /* SyntaxKind.Unknown */;
switch (parent.kind) {
- case 238 /* SyntaxKind.ExpressionStatement */:
- case 257 /* SyntaxKind.ClassDeclaration */:
- case 226 /* SyntaxKind.ClassExpression */:
- case 258 /* SyntaxKind.InterfaceDeclaration */:
- case 260 /* SyntaxKind.EnumDeclaration */:
- case 259 /* SyntaxKind.TypeAliasDeclaration */:
- case 204 /* SyntaxKind.ArrayLiteralExpression */:
- case 235 /* SyntaxKind.Block */:
- case 262 /* SyntaxKind.ModuleBlock */:
- case 205 /* SyntaxKind.ObjectLiteralExpression */:
- case 182 /* SyntaxKind.TypeLiteral */:
- case 195 /* SyntaxKind.MappedType */:
- case 184 /* SyntaxKind.TupleType */:
- case 263 /* SyntaxKind.CaseBlock */:
- case 290 /* SyntaxKind.DefaultClause */:
- case 289 /* SyntaxKind.CaseClause */:
- case 212 /* SyntaxKind.ParenthesizedExpression */:
- case 206 /* SyntaxKind.PropertyAccessExpression */:
- case 208 /* SyntaxKind.CallExpression */:
- case 209 /* SyntaxKind.NewExpression */:
- case 237 /* SyntaxKind.VariableStatement */:
- case 271 /* SyntaxKind.ExportAssignment */:
- case 247 /* SyntaxKind.ReturnStatement */:
- case 222 /* SyntaxKind.ConditionalExpression */:
- case 202 /* SyntaxKind.ArrayBindingPattern */:
- case 201 /* SyntaxKind.ObjectBindingPattern */:
- case 280 /* SyntaxKind.JsxOpeningElement */:
- case 283 /* SyntaxKind.JsxOpeningFragment */:
- case 279 /* SyntaxKind.JsxSelfClosingElement */:
- case 288 /* SyntaxKind.JsxExpression */:
- case 168 /* SyntaxKind.MethodSignature */:
- case 174 /* SyntaxKind.CallSignature */:
- case 175 /* SyntaxKind.ConstructSignature */:
- case 164 /* SyntaxKind.Parameter */:
- case 179 /* SyntaxKind.FunctionType */:
- case 180 /* SyntaxKind.ConstructorType */:
- case 191 /* SyntaxKind.ParenthesizedType */:
- case 210 /* SyntaxKind.TaggedTemplateExpression */:
- case 218 /* SyntaxKind.AwaitExpression */:
- case 273 /* SyntaxKind.NamedExports */:
- case 269 /* SyntaxKind.NamedImports */:
- case 275 /* SyntaxKind.ExportSpecifier */:
- case 270 /* SyntaxKind.ImportSpecifier */:
- case 167 /* SyntaxKind.PropertyDeclaration */:
+ case 241 /* SyntaxKind.ExpressionStatement */:
+ case 260 /* SyntaxKind.ClassDeclaration */:
+ case 228 /* SyntaxKind.ClassExpression */:
+ case 261 /* SyntaxKind.InterfaceDeclaration */:
+ case 263 /* SyntaxKind.EnumDeclaration */:
+ case 262 /* SyntaxKind.TypeAliasDeclaration */:
+ case 206 /* SyntaxKind.ArrayLiteralExpression */:
+ case 238 /* SyntaxKind.Block */:
+ case 265 /* SyntaxKind.ModuleBlock */:
+ case 207 /* SyntaxKind.ObjectLiteralExpression */:
+ case 184 /* SyntaxKind.TypeLiteral */:
+ case 197 /* SyntaxKind.MappedType */:
+ case 186 /* SyntaxKind.TupleType */:
+ case 266 /* SyntaxKind.CaseBlock */:
+ case 293 /* SyntaxKind.DefaultClause */:
+ case 292 /* SyntaxKind.CaseClause */:
+ case 214 /* SyntaxKind.ParenthesizedExpression */:
+ case 208 /* SyntaxKind.PropertyAccessExpression */:
+ case 210 /* SyntaxKind.CallExpression */:
+ case 211 /* SyntaxKind.NewExpression */:
+ case 240 /* SyntaxKind.VariableStatement */:
+ case 274 /* SyntaxKind.ExportAssignment */:
+ case 250 /* SyntaxKind.ReturnStatement */:
+ case 224 /* SyntaxKind.ConditionalExpression */:
+ case 204 /* SyntaxKind.ArrayBindingPattern */:
+ case 203 /* SyntaxKind.ObjectBindingPattern */:
+ case 283 /* SyntaxKind.JsxOpeningElement */:
+ case 286 /* SyntaxKind.JsxOpeningFragment */:
+ case 282 /* SyntaxKind.JsxSelfClosingElement */:
+ case 291 /* SyntaxKind.JsxExpression */:
+ case 170 /* SyntaxKind.MethodSignature */:
+ case 176 /* SyntaxKind.CallSignature */:
+ case 177 /* SyntaxKind.ConstructSignature */:
+ case 166 /* SyntaxKind.Parameter */:
+ case 181 /* SyntaxKind.FunctionType */:
+ case 182 /* SyntaxKind.ConstructorType */:
+ case 193 /* SyntaxKind.ParenthesizedType */:
+ case 212 /* SyntaxKind.TaggedTemplateExpression */:
+ case 220 /* SyntaxKind.AwaitExpression */:
+ case 276 /* SyntaxKind.NamedExports */:
+ case 272 /* SyntaxKind.NamedImports */:
+ case 278 /* SyntaxKind.ExportSpecifier */:
+ case 273 /* SyntaxKind.ImportSpecifier */:
+ case 169 /* SyntaxKind.PropertyDeclaration */:
return true;
- case 254 /* SyntaxKind.VariableDeclaration */:
- case 296 /* SyntaxKind.PropertyAssignment */:
- case 221 /* SyntaxKind.BinaryExpression */:
- if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 205 /* SyntaxKind.ObjectLiteralExpression */) { // TODO: GH#18217
+ case 257 /* SyntaxKind.VariableDeclaration */:
+ case 299 /* SyntaxKind.PropertyAssignment */:
+ case 223 /* SyntaxKind.BinaryExpression */:
+ if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 207 /* SyntaxKind.ObjectLiteralExpression */) { // TODO: GH#18217
return rangeIsOnOneLine(sourceFile, child);
}
- if (parent.kind === 221 /* SyntaxKind.BinaryExpression */ && sourceFile && child && childKind === 278 /* SyntaxKind.JsxElement */) {
+ if (parent.kind === 223 /* SyntaxKind.BinaryExpression */ && sourceFile && child && childKind === 281 /* SyntaxKind.JsxElement */) {
var parentStartLine = sourceFile.getLineAndCharacterOfPosition(ts.skipTrivia(sourceFile.text, parent.pos)).line;
var childStartLine = sourceFile.getLineAndCharacterOfPosition(ts.skipTrivia(sourceFile.text, child.pos)).line;
return parentStartLine !== childStartLine;
}
- if (parent.kind !== 221 /* SyntaxKind.BinaryExpression */) {
+ if (parent.kind !== 223 /* SyntaxKind.BinaryExpression */) {
return true;
}
break;
- case 240 /* SyntaxKind.DoStatement */:
- case 241 /* SyntaxKind.WhileStatement */:
- case 243 /* SyntaxKind.ForInStatement */:
- case 244 /* SyntaxKind.ForOfStatement */:
- case 242 /* SyntaxKind.ForStatement */:
- case 239 /* SyntaxKind.IfStatement */:
- case 256 /* SyntaxKind.FunctionDeclaration */:
- case 213 /* SyntaxKind.FunctionExpression */:
- case 169 /* SyntaxKind.MethodDeclaration */:
- case 171 /* SyntaxKind.Constructor */:
- case 172 /* SyntaxKind.GetAccessor */:
- case 173 /* SyntaxKind.SetAccessor */:
- return childKind !== 235 /* SyntaxKind.Block */;
- case 214 /* SyntaxKind.ArrowFunction */:
- if (sourceFile && childKind === 212 /* SyntaxKind.ParenthesizedExpression */) {
+ case 243 /* SyntaxKind.DoStatement */:
+ case 244 /* SyntaxKind.WhileStatement */:
+ case 246 /* SyntaxKind.ForInStatement */:
+ case 247 /* SyntaxKind.ForOfStatement */:
+ case 245 /* SyntaxKind.ForStatement */:
+ case 242 /* SyntaxKind.IfStatement */:
+ case 259 /* SyntaxKind.FunctionDeclaration */:
+ case 215 /* SyntaxKind.FunctionExpression */:
+ case 171 /* SyntaxKind.MethodDeclaration */:
+ case 173 /* SyntaxKind.Constructor */:
+ case 174 /* SyntaxKind.GetAccessor */:
+ case 175 /* SyntaxKind.SetAccessor */:
+ return childKind !== 238 /* SyntaxKind.Block */;
+ case 216 /* SyntaxKind.ArrowFunction */:
+ if (sourceFile && childKind === 214 /* SyntaxKind.ParenthesizedExpression */) {
return rangeIsOnOneLine(sourceFile, child);
}
- return childKind !== 235 /* SyntaxKind.Block */;
- case 272 /* SyntaxKind.ExportDeclaration */:
- return childKind !== 273 /* SyntaxKind.NamedExports */;
- case 266 /* SyntaxKind.ImportDeclaration */:
- return childKind !== 267 /* SyntaxKind.ImportClause */ ||
- (!!child.namedBindings && child.namedBindings.kind !== 269 /* SyntaxKind.NamedImports */);
- case 278 /* SyntaxKind.JsxElement */:
- return childKind !== 281 /* SyntaxKind.JsxClosingElement */;
- case 282 /* SyntaxKind.JsxFragment */:
- return childKind !== 284 /* SyntaxKind.JsxClosingFragment */;
- case 188 /* SyntaxKind.IntersectionType */:
- case 187 /* SyntaxKind.UnionType */:
- if (childKind === 182 /* SyntaxKind.TypeLiteral */ || childKind === 184 /* SyntaxKind.TupleType */) {
+ return childKind !== 238 /* SyntaxKind.Block */;
+ case 275 /* SyntaxKind.ExportDeclaration */:
+ return childKind !== 276 /* SyntaxKind.NamedExports */;
+ case 269 /* SyntaxKind.ImportDeclaration */:
+ return childKind !== 270 /* SyntaxKind.ImportClause */ ||
+ (!!child.namedBindings && child.namedBindings.kind !== 272 /* SyntaxKind.NamedImports */);
+ case 281 /* SyntaxKind.JsxElement */:
+ return childKind !== 284 /* SyntaxKind.JsxClosingElement */;
+ case 285 /* SyntaxKind.JsxFragment */:
+ return childKind !== 287 /* SyntaxKind.JsxClosingFragment */;
+ case 190 /* SyntaxKind.IntersectionType */:
+ case 189 /* SyntaxKind.UnionType */:
+ if (childKind === 184 /* SyntaxKind.TypeLiteral */ || childKind === 186 /* SyntaxKind.TupleType */) {
return false;
}
break;
@@ -438213,11 +439556,11 @@ var ts;
SmartIndenter.nodeWillIndentChild = nodeWillIndentChild;
function isControlFlowEndingStatement(kind, parent) {
switch (kind) {
- case 247 /* SyntaxKind.ReturnStatement */:
- case 251 /* SyntaxKind.ThrowStatement */:
- case 245 /* SyntaxKind.ContinueStatement */:
- case 246 /* SyntaxKind.BreakStatement */:
- return parent.kind !== 235 /* SyntaxKind.Block */;
+ case 250 /* SyntaxKind.ReturnStatement */:
+ case 254 /* SyntaxKind.ThrowStatement */:
+ case 248 /* SyntaxKind.ContinueStatement */:
+ case 249 /* SyntaxKind.BreakStatement */:
+ return parent.kind !== 238 /* SyntaxKind.Block */;
default:
return false;
}
@@ -438434,7 +439777,7 @@ var ts;
* Checks if 'candidate' argument is a legal separator in the list that contains 'node' as an element
*/
function isSeparator(node, candidate) {
- return !!candidate && !!node.parent && (candidate.kind === 27 /* SyntaxKind.CommaToken */ || (candidate.kind === 26 /* SyntaxKind.SemicolonToken */ && node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */));
+ return !!candidate && !!node.parent && (candidate.kind === 27 /* SyntaxKind.CommaToken */ || (candidate.kind === 26 /* SyntaxKind.SemicolonToken */ && node.parent.kind === 207 /* SyntaxKind.ObjectLiteralExpression */));
}
function isThisTypeAnnotatable(containingFunction) {
return ts.isFunctionExpression(containingFunction) || ts.isFunctionDeclaration(containingFunction);
@@ -438666,7 +440009,7 @@ var ts;
}
}
else {
- endNode = (_a = (node.kind === 254 /* SyntaxKind.VariableDeclaration */ ? node.exclamationToken : node.questionToken)) !== null && _a !== void 0 ? _a : node.name;
+ endNode = (_a = (node.kind === 257 /* SyntaxKind.VariableDeclaration */ ? node.exclamationToken : node.questionToken)) !== null && _a !== void 0 ? _a : node.name;
}
this.insertNodeAt(sourceFile, endNode.end, type, { prefix: ": " });
return true;
@@ -438832,18 +440175,18 @@ var ts;
};
ChangeTracker.prototype.getInsertNodeAfterOptionsWorker = function (node) {
switch (node.kind) {
- case 257 /* SyntaxKind.ClassDeclaration */:
- case 261 /* SyntaxKind.ModuleDeclaration */:
+ case 260 /* SyntaxKind.ClassDeclaration */:
+ case 264 /* SyntaxKind.ModuleDeclaration */:
return { prefix: this.newLineCharacter, suffix: this.newLineCharacter };
- case 254 /* SyntaxKind.VariableDeclaration */:
+ case 257 /* SyntaxKind.VariableDeclaration */:
case 10 /* SyntaxKind.StringLiteral */:
case 79 /* SyntaxKind.Identifier */:
return { prefix: ", " };
- case 296 /* SyntaxKind.PropertyAssignment */:
+ case 299 /* SyntaxKind.PropertyAssignment */:
return { suffix: "," + this.newLineCharacter };
case 93 /* SyntaxKind.ExportKeyword */:
return { prefix: " " };
- case 164 /* SyntaxKind.Parameter */:
+ case 166 /* SyntaxKind.Parameter */:
return {};
default:
ts.Debug.assert(ts.isStatement(node) || ts.isClassOrTypeElement(node)); // Else we haven't handled this kind of node yet -- add it
@@ -438852,7 +440195,7 @@ var ts;
};
ChangeTracker.prototype.insertName = function (sourceFile, node, name) {
ts.Debug.assert(!node.name);
- if (node.kind === 214 /* SyntaxKind.ArrowFunction */) {
+ if (node.kind === 216 /* SyntaxKind.ArrowFunction */) {
var arrow = ts.findChildOfKind(node, 38 /* SyntaxKind.EqualsGreaterThanToken */, sourceFile);
var lparen = ts.findChildOfKind(node, 20 /* SyntaxKind.OpenParenToken */, sourceFile);
if (lparen) {
@@ -438866,14 +440209,14 @@ var ts;
// Replacing full range of arrow to get rid of the leading space -- replace ` =>` with `)`
this.replaceRange(sourceFile, arrow, ts.factory.createToken(21 /* SyntaxKind.CloseParenToken */));
}
- if (node.body.kind !== 235 /* SyntaxKind.Block */) {
+ if (node.body.kind !== 238 /* SyntaxKind.Block */) {
// `() => 0` => `function f() { return 0; }`
this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.factory.createToken(18 /* SyntaxKind.OpenBraceToken */), ts.factory.createToken(105 /* SyntaxKind.ReturnKeyword */)], { joiner: " ", suffix: " " });
this.insertNodesAt(sourceFile, node.body.end, [ts.factory.createToken(26 /* SyntaxKind.SemicolonToken */), ts.factory.createToken(19 /* SyntaxKind.CloseBraceToken */)], { joiner: " " });
}
}
else {
- var pos = ts.findChildOfKind(node, node.kind === 213 /* SyntaxKind.FunctionExpression */ ? 98 /* SyntaxKind.FunctionKeyword */ : 84 /* SyntaxKind.ClassKeyword */, sourceFile).end;
+ var pos = ts.findChildOfKind(node, node.kind === 215 /* SyntaxKind.FunctionExpression */ ? 98 /* SyntaxKind.FunctionKeyword */ : 84 /* SyntaxKind.ClassKeyword */, sourceFile).end;
this.insertNodeAt(sourceFile, pos, ts.factory.createIdentifier(name), { prefix: " " });
}
};
@@ -439050,10 +440393,10 @@ var ts;
}());
textChanges_3.ChangeTracker = ChangeTracker;
function updateJSDocHost(parent) {
- if (parent.kind !== 214 /* SyntaxKind.ArrowFunction */) {
+ if (parent.kind !== 216 /* SyntaxKind.ArrowFunction */) {
return parent;
}
- var jsDocNode = parent.parent.kind === 167 /* SyntaxKind.PropertyDeclaration */ ?
+ var jsDocNode = parent.parent.kind === 169 /* SyntaxKind.PropertyDeclaration */ ?
parent.parent :
parent.parent.parent;
jsDocNode.jsDoc = parent.jsDoc;
@@ -439065,16 +440408,16 @@ var ts;
return undefined;
}
switch (oldTag.kind) {
- case 340 /* SyntaxKind.JSDocParameterTag */: {
+ case 343 /* SyntaxKind.JSDocParameterTag */: {
var oldParam = oldTag;
var newParam = newTag;
return ts.isIdentifier(oldParam.name) && ts.isIdentifier(newParam.name) && oldParam.name.escapedText === newParam.name.escapedText
? ts.factory.createJSDocParameterTag(/*tagName*/ undefined, newParam.name, /*isBracketed*/ false, newParam.typeExpression, newParam.isNameFirst, oldParam.comment)
: undefined;
}
- case 341 /* SyntaxKind.JSDocReturnTag */:
+ case 344 /* SyntaxKind.JSDocReturnTag */:
return ts.factory.createJSDocReturnTag(/*tagName*/ undefined, newTag.typeExpression, oldTag.comment);
- case 343 /* SyntaxKind.JSDocTypeTag */:
+ case 346 /* SyntaxKind.JSDocTypeTag */:
return ts.factory.createJSDocTypeTag(/*tagName*/ undefined, newTag.typeExpression, oldTag.comment);
}
}
@@ -439082,6 +440425,26 @@ var ts;
function startPositionToDeleteNodeInList(sourceFile, node) {
return ts.skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, node, { leadingTriviaOption: LeadingTriviaOption.IncludeAll }), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true);
}
+ function endPositionToDeleteNodeInList(sourceFile, node, prevNode, nextNode) {
+ var end = startPositionToDeleteNodeInList(sourceFile, nextNode);
+ if (prevNode === undefined || ts.positionsAreOnSameLine(getAdjustedEndPosition(sourceFile, node, {}), end, sourceFile)) {
+ return end;
+ }
+ var token = ts.findPrecedingToken(nextNode.getStart(sourceFile), sourceFile);
+ if (isSeparator(node, token)) {
+ var prevToken = ts.findPrecedingToken(node.getStart(sourceFile), sourceFile);
+ if (isSeparator(prevNode, prevToken)) {
+ var pos = ts.skipTrivia(sourceFile.text, token.getEnd(), /*stopAfterLineBreak*/ true, /*stopAtComments*/ true);
+ if (ts.positionsAreOnSameLine(prevToken.getStart(sourceFile), token.getStart(sourceFile), sourceFile)) {
+ return ts.isLineBreak(sourceFile.text.charCodeAt(pos - 1)) ? pos - 1 : pos;
+ }
+ if (ts.isLineBreak(sourceFile.text.charCodeAt(pos))) {
+ return pos;
+ }
+ }
+ }
+ return end;
+ }
function getClassOrObjectBraceEnds(cls, sourceFile) {
var open = ts.findChildOfKind(cls, 18 /* SyntaxKind.OpenBraceToken */, sourceFile);
var close = ts.findChildOfKind(cls, 19 /* SyntaxKind.CloseBraceToken */, sourceFile);
@@ -439468,14 +440831,14 @@ var ts;
}
textChanges_3.isValidLocationToAddComment = isValidLocationToAddComment;
function needSemicolonBetween(a, b) {
- return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 162 /* SyntaxKind.ComputedPropertyName */
+ return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 164 /* SyntaxKind.ComputedPropertyName */
|| ts.isStatementButNotDeclaration(a) && ts.isStatementButNotDeclaration(b); // TODO: only if b would start with a `(` or `[`
}
var deleteDeclaration;
(function (deleteDeclaration_1) {
function deleteDeclaration(changes, deletedNodesInLists, sourceFile, node) {
switch (node.kind) {
- case 164 /* SyntaxKind.Parameter */: {
+ case 166 /* SyntaxKind.Parameter */: {
var oldFunction = node.parent;
if (ts.isArrowFunction(oldFunction) &&
oldFunction.parameters.length === 1 &&
@@ -439490,17 +440853,17 @@ var ts;
}
break;
}
- case 266 /* SyntaxKind.ImportDeclaration */:
- case 265 /* SyntaxKind.ImportEqualsDeclaration */:
+ case 269 /* SyntaxKind.ImportDeclaration */:
+ case 268 /* SyntaxKind.ImportEqualsDeclaration */:
var isFirstImport = sourceFile.imports.length && node === ts.first(sourceFile.imports).parent || node === ts.find(sourceFile.statements, ts.isAnyImportSyntax);
// For first import, leave header comment in place, otherwise only delete JSDoc comments
deleteNode(changes, sourceFile, node, {
leadingTriviaOption: isFirstImport ? LeadingTriviaOption.Exclude : ts.hasJSDocNodes(node) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine,
});
break;
- case 203 /* SyntaxKind.BindingElement */:
+ case 205 /* SyntaxKind.BindingElement */:
var pattern = node.parent;
- var preserveComma = pattern.kind === 202 /* SyntaxKind.ArrayBindingPattern */ && node !== ts.last(pattern.elements);
+ var preserveComma = pattern.kind === 204 /* SyntaxKind.ArrayBindingPattern */ && node !== ts.last(pattern.elements);
if (preserveComma) {
deleteNode(changes, sourceFile, node);
}
@@ -439508,13 +440871,13 @@ var ts;
deleteNodeInList(changes, deletedNodesInLists, sourceFile, node);
}
break;
- case 254 /* SyntaxKind.VariableDeclaration */:
+ case 257 /* SyntaxKind.VariableDeclaration */:
deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node);
break;
- case 163 /* SyntaxKind.TypeParameter */:
+ case 165 /* SyntaxKind.TypeParameter */:
deleteNodeInList(changes, deletedNodesInLists, sourceFile, node);
break;
- case 270 /* SyntaxKind.ImportSpecifier */:
+ case 273 /* SyntaxKind.ImportSpecifier */:
var namedImports = node.parent;
if (namedImports.elements.length === 1) {
deleteImportBinding(changes, sourceFile, namedImports);
@@ -439523,7 +440886,7 @@ var ts;
deleteNodeInList(changes, deletedNodesInLists, sourceFile, node);
}
break;
- case 268 /* SyntaxKind.NamespaceImport */:
+ case 271 /* SyntaxKind.NamespaceImport */:
deleteImportBinding(changes, sourceFile, node);
break;
case 26 /* SyntaxKind.SemicolonToken */:
@@ -439532,8 +440895,8 @@ var ts;
case 98 /* SyntaxKind.FunctionKeyword */:
deleteNode(changes, sourceFile, node, { leadingTriviaOption: LeadingTriviaOption.Exclude });
break;
- case 257 /* SyntaxKind.ClassDeclaration */:
- case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 260 /* SyntaxKind.ClassDeclaration */:
+ case 259 /* SyntaxKind.FunctionDeclaration */:
deleteNode(changes, sourceFile, node, { leadingTriviaOption: ts.hasJSDocNodes(node) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine });
break;
default:
@@ -439584,13 +440947,13 @@ var ts;
// Delete the entire import declaration
// |import * as ns from './file'|
// |import { a } from './file'|
- var importDecl = ts.getAncestor(node, 266 /* SyntaxKind.ImportDeclaration */);
+ var importDecl = ts.getAncestor(node, 269 /* SyntaxKind.ImportDeclaration */);
deleteNode(changes, sourceFile, importDecl);
}
}
function deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node) {
var parent = node.parent;
- if (parent.kind === 292 /* SyntaxKind.CatchClause */) {
+ if (parent.kind === 295 /* SyntaxKind.CatchClause */) {
// TODO: There's currently no unused diagnostic for this, could be a suggestion
changes.deleteNodeRange(sourceFile, ts.findChildOfKind(parent, 20 /* SyntaxKind.OpenParenToken */, sourceFile), ts.findChildOfKind(parent, 21 /* SyntaxKind.CloseParenToken */, sourceFile));
return;
@@ -439601,14 +440964,14 @@ var ts;
}
var gp = parent.parent;
switch (gp.kind) {
- case 244 /* SyntaxKind.ForOfStatement */:
- case 243 /* SyntaxKind.ForInStatement */:
+ case 247 /* SyntaxKind.ForOfStatement */:
+ case 246 /* SyntaxKind.ForInStatement */:
changes.replaceNode(sourceFile, node, ts.factory.createObjectLiteralExpression());
break;
- case 242 /* SyntaxKind.ForStatement */:
+ case 245 /* SyntaxKind.ForStatement */:
deleteNode(changes, sourceFile, parent);
break;
- case 237 /* SyntaxKind.VariableStatement */:
+ case 240 /* SyntaxKind.VariableStatement */:
deleteNode(changes, sourceFile, gp, { leadingTriviaOption: ts.hasJSDocNodes(gp) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine });
break;
default:
@@ -439639,7 +441002,7 @@ var ts;
deletedNodesInLists.add(node);
changes.deleteRange(sourceFile, {
pos: startPositionToDeleteNodeInList(sourceFile, node),
- end: index === containingList.length - 1 ? getAdjustedEndPosition(sourceFile, node, {}) : startPositionToDeleteNodeInList(sourceFile, containingList[index + 1]),
+ end: index === containingList.length - 1 ? getAdjustedEndPosition(sourceFile, node, {}) : endPositionToDeleteNodeInList(sourceFile, node, containingList[index - 1], containingList[index + 1]),
});
}
})(textChanges = ts.textChanges || (ts.textChanges = {}));
@@ -439795,8 +441158,8 @@ var ts;
});
function makeChange(changeTracker, sourceFile, assertion) {
var replacement = ts.isAsExpression(assertion)
- ? ts.factory.createAsExpression(assertion.expression, ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */))
- : ts.factory.createTypeAssertion(ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */), assertion.expression);
+ ? ts.factory.createAsExpression(assertion.expression, ts.factory.createKeywordTypeNode(157 /* SyntaxKind.UnknownKeyword */))
+ : ts.factory.createTypeAssertion(ts.factory.createKeywordTypeNode(157 /* SyntaxKind.UnknownKeyword */), assertion.expression);
changeTracker.replaceNode(sourceFile, assertion.expression, replacement);
}
function getAssertion(sourceFile, pos) {
@@ -439880,7 +441243,7 @@ var ts;
}
}
fixedDeclarations === null || fixedDeclarations === void 0 ? void 0 : fixedDeclarations.add(ts.getNodeId(insertionSite));
- var cloneWithModifier = ts.factory.updateModifiers(ts.getSynthesizedDeepClone(insertionSite, /*includeTrivia*/ true), ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(ts.getSyntacticModifierFlags(insertionSite) | 256 /* ModifierFlags.Async */)));
+ var cloneWithModifier = ts.factory.updateModifiers(ts.getSynthesizedDeepClone(insertionSite, /*includeTrivia*/ true), ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(ts.getSyntacticModifierFlags(insertionSite) | 512 /* ModifierFlags.Async */)));
changeTracker.replaceNode(sourceFile, insertionSite, cloneWithModifier);
}
function getFixableErrorSpanDeclaration(sourceFile, span) {
@@ -439926,7 +441289,7 @@ var ts;
ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type.code,
ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1.code,
ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2.code,
- ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap.code,
+ ts.Diagnostics.This_comparison_appears_to_be_unintentional_because_the_types_0_and_1_have_no_overlap.code,
ts.Diagnostics.This_condition_will_always_return_true_since_this_0_is_always_defined.code,
ts.Diagnostics.Type_0_is_not_an_array_type.code,
ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type.code,
@@ -440024,7 +441387,7 @@ var ts;
}
var declaration = ts.tryCast(symbol.valueDeclaration, ts.isVariableDeclaration);
var variableName = declaration && ts.tryCast(declaration.name, ts.isIdentifier);
- var variableStatement = ts.getAncestor(declaration, 237 /* SyntaxKind.VariableStatement */);
+ var variableStatement = ts.getAncestor(declaration, 240 /* SyntaxKind.VariableStatement */);
if (!declaration || !variableStatement ||
declaration.type ||
!declaration.initializer ||
@@ -440102,13 +441465,22 @@ var ts;
function isInsideAwaitableBody(node) {
return node.kind & 32768 /* NodeFlags.AwaitContext */ || !!ts.findAncestor(node, function (ancestor) {
return ancestor.parent && ts.isArrowFunction(ancestor.parent) && ancestor.parent.body === ancestor ||
- ts.isBlock(ancestor) && (ancestor.parent.kind === 256 /* SyntaxKind.FunctionDeclaration */ ||
- ancestor.parent.kind === 213 /* SyntaxKind.FunctionExpression */ ||
- ancestor.parent.kind === 214 /* SyntaxKind.ArrowFunction */ ||
- ancestor.parent.kind === 169 /* SyntaxKind.MethodDeclaration */);
+ ts.isBlock(ancestor) && (ancestor.parent.kind === 259 /* SyntaxKind.FunctionDeclaration */ ||
+ ancestor.parent.kind === 215 /* SyntaxKind.FunctionExpression */ ||
+ ancestor.parent.kind === 216 /* SyntaxKind.ArrowFunction */ ||
+ ancestor.parent.kind === 171 /* SyntaxKind.MethodDeclaration */);
});
}
function makeChange(changeTracker, errorCode, sourceFile, checker, insertionSite, fixedDeclarations) {
+ if (ts.isForOfStatement(insertionSite.parent) && !insertionSite.parent.awaitModifier) {
+ var exprType = checker.getTypeAtLocation(insertionSite);
+ var asyncIter = checker.getAsyncIterableType();
+ if (asyncIter && checker.isTypeAssignableTo(exprType, asyncIter)) {
+ var forOf = insertionSite.parent;
+ changeTracker.replaceNode(sourceFile, forOf, ts.factory.updateForOfStatement(forOf, ts.factory.createToken(133 /* SyntaxKind.AwaitKeyword */), forOf.initializer, forOf.expression, forOf.statement));
+ return;
+ }
+ }
if (ts.isBinaryExpression(insertionSite)) {
for (var _i = 0, _a = [insertionSite.left, insertionSite.right]; _i < _a.length; _i++) {
var side = _a[_i];
@@ -440224,10 +441596,10 @@ var ts;
function isPossiblyPartOfDestructuring(node) {
switch (node.kind) {
case 79 /* SyntaxKind.Identifier */:
- case 204 /* SyntaxKind.ArrayLiteralExpression */:
- case 205 /* SyntaxKind.ObjectLiteralExpression */:
- case 296 /* SyntaxKind.PropertyAssignment */:
- case 297 /* SyntaxKind.ShorthandPropertyAssignment */:
+ case 206 /* SyntaxKind.ArrayLiteralExpression */:
+ case 207 /* SyntaxKind.ObjectLiteralExpression */:
+ case 299 /* SyntaxKind.PropertyAssignment */:
+ case 300 /* SyntaxKind.ShorthandPropertyAssignment */:
return true;
default:
return false;
@@ -440242,7 +441614,7 @@ var ts;
function isPossiblyPartOfCommaSeperatedInitializer(node) {
switch (node.kind) {
case 79 /* SyntaxKind.Identifier */:
- case 221 /* SyntaxKind.BinaryExpression */:
+ case 223 /* SyntaxKind.BinaryExpression */:
case 27 /* SyntaxKind.CommaToken */:
return true;
default:
@@ -440291,9 +441663,9 @@ var ts;
return;
}
var declaration = token.parent;
- if (declaration.kind === 167 /* SyntaxKind.PropertyDeclaration */ &&
+ if (declaration.kind === 169 /* SyntaxKind.PropertyDeclaration */ &&
(!fixedNodes || ts.tryAddToSet(fixedNodes, declaration))) {
- changeTracker.insertModifierBefore(sourceFile, 135 /* SyntaxKind.DeclareKeyword */, declaration);
+ changeTracker.insertModifierBefore(sourceFile, 136 /* SyntaxKind.DeclareKeyword */, declaration);
}
}
})(codefix = ts.codefix || (ts.codefix = {}));
@@ -440447,7 +441819,7 @@ var ts;
var add = toAdd_1[_i];
var d = add.valueDeclaration;
if (d && (ts.isPropertySignature(d) || ts.isPropertyDeclaration(d)) && d.type) {
- var t = ts.factory.createUnionTypeNode(__spreadArray(__spreadArray([], d.type.kind === 187 /* SyntaxKind.UnionType */ ? d.type.types : [d.type], true), [
+ var t = ts.factory.createUnionTypeNode(__spreadArray(__spreadArray([], d.type.kind === 189 /* SyntaxKind.UnionType */ ? d.type.types : [d.type], true), [
ts.factory.createTypeReferenceNode("undefined")
], false));
changes.replaceNode(d.getSourceFile(), d.type, t);
@@ -440527,26 +441899,26 @@ var ts;
}
function isDeclarationWithType(node) {
return ts.isFunctionLikeDeclaration(node) ||
- node.kind === 254 /* SyntaxKind.VariableDeclaration */ ||
- node.kind === 166 /* SyntaxKind.PropertySignature */ ||
- node.kind === 167 /* SyntaxKind.PropertyDeclaration */;
+ node.kind === 257 /* SyntaxKind.VariableDeclaration */ ||
+ node.kind === 168 /* SyntaxKind.PropertySignature */ ||
+ node.kind === 169 /* SyntaxKind.PropertyDeclaration */;
}
function transformJSDocType(node) {
switch (node.kind) {
- case 312 /* SyntaxKind.JSDocAllType */:
- case 313 /* SyntaxKind.JSDocUnknownType */:
+ case 315 /* SyntaxKind.JSDocAllType */:
+ case 316 /* SyntaxKind.JSDocUnknownType */:
return ts.factory.createTypeReferenceNode("any", ts.emptyArray);
- case 316 /* SyntaxKind.JSDocOptionalType */:
+ case 319 /* SyntaxKind.JSDocOptionalType */:
return transformJSDocOptionalType(node);
- case 315 /* SyntaxKind.JSDocNonNullableType */:
+ case 318 /* SyntaxKind.JSDocNonNullableType */:
return transformJSDocType(node.type);
- case 314 /* SyntaxKind.JSDocNullableType */:
+ case 317 /* SyntaxKind.JSDocNullableType */:
return transformJSDocNullableType(node);
- case 318 /* SyntaxKind.JSDocVariadicType */:
+ case 321 /* SyntaxKind.JSDocVariadicType */:
return transformJSDocVariadicType(node);
- case 317 /* SyntaxKind.JSDocFunctionType */:
+ case 320 /* SyntaxKind.JSDocFunctionType */:
return transformJSDocFunctionType(node);
- case 178 /* SyntaxKind.TypeReference */:
+ case 180 /* SyntaxKind.TypeReference */:
return transformJSDocTypeReference(node);
default:
var visited = ts.visitEachChild(node, transformJSDocType, ts.nullTransformationContext);
@@ -440567,11 +441939,11 @@ var ts;
var _a;
// TODO: This does not properly handle `function(new:C, string)` per https://github.com/google/closure-compiler/wiki/Types-in-the-Closure-Type-System#the-javascript-type-language
// however we do handle it correctly in `serializeTypeForDeclaration` in checker.ts
- return ts.factory.createFunctionTypeNode(ts.emptyArray, node.parameters.map(transformJSDocParameter), (_a = node.type) !== null && _a !== void 0 ? _a : ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */));
+ return ts.factory.createFunctionTypeNode(ts.emptyArray, node.parameters.map(transformJSDocParameter), (_a = node.type) !== null && _a !== void 0 ? _a : ts.factory.createKeywordTypeNode(131 /* SyntaxKind.AnyKeyword */));
}
function transformJSDocParameter(node) {
var index = node.parent.parameters.indexOf(node);
- var isRest = node.type.kind === 318 /* SyntaxKind.JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217
+ var isRest = node.type.kind === 321 /* SyntaxKind.JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217
var name = node.name || (isRest ? "rest" : "arg" + index);
var dotdotdot = isRest ? ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */) : node.dotDotDotToken;
return ts.factory.createParameterDeclaration(node.modifiers, dotdotdot, name, node.questionToken, ts.visitNode(node.type, transformJSDocType), node.initializer);
@@ -440610,8 +441982,8 @@ var ts;
function transformJSDocIndexSignature(node) {
var index = ts.factory.createParameterDeclaration(
/*modifiers*/ undefined,
- /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 147 /* SyntaxKind.NumberKeyword */ ? "n" : "s",
- /*questionToken*/ undefined, ts.factory.createTypeReferenceNode(node.typeArguments[0].kind === 147 /* SyntaxKind.NumberKeyword */ ? "number" : "string", []),
+ /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 148 /* SyntaxKind.NumberKeyword */ ? "n" : "s",
+ /*questionToken*/ undefined, ts.factory.createTypeReferenceNode(node.typeArguments[0].kind === 148 /* SyntaxKind.NumberKeyword */ ? "number" : "string", []),
/*initializer*/ undefined);
var indexSignature = ts.factory.createTypeLiteralNode([ts.factory.createIndexSignature(/*modifiers*/ undefined, [index], node.typeArguments[1])]);
ts.setEmitFlags(indexSignature, 1 /* EmitFlags.SingleLine */);
@@ -440646,8 +442018,8 @@ var ts;
return undefined;
}
var ctorDeclaration = ctorSymbol.valueDeclaration;
- if (ts.isFunctionDeclaration(ctorDeclaration)) {
- changes.replaceNode(sourceFile, ctorDeclaration, createClassFromFunctionDeclaration(ctorDeclaration));
+ if (ts.isFunctionDeclaration(ctorDeclaration) || ts.isFunctionExpression(ctorDeclaration)) {
+ changes.replaceNode(sourceFile, ctorDeclaration, createClassFromFunction(ctorDeclaration));
}
else if (ts.isVariableDeclaration(ctorDeclaration)) {
var classDeclaration = createClassFromVariableDeclaration(ctorDeclaration);
@@ -440751,7 +442123,7 @@ var ts;
return;
}
// delete the entire statement if this expression is the sole expression to take care of the semicolon at the end
- var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 238 /* SyntaxKind.ExpressionStatement */
+ var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 241 /* SyntaxKind.ExpressionStatement */
? assignmentBinaryExpression.parent : assignmentBinaryExpression;
changes.delete(sourceFile, nodeToDelete);
if (!assignmentExpr) {
@@ -440803,7 +442175,7 @@ var ts;
return createArrowFunctionExpressionMember(members, expression, name);
}
function createFunctionExpressionMember(members, functionExpression, name) {
- var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 131 /* SyntaxKind.AsyncKeyword */));
+ var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 132 /* SyntaxKind.AsyncKeyword */));
var method = ts.factory.createMethodDeclaration(fullModifiers, /*asteriskToken*/ undefined, name, /*questionToken*/ undefined,
/*typeParameters*/ undefined, functionExpression.parameters, /*type*/ undefined, functionExpression.body);
ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile);
@@ -440814,14 +442186,14 @@ var ts;
var arrowFunctionBody = arrowFunction.body;
var bodyBlock;
// case 1: () => { return [1,2,3] }
- if (arrowFunctionBody.kind === 235 /* SyntaxKind.Block */) {
+ if (arrowFunctionBody.kind === 238 /* SyntaxKind.Block */) {
bodyBlock = arrowFunctionBody;
}
// case 2: () => [1,2,3]
else {
bodyBlock = ts.factory.createBlock([ts.factory.createReturnStatement(arrowFunctionBody)]);
}
- var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 131 /* SyntaxKind.AsyncKeyword */));
+ var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 132 /* SyntaxKind.AsyncKeyword */));
var method = ts.factory.createMethodDeclaration(fullModifiers, /*asteriskToken*/ undefined, name, /*questionToken*/ undefined,
/*typeParameters*/ undefined, arrowFunction.parameters, /*type*/ undefined, bodyBlock);
ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile);
@@ -440844,7 +442216,7 @@ var ts;
// Don't call copyComments here because we'll already leave them in place
return cls;
}
- function createClassFromFunctionDeclaration(node) {
+ function createClassFromFunction(node) {
var memberElements = createClassElementsFromSymbol(ctorSymbol);
if (node.body) {
memberElements.unshift(ts.factory.createConstructorDeclaration(/*modifiers*/ undefined, node.parameters, node.body));
@@ -440934,7 +442306,7 @@ var ts;
return;
}
var pos = ts.skipTrivia(sourceFile.text, ts.moveRangePastModifiers(functionToConvert).pos);
- changes.insertModifierAt(sourceFile, pos, 131 /* SyntaxKind.AsyncKeyword */, { suffix: " " });
+ changes.insertModifierAt(sourceFile, pos, 132 /* SyntaxKind.AsyncKeyword */, { suffix: " " });
var _loop_12 = function (returnStatement) {
ts.forEachChild(returnStatement, function visit(node) {
if (ts.isCallExpression(node)) {
@@ -441340,7 +442712,7 @@ var ts;
case 104 /* SyntaxKind.NullKeyword */:
// do not produce a transformed statement for a null argument
break;
- case 206 /* SyntaxKind.PropertyAccessExpression */:
+ case 208 /* SyntaxKind.PropertyAccessExpression */:
case 79 /* SyntaxKind.Identifier */: // identifier includes undefined
if (!inputArgName) {
// undefined was argument passed to promise handler
@@ -441362,8 +442734,8 @@ var ts;
continuationArgName.types.push(transformer.checker.getAwaitedType(returnType) || returnType);
}
return varDeclOrAssignment;
- case 213 /* SyntaxKind.FunctionExpression */:
- case 214 /* SyntaxKind.ArrowFunction */: {
+ case 215 /* SyntaxKind.FunctionExpression */:
+ case 216 /* SyntaxKind.ArrowFunction */: {
var funcBody = func.body;
var returnType_1 = (_a = getLastCallSignature(transformer.checker.getTypeAtLocation(func), transformer.checker)) === null || _a === void 0 ? void 0 : _a.getReturnType();
// Arrow functions with block bodies { } will enter this control flow
@@ -441532,7 +442904,7 @@ var ts;
name = getMapEntryOrDefault(funcNode.name);
}
// return undefined argName when arg is null or undefined
- // eslint-disable-next-line no-in-operator
+ // eslint-disable-next-line local/no-in-operator
if (!name || "identifier" in name && name.identifier.text === "undefined") {
return undefined;
}
@@ -441641,10 +443013,10 @@ var ts;
}
var importNode = ts.importFromModuleSpecifier(moduleSpecifier);
switch (importNode.kind) {
- case 265 /* SyntaxKind.ImportEqualsDeclaration */:
+ case 268 /* SyntaxKind.ImportEqualsDeclaration */:
changes.replaceNode(importingFile, importNode, ts.makeImport(importNode.name, /*namedImports*/ undefined, moduleSpecifier, quotePreference));
break;
- case 208 /* SyntaxKind.CallExpression */:
+ case 210 /* SyntaxKind.CallExpression */:
if (ts.isRequireCall(importNode, /*checkArgumentIsStringLiteralLike*/ false)) {
changes.replaceNode(importingFile, importNode, ts.factory.createPropertyAccessExpression(ts.getSynthesizedDeepClone(importNode), "default"));
}
@@ -441711,20 +443083,20 @@ var ts;
}
function convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports, useSitesToUnqualify, quotePreference) {
switch (statement.kind) {
- case 237 /* SyntaxKind.VariableStatement */:
+ case 240 /* SyntaxKind.VariableStatement */:
convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target, quotePreference);
return false;
- case 238 /* SyntaxKind.ExpressionStatement */: {
+ case 241 /* SyntaxKind.ExpressionStatement */: {
var expression = statement.expression;
switch (expression.kind) {
- case 208 /* SyntaxKind.CallExpression */: {
+ case 210 /* SyntaxKind.CallExpression */: {
if (ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true)) {
// For side-effecting require() call, just make a side-effecting import.
changes.replaceNode(sourceFile, statement, ts.makeImport(/*name*/ undefined, /*namedImports*/ undefined, expression.arguments[0], quotePreference));
}
return false;
}
- case 221 /* SyntaxKind.BinaryExpression */: {
+ case 223 /* SyntaxKind.BinaryExpression */: {
var operatorToken = expression.operatorToken;
return operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports, useSitesToUnqualify);
}
@@ -441773,8 +443145,8 @@ var ts;
/** Converts `const name = require("moduleSpecifier").propertyName` */
function convertPropertyAccessImport(name, propertyName, moduleSpecifier, identifiers, quotePreference) {
switch (name.kind) {
- case 201 /* SyntaxKind.ObjectBindingPattern */:
- case 202 /* SyntaxKind.ArrayBindingPattern */: {
+ case 203 /* SyntaxKind.ObjectBindingPattern */:
+ case 204 /* SyntaxKind.ArrayBindingPattern */: {
// `const [a, b] = require("c").d` --> `import { d } from "c"; const [a, b] = d;`
var tmp = makeUniqueName(propertyName, identifiers);
return convertedImports([
@@ -441825,16 +443197,16 @@ var ts;
function tryChangeModuleExportsObject(object, useSitesToUnqualify) {
var statements = ts.mapAllOrFail(object.properties, function (prop) {
switch (prop.kind) {
- case 172 /* SyntaxKind.GetAccessor */:
- case 173 /* SyntaxKind.SetAccessor */:
+ case 174 /* SyntaxKind.GetAccessor */:
+ case 175 /* SyntaxKind.SetAccessor */:
// TODO: Maybe we should handle this? See fourslash test `refactorConvertToEs6Module_export_object_shorthand.ts`.
// falls through
- case 297 /* SyntaxKind.ShorthandPropertyAssignment */:
- case 298 /* SyntaxKind.SpreadAssignment */:
+ case 300 /* SyntaxKind.ShorthandPropertyAssignment */:
+ case 301 /* SyntaxKind.SpreadAssignment */:
return undefined;
- case 296 /* SyntaxKind.PropertyAssignment */:
+ case 299 /* SyntaxKind.PropertyAssignment */:
return !ts.isIdentifier(prop.name) ? undefined : convertExportsDotXEquals_replaceNode(prop.name.text, prop.initializer, useSitesToUnqualify);
- case 169 /* SyntaxKind.MethodDeclaration */:
+ case 171 /* SyntaxKind.MethodDeclaration */:
return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.factory.createToken(93 /* SyntaxKind.ExportKeyword */)], prop, useSitesToUnqualify);
default:
ts.Debug.assertNever(prop, "Convert to ES6 got invalid prop kind ".concat(prop.kind));
@@ -441898,7 +443270,7 @@ var ts;
function convertExportsDotXEquals_replaceNode(name, exported, useSitesToUnqualify) {
var modifiers = [ts.factory.createToken(93 /* SyntaxKind.ExportKeyword */)];
switch (exported.kind) {
- case 213 /* SyntaxKind.FunctionExpression */: {
+ case 215 /* SyntaxKind.FunctionExpression */: {
var expressionName = exported.name;
if (expressionName && expressionName.text !== name) {
// `exports.f = function g() {}` -> `export const f = function g() {}`
@@ -441906,10 +443278,10 @@ var ts;
}
}
// falls through
- case 214 /* SyntaxKind.ArrowFunction */:
+ case 216 /* SyntaxKind.ArrowFunction */:
// `exports.f = function() {}` --> `export function f() {}`
return functionExpressionToDeclaration(name, modifiers, exported, useSitesToUnqualify);
- case 226 /* SyntaxKind.ClassExpression */:
+ case 228 /* SyntaxKind.ClassExpression */:
// `exports.C = class {}` --> `export class C {}`
return classExpressionToDeclaration(name, modifiers, exported, useSitesToUnqualify);
default:
@@ -441929,7 +443301,7 @@ var ts;
: ts.getSynthesizedDeepCloneWithReplacements(nodeOrNodes, /*includeTrivia*/ true, replaceNode);
function replaceNode(original) {
// We are replacing `mod.SomeExport` wih `SomeExport`, so we only need to look at PropertyAccessExpressions
- if (original.kind === 206 /* SyntaxKind.PropertyAccessExpression */) {
+ if (original.kind === 208 /* SyntaxKind.PropertyAccessExpression */) {
var replacement = useSitesToUnqualify.get(original);
// Remove entry from `useSitesToUnqualify` so the refactor knows it's taken care of by the parent statement we're replacing
useSitesToUnqualify.delete(original);
@@ -441944,7 +443316,7 @@ var ts;
*/
function convertSingleImport(name, moduleSpecifier, checker, identifiers, target, quotePreference) {
switch (name.kind) {
- case 201 /* SyntaxKind.ObjectBindingPattern */: {
+ case 203 /* SyntaxKind.ObjectBindingPattern */: {
var importSpecifiers = ts.mapAllOrFail(name.elements, function (e) {
return e.dotDotDotToken || e.initializer || e.propertyName && !ts.isIdentifier(e.propertyName) || !ts.isIdentifier(e.name)
? undefined
@@ -441955,7 +443327,7 @@ var ts;
}
}
// falls through -- object destructuring has an interesting pattern and must be a variable declaration
- case 202 /* SyntaxKind.ArrayBindingPattern */: {
+ case 204 /* SyntaxKind.ArrayBindingPattern */: {
/*
import x from "x";
const [a, b, c] = x;
@@ -442048,11 +443420,11 @@ var ts;
function isFreeIdentifier(node) {
var parent = node.parent;
switch (parent.kind) {
- case 206 /* SyntaxKind.PropertyAccessExpression */:
+ case 208 /* SyntaxKind.PropertyAccessExpression */:
return parent.name !== node;
- case 203 /* SyntaxKind.BindingElement */:
+ case 205 /* SyntaxKind.BindingElement */:
return parent.propertyName !== node;
- case 270 /* SyntaxKind.ImportSpecifier */:
+ case 273 /* SyntaxKind.ImportSpecifier */:
return parent.propertyName !== node;
default:
return true;
@@ -442163,7 +443535,7 @@ var ts;
var exportDeclaration = exportClause.parent;
var typeExportSpecifiers = getTypeExportSpecifiers(exportSpecifier, context);
if (typeExportSpecifiers.length === exportClause.elements.length) {
- changes.insertModifierBefore(context.sourceFile, 152 /* SyntaxKind.TypeKeyword */, exportClause);
+ changes.insertModifierBefore(context.sourceFile, 154 /* SyntaxKind.TypeKeyword */, exportClause);
}
else {
var valueExportDeclaration = ts.factory.updateExportDeclaration(exportDeclaration, exportDeclaration.modifiers,
@@ -442399,27 +443771,29 @@ var ts;
errorCodes: errorCodes,
getCodeActions: function (context) {
var errorCode = context.errorCode, preferences = context.preferences, sourceFile = context.sourceFile, span = context.span, program = context.program;
- var info = getFixesInfo(context, errorCode, span.start, /*useAutoImportProvider*/ true);
+ var info = getFixInfos(context, errorCode, span.start, /*useAutoImportProvider*/ true);
if (!info)
return undefined;
- var fixes = info.fixes, symbolName = info.symbolName, errorIdentifierText = info.errorIdentifierText;
var quotePreference = ts.getQuotePreference(sourceFile, preferences);
- return fixes.map(function (fix) { return codeActionForFix(context, sourceFile, symbolName, fix,
- /*includeSymbolNameInDescription*/ symbolName !== errorIdentifierText, quotePreference, program.getCompilerOptions()); });
+ return info.map(function (_a) {
+ var fix = _a.fix, symbolName = _a.symbolName, errorIdentifierText = _a.errorIdentifierText;
+ return codeActionForFix(context, sourceFile, symbolName, fix,
+ /*includeSymbolNameInDescription*/ symbolName !== errorIdentifierText, quotePreference, program.getCompilerOptions());
+ });
},
fixIds: [importFixId],
getAllCodeActions: function (context) {
- var sourceFile = context.sourceFile, program = context.program, preferences = context.preferences, host = context.host;
- var importAdder = createImportAdderWorker(sourceFile, program, /*useAutoImportProvider*/ true, preferences, host);
+ var sourceFile = context.sourceFile, program = context.program, preferences = context.preferences, host = context.host, cancellationToken = context.cancellationToken;
+ var importAdder = createImportAdderWorker(sourceFile, program, /*useAutoImportProvider*/ true, preferences, host, cancellationToken);
codefix.eachDiagnostic(context, errorCodes, function (diag) { return importAdder.addImportFromDiagnostic(diag, context); });
return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, importAdder.writeFixes));
},
});
- function createImportAdder(sourceFile, program, preferences, host) {
- return createImportAdderWorker(sourceFile, program, /*useAutoImportProvider*/ false, preferences, host);
+ function createImportAdder(sourceFile, program, preferences, host, cancellationToken) {
+ return createImportAdderWorker(sourceFile, program, /*useAutoImportProvider*/ false, preferences, host, cancellationToken);
}
codefix.createImportAdder = createImportAdder;
- function createImportAdderWorker(sourceFile, program, useAutoImportProvider, preferences, host) {
+ function createImportAdderWorker(sourceFile, program, useAutoImportProvider, preferences, host, cancellationToken) {
var compilerOptions = program.getCompilerOptions();
// Namespace fixes don't conflict, so just build a list.
var addToNamespace = [];
@@ -442430,27 +443804,26 @@ var ts;
var newImports = new ts.Map();
return { addImportFromDiagnostic: addImportFromDiagnostic, addImportFromExportedSymbol: addImportFromExportedSymbol, writeFixes: writeFixes, hasFixes: hasFixes };
function addImportFromDiagnostic(diagnostic, context) {
- var info = getFixesInfo(context, diagnostic.code, diagnostic.start, useAutoImportProvider);
- if (!info || !info.fixes.length)
+ var info = getFixInfos(context, diagnostic.code, diagnostic.start, useAutoImportProvider);
+ if (!info || !info.length)
return;
- addImport(info);
+ addImport(ts.first(info));
}
function addImportFromExportedSymbol(exportedSymbol, isValidTypeOnlyUseSite) {
var moduleSymbol = ts.Debug.checkDefined(exportedSymbol.parent);
var symbolName = ts.getNameForExportedSymbol(exportedSymbol, ts.getEmitScriptTarget(compilerOptions));
var checker = program.getTypeChecker();
var symbol = checker.getMergedSymbol(ts.skipAlias(exportedSymbol, checker));
- var exportInfo = getAllReExportingModules(sourceFile, symbol, moduleSymbol, symbolName, /*isJsxTagName*/ false, host, program, preferences, useAutoImportProvider);
+ var exportInfo = getAllExportInfoForSymbol(sourceFile, symbol, symbolName, /*isJsxTagName*/ false, program, host, preferences, cancellationToken);
var useRequire = shouldUseRequire(sourceFile, program);
- var fix = getImportFixForSymbol(sourceFile, exportInfo, moduleSymbol, program, /*useNamespaceInfo*/ undefined, !!isValidTypeOnlyUseSite, useRequire, host, preferences);
+ var fix = getImportFixForSymbol(sourceFile, ts.Debug.checkDefined(exportInfo), moduleSymbol, program, /*useNamespaceInfo*/ undefined, !!isValidTypeOnlyUseSite, useRequire, host, preferences);
if (fix) {
- addImport({ fixes: [fix], symbolName: symbolName, errorIdentifierText: undefined });
+ addImport({ fix: fix, symbolName: symbolName, errorIdentifierText: undefined });
}
}
function addImport(info) {
var _a, _b;
- var fixes = info.fixes, symbolName = info.symbolName;
- var fix = ts.first(fixes);
+ var fix = info.fix, symbolName = info.symbolName;
switch (fix.kind) {
case 0 /* ImportFixKind.UseNamespace */:
addToNamespace.push(fix);
@@ -442617,11 +443990,12 @@ var ts;
AddAsTypeOnly[AddAsTypeOnly["Required"] = 2] = "Required";
AddAsTypeOnly[AddAsTypeOnly["NotAllowed"] = 4] = "NotAllowed";
})(AddAsTypeOnly || (AddAsTypeOnly = {}));
- function getImportCompletionAction(targetSymbol, moduleSymbol, sourceFile, symbolName, isJsxTagName, host, program, formatContext, position, preferences) {
+ function getImportCompletionAction(targetSymbol, moduleSymbol, sourceFile, symbolName, isJsxTagName, host, program, formatContext, position, preferences, cancellationToken) {
var compilerOptions = program.getCompilerOptions();
var exportInfos = ts.pathIsBareSpecifier(ts.stripQuotes(moduleSymbol.name))
- ? [getSymbolExportInfoForSymbol(targetSymbol, moduleSymbol, program, host)]
- : getAllReExportingModules(sourceFile, targetSymbol, moduleSymbol, symbolName, isJsxTagName, host, program, preferences, /*useAutoImportProvider*/ true);
+ ? [getSingleExportInfoForSymbol(targetSymbol, moduleSymbol, program, host)]
+ : getAllExportInfoForSymbol(sourceFile, targetSymbol, symbolName, isJsxTagName, program, host, preferences, cancellationToken);
+ ts.Debug.assertIsDefined(exportInfos);
var useRequire = shouldUseRequire(sourceFile, program);
var isValidTypeOnlyUseSite = ts.isValidTypeOnlyAliasUseSite(ts.getTokenAtPosition(sourceFile, position));
var fix = ts.Debug.checkDefined(getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, program, { symbolName: symbolName, position: position }, isValidTypeOnlyUseSite, useRequire, host, preferences));
@@ -442634,7 +444008,7 @@ var ts;
codefix.getImportCompletionAction = getImportCompletionAction;
function getPromoteTypeOnlyCompletionAction(sourceFile, symbolToken, program, host, formatContext, preferences) {
var compilerOptions = program.getCompilerOptions();
- var symbolName = getSymbolName(sourceFile, program.getTypeChecker(), symbolToken, compilerOptions);
+ var symbolName = ts.single(getSymbolNamesToImport(sourceFile, program.getTypeChecker(), symbolToken, compilerOptions));
var fix = getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program);
var includeSymbolNameInDescription = symbolName !== symbolToken.text;
return fix && codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, includeSymbolNameInDescription, 1 /* QuotePreference.Double */, compilerOptions));
@@ -442649,7 +444023,16 @@ var ts;
var description = _a.description, changes = _a.changes, commands = _a.commands;
return { description: description, changes: changes, commands: commands };
}
- function getSymbolExportInfoForSymbol(symbol, moduleSymbol, program, host) {
+ function getAllExportInfoForSymbol(importingFile, symbol, symbolName, preferCapitalized, program, host, preferences, cancellationToken) {
+ var getChecker = createGetChecker(program, host);
+ return ts.getExportInfoMap(importingFile, host, program, preferences, cancellationToken)
+ .search(importingFile.path, preferCapitalized, function (name) { return name === symbolName; }, function (info) {
+ if (ts.skipAlias(info[0].symbol, getChecker(info[0].isFromPackageJson)) === symbol) {
+ return info;
+ }
+ });
+ }
+ function getSingleExportInfoForSymbol(symbol, moduleSymbol, program, host) {
var _a, _b;
var compilerOptions = program.getCompilerOptions();
var mainProgramInfo = getInfoWithChecker(program.getTypeChecker(), /*isFromPackageJson*/ false);
@@ -442669,35 +444052,6 @@ var ts;
}
}
}
- function getAllReExportingModules(importingFile, targetSymbol, exportingModuleSymbol, symbolName, isJsxTagName, host, program, preferences, useAutoImportProvider) {
- var result = [];
- var compilerOptions = program.getCompilerOptions();
- var getModuleSpecifierResolutionHost = ts.memoizeOne(function (isFromPackageJson) {
- return ts.createModuleSpecifierResolutionHost(isFromPackageJson ? host.getPackageJsonAutoImportProvider() : program, host);
- });
- ts.forEachExternalModuleToImportFrom(program, host, preferences, useAutoImportProvider, function (moduleSymbol, moduleFile, program, isFromPackageJson) {
- var checker = program.getTypeChecker();
- // Don't import from a re-export when looking "up" like to `./index` or `../index`.
- if (moduleFile && moduleSymbol !== exportingModuleSymbol && ts.startsWith(importingFile.fileName, ts.getDirectoryPath(moduleFile.fileName))) {
- return;
- }
- var defaultInfo = ts.getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions);
- if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, ts.getEmitScriptTarget(compilerOptions), isJsxTagName) === symbolName) && ts.skipAlias(defaultInfo.symbol, checker) === targetSymbol && isImportable(program, moduleFile, isFromPackageJson)) {
- result.push({ symbol: defaultInfo.symbol, moduleSymbol: moduleSymbol, moduleFileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName, exportKind: defaultInfo.exportKind, targetFlags: ts.skipAlias(defaultInfo.symbol, checker).flags, isFromPackageJson: isFromPackageJson });
- }
- for (var _i = 0, _a = checker.getExportsAndPropertiesOfModule(moduleSymbol); _i < _a.length; _i++) {
- var exported = _a[_i];
- if (exported.name === symbolName && checker.getMergedSymbol(ts.skipAlias(exported, checker)) === targetSymbol && isImportable(program, moduleFile, isFromPackageJson)) {
- result.push({ symbol: exported, moduleSymbol: moduleSymbol, moduleFileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName, exportKind: 0 /* ExportKind.Named */, targetFlags: ts.skipAlias(exported, checker).flags, isFromPackageJson: isFromPackageJson });
- }
- }
- });
- return result;
- function isImportable(program, moduleFile, isFromPackageJson) {
- var _a;
- return !moduleFile || ts.isImportableFile(program, importingFile, moduleFile, preferences, /*packageJsonFilter*/ undefined, getModuleSpecifierResolutionHost(isFromPackageJson), (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host));
- }
- }
function getImportFixes(exportInfos, useNamespaceInfo,
/** undefined only for missing JSX namespace */
isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences, importMap, fromCacheOnly) {
@@ -442748,11 +444102,11 @@ var ts;
function getTargetModuleFromNamespaceLikeImport(declaration, checker) {
var _a;
switch (declaration.kind) {
- case 254 /* SyntaxKind.VariableDeclaration */:
+ case 257 /* SyntaxKind.VariableDeclaration */:
return checker.resolveExternalModuleName(declaration.initializer.arguments[0]);
- case 265 /* SyntaxKind.ImportEqualsDeclaration */:
+ case 268 /* SyntaxKind.ImportEqualsDeclaration */:
return checker.getAliasedSymbol(declaration.symbol);
- case 266 /* SyntaxKind.ImportDeclaration */:
+ case 269 /* SyntaxKind.ImportDeclaration */:
var namespaceImport = ts.tryCast((_a = declaration.importClause) === null || _a === void 0 ? void 0 : _a.namedBindings, ts.isNamespaceImport);
return namespaceImport && checker.getAliasedSymbol(namespaceImport.symbol);
default:
@@ -442762,11 +444116,11 @@ var ts;
function getNamespaceLikeImportText(declaration) {
var _a, _b, _c;
switch (declaration.kind) {
- case 254 /* SyntaxKind.VariableDeclaration */:
+ case 257 /* SyntaxKind.VariableDeclaration */:
return (_a = ts.tryCast(declaration.name, ts.isIdentifier)) === null || _a === void 0 ? void 0 : _a.text;
- case 265 /* SyntaxKind.ImportEqualsDeclaration */:
+ case 268 /* SyntaxKind.ImportEqualsDeclaration */:
return declaration.name.text;
- case 266 /* SyntaxKind.ImportDeclaration */:
+ case 269 /* SyntaxKind.ImportDeclaration */:
return (_c = ts.tryCast((_b = declaration.importClause) === null || _b === void 0 ? void 0 : _b.namedBindings, ts.isNamespaceImport)) === null || _c === void 0 ? void 0 : _c.name.text;
default:
return ts.Debug.assertNever(declaration);
@@ -442793,12 +444147,12 @@ var ts;
function tryAddToExistingImport(existingImports, isValidTypeOnlyUseSite, checker, compilerOptions) {
return ts.firstDefined(existingImports, function (_a) {
var declaration = _a.declaration, importKind = _a.importKind, symbol = _a.symbol, targetFlags = _a.targetFlags;
- if (importKind === 3 /* ImportKind.CommonJS */ || importKind === 2 /* ImportKind.Namespace */ || declaration.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) {
+ if (importKind === 3 /* ImportKind.CommonJS */ || importKind === 2 /* ImportKind.Namespace */ || declaration.kind === 268 /* SyntaxKind.ImportEqualsDeclaration */) {
// These kinds of imports are not combinable with anything
return undefined;
}
- if (declaration.kind === 254 /* SyntaxKind.VariableDeclaration */) {
- return (importKind === 0 /* ImportKind.Named */ || importKind === 1 /* ImportKind.Default */) && declaration.name.kind === 201 /* SyntaxKind.ObjectBindingPattern */
+ if (declaration.kind === 257 /* SyntaxKind.VariableDeclaration */) {
+ return (importKind === 0 /* ImportKind.Named */ || importKind === 1 /* ImportKind.Default */) && declaration.name.kind === 203 /* SyntaxKind.ObjectBindingPattern */
? { kind: 2 /* ImportFixKind.AddToExisting */, importClauseOrBindingPattern: declaration.name, importKind: importKind, moduleSpecifier: declaration.initializer.arguments[0].text, addAsTypeOnly: 4 /* AddAsTypeOnly.NotAllowed */ }
: undefined;
}
@@ -442819,7 +444173,7 @@ var ts;
))
return undefined;
if (importKind === 0 /* ImportKind.Named */ &&
- (namedBindings === null || namedBindings === void 0 ? void 0 : namedBindings.kind) === 268 /* SyntaxKind.NamespaceImport */ // Cannot add a named import to a declaration that has a namespace import
+ (namedBindings === null || namedBindings === void 0 ? void 0 : namedBindings.kind) === 271 /* SyntaxKind.NamespaceImport */ // Cannot add a named import to a declaration that has a namespace import
)
return undefined;
return {
@@ -442842,7 +444196,7 @@ var ts;
(importMap || (importMap = ts.createMultiMap())).add(ts.getSymbolId(moduleSymbol), i.parent);
}
}
- else if (i.kind === 266 /* SyntaxKind.ImportDeclaration */ || i.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) {
+ else if (i.kind === 269 /* SyntaxKind.ImportDeclaration */ || i.kind === 268 /* SyntaxKind.ImportEqualsDeclaration */) {
var moduleSymbol = checker.getSymbolAtLocation(moduleSpecifier);
if (moduleSymbol) {
(importMap || (importMap = ts.createMultiMap())).add(ts.getSymbolId(moduleSymbol), i);
@@ -442891,11 +444245,14 @@ var ts;
// 5. Literally nothing to go on
return true;
}
+ function createGetChecker(program, host) {
+ return ts.memoizeOne(function (isFromPackageJson) { return isFromPackageJson ? host.getPackageJsonAutoImportProvider().getTypeChecker() : program.getTypeChecker(); });
+ }
function getNewImportFixes(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, exportInfo, host, preferences, fromCacheOnly) {
var isJs = ts.isSourceFileJS(sourceFile);
var compilerOptions = program.getCompilerOptions();
var moduleSpecifierResolutionHost = ts.createModuleSpecifierResolutionHost(program, host);
- var getChecker = ts.memoizeOne(function (isFromPackageJson) { return isFromPackageJson ? host.getPackageJsonAutoImportProvider().getTypeChecker() : program.getTypeChecker(); });
+ var getChecker = createGetChecker(program, host);
var rejectNodeModulesRelativePaths = ts.moduleResolutionUsesNodeModules(ts.getEmitModuleResolutionKind(compilerOptions));
var getModuleSpecifiers = fromCacheOnly
? function (moduleSymbol) { return ({ moduleSpecifiers: ts.moduleSpecifiers.tryGetModuleSpecifiersFromCache(moduleSymbol, sourceFile, moduleSpecifierResolutionHost, preferences), computedWithoutCache: false }); }
@@ -442939,7 +444296,7 @@ var ts;
return { kind: 3 /* ImportFixKind.AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind, addAsTypeOnly: addAsTypeOnly, useRequire: useRequire };
}
}
- function getFixesInfo(context, errorCode, pos, useAutoImportProvider) {
+ function getFixInfos(context, errorCode, pos, useAutoImportProvider) {
var symbolToken = ts.getTokenAtPosition(context.sourceFile, pos);
var info;
if (errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code) {
@@ -442949,19 +444306,23 @@ var ts;
return undefined;
}
else if (errorCode === ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type.code) {
- var symbolName_1 = getSymbolName(context.sourceFile, context.program.getTypeChecker(), symbolToken, context.program.getCompilerOptions());
+ var symbolName_1 = ts.single(getSymbolNamesToImport(context.sourceFile, context.program.getTypeChecker(), symbolToken, context.program.getCompilerOptions()));
var fix = getTypeOnlyPromotionFix(context.sourceFile, symbolToken, symbolName_1, context.program);
- return fix && { fixes: [fix], symbolName: symbolName_1, errorIdentifierText: symbolToken.text };
+ return fix && [{ fix: fix, symbolName: symbolName_1, errorIdentifierText: symbolToken.text }];
}
else {
info = getFixesInfoForNonUMDImport(context, symbolToken, useAutoImportProvider);
}
var packageJsonImportFilter = ts.createPackageJsonImportFilter(context.sourceFile, context.preferences, context.host);
- return info && __assign(__assign({}, info), { fixes: sortFixes(info.fixes, context.sourceFile, context.program, packageJsonImportFilter, context.host) });
+ return info && sortFixInfo(info, context.sourceFile, context.program, packageJsonImportFilter, context.host);
}
- function sortFixes(fixes, sourceFile, program, packageJsonImportFilter, host) {
+ function sortFixInfo(fixes, sourceFile, program, packageJsonImportFilter, host) {
var _toPath = function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), ts.hostGetCanonicalFileName(host)); };
- return ts.sort(fixes, function (a, b) { return ts.compareValues(a.kind, b.kind) || compareModuleSpecifiers(a, b, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier, _toPath); });
+ return ts.sort(fixes, function (a, b) {
+ return ts.compareBooleans(!!a.isJsxNamespaceFix, !!b.isJsxNamespaceFix) ||
+ ts.compareValues(a.fix.kind, b.fix.kind) ||
+ compareModuleSpecifiers(a.fix, b.fix, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier, _toPath);
+ });
}
function getBestFix(fixes, sourceFile, program, packageJsonImportFilter, host) {
if (!ts.some(fixes))
@@ -443012,7 +444373,6 @@ var ts;
return 0 /* Comparison.EqualTo */;
}
function getFixesInfoForUMDImport(_a, token) {
- var _b;
var sourceFile = _a.sourceFile, program = _a.program, host = _a.host, preferences = _a.preferences;
var checker = program.getTypeChecker();
var umdSymbol = getUmdSymbol(token, checker);
@@ -443024,7 +444384,7 @@ var ts;
var useRequire = shouldUseRequire(sourceFile, program);
var position = ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined;
var fixes = getImportFixes(exportInfo, position ? { position: position, symbolName: symbolName } : undefined, /*isValidTypeOnlyUseSite*/ false, useRequire, program, sourceFile, host, preferences).fixes;
- return { fixes: fixes, symbolName: symbolName, errorIdentifierText: (_b = ts.tryCast(token, ts.isIdentifier)) === null || _b === void 0 ? void 0 : _b.text };
+ return fixes.map(function (fix) { var _a; return ({ fix: fix, symbolName: symbolName, errorIdentifierText: (_a = ts.tryCast(token, ts.isIdentifier)) === null || _a === void 0 ? void 0 : _a.text }); });
}
function getUmdSymbol(token, checker) {
// try the identifier to see if it is the umd symbol
@@ -443085,19 +444445,20 @@ var ts;
var sourceFile = _a.sourceFile, program = _a.program, cancellationToken = _a.cancellationToken, host = _a.host, preferences = _a.preferences;
var checker = program.getTypeChecker();
var compilerOptions = program.getCompilerOptions();
- var symbolName = getSymbolName(sourceFile, checker, symbolToken, compilerOptions);
- // "default" is a keyword and not a legal identifier for the import, but appears as an identifier.
- if (symbolName === "default" /* InternalSymbolName.Default */) {
- return undefined;
- }
- var isValidTypeOnlyUseSite = ts.isValidTypeOnlyAliasUseSite(symbolToken);
- var useRequire = shouldUseRequire(sourceFile, program);
- var exportInfo = getExportInfos(symbolName, ts.isJSXTagName(symbolToken), ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, program, useAutoImportProvider, host, preferences);
- var fixes = ts.arrayFrom(ts.flatMapIterator(exportInfo.entries(), function (_a) {
- var _ = _a[0], exportInfos = _a[1];
- return getImportFixes(exportInfos, { symbolName: symbolName, position: symbolToken.getStart(sourceFile) }, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences).fixes;
- }));
- return { fixes: fixes, symbolName: symbolName, errorIdentifierText: symbolToken.text };
+ return ts.flatMap(getSymbolNamesToImport(sourceFile, checker, symbolToken, compilerOptions), function (symbolName) {
+ // "default" is a keyword and not a legal identifier for the import, but appears as an identifier.
+ if (symbolName === "default" /* InternalSymbolName.Default */) {
+ return undefined;
+ }
+ var isValidTypeOnlyUseSite = ts.isValidTypeOnlyAliasUseSite(symbolToken);
+ var useRequire = shouldUseRequire(sourceFile, program);
+ var exportInfo = getExportInfos(symbolName, ts.isJSXTagName(symbolToken), ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, program, useAutoImportProvider, host, preferences);
+ var fixes = ts.arrayFrom(ts.flatMapIterator(exportInfo.entries(), function (_a) {
+ var _ = _a[0], exportInfos = _a[1];
+ return getImportFixes(exportInfos, { symbolName: symbolName, position: symbolToken.getStart(sourceFile) }, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences).fixes;
+ }));
+ return fixes.map(function (fix) { return ({ fix: fix, symbolName: symbolName, errorIdentifierText: symbolToken.text, isJsxNamespaceFix: symbolName !== symbolToken.text }); });
+ });
}
function getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program) {
var checker = program.getTypeChecker();
@@ -443109,15 +444470,16 @@ var ts;
return undefined;
return { kind: 4 /* ImportFixKind.PromoteTypeOnly */, typeOnlyAliasDeclaration: typeOnlyAliasDeclaration };
}
- function getSymbolName(sourceFile, checker, symbolToken, compilerOptions) {
+ function getSymbolNamesToImport(sourceFile, checker, symbolToken, compilerOptions) {
var parent = symbolToken.parent;
if ((ts.isJsxOpeningLikeElement(parent) || ts.isJsxClosingElement(parent)) && parent.tagName === symbolToken && ts.jsxModeNeedsExplicitImport(compilerOptions.jsx)) {
var jsxNamespace = checker.getJsxNamespace(sourceFile);
if (needsJsxNamespaceFix(jsxNamespace, symbolToken, checker)) {
- return jsxNamespace;
+ var needsComponentNameFix = !ts.isIntrinsicJsxName(symbolToken.text) && !checker.resolveName(symbolToken.text, symbolToken, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ false);
+ return needsComponentNameFix ? [symbolToken.text, jsxNamespace] : [jsxNamespace];
}
}
- return symbolToken.text;
+ return [symbolToken.text];
}
function needsJsxNamespaceFix(jsxNamespace, symbolToken, checker) {
if (ts.isIntrinsicJsxName(symbolToken.text))
@@ -443226,7 +444588,7 @@ var ts;
case 4 /* ImportFixKind.PromoteTypeOnly */: {
var typeOnlyAliasDeclaration = fix.typeOnlyAliasDeclaration;
var promotedDeclaration = promoteFromTypeOnly(changes, typeOnlyAliasDeclaration, compilerOptions, sourceFile);
- return promotedDeclaration.kind === 270 /* SyntaxKind.ImportSpecifier */
+ return promotedDeclaration.kind === 273 /* SyntaxKind.ImportSpecifier */
? [ts.Diagnostics.Remove_type_from_import_of_0_from_1, symbolName, getModuleSpecifierText(promotedDeclaration.parent.parent)]
: [ts.Diagnostics.Remove_type_from_import_declaration_from_0, getModuleSpecifierText(promotedDeclaration)];
}
@@ -443236,7 +444598,7 @@ var ts;
}
function getModuleSpecifierText(promotedDeclaration) {
var _a, _b;
- return promotedDeclaration.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */
+ return promotedDeclaration.kind === 268 /* SyntaxKind.ImportEqualsDeclaration */
? ((_b = ts.tryCast((_a = ts.tryCast(promotedDeclaration.moduleReference, ts.isExternalModuleReference)) === null || _a === void 0 ? void 0 : _a.expression, ts.isStringLiteralLike)) === null || _b === void 0 ? void 0 : _b.text) || promotedDeclaration.moduleReference.getText()
: ts.cast(promotedDeclaration.parent.moduleSpecifier, ts.isStringLiteral).text;
}
@@ -443244,7 +444606,7 @@ var ts;
// See comment in `doAddExistingFix` on constant with the same name.
var convertExistingToTypeOnly = compilerOptions.preserveValueImports && compilerOptions.isolatedModules;
switch (aliasDeclaration.kind) {
- case 270 /* SyntaxKind.ImportSpecifier */:
+ case 273 /* SyntaxKind.ImportSpecifier */:
if (aliasDeclaration.isTypeOnly) {
if (aliasDeclaration.parent.elements.length > 1 && ts.OrganizeImports.importSpecifiersAreSorted(aliasDeclaration.parent.elements)) {
changes.delete(sourceFile, aliasDeclaration);
@@ -443262,13 +444624,13 @@ var ts;
promoteImportClause(aliasDeclaration.parent.parent);
return aliasDeclaration.parent.parent;
}
- case 267 /* SyntaxKind.ImportClause */:
+ case 270 /* SyntaxKind.ImportClause */:
promoteImportClause(aliasDeclaration);
return aliasDeclaration;
- case 268 /* SyntaxKind.NamespaceImport */:
+ case 271 /* SyntaxKind.NamespaceImport */:
promoteImportClause(aliasDeclaration.parent);
return aliasDeclaration.parent;
- case 265 /* SyntaxKind.ImportEqualsDeclaration */:
+ case 268 /* SyntaxKind.ImportEqualsDeclaration */:
changes.deleteRange(sourceFile, aliasDeclaration.getChildAt(1));
return aliasDeclaration;
default:
@@ -443280,7 +444642,7 @@ var ts;
var namedImports = ts.tryCast(importClause.namedBindings, ts.isNamedImports);
if (namedImports && namedImports.elements.length > 1) {
if (ts.OrganizeImports.importSpecifiersAreSorted(namedImports.elements) &&
- aliasDeclaration.kind === 270 /* SyntaxKind.ImportSpecifier */ &&
+ aliasDeclaration.kind === 273 /* SyntaxKind.ImportSpecifier */ &&
namedImports.elements.indexOf(aliasDeclaration) !== 0) {
// The import specifier being promoted will be the only non-type-only,
// import in the NamedImports, so it should be moved to the front.
@@ -443290,7 +444652,7 @@ var ts;
for (var _i = 0, _a = namedImports.elements; _i < _a.length; _i++) {
var element = _a[_i];
if (element !== aliasDeclaration && !element.isTypeOnly) {
- changes.insertModifierBefore(sourceFile, 152 /* SyntaxKind.TypeKeyword */, element);
+ changes.insertModifierBefore(sourceFile, 154 /* SyntaxKind.TypeKeyword */, element);
}
}
}
@@ -443299,7 +444661,7 @@ var ts;
}
function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports, compilerOptions) {
var _a;
- if (clause.kind === 201 /* SyntaxKind.ObjectBindingPattern */) {
+ if (clause.kind === 203 /* SyntaxKind.ObjectBindingPattern */) {
if (defaultImport) {
addElementToBindingPattern(clause, defaultImport.name, "default");
}
@@ -443360,7 +444722,7 @@ var ts;
if (convertExistingToTypeOnly && existingSpecifiers) {
for (var _d = 0, existingSpecifiers_1 = existingSpecifiers; _d < existingSpecifiers_1.length; _d++) {
var specifier = existingSpecifiers_1[_d];
- changes.insertModifierBefore(sourceFile, 152 /* SyntaxKind.TypeKeyword */, specifier);
+ changes.insertModifierBefore(sourceFile, 154 /* SyntaxKind.TypeKeyword */, specifier);
}
}
}
@@ -443535,7 +444897,7 @@ var ts;
var related = ts.find(diag.relatedInformation, function (related) { return related.code === ts.Diagnostics.This_type_parameter_might_need_an_extends_0_constraint.code; });
if (related === undefined || related.file === undefined || related.start === undefined || related.length === undefined)
return;
- var declaration = findAncestorMatchingSpan(related.file, ts.createTextSpan(related.start, related.length));
+ var declaration = codefix.findAncestorMatchingSpan(related.file, ts.createTextSpan(related.start, related.length));
if (declaration === undefined)
return;
if (ts.isIdentifier(declaration) && ts.isTypeParameterDeclaration(declaration.parent)) {
@@ -443569,14 +444931,6 @@ var ts;
}
}
}
- function findAncestorMatchingSpan(sourceFile, span) {
- var end = ts.textSpanEnd(span);
- var token = ts.getTokenAtPosition(sourceFile, span.start);
- while (token.end < end) {
- token = token.parent;
- }
- return token;
- }
function tryGetConstraintFromDiagnosticMessage(messageText) {
var _a = ts.flattenDiagnosticMessageText(messageText, "\n", 0).match(/`extends (.*)`/) || [], _ = _a[0], constraint = _a[1];
return constraint;
@@ -443720,7 +445074,7 @@ var ts;
accessibilityModifier ? accessibilityModifier.end :
lastDecorator ? ts.skipTrivia(sourceFile.text, lastDecorator.end) : classElement.getStart(sourceFile);
var options = accessibilityModifier || staticModifier || abstractModifier ? { prefix: " " } : { suffix: " " };
- changeTracker.insertModifierAt(sourceFile, modifierPos, 159 /* SyntaxKind.OverrideKeyword */, options);
+ changeTracker.insertModifierAt(sourceFile, modifierPos, 161 /* SyntaxKind.OverrideKeyword */, options);
}
function doRemoveOverrideModifierChange(changeTracker, sourceFile, pos) {
var classElement = findContainerClassElementLike(sourceFile, pos);
@@ -443734,13 +445088,13 @@ var ts;
}
function isClassElementLikeHasJSDoc(node) {
switch (node.kind) {
- case 171 /* SyntaxKind.Constructor */:
- case 167 /* SyntaxKind.PropertyDeclaration */:
- case 169 /* SyntaxKind.MethodDeclaration */:
- case 172 /* SyntaxKind.GetAccessor */:
- case 173 /* SyntaxKind.SetAccessor */:
+ case 173 /* SyntaxKind.Constructor */:
+ case 169 /* SyntaxKind.PropertyDeclaration */:
+ case 171 /* SyntaxKind.MethodDeclaration */:
+ case 174 /* SyntaxKind.GetAccessor */:
+ case 175 /* SyntaxKind.SetAccessor */:
return true;
- case 164 /* SyntaxKind.Parameter */:
+ case 166 /* SyntaxKind.Parameter */:
return ts.isParameterPropertyDeclaration(node, node.parent);
default:
return false;
@@ -443852,6 +445206,143 @@ var ts;
})(ts || (ts = {}));
/* @internal */
var ts;
+(function (ts) {
+ var codefix;
+ (function (codefix) {
+ var fixId = "fixImportNonExportedMember";
+ var errorCodes = [
+ ts.Diagnostics.Module_0_declares_1_locally_but_it_is_not_exported.code,
+ ];
+ codefix.registerCodeFix({
+ errorCodes: errorCodes,
+ fixIds: [fixId],
+ getCodeActions: function (context) {
+ var sourceFile = context.sourceFile, span = context.span, program = context.program;
+ var info = getInfo(sourceFile, span.start, program);
+ if (info === undefined)
+ return undefined;
+ var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, program, info); });
+ return [codefix.createCodeFixAction(fixId, changes, [ts.Diagnostics.Export_0_from_module_1, info.exportName.node.text, info.moduleSpecifier], fixId, ts.Diagnostics.Export_all_referenced_locals)];
+ },
+ getAllCodeActions: function (context) {
+ var program = context.program;
+ return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) {
+ var exports = new ts.Map();
+ codefix.eachDiagnostic(context, errorCodes, function (diag) {
+ var info = getInfo(diag.file, diag.start, program);
+ if (info === undefined)
+ return undefined;
+ var exportName = info.exportName, node = info.node, moduleSourceFile = info.moduleSourceFile;
+ if (tryGetExportDeclaration(moduleSourceFile, exportName.isTypeOnly) === undefined && ts.canHaveExportModifier(node)) {
+ changes.insertExportModifier(moduleSourceFile, node);
+ }
+ else {
+ var moduleExports = exports.get(moduleSourceFile) || { typeOnlyExports: [], exports: [] };
+ if (exportName.isTypeOnly) {
+ moduleExports.typeOnlyExports.push(exportName);
+ }
+ else {
+ moduleExports.exports.push(exportName);
+ }
+ exports.set(moduleSourceFile, moduleExports);
+ }
+ });
+ exports.forEach(function (moduleExports, moduleSourceFile) {
+ var exportDeclaration = tryGetExportDeclaration(moduleSourceFile, /*isTypeOnly*/ true);
+ if (exportDeclaration && exportDeclaration.isTypeOnly) {
+ doChanges(changes, program, moduleSourceFile, moduleExports.typeOnlyExports, exportDeclaration);
+ doChanges(changes, program, moduleSourceFile, moduleExports.exports, tryGetExportDeclaration(moduleSourceFile, /*isTypeOnly*/ false));
+ }
+ else {
+ doChanges(changes, program, moduleSourceFile, __spreadArray(__spreadArray([], moduleExports.exports, true), moduleExports.typeOnlyExports, true), exportDeclaration);
+ }
+ });
+ }));
+ }
+ });
+ function getInfo(sourceFile, pos, program) {
+ var _a;
+ var token = ts.getTokenAtPosition(sourceFile, pos);
+ if (ts.isIdentifier(token)) {
+ var importDeclaration = ts.findAncestor(token, ts.isImportDeclaration);
+ if (importDeclaration === undefined)
+ return undefined;
+ var moduleSpecifier = ts.isStringLiteral(importDeclaration.moduleSpecifier) ? importDeclaration.moduleSpecifier.text : undefined;
+ if (moduleSpecifier === undefined)
+ return undefined;
+ var resolvedModule = ts.getResolvedModule(sourceFile, moduleSpecifier, /*mode*/ undefined);
+ if (resolvedModule === undefined)
+ return undefined;
+ var moduleSourceFile = program.getSourceFile(resolvedModule.resolvedFileName);
+ if (moduleSourceFile === undefined || ts.isSourceFileFromLibrary(program, moduleSourceFile))
+ return undefined;
+ var moduleSymbol = moduleSourceFile.symbol;
+ var locals = (_a = moduleSymbol.valueDeclaration) === null || _a === void 0 ? void 0 : _a.locals;
+ if (locals === undefined)
+ return undefined;
+ var localSymbol = locals.get(token.escapedText);
+ if (localSymbol === undefined)
+ return undefined;
+ var node = getNodeOfSymbol(localSymbol);
+ if (node === undefined)
+ return undefined;
+ var exportName = { node: token, isTypeOnly: ts.isTypeDeclaration(node) };
+ return { exportName: exportName, node: node, moduleSourceFile: moduleSourceFile, moduleSpecifier: moduleSpecifier };
+ }
+ return undefined;
+ }
+ function doChange(changes, program, _a) {
+ var exportName = _a.exportName, node = _a.node, moduleSourceFile = _a.moduleSourceFile;
+ var exportDeclaration = tryGetExportDeclaration(moduleSourceFile, exportName.isTypeOnly);
+ if (exportDeclaration) {
+ updateExport(changes, program, moduleSourceFile, exportDeclaration, [exportName]);
+ }
+ else if (ts.canHaveExportModifier(node)) {
+ changes.insertExportModifier(moduleSourceFile, node);
+ }
+ else {
+ createExport(changes, program, moduleSourceFile, [exportName]);
+ }
+ }
+ function doChanges(changes, program, sourceFile, moduleExports, node) {
+ if (ts.length(moduleExports)) {
+ if (node) {
+ updateExport(changes, program, sourceFile, node, moduleExports);
+ }
+ else {
+ createExport(changes, program, sourceFile, moduleExports);
+ }
+ }
+ }
+ function tryGetExportDeclaration(sourceFile, isTypeOnly) {
+ var predicate = function (node) {
+ return ts.isExportDeclaration(node) && (isTypeOnly && node.isTypeOnly || !node.isTypeOnly);
+ };
+ return ts.findLast(sourceFile.statements, predicate);
+ }
+ function updateExport(changes, program, sourceFile, node, names) {
+ var namedExports = node.exportClause && ts.isNamedExports(node.exportClause) ? node.exportClause.elements : ts.factory.createNodeArray([]);
+ var allowTypeModifier = !node.isTypeOnly && !!(program.getCompilerOptions().isolatedModules || ts.find(namedExports, function (e) { return e.isTypeOnly; }));
+ changes.replaceNode(sourceFile, node, ts.factory.updateExportDeclaration(node, node.modifiers, node.isTypeOnly, ts.factory.createNamedExports(ts.factory.createNodeArray(__spreadArray(__spreadArray([], namedExports, true), createExportSpecifiers(names, allowTypeModifier), true), /*hasTrailingComma*/ namedExports.hasTrailingComma)), node.moduleSpecifier, node.assertClause));
+ }
+ function createExport(changes, program, sourceFile, names) {
+ changes.insertNodeAtEndOfScope(sourceFile, sourceFile, ts.factory.createExportDeclaration(/*modifiers*/ undefined, /*isTypeOnly*/ false, ts.factory.createNamedExports(createExportSpecifiers(names, /*allowTypeModifier*/ !!program.getCompilerOptions().isolatedModules)), /*moduleSpecifier*/ undefined, /*assertClause*/ undefined));
+ }
+ function createExportSpecifiers(names, allowTypeModifier) {
+ return ts.factory.createNodeArray(ts.map(names, function (n) { return ts.factory.createExportSpecifier(allowTypeModifier && n.isTypeOnly, /*propertyName*/ undefined, n.node); }));
+ }
+ function getNodeOfSymbol(symbol) {
+ if (symbol.valueDeclaration === undefined) {
+ return ts.firstOrUndefined(symbol.declarations);
+ }
+ var declaration = symbol.valueDeclaration;
+ var variableStatement = ts.isVariableDeclaration(declaration) ? ts.tryCast(declaration.parent.parent, ts.isVariableStatement) : undefined;
+ return variableStatement && ts.length(variableStatement.declarationList.declarations) === 1 ? variableStatement : declaration;
+ }
+ })(codefix = ts.codefix || (ts.codefix = {}));
+})(ts || (ts = {}));
+/* @internal */
+var ts;
(function (ts) {
var codefix;
(function (codefix) {
@@ -443872,7 +445363,7 @@ var ts;
});
function getNamedTupleMember(sourceFile, pos) {
var token = ts.getTokenAtPosition(sourceFile, pos);
- return ts.findAncestor(token, function (t) { return t.kind === 197 /* SyntaxKind.NamedTupleMember */; });
+ return ts.findAncestor(token, function (t) { return t.kind === 199 /* SyntaxKind.NamedTupleMember */; });
}
function doChange(changes, sourceFile, namedTupleMember) {
if (!namedTupleMember) {
@@ -443881,11 +445372,11 @@ var ts;
var unwrappedType = namedTupleMember.type;
var sawOptional = false;
var sawRest = false;
- while (unwrappedType.kind === 185 /* SyntaxKind.OptionalType */ || unwrappedType.kind === 186 /* SyntaxKind.RestType */ || unwrappedType.kind === 191 /* SyntaxKind.ParenthesizedType */) {
- if (unwrappedType.kind === 185 /* SyntaxKind.OptionalType */) {
+ while (unwrappedType.kind === 187 /* SyntaxKind.OptionalType */ || unwrappedType.kind === 188 /* SyntaxKind.RestType */ || unwrappedType.kind === 193 /* SyntaxKind.ParenthesizedType */) {
+ if (unwrappedType.kind === 187 /* SyntaxKind.OptionalType */) {
sawOptional = true;
}
- else if (unwrappedType.kind === 186 /* SyntaxKind.RestType */) {
+ else if (unwrappedType.kind === 188 /* SyntaxKind.RestType */) {
sawRest = true;
}
unwrappedType = unwrappedType.type;
@@ -444156,7 +445647,7 @@ var ts;
if (isFunctionType) {
var sig = checker.getSignatureFromDeclaration(declaration);
if (sig) {
- if (ts.hasSyntacticModifier(declaration, 256 /* ModifierFlags.Async */)) {
+ if (ts.hasSyntacticModifier(declaration, 512 /* ModifierFlags.Async */)) {
exprType = checker.createPromiseType(exprType);
}
var newSig = checker.createSignature(declaration, sig.typeParameters, sig.thisParameter, sig.parameters, exprType,
@@ -444200,19 +445691,19 @@ var ts;
}
function getVariableLikeInitializer(declaration) {
switch (declaration.kind) {
- case 254 /* SyntaxKind.VariableDeclaration */:
- case 164 /* SyntaxKind.Parameter */:
- case 203 /* SyntaxKind.BindingElement */:
- case 167 /* SyntaxKind.PropertyDeclaration */:
- case 296 /* SyntaxKind.PropertyAssignment */:
+ case 257 /* SyntaxKind.VariableDeclaration */:
+ case 166 /* SyntaxKind.Parameter */:
+ case 205 /* SyntaxKind.BindingElement */:
+ case 169 /* SyntaxKind.PropertyDeclaration */:
+ case 299 /* SyntaxKind.PropertyAssignment */:
return declaration.initializer;
- case 285 /* SyntaxKind.JsxAttribute */:
+ case 288 /* SyntaxKind.JsxAttribute */:
return declaration.initializer && (ts.isJsxExpression(declaration.initializer) ? declaration.initializer.expression : undefined);
- case 297 /* SyntaxKind.ShorthandPropertyAssignment */:
- case 166 /* SyntaxKind.PropertySignature */:
- case 299 /* SyntaxKind.EnumMember */:
- case 347 /* SyntaxKind.JSDocPropertyTag */:
- case 340 /* SyntaxKind.JSDocParameterTag */:
+ case 300 /* SyntaxKind.ShorthandPropertyAssignment */:
+ case 168 /* SyntaxKind.PropertySignature */:
+ case 302 /* SyntaxKind.EnumMember */:
+ case 350 /* SyntaxKind.JSDocPropertyTag */:
+ case 343 /* SyntaxKind.JSDocParameterTag */:
return undefined;
}
}
@@ -444266,6 +445757,15 @@ var ts;
ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code,
ts.Diagnostics.Cannot_find_name_0.code
];
+ var InfoKind;
+ (function (InfoKind) {
+ InfoKind[InfoKind["TypeLikeDeclaration"] = 0] = "TypeLikeDeclaration";
+ InfoKind[InfoKind["Enum"] = 1] = "Enum";
+ InfoKind[InfoKind["Function"] = 2] = "Function";
+ InfoKind[InfoKind["ObjectLiteral"] = 3] = "ObjectLiteral";
+ InfoKind[InfoKind["JsxAttributes"] = 4] = "JsxAttributes";
+ InfoKind[InfoKind["Signature"] = 5] = "Signature";
+ })(InfoKind || (InfoKind = {}));
codefix.registerCodeFix({
errorCodes: errorCodes,
getCodeActions: function (context) {
@@ -444274,19 +445774,19 @@ var ts;
if (!info) {
return undefined;
}
- if (info.kind === 3 /* InfoKind.ObjectLiteral */) {
+ if (info.kind === InfoKind.ObjectLiteral) {
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addObjectLiteralProperties(t, context, info); });
return [codefix.createCodeFixAction(fixMissingProperties, changes, ts.Diagnostics.Add_missing_properties, fixMissingProperties, ts.Diagnostics.Add_all_missing_properties)];
}
- if (info.kind === 4 /* InfoKind.JsxAttributes */) {
+ if (info.kind === InfoKind.JsxAttributes) {
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addJsxAttributes(t, context, info); });
return [codefix.createCodeFixAction(fixMissingAttributes, changes, ts.Diagnostics.Add_missing_attributes, fixMissingAttributes, ts.Diagnostics.Add_all_missing_attributes)];
}
- if (info.kind === 2 /* InfoKind.Function */) {
+ if (info.kind === InfoKind.Function || info.kind === InfoKind.Signature) {
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addFunctionDeclaration(t, context, info); });
return [codefix.createCodeFixAction(fixMissingFunctionDeclaration, changes, [ts.Diagnostics.Add_missing_function_declaration_0, info.token.text], fixMissingFunctionDeclaration, ts.Diagnostics.Add_all_missing_function_declarations)];
}
- if (info.kind === 1 /* InfoKind.Enum */) {
+ if (info.kind === InfoKind.Enum) {
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addEnumMemberDeclaration(t, context.program.getTypeChecker(), info); });
return [codefix.createCodeFixAction(fixMissingMember, changes, [ts.Diagnostics.Add_missing_enum_member_0, info.token.text], fixMissingMember, ts.Diagnostics.Add_all_missing_members)];
}
@@ -444304,20 +445804,20 @@ var ts;
if (!info || !ts.addToSeen(seen, ts.getNodeId(info.parentDeclaration) + "#" + info.token.text)) {
return;
}
- if (fixId === fixMissingFunctionDeclaration && info.kind === 2 /* InfoKind.Function */) {
+ if (fixId === fixMissingFunctionDeclaration && (info.kind === InfoKind.Function || info.kind === InfoKind.Signature)) {
addFunctionDeclaration(changes, context, info);
}
- else if (fixId === fixMissingProperties && info.kind === 3 /* InfoKind.ObjectLiteral */) {
+ else if (fixId === fixMissingProperties && info.kind === InfoKind.ObjectLiteral) {
addObjectLiteralProperties(changes, context, info);
}
- else if (fixId === fixMissingAttributes && info.kind === 4 /* InfoKind.JsxAttributes */) {
+ else if (fixId === fixMissingAttributes && info.kind === InfoKind.JsxAttributes) {
addJsxAttributes(changes, context, info);
}
else {
- if (info.kind === 1 /* InfoKind.Enum */) {
+ if (info.kind === InfoKind.Enum) {
addEnumMemberDeclaration(changes, checker, info);
}
- if (info.kind === 0 /* InfoKind.TypeLikeDeclaration */) {
+ if (info.kind === InfoKind.TypeLikeDeclaration) {
var parentDeclaration = info.parentDeclaration, token_1 = info.token;
var infos = ts.getOrUpdate(typeDeclToMembers, parentDeclaration, function () { return []; });
if (!infos.some(function (i) { return i.token.text === token_1.text; })) {
@@ -444361,14 +445861,6 @@ var ts;
}));
},
});
- var InfoKind;
- (function (InfoKind) {
- InfoKind[InfoKind["TypeLikeDeclaration"] = 0] = "TypeLikeDeclaration";
- InfoKind[InfoKind["Enum"] = 1] = "Enum";
- InfoKind[InfoKind["Function"] = 2] = "Function";
- InfoKind[InfoKind["ObjectLiteral"] = 3] = "ObjectLiteral";
- InfoKind[InfoKind["JsxAttributes"] = 4] = "JsxAttributes";
- })(InfoKind || (InfoKind = {}));
function getInfo(sourceFile, tokenPos, errorCode, checker, program) {
// The identifier of the missing property. eg:
// this.missing = 1;
@@ -444381,7 +445873,7 @@ var ts;
var argIndex = ts.findIndex(parent.parent.arguments, function (arg) { return arg === parent; });
if (argIndex < 0)
return undefined;
- var signature = ts.singleOrUndefined(checker.getSignaturesOfType(checker.getTypeAtLocation(parent.parent.expression), 0 /* SignatureKind.Call */));
+ var signature = checker.getResolvedSignature(parent.parent);
if (!(signature && signature.declaration && signature.parameters[argIndex]))
return undefined;
var param = signature.parameters[argIndex].valueDeclaration;
@@ -444390,7 +445882,7 @@ var ts;
var properties = ts.arrayFrom(checker.getUnmatchedProperties(checker.getTypeAtLocation(parent), checker.getParameterType(signature, argIndex), /* requireOptionalProperties */ false, /* matchDiscriminantProperties */ false));
if (!ts.length(properties))
return undefined;
- return { kind: 3 /* InfoKind.ObjectLiteral */, token: param.name, properties: properties, parentDeclaration: parent };
+ return { kind: InfoKind.ObjectLiteral, token: param.name, properties: properties, parentDeclaration: parent };
}
if (!ts.isMemberName(token))
return undefined;
@@ -444398,17 +445890,26 @@ var ts;
var properties = ts.arrayFrom(checker.getUnmatchedProperties(checker.getTypeAtLocation(parent.initializer), checker.getTypeAtLocation(token), /* requireOptionalProperties */ false, /* matchDiscriminantProperties */ false));
if (!ts.length(properties))
return undefined;
- return { kind: 3 /* InfoKind.ObjectLiteral */, token: token, properties: properties, parentDeclaration: parent.initializer };
+ return { kind: InfoKind.ObjectLiteral, token: token, properties: properties, parentDeclaration: parent.initializer };
}
if (ts.isIdentifier(token) && ts.isJsxOpeningLikeElement(token.parent)) {
var target = ts.getEmitScriptTarget(program.getCompilerOptions());
var attributes = getUnmatchedAttributes(checker, target, token.parent);
if (!ts.length(attributes))
return undefined;
- return { kind: 4 /* InfoKind.JsxAttributes */, token: token, attributes: attributes, parentDeclaration: token.parent };
+ return { kind: InfoKind.JsxAttributes, token: token, attributes: attributes, parentDeclaration: token.parent };
}
- if (ts.isIdentifier(token) && ts.isCallExpression(parent) && parent.expression === token) {
- return { kind: 2 /* InfoKind.Function */, token: token, call: parent, sourceFile: sourceFile, modifierFlags: 0 /* ModifierFlags.None */, parentDeclaration: sourceFile };
+ if (ts.isIdentifier(token)) {
+ var type = checker.getContextualType(token);
+ if (type && ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */) {
+ var signature = ts.firstOrUndefined(checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */));
+ if (signature === undefined)
+ return undefined;
+ return { kind: InfoKind.Signature, token: token, signature: signature, sourceFile: sourceFile, parentDeclaration: findScope(token) };
+ }
+ if (ts.isCallExpression(parent) && parent.expression === token) {
+ return { kind: InfoKind.Function, token: token, call: parent, sourceFile: sourceFile, modifierFlags: 0 /* ModifierFlags.None */, parentDeclaration: findScope(token) };
+ }
}
if (!ts.isPropertyAccessExpression(parent))
return undefined;
@@ -444419,14 +445920,14 @@ var ts;
if (ts.isIdentifier(token) && ts.isCallExpression(parent.parent)) {
var moduleDeclaration = ts.find(symbol.declarations, ts.isModuleDeclaration);
var moduleDeclarationSourceFile = moduleDeclaration === null || moduleDeclaration === void 0 ? void 0 : moduleDeclaration.getSourceFile();
- if (moduleDeclaration && moduleDeclarationSourceFile && !isSourceFileFromLibrary(program, moduleDeclarationSourceFile)) {
- return { kind: 2 /* InfoKind.Function */, token: token, call: parent.parent, sourceFile: sourceFile, modifierFlags: 1 /* ModifierFlags.Export */, parentDeclaration: moduleDeclaration };
+ if (moduleDeclaration && moduleDeclarationSourceFile && !ts.isSourceFileFromLibrary(program, moduleDeclarationSourceFile)) {
+ return { kind: InfoKind.Function, token: token, call: parent.parent, sourceFile: sourceFile, modifierFlags: 1 /* ModifierFlags.Export */, parentDeclaration: moduleDeclaration };
}
var moduleSourceFile = ts.find(symbol.declarations, ts.isSourceFile);
if (sourceFile.commonJsModuleIndicator)
return undefined;
- if (moduleSourceFile && !isSourceFileFromLibrary(program, moduleSourceFile)) {
- return { kind: 2 /* InfoKind.Function */, token: token, call: parent.parent, sourceFile: moduleSourceFile, modifierFlags: 1 /* ModifierFlags.Export */, parentDeclaration: moduleSourceFile };
+ if (moduleSourceFile && !ts.isSourceFileFromLibrary(program, moduleSourceFile)) {
+ return { kind: InfoKind.Function, token: token, call: parent.parent, sourceFile: moduleSourceFile, modifierFlags: 1 /* ModifierFlags.Export */, parentDeclaration: moduleSourceFile };
}
}
var classDeclaration = ts.find(symbol.declarations, ts.isClassLike);
@@ -444435,7 +445936,7 @@ var ts;
return undefined;
// Prefer to change the class instead of the interface if they are merged
var declaration = classDeclaration || ts.find(symbol.declarations, function (d) { return ts.isInterfaceDeclaration(d) || ts.isTypeLiteralNode(d); });
- if (declaration && !isSourceFileFromLibrary(program, declaration.getSourceFile())) {
+ if (declaration && !ts.isSourceFileFromLibrary(program, declaration.getSourceFile())) {
var makeStatic = !ts.isTypeLiteralNode(declaration) && (leftExpressionType.target || leftExpressionType) !== checker.getDeclaredTypeOfSymbol(symbol);
if (makeStatic && (ts.isPrivateIdentifier(token) || ts.isInterfaceDeclaration(declaration)))
return undefined;
@@ -444444,17 +445945,14 @@ var ts;
(makeStatic ? 32 /* ModifierFlags.Static */ : 0 /* ModifierFlags.None */) | (ts.startsWithUnderscore(token.text) ? 8 /* ModifierFlags.Private */ : 0 /* ModifierFlags.None */);
var isJSFile = ts.isSourceFileJS(declSourceFile);
var call = ts.tryCast(parent.parent, ts.isCallExpression);
- return { kind: 0 /* InfoKind.TypeLikeDeclaration */, token: token, call: call, modifierFlags: modifierFlags, parentDeclaration: declaration, declSourceFile: declSourceFile, isJSFile: isJSFile };
+ return { kind: InfoKind.TypeLikeDeclaration, token: token, call: call, modifierFlags: modifierFlags, parentDeclaration: declaration, declSourceFile: declSourceFile, isJSFile: isJSFile };
}
var enumDeclaration = ts.find(symbol.declarations, ts.isEnumDeclaration);
- if (enumDeclaration && !ts.isPrivateIdentifier(token) && !isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) {
- return { kind: 1 /* InfoKind.Enum */, token: token, parentDeclaration: enumDeclaration };
+ if (enumDeclaration && !(leftExpressionType.flags & 1056 /* TypeFlags.EnumLike */) && !ts.isPrivateIdentifier(token) && !ts.isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) {
+ return { kind: InfoKind.Enum, token: token, parentDeclaration: enumDeclaration };
}
return undefined;
}
- function isSourceFileFromLibrary(program, node) {
- return program.isSourceFileFromExternalLibrary(node) || program.isSourceFileDefaultLibrary(node);
- }
function getActionsForMissingMemberDeclaration(context, info) {
return info.isJSFile ? ts.singleElementArray(createActionForAddMissingMemberInJavascriptFile(context, info)) :
createActionsForAddMissingMemberInTypeScriptFile(context, info);
@@ -444475,7 +445973,7 @@ var ts;
function addMissingMemberInJs(changeTracker, sourceFile, classDeclaration, token, makeStatic) {
var tokenName = token.text;
if (makeStatic) {
- if (classDeclaration.kind === 226 /* SyntaxKind.ClassExpression */) {
+ if (classDeclaration.kind === 228 /* SyntaxKind.ClassExpression */) {
return;
}
var className = classDeclaration.name.getText();
@@ -444526,7 +446024,7 @@ var ts;
}
function getTypeNode(checker, node, token) {
var typeNode;
- if (token.parent.parent.kind === 221 /* SyntaxKind.BinaryExpression */) {
+ if (token.parent.parent.kind === 223 /* SyntaxKind.BinaryExpression */) {
var binaryExpression = token.parent.parent;
var otherExpression = token.parent === binaryExpression.left ? binaryExpression.right : binaryExpression.left;
var widenedType = checker.getWidenedType(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(otherExpression)));
@@ -444536,7 +446034,7 @@ var ts;
var contextualType = checker.getContextualType(token.parent);
typeNode = contextualType ? checker.typeToTypeNode(contextualType, /*enclosingDeclaration*/ undefined, 1 /* NodeBuilderFlags.NoTruncation */) : undefined;
}
- return typeNode || ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */);
+ return typeNode || ts.factory.createKeywordTypeNode(131 /* SyntaxKind.AnyKeyword */);
}
function addPropertyDeclaration(changeTracker, sourceFile, node, tokenName, typeNode, modifierFlags) {
var modifiers = modifierFlags ? ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(modifierFlags)) : undefined;
@@ -444564,7 +446062,7 @@ var ts;
}
function createAddIndexSignatureAction(context, sourceFile, node, tokenName, typeNode) {
// Index signatures cannot have the static modifier.
- var stringTypeNode = ts.factory.createKeywordTypeNode(150 /* SyntaxKind.StringKeyword */);
+ var stringTypeNode = ts.factory.createKeywordTypeNode(152 /* SyntaxKind.StringKeyword */);
var indexingParameter = ts.factory.createParameterDeclaration(
/*modifiers*/ undefined,
/*dotDotDotToken*/ undefined, "x",
@@ -444595,7 +446093,7 @@ var ts;
}
function addMethodDeclaration(context, changes, callExpression, name, modifierFlags, parentDeclaration, sourceFile) {
var importAdder = codefix.createImportAdder(sourceFile, context.program, context.preferences, context.host);
- var kind = ts.isClassLike(parentDeclaration) ? 169 /* SyntaxKind.MethodDeclaration */ : 168 /* SyntaxKind.MethodSignature */;
+ var kind = ts.isClassLike(parentDeclaration) ? 171 /* SyntaxKind.MethodDeclaration */ : 170 /* SyntaxKind.MethodSignature */;
var signatureDeclaration = codefix.createSignatureDeclarationFromCallExpression(kind, context, importAdder, callExpression, name, modifierFlags, parentDeclaration);
var containingMethodDeclaration = tryGetContainingMethodDeclaration(parentDeclaration, callExpression);
if (containingMethodDeclaration) {
@@ -444624,9 +446122,17 @@ var ts;
});
}
function addFunctionDeclaration(changes, context, info) {
+ var quotePreference = ts.getQuotePreference(context.sourceFile, context.preferences);
var importAdder = codefix.createImportAdder(context.sourceFile, context.program, context.preferences, context.host);
- var functionDeclaration = codefix.createSignatureDeclarationFromCallExpression(256 /* SyntaxKind.FunctionDeclaration */, context, importAdder, info.call, ts.idText(info.token), info.modifierFlags, info.parentDeclaration);
- changes.insertNodeAtEndOfScope(info.sourceFile, info.parentDeclaration, functionDeclaration);
+ var functionDeclaration = info.kind === InfoKind.Function
+ ? codefix.createSignatureDeclarationFromCallExpression(259 /* SyntaxKind.FunctionDeclaration */, context, importAdder, info.call, ts.idText(info.token), info.modifierFlags, info.parentDeclaration)
+ : codefix.createSignatureDeclarationFromSignature(259 /* SyntaxKind.FunctionDeclaration */, context, quotePreference, info.signature, codefix.createStubbedBody(ts.Diagnostics.Function_not_implemented.message, quotePreference), info.token, /*modifiers*/ undefined, /*optional*/ undefined, /*enclosingDeclaration*/ undefined, importAdder);
+ if (functionDeclaration === undefined) {
+ ts.Debug.fail("fixMissingFunctionDeclaration codefix got unexpected error.");
+ }
+ ts.isReturnStatement(info.parentDeclaration)
+ ? changes.insertNodeBefore(info.sourceFile, info.parentDeclaration, functionDeclaration, /*blankLineBetween*/ true)
+ : changes.insertNodeAtEndOfScope(info.sourceFile, info.parentDeclaration, functionDeclaration);
importAdder.writeFixes(changes);
}
function addJsxAttributes(changes, context, info) {
@@ -444722,7 +446228,7 @@ var ts;
var signature = checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */);
if (signature === undefined)
return createUndefined();
- var func = codefix.createSignatureDeclarationFromSignature(213 /* SyntaxKind.FunctionExpression */, context, quotePreference, signature[0], codefix.createStubbedBody(ts.Diagnostics.Function_not_implemented.message, quotePreference), /*name*/ undefined, /*modifiers*/ undefined, /*optional*/ undefined, /*enclosingDeclaration*/ enclosingDeclaration, importAdder);
+ var func = codefix.createSignatureDeclarationFromSignature(215 /* SyntaxKind.FunctionExpression */, context, quotePreference, signature[0], codefix.createStubbedBody(ts.Diagnostics.Function_not_implemented.message, quotePreference), /*name*/ undefined, /*modifiers*/ undefined, /*optional*/ undefined, /*enclosingDeclaration*/ enclosingDeclaration, importAdder);
return func !== null && func !== void 0 ? func : createUndefined();
}
if (ts.getObjectFlags(type) & 1 /* ObjectFlags.Class */) {
@@ -444776,14 +446282,21 @@ var ts;
return declaration && declaration.parent === node ? declaration : undefined;
}
function createPropertyNameFromSymbol(symbol, target, quotePreference, checker) {
- if (ts.isTransientSymbol(symbol) && symbol.nameType && symbol.nameType.flags & 8192 /* TypeFlags.UniqueESSymbol */) {
- var expression = checker.symbolToExpression(symbol.nameType.symbol, 111551 /* SymbolFlags.Value */, symbol.valueDeclaration, 1048576 /* NodeBuilderFlags.AllowUniqueESSymbolType */);
- if (expression) {
- return ts.factory.createComputedPropertyName(expression);
- }
+ if (ts.isTransientSymbol(symbol)) {
+ var prop = checker.symbolToNode(symbol, 111551 /* SymbolFlags.Value */, /*enclosingDeclaration*/ undefined, 1073741824 /* NodeBuilderFlags.WriteComputedProps */);
+ if (prop && ts.isComputedPropertyName(prop))
+ return prop;
}
return ts.createPropertyNameNodeForIdentifierOrLiteral(symbol.name, target, quotePreference === 0 /* QuotePreference.Single */);
}
+ function findScope(node) {
+ if (ts.findAncestor(node, ts.isJsxExpression)) {
+ var returnStatement = ts.findAncestor(node.parent, ts.isReturnStatement);
+ if (returnStatement)
+ return returnStatement;
+ }
+ return ts.getSourceFileOfNode(node);
+ }
})(codefix = ts.codefix || (ts.codefix = {}));
})(ts || (ts = {}));
/* @internal */
@@ -444934,7 +446447,7 @@ var ts;
// See `codeFixClassExtendAbstractProtectedProperty.ts` in https://github.com/Microsoft/TypeScript/pull/11547/files
// (now named `codeFixClassExtendAbstractPrivateProperty.ts`)
var flags = ts.getSyntacticModifierFlags(ts.first(symbol.getDeclarations()));
- return !(flags & 8 /* ModifierFlags.Private */) && !!(flags & 128 /* ModifierFlags.Abstract */);
+ return !(flags & 8 /* ModifierFlags.Private */) && !!(flags & 256 /* ModifierFlags.Abstract */);
}
})(codefix = ts.codefix || (ts.codefix = {}));
})(ts || (ts = {}));
@@ -445097,6 +446610,63 @@ var ts;
})(ts || (ts = {}));
/* @internal */
var ts;
+(function (ts) {
+ var codefix;
+ (function (codefix) {
+ var fixId = "fixNaNEquality";
+ var errorCodes = [
+ ts.Diagnostics.This_condition_will_always_return_0.code,
+ ];
+ codefix.registerCodeFix({
+ errorCodes: errorCodes,
+ getCodeActions: function (context) {
+ var sourceFile = context.sourceFile, span = context.span, program = context.program;
+ var info = getInfo(program, sourceFile, span);
+ if (info === undefined)
+ return;
+ var suggestion = info.suggestion, expression = info.expression, arg = info.arg;
+ var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, sourceFile, arg, expression); });
+ return [codefix.createCodeFixAction(fixId, changes, [ts.Diagnostics.Use_0, suggestion], fixId, ts.Diagnostics.Use_Number_isNaN_in_all_conditions)];
+ },
+ fixIds: [fixId],
+ getAllCodeActions: function (context) {
+ return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
+ var info = getInfo(context.program, diag.file, ts.createTextSpan(diag.start, diag.length));
+ if (info) {
+ doChange(changes, diag.file, info.arg, info.expression);
+ }
+ });
+ }
+ });
+ function getInfo(program, sourceFile, span) {
+ var diag = ts.find(program.getSemanticDiagnostics(sourceFile), function (diag) { return diag.start === span.start && diag.length === span.length; });
+ if (diag === undefined || diag.relatedInformation === undefined)
+ return;
+ var related = ts.find(diag.relatedInformation, function (related) { return related.code === ts.Diagnostics.Did_you_mean_0.code; });
+ if (related === undefined || related.file === undefined || related.start === undefined || related.length === undefined)
+ return;
+ var token = codefix.findAncestorMatchingSpan(related.file, ts.createTextSpan(related.start, related.length));
+ if (token === undefined)
+ return;
+ if (ts.isExpression(token) && ts.isBinaryExpression(token.parent)) {
+ return { suggestion: getSuggestion(related.messageText), expression: token.parent, arg: token };
+ }
+ return undefined;
+ }
+ function doChange(changes, sourceFile, arg, expression) {
+ var callExpression = ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("Number"), ts.factory.createIdentifier("isNaN")), /*typeArguments*/ undefined, [arg]);
+ var operator = expression.operatorToken.kind;
+ changes.replaceNode(sourceFile, expression, operator === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */ || operator === 35 /* SyntaxKind.ExclamationEqualsToken */
+ ? ts.factory.createPrefixUnaryExpression(53 /* SyntaxKind.ExclamationToken */, callExpression) : callExpression);
+ }
+ function getSuggestion(messageText) {
+ var _a = ts.flattenDiagnosticMessageText(messageText, "\n", 0).match(/\'(.*)\'/) || [], _ = _a[0], suggestion = _a[1];
+ return suggestion;
+ }
+ })(codefix = ts.codefix || (ts.codefix = {}));
+})(ts || (ts = {}));
+/* @internal */
+var ts;
(function (ts) {
var codefix;
(function (codefix) {
@@ -445414,7 +446984,7 @@ var ts;
var importDeclaration = getImportDeclaration(context.sourceFile, context.program, context.span.start);
if (!importDeclaration)
return;
- var namespaceChanges = ts.textChanges.ChangeTracker.with(context, function (t) { return importDeclaration.kind === 270 /* SyntaxKind.ImportSpecifier */ && doNamespaceImportChange(t, context.sourceFile, importDeclaration, context.program); });
+ var namespaceChanges = ts.textChanges.ChangeTracker.with(context, function (t) { return importDeclaration.kind === 273 /* SyntaxKind.ImportSpecifier */ && doNamespaceImportChange(t, context.sourceFile, importDeclaration, context.program); });
var typeOnlyChanges = ts.textChanges.ChangeTracker.with(context, function (t) { return doTypeOnlyImportChange(t, context.sourceFile, importDeclaration, context.program); });
var actions;
if (namespaceChanges.length) {
@@ -445429,7 +446999,7 @@ var ts;
});
function getImportDeclaration(sourceFile, program, start) {
var identifier = ts.tryCast(ts.getTokenAtPosition(sourceFile, start), ts.isIdentifier);
- if (!identifier || identifier.parent.kind !== 178 /* SyntaxKind.TypeReference */)
+ if (!identifier || identifier.parent.kind !== 180 /* SyntaxKind.TypeReference */)
return;
var checker = program.getTypeChecker();
var symbol = checker.getSymbolAtLocation(identifier);
@@ -445441,11 +447011,11 @@ var ts;
// new type-only import declaration, but honestly I doubt anyone will ever use this
// codefix at all, so it's probably not worth the lines of code.
function doTypeOnlyImportChange(changes, sourceFile, importDeclaration, program) {
- if (importDeclaration.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) {
- changes.insertModifierBefore(sourceFile, 152 /* SyntaxKind.TypeKeyword */, importDeclaration.name);
+ if (importDeclaration.kind === 268 /* SyntaxKind.ImportEqualsDeclaration */) {
+ changes.insertModifierBefore(sourceFile, 154 /* SyntaxKind.TypeKeyword */, importDeclaration.name);
return;
}
- var importClause = importDeclaration.kind === 267 /* SyntaxKind.ImportClause */ ? importDeclaration : importDeclaration.parent.parent;
+ var importClause = importDeclaration.kind === 270 /* SyntaxKind.ImportClause */ ? importDeclaration : importDeclaration.parent.parent;
if (importClause.name && importClause.namedBindings) {
// Cannot convert an import with a default import and named bindings to type-only
// (it's a grammar error).
@@ -445462,7 +447032,7 @@ var ts;
// Don't convert it to type-only.
return;
}
- changes.insertModifierBefore(sourceFile, 152 /* SyntaxKind.TypeKeyword */, importClause);
+ changes.insertModifierBefore(sourceFile, 154 /* SyntaxKind.TypeKeyword */, importClause);
}
function doNamespaceImportChange(changes, sourceFile, importDeclaration, program) {
ts.refactor.doChangeNamedToNamespaceOrDefault(sourceFile, program, changes, importDeclaration.parent);
@@ -445540,7 +447110,7 @@ var ts;
];
}
var result = [];
- if (token.kind === 137 /* SyntaxKind.InferKeyword */) {
+ if (token.kind === 138 /* SyntaxKind.InferKeyword */) {
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return changeInferToUnknown(t, sourceFile, token); });
var name = ts.cast(token.parent, ts.isInferTypeNode).typeParameter.name.text;
result.push(codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Replace_infer_0_with_unknown, name], fixIdInfer, ts.Diagnostics.Replace_all_unused_infer_with_unknown));
@@ -445582,7 +447152,7 @@ var ts;
break;
}
case fixIdDelete: {
- if (token.kind === 137 /* SyntaxKind.InferKeyword */ || isImport(token)) {
+ if (token.kind === 138 /* SyntaxKind.InferKeyword */ || isImport(token)) {
break; // Can't delete
}
else if (ts.isJSDocTemplateTag(token)) {
@@ -445611,7 +447181,7 @@ var ts;
break;
}
case fixIdInfer:
- if (token.kind === 137 /* SyntaxKind.InferKeyword */) {
+ if (token.kind === 138 /* SyntaxKind.InferKeyword */) {
changeInferToUnknown(changes, sourceFile, token);
}
break;
@@ -445622,7 +447192,7 @@ var ts;
},
});
function changeInferToUnknown(changes, sourceFile, token) {
- changes.replaceNode(sourceFile, token.parent, ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */));
+ changes.replaceNode(sourceFile, token.parent, ts.factory.createKeywordTypeNode(157 /* SyntaxKind.UnknownKeyword */));
}
function createDeleteFix(changes, diag) {
return codefix.createCodeFixAction(fixName, changes, diag, fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations);
@@ -445632,7 +447202,7 @@ var ts;
}
function isImport(token) {
return token.kind === 100 /* SyntaxKind.ImportKeyword */
- || token.kind === 79 /* SyntaxKind.Identifier */ && (token.parent.kind === 270 /* SyntaxKind.ImportSpecifier */ || token.parent.kind === 267 /* SyntaxKind.ImportClause */);
+ || token.kind === 79 /* SyntaxKind.Identifier */ && (token.parent.kind === 273 /* SyntaxKind.ImportSpecifier */ || token.parent.kind === 270 /* SyntaxKind.ImportClause */);
}
/** Sometimes the diagnostic span is an entire ImportDeclaration, so we should remove the whole thing. */
function tryGetFullImport(token) {
@@ -445642,7 +447212,7 @@ var ts;
return ts.isVariableDeclarationList(token.parent) && ts.first(token.parent.getChildren(sourceFile)) === token;
}
function deleteEntireVariableStatement(changes, sourceFile, node) {
- changes.delete(sourceFile, node.parent.kind === 237 /* SyntaxKind.VariableStatement */ ? node.parent : node);
+ changes.delete(sourceFile, node.parent.kind === 240 /* SyntaxKind.VariableStatement */ ? node.parent : node);
}
function deleteDestructuringElements(changes, sourceFile, node) {
ts.forEach(node.elements, function (n) { return changes.delete(sourceFile, n); });
@@ -445651,7 +447221,7 @@ var ts;
// Don't offer to prefix a property.
if (errorCode === ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read.code)
return;
- if (token.kind === 137 /* SyntaxKind.InferKeyword */) {
+ if (token.kind === 138 /* SyntaxKind.InferKeyword */) {
token = ts.cast(token.parent, ts.isInferTypeNode).typeParameter.name;
}
if (ts.isIdentifier(token) && canPrefix(token)) {
@@ -445667,14 +447237,14 @@ var ts;
}
function canPrefix(token) {
switch (token.parent.kind) {
- case 164 /* SyntaxKind.Parameter */:
- case 163 /* SyntaxKind.TypeParameter */:
+ case 166 /* SyntaxKind.Parameter */:
+ case 165 /* SyntaxKind.TypeParameter */:
return true;
- case 254 /* SyntaxKind.VariableDeclaration */: {
+ case 257 /* SyntaxKind.VariableDeclaration */: {
var varDecl = token.parent;
switch (varDecl.parent.parent.kind) {
- case 244 /* SyntaxKind.ForOfStatement */:
- case 243 /* SyntaxKind.ForInStatement */:
+ case 247 /* SyntaxKind.ForOfStatement */:
+ case 246 /* SyntaxKind.ForInStatement */:
return true;
}
}
@@ -445729,8 +447299,8 @@ var ts;
function mayDeleteParameter(checker, sourceFile, parameter, sourceFiles, program, cancellationToken, isFixAll) {
var parent = parameter.parent;
switch (parent.kind) {
- case 169 /* SyntaxKind.MethodDeclaration */:
- case 171 /* SyntaxKind.Constructor */:
+ case 171 /* SyntaxKind.MethodDeclaration */:
+ case 173 /* SyntaxKind.Constructor */:
var index = parent.parameters.indexOf(parameter);
var referent = ts.isMethodDeclaration(parent) ? parent.name : parent;
var entries = ts.FindAllReferences.Core.getReferencedSymbolsForNode(parent.pos, referent, program, sourceFiles, cancellationToken);
@@ -445760,20 +447330,20 @@ var ts;
}
}
return true;
- case 256 /* SyntaxKind.FunctionDeclaration */: {
+ case 259 /* SyntaxKind.FunctionDeclaration */: {
if (parent.name && isCallbackLike(checker, sourceFile, parent.name)) {
return isLastParameter(parent, parameter, isFixAll);
}
return true;
}
- case 213 /* SyntaxKind.FunctionExpression */:
- case 214 /* SyntaxKind.ArrowFunction */:
+ case 215 /* SyntaxKind.FunctionExpression */:
+ case 216 /* SyntaxKind.ArrowFunction */:
// Can't remove a non-last parameter in a callback. Can remove a parameter in code-fix-all if future parameters are also unused.
return isLastParameter(parent, parameter, isFixAll);
- case 173 /* SyntaxKind.SetAccessor */:
+ case 175 /* SyntaxKind.SetAccessor */:
// Setter must have a parameter
return false;
- case 172 /* SyntaxKind.GetAccessor */:
+ case 174 /* SyntaxKind.GetAccessor */:
// Getter cannot have parameters
return true;
default:
@@ -445834,7 +447404,7 @@ var ts;
var container = (ts.isBlock(statement.parent) ? statement.parent : statement).parent;
if (!ts.isBlock(statement.parent) || statement === ts.first(statement.parent.statements)) {
switch (container.kind) {
- case 239 /* SyntaxKind.IfStatement */:
+ case 242 /* SyntaxKind.IfStatement */:
if (container.elseStatement) {
if (ts.isBlock(statement.parent)) {
break;
@@ -445845,8 +447415,8 @@ var ts;
return;
}
// falls through
- case 241 /* SyntaxKind.WhileStatement */:
- case 242 /* SyntaxKind.ForStatement */:
+ case 244 /* SyntaxKind.WhileStatement */:
+ case 245 /* SyntaxKind.ForStatement */:
changes.delete(sourceFile, container);
return;
}
@@ -445919,7 +447489,7 @@ var ts;
var typeNode = info.typeNode, type = info.type;
var original = typeNode.getText(sourceFile);
var actions = [fix(type, fixIdPlain, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript)];
- if (typeNode.kind === 314 /* SyntaxKind.JSDocNullableType */) {
+ if (typeNode.kind === 317 /* SyntaxKind.JSDocNullableType */) {
// for nullable types, suggest the flow-compatible `T | null | undefined`
// in addition to the jsdoc/closure-compatible `T | null`
actions.push(fix(checker.getNullableType(type, 32768 /* TypeFlags.Undefined */), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types));
@@ -445939,7 +447509,7 @@ var ts;
if (!info)
return;
var typeNode = info.typeNode, type = info.type;
- var fixedType = typeNode.kind === 314 /* SyntaxKind.JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* TypeFlags.Undefined */) : type;
+ var fixedType = typeNode.kind === 317 /* SyntaxKind.JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* TypeFlags.Undefined */) : type;
doChange(changes, sourceFile, typeNode, fixedType, checker);
});
}
@@ -445956,22 +447526,22 @@ var ts;
// NOTE: Some locations are not handled yet:
// MappedTypeNode.typeParameters and SignatureDeclaration.typeParameters, as well as CallExpression.typeArguments
switch (node.kind) {
- case 229 /* SyntaxKind.AsExpression */:
- case 174 /* SyntaxKind.CallSignature */:
- case 175 /* SyntaxKind.ConstructSignature */:
- case 256 /* SyntaxKind.FunctionDeclaration */:
- case 172 /* SyntaxKind.GetAccessor */:
- case 176 /* SyntaxKind.IndexSignature */:
- case 195 /* SyntaxKind.MappedType */:
- case 169 /* SyntaxKind.MethodDeclaration */:
- case 168 /* SyntaxKind.MethodSignature */:
- case 164 /* SyntaxKind.Parameter */:
- case 167 /* SyntaxKind.PropertyDeclaration */:
- case 166 /* SyntaxKind.PropertySignature */:
- case 173 /* SyntaxKind.SetAccessor */:
- case 259 /* SyntaxKind.TypeAliasDeclaration */:
- case 211 /* SyntaxKind.TypeAssertionExpression */:
- case 254 /* SyntaxKind.VariableDeclaration */:
+ case 231 /* SyntaxKind.AsExpression */:
+ case 176 /* SyntaxKind.CallSignature */:
+ case 177 /* SyntaxKind.ConstructSignature */:
+ case 259 /* SyntaxKind.FunctionDeclaration */:
+ case 174 /* SyntaxKind.GetAccessor */:
+ case 178 /* SyntaxKind.IndexSignature */:
+ case 197 /* SyntaxKind.MappedType */:
+ case 171 /* SyntaxKind.MethodDeclaration */:
+ case 170 /* SyntaxKind.MethodSignature */:
+ case 166 /* SyntaxKind.Parameter */:
+ case 169 /* SyntaxKind.PropertyDeclaration */:
+ case 168 /* SyntaxKind.PropertySignature */:
+ case 175 /* SyntaxKind.SetAccessor */:
+ case 262 /* SyntaxKind.TypeAliasDeclaration */:
+ case 213 /* SyntaxKind.TypeAssertionExpression */:
+ case 257 /* SyntaxKind.VariableDeclaration */:
return true;
default:
return false;
@@ -446074,14 +447644,14 @@ var ts;
}
var insertBefore;
switch (containingFunction.kind) {
- case 169 /* SyntaxKind.MethodDeclaration */:
+ case 171 /* SyntaxKind.MethodDeclaration */:
insertBefore = containingFunction.name;
break;
- case 256 /* SyntaxKind.FunctionDeclaration */:
- case 213 /* SyntaxKind.FunctionExpression */:
+ case 259 /* SyntaxKind.FunctionDeclaration */:
+ case 215 /* SyntaxKind.FunctionExpression */:
insertBefore = ts.findChildOfKind(containingFunction, 98 /* SyntaxKind.FunctionKeyword */, sourceFile);
break;
- case 214 /* SyntaxKind.ArrowFunction */:
+ case 216 /* SyntaxKind.ArrowFunction */:
var kind = containingFunction.typeParameters ? 29 /* SyntaxKind.LessThanToken */ : 20 /* SyntaxKind.OpenParenToken */;
insertBefore = ts.findChildOfKind(containingFunction, kind, sourceFile) || ts.first(containingFunction.parameters);
break;
@@ -446101,7 +447671,7 @@ var ts;
changes.replaceNode(sourceFile, returnType, ts.factory.createTypeReferenceNode("Promise", ts.factory.createNodeArray([returnType])));
}
}
- changes.insertModifierBefore(sourceFile, 131 /* SyntaxKind.AsyncKeyword */, insertBefore);
+ changes.insertModifierBefore(sourceFile, 132 /* SyntaxKind.AsyncKeyword */, insertBefore);
}
})(codefix = ts.codefix || (ts.codefix = {}));
})(ts || (ts = {}));
@@ -446417,7 +447987,7 @@ var ts;
function annotate(changes, importAdder, sourceFile, declaration, type, program, host) {
var typeNode = ts.getTypeNodeIfAccessible(type, declaration, program, host);
if (typeNode) {
- if (ts.isInJSFile(sourceFile) && declaration.kind !== 166 /* SyntaxKind.PropertySignature */) {
+ if (ts.isInJSFile(sourceFile) && declaration.kind !== 168 /* SyntaxKind.PropertySignature */) {
var parent = ts.isVariableDeclaration(declaration) ? ts.tryCast(declaration.parent.parent, ts.isVariableStatement) : declaration;
if (!parent) {
return;
@@ -446504,19 +448074,19 @@ var ts;
function getFunctionReferences(containingFunction, sourceFile, program, cancellationToken) {
var searchToken;
switch (containingFunction.kind) {
- case 171 /* SyntaxKind.Constructor */:
- searchToken = ts.findChildOfKind(containingFunction, 134 /* SyntaxKind.ConstructorKeyword */, sourceFile);
+ case 173 /* SyntaxKind.Constructor */:
+ searchToken = ts.findChildOfKind(containingFunction, 135 /* SyntaxKind.ConstructorKeyword */, sourceFile);
break;
- case 214 /* SyntaxKind.ArrowFunction */:
- case 213 /* SyntaxKind.FunctionExpression */:
+ case 216 /* SyntaxKind.ArrowFunction */:
+ case 215 /* SyntaxKind.FunctionExpression */:
var parent = containingFunction.parent;
searchToken = (ts.isVariableDeclaration(parent) || ts.isPropertyDeclaration(parent)) && ts.isIdentifier(parent.name) ?
parent.name :
containingFunction.name;
break;
- case 256 /* SyntaxKind.FunctionDeclaration */:
- case 169 /* SyntaxKind.MethodDeclaration */:
- case 168 /* SyntaxKind.MethodSignature */:
+ case 259 /* SyntaxKind.FunctionDeclaration */:
+ case 171 /* SyntaxKind.MethodDeclaration */:
+ case 170 /* SyntaxKind.MethodSignature */:
searchToken = containingFunction.name;
break;
}
@@ -446658,24 +448228,24 @@ var ts;
node = node.parent;
}
switch (node.parent.kind) {
- case 238 /* SyntaxKind.ExpressionStatement */:
+ case 241 /* SyntaxKind.ExpressionStatement */:
inferTypeFromExpressionStatement(node, usage);
break;
- case 220 /* SyntaxKind.PostfixUnaryExpression */:
+ case 222 /* SyntaxKind.PostfixUnaryExpression */:
usage.isNumber = true;
break;
- case 219 /* SyntaxKind.PrefixUnaryExpression */:
+ case 221 /* SyntaxKind.PrefixUnaryExpression */:
inferTypeFromPrefixUnaryExpression(node.parent, usage);
break;
- case 221 /* SyntaxKind.BinaryExpression */:
+ case 223 /* SyntaxKind.BinaryExpression */:
inferTypeFromBinaryExpression(node, node.parent, usage);
break;
- case 289 /* SyntaxKind.CaseClause */:
- case 290 /* SyntaxKind.DefaultClause */:
+ case 292 /* SyntaxKind.CaseClause */:
+ case 293 /* SyntaxKind.DefaultClause */:
inferTypeFromSwitchStatementLabel(node.parent, usage);
break;
- case 208 /* SyntaxKind.CallExpression */:
- case 209 /* SyntaxKind.NewExpression */:
+ case 210 /* SyntaxKind.CallExpression */:
+ case 211 /* SyntaxKind.NewExpression */:
if (node.parent.expression === node) {
inferTypeFromCallExpression(node.parent, usage);
}
@@ -446683,20 +448253,20 @@ var ts;
inferTypeFromContextualType(node, usage);
}
break;
- case 206 /* SyntaxKind.PropertyAccessExpression */:
+ case 208 /* SyntaxKind.PropertyAccessExpression */:
inferTypeFromPropertyAccessExpression(node.parent, usage);
break;
- case 207 /* SyntaxKind.ElementAccessExpression */:
+ case 209 /* SyntaxKind.ElementAccessExpression */:
inferTypeFromPropertyElementExpression(node.parent, node, usage);
break;
- case 296 /* SyntaxKind.PropertyAssignment */:
- case 297 /* SyntaxKind.ShorthandPropertyAssignment */:
+ case 299 /* SyntaxKind.PropertyAssignment */:
+ case 300 /* SyntaxKind.ShorthandPropertyAssignment */:
inferTypeFromPropertyAssignment(node.parent, usage);
break;
- case 167 /* SyntaxKind.PropertyDeclaration */:
+ case 169 /* SyntaxKind.PropertyDeclaration */:
inferTypeFromPropertyDeclaration(node.parent, usage);
break;
- case 254 /* SyntaxKind.VariableDeclaration */: {
+ case 257 /* SyntaxKind.VariableDeclaration */: {
var _a = node.parent, name = _a.name, initializer = _a.initializer;
if (node === name) {
if (initializer) { // This can happen for `let x = null;` which still has an implicit-any error.
@@ -446818,7 +448388,7 @@ var ts;
case 56 /* SyntaxKind.BarBarToken */:
case 60 /* SyntaxKind.QuestionQuestionToken */:
if (node === parent.left &&
- (node.parent.parent.kind === 254 /* SyntaxKind.VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) {
+ (node.parent.parent.kind === 257 /* SyntaxKind.VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) {
// var x = x || {};
// TODO: use getFalsyflagsOfType
addCandidateType(usage, checker.getTypeAtLocation(parent.right));
@@ -446846,7 +448416,7 @@ var ts;
}
}
calculateUsageOfNode(parent, call.return_);
- if (parent.kind === 208 /* SyntaxKind.CallExpression */) {
+ if (parent.kind === 210 /* SyntaxKind.CallExpression */) {
(usage.calls || (usage.calls = [])).push(call);
}
else {
@@ -447300,25 +448870,44 @@ var ts;
* @param body If defined, this will be the body of the member node passed to `addClassElement`. Otherwise, the body will default to a stub.
*/
function addNewNodeForMemberSymbol(symbol, enclosingDeclaration, sourceFile, context, preferences, importAdder, addClassElement, body, preserveOptional, isAmbient) {
+ var _a;
if (preserveOptional === void 0) { preserveOptional = 3 /* PreserveOptionalFlags.All */; }
if (isAmbient === void 0) { isAmbient = false; }
var declarations = symbol.getDeclarations();
- if (!(declarations && declarations.length)) {
- return undefined;
- }
+ var declaration = declarations === null || declarations === void 0 ? void 0 : declarations[0];
var checker = context.program.getTypeChecker();
var scriptTarget = ts.getEmitScriptTarget(context.program.getCompilerOptions());
- var declaration = declarations[0];
- var name = ts.getSynthesizedDeepClone(ts.getNameOfDeclaration(declaration), /*includeTrivia*/ false);
- var visibilityModifier = createVisibilityModifier(ts.getEffectiveModifierFlags(declaration));
- var modifiers = visibilityModifier ? ts.factory.createNodeArray([visibilityModifier]) : undefined;
+ /**
+ * (#49811)
+ * Note that there are cases in which the symbol declaration is not present. For example, in the code below both
+ * `MappedIndirect.ax` and `MappedIndirect.ay` have no declaration node attached (due to their mapped-type
+ * parent):
+ *
+ * ```ts
+ * type Base = { ax: number; ay: string };
+ * type BaseKeys = keyof Base;
+ * type MappedIndirect = { [K in BaseKeys]: boolean };
+ * ```
+ *
+ * In such cases, we assume the declaration to be a `PropertySignature`.
+ */
+ var kind = (_a = declaration === null || declaration === void 0 ? void 0 : declaration.kind) !== null && _a !== void 0 ? _a : 168 /* SyntaxKind.PropertySignature */;
+ var declarationName = ts.getSynthesizedDeepClone(ts.getNameOfDeclaration(declaration), /*includeTrivia*/ false);
+ var effectiveModifierFlags = declaration ? ts.getEffectiveModifierFlags(declaration) : 0 /* ModifierFlags.None */;
+ var modifierFlags = effectiveModifierFlags & 4 /* ModifierFlags.Public */ ? 4 /* ModifierFlags.Public */ :
+ effectiveModifierFlags & 16 /* ModifierFlags.Protected */ ? 16 /* ModifierFlags.Protected */ :
+ 0 /* ModifierFlags.None */;
+ if (declaration && ts.isAutoAccessorPropertyDeclaration(declaration)) {
+ modifierFlags |= 128 /* ModifierFlags.Accessor */;
+ }
+ var modifiers = modifierFlags ? ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(modifierFlags)) : undefined;
var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration));
var optional = !!(symbol.flags & 16777216 /* SymbolFlags.Optional */);
var ambient = !!(enclosingDeclaration.flags & 16777216 /* NodeFlags.Ambient */) || isAmbient;
var quotePreference = ts.getQuotePreference(sourceFile, preferences);
- switch (declaration.kind) {
- case 166 /* SyntaxKind.PropertySignature */:
- case 167 /* SyntaxKind.PropertyDeclaration */:
+ switch (kind) {
+ case 168 /* SyntaxKind.PropertySignature */:
+ case 169 /* SyntaxKind.PropertyDeclaration */:
var flags = quotePreference === 0 /* QuotePreference.Single */ ? 268435456 /* NodeBuilderFlags.UseSingleQuotesForStringLiteralType */ : undefined;
var typeNode = checker.typeToTypeNode(type, enclosingDeclaration, flags, getNoopSymbolTrackerWithResolver(context));
if (importAdder) {
@@ -447328,11 +448917,12 @@ var ts;
importSymbols(importAdder, importableReference.symbols);
}
}
- addClassElement(ts.factory.createPropertyDeclaration(modifiers, name, optional && (preserveOptional & 2 /* PreserveOptionalFlags.Property */) ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, typeNode,
+ addClassElement(ts.factory.createPropertyDeclaration(modifiers, declaration ? createName(declarationName) : symbol.getName(), optional && (preserveOptional & 2 /* PreserveOptionalFlags.Property */) ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, typeNode,
/*initializer*/ undefined));
break;
- case 172 /* SyntaxKind.GetAccessor */:
- case 173 /* SyntaxKind.SetAccessor */: {
+ case 174 /* SyntaxKind.GetAccessor */:
+ case 175 /* SyntaxKind.SetAccessor */: {
+ ts.Debug.assertIsDefined(declarations);
var typeNode_1 = checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context));
var allAccessors = ts.getAllAccessorDeclarations(declarations, declaration);
var orderedAccessors = allAccessors.secondAccessor
@@ -447348,19 +448938,19 @@ var ts;
for (var _i = 0, orderedAccessors_1 = orderedAccessors; _i < orderedAccessors_1.length; _i++) {
var accessor = orderedAccessors_1[_i];
if (ts.isGetAccessorDeclaration(accessor)) {
- addClassElement(ts.factory.createGetAccessorDeclaration(modifiers, name, ts.emptyArray, typeNode_1, ambient ? undefined : body || createStubbedMethodBody(quotePreference)));
+ addClassElement(ts.factory.createGetAccessorDeclaration(modifiers, createName(declarationName), ts.emptyArray, createTypeNode(typeNode_1), createBody(body, quotePreference, ambient)));
}
else {
ts.Debug.assertNode(accessor, ts.isSetAccessorDeclaration, "The counterpart to a getter should be a setter");
var parameter = ts.getSetAccessorValueParameter(accessor);
var parameterName = parameter && ts.isIdentifier(parameter.name) ? ts.idText(parameter.name) : undefined;
- addClassElement(ts.factory.createSetAccessorDeclaration(modifiers, name, createDummyParameters(1, [parameterName], [typeNode_1], 1, /*inJs*/ false), ambient ? undefined : body || createStubbedMethodBody(quotePreference)));
+ addClassElement(ts.factory.createSetAccessorDeclaration(modifiers, createName(declarationName), createDummyParameters(1, [parameterName], [createTypeNode(typeNode_1)], 1, /*inJs*/ false), createBody(body, quotePreference, ambient)));
}
}
break;
}
- case 168 /* SyntaxKind.MethodSignature */:
- case 169 /* SyntaxKind.MethodDeclaration */:
+ case 170 /* SyntaxKind.MethodSignature */:
+ case 171 /* SyntaxKind.MethodDeclaration */:
// The signature for the implementation appears as an entry in `signatures` iff
// there is only one signature.
// If there are overloads and an implementation signature, it appears as an
@@ -447368,6 +448958,7 @@ var ts;
// If there is more than one overload but no implementation signature
// (eg: an abstract method or interface declaration), there is a 1-1
// correspondence of declarations and signatures.
+ ts.Debug.assertIsDefined(declarations);
var signatures = type.isUnion() ? ts.flatMap(type.types, function (t) { return t.getCallSignatures(); }) : type.getCallSignatures();
if (!ts.some(signatures)) {
break;
@@ -447375,31 +448966,41 @@ var ts;
if (declarations.length === 1) {
ts.Debug.assert(signatures.length === 1, "One declaration implies one signature");
var signature = signatures[0];
- outputMethod(quotePreference, signature, modifiers, name, ambient ? undefined : body || createStubbedMethodBody(quotePreference));
+ outputMethod(quotePreference, signature, modifiers, createName(declarationName), createBody(body, quotePreference, ambient));
break;
}
- for (var _a = 0, signatures_1 = signatures; _a < signatures_1.length; _a++) {
- var signature = signatures_1[_a];
+ for (var _b = 0, signatures_1 = signatures; _b < signatures_1.length; _b++) {
+ var signature = signatures_1[_b];
// Ensure nodes are fresh so they can have different positions when going through formatting.
- outputMethod(quotePreference, signature, ts.getSynthesizedDeepClones(modifiers, /*includeTrivia*/ false), ts.getSynthesizedDeepClone(name, /*includeTrivia*/ false));
+ outputMethod(quotePreference, signature, modifiers, createName(declarationName));
}
if (!ambient) {
if (declarations.length > signatures.length) {
var signature = checker.getSignatureFromDeclaration(declarations[declarations.length - 1]);
- outputMethod(quotePreference, signature, modifiers, name, body || createStubbedMethodBody(quotePreference));
+ outputMethod(quotePreference, signature, modifiers, createName(declarationName), createBody(body, quotePreference));
}
else {
ts.Debug.assert(declarations.length === signatures.length, "Declarations and signatures should match count");
- addClassElement(createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional && !!(preserveOptional & 1 /* PreserveOptionalFlags.Method */), modifiers, quotePreference, body));
+ addClassElement(createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, createName(declarationName), optional && !!(preserveOptional & 1 /* PreserveOptionalFlags.Method */), modifiers, quotePreference, body));
}
}
break;
}
function outputMethod(quotePreference, signature, modifiers, name, body) {
- var method = createSignatureDeclarationFromSignature(169 /* SyntaxKind.MethodDeclaration */, context, quotePreference, signature, body, name, modifiers, optional && !!(preserveOptional & 1 /* PreserveOptionalFlags.Method */), enclosingDeclaration, importAdder);
+ var method = createSignatureDeclarationFromSignature(171 /* SyntaxKind.MethodDeclaration */, context, quotePreference, signature, body, name, modifiers, optional && !!(preserveOptional & 1 /* PreserveOptionalFlags.Method */), enclosingDeclaration, importAdder);
if (method)
addClassElement(method);
}
+ function createName(node) {
+ return ts.getSynthesizedDeepClone(node, /*includeTrivia*/ false);
+ }
+ function createBody(block, quotePreference, ambient) {
+ return ambient ? undefined :
+ ts.getSynthesizedDeepClone(block, /*includeTrivia*/ false) || createStubbedMethodBody(quotePreference);
+ }
+ function createTypeNode(typeNode) {
+ return ts.getSynthesizedDeepClone(typeNode, /*includeTrivia*/ false);
+ }
}
codefix.addNewNodeForMemberSymbol = addNewNodeForMemberSymbol;
function createSignatureDeclarationFromSignature(kind, context, quotePreference, signature, body, name, modifiers, optional, enclosingDeclaration, importAdder) {
@@ -447473,6 +449074,9 @@ var ts;
if (ts.isMethodDeclaration(signatureDeclaration)) {
return ts.factory.updateMethodDeclaration(signatureDeclaration, modifiers, asteriskToken, name !== null && name !== void 0 ? name : ts.factory.createIdentifier(""), questionToken, typeParameters, parameters, type, body);
}
+ if (ts.isFunctionDeclaration(signatureDeclaration)) {
+ return ts.factory.updateFunctionDeclaration(signatureDeclaration, modifiers, signatureDeclaration.asteriskToken, ts.tryCast(name, ts.isIdentifier), typeParameters, parameters, type, body !== null && body !== void 0 ? body : signatureDeclaration.body);
+ }
return undefined;
}
codefix.createSignatureDeclarationFromSignature = createSignatureDeclarationFromSignature;
@@ -447501,13 +449105,13 @@ var ts;
? undefined
: checker.typeToTypeNode(contextualType, contextNode, /*flags*/ undefined, tracker);
switch (kind) {
- case 169 /* SyntaxKind.MethodDeclaration */:
+ case 171 /* SyntaxKind.MethodDeclaration */:
return ts.factory.createMethodDeclaration(modifiers, asteriskToken, name,
/*questionToken*/ undefined, typeParameters, parameters, type, createStubbedMethodBody(quotePreference));
- case 168 /* SyntaxKind.MethodSignature */:
+ case 170 /* SyntaxKind.MethodSignature */:
return ts.factory.createMethodSignature(modifiers, name,
- /*questionToken*/ undefined, typeParameters, parameters, type === undefined ? ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */) : type);
- case 256 /* SyntaxKind.FunctionDeclaration */:
+ /*questionToken*/ undefined, typeParameters, parameters, type === undefined ? ts.factory.createKeywordTypeNode(157 /* SyntaxKind.UnknownKeyword */) : type);
+ case 259 /* SyntaxKind.FunctionDeclaration */:
return ts.factory.createFunctionDeclaration(modifiers, asteriskToken, name, typeParameters, parameters, type, createStubbedBody(ts.Diagnostics.Function_not_implemented.message, quotePreference));
default:
ts.Debug.fail("Unexpected kind");
@@ -447644,7 +449248,7 @@ var ts;
/*dotDotDotToken*/ undefined,
/*name*/ parameterName + (parameterNameCount || ""),
/*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined,
- /*type*/ inJs ? undefined : (types === null || types === void 0 ? void 0 : types[i]) || ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */),
+ /*type*/ inJs ? undefined : (types === null || types === void 0 ? void 0 : types[i]) || ts.factory.createKeywordTypeNode(157 /* SyntaxKind.UnknownKeyword */),
/*initializer*/ undefined);
parameters.push(newParameter);
}
@@ -447674,7 +449278,7 @@ var ts;
if (someSigHasRestParameter) {
var restParameter = ts.factory.createParameterDeclaration(
/*modifiers*/ undefined, ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */), maxArgsParameterSymbolNames[maxNonRestArgs] || "rest",
- /*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, ts.factory.createArrayTypeNode(ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */)),
+ /*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, ts.factory.createArrayTypeNode(ts.factory.createKeywordTypeNode(157 /* SyntaxKind.UnknownKeyword */)),
/*initializer*/ undefined);
parameters.push(restParameter);
}
@@ -447702,15 +449306,6 @@ var ts;
/*multiline*/ true);
}
codefix.createStubbedBody = createStubbedBody;
- function createVisibilityModifier(flags) {
- if (flags & 4 /* ModifierFlags.Public */) {
- return ts.factory.createToken(123 /* SyntaxKind.PublicKeyword */);
- }
- else if (flags & 16 /* ModifierFlags.Protected */) {
- return ts.factory.createToken(122 /* SyntaxKind.ProtectedKeyword */);
- }
- return undefined;
- }
function setJsonCompilerOptionValues(changeTracker, configFile, options) {
var tsconfigObjectLiteral = ts.getTsConfigObjectLiteralExpression(configFile);
if (!tsconfigObjectLiteral)
@@ -447789,6 +449384,15 @@ var ts;
symbols.forEach(function (s) { return importAdder.addImportFromExportedSymbol(s, /*isValidTypeOnlyUseSite*/ true); });
}
codefix.importSymbols = importSymbols;
+ function findAncestorMatchingSpan(sourceFile, span) {
+ var end = ts.textSpanEnd(span);
+ var token = ts.getTokenAtPosition(sourceFile, span.start);
+ while (token.end < end) {
+ token = token.parent;
+ }
+ return token;
+ }
+ codefix.findAncestorMatchingSpan = findAncestorMatchingSpan;
})(codefix = ts.codefix || (ts.codefix = {}));
})(ts || (ts = {}));
/* @internal */
@@ -447811,13 +449415,13 @@ var ts;
if (ts.isClassLike(container)) {
var modifierFlags = ts.getEffectiveModifierFlags(declaration);
if (ts.isSourceFileJS(file)) {
- var modifiers = ts.createModifiers(modifierFlags);
+ var modifiers = ts.factory.createModifiersFromModifierFlags(modifierFlags);
accessorModifiers = modifiers;
fieldModifiers = modifiers;
}
else {
- accessorModifiers = ts.createModifiers(prepareModifierFlagsForAccessor(modifierFlags));
- fieldModifiers = ts.createModifiers(prepareModifierFlagsForField(modifierFlags));
+ accessorModifiers = ts.factory.createModifiersFromModifierFlags(prepareModifierFlagsForAccessor(modifierFlags));
+ fieldModifiers = ts.factory.createModifiersFromModifierFlags(prepareModifierFlagsForField(modifierFlags));
}
if (ts.canHaveDecorators(declaration)) {
fieldModifiers = ts.concatenate(ts.getDecorators(declaration), fieldModifiers);
@@ -447886,7 +449490,7 @@ var ts;
error: ts.getLocaleSpecificMessage(ts.Diagnostics.Name_is_not_valid)
};
}
- if (((ts.getEffectiveModifierFlags(declaration) & 125951 /* ModifierFlags.Modifier */) | meaning) !== meaning) {
+ if (((ts.getEffectiveModifierFlags(declaration) & 126975 /* ModifierFlags.Modifier */) | meaning) !== meaning) {
return {
error: ts.getLocaleSpecificMessage(ts.Diagnostics.Can_only_convert_property_with_modifier)
};
@@ -447899,7 +449503,7 @@ var ts;
isStatic: ts.hasStaticModifier(declaration),
isReadonly: ts.hasEffectiveReadonlyModifier(declaration),
type: getDeclarationType(declaration, program),
- container: declaration.kind === 164 /* SyntaxKind.Parameter */ ? declaration.parent.parent : declaration.parent,
+ container: declaration.kind === 166 /* SyntaxKind.Parameter */ ? declaration.parent.parent : declaration.parent,
originalName: declaration.name.text,
declaration: declaration,
fieldName: fieldName,
@@ -447973,7 +449577,7 @@ var ts;
var type = typeChecker.getTypeFromTypeNode(typeNode);
if (!typeChecker.isTypeAssignableTo(typeChecker.getUndefinedType(), type)) {
var types = ts.isUnionTypeNode(typeNode) ? typeNode.types : [typeNode];
- return ts.factory.createUnionTypeNode(__spreadArray(__spreadArray([], types, true), [ts.factory.createKeywordTypeNode(153 /* SyntaxKind.UndefinedKeyword */)], false));
+ return ts.factory.createUnionTypeNode(__spreadArray(__spreadArray([], types, true), [ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UndefinedKeyword */)], false));
}
}
return typeNode;
@@ -448031,7 +449635,7 @@ var ts;
});
function getActionsForUsageOfInvalidImport(context) {
var sourceFile = context.sourceFile;
- var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 208 /* SyntaxKind.CallExpression */ : 209 /* SyntaxKind.NewExpression */;
+ var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 210 /* SyntaxKind.CallExpression */ : 211 /* SyntaxKind.NewExpression */;
var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start), function (a) { return a.kind === targetKind; });
if (!node) {
return [];
@@ -448157,7 +449761,7 @@ var ts;
return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_undefined_type_to_property_0, info.prop.name.getText()], fixIdAddUndefinedType, ts.Diagnostics.Add_undefined_type_to_all_uninitialized_properties);
}
function addUndefinedType(changeTracker, sourceFile, info) {
- var undefinedTypeNode = ts.factory.createKeywordTypeNode(153 /* SyntaxKind.UndefinedKeyword */);
+ var undefinedTypeNode = ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UndefinedKeyword */);
var types = ts.isUnionTypeNode(info.type) ? info.type.types.concat(undefinedTypeNode) : [info.type, undefinedTypeNode];
var unionTypeNode = ts.factory.createUnionTypeNode(types);
if (info.isJs) {
@@ -448203,7 +449807,7 @@ var ts;
}
else if (type.isClass()) {
var classDeclaration = ts.getClassLikeDeclarationOfSymbol(type.symbol);
- if (!classDeclaration || ts.hasSyntacticModifier(classDeclaration, 128 /* ModifierFlags.Abstract */))
+ if (!classDeclaration || ts.hasSyntacticModifier(classDeclaration, 256 /* ModifierFlags.Abstract */))
return undefined;
var constructorDeclaration = ts.getFirstConstructorWithBody(classDeclaration);
if (constructorDeclaration && constructorDeclaration.parameters.length)
@@ -448380,7 +449984,7 @@ var ts;
function getImportTypeNode(sourceFile, pos) {
var token = ts.getTokenAtPosition(sourceFile, pos);
ts.Debug.assert(token.kind === 100 /* SyntaxKind.ImportKeyword */, "This token should be an ImportKeyword");
- ts.Debug.assert(token.parent.kind === 200 /* SyntaxKind.ImportType */, "Token parent should be an ImportType");
+ ts.Debug.assert(token.parent.kind === 202 /* SyntaxKind.ImportType */, "Token parent should be an ImportType");
return token.parent;
}
function doChange(changes, sourceFile, importType) {
@@ -448509,7 +450113,7 @@ var ts;
var otherMembers = members.filter(function (member) { return !ts.isIndexSignatureDeclaration(member); });
var parameter = ts.first(indexSignature.parameters);
var mappedTypeParameter = ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.cast(parameter.name, ts.isIdentifier), parameter.type);
- var mappedIntersectionType = ts.factory.createMappedTypeNode(ts.hasEffectiveReadonlyModifier(indexSignature) ? ts.factory.createModifier(145 /* SyntaxKind.ReadonlyKeyword */) : undefined, mappedTypeParameter,
+ var mappedIntersectionType = ts.factory.createMappedTypeNode(ts.hasEffectiveReadonlyModifier(indexSignature) ? ts.factory.createModifier(146 /* SyntaxKind.ReadonlyKeyword */) : undefined, mappedTypeParameter,
/*nameType*/ undefined, indexSignature.questionToken, indexSignature.type,
/*members*/ undefined);
var intersectionType = ts.factory.createIntersectionTypeNode(__spreadArray(__spreadArray(__spreadArray([], ts.getAllSuperTypeNodes(container), true), [
@@ -448567,7 +450171,7 @@ var ts;
},
});
function makeChange(changeTracker, sourceFile, span) {
- var awaitKeyword = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), function (node) { return node.kind === 132 /* SyntaxKind.AwaitKeyword */; });
+ var awaitKeyword = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), function (node) { return node.kind === 133 /* SyntaxKind.AwaitKeyword */; });
var awaitExpression = awaitKeyword && ts.tryCast(awaitKeyword.parent, ts.isAwaitExpression);
if (!awaitExpression) {
return;
@@ -448634,28 +450238,45 @@ var ts;
errorCodes: errorCodes,
getCodeActions: function getCodeActionsToConvertConstToLet(context) {
var sourceFile = context.sourceFile, span = context.span, program = context.program;
- var range = getConstTokenRange(sourceFile, span.start, program);
- if (range === undefined)
+ var info = getInfo(sourceFile, span.start, program);
+ if (info === undefined)
return;
- var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, sourceFile, range); });
- return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Convert_const_to_let, fixId, ts.Diagnostics.Convert_const_to_let)];
+ var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, sourceFile, info.token); });
+ return [codefix.createCodeFixActionMaybeFixAll(fixId, changes, ts.Diagnostics.Convert_const_to_let, fixId, ts.Diagnostics.Convert_all_const_to_let)];
+ },
+ getAllCodeActions: function (context) {
+ var program = context.program;
+ var seen = new ts.Map();
+ return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) {
+ codefix.eachDiagnostic(context, errorCodes, function (diag) {
+ var info = getInfo(diag.file, diag.start, program);
+ if (info) {
+ if (ts.addToSeen(seen, ts.getSymbolId(info.symbol))) {
+ return doChange(changes, diag.file, info.token);
+ }
+ }
+ return undefined;
+ });
+ }));
},
fixIds: [fixId]
});
- function getConstTokenRange(sourceFile, pos, program) {
+ function getInfo(sourceFile, pos, program) {
var _a;
var checker = program.getTypeChecker();
var symbol = checker.getSymbolAtLocation(ts.getTokenAtPosition(sourceFile, pos));
+ if (symbol === undefined)
+ return;
var declaration = ts.tryCast((_a = symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration) === null || _a === void 0 ? void 0 : _a.parent, ts.isVariableDeclarationList);
if (declaration === undefined)
return;
var constToken = ts.findChildOfKind(declaration, 85 /* SyntaxKind.ConstKeyword */, sourceFile);
if (constToken === undefined)
return;
- return ts.createRange(constToken.pos, constToken.end);
+ return { symbol: symbol, token: constToken };
}
- function doChange(changes, sourceFile, range) {
- changes.replaceRangeWithText(sourceFile, range, "let");
+ function doChange(changes, sourceFile, token) {
+ changes.replaceNode(sourceFile, token, ts.factory.createToken(119 /* SyntaxKind.LetKeyword */));
}
})(codefix = ts.codefix || (ts.codefix = {}));
})(ts || (ts = {}));
@@ -448830,7 +450451,6 @@ var ts;
return { edits: edits, renameFilename: undefined, renameLocation: undefined };
},
});
- ;
function getInfo(context, considerPartialSpans) {
if (considerPartialSpans === void 0) { considerPartialSpans = true; }
var file = context.file, program = context.program;
@@ -448842,8 +450462,8 @@ var ts;
}
var checker = program.getTypeChecker();
var exportingModuleSymbol = getExportingModuleSymbol(exportNode, checker);
- var flags = ts.getSyntacticModifierFlags(exportNode) || ((ts.isExportAssignment(exportNode) && !exportNode.isExportEquals) ? 513 /* ModifierFlags.ExportDefault */ : 0 /* ModifierFlags.None */);
- var wasDefault = !!(flags & 512 /* ModifierFlags.Default */);
+ var flags = ts.getSyntacticModifierFlags(exportNode) || ((ts.isExportAssignment(exportNode) && !exportNode.isExportEquals) ? 1025 /* ModifierFlags.ExportDefault */ : 0 /* ModifierFlags.None */);
+ var wasDefault = !!(flags & 1024 /* ModifierFlags.Default */);
// If source file already has a default export, don't offer refactor.
if (!(flags & 1 /* ModifierFlags.Export */) || !wasDefault && exportingModuleSymbol.exports.has("default" /* InternalSymbolName.Default */)) {
return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.This_file_already_has_a_default_export) };
@@ -448853,19 +450473,19 @@ var ts;
: { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Can_only_convert_named_export) };
};
switch (exportNode.kind) {
- case 256 /* SyntaxKind.FunctionDeclaration */:
- case 257 /* SyntaxKind.ClassDeclaration */:
- case 258 /* SyntaxKind.InterfaceDeclaration */:
- case 260 /* SyntaxKind.EnumDeclaration */:
- case 259 /* SyntaxKind.TypeAliasDeclaration */:
- case 261 /* SyntaxKind.ModuleDeclaration */: {
+ case 259 /* SyntaxKind.FunctionDeclaration */:
+ case 260 /* SyntaxKind.ClassDeclaration */:
+ case 261 /* SyntaxKind.InterfaceDeclaration */:
+ case 263 /* SyntaxKind.EnumDeclaration */:
+ case 262 /* SyntaxKind.TypeAliasDeclaration */:
+ case 264 /* SyntaxKind.ModuleDeclaration */: {
var node = exportNode;
if (!node.name)
return undefined;
return noSymbolError(node.name)
|| { exportNode: node, exportName: node.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol };
}
- case 237 /* SyntaxKind.VariableStatement */: {
+ case 240 /* SyntaxKind.VariableStatement */: {
var vs = exportNode;
// Must be `export const x = something;`.
if (!(vs.declarationList.flags & 2 /* NodeFlags.Const */) || vs.declarationList.declarations.length !== 1) {
@@ -448878,7 +450498,7 @@ var ts;
return noSymbolError(decl.name)
|| { exportNode: vs, exportName: decl.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol };
}
- case 271 /* SyntaxKind.ExportAssignment */: {
+ case 274 /* SyntaxKind.ExportAssignment */: {
var node = exportNode;
if (node.isExportEquals)
return undefined;
@@ -448908,12 +450528,12 @@ var ts;
else {
var exportKeyword = ts.Debug.checkDefined(ts.findModifier(exportNode, 93 /* SyntaxKind.ExportKeyword */), "Should find an export keyword in modifier list");
switch (exportNode.kind) {
- case 256 /* SyntaxKind.FunctionDeclaration */:
- case 257 /* SyntaxKind.ClassDeclaration */:
- case 258 /* SyntaxKind.InterfaceDeclaration */:
+ case 259 /* SyntaxKind.FunctionDeclaration */:
+ case 260 /* SyntaxKind.ClassDeclaration */:
+ case 261 /* SyntaxKind.InterfaceDeclaration */:
changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.factory.createToken(88 /* SyntaxKind.DefaultKeyword */));
break;
- case 237 /* SyntaxKind.VariableStatement */:
+ case 240 /* SyntaxKind.VariableStatement */:
// If 'x' isn't used in this file and doesn't have type definition, `export const x = 0;` --> `export default 0;`
var decl = ts.first(exportNode.declarationList.declarations);
if (!ts.FindAllReferences.Core.isSymbolReferencedInFile(exportName, checker, exportingSourceFile) && !decl.type) {
@@ -448922,9 +450542,9 @@ var ts;
break;
}
// falls through
- case 260 /* SyntaxKind.EnumDeclaration */:
- case 259 /* SyntaxKind.TypeAliasDeclaration */:
- case 261 /* SyntaxKind.ModuleDeclaration */:
+ case 263 /* SyntaxKind.EnumDeclaration */:
+ case 262 /* SyntaxKind.TypeAliasDeclaration */:
+ case 264 /* SyntaxKind.ModuleDeclaration */:
// `export type T = number;` -> `type T = number; export default T;`
changes.deleteModifier(exportingSourceFile, exportKeyword);
changes.insertNodeAfter(exportingSourceFile, exportNode, ts.factory.createExportDefault(ts.factory.createIdentifier(exportName.text)));
@@ -448953,18 +450573,18 @@ var ts;
function changeDefaultToNamedImport(importingSourceFile, ref, changes, exportName) {
var parent = ref.parent;
switch (parent.kind) {
- case 206 /* SyntaxKind.PropertyAccessExpression */:
+ case 208 /* SyntaxKind.PropertyAccessExpression */:
// `a.default` --> `a.foo`
changes.replaceNode(importingSourceFile, ref, ts.factory.createIdentifier(exportName));
break;
- case 270 /* SyntaxKind.ImportSpecifier */:
- case 275 /* SyntaxKind.ExportSpecifier */: {
+ case 273 /* SyntaxKind.ImportSpecifier */:
+ case 278 /* SyntaxKind.ExportSpecifier */: {
var spec = parent;
// `default as foo` --> `foo`, `default as bar` --> `foo as bar`
changes.replaceNode(importingSourceFile, spec, makeImportSpecifier(exportName, spec.name.text));
break;
}
- case 267 /* SyntaxKind.ImportClause */: {
+ case 270 /* SyntaxKind.ImportClause */: {
var clause = parent;
ts.Debug.assert(clause.name === ref, "Import clause name should match provided ref");
var spec = makeImportSpecifier(exportName, ref.text);
@@ -448973,7 +450593,7 @@ var ts;
// `import foo from "./a";` --> `import { foo } from "./a";`
changes.replaceNode(importingSourceFile, ref, ts.factory.createNamedImports([spec]));
}
- else if (namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) {
+ else if (namedBindings.kind === 271 /* SyntaxKind.NamespaceImport */) {
// `import foo, * as a from "./a";` --> `import * as a from ".a/"; import { foo } from "./a";`
changes.deleteRange(importingSourceFile, { pos: ref.getStart(importingSourceFile), end: namedBindings.getStart(importingSourceFile) });
var quotePreference = ts.isStringLiteral(clause.parent.moduleSpecifier) ? ts.quotePreferenceFromString(clause.parent.moduleSpecifier, importingSourceFile) : 1 /* QuotePreference.Double */;
@@ -448987,7 +450607,7 @@ var ts;
}
break;
}
- case 200 /* SyntaxKind.ImportType */:
+ case 202 /* SyntaxKind.ImportType */:
var importTypeNode = parent;
changes.replaceNode(importingSourceFile, parent, ts.factory.createImportTypeNode(importTypeNode.argument, importTypeNode.assertions, ts.factory.createIdentifier(exportName), importTypeNode.typeArguments, importTypeNode.isTypeOf));
break;
@@ -448998,11 +450618,11 @@ var ts;
function changeNamedToDefaultImport(importingSourceFile, ref, changes) {
var parent = ref.parent;
switch (parent.kind) {
- case 206 /* SyntaxKind.PropertyAccessExpression */:
+ case 208 /* SyntaxKind.PropertyAccessExpression */:
// `a.foo` --> `a.default`
changes.replaceNode(importingSourceFile, ref, ts.factory.createIdentifier("default"));
break;
- case 270 /* SyntaxKind.ImportSpecifier */: {
+ case 273 /* SyntaxKind.ImportSpecifier */: {
// `import { foo } from "./a";` --> `import foo from "./a";`
// `import { foo as bar } from "./a";` --> `import bar from "./a";`
var defaultImport = ts.factory.createIdentifier(parent.name.text);
@@ -449015,7 +450635,7 @@ var ts;
}
break;
}
- case 275 /* SyntaxKind.ExportSpecifier */: {
+ case 278 /* SyntaxKind.ExportSpecifier */: {
// `export { foo } from "./a";` --> `export { default as foo } from "./a";`
// `export { foo as bar } from "./a";` --> `export { default as bar } from "./a";`
// `export { foo as default } from "./a";` --> `export { default } from "./a";`
@@ -449116,7 +450736,7 @@ var ts;
if (!importClause.namedBindings) {
return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_find_namespace_import_or_named_imports) };
}
- if (importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) {
+ if (importClause.namedBindings.kind === 271 /* SyntaxKind.NamespaceImport */) {
return { convertTo: 0 /* ImportKind.Named */, import: importClause.namedBindings };
}
var shouldUseDefault = getShouldUseDefault(context.program, importClause);
@@ -449307,7 +450927,6 @@ var ts;
});
return { edits: edits, renameFilename: undefined, renameLocation: undefined };
}
- ;
function isValidExpression(node) {
return ts.isBinaryExpression(node) || ts.isConditionalExpression(node);
}
@@ -449355,7 +450974,6 @@ var ts;
if (expression.operatorToken.kind !== 55 /* SyntaxKind.AmpersandAmpersandToken */) {
return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Can_only_convert_logical_AND_access_chains) };
}
- ;
var finalExpression = getFinalExpressionInChain(expression.right);
if (!finalExpression)
return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_find_convertible_access_expression) };
@@ -449565,27 +451183,27 @@ var ts;
var lastDeclaration = signatureDecls[signatureDecls.length - 1];
var updated = lastDeclaration;
switch (lastDeclaration.kind) {
- case 168 /* SyntaxKind.MethodSignature */: {
+ case 170 /* SyntaxKind.MethodSignature */: {
updated = ts.factory.updateMethodSignature(lastDeclaration, lastDeclaration.modifiers, lastDeclaration.name, lastDeclaration.questionToken, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type);
break;
}
- case 169 /* SyntaxKind.MethodDeclaration */: {
+ case 171 /* SyntaxKind.MethodDeclaration */: {
updated = ts.factory.updateMethodDeclaration(lastDeclaration, lastDeclaration.modifiers, lastDeclaration.asteriskToken, lastDeclaration.name, lastDeclaration.questionToken, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type, lastDeclaration.body);
break;
}
- case 174 /* SyntaxKind.CallSignature */: {
+ case 176 /* SyntaxKind.CallSignature */: {
updated = ts.factory.updateCallSignature(lastDeclaration, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type);
break;
}
- case 171 /* SyntaxKind.Constructor */: {
+ case 173 /* SyntaxKind.Constructor */: {
updated = ts.factory.updateConstructorDeclaration(lastDeclaration, lastDeclaration.modifiers, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.body);
break;
}
- case 175 /* SyntaxKind.ConstructSignature */: {
+ case 177 /* SyntaxKind.ConstructSignature */: {
updated = ts.factory.updateConstructSignature(lastDeclaration, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type);
break;
}
- case 256 /* SyntaxKind.FunctionDeclaration */: {
+ case 259 /* SyntaxKind.FunctionDeclaration */: {
updated = ts.factory.updateFunctionDeclaration(lastDeclaration, lastDeclaration.modifiers, lastDeclaration.asteriskToken, lastDeclaration.name, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type, lastDeclaration.body);
break;
}
@@ -449616,7 +451234,7 @@ var ts;
}
function convertParameterToNamedTupleMember(p) {
ts.Debug.assert(ts.isIdentifier(p.name)); // This is checked during refactoring applicability checking
- var result = ts.setTextRange(ts.factory.createNamedTupleMember(p.dotDotDotToken, p.name, p.questionToken, p.type || ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)), p);
+ var result = ts.setTextRange(ts.factory.createNamedTupleMember(p.dotDotDotToken, p.name, p.questionToken, p.type || ts.factory.createKeywordTypeNode(131 /* SyntaxKind.AnyKeyword */)), p);
var parameterDocComment = p.symbol && p.symbol.getDocumentationComment(checker);
if (parameterDocComment) {
var newComment = ts.displayPartsToString(parameterDocComment);
@@ -449636,12 +451254,12 @@ var ts;
}
function isConvertableSignatureDeclaration(d) {
switch (d.kind) {
- case 168 /* SyntaxKind.MethodSignature */:
- case 169 /* SyntaxKind.MethodDeclaration */:
- case 174 /* SyntaxKind.CallSignature */:
- case 171 /* SyntaxKind.Constructor */:
- case 175 /* SyntaxKind.ConstructSignature */:
- case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 170 /* SyntaxKind.MethodSignature */:
+ case 171 /* SyntaxKind.MethodDeclaration */:
+ case 176 /* SyntaxKind.CallSignature */:
+ case 173 /* SyntaxKind.Constructor */:
+ case 177 /* SyntaxKind.ConstructSignature */:
+ case 259 /* SyntaxKind.FunctionDeclaration */:
return true;
}
return false;
@@ -449760,8 +451378,8 @@ var ts;
var i = 0;
for (var _i = 0, extractions_1 = extractions; _i < extractions_1.length; _i++) {
var _a = extractions_1[_i], functionExtraction = _a.functionExtraction, constantExtraction = _a.constantExtraction;
- var description = functionExtraction.description;
if (refactor.refactorKindBeginsWith(extractFunctionAction.kind, requestedRefactor)) {
+ var description = functionExtraction.description;
if (functionExtraction.errors.length === 0) {
// Don't issue refactorings with duplicated names.
// Scopes come back in "innermost first" order, so extractions will
@@ -449785,15 +451403,15 @@ var ts;
}
}
if (refactor.refactorKindBeginsWith(extractConstantAction.kind, requestedRefactor)) {
+ var description = constantExtraction.description;
if (constantExtraction.errors.length === 0) {
// Don't issue refactorings with duplicated names.
// Scopes come back in "innermost first" order, so extractions will
// preferentially go into nearer scopes
- var description_1 = constantExtraction.description;
- if (!usedConstantNames.has(description_1)) {
- usedConstantNames.set(description_1, true);
+ if (!usedConstantNames.has(description)) {
+ usedConstantNames.set(description, true);
constantActions.push({
- description: description_1,
+ description: description,
name: "constant_scope_".concat(i),
kind: extractConstantAction.kind
});
@@ -449938,7 +451556,6 @@ var ts;
var start = cursorRequest ? getExtractableParent(startToken) : ts.getParentNodeInSpan(startToken, sourceFile, adjustedSpan);
// Do the same for the ending position
var end = cursorRequest ? start : ts.getParentNodeInSpan(endToken, sourceFile, adjustedSpan);
- var declarations = [];
// We'll modify these flags as we walk the tree to collect data
// about what things need to be done as part of the extraction.
var rangeFacts = RangeFacts.None;
@@ -449981,7 +451598,7 @@ var ts;
// the expression.
return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] };
}
- return { targetRange: { range: statements, facts: rangeFacts, declarations: declarations, thisNode: thisNode } };
+ return { targetRange: { range: statements, facts: rangeFacts, thisNode: thisNode } };
}
if (ts.isReturnStatement(start) && !start.expression) {
// Makes no sense to extract an expression-less return statement.
@@ -449993,7 +451610,7 @@ var ts;
if (errors) {
return { errors: errors };
}
- return { targetRange: { range: getStatementOrExpressionRange(node), facts: rangeFacts, declarations: declarations, thisNode: thisNode } }; // TODO: GH#18217
+ return { targetRange: { range: getStatementOrExpressionRange(node), facts: rangeFacts, thisNode: thisNode } }; // TODO: GH#18217
/**
* Attempt to refine the extraction node (generally, by shrinking it) to produce better results.
* @param node The unrefined extraction node.
@@ -450005,10 +451622,10 @@ var ts;
}
}
else if (ts.isVariableStatement(node) || ts.isVariableDeclarationList(node)) {
- var declarations_6 = ts.isVariableStatement(node) ? node.declarationList.declarations : node.declarations;
+ var declarations = ts.isVariableStatement(node) ? node.declarationList.declarations : node.declarations;
var numInitializers = 0;
var lastInitializer = void 0;
- for (var _i = 0, declarations_5 = declarations_6; _i < declarations_5.length; _i++) {
+ for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) {
var declaration = declarations_5[_i];
if (declaration.initializer) {
numInitializers++;
@@ -450036,20 +451653,20 @@ var ts;
function checkForStaticContext(nodeToCheck, containingClass) {
var current = nodeToCheck;
while (current !== containingClass) {
- if (current.kind === 167 /* SyntaxKind.PropertyDeclaration */) {
+ if (current.kind === 169 /* SyntaxKind.PropertyDeclaration */) {
if (ts.isStatic(current)) {
rangeFacts |= RangeFacts.InStaticRegion;
}
break;
}
- else if (current.kind === 164 /* SyntaxKind.Parameter */) {
+ else if (current.kind === 166 /* SyntaxKind.Parameter */) {
var ctorOrMethod = ts.getContainingFunction(current);
- if (ctorOrMethod.kind === 171 /* SyntaxKind.Constructor */) {
+ if (ctorOrMethod.kind === 173 /* SyntaxKind.Constructor */) {
rangeFacts |= RangeFacts.InStaticRegion;
}
break;
}
- else if (current.kind === 169 /* SyntaxKind.MethodDeclaration */) {
+ else if (current.kind === 171 /* SyntaxKind.MethodDeclaration */) {
if (ts.isStatic(current)) {
rangeFacts |= RangeFacts.InStaticRegion;
}
@@ -450087,9 +451704,9 @@ var ts;
visit(nodeToCheck);
if (rangeFacts & RangeFacts.UsesThis) {
var container = ts.getThisContainer(nodeToCheck, /** includeArrowFunctions */ false);
- if (container.kind === 256 /* SyntaxKind.FunctionDeclaration */ ||
- (container.kind === 169 /* SyntaxKind.MethodDeclaration */ && container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) ||
- container.kind === 213 /* SyntaxKind.FunctionExpression */) {
+ if (container.kind === 259 /* SyntaxKind.FunctionDeclaration */ ||
+ (container.kind === 171 /* SyntaxKind.MethodDeclaration */ && container.parent.kind === 207 /* SyntaxKind.ObjectLiteralExpression */) ||
+ container.kind === 215 /* SyntaxKind.FunctionExpression */) {
rangeFacts |= RangeFacts.UsesThisInFunction;
}
}
@@ -450100,7 +451717,7 @@ var ts;
return true;
}
if (ts.isDeclaration(node)) {
- var declaringNode = (node.kind === 254 /* SyntaxKind.VariableDeclaration */) ? node.parent.parent : node;
+ var declaringNode = (node.kind === 257 /* SyntaxKind.VariableDeclaration */) ? node.parent.parent : node;
if (ts.hasSyntacticModifier(declaringNode, 1 /* ModifierFlags.Export */)) {
// TODO: GH#18217 Silly to use `errors ||` since it's definitely not defined (see top of `visit`)
// Also, if we're only pushing one error, just use `let error: Diagnostic | undefined`!
@@ -450108,20 +451725,19 @@ var ts;
(errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractExportedEntity));
return true;
}
- declarations.push(node.symbol);
}
// Some things can't be extracted in certain situations
switch (node.kind) {
- case 266 /* SyntaxKind.ImportDeclaration */:
+ case 269 /* SyntaxKind.ImportDeclaration */:
(errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractImport));
return true;
- case 271 /* SyntaxKind.ExportAssignment */:
+ case 274 /* SyntaxKind.ExportAssignment */:
(errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractExportedEntity));
return true;
case 106 /* SyntaxKind.SuperKeyword */:
// For a super *constructor call*, we have to be extracting the entire class,
// but a super *method call* simply implies a 'this' reference
- if (node.parent.kind === 208 /* SyntaxKind.CallExpression */) {
+ if (node.parent.kind === 210 /* SyntaxKind.CallExpression */) {
// Super constructor call
var containingClass_1 = ts.getContainingClass(node);
if (containingClass_1 === undefined || containingClass_1.pos < span.start || containingClass_1.end >= (span.start + span.length)) {
@@ -450134,7 +451750,7 @@ var ts;
thisNode = node;
}
break;
- case 214 /* SyntaxKind.ArrowFunction */:
+ case 216 /* SyntaxKind.ArrowFunction */:
// check if arrow function uses this
ts.forEachChild(node, function check(n) {
if (ts.isThis(n)) {
@@ -450149,39 +451765,39 @@ var ts;
}
});
// falls through
- case 257 /* SyntaxKind.ClassDeclaration */:
- case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 260 /* SyntaxKind.ClassDeclaration */:
+ case 259 /* SyntaxKind.FunctionDeclaration */:
if (ts.isSourceFile(node.parent) && node.parent.externalModuleIndicator === undefined) {
// You cannot extract global declarations
(errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.functionWillNotBeVisibleInTheNewScope));
}
// falls through
- case 226 /* SyntaxKind.ClassExpression */:
- case 213 /* SyntaxKind.FunctionExpression */:
- case 169 /* SyntaxKind.MethodDeclaration */:
- case 171 /* SyntaxKind.Constructor */:
- case 172 /* SyntaxKind.GetAccessor */:
- case 173 /* SyntaxKind.SetAccessor */:
+ case 228 /* SyntaxKind.ClassExpression */:
+ case 215 /* SyntaxKind.FunctionExpression */:
+ case 171 /* SyntaxKind.MethodDeclaration */:
+ case 173 /* SyntaxKind.Constructor */:
+ case 174 /* SyntaxKind.GetAccessor */:
+ case 175 /* SyntaxKind.SetAccessor */:
// do not dive into functions or classes
return false;
}
var savedPermittedJumps = permittedJumps;
switch (node.kind) {
- case 239 /* SyntaxKind.IfStatement */:
+ case 242 /* SyntaxKind.IfStatement */:
permittedJumps &= ~4 /* PermittedJumps.Return */;
break;
- case 252 /* SyntaxKind.TryStatement */:
+ case 255 /* SyntaxKind.TryStatement */:
// forbid all jumps inside try blocks
permittedJumps = 0 /* PermittedJumps.None */;
break;
- case 235 /* SyntaxKind.Block */:
- if (node.parent && node.parent.kind === 252 /* SyntaxKind.TryStatement */ && node.parent.finallyBlock === node) {
+ case 238 /* SyntaxKind.Block */:
+ if (node.parent && node.parent.kind === 255 /* SyntaxKind.TryStatement */ && node.parent.finallyBlock === node) {
// allow unconditional returns from finally blocks
permittedJumps = 4 /* PermittedJumps.Return */;
}
break;
- case 290 /* SyntaxKind.DefaultClause */:
- case 289 /* SyntaxKind.CaseClause */:
+ case 293 /* SyntaxKind.DefaultClause */:
+ case 292 /* SyntaxKind.CaseClause */:
// allow unlabeled break inside case clauses
permittedJumps |= 1 /* PermittedJumps.Break */;
break;
@@ -450193,20 +451809,20 @@ var ts;
break;
}
switch (node.kind) {
- case 192 /* SyntaxKind.ThisType */:
+ case 194 /* SyntaxKind.ThisType */:
case 108 /* SyntaxKind.ThisKeyword */:
rangeFacts |= RangeFacts.UsesThis;
thisNode = node;
break;
- case 250 /* SyntaxKind.LabeledStatement */: {
+ case 253 /* SyntaxKind.LabeledStatement */: {
var label = node.label;
(seenLabels || (seenLabels = [])).push(label.escapedText);
ts.forEachChild(node, visit);
seenLabels.pop();
break;
}
- case 246 /* SyntaxKind.BreakStatement */:
- case 245 /* SyntaxKind.ContinueStatement */: {
+ case 249 /* SyntaxKind.BreakStatement */:
+ case 248 /* SyntaxKind.ContinueStatement */: {
var label = node.label;
if (label) {
if (!ts.contains(seenLabels, label.escapedText)) {
@@ -450215,20 +451831,20 @@ var ts;
}
}
else {
- if (!(permittedJumps & (node.kind === 246 /* SyntaxKind.BreakStatement */ ? 1 /* PermittedJumps.Break */ : 2 /* PermittedJumps.Continue */))) {
+ if (!(permittedJumps & (node.kind === 249 /* SyntaxKind.BreakStatement */ ? 1 /* PermittedJumps.Break */ : 2 /* PermittedJumps.Continue */))) {
// attempt to break or continue in a forbidden context
(errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractRangeContainingConditionalBreakOrContinueStatements));
}
}
break;
}
- case 218 /* SyntaxKind.AwaitExpression */:
+ case 220 /* SyntaxKind.AwaitExpression */:
rangeFacts |= RangeFacts.IsAsyncFunction;
break;
- case 224 /* SyntaxKind.YieldExpression */:
+ case 226 /* SyntaxKind.YieldExpression */:
rangeFacts |= RangeFacts.IsGenerator;
break;
- case 247 /* SyntaxKind.ReturnStatement */:
+ case 250 /* SyntaxKind.ReturnStatement */:
if (permittedJumps & 4 /* PermittedJumps.Return */) {
rangeFacts |= RangeFacts.HasReturn;
}
@@ -450298,7 +451914,7 @@ var ts;
while (true) {
current = current.parent;
// A function parameter's initializer is actually in the outer scope, not the function declaration
- if (current.kind === 164 /* SyntaxKind.Parameter */) {
+ if (current.kind === 166 /* SyntaxKind.Parameter */) {
// Skip all the way to the outer scope of the function that declared this parameter
current = ts.findAncestor(current, function (parent) { return ts.isFunctionLikeDeclaration(parent); }).parent;
}
@@ -450309,7 +451925,7 @@ var ts;
// * Module/namespace or source file
if (isScope(current)) {
scopes.push(current);
- if (current.kind === 305 /* SyntaxKind.SourceFile */) {
+ if (current.kind === 308 /* SyntaxKind.SourceFile */) {
return scopes;
}
}
@@ -450399,32 +452015,32 @@ var ts;
}
function getDescriptionForFunctionLikeDeclaration(scope) {
switch (scope.kind) {
- case 171 /* SyntaxKind.Constructor */:
+ case 173 /* SyntaxKind.Constructor */:
return "constructor";
- case 213 /* SyntaxKind.FunctionExpression */:
- case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 215 /* SyntaxKind.FunctionExpression */:
+ case 259 /* SyntaxKind.FunctionDeclaration */:
return scope.name
? "function '".concat(scope.name.text, "'")
: ts.ANONYMOUS;
- case 214 /* SyntaxKind.ArrowFunction */:
+ case 216 /* SyntaxKind.ArrowFunction */:
return "arrow function";
- case 169 /* SyntaxKind.MethodDeclaration */:
+ case 171 /* SyntaxKind.MethodDeclaration */:
return "method '".concat(scope.name.getText(), "'");
- case 172 /* SyntaxKind.GetAccessor */:
+ case 174 /* SyntaxKind.GetAccessor */:
return "'get ".concat(scope.name.getText(), "'");
- case 173 /* SyntaxKind.SetAccessor */:
+ case 175 /* SyntaxKind.SetAccessor */:
return "'set ".concat(scope.name.getText(), "'");
default:
throw ts.Debug.assertNever(scope, "Unexpected scope kind ".concat(scope.kind));
}
}
function getDescriptionForClassLikeDeclaration(scope) {
- return scope.kind === 257 /* SyntaxKind.ClassDeclaration */
+ return scope.kind === 260 /* SyntaxKind.ClassDeclaration */
? scope.name ? "class '".concat(scope.name.text, "'") : "anonymous class declaration"
: scope.name ? "class expression '".concat(scope.name.text, "'") : "anonymous class expression";
}
function getDescriptionForModuleLikeDeclaration(scope) {
- return scope.kind === 262 /* SyntaxKind.ModuleBlock */
+ return scope.kind === 265 /* SyntaxKind.ModuleBlock */
? "namespace '".concat(scope.parent.name.getText(), "'")
: scope.externalModuleIndicator ? 0 /* SpecialScope.Module */ : 1 /* SpecialScope.Global */;
}
@@ -450497,7 +452113,7 @@ var ts;
modifiers.push(ts.factory.createModifier(124 /* SyntaxKind.StaticKeyword */));
}
if (range.facts & RangeFacts.IsAsyncFunction) {
- modifiers.push(ts.factory.createModifier(131 /* SyntaxKind.AsyncKeyword */));
+ modifiers.push(ts.factory.createModifier(132 /* SyntaxKind.AsyncKeyword */));
}
newFunction = ts.factory.createMethodDeclaration(modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* SyntaxKind.AsteriskToken */) : undefined, functionName,
/*questionToken*/ undefined, typeParameters, parameters, returnType, body);
@@ -450511,7 +452127,7 @@ var ts;
/*questionToken*/ undefined, checker.typeToTypeNode(checker.getTypeAtLocation(range.thisNode), scope, 1 /* NodeBuilderFlags.NoTruncation */),
/*initializer*/ undefined));
}
- newFunction = ts.factory.createFunctionDeclaration(range.facts & RangeFacts.IsAsyncFunction ? [ts.factory.createToken(131 /* SyntaxKind.AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* SyntaxKind.AsteriskToken */) : undefined, functionName, typeParameters, parameters, returnType, body);
+ newFunction = ts.factory.createFunctionDeclaration(range.facts & RangeFacts.IsAsyncFunction ? [ts.factory.createToken(132 /* SyntaxKind.AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* SyntaxKind.AsteriskToken */) : undefined, functionName, typeParameters, parameters, returnType, body);
}
var changeTracker = ts.textChanges.ChangeTracker.fromContext(context);
var minInsertionPos = (isReadonlyArray(range.range) ? ts.last(range.range) : range.range).end;
@@ -450659,9 +452275,9 @@ var ts;
while (ts.isParenthesizedTypeNode(withoutParens)) {
withoutParens = withoutParens.type;
}
- return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 153 /* SyntaxKind.UndefinedKeyword */; })
+ return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 155 /* SyntaxKind.UndefinedKeyword */; })
? clone
- : ts.factory.createUnionTypeNode([clone, ts.factory.createKeywordTypeNode(153 /* SyntaxKind.UndefinedKeyword */)]);
+ : ts.factory.createUnionTypeNode([clone, ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UndefinedKeyword */)]);
}
}
/**
@@ -450692,7 +452308,7 @@ var ts;
if (rangeFacts & RangeFacts.InStaticRegion) {
modifiers.push(ts.factory.createModifier(124 /* SyntaxKind.StaticKeyword */));
}
- modifiers.push(ts.factory.createModifier(145 /* SyntaxKind.ReadonlyKeyword */));
+ modifiers.push(ts.factory.createModifier(146 /* SyntaxKind.ReadonlyKeyword */));
var newVariable = ts.factory.createPropertyDeclaration(modifiers, localNameText,
/*questionToken*/ undefined, variableType, initializer);
var localReference = ts.factory.createPropertyAccessExpression(rangeFacts & RangeFacts.InStaticRegion
@@ -450723,7 +452339,7 @@ var ts;
var localReference = ts.factory.createIdentifier(localNameText);
changeTracker.replaceNode(context.file, node, localReference);
}
- else if (node.parent.kind === 238 /* SyntaxKind.ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) {
+ else if (node.parent.kind === 241 /* SyntaxKind.ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) {
// If the parent is an expression statement and the target scope is the immediately enclosing one,
// replace the statement with the declaration.
var newVariableStatement = ts.factory.createVariableStatement(
@@ -450742,7 +452358,7 @@ var ts;
changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newVariableStatement, /*blankLineBetween*/ false);
}
// Consume
- if (node.parent.kind === 238 /* SyntaxKind.ExpressionStatement */) {
+ if (node.parent.kind === 241 /* SyntaxKind.ExpressionStatement */) {
// If the parent is an expression statement, delete it.
changeTracker.delete(context.file, node.parent);
}
@@ -451388,30 +453004,30 @@ var ts;
function isExtractableExpression(node) {
var parent = node.parent;
switch (parent.kind) {
- case 299 /* SyntaxKind.EnumMember */:
+ case 302 /* SyntaxKind.EnumMember */:
return false;
}
switch (node.kind) {
case 10 /* SyntaxKind.StringLiteral */:
- return parent.kind !== 266 /* SyntaxKind.ImportDeclaration */ &&
- parent.kind !== 270 /* SyntaxKind.ImportSpecifier */;
- case 225 /* SyntaxKind.SpreadElement */:
- case 201 /* SyntaxKind.ObjectBindingPattern */:
- case 203 /* SyntaxKind.BindingElement */:
+ return parent.kind !== 269 /* SyntaxKind.ImportDeclaration */ &&
+ parent.kind !== 273 /* SyntaxKind.ImportSpecifier */;
+ case 227 /* SyntaxKind.SpreadElement */:
+ case 203 /* SyntaxKind.ObjectBindingPattern */:
+ case 205 /* SyntaxKind.BindingElement */:
return false;
case 79 /* SyntaxKind.Identifier */:
- return parent.kind !== 203 /* SyntaxKind.BindingElement */ &&
- parent.kind !== 270 /* SyntaxKind.ImportSpecifier */ &&
- parent.kind !== 275 /* SyntaxKind.ExportSpecifier */;
+ return parent.kind !== 205 /* SyntaxKind.BindingElement */ &&
+ parent.kind !== 273 /* SyntaxKind.ImportSpecifier */ &&
+ parent.kind !== 278 /* SyntaxKind.ExportSpecifier */;
}
return true;
}
function isBlockLike(node) {
switch (node.kind) {
- case 235 /* SyntaxKind.Block */:
- case 305 /* SyntaxKind.SourceFile */:
- case 262 /* SyntaxKind.ModuleBlock */:
- case 289 /* SyntaxKind.CaseClause */:
+ case 238 /* SyntaxKind.Block */:
+ case 308 /* SyntaxKind.SourceFile */:
+ case 265 /* SyntaxKind.ModuleBlock */:
+ case 292 /* SyntaxKind.CaseClause */:
return true;
default:
return false;
@@ -451699,7 +453315,6 @@ var ts;
(function (ts) {
var refactor;
(function (refactor) {
- ;
/**
* Checks if some refactor info has refactor error info.
*/
@@ -451804,15 +453419,14 @@ var ts;
// Imports will be copied to the new file anyway, and may still be needed in the old file.
// Prologue directives will be copied to the new file and should be left in the old file.
return !isPureImport(statement) && !ts.isPrologueDirective(statement);
- ;
}
function isPureImport(node) {
switch (node.kind) {
- case 266 /* SyntaxKind.ImportDeclaration */:
+ case 269 /* SyntaxKind.ImportDeclaration */:
return true;
- case 265 /* SyntaxKind.ImportEqualsDeclaration */:
+ case 268 /* SyntaxKind.ImportEqualsDeclaration */:
return !ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */);
- case 237 /* SyntaxKind.VariableStatement */:
+ case 240 /* SyntaxKind.VariableStatement */:
return node.declarationList.declarations.every(function (d) { return !!d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true); });
default:
return false;
@@ -451835,7 +453449,7 @@ var ts;
function getNewStatementsAndRemoveFromOldFile(oldFile, usage, changes, toMove, program, newModuleName, preferences) {
var checker = program.getTypeChecker();
var prologueDirectives = ts.takeWhile(oldFile.statements, ts.isPrologueDirective);
- if (!oldFile.externalModuleIndicator && !oldFile.commonJsModuleIndicator) {
+ if (oldFile.externalModuleIndicator === undefined && oldFile.commonJsModuleIndicator === undefined && usage.oldImportsNeededByNewFile.size() === 0) {
deleteMovedStatements(oldFile, toMove.ranges, changes);
return __spreadArray(__spreadArray([], prologueDirectives, true), toMove.all, true);
}
@@ -451908,12 +453522,12 @@ var ts;
}
function getNamespaceLikeImport(node) {
switch (node.kind) {
- case 266 /* SyntaxKind.ImportDeclaration */:
- return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */ ?
+ case 269 /* SyntaxKind.ImportDeclaration */:
+ return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 271 /* SyntaxKind.NamespaceImport */ ?
node.importClause.namedBindings.name : undefined;
- case 265 /* SyntaxKind.ImportEqualsDeclaration */:
+ case 268 /* SyntaxKind.ImportEqualsDeclaration */:
return node.name;
- case 254 /* SyntaxKind.VariableDeclaration */:
+ case 257 /* SyntaxKind.VariableDeclaration */:
return ts.tryCast(node.name, ts.isIdentifier);
default:
return ts.Debug.assertNever(node, "Unexpected node kind ".concat(node.kind));
@@ -451944,21 +453558,21 @@ var ts;
var newNamespaceId = ts.factory.createIdentifier(newNamespaceName);
var newModuleString = ts.factory.createStringLiteral(newModuleSpecifier);
switch (node.kind) {
- case 266 /* SyntaxKind.ImportDeclaration */:
+ case 269 /* SyntaxKind.ImportDeclaration */:
return ts.factory.createImportDeclaration(
/*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, ts.factory.createNamespaceImport(newNamespaceId)), newModuleString,
/*assertClause*/ undefined);
- case 265 /* SyntaxKind.ImportEqualsDeclaration */:
+ case 268 /* SyntaxKind.ImportEqualsDeclaration */:
return ts.factory.createImportEqualsDeclaration(/*modifiers*/ undefined, /*isTypeOnly*/ false, newNamespaceId, ts.factory.createExternalModuleReference(newModuleString));
- case 254 /* SyntaxKind.VariableDeclaration */:
+ case 257 /* SyntaxKind.VariableDeclaration */:
return ts.factory.createVariableDeclaration(newNamespaceId, /*exclamationToken*/ undefined, /*type*/ undefined, createRequireCall(newModuleString));
default:
return ts.Debug.assertNever(node, "Unexpected node kind ".concat(node.kind));
}
}
function moduleSpecifierFromImport(i) {
- return (i.kind === 266 /* SyntaxKind.ImportDeclaration */ ? i.moduleSpecifier
- : i.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ ? i.moduleReference.expression
+ return (i.kind === 269 /* SyntaxKind.ImportDeclaration */ ? i.moduleSpecifier
+ : i.kind === 268 /* SyntaxKind.ImportEqualsDeclaration */ ? i.moduleReference.expression
: i.initializer.arguments[0]);
}
function forEachImportInStatement(statement, cb) {
@@ -452028,15 +453642,15 @@ var ts;
}
function deleteUnusedImports(sourceFile, importDecl, changes, isUnused) {
switch (importDecl.kind) {
- case 266 /* SyntaxKind.ImportDeclaration */:
+ case 269 /* SyntaxKind.ImportDeclaration */:
deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused);
break;
- case 265 /* SyntaxKind.ImportEqualsDeclaration */:
+ case 268 /* SyntaxKind.ImportEqualsDeclaration */:
if (isUnused(importDecl.name)) {
changes.delete(sourceFile, importDecl);
}
break;
- case 254 /* SyntaxKind.VariableDeclaration */:
+ case 257 /* SyntaxKind.VariableDeclaration */:
deleteUnusedImportsInVariableDeclaration(sourceFile, importDecl, changes, isUnused);
break;
default:
@@ -452049,7 +453663,7 @@ var ts;
var _a = importDecl.importClause, name = _a.name, namedBindings = _a.namedBindings;
var defaultUnused = !name || isUnused(name);
var namedBindingsUnused = !namedBindings ||
- (namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); }));
+ (namedBindings.kind === 271 /* SyntaxKind.NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); }));
if (defaultUnused && namedBindingsUnused) {
changes.delete(sourceFile, importDecl);
}
@@ -452061,7 +453675,7 @@ var ts;
if (namedBindingsUnused) {
changes.replaceNode(sourceFile, importDecl.importClause, ts.factory.updateImportClause(importDecl.importClause, importDecl.importClause.isTypeOnly, name, /*namedBindings*/ undefined));
}
- else if (namedBindings.kind === 269 /* SyntaxKind.NamedImports */) {
+ else if (namedBindings.kind === 272 /* SyntaxKind.NamedImports */) {
for (var _i = 0, _b = namedBindings.elements; _i < _b.length; _i++) {
var element = _b[_i];
if (isUnused(element.name))
@@ -452076,12 +453690,17 @@ var ts;
switch (name.kind) {
case 79 /* SyntaxKind.Identifier */:
if (isUnused(name)) {
- changes.delete(sourceFile, name);
+ if (varDecl.initializer && ts.isRequireCall(varDecl.initializer, /*requireStringLiteralLikeArgument*/ true)) {
+ changes.delete(sourceFile, ts.isVariableDeclarationList(varDecl.parent) && ts.length(varDecl.parent.declarations) === 1 ? varDecl.parent.parent : varDecl);
+ }
+ else {
+ changes.delete(sourceFile, name);
+ }
}
break;
- case 202 /* SyntaxKind.ArrayBindingPattern */:
+ case 204 /* SyntaxKind.ArrayBindingPattern */:
break;
- case 201 /* SyntaxKind.ObjectBindingPattern */:
+ case 203 /* SyntaxKind.ObjectBindingPattern */:
if (name.elements.every(function (e) { return ts.isIdentifier(e.name) && isUnused(e.name); })) {
changes.delete(sourceFile, ts.isVariableDeclarationList(varDecl.parent) && varDecl.parent.declarations.length === 1 ? varDecl.parent.parent : varDecl);
}
@@ -452123,7 +453742,7 @@ var ts;
if (markSeenTop(top)) {
addExportToChanges(oldFile, top, name, changes, useEsModuleSyntax);
}
- if (ts.hasSyntacticModifier(decl, 512 /* ModifierFlags.Default */)) {
+ if (ts.hasSyntacticModifier(decl, 1024 /* ModifierFlags.Default */)) {
oldFileDefault = name;
}
else {
@@ -452211,14 +453830,14 @@ var ts;
// Below should all be utilities
function isInImport(decl) {
switch (decl.kind) {
- case 265 /* SyntaxKind.ImportEqualsDeclaration */:
- case 270 /* SyntaxKind.ImportSpecifier */:
- case 267 /* SyntaxKind.ImportClause */:
- case 268 /* SyntaxKind.NamespaceImport */:
+ case 268 /* SyntaxKind.ImportEqualsDeclaration */:
+ case 273 /* SyntaxKind.ImportSpecifier */:
+ case 270 /* SyntaxKind.ImportClause */:
+ case 271 /* SyntaxKind.NamespaceImport */:
return true;
- case 254 /* SyntaxKind.VariableDeclaration */:
+ case 257 /* SyntaxKind.VariableDeclaration */:
return isVariableDeclarationInImport(decl);
- case 203 /* SyntaxKind.BindingElement */:
+ case 205 /* SyntaxKind.BindingElement */:
return ts.isVariableDeclaration(decl.parent.parent) && isVariableDeclarationInImport(decl.parent.parent);
default:
return false;
@@ -452230,7 +453849,7 @@ var ts;
}
function filterImport(i, moduleSpecifier, keep) {
switch (i.kind) {
- case 266 /* SyntaxKind.ImportDeclaration */: {
+ case 269 /* SyntaxKind.ImportDeclaration */: {
var clause = i.importClause;
if (!clause)
return undefined;
@@ -452240,9 +453859,9 @@ var ts;
? ts.factory.createImportDeclaration(/*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, defaultImport, namedBindings), moduleSpecifier, /*assertClause*/ undefined)
: undefined;
}
- case 265 /* SyntaxKind.ImportEqualsDeclaration */:
+ case 268 /* SyntaxKind.ImportEqualsDeclaration */:
return keep(i.name) ? i : undefined;
- case 254 /* SyntaxKind.VariableDeclaration */: {
+ case 257 /* SyntaxKind.VariableDeclaration */: {
var name = filterBindingName(i.name, keep);
return name ? makeVariableStatement(name, i.type, createRequireCall(moduleSpecifier), i.parent.flags) : undefined;
}
@@ -452251,7 +453870,7 @@ var ts;
}
}
function filterNamedBindings(namedBindings, keep) {
- if (namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) {
+ if (namedBindings.kind === 271 /* SyntaxKind.NamespaceImport */) {
return keep(namedBindings.name) ? namedBindings : undefined;
}
else {
@@ -452263,9 +453882,9 @@ var ts;
switch (name.kind) {
case 79 /* SyntaxKind.Identifier */:
return keep(name) ? name : undefined;
- case 202 /* SyntaxKind.ArrayBindingPattern */:
+ case 204 /* SyntaxKind.ArrayBindingPattern */:
return name;
- case 201 /* SyntaxKind.ObjectBindingPattern */: {
+ case 203 /* SyntaxKind.ObjectBindingPattern */: {
// We can't handle nested destructurings or property names well here, so just copy them all.
var newElements = name.elements.filter(function (prop) { return prop.propertyName || !ts.isIdentifier(prop.name) || keep(prop.name); });
return newElements.length ? ts.factory.createObjectBindingPattern(newElements) : undefined;
@@ -452308,6 +453927,9 @@ var ts;
ts.copyEntries(this.map, clone.map);
return clone;
};
+ SymbolSet.prototype.size = function () {
+ return this.map.size;
+ };
return SymbolSet;
}());
function isTopLevelDeclaration(node) {
@@ -452322,13 +453944,13 @@ var ts;
}
function isNonVariableTopLevelDeclaration(node) {
switch (node.kind) {
- case 256 /* SyntaxKind.FunctionDeclaration */:
- case 257 /* SyntaxKind.ClassDeclaration */:
- case 261 /* SyntaxKind.ModuleDeclaration */:
- case 260 /* SyntaxKind.EnumDeclaration */:
- case 259 /* SyntaxKind.TypeAliasDeclaration */:
- case 258 /* SyntaxKind.InterfaceDeclaration */:
- case 265 /* SyntaxKind.ImportEqualsDeclaration */:
+ case 259 /* SyntaxKind.FunctionDeclaration */:
+ case 260 /* SyntaxKind.ClassDeclaration */:
+ case 264 /* SyntaxKind.ModuleDeclaration */:
+ case 263 /* SyntaxKind.EnumDeclaration */:
+ case 262 /* SyntaxKind.TypeAliasDeclaration */:
+ case 261 /* SyntaxKind.InterfaceDeclaration */:
+ case 268 /* SyntaxKind.ImportEqualsDeclaration */:
return true;
default:
return false;
@@ -452336,17 +453958,17 @@ var ts;
}
function forEachTopLevelDeclaration(statement, cb) {
switch (statement.kind) {
- case 256 /* SyntaxKind.FunctionDeclaration */:
- case 257 /* SyntaxKind.ClassDeclaration */:
- case 261 /* SyntaxKind.ModuleDeclaration */:
- case 260 /* SyntaxKind.EnumDeclaration */:
- case 259 /* SyntaxKind.TypeAliasDeclaration */:
- case 258 /* SyntaxKind.InterfaceDeclaration */:
- case 265 /* SyntaxKind.ImportEqualsDeclaration */:
+ case 259 /* SyntaxKind.FunctionDeclaration */:
+ case 260 /* SyntaxKind.ClassDeclaration */:
+ case 264 /* SyntaxKind.ModuleDeclaration */:
+ case 263 /* SyntaxKind.EnumDeclaration */:
+ case 262 /* SyntaxKind.TypeAliasDeclaration */:
+ case 261 /* SyntaxKind.InterfaceDeclaration */:
+ case 268 /* SyntaxKind.ImportEqualsDeclaration */:
return cb(statement);
- case 237 /* SyntaxKind.VariableStatement */:
+ case 240 /* SyntaxKind.VariableStatement */:
return ts.firstDefined(statement.declarationList.declarations, function (decl) { return forEachTopLevelDeclarationInBindingName(decl.name, cb); });
- case 238 /* SyntaxKind.ExpressionStatement */: {
+ case 241 /* SyntaxKind.ExpressionStatement */: {
var expression = statement.expression;
return ts.isBinaryExpression(expression) && ts.getAssignmentDeclarationKind(expression) === 1 /* AssignmentDeclarationKind.ExportsProperty */
? cb(statement)
@@ -452358,8 +453980,8 @@ var ts;
switch (name.kind) {
case 79 /* SyntaxKind.Identifier */:
return cb(ts.cast(name.parent, function (x) { return ts.isVariableDeclaration(x) || ts.isBindingElement(x); }));
- case 202 /* SyntaxKind.ArrayBindingPattern */:
- case 201 /* SyntaxKind.ObjectBindingPattern */:
+ case 204 /* SyntaxKind.ArrayBindingPattern */:
+ case 203 /* SyntaxKind.ObjectBindingPattern */:
return ts.firstDefined(name.elements, function (em) { return ts.isOmittedExpression(em) ? undefined : forEachTopLevelDeclarationInBindingName(em.name, cb); });
default:
return ts.Debug.assertNever(name, "Unexpected name kind ".concat(name.kind));
@@ -452370,9 +453992,9 @@ var ts;
}
function getTopLevelDeclarationStatement(d) {
switch (d.kind) {
- case 254 /* SyntaxKind.VariableDeclaration */:
+ case 257 /* SyntaxKind.VariableDeclaration */:
return d.parent.parent;
- case 203 /* SyntaxKind.BindingElement */:
+ case 205 /* SyntaxKind.BindingElement */:
return getTopLevelDeclarationStatement(ts.cast(d.parent.parent, function (p) { return ts.isVariableDeclaration(p) || ts.isBindingElement(p); }));
default:
return d;
@@ -452396,7 +454018,8 @@ var ts;
if (useEs6Exports) {
return !ts.isExpressionStatement(decl) && ts.hasSyntacticModifier(decl, 1 /* ModifierFlags.Export */) || !!(name && ((_a = sourceFile.symbol.exports) === null || _a === void 0 ? void 0 : _a.has(name.escapedText)));
}
- return getNamesToExportInCommonJS(decl).some(function (name) { return sourceFile.symbol.exports.has(ts.escapeLeadingUnderscores(name)); });
+ return !!sourceFile.symbol && !!sourceFile.symbol.exports &&
+ getNamesToExportInCommonJS(decl).some(function (name) { return sourceFile.symbol.exports.has(ts.escapeLeadingUnderscores(name)); });
}
function addExport(decl, useEs6Exports) {
return useEs6Exports ? [addEs6Export(decl)] : addCommonjsExport(decl);
@@ -452404,24 +454027,24 @@ var ts;
function addEs6Export(d) {
var modifiers = ts.canHaveModifiers(d) ? ts.concatenate([ts.factory.createModifier(93 /* SyntaxKind.ExportKeyword */)], ts.getModifiers(d)) : undefined;
switch (d.kind) {
- case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 259 /* SyntaxKind.FunctionDeclaration */:
return ts.factory.updateFunctionDeclaration(d, modifiers, d.asteriskToken, d.name, d.typeParameters, d.parameters, d.type, d.body);
- case 257 /* SyntaxKind.ClassDeclaration */:
+ case 260 /* SyntaxKind.ClassDeclaration */:
var decorators = ts.canHaveDecorators(d) ? ts.getDecorators(d) : undefined;
return ts.factory.updateClassDeclaration(d, ts.concatenate(decorators, modifiers), d.name, d.typeParameters, d.heritageClauses, d.members);
- case 237 /* SyntaxKind.VariableStatement */:
+ case 240 /* SyntaxKind.VariableStatement */:
return ts.factory.updateVariableStatement(d, modifiers, d.declarationList);
- case 261 /* SyntaxKind.ModuleDeclaration */:
+ case 264 /* SyntaxKind.ModuleDeclaration */:
return ts.factory.updateModuleDeclaration(d, modifiers, d.name, d.body);
- case 260 /* SyntaxKind.EnumDeclaration */:
+ case 263 /* SyntaxKind.EnumDeclaration */:
return ts.factory.updateEnumDeclaration(d, modifiers, d.name, d.members);
- case 259 /* SyntaxKind.TypeAliasDeclaration */:
+ case 262 /* SyntaxKind.TypeAliasDeclaration */:
return ts.factory.updateTypeAliasDeclaration(d, modifiers, d.name, d.typeParameters, d.type);
- case 258 /* SyntaxKind.InterfaceDeclaration */:
+ case 261 /* SyntaxKind.InterfaceDeclaration */:
return ts.factory.updateInterfaceDeclaration(d, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members);
- case 265 /* SyntaxKind.ImportEqualsDeclaration */:
+ case 268 /* SyntaxKind.ImportEqualsDeclaration */:
return ts.factory.updateImportEqualsDeclaration(d, modifiers, d.isTypeOnly, d.name, d.moduleReference);
- case 238 /* SyntaxKind.ExpressionStatement */:
+ case 241 /* SyntaxKind.ExpressionStatement */:
return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...`
default:
return ts.Debug.assertNever(d, "Unexpected declaration kind ".concat(d.kind));
@@ -452432,18 +454055,18 @@ var ts;
}
function getNamesToExportInCommonJS(decl) {
switch (decl.kind) {
- case 256 /* SyntaxKind.FunctionDeclaration */:
- case 257 /* SyntaxKind.ClassDeclaration */:
+ case 259 /* SyntaxKind.FunctionDeclaration */:
+ case 260 /* SyntaxKind.ClassDeclaration */:
return [decl.name.text]; // TODO: GH#18217
- case 237 /* SyntaxKind.VariableStatement */:
+ case 240 /* SyntaxKind.VariableStatement */:
return ts.mapDefined(decl.declarationList.declarations, function (d) { return ts.isIdentifier(d.name) ? d.name.text : undefined; });
- case 261 /* SyntaxKind.ModuleDeclaration */:
- case 260 /* SyntaxKind.EnumDeclaration */:
- case 259 /* SyntaxKind.TypeAliasDeclaration */:
- case 258 /* SyntaxKind.InterfaceDeclaration */:
- case 265 /* SyntaxKind.ImportEqualsDeclaration */:
+ case 264 /* SyntaxKind.ModuleDeclaration */:
+ case 263 /* SyntaxKind.EnumDeclaration */:
+ case 262 /* SyntaxKind.TypeAliasDeclaration */:
+ case 261 /* SyntaxKind.InterfaceDeclaration */:
+ case 268 /* SyntaxKind.ImportEqualsDeclaration */:
return ts.emptyArray;
- case 238 /* SyntaxKind.ExpressionStatement */:
+ case 241 /* SyntaxKind.ExpressionStatement */:
return ts.Debug.fail("Can't export an ExpressionStatement"); // Shouldn't try to add 'export' keyword to `exports.x = ...`
default:
return ts.Debug.assertNever(decl, "Unexpected decl kind ".concat(decl.kind));
@@ -452784,15 +454407,15 @@ var ts;
var parent = functionReference.parent;
switch (parent.kind) {
// foo(...) or super(...) or new Foo(...)
- case 208 /* SyntaxKind.CallExpression */:
- case 209 /* SyntaxKind.NewExpression */:
+ case 210 /* SyntaxKind.CallExpression */:
+ case 211 /* SyntaxKind.NewExpression */:
var callOrNewExpression = ts.tryCast(parent, ts.isCallOrNewExpression);
if (callOrNewExpression && callOrNewExpression.expression === functionReference) {
return callOrNewExpression;
}
break;
// x.foo(...)
- case 206 /* SyntaxKind.PropertyAccessExpression */:
+ case 208 /* SyntaxKind.PropertyAccessExpression */:
var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression);
if (propertyAccessExpression && propertyAccessExpression.parent && propertyAccessExpression.name === functionReference) {
var callOrNewExpression_1 = ts.tryCast(propertyAccessExpression.parent, ts.isCallOrNewExpression);
@@ -452802,7 +454425,7 @@ var ts;
}
break;
// x["foo"](...)
- case 207 /* SyntaxKind.ElementAccessExpression */:
+ case 209 /* SyntaxKind.ElementAccessExpression */:
var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression);
if (elementAccessExpression && elementAccessExpression.parent && elementAccessExpression.argumentExpression === functionReference) {
var callOrNewExpression_2 = ts.tryCast(elementAccessExpression.parent, ts.isCallOrNewExpression);
@@ -452821,14 +454444,14 @@ var ts;
var parent = reference.parent;
switch (parent.kind) {
// `C.foo`
- case 206 /* SyntaxKind.PropertyAccessExpression */:
+ case 208 /* SyntaxKind.PropertyAccessExpression */:
var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression);
if (propertyAccessExpression && propertyAccessExpression.expression === reference) {
return propertyAccessExpression;
}
break;
// `C["foo"]`
- case 207 /* SyntaxKind.ElementAccessExpression */:
+ case 209 /* SyntaxKind.ElementAccessExpression */:
var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression);
if (elementAccessExpression && elementAccessExpression.expression === reference) {
return elementAccessExpression;
@@ -452874,16 +454497,16 @@ var ts;
if (!isValidParameterNodeArray(functionDeclaration.parameters, checker))
return false;
switch (functionDeclaration.kind) {
- case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 259 /* SyntaxKind.FunctionDeclaration */:
return hasNameOrDefault(functionDeclaration) && isSingleImplementation(functionDeclaration, checker);
- case 169 /* SyntaxKind.MethodDeclaration */:
+ case 171 /* SyntaxKind.MethodDeclaration */:
if (ts.isObjectLiteralExpression(functionDeclaration.parent)) {
var contextualSymbol = getSymbolForContextualType(functionDeclaration.name, checker);
// don't offer the refactor when there are multiple signatures since we won't know which ones the user wants to change
return ((_a = contextualSymbol === null || contextualSymbol === void 0 ? void 0 : contextualSymbol.declarations) === null || _a === void 0 ? void 0 : _a.length) === 1 && isSingleImplementation(functionDeclaration, checker);
}
return isSingleImplementation(functionDeclaration, checker);
- case 171 /* SyntaxKind.Constructor */:
+ case 173 /* SyntaxKind.Constructor */:
if (ts.isClassDeclaration(functionDeclaration.parent)) {
return hasNameOrDefault(functionDeclaration.parent) && isSingleImplementation(functionDeclaration, checker);
}
@@ -452891,8 +454514,8 @@ var ts;
return isValidVariableDeclaration(functionDeclaration.parent.parent)
&& isSingleImplementation(functionDeclaration, checker);
}
- case 213 /* SyntaxKind.FunctionExpression */:
- case 214 /* SyntaxKind.ArrowFunction */:
+ case 215 /* SyntaxKind.FunctionExpression */:
+ case 216 /* SyntaxKind.ArrowFunction */:
return isValidVariableDeclaration(functionDeclaration.parent);
}
return false;
@@ -453040,7 +454663,7 @@ var ts;
}
function getClassNames(constructorDeclaration) {
switch (constructorDeclaration.parent.kind) {
- case 257 /* SyntaxKind.ClassDeclaration */:
+ case 260 /* SyntaxKind.ClassDeclaration */:
var classDeclaration = constructorDeclaration.parent;
if (classDeclaration.name)
return [classDeclaration.name];
@@ -453048,7 +454671,7 @@ var ts;
// We validated this in `isValidFunctionDeclaration` through `hasNameOrDefault`
var defaultModifier = ts.Debug.checkDefined(ts.findModifier(classDeclaration, 88 /* SyntaxKind.DefaultKeyword */), "Nameless class declaration should be a default export");
return [defaultModifier];
- case 226 /* SyntaxKind.ClassExpression */:
+ case 228 /* SyntaxKind.ClassExpression */:
var classExpression = constructorDeclaration.parent;
var variableDeclaration = constructorDeclaration.parent.parent;
var className = classExpression.name;
@@ -453059,25 +454682,25 @@ var ts;
}
function getFunctionNames(functionDeclaration) {
switch (functionDeclaration.kind) {
- case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 259 /* SyntaxKind.FunctionDeclaration */:
if (functionDeclaration.name)
return [functionDeclaration.name];
// If the function declaration doesn't have a name, it should have a default modifier.
// We validated this in `isValidFunctionDeclaration` through `hasNameOrDefault`
var defaultModifier = ts.Debug.checkDefined(ts.findModifier(functionDeclaration, 88 /* SyntaxKind.DefaultKeyword */), "Nameless function declaration should be a default export");
return [defaultModifier];
- case 169 /* SyntaxKind.MethodDeclaration */:
+ case 171 /* SyntaxKind.MethodDeclaration */:
return [functionDeclaration.name];
- case 171 /* SyntaxKind.Constructor */:
- var ctrKeyword = ts.Debug.checkDefined(ts.findChildOfKind(functionDeclaration, 134 /* SyntaxKind.ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword");
- if (functionDeclaration.parent.kind === 226 /* SyntaxKind.ClassExpression */) {
+ case 173 /* SyntaxKind.Constructor */:
+ var ctrKeyword = ts.Debug.checkDefined(ts.findChildOfKind(functionDeclaration, 135 /* SyntaxKind.ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword");
+ if (functionDeclaration.parent.kind === 228 /* SyntaxKind.ClassExpression */) {
var variableDeclaration = functionDeclaration.parent.parent;
return [variableDeclaration.name, ctrKeyword];
}
return [ctrKeyword];
- case 214 /* SyntaxKind.ArrowFunction */:
+ case 216 /* SyntaxKind.ArrowFunction */:
return [functionDeclaration.parent.name];
- case 213 /* SyntaxKind.FunctionExpression */:
+ case 215 /* SyntaxKind.FunctionExpression */:
if (functionDeclaration.name)
return [functionDeclaration.name, functionDeclaration.parent.name];
return [functionDeclaration.parent.name];
@@ -453168,11 +454791,11 @@ var ts;
function getParentBinaryExpression(expr) {
var container = ts.findAncestor(expr.parent, function (n) {
switch (n.kind) {
- case 206 /* SyntaxKind.PropertyAccessExpression */:
- case 207 /* SyntaxKind.ElementAccessExpression */:
+ case 208 /* SyntaxKind.PropertyAccessExpression */:
+ case 209 /* SyntaxKind.ElementAccessExpression */:
return false;
- case 223 /* SyntaxKind.TemplateExpression */:
- case 221 /* SyntaxKind.BinaryExpression */:
+ case 225 /* SyntaxKind.TemplateExpression */:
+ case 223 /* SyntaxKind.BinaryExpression */:
return !(ts.isBinaryExpression(n.parent) && isNotEqualsOperator(n.parent));
default:
return "quit";
@@ -453620,10 +455243,10 @@ var ts;
}
function isConvertibleDeclaration(node) {
switch (node.kind) {
- case 256 /* SyntaxKind.FunctionDeclaration */:
- case 213 /* SyntaxKind.FunctionExpression */:
- case 214 /* SyntaxKind.ArrowFunction */:
- case 169 /* SyntaxKind.MethodDeclaration */:
+ case 259 /* SyntaxKind.FunctionDeclaration */:
+ case 215 /* SyntaxKind.FunctionExpression */:
+ case 216 /* SyntaxKind.ArrowFunction */:
+ case 171 /* SyntaxKind.MethodDeclaration */:
return true;
default:
return false;
@@ -453668,7 +455291,7 @@ var ts;
this.kind = kind;
}
NodeObject.prototype.assertHasRealPosition = function (message) {
- // eslint-disable-next-line debug-assert
+ // eslint-disable-next-line local/debug-assert
ts.Debug.assert(!ts.positionIsSynthesized(this.pos) && !ts.positionIsSynthesized(this.end), message || "Node must have a real position for this operation");
};
NodeObject.prototype.getSourceFile = function () {
@@ -453725,8 +455348,8 @@ var ts;
if (!children.length) {
return undefined;
}
- var child = ts.find(children, function (kid) { return kid.kind < 309 /* SyntaxKind.FirstJSDocNode */ || kid.kind > 347 /* SyntaxKind.LastJSDocNode */; });
- return child.kind < 161 /* SyntaxKind.FirstNode */ ?
+ var child = ts.find(children, function (kid) { return kid.kind < 312 /* SyntaxKind.FirstJSDocNode */ || kid.kind > 350 /* SyntaxKind.LastJSDocNode */; });
+ return child.kind < 163 /* SyntaxKind.FirstNode */ ?
child :
child.getFirstToken(sourceFile);
};
@@ -453737,7 +455360,7 @@ var ts;
if (!child) {
return undefined;
}
- return child.kind < 161 /* SyntaxKind.FirstNode */ ? child : child.getLastToken(sourceFile);
+ return child.kind < 163 /* SyntaxKind.FirstNode */ ? child : child.getLastToken(sourceFile);
};
NodeObject.prototype.forEachChild = function (cbNode, cbNodeArray) {
return ts.forEachChild(this, cbNode, cbNodeArray);
@@ -453797,7 +455420,7 @@ var ts;
}
}
function createSyntaxList(nodes, parent) {
- var list = createNode(348 /* SyntaxKind.SyntaxList */, nodes.pos, nodes.end, parent);
+ var list = createNode(351 /* SyntaxKind.SyntaxList */, nodes.pos, nodes.end, parent);
list._children = [];
var pos = nodes.pos;
for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) {
@@ -454146,7 +455769,7 @@ var ts;
var _a;
if (!seenSymbols_1.has(symbol)) {
seenSymbols_1.add(symbol);
- if (declaration.kind === 172 /* SyntaxKind.GetAccessor */ || declaration.kind === 173 /* SyntaxKind.SetAccessor */) {
+ if (declaration.kind === 174 /* SyntaxKind.GetAccessor */ || declaration.kind === 175 /* SyntaxKind.SetAccessor */) {
return symbol.getContextualJsDocTags(declaration, checker);
}
return ((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.length) === 1 ? symbol.getJsDocTags() : undefined;
@@ -454156,8 +455779,8 @@ var ts;
tags = __spreadArray(__spreadArray([], inheritedTags, true), tags, true);
}
};
- for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
- var declaration = declarations_7[_i];
+ for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) {
+ var declaration = declarations_6[_i];
_loop_20(declaration);
}
}
@@ -454173,7 +455796,7 @@ var ts;
var inheritedDocs = findBaseOfDeclaration(checker, declaration, function (symbol) {
if (!seenSymbols_2.has(symbol)) {
seenSymbols_2.add(symbol);
- if (declaration.kind === 172 /* SyntaxKind.GetAccessor */ || declaration.kind === 173 /* SyntaxKind.SetAccessor */) {
+ if (declaration.kind === 174 /* SyntaxKind.GetAccessor */ || declaration.kind === 175 /* SyntaxKind.SetAccessor */) {
return symbol.getContextualDocumentationComment(declaration, checker);
}
return symbol.getDocumentationComment(checker);
@@ -454183,8 +455806,8 @@ var ts;
if (inheritedDocs)
doc = doc.length === 0 ? inheritedDocs.slice() : inheritedDocs.concat(ts.lineBreakPart(), doc);
};
- for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) {
- var declaration = declarations_8[_i];
+ for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
+ var declaration = declarations_7[_i];
_loop_21(declaration);
}
}
@@ -454192,7 +455815,7 @@ var ts;
}
function findBaseOfDeclaration(checker, declaration, cb) {
var _a;
- var classOrInterfaceDeclaration = ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.kind) === 171 /* SyntaxKind.Constructor */ ? declaration.parent.parent : declaration.parent;
+ var classOrInterfaceDeclaration = ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.kind) === 173 /* SyntaxKind.Constructor */ ? declaration.parent.parent : declaration.parent;
if (!classOrInterfaceDeclaration)
return;
var isStaticMember = ts.hasStaticModifier(declaration);
@@ -454207,7 +455830,7 @@ var ts;
__extends(SourceFileObject, _super);
function SourceFileObject(kind, pos, end) {
var _this = _super.call(this, kind, pos, end) || this;
- _this.kind = 305 /* SyntaxKind.SourceFile */;
+ _this.kind = 308 /* SyntaxKind.SourceFile */;
return _this;
}
SourceFileObject.prototype.update = function (newText, textChangeRange) {
@@ -454266,10 +455889,10 @@ var ts;
}
function visit(node) {
switch (node.kind) {
- case 256 /* SyntaxKind.FunctionDeclaration */:
- case 213 /* SyntaxKind.FunctionExpression */:
- case 169 /* SyntaxKind.MethodDeclaration */:
- case 168 /* SyntaxKind.MethodSignature */:
+ case 259 /* SyntaxKind.FunctionDeclaration */:
+ case 215 /* SyntaxKind.FunctionExpression */:
+ case 171 /* SyntaxKind.MethodDeclaration */:
+ case 170 /* SyntaxKind.MethodSignature */:
var functionDeclaration = node;
var declarationName = getDeclarationName(functionDeclaration);
if (declarationName) {
@@ -454289,31 +455912,31 @@ var ts;
}
ts.forEachChild(node, visit);
break;
- case 257 /* SyntaxKind.ClassDeclaration */:
- case 226 /* SyntaxKind.ClassExpression */:
- case 258 /* SyntaxKind.InterfaceDeclaration */:
- case 259 /* SyntaxKind.TypeAliasDeclaration */:
- case 260 /* SyntaxKind.EnumDeclaration */:
- case 261 /* SyntaxKind.ModuleDeclaration */:
- case 265 /* SyntaxKind.ImportEqualsDeclaration */:
- case 275 /* SyntaxKind.ExportSpecifier */:
- case 270 /* SyntaxKind.ImportSpecifier */:
- case 267 /* SyntaxKind.ImportClause */:
- case 268 /* SyntaxKind.NamespaceImport */:
- case 172 /* SyntaxKind.GetAccessor */:
- case 173 /* SyntaxKind.SetAccessor */:
- case 182 /* SyntaxKind.TypeLiteral */:
+ case 260 /* SyntaxKind.ClassDeclaration */:
+ case 228 /* SyntaxKind.ClassExpression */:
+ case 261 /* SyntaxKind.InterfaceDeclaration */:
+ case 262 /* SyntaxKind.TypeAliasDeclaration */:
+ case 263 /* SyntaxKind.EnumDeclaration */:
+ case 264 /* SyntaxKind.ModuleDeclaration */:
+ case 268 /* SyntaxKind.ImportEqualsDeclaration */:
+ case 278 /* SyntaxKind.ExportSpecifier */:
+ case 273 /* SyntaxKind.ImportSpecifier */:
+ case 270 /* SyntaxKind.ImportClause */:
+ case 271 /* SyntaxKind.NamespaceImport */:
+ case 174 /* SyntaxKind.GetAccessor */:
+ case 175 /* SyntaxKind.SetAccessor */:
+ case 184 /* SyntaxKind.TypeLiteral */:
addDeclaration(node);
ts.forEachChild(node, visit);
break;
- case 164 /* SyntaxKind.Parameter */:
+ case 166 /* SyntaxKind.Parameter */:
// Only consider parameter properties
if (!ts.hasSyntacticModifier(node, 16476 /* ModifierFlags.ParameterPropertyModifier */)) {
break;
}
// falls through
- case 254 /* SyntaxKind.VariableDeclaration */:
- case 203 /* SyntaxKind.BindingElement */: {
+ case 257 /* SyntaxKind.VariableDeclaration */:
+ case 205 /* SyntaxKind.BindingElement */: {
var decl = node;
if (ts.isBindingPattern(decl.name)) {
ts.forEachChild(decl.name, visit);
@@ -454324,12 +455947,12 @@ var ts;
}
}
// falls through
- case 299 /* SyntaxKind.EnumMember */:
- case 167 /* SyntaxKind.PropertyDeclaration */:
- case 166 /* SyntaxKind.PropertySignature */:
+ case 302 /* SyntaxKind.EnumMember */:
+ case 169 /* SyntaxKind.PropertyDeclaration */:
+ case 168 /* SyntaxKind.PropertySignature */:
addDeclaration(node);
break;
- case 272 /* SyntaxKind.ExportDeclaration */:
+ case 275 /* SyntaxKind.ExportDeclaration */:
// Handle named exports case e.g.:
// export {a, b as B} from "mod";
var exportDeclaration = node;
@@ -454342,7 +455965,7 @@ var ts;
}
}
break;
- case 266 /* SyntaxKind.ImportDeclaration */:
+ case 269 /* SyntaxKind.ImportDeclaration */:
var importClause = node.importClause;
if (importClause) {
// Handle default import case e.g.:
@@ -454354,7 +455977,7 @@ var ts;
// import * as NS from "mod";
// import {a, b as B} from "mod";
if (importClause.namedBindings) {
- if (importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) {
+ if (importClause.namedBindings.kind === 271 /* SyntaxKind.NamespaceImport */) {
addDeclaration(importClause.namedBindings);
}
else {
@@ -454363,7 +455986,7 @@ var ts;
}
}
break;
- case 221 /* SyntaxKind.BinaryExpression */:
+ case 223 /* SyntaxKind.BinaryExpression */:
if (ts.getAssignmentDeclarationKind(node) !== 0 /* AssignmentDeclarationKind.None */) {
addDeclaration(node);
}
@@ -454709,7 +456332,7 @@ var ts;
var rootFileNames = host.getScriptFileNames().slice();
// Get a fresh cache of the host information
var newSettings = host.getCompilationSettings() || getDefaultCompilerOptions();
- var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse;
+ var hasInvalidatedResolutions = host.hasInvalidatedResolutions || ts.returnFalse;
var hasChangedAutomaticTypeDirectiveNames = ts.maybeBind(host, host.hasChangedAutomaticTypeDirectiveNames);
var projectReferences = (_b = host.getProjectReferences) === null || _b === void 0 ? void 0 : _b.call(host);
var parsedCommandLines;
@@ -454740,7 +456363,7 @@ var ts;
},
onReleaseOldSourceFile: onReleaseOldSourceFile,
onReleaseParsedCommandLine: onReleaseParsedCommandLine,
- hasInvalidatedResolution: hasInvalidatedResolution,
+ hasInvalidatedResolutions: hasInvalidatedResolutions,
hasChangedAutomaticTypeDirectiveNames: hasChangedAutomaticTypeDirectiveNames,
trace: ts.maybeBind(host, host.trace),
resolveModuleNames: ts.maybeBind(host, host.resolveModuleNames),
@@ -454775,8 +456398,12 @@ var ts;
getCurrentDirectory: compilerHost.getCurrentDirectory,
onUnRecoverableConfigFileDiagnostic: ts.noop,
};
+ // The call to isProgramUptoDate below may refer back to documentRegistryBucketKey;
+ // calculate this early so it's not undefined if downleveled to a var (or, if emitted
+ // as a const variable without downleveling, doesn't crash).
+ var documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings);
// If the program is already up-to-date, we can reuse it
- if (ts.isProgramUptoDate(program, rootFileNames, newSettings, function (_path, fileName) { return host.getScriptVersion(fileName); }, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
+ if (ts.isProgramUptoDate(program, rootFileNames, newSettings, function (_path, fileName) { return host.getScriptVersion(fileName); }, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
return;
}
// IMPORTANT - It is critical from this moment onward that we do not check
@@ -454784,7 +456411,6 @@ var ts;
// instance. If we cancel midway through, we may end up in an inconsistent state where
// the program points to old source files that have been invalidated because of
// incremental parsing.
- var documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings);
var options = {
rootNames: rootFileNames,
options: newSettings,
@@ -455080,16 +456706,16 @@ var ts;
switch (node.kind) {
case 79 /* SyntaxKind.Identifier */:
return !ts.isLabelName(node) && !ts.isTagName(node) && !ts.isConstTypeReference(node.parent);
- case 206 /* SyntaxKind.PropertyAccessExpression */:
- case 161 /* SyntaxKind.QualifiedName */:
+ case 208 /* SyntaxKind.PropertyAccessExpression */:
+ case 163 /* SyntaxKind.QualifiedName */:
// Don't return quickInfo if inside the comment in `a/**/.b`
return !ts.isInComment(sourceFile, position);
case 108 /* SyntaxKind.ThisKeyword */:
- case 192 /* SyntaxKind.ThisType */:
+ case 194 /* SyntaxKind.ThisType */:
case 106 /* SyntaxKind.SuperKeyword */:
- case 197 /* SyntaxKind.NamedTupleMember */:
+ case 199 /* SyntaxKind.NamedTupleMember */:
return true;
- case 231 /* SyntaxKind.MetaProperty */:
+ case 233 /* SyntaxKind.MetaProperty */:
return ts.isImportMeta(node);
default:
return false;
@@ -455196,15 +456822,15 @@ var ts;
return undefined;
}
switch (node.kind) {
- case 206 /* SyntaxKind.PropertyAccessExpression */:
- case 161 /* SyntaxKind.QualifiedName */:
+ case 208 /* SyntaxKind.PropertyAccessExpression */:
+ case 163 /* SyntaxKind.QualifiedName */:
case 10 /* SyntaxKind.StringLiteral */:
case 95 /* SyntaxKind.FalseKeyword */:
case 110 /* SyntaxKind.TrueKeyword */:
case 104 /* SyntaxKind.NullKeyword */:
case 106 /* SyntaxKind.SuperKeyword */:
case 108 /* SyntaxKind.ThisKeyword */:
- case 192 /* SyntaxKind.ThisType */:
+ case 194 /* SyntaxKind.ThisType */:
case 79 /* SyntaxKind.Identifier */:
break;
// Cant create the text span
@@ -455221,7 +456847,7 @@ var ts;
// If this is name of a module declarations, check if this is right side of dotted module name
// If parent of the module declaration which is parent of this node is module declaration and its body is the module declaration that this node is name of
// Then this name is name from dotted module
- if (nodeForStartPos.parent.parent.kind === 261 /* SyntaxKind.ModuleDeclaration */ &&
+ if (nodeForStartPos.parent.parent.kind === 264 /* SyntaxKind.ModuleDeclaration */ &&
nodeForStartPos.parent.parent.body === nodeForStartPos.parent) {
// Use parent module declarations name for start pos
nodeForStartPos = nodeForStartPos.parent.parent.name;
@@ -455351,12 +456977,14 @@ var ts;
return ts.codefix.getAllFixes({ fixId: fixId, sourceFile: sourceFile, program: program, host: host, cancellationToken: cancellationToken, formatContext: formatContext, preferences: preferences });
}
function organizeImports(args, formatOptions, preferences) {
+ var _a;
if (preferences === void 0) { preferences = ts.emptyOptions; }
synchronizeHostData();
ts.Debug.assert(args.type === "file");
var sourceFile = getValidSourceFile(args.fileName);
var formatContext = ts.formatting.getFormatContext(formatOptions, host);
- return ts.OrganizeImports.organizeImports(sourceFile, formatContext, host, program, preferences, args.skipDestructiveCodeActions);
+ var mode = (_a = args.mode) !== null && _a !== void 0 ? _a : (args.skipDestructiveCodeActions ? "SortAndCombine" /* OrganizeImportsMode.SortAndCombine */ : "All" /* OrganizeImportsMode.All */);
+ return ts.OrganizeImports.organizeImports(sourceFile, formatContext, host, program, preferences, mode);
}
function getEditsForFileRename(oldFilePath, newFilePath, formatOptions, preferences) {
if (preferences === void 0) { preferences = ts.emptyOptions; }
@@ -455970,7 +457598,7 @@ var ts;
*/
function literalIsName(node) {
return ts.isDeclarationName(node) ||
- node.parent.kind === 277 /* SyntaxKind.ExternalModuleReference */ ||
+ node.parent.kind === 280 /* SyntaxKind.ExternalModuleReference */ ||
isArgumentOfElementAccessExpression(node) ||
ts.isLiteralComputedPropertyDeclarationName(node);
}
@@ -455988,13 +457616,13 @@ var ts;
case 10 /* SyntaxKind.StringLiteral */:
case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */:
case 8 /* SyntaxKind.NumericLiteral */:
- if (node.parent.kind === 162 /* SyntaxKind.ComputedPropertyName */) {
+ if (node.parent.kind === 164 /* SyntaxKind.ComputedPropertyName */) {
return ts.isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined;
}
// falls through
case 79 /* SyntaxKind.Identifier */:
return ts.isObjectLiteralElement(node.parent) &&
- (node.parent.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || node.parent.parent.kind === 286 /* SyntaxKind.JsxAttributes */) &&
+ (node.parent.parent.kind === 207 /* SyntaxKind.ObjectLiteralExpression */ || node.parent.parent.kind === 289 /* SyntaxKind.JsxAttributes */) &&
node.parent.name === node ? node.parent : undefined;
}
return undefined;
@@ -456036,7 +457664,7 @@ var ts;
function isArgumentOfElementAccessExpression(node) {
return node &&
node.parent &&
- node.parent.kind === 207 /* SyntaxKind.ElementAccessExpression */ &&
+ node.parent.kind === 209 /* SyntaxKind.ElementAccessExpression */ &&
node.parent.argumentExpression === node;
}
/**
@@ -456129,114 +457757,114 @@ var ts;
if (node) {
var parent = node.parent;
switch (node.kind) {
- case 237 /* SyntaxKind.VariableStatement */:
+ case 240 /* SyntaxKind.VariableStatement */:
// Span on first variable declaration
return spanInVariableDeclaration(node.declarationList.declarations[0]);
- case 254 /* SyntaxKind.VariableDeclaration */:
- case 167 /* SyntaxKind.PropertyDeclaration */:
- case 166 /* SyntaxKind.PropertySignature */:
+ case 257 /* SyntaxKind.VariableDeclaration */:
+ case 169 /* SyntaxKind.PropertyDeclaration */:
+ case 168 /* SyntaxKind.PropertySignature */:
return spanInVariableDeclaration(node);
- case 164 /* SyntaxKind.Parameter */:
+ case 166 /* SyntaxKind.Parameter */:
return spanInParameterDeclaration(node);
- case 256 /* SyntaxKind.FunctionDeclaration */:
- case 169 /* SyntaxKind.MethodDeclaration */:
- case 168 /* SyntaxKind.MethodSignature */:
- case 172 /* SyntaxKind.GetAccessor */:
- case 173 /* SyntaxKind.SetAccessor */:
- case 171 /* SyntaxKind.Constructor */:
- case 213 /* SyntaxKind.FunctionExpression */:
- case 214 /* SyntaxKind.ArrowFunction */:
+ case 259 /* SyntaxKind.FunctionDeclaration */:
+ case 171 /* SyntaxKind.MethodDeclaration */:
+ case 170 /* SyntaxKind.MethodSignature */:
+ case 174 /* SyntaxKind.GetAccessor */:
+ case 175 /* SyntaxKind.SetAccessor */:
+ case 173 /* SyntaxKind.Constructor */:
+ case 215 /* SyntaxKind.FunctionExpression */:
+ case 216 /* SyntaxKind.ArrowFunction */:
return spanInFunctionDeclaration(node);
- case 235 /* SyntaxKind.Block */:
+ case 238 /* SyntaxKind.Block */:
if (ts.isFunctionBlock(node)) {
return spanInFunctionBlock(node);
}
// falls through
- case 262 /* SyntaxKind.ModuleBlock */:
+ case 265 /* SyntaxKind.ModuleBlock */:
return spanInBlock(node);
- case 292 /* SyntaxKind.CatchClause */:
+ case 295 /* SyntaxKind.CatchClause */:
return spanInBlock(node.block);
- case 238 /* SyntaxKind.ExpressionStatement */:
+ case 241 /* SyntaxKind.ExpressionStatement */:
// span on the expression
return textSpan(node.expression);
- case 247 /* SyntaxKind.ReturnStatement */:
+ case 250 /* SyntaxKind.ReturnStatement */:
// span on return keyword and expression if present
return textSpan(node.getChildAt(0), node.expression);
- case 241 /* SyntaxKind.WhileStatement */:
+ case 244 /* SyntaxKind.WhileStatement */:
// Span on while(...)
return textSpanEndingAtNextToken(node, node.expression);
- case 240 /* SyntaxKind.DoStatement */:
+ case 243 /* SyntaxKind.DoStatement */:
// span in statement of the do statement
return spanInNode(node.statement);
- case 253 /* SyntaxKind.DebuggerStatement */:
+ case 256 /* SyntaxKind.DebuggerStatement */:
// span on debugger keyword
return textSpan(node.getChildAt(0));
- case 239 /* SyntaxKind.IfStatement */:
+ case 242 /* SyntaxKind.IfStatement */:
// set on if(..) span
return textSpanEndingAtNextToken(node, node.expression);
- case 250 /* SyntaxKind.LabeledStatement */:
+ case 253 /* SyntaxKind.LabeledStatement */:
// span in statement
return spanInNode(node.statement);
- case 246 /* SyntaxKind.BreakStatement */:
- case 245 /* SyntaxKind.ContinueStatement */:
+ case 249 /* SyntaxKind.BreakStatement */:
+ case 248 /* SyntaxKind.ContinueStatement */:
// On break or continue keyword and label if present
return textSpan(node.getChildAt(0), node.label);
- case 242 /* SyntaxKind.ForStatement */:
+ case 245 /* SyntaxKind.ForStatement */:
return spanInForStatement(node);
- case 243 /* SyntaxKind.ForInStatement */:
+ case 246 /* SyntaxKind.ForInStatement */:
// span of for (a in ...)
return textSpanEndingAtNextToken(node, node.expression);
- case 244 /* SyntaxKind.ForOfStatement */:
+ case 247 /* SyntaxKind.ForOfStatement */:
// span in initializer
return spanInInitializerOfForLike(node);
- case 249 /* SyntaxKind.SwitchStatement */:
+ case 252 /* SyntaxKind.SwitchStatement */:
// span on switch(...)
return textSpanEndingAtNextToken(node, node.expression);
- case 289 /* SyntaxKind.CaseClause */:
- case 290 /* SyntaxKind.DefaultClause */:
+ case 292 /* SyntaxKind.CaseClause */:
+ case 293 /* SyntaxKind.DefaultClause */:
// span in first statement of the clause
return spanInNode(node.statements[0]);
- case 252 /* SyntaxKind.TryStatement */:
+ case 255 /* SyntaxKind.TryStatement */:
// span in try block
return spanInBlock(node.tryBlock);
- case 251 /* SyntaxKind.ThrowStatement */:
+ case 254 /* SyntaxKind.ThrowStatement */:
// span in throw ...
return textSpan(node, node.expression);
- case 271 /* SyntaxKind.ExportAssignment */:
+ case 274 /* SyntaxKind.ExportAssignment */:
// span on export = id
return textSpan(node, node.expression);
- case 265 /* SyntaxKind.ImportEqualsDeclaration */:
+ case 268 /* SyntaxKind.ImportEqualsDeclaration */:
// import statement without including semicolon
return textSpan(node, node.moduleReference);
- case 266 /* SyntaxKind.ImportDeclaration */:
+ case 269 /* SyntaxKind.ImportDeclaration */:
// import statement without including semicolon
return textSpan(node, node.moduleSpecifier);
- case 272 /* SyntaxKind.ExportDeclaration */:
+ case 275 /* SyntaxKind.ExportDeclaration */:
// import statement without including semicolon
return textSpan(node, node.moduleSpecifier);
- case 261 /* SyntaxKind.ModuleDeclaration */:
+ case 264 /* SyntaxKind.ModuleDeclaration */:
// span on complete module if it is instantiated
if (ts.getModuleInstanceState(node) !== 1 /* ModuleInstanceState.Instantiated */) {
return undefined;
}
// falls through
- case 257 /* SyntaxKind.ClassDeclaration */:
- case 260 /* SyntaxKind.EnumDeclaration */:
- case 299 /* SyntaxKind.EnumMember */:
- case 203 /* SyntaxKind.BindingElement */:
+ case 260 /* SyntaxKind.ClassDeclaration */:
+ case 263 /* SyntaxKind.EnumDeclaration */:
+ case 302 /* SyntaxKind.EnumMember */:
+ case 205 /* SyntaxKind.BindingElement */:
// span on complete node
return textSpan(node);
- case 248 /* SyntaxKind.WithStatement */:
+ case 251 /* SyntaxKind.WithStatement */:
// span in statement
return spanInNode(node.statement);
- case 165 /* SyntaxKind.Decorator */:
+ case 167 /* SyntaxKind.Decorator */:
return spanInNodeArray(parent.modifiers, node, ts.isDecorator);
- case 201 /* SyntaxKind.ObjectBindingPattern */:
- case 202 /* SyntaxKind.ArrayBindingPattern */:
+ case 203 /* SyntaxKind.ObjectBindingPattern */:
+ case 204 /* SyntaxKind.ArrayBindingPattern */:
return spanInBindingPattern(node);
// No breakpoint in interface, type alias
- case 258 /* SyntaxKind.InterfaceDeclaration */:
- case 259 /* SyntaxKind.TypeAliasDeclaration */:
+ case 261 /* SyntaxKind.InterfaceDeclaration */:
+ case 262 /* SyntaxKind.TypeAliasDeclaration */:
return undefined;
// Tokens:
case 26 /* SyntaxKind.SemicolonToken */:
@@ -456266,7 +457894,7 @@ var ts;
case 83 /* SyntaxKind.CatchKeyword */:
case 96 /* SyntaxKind.FinallyKeyword */:
return spanInNextNode(node);
- case 160 /* SyntaxKind.OfKeyword */:
+ case 162 /* SyntaxKind.OfKeyword */:
return spanInOfKeyword(node);
default:
// Destructuring pattern in destructuring assignment
@@ -456279,13 +457907,13 @@ var ts;
// `a` or `...c` or `d: x` from
// `[a, b, ...c]` or `{ a, b }` or `{ d: x }` from destructuring pattern
if ((node.kind === 79 /* SyntaxKind.Identifier */ ||
- node.kind === 225 /* SyntaxKind.SpreadElement */ ||
- node.kind === 296 /* SyntaxKind.PropertyAssignment */ ||
- node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) &&
+ node.kind === 227 /* SyntaxKind.SpreadElement */ ||
+ node.kind === 299 /* SyntaxKind.PropertyAssignment */ ||
+ node.kind === 300 /* SyntaxKind.ShorthandPropertyAssignment */) &&
ts.isArrayLiteralOrObjectLiteralDestructuringPattern(parent)) {
return textSpan(node);
}
- if (node.kind === 221 /* SyntaxKind.BinaryExpression */) {
+ if (node.kind === 223 /* SyntaxKind.BinaryExpression */) {
var _a = node, left = _a.left, operatorToken = _a.operatorToken;
// Set breakpoint in destructuring pattern if its destructuring assignment
// [a, b, c] or {a, b, c} of
@@ -456307,22 +457935,22 @@ var ts;
}
if (ts.isExpressionNode(node)) {
switch (parent.kind) {
- case 240 /* SyntaxKind.DoStatement */:
+ case 243 /* SyntaxKind.DoStatement */:
// Set span as if on while keyword
return spanInPreviousNode(node);
- case 165 /* SyntaxKind.Decorator */:
+ case 167 /* SyntaxKind.Decorator */:
// Set breakpoint on the decorator emit
return spanInNode(node.parent);
- case 242 /* SyntaxKind.ForStatement */:
- case 244 /* SyntaxKind.ForOfStatement */:
+ case 245 /* SyntaxKind.ForStatement */:
+ case 247 /* SyntaxKind.ForOfStatement */:
return textSpan(node);
- case 221 /* SyntaxKind.BinaryExpression */:
+ case 223 /* SyntaxKind.BinaryExpression */:
if (node.parent.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) {
// If this is a comma expression, the breakpoint is possible in this expression
return textSpan(node);
}
break;
- case 214 /* SyntaxKind.ArrowFunction */:
+ case 216 /* SyntaxKind.ArrowFunction */:
if (node.parent.body === node) {
// If this is body of arrow function, it is allowed to have the breakpoint
return textSpan(node);
@@ -456331,21 +457959,21 @@ var ts;
}
}
switch (node.parent.kind) {
- case 296 /* SyntaxKind.PropertyAssignment */:
+ case 299 /* SyntaxKind.PropertyAssignment */:
// If this is name of property assignment, set breakpoint in the initializer
if (node.parent.name === node &&
!ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) {
return spanInNode(node.parent.initializer);
}
break;
- case 211 /* SyntaxKind.TypeAssertionExpression */:
+ case 213 /* SyntaxKind.TypeAssertionExpression */:
// Breakpoint in type assertion goes to its operand
if (node.parent.type === node) {
return spanInNextNode(node.parent.type);
}
break;
- case 254 /* SyntaxKind.VariableDeclaration */:
- case 164 /* SyntaxKind.Parameter */: {
+ case 257 /* SyntaxKind.VariableDeclaration */:
+ case 166 /* SyntaxKind.Parameter */: {
// initializer of variable/parameter declaration go to previous node
var _b = node.parent, initializer = _b.initializer, type = _b.type;
if (initializer === node || type === node || ts.isAssignmentOperator(node.kind)) {
@@ -456353,7 +457981,7 @@ var ts;
}
break;
}
- case 221 /* SyntaxKind.BinaryExpression */: {
+ case 223 /* SyntaxKind.BinaryExpression */: {
var left = node.parent.left;
if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left) && node !== left) {
// If initializer of destructuring assignment move to previous token
@@ -456383,7 +458011,7 @@ var ts;
}
function spanInVariableDeclaration(variableDeclaration) {
// If declaration of for in statement, just set the span in parent
- if (variableDeclaration.parent.parent.kind === 243 /* SyntaxKind.ForInStatement */) {
+ if (variableDeclaration.parent.parent.kind === 246 /* SyntaxKind.ForInStatement */) {
return spanInNode(variableDeclaration.parent.parent);
}
var parent = variableDeclaration.parent;
@@ -456395,7 +458023,7 @@ var ts;
// or its declaration from 'for of'
if ((ts.hasOnlyExpressionInitializer(variableDeclaration) && variableDeclaration.initializer) ||
ts.hasSyntacticModifier(variableDeclaration, 1 /* ModifierFlags.Export */) ||
- parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */) {
+ parent.parent.kind === 247 /* SyntaxKind.ForOfStatement */) {
return textSpanFromVariableDeclaration(variableDeclaration);
}
if (ts.isVariableDeclarationList(variableDeclaration.parent) &&
@@ -456436,7 +458064,7 @@ var ts;
}
function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) {
return ts.hasSyntacticModifier(functionDeclaration, 1 /* ModifierFlags.Export */) ||
- (functionDeclaration.parent.kind === 257 /* SyntaxKind.ClassDeclaration */ && functionDeclaration.kind !== 171 /* SyntaxKind.Constructor */);
+ (functionDeclaration.parent.kind === 260 /* SyntaxKind.ClassDeclaration */ && functionDeclaration.kind !== 173 /* SyntaxKind.Constructor */);
}
function spanInFunctionDeclaration(functionDeclaration) {
// No breakpoints in the function signature
@@ -456459,26 +458087,26 @@ var ts;
}
function spanInBlock(block) {
switch (block.parent.kind) {
- case 261 /* SyntaxKind.ModuleDeclaration */:
+ case 264 /* SyntaxKind.ModuleDeclaration */:
if (ts.getModuleInstanceState(block.parent) !== 1 /* ModuleInstanceState.Instantiated */) {
return undefined;
}
// Set on parent if on same line otherwise on first statement
// falls through
- case 241 /* SyntaxKind.WhileStatement */:
- case 239 /* SyntaxKind.IfStatement */:
- case 243 /* SyntaxKind.ForInStatement */:
+ case 244 /* SyntaxKind.WhileStatement */:
+ case 242 /* SyntaxKind.IfStatement */:
+ case 246 /* SyntaxKind.ForInStatement */:
return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]);
// Set span on previous token if it starts on same line otherwise on the first statement of the block
- case 242 /* SyntaxKind.ForStatement */:
- case 244 /* SyntaxKind.ForOfStatement */:
+ case 245 /* SyntaxKind.ForStatement */:
+ case 247 /* SyntaxKind.ForOfStatement */:
return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]);
}
// Default action is to set on first statement
return spanInNode(block.statements[0]);
}
function spanInInitializerOfForLike(forLikeStatement) {
- if (forLikeStatement.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) {
+ if (forLikeStatement.initializer.kind === 258 /* SyntaxKind.VariableDeclarationList */) {
// Declaration list - set breakpoint in first declaration
var variableDeclarationList = forLikeStatement.initializer;
if (variableDeclarationList.declarations.length > 0) {
@@ -456503,21 +458131,21 @@ var ts;
}
function spanInBindingPattern(bindingPattern) {
// Set breakpoint in first binding element
- var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 227 /* SyntaxKind.OmittedExpression */ ? element : undefined; });
+ var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 229 /* SyntaxKind.OmittedExpression */ ? element : undefined; });
if (firstBindingElement) {
return spanInNode(firstBindingElement);
}
// Empty binding pattern of binding element, set breakpoint on binding element
- if (bindingPattern.parent.kind === 203 /* SyntaxKind.BindingElement */) {
+ if (bindingPattern.parent.kind === 205 /* SyntaxKind.BindingElement */) {
return textSpan(bindingPattern.parent);
}
// Variable declaration is used as the span
return textSpanFromVariableDeclaration(bindingPattern.parent);
}
function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) {
- ts.Debug.assert(node.kind !== 202 /* SyntaxKind.ArrayBindingPattern */ && node.kind !== 201 /* SyntaxKind.ObjectBindingPattern */);
- var elements = node.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ ? node.elements : node.properties;
- var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 227 /* SyntaxKind.OmittedExpression */ ? element : undefined; });
+ ts.Debug.assert(node.kind !== 204 /* SyntaxKind.ArrayBindingPattern */ && node.kind !== 203 /* SyntaxKind.ObjectBindingPattern */);
+ var elements = node.kind === 206 /* SyntaxKind.ArrayLiteralExpression */ ? node.elements : node.properties;
+ var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 229 /* SyntaxKind.OmittedExpression */ ? element : undefined; });
if (firstBindingElement) {
return spanInNode(firstBindingElement);
}
@@ -456525,18 +458153,18 @@ var ts;
// just nested element in another destructuring assignment
// set breakpoint on assignment when parent is destructuring assignment
// Otherwise set breakpoint for this element
- return textSpan(node.parent.kind === 221 /* SyntaxKind.BinaryExpression */ ? node.parent : node);
+ return textSpan(node.parent.kind === 223 /* SyntaxKind.BinaryExpression */ ? node.parent : node);
}
// Tokens:
function spanInOpenBraceToken(node) {
switch (node.parent.kind) {
- case 260 /* SyntaxKind.EnumDeclaration */:
+ case 263 /* SyntaxKind.EnumDeclaration */:
var enumDeclaration = node.parent;
return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile));
- case 257 /* SyntaxKind.ClassDeclaration */:
+ case 260 /* SyntaxKind.ClassDeclaration */:
var classDeclaration = node.parent;
return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile));
- case 263 /* SyntaxKind.CaseBlock */:
+ case 266 /* SyntaxKind.CaseBlock */:
return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]);
}
// Default to parent node
@@ -456544,25 +458172,25 @@ var ts;
}
function spanInCloseBraceToken(node) {
switch (node.parent.kind) {
- case 262 /* SyntaxKind.ModuleBlock */:
+ case 265 /* SyntaxKind.ModuleBlock */:
// If this is not an instantiated module block, no bp span
if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* ModuleInstanceState.Instantiated */) {
return undefined;
}
// falls through
- case 260 /* SyntaxKind.EnumDeclaration */:
- case 257 /* SyntaxKind.ClassDeclaration */:
+ case 263 /* SyntaxKind.EnumDeclaration */:
+ case 260 /* SyntaxKind.ClassDeclaration */:
// Span on close brace token
return textSpan(node);
- case 235 /* SyntaxKind.Block */:
+ case 238 /* SyntaxKind.Block */:
if (ts.isFunctionBlock(node.parent)) {
// Span on close brace token
return textSpan(node);
}
// falls through
- case 292 /* SyntaxKind.CatchClause */:
+ case 295 /* SyntaxKind.CatchClause */:
return spanInNode(ts.lastOrUndefined(node.parent.statements));
- case 263 /* SyntaxKind.CaseBlock */:
+ case 266 /* SyntaxKind.CaseBlock */:
// breakpoint in last statement of the last clause
var caseBlock = node.parent;
var lastClause = ts.lastOrUndefined(caseBlock.clauses);
@@ -456570,7 +458198,7 @@ var ts;
return spanInNode(ts.lastOrUndefined(lastClause.statements));
}
return undefined;
- case 201 /* SyntaxKind.ObjectBindingPattern */:
+ case 203 /* SyntaxKind.ObjectBindingPattern */:
// Breakpoint in last binding element or binding pattern if it contains no elements
var bindingPattern = node.parent;
return spanInNode(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern);
@@ -456586,7 +458214,7 @@ var ts;
}
function spanInCloseBracketToken(node) {
switch (node.parent.kind) {
- case 202 /* SyntaxKind.ArrayBindingPattern */:
+ case 204 /* SyntaxKind.ArrayBindingPattern */:
// Breakpoint in last binding element or binding pattern if it contains no elements
var bindingPattern = node.parent;
return textSpan(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern);
@@ -456601,12 +458229,12 @@ var ts;
}
}
function spanInOpenParenToken(node) {
- if (node.parent.kind === 240 /* SyntaxKind.DoStatement */ || // Go to while keyword and do action instead
- node.parent.kind === 208 /* SyntaxKind.CallExpression */ ||
- node.parent.kind === 209 /* SyntaxKind.NewExpression */) {
+ if (node.parent.kind === 243 /* SyntaxKind.DoStatement */ || // Go to while keyword and do action instead
+ node.parent.kind === 210 /* SyntaxKind.CallExpression */ ||
+ node.parent.kind === 211 /* SyntaxKind.NewExpression */) {
return spanInPreviousNode(node);
}
- if (node.parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */) {
+ if (node.parent.kind === 214 /* SyntaxKind.ParenthesizedExpression */) {
return spanInNextNode(node);
}
// Default to parent node
@@ -456615,21 +458243,21 @@ var ts;
function spanInCloseParenToken(node) {
// Is this close paren token of parameter list, set span in previous token
switch (node.parent.kind) {
- case 213 /* SyntaxKind.FunctionExpression */:
- case 256 /* SyntaxKind.FunctionDeclaration */:
- case 214 /* SyntaxKind.ArrowFunction */:
- case 169 /* SyntaxKind.MethodDeclaration */:
- case 168 /* SyntaxKind.MethodSignature */:
- case 172 /* SyntaxKind.GetAccessor */:
- case 173 /* SyntaxKind.SetAccessor */:
- case 171 /* SyntaxKind.Constructor */:
- case 241 /* SyntaxKind.WhileStatement */:
- case 240 /* SyntaxKind.DoStatement */:
- case 242 /* SyntaxKind.ForStatement */:
- case 244 /* SyntaxKind.ForOfStatement */:
- case 208 /* SyntaxKind.CallExpression */:
- case 209 /* SyntaxKind.NewExpression */:
- case 212 /* SyntaxKind.ParenthesizedExpression */:
+ case 215 /* SyntaxKind.FunctionExpression */:
+ case 259 /* SyntaxKind.FunctionDeclaration */:
+ case 216 /* SyntaxKind.ArrowFunction */:
+ case 171 /* SyntaxKind.MethodDeclaration */:
+ case 170 /* SyntaxKind.MethodSignature */:
+ case 174 /* SyntaxKind.GetAccessor */:
+ case 175 /* SyntaxKind.SetAccessor */:
+ case 173 /* SyntaxKind.Constructor */:
+ case 244 /* SyntaxKind.WhileStatement */:
+ case 243 /* SyntaxKind.DoStatement */:
+ case 245 /* SyntaxKind.ForStatement */:
+ case 247 /* SyntaxKind.ForOfStatement */:
+ case 210 /* SyntaxKind.CallExpression */:
+ case 211 /* SyntaxKind.NewExpression */:
+ case 214 /* SyntaxKind.ParenthesizedExpression */:
return spanInPreviousNode(node);
// Default to parent node
default:
@@ -456639,20 +458267,20 @@ var ts;
function spanInColonToken(node) {
// Is this : specifying return annotation of the function declaration
if (ts.isFunctionLike(node.parent) ||
- node.parent.kind === 296 /* SyntaxKind.PropertyAssignment */ ||
- node.parent.kind === 164 /* SyntaxKind.Parameter */) {
+ node.parent.kind === 299 /* SyntaxKind.PropertyAssignment */ ||
+ node.parent.kind === 166 /* SyntaxKind.Parameter */) {
return spanInPreviousNode(node);
}
return spanInNode(node.parent);
}
function spanInGreaterThanOrLessThanToken(node) {
- if (node.parent.kind === 211 /* SyntaxKind.TypeAssertionExpression */) {
+ if (node.parent.kind === 213 /* SyntaxKind.TypeAssertionExpression */) {
return spanInNextNode(node);
}
return spanInNode(node.parent);
}
function spanInWhileKeyword(node) {
- if (node.parent.kind === 240 /* SyntaxKind.DoStatement */) {
+ if (node.parent.kind === 243 /* SyntaxKind.DoStatement */) {
// Set span on while expression
return textSpanEndingAtNextToken(node, node.parent.expression);
}
@@ -456660,7 +458288,7 @@ var ts;
return spanInNode(node.parent);
}
function spanInOfKeyword(node) {
- if (node.parent.kind === 244 /* SyntaxKind.ForOfStatement */) {
+ if (node.parent.kind === 247 /* SyntaxKind.ForOfStatement */) {
// Set using next token
return spanInNextNode(node);
}
@@ -456709,7 +458337,7 @@ var debugObjectHost = (function () {
return this;
})();
// We need to use 'null' to interface with the managed side.
-/* eslint-disable no-in-operator */
+/* eslint-disable local/no-in-operator */
/* @internal */
var ts;
(function (ts) {
@@ -457509,7 +459137,7 @@ var ts;
}());
ts.TypeScriptServicesFactory = TypeScriptServicesFactory;
})(ts || (ts = {}));
-/* eslint-enable no-in-operator */
+/* eslint-enable local/no-in-operator */
// We polyfill `globalThis` here so re can reliably patch the global scope
// in the contexts we want to in the same way across script and module formats
/* eslint-enable no-var */
@@ -458279,7 +459907,7 @@ var ts;
if (typeof value === "number") {
return ts.factory.createNumericLiteral(value);
}
- // eslint-disable-next-line no-in-operator
+ // eslint-disable-next-line local/no-in-operator
if (typeof value === "object" && "base10Value" in value) { // PseudoBigInt
return ts.factory.createBigIntLiteral(value);
}
@@ -458307,7 +459935,7 @@ var ts;
}
else {
type = operatorOrType;
- operator = 140 /* SyntaxKind.KeyOfKeyword */;
+ operator = 141 /* SyntaxKind.KeyOfKeyword */;
}
return ts.factory.createTypeOperatorNode(operator, type);
}, factoryDeprecation);
@@ -458485,7 +460113,7 @@ var ts;
ts.createNode = ts.Debug.deprecate(function createNode(kind, pos, end) {
if (pos === void 0) { pos = 0; }
if (end === void 0) { end = 0; }
- return ts.setTextRangePosEnd(kind === 305 /* SyntaxKind.SourceFile */ ? ts.parseBaseNodeFactory.createBaseSourceFileNode(kind) :
+ return ts.setTextRangePosEnd(kind === 308 /* SyntaxKind.SourceFile */ ? ts.parseBaseNodeFactory.createBaseSourceFileNode(kind) :
kind === 79 /* SyntaxKind.Identifier */ ? ts.parseBaseNodeFactory.createBaseIdentifierNode(kind) :
kind === 80 /* SyntaxKind.PrivateIdentifier */ ? ts.parseBaseNodeFactory.createBasePrivateIdentifierNode(kind) :
!ts.isNodeKind(kind) ? ts.parseBaseNodeFactory.createBaseTokenNode(kind) :
@@ -458515,7 +460143,7 @@ var ts;
(function (ts) {
/** @deprecated Use `isTypeAssertionExpression` instead. */
ts.isTypeAssertion = ts.Debug.deprecate(function isTypeAssertion(node) {
- return node.kind === 211 /* SyntaxKind.TypeAssertionExpression */;
+ return node.kind === 213 /* SyntaxKind.TypeAssertionExpression */;
}, {
since: "4.0",
warnAfter: "4.1",
diff --git a/package-lock.json b/package-lock.json
index 8fd31692..9d47965c 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -25,7 +25,7 @@
"js-yaml": "^4.1.0",
"prettier": "^2.7.1",
"ts-jest": "^26.5.6",
- "typescript": "^4.8.4"
+ "typescript": "^4.9.3"
}
},
"node_modules/@actions/core": {
@@ -10852,9 +10852,9 @@
}
},
"node_modules/typescript": {
- "version": "4.8.4",
- "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.4.tgz",
- "integrity": "sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ==",
+ "version": "4.9.3",
+ "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.3.tgz",
+ "integrity": "sha512-CIfGzTelbKNEnLpLdGFgdyKhG23CKdKgQPOBc+OUNrkJ2vr+KSzsSV5kq5iWhEQbok+quxgGzrAtGWCyU7tHnA==",
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
@@ -19984,9 +19984,9 @@
}
},
"typescript": {
- "version": "4.8.4",
- "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.4.tgz",
- "integrity": "sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ=="
+ "version": "4.9.3",
+ "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.3.tgz",
+ "integrity": "sha512-CIfGzTelbKNEnLpLdGFgdyKhG23CKdKgQPOBc+OUNrkJ2vr+KSzsSV5kq5iWhEQbok+quxgGzrAtGWCyU7tHnA=="
},
"union-value": {
"version": "1.0.1",
diff --git a/package.json b/package.json
index be56d44e..dbe7c7f1 100644
--- a/package.json
+++ b/package.json
@@ -40,6 +40,6 @@
"js-yaml": "^4.1.0",
"prettier": "^2.7.1",
"ts-jest": "^26.5.6",
- "typescript": "^4.8.4"
+ "typescript": "^4.9.3"
}
}