mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Reduce polymorphism resulting from unstable Node shapes (#51682)
* Move .symbol to Declaration * simplify some factories * Move localSymbol to Declaration * Ensure JSDocContainer types are properly initialized * Move contextualType from Node to NodeLinks * Move 'locals' and 'nextContainer' out of Node * Move 'flowNode' out of 'Node' * Pre-define endFlowNode/returnFlowNode * Pre-define some SourceFile properties and a more stable cloneNode * Don't add excess properties to type nodes in typeToTypeNode * Refactor wrapSymbolTrackerToReportForContext to improve perf
This commit is contained in:
@@ -84,3 +84,4 @@ tests/cases/user/puppeteer/puppeteer
|
||||
tests/cases/user/axios-src/axios-src
|
||||
tests/cases/user/prettier/prettier
|
||||
.eslintcache
|
||||
*v8.log
|
||||
+138
-120
@@ -21,6 +21,8 @@ import {
|
||||
BreakOrContinueStatement,
|
||||
CallChain,
|
||||
CallExpression,
|
||||
canHaveLocals,
|
||||
canHaveSymbol,
|
||||
CaseBlock,
|
||||
CaseClause,
|
||||
cast,
|
||||
@@ -104,8 +106,11 @@ import {
|
||||
getTextOfIdentifierOrLiteral,
|
||||
getThisContainer,
|
||||
getTokenPosOfNode,
|
||||
HasContainerFlags,
|
||||
hasDynamicName,
|
||||
HasFlowNode,
|
||||
hasJSDocNodes,
|
||||
HasLocals,
|
||||
hasSyntacticModifier,
|
||||
Identifier,
|
||||
idText,
|
||||
@@ -126,9 +131,11 @@ import {
|
||||
isBindingPattern,
|
||||
isBlock,
|
||||
isBlockOrCatchScoped,
|
||||
IsBlockScopedContainer,
|
||||
isCallExpression,
|
||||
isClassStaticBlockDeclaration,
|
||||
isConditionalTypeNode,
|
||||
IsContainer,
|
||||
isDeclaration,
|
||||
isDeclarationStatement,
|
||||
isDestructuringAssignment,
|
||||
@@ -223,6 +230,7 @@ import {
|
||||
length,
|
||||
LiteralLikeElementAccessExpression,
|
||||
MappedTypeNode,
|
||||
MetaProperty,
|
||||
MethodDeclaration,
|
||||
ModifierFlags,
|
||||
ModuleBlock,
|
||||
@@ -250,9 +258,11 @@ import {
|
||||
PrefixUnaryExpression,
|
||||
PrivateIdentifier,
|
||||
PropertyAccessChain,
|
||||
PropertyAccessEntityNameExpression,
|
||||
PropertyAccessExpression,
|
||||
PropertyDeclaration,
|
||||
PropertySignature,
|
||||
QualifiedName,
|
||||
removeFileExtension,
|
||||
ReturnStatement,
|
||||
ScriptTarget,
|
||||
@@ -270,6 +280,7 @@ import {
|
||||
SpreadElement,
|
||||
Statement,
|
||||
StringLiteral,
|
||||
SuperExpression,
|
||||
SwitchStatement,
|
||||
Symbol,
|
||||
SymbolFlags,
|
||||
@@ -277,6 +288,7 @@ import {
|
||||
SymbolTable,
|
||||
SyntaxKind,
|
||||
TextRange,
|
||||
ThisExpression,
|
||||
ThrowStatement,
|
||||
TokenFlags,
|
||||
tokenToString,
|
||||
@@ -486,10 +498,10 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
|
||||
let options: CompilerOptions;
|
||||
let languageVersion: ScriptTarget;
|
||||
let parent: Node;
|
||||
let container: Node;
|
||||
let thisParentContainer: Node; // Container one level up
|
||||
let blockScopeContainer: Node;
|
||||
let lastContainer: Node;
|
||||
let container: IsContainer | EntityNameExpression;
|
||||
let thisParentContainer: IsContainer | EntityNameExpression; // Container one level up
|
||||
let blockScopeContainer: IsBlockScopedContainer;
|
||||
let lastContainer: HasLocals;
|
||||
let delayedTypeAliases: (JSDocTypedefTag | JSDocCallbackTag | JSDocEnumTag)[];
|
||||
let seenThisKeyword: boolean;
|
||||
|
||||
@@ -852,6 +864,7 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
|
||||
return declareSymbol(container.symbol.exports!, container.symbol, node, symbolFlags, symbolExcludes);
|
||||
}
|
||||
else {
|
||||
Debug.assertNode(container, canHaveLocals);
|
||||
return declareSymbol(container.locals!, /*parent*/ undefined, node, symbolFlags, symbolExcludes);
|
||||
}
|
||||
}
|
||||
@@ -873,7 +886,7 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
|
||||
// and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed.
|
||||
if (isJSDocTypeAlias(node)) Debug.assert(isInJSFile(node)); // We shouldn't add symbols for JSDoc nodes if not in a JS file.
|
||||
if (!isAmbientModule(node) && (hasExportModifier || container.flags & NodeFlags.ExportContext)) {
|
||||
if (!container.locals || (hasSyntacticModifier(node, ModifierFlags.Default) && !getDeclarationName(node))) {
|
||||
if (!canHaveLocals(container) || !container.locals || (hasSyntacticModifier(node, ModifierFlags.Default) && !getDeclarationName(node))) {
|
||||
return declareSymbol(container.symbol.exports!, container.symbol, node, symbolFlags, symbolExcludes); // No local symbol for an unnamed default!
|
||||
}
|
||||
const exportKind = symbolFlags & SymbolFlags.Value ? SymbolFlags.ExportValue : 0;
|
||||
@@ -883,6 +896,7 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
|
||||
return local;
|
||||
}
|
||||
else {
|
||||
Debug.assertNode(container, canHaveLocals);
|
||||
return declareSymbol(container.locals!, /*parent*/ undefined, node, symbolFlags, symbolExcludes);
|
||||
}
|
||||
}
|
||||
@@ -909,7 +923,7 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
|
||||
// All container nodes are kept on a linked list in declaration order. This list is used by
|
||||
// the getLocalNameOfContainer function in the type checker to validate that the local name
|
||||
// used for a container is unique.
|
||||
function bindContainer(node: Mutable<Node>, containerFlags: ContainerFlags) {
|
||||
function bindContainer(node: Mutable<HasContainerFlags>, containerFlags: ContainerFlags) {
|
||||
// Before we recurse into a node's children, we first save the existing parent, container
|
||||
// and block-container. Then after we pop out of processing the children, we restore
|
||||
// these saved values.
|
||||
@@ -938,15 +952,17 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
|
||||
if (node.kind !== SyntaxKind.ArrowFunction) {
|
||||
thisParentContainer = container;
|
||||
}
|
||||
container = blockScopeContainer = node;
|
||||
container = blockScopeContainer = node as IsContainer;
|
||||
if (containerFlags & ContainerFlags.HasLocals) {
|
||||
container.locals = createSymbolTable();
|
||||
(container as HasLocals).locals = createSymbolTable();
|
||||
addToContainerChain(container as HasLocals);
|
||||
}
|
||||
addToContainerChain(container);
|
||||
}
|
||||
else if (containerFlags & ContainerFlags.IsBlockScopedContainer) {
|
||||
blockScopeContainer = node;
|
||||
blockScopeContainer.locals = undefined;
|
||||
blockScopeContainer = node as IsBlockScopedContainer;
|
||||
if (containerFlags & ContainerFlags.HasLocals) {
|
||||
(blockScopeContainer as HasLocals).locals = undefined;
|
||||
}
|
||||
}
|
||||
if (containerFlags & ContainerFlags.IsControlFlowContainer) {
|
||||
const saveCurrentFlow = currentFlow;
|
||||
@@ -1051,7 +1067,7 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
|
||||
return;
|
||||
}
|
||||
if (node.kind >= SyntaxKind.FirstStatement && node.kind <= SyntaxKind.LastStatement && !options.allowUnreachableCode) {
|
||||
node.flowNode = currentFlow;
|
||||
(node as HasFlowNode).flowNode = currentFlow;
|
||||
}
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.WhileStatement:
|
||||
@@ -2121,88 +2137,7 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
|
||||
}
|
||||
}
|
||||
|
||||
function getContainerFlags(node: Node): ContainerFlags {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ClassExpression:
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
case SyntaxKind.ObjectLiteralExpression:
|
||||
case SyntaxKind.TypeLiteral:
|
||||
case SyntaxKind.JSDocTypeLiteral:
|
||||
case SyntaxKind.JsxAttributes:
|
||||
return ContainerFlags.IsContainer;
|
||||
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
return ContainerFlags.IsContainer | ContainerFlags.IsInterface;
|
||||
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
case SyntaxKind.TypeAliasDeclaration:
|
||||
case SyntaxKind.MappedType:
|
||||
case SyntaxKind.IndexSignature:
|
||||
return ContainerFlags.IsContainer | ContainerFlags.HasLocals;
|
||||
|
||||
case SyntaxKind.SourceFile:
|
||||
return ContainerFlags.IsContainer | ContainerFlags.IsControlFlowContainer | ContainerFlags.HasLocals;
|
||||
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
if (isObjectLiteralOrClassExpressionMethodOrAccessor(node)) {
|
||||
return ContainerFlags.IsContainer | ContainerFlags.IsControlFlowContainer | ContainerFlags.HasLocals | ContainerFlags.IsFunctionLike | ContainerFlags.IsObjectLiteralOrClassExpressionMethodOrAccessor;
|
||||
}
|
||||
// falls through
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
case SyntaxKind.CallSignature:
|
||||
case SyntaxKind.JSDocSignature:
|
||||
case SyntaxKind.JSDocFunctionType:
|
||||
case SyntaxKind.FunctionType:
|
||||
case SyntaxKind.ConstructSignature:
|
||||
case SyntaxKind.ConstructorType:
|
||||
case SyntaxKind.ClassStaticBlockDeclaration:
|
||||
return ContainerFlags.IsContainer | ContainerFlags.IsControlFlowContainer | ContainerFlags.HasLocals | ContainerFlags.IsFunctionLike;
|
||||
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
return ContainerFlags.IsContainer | ContainerFlags.IsControlFlowContainer | ContainerFlags.HasLocals | ContainerFlags.IsFunctionLike | ContainerFlags.IsFunctionExpression;
|
||||
|
||||
case SyntaxKind.ModuleBlock:
|
||||
return ContainerFlags.IsControlFlowContainer;
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
return (node as PropertyDeclaration).initializer ? ContainerFlags.IsControlFlowContainer : 0;
|
||||
|
||||
case SyntaxKind.CatchClause:
|
||||
case SyntaxKind.ForStatement:
|
||||
case SyntaxKind.ForInStatement:
|
||||
case SyntaxKind.ForOfStatement:
|
||||
case SyntaxKind.CaseBlock:
|
||||
return ContainerFlags.IsBlockScopedContainer;
|
||||
|
||||
case SyntaxKind.Block:
|
||||
// do not treat blocks directly inside a function as a block-scoped-container.
|
||||
// Locals that reside in this block should go to the function locals. Otherwise 'x'
|
||||
// would not appear to be a redeclaration of a block scoped local in the following
|
||||
// example:
|
||||
//
|
||||
// function foo() {
|
||||
// var x;
|
||||
// let x;
|
||||
// }
|
||||
//
|
||||
// If we placed 'var x' into the function locals and 'let x' into the locals of
|
||||
// the block, then there would be no collision.
|
||||
//
|
||||
// By not creating a new block-scoped-container here, we ensure that both 'var x'
|
||||
// and 'let x' go into the Function-container's locals, and we do get a collision
|
||||
// conflict.
|
||||
return isFunctionLike(node.parent) || isClassStaticBlockDeclaration(node.parent) ? ContainerFlags.None : ContainerFlags.IsBlockScopedContainer;
|
||||
}
|
||||
|
||||
return ContainerFlags.None;
|
||||
}
|
||||
|
||||
function addToContainerChain(next: Node) {
|
||||
function addToContainerChain(next: HasLocals) {
|
||||
if (lastContainer) {
|
||||
lastContainer.nextContainer = next;
|
||||
}
|
||||
@@ -2256,8 +2191,6 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
case SyntaxKind.JSDocFunctionType:
|
||||
case SyntaxKind.JSDocTypedefTag:
|
||||
case SyntaxKind.JSDocCallbackTag:
|
||||
case SyntaxKind.ClassStaticBlockDeclaration:
|
||||
case SyntaxKind.TypeAliasDeclaration:
|
||||
case SyntaxKind.MappedType:
|
||||
@@ -2267,6 +2200,7 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
|
||||
// their container in the tree). To accomplish this, we simply add their declared
|
||||
// symbol to the 'locals' of the container. These symbols can then be found as
|
||||
// the type checker walks up the containers, checking them for matching names.
|
||||
if (container.locals) Debug.assertNode(container, canHaveLocals);
|
||||
return declareSymbol(container.locals!, /*parent*/ undefined, node, symbolFlags, symbolExcludes);
|
||||
}
|
||||
}
|
||||
@@ -2394,6 +2328,7 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
|
||||
}
|
||||
// falls through
|
||||
default:
|
||||
Debug.assertNode(blockScopeContainer, canHaveLocals);
|
||||
if (!blockScopeContainer.locals) {
|
||||
blockScopeContainer.locals = createSymbolTable();
|
||||
addToContainerChain(blockScopeContainer);
|
||||
@@ -2413,8 +2348,8 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
|
||||
const saveCurrentFlow = currentFlow;
|
||||
for (const typeAlias of delayedTypeAliases) {
|
||||
const host = typeAlias.parent.parent;
|
||||
container = findAncestor(host.parent, n => !!(getContainerFlags(n) & ContainerFlags.IsContainer)) || file;
|
||||
blockScopeContainer = getEnclosingBlockScopeContainer(host) || file;
|
||||
container = (findAncestor(host.parent, n => !!(getContainerFlags(n) & ContainerFlags.IsContainer)) as IsContainer | undefined) || file;
|
||||
blockScopeContainer = (getEnclosingBlockScopeContainer(host) as IsBlockScopedContainer | undefined) || file;
|
||||
currentFlow = initFlowNode({ flags: FlowFlags.Start });
|
||||
parent = typeAlias;
|
||||
bind(typeAlias.typeExpression);
|
||||
@@ -2440,7 +2375,7 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
|
||||
container = declName.parent.expression;
|
||||
break;
|
||||
case AssignmentDeclarationKind.PrototypeProperty:
|
||||
container = (declName.parent.expression as PropertyAccessExpression).name;
|
||||
container = (declName.parent.expression as PropertyAccessEntityNameExpression).name;
|
||||
break;
|
||||
case AssignmentDeclarationKind.Property:
|
||||
container = isExportsOrModuleExportsOrAlias(file, declName.parent.expression) ? file
|
||||
@@ -2733,7 +2668,7 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
|
||||
bindChildren(node);
|
||||
}
|
||||
else {
|
||||
bindContainer(node, containerFlags);
|
||||
bindContainer(node as HasContainerFlags, containerFlags);
|
||||
}
|
||||
parent = saveParent;
|
||||
}
|
||||
@@ -2803,18 +2738,20 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
|
||||
}
|
||||
// falls through
|
||||
case SyntaxKind.ThisKeyword:
|
||||
// TODO: Why use `isExpression` here? both Identifier and ThisKeyword are expressions.
|
||||
if (currentFlow && (isExpression(node) || parent.kind === SyntaxKind.ShorthandPropertyAssignment)) {
|
||||
node.flowNode = currentFlow;
|
||||
(node as Identifier | ThisExpression).flowNode = currentFlow;
|
||||
}
|
||||
// TODO: a `ThisExpression` is not an Identifier, this cast is unsound
|
||||
return checkContextualIdentifier(node as Identifier);
|
||||
case SyntaxKind.QualifiedName:
|
||||
if (currentFlow && isPartOfTypeQuery(node)) {
|
||||
node.flowNode = currentFlow;
|
||||
(node as QualifiedName).flowNode = currentFlow;
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.MetaProperty:
|
||||
case SyntaxKind.SuperKeyword:
|
||||
node.flowNode = currentFlow;
|
||||
(node as MetaProperty | SuperExpression).flowNode = currentFlow;
|
||||
break;
|
||||
case SyntaxKind.PrivateIdentifier:
|
||||
return checkPrivateIdentifier(node as PrivateIdentifier);
|
||||
@@ -2897,7 +2834,7 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
return bindVariableDeclarationOrBindingElement(node as VariableDeclaration);
|
||||
case SyntaxKind.BindingElement:
|
||||
node.flowNode = currentFlow;
|
||||
(node as BindingElement).flowNode = currentFlow;
|
||||
return bindVariableDeclarationOrBindingElement(node as BindingElement);
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
case SyntaxKind.PropertySignature:
|
||||
@@ -2943,7 +2880,7 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
|
||||
return bindObjectLiteralExpression(node as ObjectLiteralExpression);
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
return bindFunctionExpression(node as FunctionExpression);
|
||||
return bindFunctionExpression(node as FunctionExpression | ArrowFunction);
|
||||
|
||||
case SyntaxKind.CallExpression:
|
||||
const assignmentKind = getAssignmentDeclarationKind(node as CallExpression);
|
||||
@@ -3208,7 +3145,7 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
|
||||
if (hasPrivateIdentifier) {
|
||||
return;
|
||||
}
|
||||
const thisContainer = getThisContainer(node, /*includeArrowFunctions*/ false);
|
||||
const thisContainer = getThisContainer(node, /*includeArrowFunctions*/ false, /*includeClassComputedPropertyName*/ false);
|
||||
switch (thisContainer.kind) {
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
@@ -3257,7 +3194,7 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
|
||||
if (hasDynamicName(node)) {
|
||||
break;
|
||||
}
|
||||
else if ((thisContainer as SourceFile).commonJsModuleIndicator) {
|
||||
else if (thisContainer.commonJsModuleIndicator) {
|
||||
declareSymbol(thisContainer.symbol.exports!, thisContainer.symbol, node, SymbolFlags.Property | SymbolFlags.ExportValue, SymbolFlags.None);
|
||||
}
|
||||
else {
|
||||
@@ -3497,7 +3434,7 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
|
||||
return expr.parent;
|
||||
}
|
||||
|
||||
function lookupSymbolForPropertyAccess(node: BindableStaticNameExpression, lookupContainer: Node = container): Symbol | undefined {
|
||||
function lookupSymbolForPropertyAccess(node: BindableStaticNameExpression, lookupContainer: IsContainer | IsBlockScopedContainer | EntityNameExpression = container): Symbol | undefined {
|
||||
if (isIdentifier(node)) {
|
||||
return lookupSymbolForName(lookupContainer, node.escapedText);
|
||||
}
|
||||
@@ -3652,7 +3589,7 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
|
||||
}
|
||||
}
|
||||
|
||||
function bindFunctionExpression(node: FunctionExpression) {
|
||||
function bindFunctionExpression(node: FunctionExpression | ArrowFunction) {
|
||||
if (!file.isDeclarationFile && !(node.flags & NodeFlags.Ambient)) {
|
||||
if (isAsyncFunction(node)) {
|
||||
emitFlags |= NodeFlags.HasAsyncFunctions;
|
||||
@@ -3687,11 +3624,10 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
|
||||
|
||||
function bindTypeParameter(node: TypeParameterDeclaration) {
|
||||
if (isJSDocTemplateTag(node.parent)) {
|
||||
const container = getEffectiveContainerForJSDocTemplateTag(node.parent);
|
||||
const container: HasLocals | undefined = getEffectiveContainerForJSDocTemplateTag(node.parent);
|
||||
if (container) {
|
||||
if (!container.locals) {
|
||||
container.locals = createSymbolTable();
|
||||
}
|
||||
Debug.assertNode(container, canHaveLocals);
|
||||
container.locals ??= createSymbolTable();
|
||||
declareSymbol(container.locals, /*parent*/ undefined, node, SymbolFlags.TypeParameter, SymbolFlags.TypeParameterExcludes);
|
||||
}
|
||||
else {
|
||||
@@ -3699,11 +3635,10 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
|
||||
}
|
||||
}
|
||||
else if (node.parent.kind === SyntaxKind.InferType) {
|
||||
const container = getInferTypeContainer(node.parent);
|
||||
const container: HasLocals | undefined = getInferTypeContainer(node.parent);
|
||||
if (container) {
|
||||
if (!container.locals) {
|
||||
container.locals = createSymbolTable();
|
||||
}
|
||||
Debug.assertNode(container, canHaveLocals);
|
||||
container.locals ??= createSymbolTable();
|
||||
declareSymbol(container.locals, /*parent*/ undefined, node, SymbolFlags.TypeParameter, SymbolFlags.TypeParameterExcludes);
|
||||
}
|
||||
else {
|
||||
@@ -3823,13 +3758,96 @@ export function isExportsOrModuleExportsOrAlias(sourceFile: SourceFile, node: Ex
|
||||
return false;
|
||||
}
|
||||
|
||||
function getContainerFlags(node: Node): ContainerFlags {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ClassExpression:
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
case SyntaxKind.ObjectLiteralExpression:
|
||||
case SyntaxKind.TypeLiteral:
|
||||
case SyntaxKind.JSDocTypeLiteral:
|
||||
case SyntaxKind.JsxAttributes:
|
||||
return ContainerFlags.IsContainer;
|
||||
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
return ContainerFlags.IsContainer | ContainerFlags.IsInterface;
|
||||
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
case SyntaxKind.TypeAliasDeclaration:
|
||||
case SyntaxKind.MappedType:
|
||||
case SyntaxKind.IndexSignature:
|
||||
return ContainerFlags.IsContainer | ContainerFlags.HasLocals;
|
||||
|
||||
case SyntaxKind.SourceFile:
|
||||
return ContainerFlags.IsContainer | ContainerFlags.IsControlFlowContainer | ContainerFlags.HasLocals;
|
||||
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
if (isObjectLiteralOrClassExpressionMethodOrAccessor(node)) {
|
||||
return ContainerFlags.IsContainer | ContainerFlags.IsControlFlowContainer | ContainerFlags.HasLocals | ContainerFlags.IsFunctionLike | ContainerFlags.IsObjectLiteralOrClassExpressionMethodOrAccessor;
|
||||
}
|
||||
// falls through
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
case SyntaxKind.CallSignature:
|
||||
case SyntaxKind.JSDocSignature:
|
||||
case SyntaxKind.JSDocFunctionType:
|
||||
case SyntaxKind.FunctionType:
|
||||
case SyntaxKind.ConstructSignature:
|
||||
case SyntaxKind.ConstructorType:
|
||||
case SyntaxKind.ClassStaticBlockDeclaration:
|
||||
return ContainerFlags.IsContainer | ContainerFlags.IsControlFlowContainer | ContainerFlags.HasLocals | ContainerFlags.IsFunctionLike;
|
||||
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
return ContainerFlags.IsContainer | ContainerFlags.IsControlFlowContainer | ContainerFlags.HasLocals | ContainerFlags.IsFunctionLike | ContainerFlags.IsFunctionExpression;
|
||||
|
||||
case SyntaxKind.ModuleBlock:
|
||||
return ContainerFlags.IsControlFlowContainer;
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
return (node as PropertyDeclaration).initializer ? ContainerFlags.IsControlFlowContainer : 0;
|
||||
|
||||
case SyntaxKind.CatchClause:
|
||||
case SyntaxKind.ForStatement:
|
||||
case SyntaxKind.ForInStatement:
|
||||
case SyntaxKind.ForOfStatement:
|
||||
case SyntaxKind.CaseBlock:
|
||||
return ContainerFlags.IsBlockScopedContainer | ContainerFlags.HasLocals;
|
||||
|
||||
case SyntaxKind.Block:
|
||||
// do not treat blocks directly inside a function as a block-scoped-container.
|
||||
// Locals that reside in this block should go to the function locals. Otherwise 'x'
|
||||
// would not appear to be a redeclaration of a block scoped local in the following
|
||||
// example:
|
||||
//
|
||||
// function foo() {
|
||||
// var x;
|
||||
// let x;
|
||||
// }
|
||||
//
|
||||
// If we placed 'var x' into the function locals and 'let x' into the locals of
|
||||
// the block, then there would be no collision.
|
||||
//
|
||||
// By not creating a new block-scoped-container here, we ensure that both 'var x'
|
||||
// and 'let x' go into the Function-container's locals, and we do get a collision
|
||||
// conflict.
|
||||
return isFunctionLike(node.parent) || isClassStaticBlockDeclaration(node.parent) ? ContainerFlags.None : ContainerFlags.IsBlockScopedContainer | ContainerFlags.HasLocals;
|
||||
}
|
||||
|
||||
return ContainerFlags.None;
|
||||
}
|
||||
|
||||
function lookupSymbolForName(container: Node, name: __String): Symbol | undefined {
|
||||
const local = container.locals && container.locals.get(name);
|
||||
const local = tryCast(container, canHaveLocals)?.locals?.get(name);
|
||||
if (local) {
|
||||
return local.exportSymbol || local;
|
||||
return local.exportSymbol ?? local;
|
||||
}
|
||||
if (isSourceFile(container) && container.jsGlobalAugmentations && container.jsGlobalAugmentations.has(name)) {
|
||||
return container.jsGlobalAugmentations.get(name);
|
||||
}
|
||||
return container.symbol && container.symbol.exports && container.symbol.exports.get(name);
|
||||
if (canHaveSymbol(container)) {
|
||||
return container.symbol?.exports?.get(name);
|
||||
}
|
||||
}
|
||||
|
||||
+489
-363
File diff suppressed because it is too large
Load Diff
@@ -28,6 +28,7 @@ import {
|
||||
BundleFileTextLikeKind,
|
||||
CallExpression,
|
||||
CallSignatureDeclaration,
|
||||
canHaveLocals,
|
||||
CaseBlock,
|
||||
CaseClause,
|
||||
CaseOrDefaultClause,
|
||||
@@ -181,6 +182,7 @@ import {
|
||||
getTransformers,
|
||||
getTypeNode,
|
||||
guessIndentation,
|
||||
HasLocals,
|
||||
hasRecordedExternalHelpers,
|
||||
HeritageClause,
|
||||
Identifier,
|
||||
@@ -412,6 +414,7 @@ import {
|
||||
tracing,
|
||||
TransformationResult,
|
||||
transformNodes,
|
||||
tryCast,
|
||||
tryParseRawSourceMap,
|
||||
TryStatement,
|
||||
TupleTypeNode,
|
||||
@@ -2475,8 +2478,7 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
|
||||
//
|
||||
|
||||
function emitPrivateIdentifier(node: PrivateIdentifier) {
|
||||
const writeText = node.symbol ? writeSymbol : write;
|
||||
writeText(getTextOfNode(node, /*includeTrivia*/ false), node.symbol);
|
||||
write(getTextOfNode(node, /*includeTrivia*/ false));
|
||||
}
|
||||
|
||||
|
||||
@@ -5656,9 +5658,9 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
|
||||
/**
|
||||
* Returns a value indicating whether a name is unique within a container.
|
||||
*/
|
||||
function isUniqueLocalName(name: string, container: Node): boolean {
|
||||
for (let node = container; isNodeDescendantOf(node, container); node = node.nextContainer!) {
|
||||
if (node.locals) {
|
||||
function isUniqueLocalName(name: string, container: HasLocals | undefined): boolean {
|
||||
for (let node = container; node && isNodeDescendantOf(node, container); node = node.nextContainer) {
|
||||
if (canHaveLocals(node) && node.locals) {
|
||||
const local = node.locals.get(escapeLeadingUnderscores(name));
|
||||
// We conservatively include alias symbols to cover cases where they're emitted as locals
|
||||
if (local && local.flags & (SymbolFlags.Value | SymbolFlags.ExportValue | SymbolFlags.Alias)) {
|
||||
@@ -5798,7 +5800,7 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
|
||||
function generateNameForModuleOrEnum(node: ModuleDeclaration | EnumDeclaration) {
|
||||
const name = getTextOfNode(node.name);
|
||||
// Use module/enum name itself if it is unique, otherwise make a unique variation
|
||||
return isUniqueLocalName(name, node) ? name : makeUniqueName(name, isUniqueName, /*optimistic*/ false, /*scoped*/ false, /*privateName*/ false, /*prefix*/ "", /*suffix*/ "");
|
||||
return isUniqueLocalName(name, tryCast(node, canHaveLocals)) ? name : makeUniqueName(name, isUniqueName, /*optimistic*/ false, /*scoped*/ false, /*privateName*/ false, /*prefix*/ "", /*suffix*/ "");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1055
-728
File diff suppressed because it is too large
Load Diff
+5
-20
@@ -3,7 +3,6 @@ import {
|
||||
AccessorDeclaration,
|
||||
addRange,
|
||||
addRelatedInfo,
|
||||
AmdDependency,
|
||||
append,
|
||||
ArrayBindingElement,
|
||||
ArrayBindingPattern,
|
||||
@@ -29,13 +28,13 @@ import {
|
||||
BreakStatement,
|
||||
CallExpression,
|
||||
CallSignatureDeclaration,
|
||||
canHaveJSDoc,
|
||||
canHaveModifiers,
|
||||
CaseBlock,
|
||||
CaseClause,
|
||||
CaseOrDefaultClause,
|
||||
CatchClause,
|
||||
CharacterCodes,
|
||||
CheckJsDirective,
|
||||
ClassDeclaration,
|
||||
ClassElement,
|
||||
ClassExpression,
|
||||
@@ -87,7 +86,6 @@ import {
|
||||
ExpressionWithTypeArguments,
|
||||
ExternalModuleReference,
|
||||
fileExtensionIsOneOf,
|
||||
FileReference,
|
||||
findIndex,
|
||||
forEach,
|
||||
ForEachChildNodes,
|
||||
@@ -166,7 +164,6 @@ import {
|
||||
JSDocCallbackTag,
|
||||
JSDocClassTag,
|
||||
JSDocComment,
|
||||
JSDocContainer,
|
||||
JSDocDeprecatedTag,
|
||||
JSDocEnumTag,
|
||||
JSDocFunctionType,
|
||||
@@ -287,6 +284,7 @@ import {
|
||||
PlusToken,
|
||||
PostfixUnaryExpression,
|
||||
PostfixUnaryOperator,
|
||||
PragmaContext,
|
||||
PragmaDefinition,
|
||||
PragmaKindFlags,
|
||||
PragmaMap,
|
||||
@@ -1641,7 +1639,7 @@ namespace Parser {
|
||||
const statement = factory.createExpressionStatement(expression) as JsonObjectExpressionStatement;
|
||||
finishNode(statement, pos);
|
||||
statements = createNodeArray([statement], pos);
|
||||
endOfFileToken = parseExpectedToken(SyntaxKind.EndOfFileToken, Diagnostics.Unexpected_token);
|
||||
endOfFileToken = parseExpectedToken(SyntaxKind.EndOfFileToken, Diagnostics.Unexpected_token) as EndOfFileToken;
|
||||
}
|
||||
|
||||
// Set source file so that errors will be reported with this file name
|
||||
@@ -3068,9 +3066,9 @@ namespace Parser {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if ((node as JSDocContainer).jsDocCache) {
|
||||
if (canHaveJSDoc(node) && node.jsDocCache) {
|
||||
// jsDocCache may include tags from parent nodes, which might have been modified.
|
||||
(node as JSDocContainer).jsDocCache = undefined;
|
||||
node.jsDocCache = undefined;
|
||||
}
|
||||
|
||||
return node;
|
||||
@@ -10109,19 +10107,6 @@ export function isDeclarationFileName(fileName: string): boolean {
|
||||
return fileExtensionIsOneOf(fileName, supportedDeclarationExtensions);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export interface PragmaContext {
|
||||
languageVersion: ScriptTarget;
|
||||
pragmas?: PragmaMap;
|
||||
checkJsDirective?: CheckJsDirective;
|
||||
referencedFiles: FileReference[];
|
||||
typeReferenceDirectives: FileReference[];
|
||||
libReferenceDirectives: FileReference[];
|
||||
amdDependencies: AmdDependency[];
|
||||
hasNoDefaultLib?: boolean;
|
||||
moduleName?: string;
|
||||
}
|
||||
|
||||
function parseResolutionMode(mode: string | undefined, pos: number, end: number, reportDiagnostic: PragmaDiagnosticReporter): ResolutionMode {
|
||||
if (!mode) {
|
||||
return undefined;
|
||||
|
||||
+4
-14
@@ -239,6 +239,7 @@ import {
|
||||
ParsedCommandLine,
|
||||
parseIsolatedEntityName,
|
||||
parseJsonSourceFileConfigFileContent,
|
||||
parseNodeFactory,
|
||||
Path,
|
||||
pathIsAbsolute,
|
||||
pathIsRelative,
|
||||
@@ -3343,26 +3344,15 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
|
||||
}
|
||||
}
|
||||
|
||||
function createRedirectSourceFile(redirectTarget: SourceFile, unredirected: SourceFile, fileName: string, path: Path, resolvedPath: Path, originalFileName: string, sourceFileOptions: CreateSourceFileOptions): SourceFile {
|
||||
const redirect: SourceFile = Object.create(redirectTarget);
|
||||
function createRedirectedSourceFile(redirectTarget: SourceFile, unredirected: SourceFile, fileName: string, path: Path, resolvedPath: Path, originalFileName: string, sourceFileOptions: CreateSourceFileOptions): SourceFile {
|
||||
const redirect = parseNodeFactory.createRedirectedSourceFile({ redirectTarget, unredirected });
|
||||
redirect.fileName = fileName;
|
||||
redirect.path = path;
|
||||
redirect.resolvedPath = resolvedPath;
|
||||
redirect.originalFileName = originalFileName;
|
||||
redirect.redirectInfo = { redirectTarget, unredirected };
|
||||
redirect.packageJsonLocations = sourceFileOptions.packageJsonLocations?.length ? sourceFileOptions.packageJsonLocations : undefined;
|
||||
redirect.packageJsonScope = sourceFileOptions.packageJsonScope;
|
||||
sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0);
|
||||
Object.defineProperties(redirect, {
|
||||
id: {
|
||||
get(this: SourceFile) { return this.redirectInfo!.redirectTarget.id; },
|
||||
set(this: SourceFile, value: SourceFile["id"]) { this.redirectInfo!.redirectTarget.id = value; },
|
||||
},
|
||||
symbol: {
|
||||
get(this: SourceFile) { return this.redirectInfo!.redirectTarget.symbol; },
|
||||
set(this: SourceFile, value: SourceFile["symbol"]) { this.redirectInfo!.redirectTarget.symbol = value; },
|
||||
},
|
||||
});
|
||||
return redirect;
|
||||
}
|
||||
|
||||
@@ -3494,7 +3484,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
|
||||
if (fileFromPackageId) {
|
||||
// Some other SourceFile already exists with this package name and version.
|
||||
// Instead of creating a duplicate, just redirect to the existing one.
|
||||
const dupFile = createRedirectSourceFile(fileFromPackageId, file!, fileName, path, toPath(fileName), originalFileName, sourceFileOptions);
|
||||
const dupFile = createRedirectedSourceFile(fileFromPackageId, file!, fileName, path, toPath(fileName), originalFileName, sourceFileOptions);
|
||||
redirectTargetsMap.add(fileFromPackageId.path, fileName);
|
||||
addFileToFilesByName(dupFile, path, redirectedPath);
|
||||
addFileIncludeReason(dupFile, reason);
|
||||
|
||||
+396
-123
@@ -16,6 +16,7 @@ import {
|
||||
ProgramBuildInfo,
|
||||
Push,
|
||||
SymlinkCache,
|
||||
ThisContainer,
|
||||
} from "./_namespaces/ts";
|
||||
|
||||
// branded string type used to store absolute, normalized and canonicalized paths
|
||||
@@ -895,23 +896,66 @@ export interface Node extends ReadonlyTextRange {
|
||||
/** @internal */ modifierFlagsCache: ModifierFlags;
|
||||
/** @internal */ readonly transformFlags: TransformFlags; // Flags for transforms
|
||||
/** @internal */ id?: NodeId; // Unique id (used to look up NodeLinks)
|
||||
readonly parent: Node; // Parent node (initialized by binding)
|
||||
readonly parent: Node; // Parent node (initialized by binding)
|
||||
/** @internal */ original?: Node; // The original node if this is an updated node.
|
||||
/** @internal */ symbol: Symbol; // Symbol declared by node (initialized by binding)
|
||||
/** @internal */ locals?: SymbolTable; // Locals associated with node (initialized by binding)
|
||||
/** @internal */ nextContainer?: Node; // Next container in declaration order (initialized by binding)
|
||||
/** @internal */ localSymbol?: Symbol; // Local symbol declared by node (initialized by binding only for exported nodes)
|
||||
/** @internal */ flowNode?: FlowNode; // Associated FlowNode (initialized by binding)
|
||||
/** @internal */ emitNode?: EmitNode; // Associated EmitNode (initialized by transforms)
|
||||
/** @internal */ contextualType?: Type; // Used to temporarily assign a contextual type during overload resolution
|
||||
/** @internal */ inferenceContext?: InferenceContext; // Inference context for contextual type
|
||||
// NOTE: `symbol` and `localSymbol` have been moved to `Declaration`
|
||||
// `locals` and `nextContainer` have been moved to `LocalsContainer`
|
||||
// `flowNode` has been moved to `FlowContainer`
|
||||
// see: https://github.com/microsoft/TypeScript/pull/51682
|
||||
}
|
||||
|
||||
export interface JSDocContainer {
|
||||
export interface JSDocContainer extends Node {
|
||||
_jsdocContainerBrand: any;
|
||||
/** @internal */ jsDoc?: JSDoc[]; // JSDoc that directly precedes this node
|
||||
/** @internal */ jsDocCache?: readonly JSDocTag[]; // Cache for getJSDocTags
|
||||
}
|
||||
|
||||
export interface LocalsContainer extends Node {
|
||||
_localsContainerBrand: any;
|
||||
/** @internal */ locals?: SymbolTable; // Locals associated with node (initialized by binding)
|
||||
/** @internal */ nextContainer?: HasLocals; // Next container in declaration order (initialized by binding)
|
||||
}
|
||||
|
||||
export interface FlowContainer extends Node {
|
||||
_flowContainerBrand: any;
|
||||
/** @internal */ flowNode?: FlowNode; // Associated FlowNode (initialized by binding)
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export type HasFlowNode =
|
||||
| Identifier
|
||||
| ThisExpression
|
||||
| SuperExpression
|
||||
| QualifiedName
|
||||
| MetaProperty
|
||||
| ElementAccessExpression
|
||||
| PropertyAccessExpression
|
||||
| BindingElement
|
||||
| FunctionExpression
|
||||
| ArrowFunction
|
||||
| MethodDeclaration
|
||||
| GetAccessorDeclaration
|
||||
| SetAccessorDeclaration
|
||||
| VariableStatement
|
||||
| ExpressionStatement
|
||||
| IfStatement
|
||||
| DoStatement
|
||||
| WhileStatement
|
||||
| ForStatement
|
||||
| ForInStatement
|
||||
| ForOfStatement
|
||||
| ContinueStatement
|
||||
| BreakStatement
|
||||
| ReturnStatement
|
||||
| WithStatement
|
||||
| SwitchStatement
|
||||
| LabeledStatement
|
||||
| ThrowStatement
|
||||
| TryStatement
|
||||
| DebuggerStatement
|
||||
;
|
||||
|
||||
// Ideally, `ForEachChildNodes` and `VisitEachChildNodes` would not differ.
|
||||
// However, `forEachChild` currently processes JSDoc comment syntax and missing declarations more thoroughly.
|
||||
// On the other hand, `visitEachChild` actually processes `Identifier`s (which really *shouldn't* have children,
|
||||
@@ -1104,62 +1148,69 @@ export type HasChildren =
|
||||
;
|
||||
|
||||
export type HasJSDoc =
|
||||
| ParameterDeclaration
|
||||
| CallSignatureDeclaration
|
||||
| ClassStaticBlockDeclaration
|
||||
| ConstructSignatureDeclaration
|
||||
| MethodSignature
|
||||
| PropertySignature
|
||||
| AccessorDeclaration
|
||||
| ArrowFunction
|
||||
| ParenthesizedExpression
|
||||
| SpreadAssignment
|
||||
| ShorthandPropertyAssignment
|
||||
| PropertyAssignment
|
||||
| FunctionExpression
|
||||
| EmptyStatement
|
||||
| DebuggerStatement
|
||||
| BinaryExpression
|
||||
| Block
|
||||
| VariableStatement
|
||||
| ExpressionStatement
|
||||
| IfStatement
|
||||
| BreakStatement
|
||||
| CallSignatureDeclaration
|
||||
| CaseClause
|
||||
| ClassLikeDeclaration
|
||||
| ClassStaticBlockDeclaration
|
||||
| ConstructorDeclaration
|
||||
| ConstructorTypeNode
|
||||
| ConstructSignatureDeclaration
|
||||
| ContinueStatement
|
||||
| DebuggerStatement
|
||||
| DoStatement
|
||||
| WhileStatement
|
||||
| ForStatement
|
||||
| ElementAccessExpression
|
||||
| EmptyStatement
|
||||
| EndOfFileToken
|
||||
| EnumDeclaration
|
||||
| EnumMember
|
||||
| ExportAssignment
|
||||
| ExportDeclaration
|
||||
| ExportSpecifier
|
||||
| ExpressionStatement
|
||||
| ForInStatement
|
||||
| ForOfStatement
|
||||
| BreakStatement
|
||||
| ContinueStatement
|
||||
| ReturnStatement
|
||||
| WithStatement
|
||||
| SwitchStatement
|
||||
| ForStatement
|
||||
| FunctionDeclaration
|
||||
| FunctionExpression
|
||||
| FunctionTypeNode
|
||||
| Identifier
|
||||
| IfStatement
|
||||
| ImportDeclaration
|
||||
| ImportEqualsDeclaration
|
||||
| IndexSignatureDeclaration
|
||||
| InterfaceDeclaration
|
||||
| JSDocFunctionType
|
||||
| JSDocSignature
|
||||
| LabeledStatement
|
||||
| MethodDeclaration
|
||||
| MethodSignature
|
||||
| ModuleDeclaration
|
||||
| NamedTupleMember
|
||||
| NamespaceExportDeclaration
|
||||
| ObjectLiteralExpression
|
||||
| ParameterDeclaration
|
||||
| ParenthesizedExpression
|
||||
| PropertyAccessExpression
|
||||
| PropertyAssignment
|
||||
| PropertyDeclaration
|
||||
| PropertySignature
|
||||
| ReturnStatement
|
||||
| ShorthandPropertyAssignment
|
||||
| SpreadAssignment
|
||||
| SwitchStatement
|
||||
| ThrowStatement
|
||||
| TryStatement
|
||||
| FunctionDeclaration
|
||||
| ConstructorDeclaration
|
||||
| MethodDeclaration
|
||||
| VariableDeclaration
|
||||
| PropertyDeclaration
|
||||
| AccessorDeclaration
|
||||
| ClassLikeDeclaration
|
||||
| InterfaceDeclaration
|
||||
| TypeAliasDeclaration
|
||||
| EnumMember
|
||||
| EnumDeclaration
|
||||
| ModuleDeclaration
|
||||
| ImportEqualsDeclaration
|
||||
| ImportDeclaration
|
||||
| NamespaceExportDeclaration
|
||||
| ExportAssignment
|
||||
| IndexSignatureDeclaration
|
||||
| FunctionTypeNode
|
||||
| ConstructorTypeNode
|
||||
| JSDocFunctionType
|
||||
| ExportDeclaration
|
||||
| NamedTupleMember
|
||||
| ExportSpecifier
|
||||
| CaseClause
|
||||
| EndOfFileToken
|
||||
| TypeParameterDeclaration
|
||||
| VariableDeclaration
|
||||
| VariableStatement
|
||||
| WhileStatement
|
||||
| WithStatement
|
||||
;
|
||||
|
||||
export type HasType =
|
||||
@@ -1306,6 +1357,191 @@ export type HasIllegalModifiers =
|
||||
| NamespaceExportDeclaration
|
||||
;
|
||||
|
||||
/**
|
||||
* Declarations that can contain other declarations. Corresponds with `ContainerFlags.IsContainer` in binder.ts.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export type IsContainer =
|
||||
| ClassExpression
|
||||
| ClassDeclaration
|
||||
| EnumDeclaration
|
||||
| ObjectLiteralExpression
|
||||
| TypeLiteralNode
|
||||
| JSDocTypeLiteral
|
||||
| JsxAttributes
|
||||
| InterfaceDeclaration
|
||||
| ModuleDeclaration
|
||||
| TypeAliasDeclaration
|
||||
| MappedTypeNode
|
||||
| IndexSignatureDeclaration
|
||||
| SourceFile
|
||||
| GetAccessorDeclaration
|
||||
| SetAccessorDeclaration
|
||||
| MethodDeclaration
|
||||
| ConstructorDeclaration
|
||||
| FunctionDeclaration
|
||||
| MethodSignature
|
||||
| CallSignatureDeclaration
|
||||
| JSDocSignature
|
||||
| JSDocFunctionType
|
||||
| FunctionTypeNode
|
||||
| ConstructSignatureDeclaration
|
||||
| ConstructorTypeNode
|
||||
| ClassStaticBlockDeclaration
|
||||
| FunctionExpression
|
||||
| ArrowFunction
|
||||
;
|
||||
|
||||
/**
|
||||
* Nodes that introduce a new block scope. Corresponds with `ContainerFlags.IsBlockScopedContainer` in binder.ts.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export type IsBlockScopedContainer =
|
||||
| IsContainer
|
||||
| CatchClause
|
||||
| ForStatement
|
||||
| ForInStatement
|
||||
| ForOfStatement
|
||||
| CaseBlock
|
||||
| Block
|
||||
;
|
||||
|
||||
/**
|
||||
* Corresponds with `ContainerFlags.IsControlFlowContainer` in binder.ts.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export type IsControlFlowContainer =
|
||||
| SourceFile
|
||||
| GetAccessorDeclaration
|
||||
| SetAccessorDeclaration
|
||||
| MethodDeclaration
|
||||
| ConstructorDeclaration
|
||||
| FunctionDeclaration
|
||||
| MethodSignature
|
||||
| CallSignatureDeclaration
|
||||
| JSDocSignature
|
||||
| JSDocFunctionType
|
||||
| FunctionTypeNode
|
||||
| ConstructSignatureDeclaration
|
||||
| ConstructorTypeNode
|
||||
| ClassStaticBlockDeclaration
|
||||
| FunctionExpression
|
||||
| ArrowFunction
|
||||
| ModuleBlock
|
||||
| PropertyDeclaration
|
||||
;
|
||||
|
||||
/**
|
||||
* Corresponds with `ContainerFlags.IsFunctionLike` in binder.ts.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export type IsFunctionLike =
|
||||
| GetAccessorDeclaration
|
||||
| SetAccessorDeclaration
|
||||
| MethodDeclaration
|
||||
| ConstructorDeclaration
|
||||
| FunctionDeclaration
|
||||
| MethodSignature
|
||||
| CallSignatureDeclaration
|
||||
| JSDocSignature
|
||||
| JSDocFunctionType
|
||||
| FunctionTypeNode
|
||||
| ConstructSignatureDeclaration
|
||||
| ConstructorTypeNode
|
||||
| ClassStaticBlockDeclaration
|
||||
| FunctionExpression
|
||||
| ArrowFunction
|
||||
;
|
||||
|
||||
/**
|
||||
* Corresponds with `ContainerFlags.IsFunctionExpression` in binder.ts.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export type IsFunctionExpression =
|
||||
| FunctionExpression
|
||||
| ArrowFunction
|
||||
;
|
||||
|
||||
/**
|
||||
* Nodes that can have local symbols. Corresponds with `ContainerFlags.HasLocals`. Constituents should extend
|
||||
* {@link LocalsContainer}.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export type HasLocals =
|
||||
| ArrowFunction
|
||||
| Block
|
||||
| CallSignatureDeclaration
|
||||
| CaseBlock
|
||||
| CatchClause
|
||||
| ClassStaticBlockDeclaration
|
||||
| ConditionalTypeNode
|
||||
| ConstructorDeclaration
|
||||
| ConstructorTypeNode
|
||||
| ConstructSignatureDeclaration
|
||||
| ForStatement
|
||||
| ForInStatement
|
||||
| ForOfStatement
|
||||
| FunctionDeclaration
|
||||
| FunctionExpression
|
||||
| FunctionTypeNode
|
||||
| GetAccessorDeclaration
|
||||
| IndexSignatureDeclaration
|
||||
| JSDocCallbackTag
|
||||
| JSDocEnumTag
|
||||
| JSDocFunctionType
|
||||
| JSDocSignature
|
||||
| JSDocTypedefTag
|
||||
| MappedTypeNode
|
||||
| MethodDeclaration
|
||||
| MethodSignature
|
||||
| ModuleDeclaration
|
||||
| SetAccessorDeclaration
|
||||
| SourceFile
|
||||
| TypeAliasDeclaration
|
||||
;
|
||||
|
||||
/**
|
||||
* Corresponds with `ContainerFlags.IsInterface` in binder.ts.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export type IsInterface =
|
||||
| InterfaceDeclaration
|
||||
;
|
||||
|
||||
/**
|
||||
* Corresponds with `ContainerFlags.IsObjectLiteralOrClassExpressionMethodOrAccessor` in binder.ts.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export type IsObjectLiteralOrClassExpressionMethodOrAccessor =
|
||||
| GetAccessorDeclaration
|
||||
| SetAccessorDeclaration
|
||||
| MethodDeclaration
|
||||
;
|
||||
|
||||
/**
|
||||
* Corresponds with `ContainerFlags` in binder.ts.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export type HasContainerFlags =
|
||||
| IsContainer
|
||||
| IsBlockScopedContainer
|
||||
| IsControlFlowContainer
|
||||
| IsFunctionLike
|
||||
| IsFunctionExpression
|
||||
| HasLocals
|
||||
| IsInterface
|
||||
| IsObjectLiteralOrClassExpressionMethodOrAccessor
|
||||
;
|
||||
|
||||
/** @internal */
|
||||
export interface MutableNodeArray<T extends Node> extends Array<T>, TextRange {
|
||||
hasTrailingComma: boolean;
|
||||
@@ -1432,7 +1668,7 @@ export const enum GeneratedIdentifierFlags {
|
||||
AllowNameSubstitution = 1 << 6, // Used by `module.ts` to indicate generated nodes which can have substitutions performed upon them (as they were generated by an earlier transform phase)
|
||||
}
|
||||
|
||||
export interface Identifier extends PrimaryExpression, Declaration {
|
||||
export interface Identifier extends PrimaryExpression, Declaration, JSDocContainer, FlowContainer {
|
||||
readonly kind: SyntaxKind.Identifier;
|
||||
/**
|
||||
* Prefer to use `id.unescapedText`. (Note: This is available only in services, not internally to the TypeScript compiler.)
|
||||
@@ -1461,7 +1697,7 @@ export interface GeneratedIdentifier extends Identifier {
|
||||
autoGenerateFlags: GeneratedIdentifierFlags;
|
||||
}
|
||||
|
||||
export interface QualifiedName extends Node {
|
||||
export interface QualifiedName extends Node, FlowContainer {
|
||||
readonly kind: SyntaxKind.QualifiedName;
|
||||
readonly left: EntityName;
|
||||
readonly right: Identifier;
|
||||
@@ -1486,6 +1722,8 @@ export type DeclarationName =
|
||||
|
||||
export interface Declaration extends Node {
|
||||
_declarationBrand: any;
|
||||
/** @internal */ symbol: Symbol; // Symbol declared by node (initialized by binding)
|
||||
/** @internal */ localSymbol?: Symbol; // Local symbol declared by node (initialized by binding only for exported nodes)
|
||||
}
|
||||
|
||||
export interface NamedDeclaration extends Declaration {
|
||||
@@ -1557,7 +1795,7 @@ export interface Decorator extends Node {
|
||||
readonly expression: LeftHandSideExpression;
|
||||
}
|
||||
|
||||
export interface TypeParameterDeclaration extends NamedDeclaration {
|
||||
export interface TypeParameterDeclaration extends NamedDeclaration, JSDocContainer {
|
||||
readonly kind: SyntaxKind.TypeParameter;
|
||||
readonly parent: DeclarationWithTypeParameterChildren | InferTypeNode;
|
||||
readonly modifiers?: NodeArray<Modifier>;
|
||||
@@ -1594,11 +1832,11 @@ export type SignatureDeclaration =
|
||||
| FunctionExpression
|
||||
| ArrowFunction;
|
||||
|
||||
export interface CallSignatureDeclaration extends SignatureDeclarationBase, TypeElement {
|
||||
export interface CallSignatureDeclaration extends SignatureDeclarationBase, TypeElement, LocalsContainer {
|
||||
readonly kind: SyntaxKind.CallSignature;
|
||||
}
|
||||
|
||||
export interface ConstructSignatureDeclaration extends SignatureDeclarationBase, TypeElement {
|
||||
export interface ConstructSignatureDeclaration extends SignatureDeclarationBase, TypeElement, LocalsContainer {
|
||||
readonly kind: SyntaxKind.ConstructSignature;
|
||||
}
|
||||
|
||||
@@ -1633,7 +1871,7 @@ export interface ParameterDeclaration extends NamedDeclaration, JSDocContainer {
|
||||
readonly initializer?: Expression; // Optional initializer
|
||||
}
|
||||
|
||||
export interface BindingElement extends NamedDeclaration {
|
||||
export interface BindingElement extends NamedDeclaration, FlowContainer {
|
||||
readonly kind: SyntaxKind.BindingElement;
|
||||
readonly parent: BindingPattern;
|
||||
readonly propertyName?: PropertyName; // Binding property name (in object binding pattern)
|
||||
@@ -1647,6 +1885,7 @@ export type BindingElementGrandparent = BindingElement["parent"]["parent"];
|
||||
|
||||
export interface PropertySignature extends TypeElement, JSDocContainer {
|
||||
readonly kind: SyntaxKind.PropertySignature;
|
||||
readonly parent: TypeLiteralNode | InterfaceDeclaration;
|
||||
readonly modifiers?: NodeArray<Modifier>;
|
||||
readonly name: PropertyName; // Declared property name
|
||||
readonly questionToken?: QuestionToken; // Present on optional property
|
||||
@@ -1766,10 +2005,6 @@ export type VariableLikeDeclaration =
|
||||
| JSDocPropertyTag
|
||||
| JSDocParameterTag;
|
||||
|
||||
export interface PropertyLikeDeclaration extends NamedDeclaration {
|
||||
readonly name: PropertyName;
|
||||
}
|
||||
|
||||
export interface ObjectBindingPattern extends Node {
|
||||
readonly kind: SyntaxKind.ObjectBindingPattern;
|
||||
readonly parent: VariableDeclaration | ParameterDeclaration | BindingElement;
|
||||
@@ -1816,7 +2051,7 @@ export type FunctionLikeDeclaration =
|
||||
/** @deprecated Use SignatureDeclaration */
|
||||
export type FunctionLike = SignatureDeclaration;
|
||||
|
||||
export interface FunctionDeclaration extends FunctionLikeDeclarationBase, DeclarationStatement {
|
||||
export interface FunctionDeclaration extends FunctionLikeDeclarationBase, DeclarationStatement, LocalsContainer {
|
||||
readonly kind: SyntaxKind.FunctionDeclaration;
|
||||
readonly modifiers?: NodeArray<Modifier>;
|
||||
readonly name?: Identifier;
|
||||
@@ -1826,9 +2061,9 @@ export interface FunctionDeclaration extends FunctionLikeDeclarationBase, Declar
|
||||
/** @internal */ readonly illegalDecorators?: NodeArray<Decorator> | undefined; // functions cannot have decorators
|
||||
}
|
||||
|
||||
export interface MethodSignature extends SignatureDeclarationBase, TypeElement {
|
||||
export interface MethodSignature extends SignatureDeclarationBase, TypeElement, LocalsContainer {
|
||||
readonly kind: SyntaxKind.MethodSignature;
|
||||
readonly parent: ObjectTypeDeclaration;
|
||||
readonly parent: TypeLiteralNode | InterfaceDeclaration;
|
||||
readonly modifiers?: NodeArray<Modifier>;
|
||||
readonly name: PropertyName;
|
||||
}
|
||||
@@ -1842,7 +2077,7 @@ export interface MethodSignature extends SignatureDeclarationBase, TypeElement {
|
||||
// Because of this, it may be necessary to determine what sort of MethodDeclaration you have
|
||||
// at later stages of the compiler pipeline. In that case, you can either check the parent kind
|
||||
// of the method, or use helpers like isObjectLiteralMethodDeclaration
|
||||
export interface MethodDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer {
|
||||
export interface MethodDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer, LocalsContainer, FlowContainer {
|
||||
readonly kind: SyntaxKind.MethodDeclaration;
|
||||
readonly parent: ClassLikeDeclaration | ObjectLiteralExpression;
|
||||
readonly modifiers?: NodeArray<ModifierLike> | undefined;
|
||||
@@ -1853,7 +2088,7 @@ export interface MethodDeclaration extends FunctionLikeDeclarationBase, ClassEle
|
||||
/** @internal */ readonly exclamationToken?: ExclamationToken | undefined; // A method cannot have an exclamation token
|
||||
}
|
||||
|
||||
export interface ConstructorDeclaration extends FunctionLikeDeclarationBase, ClassElement, JSDocContainer {
|
||||
export interface ConstructorDeclaration extends FunctionLikeDeclarationBase, ClassElement, JSDocContainer, LocalsContainer {
|
||||
readonly kind: SyntaxKind.Constructor;
|
||||
readonly parent: ClassLikeDeclaration;
|
||||
readonly modifiers?: NodeArray<Modifier> | undefined;
|
||||
@@ -1873,7 +2108,7 @@ export interface SemicolonClassElement extends ClassElement {
|
||||
|
||||
// See the comment on MethodDeclaration for the intuition behind GetAccessorDeclaration being a
|
||||
// ClassElement and an ObjectLiteralElement.
|
||||
export interface GetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, TypeElement, ObjectLiteralElement, JSDocContainer {
|
||||
export interface GetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, TypeElement, ObjectLiteralElement, JSDocContainer, LocalsContainer, FlowContainer {
|
||||
readonly kind: SyntaxKind.GetAccessor;
|
||||
readonly parent: ClassLikeDeclaration | ObjectLiteralExpression | TypeLiteralNode | InterfaceDeclaration;
|
||||
readonly modifiers?: NodeArray<ModifierLike>;
|
||||
@@ -1886,7 +2121,7 @@ export interface GetAccessorDeclaration extends FunctionLikeDeclarationBase, Cla
|
||||
|
||||
// See the comment on MethodDeclaration for the intuition behind SetAccessorDeclaration being a
|
||||
// ClassElement and an ObjectLiteralElement.
|
||||
export interface SetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, TypeElement, ObjectLiteralElement, JSDocContainer {
|
||||
export interface SetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, TypeElement, ObjectLiteralElement, JSDocContainer, LocalsContainer, FlowContainer {
|
||||
readonly kind: SyntaxKind.SetAccessor;
|
||||
readonly parent: ClassLikeDeclaration | ObjectLiteralExpression | TypeLiteralNode | InterfaceDeclaration;
|
||||
readonly modifiers?: NodeArray<ModifierLike>;
|
||||
@@ -1900,7 +2135,7 @@ export interface SetAccessorDeclaration extends FunctionLikeDeclarationBase, Cla
|
||||
|
||||
export type AccessorDeclaration = GetAccessorDeclaration | SetAccessorDeclaration;
|
||||
|
||||
export interface IndexSignatureDeclaration extends SignatureDeclarationBase, ClassElement, TypeElement {
|
||||
export interface IndexSignatureDeclaration extends SignatureDeclarationBase, ClassElement, TypeElement, LocalsContainer {
|
||||
readonly kind: SyntaxKind.IndexSignature;
|
||||
readonly parent: ObjectTypeDeclaration;
|
||||
readonly modifiers?: NodeArray<Modifier>;
|
||||
@@ -1910,7 +2145,7 @@ export interface IndexSignatureDeclaration extends SignatureDeclarationBase, Cla
|
||||
/** @internal */ readonly illegalDecorators?: NodeArray<Decorator> | undefined;
|
||||
}
|
||||
|
||||
export interface ClassStaticBlockDeclaration extends ClassElement, JSDocContainer {
|
||||
export interface ClassStaticBlockDeclaration extends ClassElement, JSDocContainer, LocalsContainer {
|
||||
readonly kind: SyntaxKind.ClassStaticBlockDeclaration;
|
||||
readonly parent: ClassDeclaration | ClassExpression;
|
||||
readonly body: Block;
|
||||
@@ -1965,14 +2200,14 @@ export interface FunctionOrConstructorTypeNodeBase extends TypeNode, SignatureDe
|
||||
readonly type: TypeNode;
|
||||
}
|
||||
|
||||
export interface FunctionTypeNode extends FunctionOrConstructorTypeNodeBase {
|
||||
export interface FunctionTypeNode extends FunctionOrConstructorTypeNodeBase, LocalsContainer {
|
||||
readonly kind: SyntaxKind.FunctionType;
|
||||
|
||||
// The following properties are used only to report grammar errors
|
||||
/** @internal */ readonly modifiers?: NodeArray<Modifier> | undefined;
|
||||
}
|
||||
|
||||
export interface ConstructorTypeNode extends FunctionOrConstructorTypeNodeBase {
|
||||
export interface ConstructorTypeNode extends FunctionOrConstructorTypeNodeBase, LocalsContainer {
|
||||
readonly kind: SyntaxKind.ConstructorType;
|
||||
readonly modifiers?: NodeArray<Modifier>;
|
||||
}
|
||||
@@ -2017,7 +2252,7 @@ export interface TupleTypeNode extends TypeNode {
|
||||
readonly elements: NodeArray<TypeNode | NamedTupleMember>;
|
||||
}
|
||||
|
||||
export interface NamedTupleMember extends TypeNode, JSDocContainer, Declaration {
|
||||
export interface NamedTupleMember extends TypeNode, Declaration, JSDocContainer {
|
||||
readonly kind: SyntaxKind.NamedTupleMember;
|
||||
readonly dotDotDotToken?: Token<SyntaxKind.DotDotDotToken>;
|
||||
readonly name: Identifier;
|
||||
@@ -2047,7 +2282,7 @@ export interface IntersectionTypeNode extends TypeNode {
|
||||
readonly types: NodeArray<TypeNode>;
|
||||
}
|
||||
|
||||
export interface ConditionalTypeNode extends TypeNode {
|
||||
export interface ConditionalTypeNode extends TypeNode, LocalsContainer {
|
||||
readonly kind: SyntaxKind.ConditionalType;
|
||||
readonly checkType: TypeNode;
|
||||
readonly extendsType: TypeNode;
|
||||
@@ -2082,7 +2317,7 @@ export interface IndexedAccessTypeNode extends TypeNode {
|
||||
readonly indexType: TypeNode;
|
||||
}
|
||||
|
||||
export interface MappedTypeNode extends TypeNode, Declaration {
|
||||
export interface MappedTypeNode extends TypeNode, Declaration, LocalsContainer {
|
||||
readonly kind: SyntaxKind.MappedType;
|
||||
readonly readonlyToken?: ReadonlyKeyword | PlusToken | MinusToken;
|
||||
readonly typeParameter: TypeParameterDeclaration;
|
||||
@@ -2211,11 +2446,11 @@ export interface FalseLiteral extends PrimaryExpression {
|
||||
|
||||
export type BooleanLiteral = TrueLiteral | FalseLiteral;
|
||||
|
||||
export interface ThisExpression extends PrimaryExpression {
|
||||
export interface ThisExpression extends PrimaryExpression, FlowContainer {
|
||||
readonly kind: SyntaxKind.ThisKeyword;
|
||||
}
|
||||
|
||||
export interface SuperExpression extends PrimaryExpression {
|
||||
export interface SuperExpression extends PrimaryExpression, FlowContainer {
|
||||
readonly kind: SyntaxKind.SuperKeyword;
|
||||
}
|
||||
|
||||
@@ -2405,7 +2640,7 @@ export type LogicalOrCoalescingAssignmentOperator
|
||||
|
||||
export type BinaryOperatorToken = Token<BinaryOperator>;
|
||||
|
||||
export interface BinaryExpression extends Expression, Declaration {
|
||||
export interface BinaryExpression extends Expression, Declaration, JSDocContainer {
|
||||
readonly kind: SyntaxKind.BinaryExpression;
|
||||
readonly left: Expression;
|
||||
readonly operatorToken: BinaryOperatorToken;
|
||||
@@ -2500,14 +2735,14 @@ export interface ConditionalExpression extends Expression {
|
||||
export type FunctionBody = Block;
|
||||
export type ConciseBody = FunctionBody | Expression;
|
||||
|
||||
export interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclarationBase, JSDocContainer {
|
||||
export interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclarationBase, JSDocContainer, LocalsContainer, FlowContainer {
|
||||
readonly kind: SyntaxKind.FunctionExpression;
|
||||
readonly modifiers?: NodeArray<Modifier>;
|
||||
readonly name?: Identifier;
|
||||
readonly body: FunctionBody; // Required, whereas the member inherited from FunctionDeclaration is optional
|
||||
}
|
||||
|
||||
export interface ArrowFunction extends Expression, FunctionLikeDeclarationBase, JSDocContainer {
|
||||
export interface ArrowFunction extends Expression, FunctionLikeDeclarationBase, JSDocContainer, LocalsContainer, FlowContainer {
|
||||
readonly kind: SyntaxKind.ArrowFunction;
|
||||
readonly modifiers?: NodeArray<Modifier>;
|
||||
readonly equalsGreaterThanToken: EqualsGreaterThanToken;
|
||||
@@ -2681,7 +2916,7 @@ export interface ObjectLiteralExpressionBase<T extends ObjectLiteralElement> ext
|
||||
}
|
||||
|
||||
// An ObjectLiteralExpression is the declaration node for an anonymous symbol.
|
||||
export interface ObjectLiteralExpression extends ObjectLiteralExpressionBase<ObjectLiteralElementLike> {
|
||||
export interface ObjectLiteralExpression extends ObjectLiteralExpressionBase<ObjectLiteralElementLike>, JSDocContainer {
|
||||
readonly kind: SyntaxKind.ObjectLiteralExpression;
|
||||
/** @internal */
|
||||
multiLine?: boolean;
|
||||
@@ -2691,7 +2926,7 @@ export type EntityNameExpression = Identifier | PropertyAccessEntityNameExpressi
|
||||
export type EntityNameOrEntityNameExpression = EntityName | EntityNameExpression;
|
||||
export type AccessExpression = PropertyAccessExpression | ElementAccessExpression;
|
||||
|
||||
export interface PropertyAccessExpression extends MemberExpression, NamedDeclaration {
|
||||
export interface PropertyAccessExpression extends MemberExpression, NamedDeclaration, JSDocContainer, FlowContainer {
|
||||
readonly kind: SyntaxKind.PropertyAccessExpression;
|
||||
readonly expression: LeftHandSideExpression;
|
||||
readonly questionDotToken?: QuestionDotToken;
|
||||
@@ -2724,7 +2959,7 @@ export interface PropertyAccessEntityNameExpression extends PropertyAccessExpres
|
||||
readonly name: Identifier;
|
||||
}
|
||||
|
||||
export interface ElementAccessExpression extends MemberExpression {
|
||||
export interface ElementAccessExpression extends MemberExpression, Declaration, JSDocContainer, FlowContainer {
|
||||
readonly kind: SyntaxKind.ElementAccessExpression;
|
||||
readonly expression: LeftHandSideExpression;
|
||||
readonly questionDotToken?: QuestionDotToken;
|
||||
@@ -2897,7 +3132,7 @@ export interface NonNullChain extends NonNullExpression {
|
||||
|
||||
// NOTE: MetaProperty is really a MemberExpression, but we consider it a PrimaryExpression
|
||||
// for the same reasons we treat NewExpression as a PrimaryExpression.
|
||||
export interface MetaProperty extends PrimaryExpression {
|
||||
export interface MetaProperty extends PrimaryExpression, FlowContainer {
|
||||
readonly kind: SyntaxKind.MetaProperty;
|
||||
readonly keywordToken: SyntaxKind.NewKeyword | SyntaxKind.ImportKeyword;
|
||||
readonly name: Identifier;
|
||||
@@ -3075,7 +3310,7 @@ export interface EmptyStatement extends Statement {
|
||||
readonly kind: SyntaxKind.EmptyStatement;
|
||||
}
|
||||
|
||||
export interface DebuggerStatement extends Statement {
|
||||
export interface DebuggerStatement extends Statement, FlowContainer {
|
||||
readonly kind: SyntaxKind.DebuggerStatement;
|
||||
}
|
||||
|
||||
@@ -3095,13 +3330,13 @@ export type BlockLike =
|
||||
| CaseOrDefaultClause
|
||||
;
|
||||
|
||||
export interface Block extends Statement {
|
||||
export interface Block extends Statement, LocalsContainer {
|
||||
readonly kind: SyntaxKind.Block;
|
||||
readonly statements: NodeArray<Statement>;
|
||||
/** @internal */ multiLine?: boolean;
|
||||
}
|
||||
|
||||
export interface VariableStatement extends Statement {
|
||||
export interface VariableStatement extends Statement, FlowContainer {
|
||||
readonly kind: SyntaxKind.VariableStatement;
|
||||
readonly modifiers?: NodeArray<Modifier>;
|
||||
readonly declarationList: VariableDeclarationList;
|
||||
@@ -3110,7 +3345,7 @@ export interface VariableStatement extends Statement {
|
||||
/** @internal */ illegalDecorators?: NodeArray<Decorator> | undefined;
|
||||
}
|
||||
|
||||
export interface ExpressionStatement extends Statement {
|
||||
export interface ExpressionStatement extends Statement, FlowContainer {
|
||||
readonly kind: SyntaxKind.ExpressionStatement;
|
||||
readonly expression: Expression;
|
||||
}
|
||||
@@ -3120,7 +3355,7 @@ export interface PrologueDirective extends ExpressionStatement {
|
||||
readonly expression: StringLiteral;
|
||||
}
|
||||
|
||||
export interface IfStatement extends Statement {
|
||||
export interface IfStatement extends Statement, FlowContainer {
|
||||
readonly kind: SyntaxKind.IfStatement;
|
||||
readonly expression: Expression;
|
||||
readonly thenStatement: Statement;
|
||||
@@ -3131,12 +3366,12 @@ export interface IterationStatement extends Statement {
|
||||
readonly statement: Statement;
|
||||
}
|
||||
|
||||
export interface DoStatement extends IterationStatement {
|
||||
export interface DoStatement extends IterationStatement, FlowContainer {
|
||||
readonly kind: SyntaxKind.DoStatement;
|
||||
readonly expression: Expression;
|
||||
}
|
||||
|
||||
export interface WhileStatement extends IterationStatement {
|
||||
export interface WhileStatement extends IterationStatement, FlowContainer {
|
||||
readonly kind: SyntaxKind.WhileStatement;
|
||||
readonly expression: Expression;
|
||||
}
|
||||
@@ -3146,7 +3381,7 @@ export type ForInitializer =
|
||||
| Expression
|
||||
;
|
||||
|
||||
export interface ForStatement extends IterationStatement {
|
||||
export interface ForStatement extends IterationStatement, LocalsContainer, FlowContainer {
|
||||
readonly kind: SyntaxKind.ForStatement;
|
||||
readonly initializer?: ForInitializer;
|
||||
readonly condition?: Expression;
|
||||
@@ -3158,25 +3393,25 @@ export type ForInOrOfStatement =
|
||||
| ForOfStatement
|
||||
;
|
||||
|
||||
export interface ForInStatement extends IterationStatement {
|
||||
export interface ForInStatement extends IterationStatement, LocalsContainer, FlowContainer {
|
||||
readonly kind: SyntaxKind.ForInStatement;
|
||||
readonly initializer: ForInitializer;
|
||||
readonly expression: Expression;
|
||||
}
|
||||
|
||||
export interface ForOfStatement extends IterationStatement {
|
||||
export interface ForOfStatement extends IterationStatement, LocalsContainer, FlowContainer {
|
||||
readonly kind: SyntaxKind.ForOfStatement;
|
||||
readonly awaitModifier?: AwaitKeyword;
|
||||
readonly initializer: ForInitializer;
|
||||
readonly expression: Expression;
|
||||
}
|
||||
|
||||
export interface BreakStatement extends Statement {
|
||||
export interface BreakStatement extends Statement, FlowContainer {
|
||||
readonly kind: SyntaxKind.BreakStatement;
|
||||
readonly label?: Identifier;
|
||||
}
|
||||
|
||||
export interface ContinueStatement extends Statement {
|
||||
export interface ContinueStatement extends Statement, FlowContainer {
|
||||
readonly kind: SyntaxKind.ContinueStatement;
|
||||
readonly label?: Identifier;
|
||||
}
|
||||
@@ -3186,25 +3421,25 @@ export type BreakOrContinueStatement =
|
||||
| ContinueStatement
|
||||
;
|
||||
|
||||
export interface ReturnStatement extends Statement {
|
||||
export interface ReturnStatement extends Statement, FlowContainer {
|
||||
readonly kind: SyntaxKind.ReturnStatement;
|
||||
readonly expression?: Expression;
|
||||
}
|
||||
|
||||
export interface WithStatement extends Statement {
|
||||
export interface WithStatement extends Statement, FlowContainer {
|
||||
readonly kind: SyntaxKind.WithStatement;
|
||||
readonly expression: Expression;
|
||||
readonly statement: Statement;
|
||||
}
|
||||
|
||||
export interface SwitchStatement extends Statement {
|
||||
export interface SwitchStatement extends Statement, FlowContainer {
|
||||
readonly kind: SyntaxKind.SwitchStatement;
|
||||
readonly expression: Expression;
|
||||
readonly caseBlock: CaseBlock;
|
||||
possiblyExhaustive?: boolean; // initialized by binding
|
||||
}
|
||||
|
||||
export interface CaseBlock extends Node {
|
||||
export interface CaseBlock extends Node, LocalsContainer {
|
||||
readonly kind: SyntaxKind.CaseBlock;
|
||||
readonly parent: SwitchStatement;
|
||||
readonly clauses: NodeArray<CaseOrDefaultClause>;
|
||||
@@ -3230,25 +3465,25 @@ export type CaseOrDefaultClause =
|
||||
| DefaultClause
|
||||
;
|
||||
|
||||
export interface LabeledStatement extends Statement {
|
||||
export interface LabeledStatement extends Statement, FlowContainer {
|
||||
readonly kind: SyntaxKind.LabeledStatement;
|
||||
readonly label: Identifier;
|
||||
readonly statement: Statement;
|
||||
}
|
||||
|
||||
export interface ThrowStatement extends Statement {
|
||||
export interface ThrowStatement extends Statement, FlowContainer {
|
||||
readonly kind: SyntaxKind.ThrowStatement;
|
||||
readonly expression: Expression;
|
||||
}
|
||||
|
||||
export interface TryStatement extends Statement {
|
||||
export interface TryStatement extends Statement, FlowContainer {
|
||||
readonly kind: SyntaxKind.TryStatement;
|
||||
readonly tryBlock: Block;
|
||||
readonly catchClause?: CatchClause;
|
||||
readonly finallyBlock?: Block;
|
||||
}
|
||||
|
||||
export interface CatchClause extends Node {
|
||||
export interface CatchClause extends Node, LocalsContainer {
|
||||
readonly kind: SyntaxKind.CatchClause;
|
||||
readonly parent: TryStatement;
|
||||
readonly variableDeclaration?: VariableDeclaration;
|
||||
@@ -3331,7 +3566,7 @@ export interface HeritageClause extends Node {
|
||||
readonly types: NodeArray<ExpressionWithTypeArguments>;
|
||||
}
|
||||
|
||||
export interface TypeAliasDeclaration extends DeclarationStatement, JSDocContainer {
|
||||
export interface TypeAliasDeclaration extends DeclarationStatement, JSDocContainer, LocalsContainer {
|
||||
readonly kind: SyntaxKind.TypeAliasDeclaration;
|
||||
readonly modifiers?: NodeArray<Modifier>;
|
||||
readonly name: Identifier;
|
||||
@@ -3376,7 +3611,7 @@ export interface AmbientModuleDeclaration extends ModuleDeclaration {
|
||||
readonly body?: ModuleBlock;
|
||||
}
|
||||
|
||||
export interface ModuleDeclaration extends DeclarationStatement, JSDocContainer {
|
||||
export interface ModuleDeclaration extends DeclarationStatement, JSDocContainer, LocalsContainer {
|
||||
readonly kind: SyntaxKind.ModuleDeclaration;
|
||||
readonly parent: ModuleBody | SourceFile;
|
||||
readonly modifiers?: NodeArray<Modifier>;
|
||||
@@ -3672,7 +3907,7 @@ export interface JSDocOptionalType extends JSDocType {
|
||||
readonly type: TypeNode;
|
||||
}
|
||||
|
||||
export interface JSDocFunctionType extends JSDocType, SignatureDeclarationBase {
|
||||
export interface JSDocFunctionType extends JSDocType, SignatureDeclarationBase, LocalsContainer {
|
||||
readonly kind: SyntaxKind.JSDocFunctionType;
|
||||
}
|
||||
|
||||
@@ -3781,7 +4016,7 @@ export interface JSDocOverrideTag extends JSDocTag {
|
||||
readonly kind: SyntaxKind.JSDocOverrideTag;
|
||||
}
|
||||
|
||||
export interface JSDocEnumTag extends JSDocTag, Declaration {
|
||||
export interface JSDocEnumTag extends JSDocTag, Declaration, LocalsContainer {
|
||||
readonly kind: SyntaxKind.JSDocEnumTag;
|
||||
readonly parent: JSDoc;
|
||||
readonly typeExpression: JSDocTypeExpression;
|
||||
@@ -3813,7 +4048,7 @@ export interface JSDocTypeTag extends JSDocTag {
|
||||
readonly typeExpression: JSDocTypeExpression;
|
||||
}
|
||||
|
||||
export interface JSDocTypedefTag extends JSDocTag, NamedDeclaration {
|
||||
export interface JSDocTypedefTag extends JSDocTag, NamedDeclaration, LocalsContainer {
|
||||
readonly kind: SyntaxKind.JSDocTypedefTag;
|
||||
readonly parent: JSDoc;
|
||||
readonly fullName?: JSDocNamespaceDeclaration | Identifier;
|
||||
@@ -3821,7 +4056,7 @@ export interface JSDocTypedefTag extends JSDocTag, NamedDeclaration {
|
||||
readonly typeExpression?: JSDocTypeExpression | JSDocTypeLiteral;
|
||||
}
|
||||
|
||||
export interface JSDocCallbackTag extends JSDocTag, NamedDeclaration {
|
||||
export interface JSDocCallbackTag extends JSDocTag, NamedDeclaration, LocalsContainer {
|
||||
readonly kind: SyntaxKind.JSDocCallbackTag;
|
||||
readonly parent: JSDoc;
|
||||
readonly fullName?: JSDocNamespaceDeclaration | Identifier;
|
||||
@@ -3834,7 +4069,7 @@ export interface JSDocThrowsTag extends JSDocTag {
|
||||
readonly typeExpression?: JSDocTypeExpression;
|
||||
}
|
||||
|
||||
export interface JSDocSignature extends JSDocType, Declaration {
|
||||
export interface JSDocSignature extends JSDocType, Declaration, JSDocContainer, LocalsContainer {
|
||||
readonly kind: SyntaxKind.JSDocSignature;
|
||||
readonly typeParameters?: readonly JSDocTemplateTag[];
|
||||
readonly parameters: readonly JSDocParameterTag[];
|
||||
@@ -3858,7 +4093,7 @@ export interface JSDocParameterTag extends JSDocPropertyLikeTag {
|
||||
readonly kind: SyntaxKind.JSDocParameterTag;
|
||||
}
|
||||
|
||||
export interface JSDocTypeLiteral extends JSDocType {
|
||||
export interface JSDocTypeLiteral extends JSDocType, Declaration {
|
||||
readonly kind: SyntaxKind.JSDocTypeLiteral;
|
||||
readonly jsDocPropertyTags?: readonly JSDocPropertyLikeTag[];
|
||||
/** If true, then this type literal represents an *array* of its type. */
|
||||
@@ -3992,7 +4227,7 @@ export interface RedirectInfo {
|
||||
export type ResolutionMode = ModuleKind.ESNext | ModuleKind.CommonJS | undefined;
|
||||
|
||||
// Source files are declarations when they are external modules.
|
||||
export interface SourceFile extends Declaration {
|
||||
export interface SourceFile extends Declaration, LocalsContainer {
|
||||
readonly kind: SyntaxKind.SourceFile;
|
||||
readonly statements: NodeArray<Statement>;
|
||||
readonly endOfFileToken: Token<SyntaxKind.EndOfFileToken>;
|
||||
@@ -4094,7 +4329,7 @@ export interface SourceFile extends Declaration {
|
||||
// JS identifier-declarations that are intended to merge with globals
|
||||
/** @internal */ jsGlobalAugmentations?: SymbolTable;
|
||||
|
||||
/** @internal */ identifiers: Map<string, string>; // Map from a string to an interned string
|
||||
/** @internal */ identifiers: ReadonlyMap<string, string>; // Map from a string to an interned string
|
||||
/** @internal */ nodeCount: number;
|
||||
/** @internal */ identifierCount: number;
|
||||
/** @internal */ symbolCount: number;
|
||||
@@ -4141,6 +4376,31 @@ export interface SourceFile extends Declaration {
|
||||
/** @internal */ endFlowNode?: FlowNode;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export interface ReadonlyPragmaContext {
|
||||
languageVersion: ScriptTarget;
|
||||
pragmas?: ReadonlyPragmaMap;
|
||||
checkJsDirective?: CheckJsDirective;
|
||||
referencedFiles: readonly FileReference[];
|
||||
typeReferenceDirectives: readonly FileReference[];
|
||||
libReferenceDirectives: readonly FileReference[];
|
||||
amdDependencies: readonly AmdDependency[];
|
||||
hasNoDefaultLib?: boolean;
|
||||
moduleName?: string;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export interface PragmaContext extends ReadonlyPragmaContext {
|
||||
pragmas?: PragmaMap;
|
||||
referencedFiles: FileReference[];
|
||||
typeReferenceDirectives: FileReference[];
|
||||
libReferenceDirectives: FileReference[];
|
||||
amdDependencies: AmdDependency[];
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export interface SourceFile extends ReadonlyPragmaContext {}
|
||||
|
||||
/** @internal */
|
||||
export interface CommentDirective {
|
||||
range: TextRange;
|
||||
@@ -4947,7 +5207,7 @@ export interface TypeChecker {
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
tryGetThisTypeAt(node: Node, includeGlobalThis?: boolean, container?: Node): Type | undefined;
|
||||
tryGetThisTypeAt(node: Node, includeGlobalThis?: boolean, container?: ThisContainer): Type | undefined;
|
||||
/** @internal */ getTypeArgumentConstraint(node: TypeNode): Type | undefined;
|
||||
|
||||
/**
|
||||
@@ -5124,7 +5384,7 @@ export interface SymbolWalker {
|
||||
|
||||
// This was previously deprecated in our public API, but is still used internally
|
||||
/** @internal */
|
||||
export interface SymbolWriter extends SymbolTracker {
|
||||
export interface SymbolWriter {
|
||||
writeKeyword(text: string): void;
|
||||
writeOperator(text: string): void;
|
||||
writePunctuation(text: string): void;
|
||||
@@ -5696,7 +5956,17 @@ export interface NodeLinks {
|
||||
isExhaustive?: boolean | 0; // Is node an exhaustive switch statement (0 indicates in-process resolution)
|
||||
skipDirectInference?: true; // Flag set by the API `getContextualType` call on a node when `Completions` is passed to force the checker to skip making inferences to a node's type
|
||||
declarationRequiresScopeChange?: boolean; // Set by `useOuterVariableScopeInParameter` in checker when downlevel emit would change the name resolution scope inside of a parameter.
|
||||
serializedTypes?: Map<string, TypeNode & {truncating?: boolean, addedLength: number}>; // Collection of types serialized at this location
|
||||
serializedTypes?: Map<string, SerializedTypeEntry>; // Collection of types serialized at this location
|
||||
|
||||
contextualType?: Type; // Used to temporarily assign a contextual type during overload resolution
|
||||
inferenceContext?: InferenceContext; // Inference context for contextual type
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export interface SerializedTypeEntry {
|
||||
node: TypeNode;
|
||||
truncating?: boolean;
|
||||
addedLength: number;
|
||||
}
|
||||
|
||||
export const enum TypeFlags {
|
||||
@@ -7863,11 +8133,12 @@ export interface NodeFactory {
|
||||
createToken(token: SyntaxKind.NullKeyword): NullLiteral;
|
||||
createToken(token: SyntaxKind.TrueKeyword): TrueLiteral;
|
||||
createToken(token: SyntaxKind.FalseKeyword): FalseLiteral;
|
||||
createToken(token: SyntaxKind.EndOfFileToken): EndOfFileToken;
|
||||
createToken(token: SyntaxKind.Unknown): Token<SyntaxKind.Unknown>;
|
||||
createToken<TKind extends PunctuationSyntaxKind>(token: TKind): PunctuationToken<TKind>;
|
||||
createToken<TKind extends KeywordTypeSyntaxKind>(token: TKind): KeywordTypeNode<TKind>;
|
||||
createToken<TKind extends ModifierSyntaxKind>(token: TKind): ModifierToken<TKind>;
|
||||
createToken<TKind extends KeywordSyntaxKind>(token: TKind): KeywordToken<TKind>;
|
||||
createToken<TKind extends SyntaxKind.Unknown | SyntaxKind.EndOfFileToken>(token: TKind): Token<TKind>;
|
||||
/** @internal */ createToken<TKind extends SyntaxKind>(token: TKind): Token<TKind>;
|
||||
|
||||
//
|
||||
@@ -8336,6 +8607,8 @@ export interface NodeFactory {
|
||||
createSourceFile(statements: readonly Statement[], endOfFileToken: EndOfFileToken, flags: NodeFlags): SourceFile;
|
||||
updateSourceFile(node: SourceFile, statements: readonly Statement[], isDeclarationFile?: boolean, referencedFiles?: readonly FileReference[], typeReferences?: readonly FileReference[], hasNoDefaultLib?: boolean, libReferences?: readonly FileReference[]): SourceFile;
|
||||
|
||||
/** @internal */ createRedirectedSourceFile(redirectInfo: RedirectInfo): SourceFile;
|
||||
|
||||
/** @internal */ createUnparsedSource(prologues: readonly UnparsedPrologue[], syntheticReferences: readonly UnparsedSyntheticReference[] | undefined, texts: readonly UnparsedSourceText[]): UnparsedSource;
|
||||
/** @internal */ createUnparsedPrologue(data?: string): UnparsedPrologue;
|
||||
/** @internal */ createUnparsedPrepend(data: string | undefined, texts: readonly UnparsedSourceText[]): UnparsedPrepend;
|
||||
|
||||
+178
-22
@@ -34,6 +34,7 @@ import {
|
||||
BundleFileTextLike,
|
||||
CallExpression,
|
||||
CallLikeExpression,
|
||||
CallSignatureDeclaration,
|
||||
canHaveDecorators,
|
||||
canHaveIllegalDecorators,
|
||||
canHaveModifiers,
|
||||
@@ -66,6 +67,7 @@ import {
|
||||
concatenate,
|
||||
ConditionalExpression,
|
||||
ConstructorDeclaration,
|
||||
ConstructSignatureDeclaration,
|
||||
contains,
|
||||
containsPath,
|
||||
createGetCanonicalFileName,
|
||||
@@ -190,6 +192,7 @@ import {
|
||||
getTrailingCommentRanges,
|
||||
HasExpressionInitializer,
|
||||
hasExtension,
|
||||
HasFlowNode,
|
||||
HasInitializer,
|
||||
hasInitializer,
|
||||
HasJSDoc,
|
||||
@@ -214,6 +217,7 @@ import {
|
||||
ImportTypeNode,
|
||||
IndexInfo,
|
||||
indexOfAnyCharCode,
|
||||
IndexSignatureDeclaration,
|
||||
InitializedVariableDeclaration,
|
||||
insertSorted,
|
||||
InterfaceDeclaration,
|
||||
@@ -357,6 +361,7 @@ import {
|
||||
MapLike,
|
||||
MemberName,
|
||||
MethodDeclaration,
|
||||
MethodSignature,
|
||||
ModeAwareCache,
|
||||
ModifierFlags,
|
||||
ModifierLike,
|
||||
@@ -602,10 +607,6 @@ function createSingleLineStringWriter(): EmitTextWriter {
|
||||
increaseIndent: noop,
|
||||
decreaseIndent: noop,
|
||||
clear: () => str = "",
|
||||
trackSymbol: () => false,
|
||||
reportInaccessibleThisError: noop,
|
||||
reportInaccessibleUniqueSymbolError: noop,
|
||||
reportPrivateInBaseOfClassExpression: noop,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2274,7 +2275,7 @@ export function isObjectLiteralMethod(node: Node): node is MethodDeclaration {
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function isObjectLiteralOrClassExpressionMethodOrAccessor(node: Node): node is MethodDeclaration {
|
||||
export function isObjectLiteralOrClassExpressionMethodOrAccessor(node: Node): node is MethodDeclaration | AccessorDeclaration {
|
||||
return (node.kind === SyntaxKind.MethodDeclaration || node.kind === SyntaxKind.GetAccessor || node.kind === SyntaxKind.SetAccessor) &&
|
||||
(node.parent.kind === SyntaxKind.ObjectLiteralExpression ||
|
||||
node.parent.kind === SyntaxKind.ClassExpression);
|
||||
@@ -2362,7 +2363,34 @@ export function getContainingFunctionOrClassStaticBlock(node: Node): SignatureDe
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function getThisContainer(node: Node, includeArrowFunctions: boolean): Node {
|
||||
export type ThisContainer =
|
||||
| FunctionDeclaration
|
||||
| FunctionExpression
|
||||
| ModuleDeclaration
|
||||
| ClassStaticBlockDeclaration
|
||||
| PropertyDeclaration
|
||||
| PropertySignature
|
||||
| MethodDeclaration
|
||||
| MethodSignature
|
||||
| ConstructorDeclaration
|
||||
| GetAccessorDeclaration
|
||||
| SetAccessorDeclaration
|
||||
| CallSignatureDeclaration
|
||||
| ConstructSignatureDeclaration
|
||||
| IndexSignatureDeclaration
|
||||
| EnumDeclaration
|
||||
| SourceFile
|
||||
;
|
||||
|
||||
/** @internal */
|
||||
export function getThisContainer(node: Node, includeArrowFunctions: false, includeClassComputedPropertyName: false): ThisContainer;
|
||||
/** @internal */
|
||||
export function getThisContainer(node: Node, includeArrowFunctions: false, includeClassComputedPropertyName: boolean): ThisContainer | ComputedPropertyName;
|
||||
/** @internal */
|
||||
export function getThisContainer(node: Node, includeArrowFunctions: boolean, includeClassComputedPropertyName: false): ThisContainer | ArrowFunction;
|
||||
/** @internal */
|
||||
export function getThisContainer(node: Node, includeArrowFunctions: boolean, includeClassComputedPropertyName: boolean): ThisContainer | ArrowFunction | ComputedPropertyName;
|
||||
export function getThisContainer(node: Node, includeArrowFunctions: boolean, includeClassComputedPropertyName: boolean) {
|
||||
Debug.assert(node.kind !== SyntaxKind.SourceFile);
|
||||
while (true) {
|
||||
node = node.parent;
|
||||
@@ -2375,15 +2403,15 @@ export function getThisContainer(node: Node, includeArrowFunctions: boolean): No
|
||||
// then the computed property is not a 'this' container.
|
||||
// A computed property name in a class needs to be a this container
|
||||
// so that we can error on it.
|
||||
if (isClassLike(node.parent.parent)) {
|
||||
return node;
|
||||
if (includeClassComputedPropertyName && isClassLike(node.parent.parent)) {
|
||||
return node as ComputedPropertyName;
|
||||
}
|
||||
// If this is a computed property, then the parent should not
|
||||
// make it a this container. The parent might be a property
|
||||
// in an object literal, like a method or accessor. But in order for
|
||||
// such a parent to be a this container, the reference must be in
|
||||
// the *body* of the container.
|
||||
node = node.parent;
|
||||
node = node.parent.parent;
|
||||
break;
|
||||
case SyntaxKind.Decorator:
|
||||
// Decorators are always applied outside of the body of a class or method.
|
||||
@@ -2420,7 +2448,7 @@ export function getThisContainer(node: Node, includeArrowFunctions: boolean): No
|
||||
case SyntaxKind.IndexSignature:
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
case SyntaxKind.SourceFile:
|
||||
return node;
|
||||
return node as ThisContainer | ArrowFunction;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2461,13 +2489,13 @@ export function isInTopLevelContext(node: Node) {
|
||||
if (isIdentifier(node) && (isClassDeclaration(node.parent) || isFunctionDeclaration(node.parent)) && node.parent.name === node) {
|
||||
node = node.parent;
|
||||
}
|
||||
const container = getThisContainer(node, /*includeArrowFunctions*/ true);
|
||||
const container = getThisContainer(node, /*includeArrowFunctions*/ true, /*includeClassComputedPropertyName*/ false);
|
||||
return isSourceFile(container);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function getNewTargetContainer(node: Node) {
|
||||
const container = getThisContainer(node, /*includeArrowFunctions*/ false);
|
||||
const container = getThisContainer(node, /*includeArrowFunctions*/ false, /*includeClassComputedPropertyName*/ false);
|
||||
if (container) {
|
||||
switch (container.kind) {
|
||||
case SyntaxKind.Constructor:
|
||||
@@ -2480,6 +2508,26 @@ export function getNewTargetContainer(node: Node) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export type SuperContainer =
|
||||
| PropertyDeclaration
|
||||
| PropertySignature
|
||||
| MethodDeclaration
|
||||
| MethodSignature
|
||||
| ConstructorDeclaration
|
||||
| GetAccessorDeclaration
|
||||
| SetAccessorDeclaration
|
||||
| ClassStaticBlockDeclaration
|
||||
;
|
||||
|
||||
/** @internal */
|
||||
export type SuperContainerOrFunctions =
|
||||
| SuperContainer
|
||||
| FunctionDeclaration
|
||||
| FunctionExpression
|
||||
| ArrowFunction
|
||||
;
|
||||
|
||||
/**
|
||||
* Given an super call/property node, returns the closest node where
|
||||
* - a super call/property access is legal in the node and not legal in the parent node the node.
|
||||
@@ -2490,11 +2538,14 @@ export function getNewTargetContainer(node: Node) {
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export function getSuperContainer(node: Node, stopOnFunctions: boolean): Node {
|
||||
export function getSuperContainer(node: Node, stopOnFunctions: false): SuperContainer | undefined;
|
||||
/** @internal */
|
||||
export function getSuperContainer(node: Node, stopOnFunctions: boolean): SuperContainerOrFunctions | undefined;
|
||||
export function getSuperContainer(node: Node, stopOnFunctions: boolean) {
|
||||
while (true) {
|
||||
node = node.parent;
|
||||
if (!node) {
|
||||
return node;
|
||||
return undefined;
|
||||
}
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ComputedPropertyName:
|
||||
@@ -2516,7 +2567,7 @@ export function getSuperContainer(node: Node, stopOnFunctions: boolean): Node {
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
case SyntaxKind.ClassStaticBlockDeclaration:
|
||||
return node;
|
||||
return node as SuperContainerOrFunctions;
|
||||
case SyntaxKind.Decorator:
|
||||
// Decorators are always applied outside of the body of a class or method.
|
||||
if (node.parent.kind === SyntaxKind.Parameter && isClassElement(node.parent.parent)) {
|
||||
@@ -3355,7 +3406,13 @@ export function getInitializerOfBinaryExpression(expr: BinaryExpression) {
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function isPrototypePropertyAssignment(node: Node): node is BinaryExpression {
|
||||
export interface PrototypePropertyAssignment extends AssignmentExpression<EqualsToken> {
|
||||
_prototypePropertyAssignmentBrand: any;
|
||||
readonly left: AccessExpression;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function isPrototypePropertyAssignment(node: Node): node is PrototypePropertyAssignment {
|
||||
return isBinaryExpression(node) && getAssignmentDeclarationKind(node) === AssignmentDeclarationKind.PrototypeProperty;
|
||||
}
|
||||
|
||||
@@ -3556,6 +3613,106 @@ function getNestedModuleDeclaration(node: Node): Node | undefined {
|
||||
: undefined;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function canHaveFlowNode(node: Node): node is HasFlowNode {
|
||||
if (node.kind >= SyntaxKind.FirstStatement && node.kind <= SyntaxKind.LastStatement) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.Identifier:
|
||||
case SyntaxKind.ThisKeyword:
|
||||
case SyntaxKind.SuperKeyword:
|
||||
case SyntaxKind.QualifiedName:
|
||||
case SyntaxKind.MetaProperty:
|
||||
case SyntaxKind.ElementAccessExpression:
|
||||
case SyntaxKind.PropertyAccessExpression:
|
||||
case SyntaxKind.BindingElement:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function canHaveJSDoc(node: Node): node is HasJSDoc {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ArrowFunction:
|
||||
case SyntaxKind.BinaryExpression:
|
||||
case SyntaxKind.Block:
|
||||
case SyntaxKind.BreakStatement:
|
||||
case SyntaxKind.CallSignature:
|
||||
case SyntaxKind.CaseClause:
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.ClassExpression:
|
||||
case SyntaxKind.ClassStaticBlockDeclaration:
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.ConstructorType:
|
||||
case SyntaxKind.ConstructSignature:
|
||||
case SyntaxKind.ContinueStatement:
|
||||
case SyntaxKind.DebuggerStatement:
|
||||
case SyntaxKind.DoStatement:
|
||||
case SyntaxKind.ElementAccessExpression:
|
||||
case SyntaxKind.EmptyStatement:
|
||||
case SyntaxKind.EndOfFileToken:
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
case SyntaxKind.EnumMember:
|
||||
case SyntaxKind.ExportAssignment:
|
||||
case SyntaxKind.ExportDeclaration:
|
||||
case SyntaxKind.ExportSpecifier:
|
||||
case SyntaxKind.ExpressionStatement:
|
||||
case SyntaxKind.ForInStatement:
|
||||
case SyntaxKind.ForOfStatement:
|
||||
case SyntaxKind.ForStatement:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.FunctionType:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.Identifier:
|
||||
case SyntaxKind.IfStatement:
|
||||
case SyntaxKind.ImportDeclaration:
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
case SyntaxKind.IndexSignature:
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
case SyntaxKind.JSDocFunctionType:
|
||||
case SyntaxKind.JSDocSignature:
|
||||
case SyntaxKind.LabeledStatement:
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
case SyntaxKind.NamedTupleMember:
|
||||
case SyntaxKind.NamespaceExportDeclaration:
|
||||
case SyntaxKind.ObjectLiteralExpression:
|
||||
case SyntaxKind.Parameter:
|
||||
case SyntaxKind.ParenthesizedExpression:
|
||||
case SyntaxKind.PropertyAccessExpression:
|
||||
case SyntaxKind.PropertyAssignment:
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
case SyntaxKind.PropertySignature:
|
||||
case SyntaxKind.ReturnStatement:
|
||||
case SyntaxKind.SetAccessor:
|
||||
case SyntaxKind.ShorthandPropertyAssignment:
|
||||
case SyntaxKind.SpreadAssignment:
|
||||
case SyntaxKind.SwitchStatement:
|
||||
case SyntaxKind.ThrowStatement:
|
||||
case SyntaxKind.TryStatement:
|
||||
case SyntaxKind.TypeAliasDeclaration:
|
||||
case SyntaxKind.TypeParameter:
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
case SyntaxKind.VariableStatement:
|
||||
case SyntaxKind.WhileStatement:
|
||||
case SyntaxKind.WithStatement:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function getJSDocCommentsAndTags(hostNode: Node, noCache?: boolean): readonly (JSDoc | JSDocTag)[] {
|
||||
let result: (JSDoc | JSDocTag)[] | undefined;
|
||||
@@ -3944,7 +4101,7 @@ export function getDeclarationFromName(name: Node): Declaration | undefined {
|
||||
const binExp = parent.parent;
|
||||
return isBinaryExpression(binExp) &&
|
||||
getAssignmentDeclarationKind(binExp) !== AssignmentDeclarationKind.None &&
|
||||
(binExp.left.symbol || binExp.symbol) &&
|
||||
((binExp.left as BindableStaticNameExpression).symbol || binExp.symbol) &&
|
||||
getNameOfDeclaration(binExp) === name
|
||||
? binExp
|
||||
: undefined;
|
||||
@@ -5164,10 +5321,6 @@ export function createTextWriter(newLine: string): EmitTextWriter {
|
||||
hasTrailingComment: () => hasTrailingComment,
|
||||
hasTrailingWhitespace: () => !!output.length && isWhiteSpaceLike(output.charCodeAt(output.length - 1)),
|
||||
clear: reset,
|
||||
reportInaccessibleThisError: noop,
|
||||
reportPrivateInBaseOfClassExpression: noop,
|
||||
reportInaccessibleUniqueSymbolError: noop,
|
||||
trackSymbol: () => false,
|
||||
writeKeyword: write,
|
||||
writeOperator: write,
|
||||
writeParameter: write,
|
||||
@@ -7138,6 +7291,7 @@ function Node(this: Mutable<Node>, kind: SyntaxKind, pos: number, end: number) {
|
||||
this.transformFlags = TransformFlags.None;
|
||||
this.parent = undefined!;
|
||||
this.original = undefined;
|
||||
this.emitNode = undefined;
|
||||
}
|
||||
|
||||
function Token(this: Mutable<Node>, kind: SyntaxKind, pos: number, end: number) {
|
||||
@@ -7148,6 +7302,7 @@ function Token(this: Mutable<Node>, kind: SyntaxKind, pos: number, end: number)
|
||||
this.flags = NodeFlags.None;
|
||||
this.transformFlags = TransformFlags.None;
|
||||
this.parent = undefined!;
|
||||
this.emitNode = undefined;
|
||||
}
|
||||
|
||||
function Identifier(this: Mutable<Node>, kind: SyntaxKind, pos: number, end: number) {
|
||||
@@ -7159,7 +7314,8 @@ function Identifier(this: Mutable<Node>, kind: SyntaxKind, pos: number, end: num
|
||||
this.transformFlags = TransformFlags.None;
|
||||
this.parent = undefined!;
|
||||
this.original = undefined;
|
||||
this.flowNode = undefined;
|
||||
this.emitNode = undefined;
|
||||
(this as Identifier).flowNode = undefined;
|
||||
}
|
||||
|
||||
function SourceMapSource(this: SourceMapSource, fileName: string, text: string, skipTrivia?: (pos: number) => number) {
|
||||
|
||||
@@ -24,6 +24,7 @@ import {
|
||||
CallExpression,
|
||||
CallLikeExpression,
|
||||
canHaveIllegalTypeParameters,
|
||||
canHaveJSDoc,
|
||||
CaseOrDefaultClause,
|
||||
CharacterCodes,
|
||||
ClassElement,
|
||||
@@ -82,6 +83,7 @@ import {
|
||||
HasExpressionInitializer,
|
||||
HasInitializer,
|
||||
HasJSDoc,
|
||||
HasLocals,
|
||||
HasModifiers,
|
||||
hasProperty,
|
||||
hasSyntacticModifier,
|
||||
@@ -1142,14 +1144,15 @@ export function getJSDocReturnType(node: Node): TypeNode | undefined {
|
||||
}
|
||||
|
||||
function getJSDocTagsWorker(node: Node, noCache?: boolean): readonly JSDocTag[] {
|
||||
let tags = (node as JSDocContainer).jsDocCache;
|
||||
if (!canHaveJSDoc(node)) return emptyArray;
|
||||
let tags = node.jsDocCache;
|
||||
// If cache is 'null', that means we did the work of searching for JSDoc tags and came up with nothing.
|
||||
if (tags === undefined || noCache) {
|
||||
const comments = getJSDocCommentsAndTags(node, noCache);
|
||||
Debug.assert(comments.length < 2 || comments[0] !== comments[1]);
|
||||
tags = flatMap(comments, j => isJSDoc(j) ? j.tags : j);
|
||||
if (!noCache) {
|
||||
(node as JSDocContainer).jsDocCache = tags;
|
||||
node.jsDocCache = tags;
|
||||
}
|
||||
}
|
||||
return tags;
|
||||
@@ -2058,6 +2061,120 @@ export function isModuleOrEnumDeclaration(node: Node): node is ModuleDeclaration
|
||||
return node.kind === SyntaxKind.ModuleDeclaration || node.kind === SyntaxKind.EnumDeclaration;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function canHaveSymbol(node: Node): node is Declaration {
|
||||
// NOTE: This should cover all possible declarations except MissingDeclaration and SemicolonClassElement
|
||||
// since they aren't actually declarations and can't have a symbol.
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ArrowFunction:
|
||||
case SyntaxKind.BinaryExpression:
|
||||
case SyntaxKind.BindingElement:
|
||||
case SyntaxKind.CallExpression:
|
||||
case SyntaxKind.CallSignature:
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.ClassExpression:
|
||||
case SyntaxKind.ClassStaticBlockDeclaration:
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.ConstructorType:
|
||||
case SyntaxKind.ConstructSignature:
|
||||
case SyntaxKind.ElementAccessExpression:
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
case SyntaxKind.EnumMember:
|
||||
case SyntaxKind.ExportAssignment:
|
||||
case SyntaxKind.ExportDeclaration:
|
||||
case SyntaxKind.ExportSpecifier:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.FunctionType:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.Identifier:
|
||||
case SyntaxKind.ImportClause:
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
case SyntaxKind.ImportSpecifier:
|
||||
case SyntaxKind.IndexSignature:
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
case SyntaxKind.JSDocCallbackTag:
|
||||
case SyntaxKind.JSDocEnumTag:
|
||||
case SyntaxKind.JSDocFunctionType:
|
||||
case SyntaxKind.JSDocParameterTag:
|
||||
case SyntaxKind.JSDocPropertyTag:
|
||||
case SyntaxKind.JSDocSignature:
|
||||
case SyntaxKind.JSDocTypedefTag:
|
||||
case SyntaxKind.JSDocTypeLiteral:
|
||||
case SyntaxKind.JsxAttribute:
|
||||
case SyntaxKind.JsxAttributes:
|
||||
case SyntaxKind.JsxSpreadAttribute:
|
||||
case SyntaxKind.MappedType:
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
case SyntaxKind.NamedTupleMember:
|
||||
case SyntaxKind.NamespaceExport:
|
||||
case SyntaxKind.NamespaceExportDeclaration:
|
||||
case SyntaxKind.NamespaceImport:
|
||||
case SyntaxKind.NewExpression:
|
||||
case SyntaxKind.NoSubstitutionTemplateLiteral:
|
||||
case SyntaxKind.NumericLiteral:
|
||||
case SyntaxKind.ObjectLiteralExpression:
|
||||
case SyntaxKind.Parameter:
|
||||
case SyntaxKind.PropertyAccessExpression:
|
||||
case SyntaxKind.PropertyAssignment:
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
case SyntaxKind.PropertySignature:
|
||||
case SyntaxKind.SetAccessor:
|
||||
case SyntaxKind.ShorthandPropertyAssignment:
|
||||
case SyntaxKind.SourceFile:
|
||||
case SyntaxKind.SpreadAssignment:
|
||||
case SyntaxKind.StringLiteral:
|
||||
case SyntaxKind.TypeAliasDeclaration:
|
||||
case SyntaxKind.TypeLiteral:
|
||||
case SyntaxKind.TypeParameter:
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function canHaveLocals(node: Node): node is HasLocals {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ArrowFunction:
|
||||
case SyntaxKind.Block:
|
||||
case SyntaxKind.CallSignature:
|
||||
case SyntaxKind.CaseBlock:
|
||||
case SyntaxKind.CatchClause:
|
||||
case SyntaxKind.ClassStaticBlockDeclaration:
|
||||
case SyntaxKind.ConditionalType:
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.ConstructorType:
|
||||
case SyntaxKind.ConstructSignature:
|
||||
case SyntaxKind.ForStatement:
|
||||
case SyntaxKind.ForInStatement:
|
||||
case SyntaxKind.ForOfStatement:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.FunctionType:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.IndexSignature:
|
||||
case SyntaxKind.JSDocCallbackTag:
|
||||
case SyntaxKind.JSDocEnumTag:
|
||||
case SyntaxKind.JSDocFunctionType:
|
||||
case SyntaxKind.JSDocSignature:
|
||||
case SyntaxKind.JSDocTypedefTag:
|
||||
case SyntaxKind.MappedType:
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
case SyntaxKind.SetAccessor:
|
||||
case SyntaxKind.SourceFile:
|
||||
case SyntaxKind.TypeAliasDeclaration:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function isDeclarationKind(kind: SyntaxKind) {
|
||||
return kind === SyntaxKind.ArrowFunction
|
||||
|| kind === SyntaxKind.BindingElement
|
||||
@@ -2289,6 +2406,8 @@ export function isGetAccessor(node: Node): node is GetAccessorDeclaration {
|
||||
*/
|
||||
// TODO: GH#19856 Would like to return `node is Node & { jsDoc: JSDoc[] }` but it causes long compile times
|
||||
export function hasJSDocNodes(node: Node): node is HasJSDoc {
|
||||
if (!canHaveJSDoc(node)) return false;
|
||||
|
||||
const { jsDoc } = node as JSDocContainer;
|
||||
return !!jsDoc && jsDoc.length > 0;
|
||||
}
|
||||
|
||||
@@ -126,6 +126,7 @@ export function assertInvariants(node: ts.Node | undefined, parent: ts.Node | un
|
||||
childName === "nextContainer" ||
|
||||
childName === "modifiers" ||
|
||||
childName === "externalModuleIndicator" ||
|
||||
childName === "original" ||
|
||||
// for now ignore jsdoc comments
|
||||
childName === "jsDocComment" ||
|
||||
childName === "checkJsDirective" ||
|
||||
@@ -200,9 +201,16 @@ export function sourceFileToJSON(file: ts.Node): string {
|
||||
case "symbolCount":
|
||||
case "identifierCount":
|
||||
case "scriptSnapshot":
|
||||
case "autoGenerateFlags":
|
||||
// Blocklist of items we never put in the baseline file.
|
||||
break;
|
||||
|
||||
case "hasExtendedUnicodeEscape":
|
||||
if ((n as any).hasExtendedUnicodeEscape) {
|
||||
o.hasExtendedUnicodeEscape = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case "originalKeywordKind":
|
||||
o[propertyName] = getKindName((n as any)[propertyName]);
|
||||
break;
|
||||
@@ -222,8 +230,8 @@ export function sourceFileToJSON(file: ts.Node): string {
|
||||
break;
|
||||
|
||||
case "nextContainer":
|
||||
if (n.nextContainer) {
|
||||
o[propertyName] = { kind: n.nextContainer.kind, pos: n.nextContainer.pos, end: n.nextContainer.end };
|
||||
if ((n as ts.HasLocals).nextContainer) {
|
||||
o[propertyName] = { kind: (n as ts.HasLocals).nextContainer!.kind, pos: (n as ts.HasLocals).nextContainer!.pos, end: (n as ts.HasLocals).nextContainer!.end };
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
Block,
|
||||
CallExpression,
|
||||
canBeConvertedToAsync,
|
||||
canHaveSymbol,
|
||||
CodeFixContext,
|
||||
concatenate,
|
||||
createMultiMap,
|
||||
@@ -867,7 +868,7 @@ function getArgBindingName(funcNode: Expression, transformer: Transformer): Synt
|
||||
}
|
||||
|
||||
function getSymbol(node: Node): Symbol | undefined {
|
||||
return node.symbol ? node.symbol : transformer.checker.getSymbolAtLocation(node);
|
||||
return tryCast(node, canHaveSymbol)?.symbol ?? transformer.checker.getSymbolAtLocation(node);
|
||||
}
|
||||
|
||||
function getOriginalNode(node: Node): Node {
|
||||
|
||||
@@ -46,10 +46,10 @@ function doChange(changes: textChanges.ChangeTracker, sourceFile: SourceFile, po
|
||||
const token = getTokenAtPosition(sourceFile, pos);
|
||||
if (!isThis(token)) return undefined;
|
||||
|
||||
const fn = getThisContainer(token, /*includeArrowFunctions*/ false);
|
||||
const fn = getThisContainer(token, /*includeArrowFunctions*/ false, /*includeClassComputedPropertyName*/ false);
|
||||
if (!isFunctionDeclaration(fn) && !isFunctionExpression(fn)) return undefined;
|
||||
|
||||
if (!isSourceFile(getThisContainer(fn, /*includeArrowFunctions*/ false))) { // 'this' is defined outside, convert to arrow function
|
||||
if (!isSourceFile(getThisContainer(fn, /*includeArrowFunctions*/ false, /*includeClassComputedPropertyName*/ false))) { // 'this' is defined outside, convert to arrow function
|
||||
const fnKeyword = Debug.checkDefined(findChildOfKind(fn, SyntaxKind.FunctionKeyword, sourceFile));
|
||||
const { name } = fn;
|
||||
const body = Debug.checkDefined(fn.body); // Should be defined because the function contained a 'this' expression
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
canHaveExportModifier,
|
||||
canHaveLocals,
|
||||
Declaration,
|
||||
Diagnostics,
|
||||
ExportDeclaration,
|
||||
@@ -125,7 +126,7 @@ function getInfo(sourceFile: SourceFile, pos: number, program: Program): Info |
|
||||
if (moduleSourceFile === undefined || isSourceFileFromLibrary(program, moduleSourceFile)) return undefined;
|
||||
|
||||
const moduleSymbol = moduleSourceFile.symbol;
|
||||
const locals = moduleSymbol.valueDeclaration?.locals;
|
||||
const locals = tryCast(moduleSymbol.valueDeclaration, canHaveLocals)?.locals;
|
||||
if (locals === undefined) return undefined;
|
||||
|
||||
const localSymbol = locals.get(token.escapedText);
|
||||
|
||||
@@ -294,6 +294,7 @@ import {
|
||||
PropertyAccessExpression,
|
||||
PropertyDeclaration,
|
||||
PropertyName,
|
||||
PropertySignature,
|
||||
PseudoBigInt,
|
||||
pseudoBigIntToString,
|
||||
QualifiedName,
|
||||
@@ -334,6 +335,7 @@ import {
|
||||
textPart,
|
||||
TextRange,
|
||||
TextSpan,
|
||||
ThisContainer,
|
||||
timestamp,
|
||||
Token,
|
||||
TokenSyntaxKind,
|
||||
@@ -3308,7 +3310,7 @@ function getCompletionData(
|
||||
|
||||
// Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions`
|
||||
if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== SyntaxKind.SourceFile) {
|
||||
const thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false, isClassLike(scopeNode.parent) ? scopeNode : undefined);
|
||||
const thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false, isClassLike(scopeNode.parent) ? scopeNode as ThisContainer : undefined);
|
||||
if (thisType && !isProbablyGlobalType(thisType, sourceFile, typeChecker)) {
|
||||
for (const symbol of getPropertiesForCompletion(thisType, typeChecker)) {
|
||||
symbolToOriginInfoMap[symbols.length] = { kind: SymbolOriginInfoKind.ThisType };
|
||||
@@ -4877,7 +4879,7 @@ function getConstraintOfTypeArgumentProperty(node: Node, checker: TypeChecker):
|
||||
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.PropertySignature:
|
||||
return checker.getTypeOfPropertyOfContextualType(t, node.symbol.escapedName);
|
||||
return checker.getTypeOfPropertyOfContextualType(t, (node as PropertySignature).symbol.escapedName);
|
||||
case SyntaxKind.IntersectionType:
|
||||
case SyntaxKind.TypeLiteral:
|
||||
case SyntaxKind.UnionType:
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
Block,
|
||||
BreakOrContinueStatement,
|
||||
CancellationToken,
|
||||
canHaveSymbol,
|
||||
CaseClause,
|
||||
cast,
|
||||
concatenate,
|
||||
@@ -78,6 +79,7 @@ import {
|
||||
ThrowStatement,
|
||||
toArray,
|
||||
toPath,
|
||||
tryCast,
|
||||
TryStatement,
|
||||
} from "./_namespaces/ts";
|
||||
|
||||
@@ -184,7 +186,7 @@ export namespace DocumentHighlights {
|
||||
}
|
||||
|
||||
function getFromAllDeclarations<T extends Node>(nodeTest: (node: Node) => node is T, keywords: readonly SyntaxKind[]): HighlightSpan[] | undefined {
|
||||
return useParent(node.parent, nodeTest, decl => mapDefined(decl.symbol.declarations, d =>
|
||||
return useParent(node.parent, nodeTest, decl => mapDefined(tryCast(decl, canHaveSymbol)?.symbol.declarations, d =>
|
||||
nodeTest(d) ? find(d.getChildren(sourceFile), c => contains(keywords, c.kind)) : undefined));
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
Block,
|
||||
CallExpression,
|
||||
CancellationToken,
|
||||
canHaveSymbol,
|
||||
cast,
|
||||
CheckFlags,
|
||||
ClassLikeDeclaration,
|
||||
@@ -190,6 +191,7 @@ import {
|
||||
NodeFlags,
|
||||
nodeSeenTracker,
|
||||
NumericLiteral,
|
||||
ObjectLiteralExpression,
|
||||
ParameterDeclaration,
|
||||
ParenthesizedExpression,
|
||||
Path,
|
||||
@@ -218,6 +220,7 @@ import {
|
||||
StringLiteral,
|
||||
StringLiteralLike,
|
||||
stripQuotes,
|
||||
SuperContainer,
|
||||
Symbol,
|
||||
SymbolDisplay,
|
||||
SymbolDisplayPart,
|
||||
@@ -234,6 +237,7 @@ import {
|
||||
tryGetClassExtendingExpressionWithTypeArguments,
|
||||
tryGetImportFromModuleSpecifier,
|
||||
TypeChecker,
|
||||
TypeLiteralNode,
|
||||
VariableDeclaration,
|
||||
} from "./_namespaces/ts";
|
||||
import {
|
||||
@@ -1882,7 +1886,7 @@ export namespace Core {
|
||||
|
||||
// Use the parent symbol if the location is commonjs require syntax on javascript files only.
|
||||
if (isInJSFile(referenceLocation)
|
||||
&& referenceLocation.parent.kind === SyntaxKind.BindingElement
|
||||
&& isBindingElement(referenceLocation.parent)
|
||||
&& 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
|
||||
@@ -2253,7 +2257,7 @@ export namespace Core {
|
||||
}
|
||||
|
||||
function getReferencesForSuperKeyword(superKeyword: Node): SymbolAndEntries[] | undefined {
|
||||
let searchSpaceNode = getSuperContainer(superKeyword, /*stopOnFunctions*/ false);
|
||||
let searchSpaceNode: SuperContainer | ClassLikeDeclaration | TypeLiteralNode | InterfaceDeclaration | ObjectLiteralExpression | undefined = getSuperContainer(superKeyword, /*stopOnFunctions*/ false);
|
||||
if (!searchSpaceNode) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -2286,7 +2290,7 @@ export namespace Core {
|
||||
// If we have a 'super' container, we must have an enclosing class.
|
||||
// Now make sure the owning class is the same as the search-space
|
||||
// and has the same static qualifier as the original 'super's owner.
|
||||
return container && isStatic(container) === !!staticFlag && container.parent.symbol === searchSpaceNode.symbol ? nodeEntry(node) : undefined;
|
||||
return container && isStatic(container) === !!staticFlag && container.parent.symbol === searchSpaceNode!.symbol ? nodeEntry(node) : undefined;
|
||||
});
|
||||
|
||||
return [{ definition: { type: DefinitionKind.Symbol, symbol: searchSpaceNode.symbol }, references }];
|
||||
@@ -2297,7 +2301,7 @@ export namespace Core {
|
||||
}
|
||||
|
||||
function getReferencesForThisKeyword(thisOrSuperKeyword: Node, sourceFiles: readonly SourceFile[], cancellationToken: CancellationToken): SymbolAndEntries[] | undefined {
|
||||
let searchSpaceNode = getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false);
|
||||
let searchSpaceNode: Node = getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false, /*includeClassComputedPropertyName*/ false);
|
||||
|
||||
// Whether 'this' occurs in a static context within a class.
|
||||
let staticFlag = ModifierFlags.Static;
|
||||
@@ -2339,11 +2343,12 @@ export namespace Core {
|
||||
if (!isThis(node)) {
|
||||
return false;
|
||||
}
|
||||
const container = getThisContainer(node, /* includeArrowFunctions */ false);
|
||||
const container = getThisContainer(node, /* includeArrowFunctions */ false, /*includeClassComputedPropertyName*/ false);
|
||||
if (!canHaveSymbol(container)) return false;
|
||||
switch (searchSpaceNode.kind) {
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
return searchSpaceNode.symbol === container.symbol;
|
||||
return (searchSpaceNode as FunctionExpression | FunctionDeclaration).symbol === container.symbol;
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
return isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol;
|
||||
@@ -2352,9 +2357,9 @@ export namespace Core {
|
||||
case 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 && isStatic(container) === !!staticFlag;
|
||||
return container.parent && canHaveSymbol(container.parent) && (searchSpaceNode as ClassLikeDeclaration | ObjectLiteralExpression).symbol === container.parent.symbol && isStatic(container) === !!staticFlag;
|
||||
case SyntaxKind.SourceFile:
|
||||
return container.kind === SyntaxKind.SourceFile && !isExternalModule(container as SourceFile) && !isParameterName(node);
|
||||
return container.kind === SyntaxKind.SourceFile && !isExternalModule(container) && !isParameterName(node);
|
||||
}
|
||||
});
|
||||
}).map(n => nodeEntry(n));
|
||||
|
||||
@@ -3,7 +3,7 @@ import {
|
||||
AssignmentExpression,
|
||||
AssignmentOperatorToken,
|
||||
CallLikeExpression,
|
||||
concatenate,
|
||||
canHaveSymbol, concatenate,
|
||||
createTextSpan,
|
||||
createTextSpanFromBounds,
|
||||
createTextSpanFromNode,
|
||||
@@ -245,7 +245,7 @@ function symbolMatchesSignature(s: Symbol, calledDeclaration: SignatureDeclarati
|
||||
return s === calledDeclaration.symbol
|
||||
|| s === calledDeclaration.symbol.parent
|
||||
|| isAssignmentExpression(calledDeclaration.parent)
|
||||
|| (!isCallLikeExpression(calledDeclaration.parent) && s === calledDeclaration.parent.symbol);
|
||||
|| (!isCallLikeExpression(calledDeclaration.parent) && s === tryCast(calledDeclaration.parent, canHaveSymbol)?.symbol);
|
||||
}
|
||||
|
||||
// If the current location we want to find its definition is in an object literal, try to get the contextual type for the
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
CallExpression,
|
||||
CancellationToken,
|
||||
canHaveModifiers,
|
||||
canHaveSymbol,
|
||||
cast,
|
||||
Debug,
|
||||
ExportAssignment,
|
||||
@@ -73,6 +74,7 @@ import {
|
||||
SymbolFlags,
|
||||
symbolName,
|
||||
SyntaxKind,
|
||||
tryCast,
|
||||
TypeChecker,
|
||||
ValidImportTypeNode,
|
||||
VariableDeclaration,
|
||||
@@ -683,10 +685,10 @@ function getExportEqualsLocalSymbol(importedSymbol: Symbol, checker: TypeChecker
|
||||
|
||||
const decl = Debug.checkDefined(importedSymbol.valueDeclaration);
|
||||
if (isExportAssignment(decl)) { // `export = class {}`
|
||||
return decl.expression.symbol;
|
||||
return tryCast(decl.expression, canHaveSymbol)?.symbol;
|
||||
}
|
||||
else if (isBinaryExpression(decl)) { // `module.exports = class {}`
|
||||
return decl.right.symbol;
|
||||
return tryCast(decl.right, canHaveSymbol)?.symbol;
|
||||
}
|
||||
else if (isSourceFile(decl)) { // json module
|
||||
return decl.symbol;
|
||||
|
||||
@@ -387,7 +387,7 @@ export function provideInlayHints(context: InlayHintsContext): InlayHint[] {
|
||||
const printer = createPrinter(options);
|
||||
|
||||
return usingSingleLineStringWriter(writer => {
|
||||
const typeNode = checker.typeToTypeNode(type, /*enclosingDeclaration*/ undefined, flags, writer);
|
||||
const typeNode = checker.typeToTypeNode(type, /*enclosingDeclaration*/ undefined, flags);
|
||||
Debug.assertIsDefined(typeNode, "should always get typenode");
|
||||
printer.writeNode(EmitHint.Unspecified, typeNode, /*sourceFile*/ file, writer);
|
||||
});
|
||||
|
||||
@@ -33,6 +33,7 @@ import {
|
||||
isStringLiteral,
|
||||
makeImport,
|
||||
ModifierFlags,
|
||||
ModuleBlock,
|
||||
NamespaceDeclaration,
|
||||
Node,
|
||||
NodeFlags,
|
||||
@@ -122,7 +123,7 @@ function getInfo(context: RefactorContext, considerPartialSpans = true): ExportI
|
||||
}
|
||||
|
||||
const checker = program.getTypeChecker();
|
||||
const exportingModuleSymbol = getExportingModuleSymbol(exportNode, checker);
|
||||
const exportingModuleSymbol = getExportingModuleSymbol(exportNode.parent, checker);
|
||||
const flags = getSyntacticModifierFlags(exportNode) || ((isExportAssignment(exportNode) && !exportNode.isExportEquals) ? ModifierFlags.ExportDefault : ModifierFlags.None);
|
||||
|
||||
const wasDefault = !!(flags & ModifierFlags.Default);
|
||||
@@ -319,8 +320,7 @@ function makeExportSpecifier(propertyName: string, name: string): ExportSpecifie
|
||||
return factory.createExportSpecifier(/*isTypeOnly*/ false, propertyName === name ? undefined : factory.createIdentifier(propertyName), factory.createIdentifier(name));
|
||||
}
|
||||
|
||||
function getExportingModuleSymbol(node: Node, checker: TypeChecker) {
|
||||
const parent = node.parent;
|
||||
function getExportingModuleSymbol(parent: SourceFile | ModuleBlock, checker: TypeChecker) {
|
||||
if (isSourceFile(parent)) {
|
||||
return parent.symbol;
|
||||
}
|
||||
|
||||
@@ -633,7 +633,7 @@ export function getRangeToExtract(sourceFile: SourceFile, span: TextSpan, invoke
|
||||
visit(nodeToCheck);
|
||||
|
||||
if (rangeFacts & RangeFacts.UsesThis) {
|
||||
const container = getThisContainer(nodeToCheck, /** includeArrowFunctions */ false);
|
||||
const container = getThisContainer(nodeToCheck, /** includeArrowFunctions */ false, /*includeClassComputedPropertyName*/ false);
|
||||
if (
|
||||
container.kind === SyntaxKind.FunctionDeclaration ||
|
||||
(container.kind === SyntaxKind.MethodDeclaration && container.parent.kind === SyntaxKind.ObjectLiteralExpression) ||
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
CallExpression,
|
||||
canHaveDecorators,
|
||||
canHaveModifiers,
|
||||
cast,
|
||||
canHaveSymbol, cast,
|
||||
ClassDeclaration,
|
||||
codefix,
|
||||
combinePaths,
|
||||
@@ -505,7 +505,7 @@ function addExports(sourceFile: SourceFile, toMove: readonly Statement[], needEx
|
||||
return flatMap(toMove, statement => {
|
||||
if (isTopLevelDeclarationStatement(statement) &&
|
||||
!isExported(sourceFile, statement, useEs6Exports) &&
|
||||
forEachTopLevelDeclaration(statement, d => needExport.has(Debug.checkDefined(d.symbol)))) {
|
||||
forEachTopLevelDeclaration(statement, d => needExport.has(Debug.checkDefined(tryCast(d, canHaveSymbol)?.symbol)))) {
|
||||
const exports = addExport(statement, useEs6Exports);
|
||||
if (exports) return exports;
|
||||
}
|
||||
|
||||
+18
-15
@@ -594,7 +594,7 @@ class TokenOrIdentifierObject implements Node {
|
||||
}
|
||||
|
||||
public getChildren(): Node[] {
|
||||
return this.kind === SyntaxKind.EndOfFileToken ? (this as EndOfFileToken).jsDoc || emptyArray : emptyArray;
|
||||
return this.kind === SyntaxKind.EndOfFileToken ? (this as Node as EndOfFileToken).jsDoc || emptyArray : emptyArray;
|
||||
}
|
||||
|
||||
public getFirstToken(): Node | undefined {
|
||||
@@ -733,13 +733,15 @@ class IdentifierObject extends TokenOrIdentifierObject implements Identifier {
|
||||
public kind: SyntaxKind.Identifier = SyntaxKind.Identifier;
|
||||
public escapedText!: __String;
|
||||
public autoGenerateFlags!: GeneratedIdentifierFlags;
|
||||
_primaryExpressionBrand: any;
|
||||
_memberExpressionBrand: any;
|
||||
_leftHandSideExpressionBrand: any;
|
||||
_updateExpressionBrand: any;
|
||||
_unaryExpressionBrand: any;
|
||||
_expressionBrand: any;
|
||||
_declarationBrand: any;
|
||||
declare _primaryExpressionBrand: any;
|
||||
declare _memberExpressionBrand: any;
|
||||
declare _leftHandSideExpressionBrand: any;
|
||||
declare _updateExpressionBrand: any;
|
||||
declare _unaryExpressionBrand: any;
|
||||
declare _expressionBrand: any;
|
||||
declare _declarationBrand: any;
|
||||
declare _jsdocContainerBrand: any;
|
||||
declare _flowContainerBrand: any;
|
||||
/** @internal */typeArguments!: NodeArray<TypeNode>;
|
||||
constructor(_kind: SyntaxKind.Identifier, pos: number, end: number) {
|
||||
super(pos, end);
|
||||
@@ -754,12 +756,12 @@ class PrivateIdentifierObject extends TokenOrIdentifierObject implements Private
|
||||
public kind: SyntaxKind.PrivateIdentifier = SyntaxKind.PrivateIdentifier;
|
||||
public escapedText!: __String;
|
||||
// public symbol!: Symbol;
|
||||
_primaryExpressionBrand: any;
|
||||
_memberExpressionBrand: any;
|
||||
_leftHandSideExpressionBrand: any;
|
||||
_updateExpressionBrand: any;
|
||||
_unaryExpressionBrand: any;
|
||||
_expressionBrand: any;
|
||||
declare _primaryExpressionBrand: any;
|
||||
declare _memberExpressionBrand: any;
|
||||
declare _leftHandSideExpressionBrand: any;
|
||||
declare _updateExpressionBrand: any;
|
||||
declare _unaryExpressionBrand: any;
|
||||
declare _expressionBrand: any;
|
||||
constructor(_kind: SyntaxKind.PrivateIdentifier, pos: number, end: number) {
|
||||
super(pos, end);
|
||||
}
|
||||
@@ -992,7 +994,8 @@ function findBaseOfDeclaration<T>(checker: TypeChecker, declaration: Declaration
|
||||
|
||||
class SourceFileObject extends NodeObject implements SourceFile {
|
||||
public kind: SyntaxKind.SourceFile = SyntaxKind.SourceFile;
|
||||
public _declarationBrand: any;
|
||||
declare _declarationBrand: any;
|
||||
declare _localsContainerBrand: any;
|
||||
public fileName!: string;
|
||||
public path!: Path;
|
||||
public resolvedPath!: Path;
|
||||
|
||||
@@ -3,6 +3,7 @@ import {
|
||||
BinaryExpression,
|
||||
CallLikeExpression,
|
||||
CancellationToken,
|
||||
canHaveSymbol,
|
||||
CheckFlags,
|
||||
contains,
|
||||
countWhere,
|
||||
@@ -77,6 +78,7 @@ import {
|
||||
TemplateExpression,
|
||||
TextSpan,
|
||||
TransientSymbol,
|
||||
tryCast,
|
||||
Type,
|
||||
TypeChecker,
|
||||
TypeParameter,
|
||||
@@ -431,7 +433,7 @@ function getContextualSignatureLocationInfo(startingToken: Node, sourceFile: Sou
|
||||
// The type of a function type node has a symbol at that node, but it's better to use the symbol for a parameter or type alias.
|
||||
function chooseBetterSymbol(s: Symbol): Symbol {
|
||||
return s.name === InternalSymbolName.Type
|
||||
? firstDefined(s.declarations, d => isFunctionTypeNode(d) ? d.parent.symbol : undefined) || s
|
||||
? firstDefined(s.declarations, d => isFunctionTypeNode(d) ? tryCast(d.parent, canHaveSymbol)?.symbol : undefined) || s
|
||||
: s;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,8 @@ import {
|
||||
isBlock,
|
||||
isCallExpression,
|
||||
isExportAssignment,
|
||||
isFunctionDeclaration,
|
||||
isFunctionExpression,
|
||||
isFunctionLike,
|
||||
isIdentifier,
|
||||
isPropertyAccessExpression,
|
||||
@@ -276,7 +278,7 @@ function getKeyFromNode(exp: FunctionLikeDeclaration) {
|
||||
}
|
||||
|
||||
function canBeConvertedToClass(node: Node, checker: TypeChecker): boolean {
|
||||
if (node.kind === SyntaxKind.FunctionExpression) {
|
||||
if (isFunctionExpression(node)) {
|
||||
if (isVariableDeclaration(node.parent) && node.symbol.members?.size) {
|
||||
return true;
|
||||
}
|
||||
@@ -285,7 +287,7 @@ function canBeConvertedToClass(node: Node, checker: TypeChecker): boolean {
|
||||
return !!(symbol && (symbol.exports?.size || symbol.members?.size));
|
||||
}
|
||||
|
||||
if (node.kind === SyntaxKind.FunctionDeclaration) {
|
||||
if (isFunctionDeclaration(node)) {
|
||||
return !!node.symbol.members?.size;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,6 @@ import {
|
||||
isFunctionBlock,
|
||||
isFunctionExpression,
|
||||
isFunctionLike,
|
||||
isFunctionLikeKind,
|
||||
isIdentifier,
|
||||
isInExpressionContext,
|
||||
isJsxOpeningLikeElement,
|
||||
@@ -59,6 +58,7 @@ import {
|
||||
isObjectBindingPattern,
|
||||
isTaggedTemplateExpression,
|
||||
isThisInTypeQuery,
|
||||
isTypeAliasDeclaration,
|
||||
isVarConst,
|
||||
JSDocTagInfo,
|
||||
JsxOpeningLikeElement,
|
||||
@@ -493,19 +493,19 @@ export function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker: Typ
|
||||
const declaration = decl.parent;
|
||||
|
||||
if (declaration) {
|
||||
if (isFunctionLikeKind(declaration.kind)) {
|
||||
if (isFunctionLike(declaration)) {
|
||||
addInPrefix();
|
||||
const signature = typeChecker.getSignatureFromDeclaration(declaration as SignatureDeclaration)!; // TODO: GH#18217
|
||||
const signature = typeChecker.getSignatureFromDeclaration(declaration)!; // TODO: GH#18217
|
||||
if (declaration.kind === SyntaxKind.ConstructSignature) {
|
||||
displayParts.push(keywordPart(SyntaxKind.NewKeyword));
|
||||
displayParts.push(spacePart());
|
||||
}
|
||||
else if (declaration.kind !== SyntaxKind.CallSignature && (declaration as SignatureDeclaration).name) {
|
||||
else if (declaration.kind !== SyntaxKind.CallSignature && declaration.name) {
|
||||
addFullSymbolName(declaration.symbol);
|
||||
}
|
||||
addRange(displayParts, signatureToDisplayParts(typeChecker, signature, sourceFile, TypeFormatFlags.WriteTypeArgumentsOfSignature));
|
||||
}
|
||||
else if (declaration.kind === SyntaxKind.TypeAliasDeclaration) {
|
||||
else if (isTypeAliasDeclaration(declaration)) {
|
||||
// Type alias type parameter
|
||||
// For example
|
||||
// type list<T> = T[]; // Both T will go through same code path
|
||||
|
||||
@@ -271,7 +271,6 @@ import {
|
||||
nodeIsMissing,
|
||||
nodeIsPresent,
|
||||
nodeIsSynthesized,
|
||||
noop,
|
||||
normalizePath,
|
||||
NoSubstitutionTemplateLiteral,
|
||||
notImplemented,
|
||||
@@ -2721,10 +2720,6 @@ function getDisplayPartWriter(): DisplayPartsSymbolWriter {
|
||||
increaseIndent: () => { indent++; },
|
||||
decreaseIndent: () => { indent--; },
|
||||
clear: resetWriter,
|
||||
trackSymbol: () => false,
|
||||
reportInaccessibleThisError: noop,
|
||||
reportInaccessibleUniqueSymbolError: noop,
|
||||
reportPrivateInBaseOfClassExpression: noop,
|
||||
};
|
||||
|
||||
function writeIndent() {
|
||||
|
||||
+70
-64
@@ -4512,9 +4512,16 @@ declare namespace ts {
|
||||
*/
|
||||
readonly modifiers?: NodeArray<ModifierLike> | undefined;
|
||||
}
|
||||
interface JSDocContainer {
|
||||
interface JSDocContainer extends Node {
|
||||
_jsdocContainerBrand: any;
|
||||
}
|
||||
type HasJSDoc = ParameterDeclaration | CallSignatureDeclaration | ClassStaticBlockDeclaration | ConstructSignatureDeclaration | MethodSignature | PropertySignature | ArrowFunction | ParenthesizedExpression | SpreadAssignment | ShorthandPropertyAssignment | PropertyAssignment | FunctionExpression | EmptyStatement | DebuggerStatement | Block | VariableStatement | ExpressionStatement | IfStatement | DoStatement | WhileStatement | ForStatement | ForInStatement | ForOfStatement | BreakStatement | ContinueStatement | ReturnStatement | WithStatement | SwitchStatement | LabeledStatement | ThrowStatement | TryStatement | FunctionDeclaration | ConstructorDeclaration | MethodDeclaration | VariableDeclaration | PropertyDeclaration | AccessorDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | EnumMember | EnumDeclaration | ModuleDeclaration | ImportEqualsDeclaration | ImportDeclaration | NamespaceExportDeclaration | ExportAssignment | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | ExportDeclaration | NamedTupleMember | ExportSpecifier | CaseClause | EndOfFileToken;
|
||||
interface LocalsContainer extends Node {
|
||||
_localsContainerBrand: any;
|
||||
}
|
||||
interface FlowContainer extends Node {
|
||||
_flowContainerBrand: any;
|
||||
}
|
||||
type HasJSDoc = AccessorDeclaration | ArrowFunction | BinaryExpression | Block | BreakStatement | CallSignatureDeclaration | CaseClause | ClassLikeDeclaration | ClassStaticBlockDeclaration | ConstructorDeclaration | ConstructorTypeNode | ConstructSignatureDeclaration | ContinueStatement | DebuggerStatement | DoStatement | ElementAccessExpression | EmptyStatement | EndOfFileToken | EnumDeclaration | EnumMember | ExportAssignment | ExportDeclaration | ExportSpecifier | ExpressionStatement | ForInStatement | ForOfStatement | ForStatement | FunctionDeclaration | FunctionExpression | FunctionTypeNode | Identifier | IfStatement | ImportDeclaration | ImportEqualsDeclaration | IndexSignatureDeclaration | InterfaceDeclaration | JSDocFunctionType | JSDocSignature | LabeledStatement | MethodDeclaration | MethodSignature | ModuleDeclaration | NamedTupleMember | NamespaceExportDeclaration | ObjectLiteralExpression | ParameterDeclaration | ParenthesizedExpression | PropertyAccessExpression | PropertyAssignment | PropertyDeclaration | PropertySignature | ReturnStatement | ShorthandPropertyAssignment | SpreadAssignment | SwitchStatement | ThrowStatement | TryStatement | TypeAliasDeclaration | TypeParameterDeclaration | VariableDeclaration | VariableStatement | WhileStatement | WithStatement;
|
||||
type HasType = SignatureDeclaration | VariableDeclaration | ParameterDeclaration | PropertySignature | PropertyDeclaration | TypePredicateNode | ParenthesizedTypeNode | TypeOperatorNode | MappedTypeNode | AssertionExpression | TypeAliasDeclaration | JSDocTypeExpression | JSDocNonNullableType | JSDocNullableType | JSDocOptionalType | JSDocVariadicType;
|
||||
type HasTypeArguments = CallExpression | NewExpression | TaggedTemplateExpression | JsxOpeningElement | JsxSelfClosingElement;
|
||||
type HasInitializer = HasExpressionInitializer | ForStatement | ForInStatement | ForOfStatement | JsxAttribute;
|
||||
@@ -4582,7 +4589,7 @@ declare namespace ts {
|
||||
FileLevel = 32,
|
||||
AllowNameSubstitution = 64
|
||||
}
|
||||
interface Identifier extends PrimaryExpression, Declaration {
|
||||
interface Identifier extends PrimaryExpression, Declaration, JSDocContainer, FlowContainer {
|
||||
readonly kind: SyntaxKind.Identifier;
|
||||
/**
|
||||
* Prefer to use `id.unescapedText`. (Note: This is available only in services, not internally to the TypeScript compiler.)
|
||||
@@ -4598,7 +4605,7 @@ declare namespace ts {
|
||||
interface TransientIdentifier extends Identifier {
|
||||
resolvedSymbol: Symbol;
|
||||
}
|
||||
interface QualifiedName extends Node {
|
||||
interface QualifiedName extends Node, FlowContainer {
|
||||
readonly kind: SyntaxKind.QualifiedName;
|
||||
readonly left: EntityName;
|
||||
readonly right: Identifier;
|
||||
@@ -4633,7 +4640,7 @@ declare namespace ts {
|
||||
readonly parent: NamedDeclaration;
|
||||
readonly expression: LeftHandSideExpression;
|
||||
}
|
||||
interface TypeParameterDeclaration extends NamedDeclaration {
|
||||
interface TypeParameterDeclaration extends NamedDeclaration, JSDocContainer {
|
||||
readonly kind: SyntaxKind.TypeParameter;
|
||||
readonly parent: DeclarationWithTypeParameterChildren | InferTypeNode;
|
||||
readonly modifiers?: NodeArray<Modifier>;
|
||||
@@ -4651,10 +4658,10 @@ declare namespace ts {
|
||||
readonly type?: TypeNode | undefined;
|
||||
}
|
||||
type SignatureDeclaration = CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | AccessorDeclaration | FunctionExpression | ArrowFunction;
|
||||
interface CallSignatureDeclaration extends SignatureDeclarationBase, TypeElement {
|
||||
interface CallSignatureDeclaration extends SignatureDeclarationBase, TypeElement, LocalsContainer {
|
||||
readonly kind: SyntaxKind.CallSignature;
|
||||
}
|
||||
interface ConstructSignatureDeclaration extends SignatureDeclarationBase, TypeElement {
|
||||
interface ConstructSignatureDeclaration extends SignatureDeclarationBase, TypeElement, LocalsContainer {
|
||||
readonly kind: SyntaxKind.ConstructSignature;
|
||||
}
|
||||
type BindingName = Identifier | BindingPattern;
|
||||
@@ -4681,7 +4688,7 @@ declare namespace ts {
|
||||
readonly type?: TypeNode;
|
||||
readonly initializer?: Expression;
|
||||
}
|
||||
interface BindingElement extends NamedDeclaration {
|
||||
interface BindingElement extends NamedDeclaration, FlowContainer {
|
||||
readonly kind: SyntaxKind.BindingElement;
|
||||
readonly parent: BindingPattern;
|
||||
readonly propertyName?: PropertyName;
|
||||
@@ -4691,6 +4698,7 @@ declare namespace ts {
|
||||
}
|
||||
interface PropertySignature extends TypeElement, JSDocContainer {
|
||||
readonly kind: SyntaxKind.PropertySignature;
|
||||
readonly parent: TypeLiteralNode | InterfaceDeclaration;
|
||||
readonly modifiers?: NodeArray<Modifier>;
|
||||
readonly name: PropertyName;
|
||||
readonly questionToken?: QuestionToken;
|
||||
@@ -4752,9 +4760,6 @@ declare namespace ts {
|
||||
readonly expression: Expression;
|
||||
}
|
||||
type VariableLikeDeclaration = VariableDeclaration | ParameterDeclaration | BindingElement | PropertyDeclaration | PropertyAssignment | PropertySignature | JsxAttribute | ShorthandPropertyAssignment | EnumMember | JSDocPropertyTag | JSDocParameterTag;
|
||||
interface PropertyLikeDeclaration extends NamedDeclaration {
|
||||
readonly name: PropertyName;
|
||||
}
|
||||
interface ObjectBindingPattern extends Node {
|
||||
readonly kind: SyntaxKind.ObjectBindingPattern;
|
||||
readonly parent: VariableDeclaration | ParameterDeclaration | BindingElement;
|
||||
@@ -4785,26 +4790,26 @@ declare namespace ts {
|
||||
type FunctionLikeDeclaration = FunctionDeclaration | MethodDeclaration | GetAccessorDeclaration | SetAccessorDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction;
|
||||
/** @deprecated Use SignatureDeclaration */
|
||||
type FunctionLike = SignatureDeclaration;
|
||||
interface FunctionDeclaration extends FunctionLikeDeclarationBase, DeclarationStatement {
|
||||
interface FunctionDeclaration extends FunctionLikeDeclarationBase, DeclarationStatement, LocalsContainer {
|
||||
readonly kind: SyntaxKind.FunctionDeclaration;
|
||||
readonly modifiers?: NodeArray<Modifier>;
|
||||
readonly name?: Identifier;
|
||||
readonly body?: FunctionBody;
|
||||
}
|
||||
interface MethodSignature extends SignatureDeclarationBase, TypeElement {
|
||||
interface MethodSignature extends SignatureDeclarationBase, TypeElement, LocalsContainer {
|
||||
readonly kind: SyntaxKind.MethodSignature;
|
||||
readonly parent: ObjectTypeDeclaration;
|
||||
readonly parent: TypeLiteralNode | InterfaceDeclaration;
|
||||
readonly modifiers?: NodeArray<Modifier>;
|
||||
readonly name: PropertyName;
|
||||
}
|
||||
interface MethodDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer {
|
||||
interface MethodDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer, LocalsContainer, FlowContainer {
|
||||
readonly kind: SyntaxKind.MethodDeclaration;
|
||||
readonly parent: ClassLikeDeclaration | ObjectLiteralExpression;
|
||||
readonly modifiers?: NodeArray<ModifierLike> | undefined;
|
||||
readonly name: PropertyName;
|
||||
readonly body?: FunctionBody | undefined;
|
||||
}
|
||||
interface ConstructorDeclaration extends FunctionLikeDeclarationBase, ClassElement, JSDocContainer {
|
||||
interface ConstructorDeclaration extends FunctionLikeDeclarationBase, ClassElement, JSDocContainer, LocalsContainer {
|
||||
readonly kind: SyntaxKind.Constructor;
|
||||
readonly parent: ClassLikeDeclaration;
|
||||
readonly modifiers?: NodeArray<Modifier> | undefined;
|
||||
@@ -4815,14 +4820,14 @@ declare namespace ts {
|
||||
readonly kind: SyntaxKind.SemicolonClassElement;
|
||||
readonly parent: ClassLikeDeclaration;
|
||||
}
|
||||
interface GetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, TypeElement, ObjectLiteralElement, JSDocContainer {
|
||||
interface GetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, TypeElement, ObjectLiteralElement, JSDocContainer, LocalsContainer, FlowContainer {
|
||||
readonly kind: SyntaxKind.GetAccessor;
|
||||
readonly parent: ClassLikeDeclaration | ObjectLiteralExpression | TypeLiteralNode | InterfaceDeclaration;
|
||||
readonly modifiers?: NodeArray<ModifierLike>;
|
||||
readonly name: PropertyName;
|
||||
readonly body?: FunctionBody;
|
||||
}
|
||||
interface SetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, TypeElement, ObjectLiteralElement, JSDocContainer {
|
||||
interface SetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, TypeElement, ObjectLiteralElement, JSDocContainer, LocalsContainer, FlowContainer {
|
||||
readonly kind: SyntaxKind.SetAccessor;
|
||||
readonly parent: ClassLikeDeclaration | ObjectLiteralExpression | TypeLiteralNode | InterfaceDeclaration;
|
||||
readonly modifiers?: NodeArray<ModifierLike>;
|
||||
@@ -4830,13 +4835,13 @@ declare namespace ts {
|
||||
readonly body?: FunctionBody;
|
||||
}
|
||||
type AccessorDeclaration = GetAccessorDeclaration | SetAccessorDeclaration;
|
||||
interface IndexSignatureDeclaration extends SignatureDeclarationBase, ClassElement, TypeElement {
|
||||
interface IndexSignatureDeclaration extends SignatureDeclarationBase, ClassElement, TypeElement, LocalsContainer {
|
||||
readonly kind: SyntaxKind.IndexSignature;
|
||||
readonly parent: ObjectTypeDeclaration;
|
||||
readonly modifiers?: NodeArray<Modifier>;
|
||||
readonly type: TypeNode;
|
||||
}
|
||||
interface ClassStaticBlockDeclaration extends ClassElement, JSDocContainer {
|
||||
interface ClassStaticBlockDeclaration extends ClassElement, JSDocContainer, LocalsContainer {
|
||||
readonly kind: SyntaxKind.ClassStaticBlockDeclaration;
|
||||
readonly parent: ClassDeclaration | ClassExpression;
|
||||
readonly body: Block;
|
||||
@@ -4868,14 +4873,14 @@ declare namespace ts {
|
||||
readonly kind: SyntaxKind.FunctionType | SyntaxKind.ConstructorType;
|
||||
readonly type: TypeNode;
|
||||
}
|
||||
interface FunctionTypeNode extends FunctionOrConstructorTypeNodeBase {
|
||||
interface FunctionTypeNode extends FunctionOrConstructorTypeNodeBase, LocalsContainer {
|
||||
readonly kind: SyntaxKind.FunctionType;
|
||||
}
|
||||
interface FunctionTypeNode {
|
||||
/** @deprecated A function type cannot have modifiers */
|
||||
readonly modifiers?: NodeArray<Modifier> | undefined;
|
||||
}
|
||||
interface ConstructorTypeNode extends FunctionOrConstructorTypeNodeBase {
|
||||
interface ConstructorTypeNode extends FunctionOrConstructorTypeNodeBase, LocalsContainer {
|
||||
readonly kind: SyntaxKind.ConstructorType;
|
||||
readonly modifiers?: NodeArray<Modifier>;
|
||||
}
|
||||
@@ -4910,7 +4915,7 @@ declare namespace ts {
|
||||
readonly kind: SyntaxKind.TupleType;
|
||||
readonly elements: NodeArray<TypeNode | NamedTupleMember>;
|
||||
}
|
||||
interface NamedTupleMember extends TypeNode, JSDocContainer, Declaration {
|
||||
interface NamedTupleMember extends TypeNode, Declaration, JSDocContainer {
|
||||
readonly kind: SyntaxKind.NamedTupleMember;
|
||||
readonly dotDotDotToken?: Token<SyntaxKind.DotDotDotToken>;
|
||||
readonly name: Identifier;
|
||||
@@ -4934,7 +4939,7 @@ declare namespace ts {
|
||||
readonly kind: SyntaxKind.IntersectionType;
|
||||
readonly types: NodeArray<TypeNode>;
|
||||
}
|
||||
interface ConditionalTypeNode extends TypeNode {
|
||||
interface ConditionalTypeNode extends TypeNode, LocalsContainer {
|
||||
readonly kind: SyntaxKind.ConditionalType;
|
||||
readonly checkType: TypeNode;
|
||||
readonly extendsType: TypeNode;
|
||||
@@ -4959,7 +4964,7 @@ declare namespace ts {
|
||||
readonly objectType: TypeNode;
|
||||
readonly indexType: TypeNode;
|
||||
}
|
||||
interface MappedTypeNode extends TypeNode, Declaration {
|
||||
interface MappedTypeNode extends TypeNode, Declaration, LocalsContainer {
|
||||
readonly kind: SyntaxKind.MappedType;
|
||||
readonly readonlyToken?: ReadonlyKeyword | PlusToken | MinusToken;
|
||||
readonly typeParameter: TypeParameterDeclaration;
|
||||
@@ -5038,10 +5043,10 @@ declare namespace ts {
|
||||
readonly kind: SyntaxKind.FalseKeyword;
|
||||
}
|
||||
type BooleanLiteral = TrueLiteral | FalseLiteral;
|
||||
interface ThisExpression extends PrimaryExpression {
|
||||
interface ThisExpression extends PrimaryExpression, FlowContainer {
|
||||
readonly kind: SyntaxKind.ThisKeyword;
|
||||
}
|
||||
interface SuperExpression extends PrimaryExpression {
|
||||
interface SuperExpression extends PrimaryExpression, FlowContainer {
|
||||
readonly kind: SyntaxKind.SuperKeyword;
|
||||
}
|
||||
interface ImportExpression extends PrimaryExpression {
|
||||
@@ -5095,7 +5100,7 @@ declare namespace ts {
|
||||
type BinaryOperator = AssignmentOperatorOrHigher | SyntaxKind.CommaToken;
|
||||
type LogicalOrCoalescingAssignmentOperator = SyntaxKind.AmpersandAmpersandEqualsToken | SyntaxKind.BarBarEqualsToken | SyntaxKind.QuestionQuestionEqualsToken;
|
||||
type BinaryOperatorToken = Token<BinaryOperator>;
|
||||
interface BinaryExpression extends Expression, Declaration {
|
||||
interface BinaryExpression extends Expression, Declaration, JSDocContainer {
|
||||
readonly kind: SyntaxKind.BinaryExpression;
|
||||
readonly left: Expression;
|
||||
readonly operatorToken: BinaryOperatorToken;
|
||||
@@ -5132,13 +5137,13 @@ declare namespace ts {
|
||||
}
|
||||
type FunctionBody = Block;
|
||||
type ConciseBody = FunctionBody | Expression;
|
||||
interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclarationBase, JSDocContainer {
|
||||
interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclarationBase, JSDocContainer, LocalsContainer, FlowContainer {
|
||||
readonly kind: SyntaxKind.FunctionExpression;
|
||||
readonly modifiers?: NodeArray<Modifier>;
|
||||
readonly name?: Identifier;
|
||||
readonly body: FunctionBody;
|
||||
}
|
||||
interface ArrowFunction extends Expression, FunctionLikeDeclarationBase, JSDocContainer {
|
||||
interface ArrowFunction extends Expression, FunctionLikeDeclarationBase, JSDocContainer, LocalsContainer, FlowContainer {
|
||||
readonly kind: SyntaxKind.ArrowFunction;
|
||||
readonly modifiers?: NodeArray<Modifier>;
|
||||
readonly equalsGreaterThanToken: EqualsGreaterThanToken;
|
||||
@@ -5225,13 +5230,13 @@ declare namespace ts {
|
||||
interface ObjectLiteralExpressionBase<T extends ObjectLiteralElement> extends PrimaryExpression, Declaration {
|
||||
readonly properties: NodeArray<T>;
|
||||
}
|
||||
interface ObjectLiteralExpression extends ObjectLiteralExpressionBase<ObjectLiteralElementLike> {
|
||||
interface ObjectLiteralExpression extends ObjectLiteralExpressionBase<ObjectLiteralElementLike>, JSDocContainer {
|
||||
readonly kind: SyntaxKind.ObjectLiteralExpression;
|
||||
}
|
||||
type EntityNameExpression = Identifier | PropertyAccessEntityNameExpression;
|
||||
type EntityNameOrEntityNameExpression = EntityName | EntityNameExpression;
|
||||
type AccessExpression = PropertyAccessExpression | ElementAccessExpression;
|
||||
interface PropertyAccessExpression extends MemberExpression, NamedDeclaration {
|
||||
interface PropertyAccessExpression extends MemberExpression, NamedDeclaration, JSDocContainer, FlowContainer {
|
||||
readonly kind: SyntaxKind.PropertyAccessExpression;
|
||||
readonly expression: LeftHandSideExpression;
|
||||
readonly questionDotToken?: QuestionDotToken;
|
||||
@@ -5250,7 +5255,7 @@ declare namespace ts {
|
||||
readonly expression: EntityNameExpression;
|
||||
readonly name: Identifier;
|
||||
}
|
||||
interface ElementAccessExpression extends MemberExpression {
|
||||
interface ElementAccessExpression extends MemberExpression, Declaration, JSDocContainer, FlowContainer {
|
||||
readonly kind: SyntaxKind.ElementAccessExpression;
|
||||
readonly expression: LeftHandSideExpression;
|
||||
readonly questionDotToken?: QuestionDotToken;
|
||||
@@ -5320,7 +5325,7 @@ declare namespace ts {
|
||||
interface NonNullChain extends NonNullExpression {
|
||||
_optionalChainBrand: any;
|
||||
}
|
||||
interface MetaProperty extends PrimaryExpression {
|
||||
interface MetaProperty extends PrimaryExpression, FlowContainer {
|
||||
readonly kind: SyntaxKind.MetaProperty;
|
||||
readonly keywordToken: SyntaxKind.NewKeyword | SyntaxKind.ImportKeyword;
|
||||
readonly name: Identifier;
|
||||
@@ -5413,7 +5418,7 @@ declare namespace ts {
|
||||
interface EmptyStatement extends Statement {
|
||||
readonly kind: SyntaxKind.EmptyStatement;
|
||||
}
|
||||
interface DebuggerStatement extends Statement {
|
||||
interface DebuggerStatement extends Statement, FlowContainer {
|
||||
readonly kind: SyntaxKind.DebuggerStatement;
|
||||
}
|
||||
interface MissingDeclaration extends DeclarationStatement {
|
||||
@@ -5421,20 +5426,20 @@ declare namespace ts {
|
||||
readonly name?: Identifier;
|
||||
}
|
||||
type BlockLike = SourceFile | Block | ModuleBlock | CaseOrDefaultClause;
|
||||
interface Block extends Statement {
|
||||
interface Block extends Statement, LocalsContainer {
|
||||
readonly kind: SyntaxKind.Block;
|
||||
readonly statements: NodeArray<Statement>;
|
||||
}
|
||||
interface VariableStatement extends Statement {
|
||||
interface VariableStatement extends Statement, FlowContainer {
|
||||
readonly kind: SyntaxKind.VariableStatement;
|
||||
readonly modifiers?: NodeArray<Modifier>;
|
||||
readonly declarationList: VariableDeclarationList;
|
||||
}
|
||||
interface ExpressionStatement extends Statement {
|
||||
interface ExpressionStatement extends Statement, FlowContainer {
|
||||
readonly kind: SyntaxKind.ExpressionStatement;
|
||||
readonly expression: Expression;
|
||||
}
|
||||
interface IfStatement extends Statement {
|
||||
interface IfStatement extends Statement, FlowContainer {
|
||||
readonly kind: SyntaxKind.IfStatement;
|
||||
readonly expression: Expression;
|
||||
readonly thenStatement: Statement;
|
||||
@@ -5443,58 +5448,58 @@ declare namespace ts {
|
||||
interface IterationStatement extends Statement {
|
||||
readonly statement: Statement;
|
||||
}
|
||||
interface DoStatement extends IterationStatement {
|
||||
interface DoStatement extends IterationStatement, FlowContainer {
|
||||
readonly kind: SyntaxKind.DoStatement;
|
||||
readonly expression: Expression;
|
||||
}
|
||||
interface WhileStatement extends IterationStatement {
|
||||
interface WhileStatement extends IterationStatement, FlowContainer {
|
||||
readonly kind: SyntaxKind.WhileStatement;
|
||||
readonly expression: Expression;
|
||||
}
|
||||
type ForInitializer = VariableDeclarationList | Expression;
|
||||
interface ForStatement extends IterationStatement {
|
||||
interface ForStatement extends IterationStatement, LocalsContainer, FlowContainer {
|
||||
readonly kind: SyntaxKind.ForStatement;
|
||||
readonly initializer?: ForInitializer;
|
||||
readonly condition?: Expression;
|
||||
readonly incrementor?: Expression;
|
||||
}
|
||||
type ForInOrOfStatement = ForInStatement | ForOfStatement;
|
||||
interface ForInStatement extends IterationStatement {
|
||||
interface ForInStatement extends IterationStatement, LocalsContainer, FlowContainer {
|
||||
readonly kind: SyntaxKind.ForInStatement;
|
||||
readonly initializer: ForInitializer;
|
||||
readonly expression: Expression;
|
||||
}
|
||||
interface ForOfStatement extends IterationStatement {
|
||||
interface ForOfStatement extends IterationStatement, LocalsContainer, FlowContainer {
|
||||
readonly kind: SyntaxKind.ForOfStatement;
|
||||
readonly awaitModifier?: AwaitKeyword;
|
||||
readonly initializer: ForInitializer;
|
||||
readonly expression: Expression;
|
||||
}
|
||||
interface BreakStatement extends Statement {
|
||||
interface BreakStatement extends Statement, FlowContainer {
|
||||
readonly kind: SyntaxKind.BreakStatement;
|
||||
readonly label?: Identifier;
|
||||
}
|
||||
interface ContinueStatement extends Statement {
|
||||
interface ContinueStatement extends Statement, FlowContainer {
|
||||
readonly kind: SyntaxKind.ContinueStatement;
|
||||
readonly label?: Identifier;
|
||||
}
|
||||
type BreakOrContinueStatement = BreakStatement | ContinueStatement;
|
||||
interface ReturnStatement extends Statement {
|
||||
interface ReturnStatement extends Statement, FlowContainer {
|
||||
readonly kind: SyntaxKind.ReturnStatement;
|
||||
readonly expression?: Expression;
|
||||
}
|
||||
interface WithStatement extends Statement {
|
||||
interface WithStatement extends Statement, FlowContainer {
|
||||
readonly kind: SyntaxKind.WithStatement;
|
||||
readonly expression: Expression;
|
||||
readonly statement: Statement;
|
||||
}
|
||||
interface SwitchStatement extends Statement {
|
||||
interface SwitchStatement extends Statement, FlowContainer {
|
||||
readonly kind: SyntaxKind.SwitchStatement;
|
||||
readonly expression: Expression;
|
||||
readonly caseBlock: CaseBlock;
|
||||
possiblyExhaustive?: boolean;
|
||||
}
|
||||
interface CaseBlock extends Node {
|
||||
interface CaseBlock extends Node, LocalsContainer {
|
||||
readonly kind: SyntaxKind.CaseBlock;
|
||||
readonly parent: SwitchStatement;
|
||||
readonly clauses: NodeArray<CaseOrDefaultClause>;
|
||||
@@ -5511,22 +5516,22 @@ declare namespace ts {
|
||||
readonly statements: NodeArray<Statement>;
|
||||
}
|
||||
type CaseOrDefaultClause = CaseClause | DefaultClause;
|
||||
interface LabeledStatement extends Statement {
|
||||
interface LabeledStatement extends Statement, FlowContainer {
|
||||
readonly kind: SyntaxKind.LabeledStatement;
|
||||
readonly label: Identifier;
|
||||
readonly statement: Statement;
|
||||
}
|
||||
interface ThrowStatement extends Statement {
|
||||
interface ThrowStatement extends Statement, FlowContainer {
|
||||
readonly kind: SyntaxKind.ThrowStatement;
|
||||
readonly expression: Expression;
|
||||
}
|
||||
interface TryStatement extends Statement {
|
||||
interface TryStatement extends Statement, FlowContainer {
|
||||
readonly kind: SyntaxKind.TryStatement;
|
||||
readonly tryBlock: Block;
|
||||
readonly catchClause?: CatchClause;
|
||||
readonly finallyBlock?: Block;
|
||||
}
|
||||
interface CatchClause extends Node {
|
||||
interface CatchClause extends Node, LocalsContainer {
|
||||
readonly kind: SyntaxKind.CatchClause;
|
||||
readonly parent: TryStatement;
|
||||
readonly variableDeclaration?: VariableDeclaration;
|
||||
@@ -5576,7 +5581,7 @@ declare namespace ts {
|
||||
readonly token: SyntaxKind.ExtendsKeyword | SyntaxKind.ImplementsKeyword;
|
||||
readonly types: NodeArray<ExpressionWithTypeArguments>;
|
||||
}
|
||||
interface TypeAliasDeclaration extends DeclarationStatement, JSDocContainer {
|
||||
interface TypeAliasDeclaration extends DeclarationStatement, JSDocContainer, LocalsContainer {
|
||||
readonly kind: SyntaxKind.TypeAliasDeclaration;
|
||||
readonly modifiers?: NodeArray<Modifier>;
|
||||
readonly name: Identifier;
|
||||
@@ -5597,7 +5602,7 @@ declare namespace ts {
|
||||
}
|
||||
type ModuleName = Identifier | StringLiteral;
|
||||
type ModuleBody = NamespaceBody | JSDocNamespaceBody;
|
||||
interface ModuleDeclaration extends DeclarationStatement, JSDocContainer {
|
||||
interface ModuleDeclaration extends DeclarationStatement, JSDocContainer, LocalsContainer {
|
||||
readonly kind: SyntaxKind.ModuleDeclaration;
|
||||
readonly parent: ModuleBody | SourceFile;
|
||||
readonly modifiers?: NodeArray<Modifier>;
|
||||
@@ -5813,7 +5818,7 @@ declare namespace ts {
|
||||
readonly kind: SyntaxKind.JSDocOptionalType;
|
||||
readonly type: TypeNode;
|
||||
}
|
||||
interface JSDocFunctionType extends JSDocType, SignatureDeclarationBase {
|
||||
interface JSDocFunctionType extends JSDocType, SignatureDeclarationBase, LocalsContainer {
|
||||
readonly kind: SyntaxKind.JSDocFunctionType;
|
||||
}
|
||||
interface JSDocVariadicType extends JSDocType {
|
||||
@@ -5899,7 +5904,7 @@ declare namespace ts {
|
||||
interface JSDocOverrideTag extends JSDocTag {
|
||||
readonly kind: SyntaxKind.JSDocOverrideTag;
|
||||
}
|
||||
interface JSDocEnumTag extends JSDocTag, Declaration {
|
||||
interface JSDocEnumTag extends JSDocTag, Declaration, LocalsContainer {
|
||||
readonly kind: SyntaxKind.JSDocEnumTag;
|
||||
readonly parent: JSDoc;
|
||||
readonly typeExpression: JSDocTypeExpression;
|
||||
@@ -5925,14 +5930,14 @@ declare namespace ts {
|
||||
readonly kind: SyntaxKind.JSDocTypeTag;
|
||||
readonly typeExpression: JSDocTypeExpression;
|
||||
}
|
||||
interface JSDocTypedefTag extends JSDocTag, NamedDeclaration {
|
||||
interface JSDocTypedefTag extends JSDocTag, NamedDeclaration, LocalsContainer {
|
||||
readonly kind: SyntaxKind.JSDocTypedefTag;
|
||||
readonly parent: JSDoc;
|
||||
readonly fullName?: JSDocNamespaceDeclaration | Identifier;
|
||||
readonly name?: Identifier;
|
||||
readonly typeExpression?: JSDocTypeExpression | JSDocTypeLiteral;
|
||||
}
|
||||
interface JSDocCallbackTag extends JSDocTag, NamedDeclaration {
|
||||
interface JSDocCallbackTag extends JSDocTag, NamedDeclaration, LocalsContainer {
|
||||
readonly kind: SyntaxKind.JSDocCallbackTag;
|
||||
readonly parent: JSDoc;
|
||||
readonly fullName?: JSDocNamespaceDeclaration | Identifier;
|
||||
@@ -5943,7 +5948,7 @@ declare namespace ts {
|
||||
readonly kind: SyntaxKind.JSDocThrowsTag;
|
||||
readonly typeExpression?: JSDocTypeExpression;
|
||||
}
|
||||
interface JSDocSignature extends JSDocType, Declaration {
|
||||
interface JSDocSignature extends JSDocType, Declaration, JSDocContainer, LocalsContainer {
|
||||
readonly kind: SyntaxKind.JSDocSignature;
|
||||
readonly typeParameters?: readonly JSDocTemplateTag[];
|
||||
readonly parameters: readonly JSDocParameterTag[];
|
||||
@@ -5963,7 +5968,7 @@ declare namespace ts {
|
||||
interface JSDocParameterTag extends JSDocPropertyLikeTag {
|
||||
readonly kind: SyntaxKind.JSDocParameterTag;
|
||||
}
|
||||
interface JSDocTypeLiteral extends JSDocType {
|
||||
interface JSDocTypeLiteral extends JSDocType, Declaration {
|
||||
readonly kind: SyntaxKind.JSDocTypeLiteral;
|
||||
readonly jsDocPropertyTags?: readonly JSDocPropertyLikeTag[];
|
||||
/** If true, then this type literal represents an *array* of its type. */
|
||||
@@ -6043,7 +6048,7 @@ declare namespace ts {
|
||||
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
|
||||
}
|
||||
type ResolutionMode = ModuleKind.ESNext | ModuleKind.CommonJS | undefined;
|
||||
interface SourceFile extends Declaration {
|
||||
interface SourceFile extends Declaration, LocalsContainer {
|
||||
readonly kind: SyntaxKind.SourceFile;
|
||||
readonly statements: NodeArray<Statement>;
|
||||
readonly endOfFileToken: Token<SyntaxKind.EndOfFileToken>;
|
||||
@@ -7469,11 +7474,12 @@ declare namespace ts {
|
||||
createToken(token: SyntaxKind.NullKeyword): NullLiteral;
|
||||
createToken(token: SyntaxKind.TrueKeyword): TrueLiteral;
|
||||
createToken(token: SyntaxKind.FalseKeyword): FalseLiteral;
|
||||
createToken(token: SyntaxKind.EndOfFileToken): EndOfFileToken;
|
||||
createToken(token: SyntaxKind.Unknown): Token<SyntaxKind.Unknown>;
|
||||
createToken<TKind extends PunctuationSyntaxKind>(token: TKind): PunctuationToken<TKind>;
|
||||
createToken<TKind extends KeywordTypeSyntaxKind>(token: TKind): KeywordTypeNode<TKind>;
|
||||
createToken<TKind extends ModifierSyntaxKind>(token: TKind): ModifierToken<TKind>;
|
||||
createToken<TKind extends KeywordSyntaxKind>(token: TKind): KeywordToken<TKind>;
|
||||
createToken<TKind extends SyntaxKind.Unknown | SyntaxKind.EndOfFileToken>(token: TKind): Token<TKind>;
|
||||
createSuper(): SuperExpression;
|
||||
createThis(): ThisExpression;
|
||||
createNull(): NullLiteral;
|
||||
|
||||
+70
-64
@@ -578,9 +578,16 @@ declare namespace ts {
|
||||
*/
|
||||
readonly modifiers?: NodeArray<ModifierLike> | undefined;
|
||||
}
|
||||
interface JSDocContainer {
|
||||
interface JSDocContainer extends Node {
|
||||
_jsdocContainerBrand: any;
|
||||
}
|
||||
type HasJSDoc = ParameterDeclaration | CallSignatureDeclaration | ClassStaticBlockDeclaration | ConstructSignatureDeclaration | MethodSignature | PropertySignature | ArrowFunction | ParenthesizedExpression | SpreadAssignment | ShorthandPropertyAssignment | PropertyAssignment | FunctionExpression | EmptyStatement | DebuggerStatement | Block | VariableStatement | ExpressionStatement | IfStatement | DoStatement | WhileStatement | ForStatement | ForInStatement | ForOfStatement | BreakStatement | ContinueStatement | ReturnStatement | WithStatement | SwitchStatement | LabeledStatement | ThrowStatement | TryStatement | FunctionDeclaration | ConstructorDeclaration | MethodDeclaration | VariableDeclaration | PropertyDeclaration | AccessorDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | EnumMember | EnumDeclaration | ModuleDeclaration | ImportEqualsDeclaration | ImportDeclaration | NamespaceExportDeclaration | ExportAssignment | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | ExportDeclaration | NamedTupleMember | ExportSpecifier | CaseClause | EndOfFileToken;
|
||||
interface LocalsContainer extends Node {
|
||||
_localsContainerBrand: any;
|
||||
}
|
||||
interface FlowContainer extends Node {
|
||||
_flowContainerBrand: any;
|
||||
}
|
||||
type HasJSDoc = AccessorDeclaration | ArrowFunction | BinaryExpression | Block | BreakStatement | CallSignatureDeclaration | CaseClause | ClassLikeDeclaration | ClassStaticBlockDeclaration | ConstructorDeclaration | ConstructorTypeNode | ConstructSignatureDeclaration | ContinueStatement | DebuggerStatement | DoStatement | ElementAccessExpression | EmptyStatement | EndOfFileToken | EnumDeclaration | EnumMember | ExportAssignment | ExportDeclaration | ExportSpecifier | ExpressionStatement | ForInStatement | ForOfStatement | ForStatement | FunctionDeclaration | FunctionExpression | FunctionTypeNode | Identifier | IfStatement | ImportDeclaration | ImportEqualsDeclaration | IndexSignatureDeclaration | InterfaceDeclaration | JSDocFunctionType | JSDocSignature | LabeledStatement | MethodDeclaration | MethodSignature | ModuleDeclaration | NamedTupleMember | NamespaceExportDeclaration | ObjectLiteralExpression | ParameterDeclaration | ParenthesizedExpression | PropertyAccessExpression | PropertyAssignment | PropertyDeclaration | PropertySignature | ReturnStatement | ShorthandPropertyAssignment | SpreadAssignment | SwitchStatement | ThrowStatement | TryStatement | TypeAliasDeclaration | TypeParameterDeclaration | VariableDeclaration | VariableStatement | WhileStatement | WithStatement;
|
||||
type HasType = SignatureDeclaration | VariableDeclaration | ParameterDeclaration | PropertySignature | PropertyDeclaration | TypePredicateNode | ParenthesizedTypeNode | TypeOperatorNode | MappedTypeNode | AssertionExpression | TypeAliasDeclaration | JSDocTypeExpression | JSDocNonNullableType | JSDocNullableType | JSDocOptionalType | JSDocVariadicType;
|
||||
type HasTypeArguments = CallExpression | NewExpression | TaggedTemplateExpression | JsxOpeningElement | JsxSelfClosingElement;
|
||||
type HasInitializer = HasExpressionInitializer | ForStatement | ForInStatement | ForOfStatement | JsxAttribute;
|
||||
@@ -648,7 +655,7 @@ declare namespace ts {
|
||||
FileLevel = 32,
|
||||
AllowNameSubstitution = 64
|
||||
}
|
||||
interface Identifier extends PrimaryExpression, Declaration {
|
||||
interface Identifier extends PrimaryExpression, Declaration, JSDocContainer, FlowContainer {
|
||||
readonly kind: SyntaxKind.Identifier;
|
||||
/**
|
||||
* Prefer to use `id.unescapedText`. (Note: This is available only in services, not internally to the TypeScript compiler.)
|
||||
@@ -664,7 +671,7 @@ declare namespace ts {
|
||||
interface TransientIdentifier extends Identifier {
|
||||
resolvedSymbol: Symbol;
|
||||
}
|
||||
interface QualifiedName extends Node {
|
||||
interface QualifiedName extends Node, FlowContainer {
|
||||
readonly kind: SyntaxKind.QualifiedName;
|
||||
readonly left: EntityName;
|
||||
readonly right: Identifier;
|
||||
@@ -699,7 +706,7 @@ declare namespace ts {
|
||||
readonly parent: NamedDeclaration;
|
||||
readonly expression: LeftHandSideExpression;
|
||||
}
|
||||
interface TypeParameterDeclaration extends NamedDeclaration {
|
||||
interface TypeParameterDeclaration extends NamedDeclaration, JSDocContainer {
|
||||
readonly kind: SyntaxKind.TypeParameter;
|
||||
readonly parent: DeclarationWithTypeParameterChildren | InferTypeNode;
|
||||
readonly modifiers?: NodeArray<Modifier>;
|
||||
@@ -717,10 +724,10 @@ declare namespace ts {
|
||||
readonly type?: TypeNode | undefined;
|
||||
}
|
||||
type SignatureDeclaration = CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | AccessorDeclaration | FunctionExpression | ArrowFunction;
|
||||
interface CallSignatureDeclaration extends SignatureDeclarationBase, TypeElement {
|
||||
interface CallSignatureDeclaration extends SignatureDeclarationBase, TypeElement, LocalsContainer {
|
||||
readonly kind: SyntaxKind.CallSignature;
|
||||
}
|
||||
interface ConstructSignatureDeclaration extends SignatureDeclarationBase, TypeElement {
|
||||
interface ConstructSignatureDeclaration extends SignatureDeclarationBase, TypeElement, LocalsContainer {
|
||||
readonly kind: SyntaxKind.ConstructSignature;
|
||||
}
|
||||
type BindingName = Identifier | BindingPattern;
|
||||
@@ -747,7 +754,7 @@ declare namespace ts {
|
||||
readonly type?: TypeNode;
|
||||
readonly initializer?: Expression;
|
||||
}
|
||||
interface BindingElement extends NamedDeclaration {
|
||||
interface BindingElement extends NamedDeclaration, FlowContainer {
|
||||
readonly kind: SyntaxKind.BindingElement;
|
||||
readonly parent: BindingPattern;
|
||||
readonly propertyName?: PropertyName;
|
||||
@@ -757,6 +764,7 @@ declare namespace ts {
|
||||
}
|
||||
interface PropertySignature extends TypeElement, JSDocContainer {
|
||||
readonly kind: SyntaxKind.PropertySignature;
|
||||
readonly parent: TypeLiteralNode | InterfaceDeclaration;
|
||||
readonly modifiers?: NodeArray<Modifier>;
|
||||
readonly name: PropertyName;
|
||||
readonly questionToken?: QuestionToken;
|
||||
@@ -818,9 +826,6 @@ declare namespace ts {
|
||||
readonly expression: Expression;
|
||||
}
|
||||
type VariableLikeDeclaration = VariableDeclaration | ParameterDeclaration | BindingElement | PropertyDeclaration | PropertyAssignment | PropertySignature | JsxAttribute | ShorthandPropertyAssignment | EnumMember | JSDocPropertyTag | JSDocParameterTag;
|
||||
interface PropertyLikeDeclaration extends NamedDeclaration {
|
||||
readonly name: PropertyName;
|
||||
}
|
||||
interface ObjectBindingPattern extends Node {
|
||||
readonly kind: SyntaxKind.ObjectBindingPattern;
|
||||
readonly parent: VariableDeclaration | ParameterDeclaration | BindingElement;
|
||||
@@ -851,26 +856,26 @@ declare namespace ts {
|
||||
type FunctionLikeDeclaration = FunctionDeclaration | MethodDeclaration | GetAccessorDeclaration | SetAccessorDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction;
|
||||
/** @deprecated Use SignatureDeclaration */
|
||||
type FunctionLike = SignatureDeclaration;
|
||||
interface FunctionDeclaration extends FunctionLikeDeclarationBase, DeclarationStatement {
|
||||
interface FunctionDeclaration extends FunctionLikeDeclarationBase, DeclarationStatement, LocalsContainer {
|
||||
readonly kind: SyntaxKind.FunctionDeclaration;
|
||||
readonly modifiers?: NodeArray<Modifier>;
|
||||
readonly name?: Identifier;
|
||||
readonly body?: FunctionBody;
|
||||
}
|
||||
interface MethodSignature extends SignatureDeclarationBase, TypeElement {
|
||||
interface MethodSignature extends SignatureDeclarationBase, TypeElement, LocalsContainer {
|
||||
readonly kind: SyntaxKind.MethodSignature;
|
||||
readonly parent: ObjectTypeDeclaration;
|
||||
readonly parent: TypeLiteralNode | InterfaceDeclaration;
|
||||
readonly modifiers?: NodeArray<Modifier>;
|
||||
readonly name: PropertyName;
|
||||
}
|
||||
interface MethodDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer {
|
||||
interface MethodDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer, LocalsContainer, FlowContainer {
|
||||
readonly kind: SyntaxKind.MethodDeclaration;
|
||||
readonly parent: ClassLikeDeclaration | ObjectLiteralExpression;
|
||||
readonly modifiers?: NodeArray<ModifierLike> | undefined;
|
||||
readonly name: PropertyName;
|
||||
readonly body?: FunctionBody | undefined;
|
||||
}
|
||||
interface ConstructorDeclaration extends FunctionLikeDeclarationBase, ClassElement, JSDocContainer {
|
||||
interface ConstructorDeclaration extends FunctionLikeDeclarationBase, ClassElement, JSDocContainer, LocalsContainer {
|
||||
readonly kind: SyntaxKind.Constructor;
|
||||
readonly parent: ClassLikeDeclaration;
|
||||
readonly modifiers?: NodeArray<Modifier> | undefined;
|
||||
@@ -881,14 +886,14 @@ declare namespace ts {
|
||||
readonly kind: SyntaxKind.SemicolonClassElement;
|
||||
readonly parent: ClassLikeDeclaration;
|
||||
}
|
||||
interface GetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, TypeElement, ObjectLiteralElement, JSDocContainer {
|
||||
interface GetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, TypeElement, ObjectLiteralElement, JSDocContainer, LocalsContainer, FlowContainer {
|
||||
readonly kind: SyntaxKind.GetAccessor;
|
||||
readonly parent: ClassLikeDeclaration | ObjectLiteralExpression | TypeLiteralNode | InterfaceDeclaration;
|
||||
readonly modifiers?: NodeArray<ModifierLike>;
|
||||
readonly name: PropertyName;
|
||||
readonly body?: FunctionBody;
|
||||
}
|
||||
interface SetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, TypeElement, ObjectLiteralElement, JSDocContainer {
|
||||
interface SetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, TypeElement, ObjectLiteralElement, JSDocContainer, LocalsContainer, FlowContainer {
|
||||
readonly kind: SyntaxKind.SetAccessor;
|
||||
readonly parent: ClassLikeDeclaration | ObjectLiteralExpression | TypeLiteralNode | InterfaceDeclaration;
|
||||
readonly modifiers?: NodeArray<ModifierLike>;
|
||||
@@ -896,13 +901,13 @@ declare namespace ts {
|
||||
readonly body?: FunctionBody;
|
||||
}
|
||||
type AccessorDeclaration = GetAccessorDeclaration | SetAccessorDeclaration;
|
||||
interface IndexSignatureDeclaration extends SignatureDeclarationBase, ClassElement, TypeElement {
|
||||
interface IndexSignatureDeclaration extends SignatureDeclarationBase, ClassElement, TypeElement, LocalsContainer {
|
||||
readonly kind: SyntaxKind.IndexSignature;
|
||||
readonly parent: ObjectTypeDeclaration;
|
||||
readonly modifiers?: NodeArray<Modifier>;
|
||||
readonly type: TypeNode;
|
||||
}
|
||||
interface ClassStaticBlockDeclaration extends ClassElement, JSDocContainer {
|
||||
interface ClassStaticBlockDeclaration extends ClassElement, JSDocContainer, LocalsContainer {
|
||||
readonly kind: SyntaxKind.ClassStaticBlockDeclaration;
|
||||
readonly parent: ClassDeclaration | ClassExpression;
|
||||
readonly body: Block;
|
||||
@@ -934,14 +939,14 @@ declare namespace ts {
|
||||
readonly kind: SyntaxKind.FunctionType | SyntaxKind.ConstructorType;
|
||||
readonly type: TypeNode;
|
||||
}
|
||||
interface FunctionTypeNode extends FunctionOrConstructorTypeNodeBase {
|
||||
interface FunctionTypeNode extends FunctionOrConstructorTypeNodeBase, LocalsContainer {
|
||||
readonly kind: SyntaxKind.FunctionType;
|
||||
}
|
||||
interface FunctionTypeNode {
|
||||
/** @deprecated A function type cannot have modifiers */
|
||||
readonly modifiers?: NodeArray<Modifier> | undefined;
|
||||
}
|
||||
interface ConstructorTypeNode extends FunctionOrConstructorTypeNodeBase {
|
||||
interface ConstructorTypeNode extends FunctionOrConstructorTypeNodeBase, LocalsContainer {
|
||||
readonly kind: SyntaxKind.ConstructorType;
|
||||
readonly modifiers?: NodeArray<Modifier>;
|
||||
}
|
||||
@@ -976,7 +981,7 @@ declare namespace ts {
|
||||
readonly kind: SyntaxKind.TupleType;
|
||||
readonly elements: NodeArray<TypeNode | NamedTupleMember>;
|
||||
}
|
||||
interface NamedTupleMember extends TypeNode, JSDocContainer, Declaration {
|
||||
interface NamedTupleMember extends TypeNode, Declaration, JSDocContainer {
|
||||
readonly kind: SyntaxKind.NamedTupleMember;
|
||||
readonly dotDotDotToken?: Token<SyntaxKind.DotDotDotToken>;
|
||||
readonly name: Identifier;
|
||||
@@ -1000,7 +1005,7 @@ declare namespace ts {
|
||||
readonly kind: SyntaxKind.IntersectionType;
|
||||
readonly types: NodeArray<TypeNode>;
|
||||
}
|
||||
interface ConditionalTypeNode extends TypeNode {
|
||||
interface ConditionalTypeNode extends TypeNode, LocalsContainer {
|
||||
readonly kind: SyntaxKind.ConditionalType;
|
||||
readonly checkType: TypeNode;
|
||||
readonly extendsType: TypeNode;
|
||||
@@ -1025,7 +1030,7 @@ declare namespace ts {
|
||||
readonly objectType: TypeNode;
|
||||
readonly indexType: TypeNode;
|
||||
}
|
||||
interface MappedTypeNode extends TypeNode, Declaration {
|
||||
interface MappedTypeNode extends TypeNode, Declaration, LocalsContainer {
|
||||
readonly kind: SyntaxKind.MappedType;
|
||||
readonly readonlyToken?: ReadonlyKeyword | PlusToken | MinusToken;
|
||||
readonly typeParameter: TypeParameterDeclaration;
|
||||
@@ -1104,10 +1109,10 @@ declare namespace ts {
|
||||
readonly kind: SyntaxKind.FalseKeyword;
|
||||
}
|
||||
type BooleanLiteral = TrueLiteral | FalseLiteral;
|
||||
interface ThisExpression extends PrimaryExpression {
|
||||
interface ThisExpression extends PrimaryExpression, FlowContainer {
|
||||
readonly kind: SyntaxKind.ThisKeyword;
|
||||
}
|
||||
interface SuperExpression extends PrimaryExpression {
|
||||
interface SuperExpression extends PrimaryExpression, FlowContainer {
|
||||
readonly kind: SyntaxKind.SuperKeyword;
|
||||
}
|
||||
interface ImportExpression extends PrimaryExpression {
|
||||
@@ -1161,7 +1166,7 @@ declare namespace ts {
|
||||
type BinaryOperator = AssignmentOperatorOrHigher | SyntaxKind.CommaToken;
|
||||
type LogicalOrCoalescingAssignmentOperator = SyntaxKind.AmpersandAmpersandEqualsToken | SyntaxKind.BarBarEqualsToken | SyntaxKind.QuestionQuestionEqualsToken;
|
||||
type BinaryOperatorToken = Token<BinaryOperator>;
|
||||
interface BinaryExpression extends Expression, Declaration {
|
||||
interface BinaryExpression extends Expression, Declaration, JSDocContainer {
|
||||
readonly kind: SyntaxKind.BinaryExpression;
|
||||
readonly left: Expression;
|
||||
readonly operatorToken: BinaryOperatorToken;
|
||||
@@ -1198,13 +1203,13 @@ declare namespace ts {
|
||||
}
|
||||
type FunctionBody = Block;
|
||||
type ConciseBody = FunctionBody | Expression;
|
||||
interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclarationBase, JSDocContainer {
|
||||
interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclarationBase, JSDocContainer, LocalsContainer, FlowContainer {
|
||||
readonly kind: SyntaxKind.FunctionExpression;
|
||||
readonly modifiers?: NodeArray<Modifier>;
|
||||
readonly name?: Identifier;
|
||||
readonly body: FunctionBody;
|
||||
}
|
||||
interface ArrowFunction extends Expression, FunctionLikeDeclarationBase, JSDocContainer {
|
||||
interface ArrowFunction extends Expression, FunctionLikeDeclarationBase, JSDocContainer, LocalsContainer, FlowContainer {
|
||||
readonly kind: SyntaxKind.ArrowFunction;
|
||||
readonly modifiers?: NodeArray<Modifier>;
|
||||
readonly equalsGreaterThanToken: EqualsGreaterThanToken;
|
||||
@@ -1291,13 +1296,13 @@ declare namespace ts {
|
||||
interface ObjectLiteralExpressionBase<T extends ObjectLiteralElement> extends PrimaryExpression, Declaration {
|
||||
readonly properties: NodeArray<T>;
|
||||
}
|
||||
interface ObjectLiteralExpression extends ObjectLiteralExpressionBase<ObjectLiteralElementLike> {
|
||||
interface ObjectLiteralExpression extends ObjectLiteralExpressionBase<ObjectLiteralElementLike>, JSDocContainer {
|
||||
readonly kind: SyntaxKind.ObjectLiteralExpression;
|
||||
}
|
||||
type EntityNameExpression = Identifier | PropertyAccessEntityNameExpression;
|
||||
type EntityNameOrEntityNameExpression = EntityName | EntityNameExpression;
|
||||
type AccessExpression = PropertyAccessExpression | ElementAccessExpression;
|
||||
interface PropertyAccessExpression extends MemberExpression, NamedDeclaration {
|
||||
interface PropertyAccessExpression extends MemberExpression, NamedDeclaration, JSDocContainer, FlowContainer {
|
||||
readonly kind: SyntaxKind.PropertyAccessExpression;
|
||||
readonly expression: LeftHandSideExpression;
|
||||
readonly questionDotToken?: QuestionDotToken;
|
||||
@@ -1316,7 +1321,7 @@ declare namespace ts {
|
||||
readonly expression: EntityNameExpression;
|
||||
readonly name: Identifier;
|
||||
}
|
||||
interface ElementAccessExpression extends MemberExpression {
|
||||
interface ElementAccessExpression extends MemberExpression, Declaration, JSDocContainer, FlowContainer {
|
||||
readonly kind: SyntaxKind.ElementAccessExpression;
|
||||
readonly expression: LeftHandSideExpression;
|
||||
readonly questionDotToken?: QuestionDotToken;
|
||||
@@ -1386,7 +1391,7 @@ declare namespace ts {
|
||||
interface NonNullChain extends NonNullExpression {
|
||||
_optionalChainBrand: any;
|
||||
}
|
||||
interface MetaProperty extends PrimaryExpression {
|
||||
interface MetaProperty extends PrimaryExpression, FlowContainer {
|
||||
readonly kind: SyntaxKind.MetaProperty;
|
||||
readonly keywordToken: SyntaxKind.NewKeyword | SyntaxKind.ImportKeyword;
|
||||
readonly name: Identifier;
|
||||
@@ -1479,7 +1484,7 @@ declare namespace ts {
|
||||
interface EmptyStatement extends Statement {
|
||||
readonly kind: SyntaxKind.EmptyStatement;
|
||||
}
|
||||
interface DebuggerStatement extends Statement {
|
||||
interface DebuggerStatement extends Statement, FlowContainer {
|
||||
readonly kind: SyntaxKind.DebuggerStatement;
|
||||
}
|
||||
interface MissingDeclaration extends DeclarationStatement {
|
||||
@@ -1487,20 +1492,20 @@ declare namespace ts {
|
||||
readonly name?: Identifier;
|
||||
}
|
||||
type BlockLike = SourceFile | Block | ModuleBlock | CaseOrDefaultClause;
|
||||
interface Block extends Statement {
|
||||
interface Block extends Statement, LocalsContainer {
|
||||
readonly kind: SyntaxKind.Block;
|
||||
readonly statements: NodeArray<Statement>;
|
||||
}
|
||||
interface VariableStatement extends Statement {
|
||||
interface VariableStatement extends Statement, FlowContainer {
|
||||
readonly kind: SyntaxKind.VariableStatement;
|
||||
readonly modifiers?: NodeArray<Modifier>;
|
||||
readonly declarationList: VariableDeclarationList;
|
||||
}
|
||||
interface ExpressionStatement extends Statement {
|
||||
interface ExpressionStatement extends Statement, FlowContainer {
|
||||
readonly kind: SyntaxKind.ExpressionStatement;
|
||||
readonly expression: Expression;
|
||||
}
|
||||
interface IfStatement extends Statement {
|
||||
interface IfStatement extends Statement, FlowContainer {
|
||||
readonly kind: SyntaxKind.IfStatement;
|
||||
readonly expression: Expression;
|
||||
readonly thenStatement: Statement;
|
||||
@@ -1509,58 +1514,58 @@ declare namespace ts {
|
||||
interface IterationStatement extends Statement {
|
||||
readonly statement: Statement;
|
||||
}
|
||||
interface DoStatement extends IterationStatement {
|
||||
interface DoStatement extends IterationStatement, FlowContainer {
|
||||
readonly kind: SyntaxKind.DoStatement;
|
||||
readonly expression: Expression;
|
||||
}
|
||||
interface WhileStatement extends IterationStatement {
|
||||
interface WhileStatement extends IterationStatement, FlowContainer {
|
||||
readonly kind: SyntaxKind.WhileStatement;
|
||||
readonly expression: Expression;
|
||||
}
|
||||
type ForInitializer = VariableDeclarationList | Expression;
|
||||
interface ForStatement extends IterationStatement {
|
||||
interface ForStatement extends IterationStatement, LocalsContainer, FlowContainer {
|
||||
readonly kind: SyntaxKind.ForStatement;
|
||||
readonly initializer?: ForInitializer;
|
||||
readonly condition?: Expression;
|
||||
readonly incrementor?: Expression;
|
||||
}
|
||||
type ForInOrOfStatement = ForInStatement | ForOfStatement;
|
||||
interface ForInStatement extends IterationStatement {
|
||||
interface ForInStatement extends IterationStatement, LocalsContainer, FlowContainer {
|
||||
readonly kind: SyntaxKind.ForInStatement;
|
||||
readonly initializer: ForInitializer;
|
||||
readonly expression: Expression;
|
||||
}
|
||||
interface ForOfStatement extends IterationStatement {
|
||||
interface ForOfStatement extends IterationStatement, LocalsContainer, FlowContainer {
|
||||
readonly kind: SyntaxKind.ForOfStatement;
|
||||
readonly awaitModifier?: AwaitKeyword;
|
||||
readonly initializer: ForInitializer;
|
||||
readonly expression: Expression;
|
||||
}
|
||||
interface BreakStatement extends Statement {
|
||||
interface BreakStatement extends Statement, FlowContainer {
|
||||
readonly kind: SyntaxKind.BreakStatement;
|
||||
readonly label?: Identifier;
|
||||
}
|
||||
interface ContinueStatement extends Statement {
|
||||
interface ContinueStatement extends Statement, FlowContainer {
|
||||
readonly kind: SyntaxKind.ContinueStatement;
|
||||
readonly label?: Identifier;
|
||||
}
|
||||
type BreakOrContinueStatement = BreakStatement | ContinueStatement;
|
||||
interface ReturnStatement extends Statement {
|
||||
interface ReturnStatement extends Statement, FlowContainer {
|
||||
readonly kind: SyntaxKind.ReturnStatement;
|
||||
readonly expression?: Expression;
|
||||
}
|
||||
interface WithStatement extends Statement {
|
||||
interface WithStatement extends Statement, FlowContainer {
|
||||
readonly kind: SyntaxKind.WithStatement;
|
||||
readonly expression: Expression;
|
||||
readonly statement: Statement;
|
||||
}
|
||||
interface SwitchStatement extends Statement {
|
||||
interface SwitchStatement extends Statement, FlowContainer {
|
||||
readonly kind: SyntaxKind.SwitchStatement;
|
||||
readonly expression: Expression;
|
||||
readonly caseBlock: CaseBlock;
|
||||
possiblyExhaustive?: boolean;
|
||||
}
|
||||
interface CaseBlock extends Node {
|
||||
interface CaseBlock extends Node, LocalsContainer {
|
||||
readonly kind: SyntaxKind.CaseBlock;
|
||||
readonly parent: SwitchStatement;
|
||||
readonly clauses: NodeArray<CaseOrDefaultClause>;
|
||||
@@ -1577,22 +1582,22 @@ declare namespace ts {
|
||||
readonly statements: NodeArray<Statement>;
|
||||
}
|
||||
type CaseOrDefaultClause = CaseClause | DefaultClause;
|
||||
interface LabeledStatement extends Statement {
|
||||
interface LabeledStatement extends Statement, FlowContainer {
|
||||
readonly kind: SyntaxKind.LabeledStatement;
|
||||
readonly label: Identifier;
|
||||
readonly statement: Statement;
|
||||
}
|
||||
interface ThrowStatement extends Statement {
|
||||
interface ThrowStatement extends Statement, FlowContainer {
|
||||
readonly kind: SyntaxKind.ThrowStatement;
|
||||
readonly expression: Expression;
|
||||
}
|
||||
interface TryStatement extends Statement {
|
||||
interface TryStatement extends Statement, FlowContainer {
|
||||
readonly kind: SyntaxKind.TryStatement;
|
||||
readonly tryBlock: Block;
|
||||
readonly catchClause?: CatchClause;
|
||||
readonly finallyBlock?: Block;
|
||||
}
|
||||
interface CatchClause extends Node {
|
||||
interface CatchClause extends Node, LocalsContainer {
|
||||
readonly kind: SyntaxKind.CatchClause;
|
||||
readonly parent: TryStatement;
|
||||
readonly variableDeclaration?: VariableDeclaration;
|
||||
@@ -1642,7 +1647,7 @@ declare namespace ts {
|
||||
readonly token: SyntaxKind.ExtendsKeyword | SyntaxKind.ImplementsKeyword;
|
||||
readonly types: NodeArray<ExpressionWithTypeArguments>;
|
||||
}
|
||||
interface TypeAliasDeclaration extends DeclarationStatement, JSDocContainer {
|
||||
interface TypeAliasDeclaration extends DeclarationStatement, JSDocContainer, LocalsContainer {
|
||||
readonly kind: SyntaxKind.TypeAliasDeclaration;
|
||||
readonly modifiers?: NodeArray<Modifier>;
|
||||
readonly name: Identifier;
|
||||
@@ -1663,7 +1668,7 @@ declare namespace ts {
|
||||
}
|
||||
type ModuleName = Identifier | StringLiteral;
|
||||
type ModuleBody = NamespaceBody | JSDocNamespaceBody;
|
||||
interface ModuleDeclaration extends DeclarationStatement, JSDocContainer {
|
||||
interface ModuleDeclaration extends DeclarationStatement, JSDocContainer, LocalsContainer {
|
||||
readonly kind: SyntaxKind.ModuleDeclaration;
|
||||
readonly parent: ModuleBody | SourceFile;
|
||||
readonly modifiers?: NodeArray<Modifier>;
|
||||
@@ -1879,7 +1884,7 @@ declare namespace ts {
|
||||
readonly kind: SyntaxKind.JSDocOptionalType;
|
||||
readonly type: TypeNode;
|
||||
}
|
||||
interface JSDocFunctionType extends JSDocType, SignatureDeclarationBase {
|
||||
interface JSDocFunctionType extends JSDocType, SignatureDeclarationBase, LocalsContainer {
|
||||
readonly kind: SyntaxKind.JSDocFunctionType;
|
||||
}
|
||||
interface JSDocVariadicType extends JSDocType {
|
||||
@@ -1965,7 +1970,7 @@ declare namespace ts {
|
||||
interface JSDocOverrideTag extends JSDocTag {
|
||||
readonly kind: SyntaxKind.JSDocOverrideTag;
|
||||
}
|
||||
interface JSDocEnumTag extends JSDocTag, Declaration {
|
||||
interface JSDocEnumTag extends JSDocTag, Declaration, LocalsContainer {
|
||||
readonly kind: SyntaxKind.JSDocEnumTag;
|
||||
readonly parent: JSDoc;
|
||||
readonly typeExpression: JSDocTypeExpression;
|
||||
@@ -1991,14 +1996,14 @@ declare namespace ts {
|
||||
readonly kind: SyntaxKind.JSDocTypeTag;
|
||||
readonly typeExpression: JSDocTypeExpression;
|
||||
}
|
||||
interface JSDocTypedefTag extends JSDocTag, NamedDeclaration {
|
||||
interface JSDocTypedefTag extends JSDocTag, NamedDeclaration, LocalsContainer {
|
||||
readonly kind: SyntaxKind.JSDocTypedefTag;
|
||||
readonly parent: JSDoc;
|
||||
readonly fullName?: JSDocNamespaceDeclaration | Identifier;
|
||||
readonly name?: Identifier;
|
||||
readonly typeExpression?: JSDocTypeExpression | JSDocTypeLiteral;
|
||||
}
|
||||
interface JSDocCallbackTag extends JSDocTag, NamedDeclaration {
|
||||
interface JSDocCallbackTag extends JSDocTag, NamedDeclaration, LocalsContainer {
|
||||
readonly kind: SyntaxKind.JSDocCallbackTag;
|
||||
readonly parent: JSDoc;
|
||||
readonly fullName?: JSDocNamespaceDeclaration | Identifier;
|
||||
@@ -2009,7 +2014,7 @@ declare namespace ts {
|
||||
readonly kind: SyntaxKind.JSDocThrowsTag;
|
||||
readonly typeExpression?: JSDocTypeExpression;
|
||||
}
|
||||
interface JSDocSignature extends JSDocType, Declaration {
|
||||
interface JSDocSignature extends JSDocType, Declaration, JSDocContainer, LocalsContainer {
|
||||
readonly kind: SyntaxKind.JSDocSignature;
|
||||
readonly typeParameters?: readonly JSDocTemplateTag[];
|
||||
readonly parameters: readonly JSDocParameterTag[];
|
||||
@@ -2029,7 +2034,7 @@ declare namespace ts {
|
||||
interface JSDocParameterTag extends JSDocPropertyLikeTag {
|
||||
readonly kind: SyntaxKind.JSDocParameterTag;
|
||||
}
|
||||
interface JSDocTypeLiteral extends JSDocType {
|
||||
interface JSDocTypeLiteral extends JSDocType, Declaration {
|
||||
readonly kind: SyntaxKind.JSDocTypeLiteral;
|
||||
readonly jsDocPropertyTags?: readonly JSDocPropertyLikeTag[];
|
||||
/** If true, then this type literal represents an *array* of its type. */
|
||||
@@ -2109,7 +2114,7 @@ declare namespace ts {
|
||||
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
|
||||
}
|
||||
type ResolutionMode = ModuleKind.ESNext | ModuleKind.CommonJS | undefined;
|
||||
interface SourceFile extends Declaration {
|
||||
interface SourceFile extends Declaration, LocalsContainer {
|
||||
readonly kind: SyntaxKind.SourceFile;
|
||||
readonly statements: NodeArray<Statement>;
|
||||
readonly endOfFileToken: Token<SyntaxKind.EndOfFileToken>;
|
||||
@@ -3535,11 +3540,12 @@ declare namespace ts {
|
||||
createToken(token: SyntaxKind.NullKeyword): NullLiteral;
|
||||
createToken(token: SyntaxKind.TrueKeyword): TrueLiteral;
|
||||
createToken(token: SyntaxKind.FalseKeyword): FalseLiteral;
|
||||
createToken(token: SyntaxKind.EndOfFileToken): EndOfFileToken;
|
||||
createToken(token: SyntaxKind.Unknown): Token<SyntaxKind.Unknown>;
|
||||
createToken<TKind extends PunctuationSyntaxKind>(token: TKind): PunctuationToken<TKind>;
|
||||
createToken<TKind extends KeywordTypeSyntaxKind>(token: TKind): KeywordTypeNode<TKind>;
|
||||
createToken<TKind extends ModifierSyntaxKind>(token: TKind): ModifierToken<TKind>;
|
||||
createToken<TKind extends KeywordSyntaxKind>(token: TKind): KeywordToken<TKind>;
|
||||
createToken<TKind extends SyntaxKind.Unknown | SyntaxKind.EndOfFileToken>(token: TKind): Token<TKind>;
|
||||
createSuper(): SuperExpression;
|
||||
createThis(): ThisExpression;
|
||||
createNull(): NullLiteral;
|
||||
|
||||
@@ -9,4 +9,7 @@ class C {
|
||||
}
|
||||
[this.bar()]() { }
|
||||
>[this.bar()] : Symbol(C[this.bar()], Decl(computedPropertyNames21_ES5.ts, 3, 5))
|
||||
>this.bar : Symbol(C.bar, Decl(computedPropertyNames21_ES5.ts, 0, 9))
|
||||
>this : Symbol(C, Decl(computedPropertyNames21_ES5.ts, 0, 0))
|
||||
>bar : Symbol(C.bar, Decl(computedPropertyNames21_ES5.ts, 0, 9))
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@ class C {
|
||||
}
|
||||
[this.bar()]() { }
|
||||
>[this.bar()] : () => void
|
||||
>this.bar() : any
|
||||
>this.bar : any
|
||||
>this : any
|
||||
>bar : any
|
||||
>this.bar() : number
|
||||
>this.bar : () => number
|
||||
>this : this
|
||||
>bar : () => number
|
||||
}
|
||||
|
||||
@@ -9,4 +9,7 @@ class C {
|
||||
}
|
||||
[this.bar()]() { }
|
||||
>[this.bar()] : Symbol(C[this.bar()], Decl(computedPropertyNames21_ES6.ts, 3, 5))
|
||||
>this.bar : Symbol(C.bar, Decl(computedPropertyNames21_ES6.ts, 0, 9))
|
||||
>this : Symbol(C, Decl(computedPropertyNames21_ES6.ts, 0, 0))
|
||||
>bar : Symbol(C.bar, Decl(computedPropertyNames21_ES6.ts, 0, 9))
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@ class C {
|
||||
}
|
||||
[this.bar()]() { }
|
||||
>[this.bar()] : () => void
|
||||
>this.bar() : any
|
||||
>this.bar : any
|
||||
>this : any
|
||||
>bar : any
|
||||
>this.bar() : number
|
||||
>this.bar : () => number
|
||||
>this : this
|
||||
>bar : () => number
|
||||
}
|
||||
|
||||
@@ -14,6 +14,9 @@ class C {
|
||||
|
||||
{ [this.bar()]: 1 }[0]
|
||||
>[this.bar()] : Symbol([this.bar()], Decl(computedPropertyNames23_ES5.ts, 5, 9))
|
||||
>this.bar : Symbol(C.bar, Decl(computedPropertyNames23_ES5.ts, 0, 9))
|
||||
>this : Symbol(C, Decl(computedPropertyNames23_ES5.ts, 0, 0))
|
||||
>bar : Symbol(C.bar, Decl(computedPropertyNames23_ES5.ts, 0, 9))
|
||||
|
||||
]() { }
|
||||
}
|
||||
|
||||
@@ -15,10 +15,10 @@ class C {
|
||||
>{ [this.bar()]: 1 }[0] : number
|
||||
>{ [this.bar()]: 1 } : { [x: number]: number; }
|
||||
>[this.bar()] : number
|
||||
>this.bar() : any
|
||||
>this.bar : any
|
||||
>this : any
|
||||
>bar : any
|
||||
>this.bar() : number
|
||||
>this.bar : () => number
|
||||
>this : this
|
||||
>bar : () => number
|
||||
>1 : 1
|
||||
>0 : 0
|
||||
|
||||
|
||||
@@ -14,6 +14,9 @@ class C {
|
||||
|
||||
{ [this.bar()]: 1 }[0]
|
||||
>[this.bar()] : Symbol([this.bar()], Decl(computedPropertyNames23_ES6.ts, 5, 9))
|
||||
>this.bar : Symbol(C.bar, Decl(computedPropertyNames23_ES6.ts, 0, 9))
|
||||
>this : Symbol(C, Decl(computedPropertyNames23_ES6.ts, 0, 0))
|
||||
>bar : Symbol(C.bar, Decl(computedPropertyNames23_ES6.ts, 0, 9))
|
||||
|
||||
]() { }
|
||||
}
|
||||
|
||||
@@ -15,10 +15,10 @@ class C {
|
||||
>{ [this.bar()]: 1 }[0] : number
|
||||
>{ [this.bar()]: 1 } : { [x: number]: number; }
|
||||
>[this.bar()] : number
|
||||
>this.bar() : any
|
||||
>this.bar : any
|
||||
>this : any
|
||||
>bar : any
|
||||
>this.bar() : number
|
||||
>this.bar : () => number
|
||||
>this : this
|
||||
>bar : () => number
|
||||
>1 : 1
|
||||
>0 : 0
|
||||
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers12.ts(4,16): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers12.ts(4,17): error TS2465: 'this' cannot be referenced in a computed property name.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers12.ts(4,22): error TS2339: Property 'c' does not exist on type 'typeof Inner'.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers12.ts(5,9): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers12.ts(5,10): error TS2465: 'this' cannot be referenced in a computed property name.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers12.ts(5,15): error TS2339: Property 'c' does not exist on type 'Inner'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers12.ts (4 errors) ====
|
||||
==== tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers12.ts (6 errors) ====
|
||||
class C {
|
||||
static readonly c: "foo" = "foo"
|
||||
static bar = class Inner {
|
||||
@@ -13,11 +15,15 @@ tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInSta
|
||||
!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type.
|
||||
~~~~
|
||||
!!! error TS2465: 'this' cannot be referenced in a computed property name.
|
||||
~
|
||||
!!! error TS2339: Property 'c' does not exist on type 'typeof Inner'.
|
||||
[this.c] = 123;
|
||||
~~~~~~~~
|
||||
!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type.
|
||||
~~~~
|
||||
!!! error TS2465: 'this' cannot be referenced in a computed property name.
|
||||
~
|
||||
!!! error TS2339: Property 'c' does not exist on type 'Inner'.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,9 +11,11 @@ class C {
|
||||
|
||||
static [this.c] = 123;
|
||||
>[this.c] : Symbol(Inner[this.c], Decl(typeOfThisInStaticMembers12.ts, 2, 31))
|
||||
>this : Symbol(Inner, Decl(typeOfThisInStaticMembers12.ts, 2, 16))
|
||||
|
||||
[this.c] = 123;
|
||||
>[this.c] : Symbol(Inner[this.c], Decl(typeOfThisInStaticMembers12.ts, 3, 30))
|
||||
>this : Symbol(Inner, Decl(typeOfThisInStaticMembers12.ts, 2, 16))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,14 +14,14 @@ class C {
|
||||
static [this.c] = 123;
|
||||
>[this.c] : number
|
||||
>this.c : any
|
||||
>this : any
|
||||
>this : typeof Inner
|
||||
>c : any
|
||||
>123 : 123
|
||||
|
||||
[this.c] = 123;
|
||||
>[this.c] : number
|
||||
>this.c : any
|
||||
>this : any
|
||||
>this : this
|
||||
>c : any
|
||||
>123 : 123
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers12.ts(4,16): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers12.ts(4,17): error TS2465: 'this' cannot be referenced in a computed property name.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers12.ts(4,22): error TS2339: Property 'c' does not exist on type 'typeof Inner'.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers12.ts(5,9): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers12.ts(5,10): error TS2465: 'this' cannot be referenced in a computed property name.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers12.ts(5,15): error TS2339: Property 'c' does not exist on type 'Inner'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers12.ts (4 errors) ====
|
||||
==== tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers12.ts (6 errors) ====
|
||||
class C {
|
||||
static readonly c: "foo" = "foo"
|
||||
static bar = class Inner {
|
||||
@@ -13,11 +15,15 @@ tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInSta
|
||||
!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type.
|
||||
~~~~
|
||||
!!! error TS2465: 'this' cannot be referenced in a computed property name.
|
||||
~
|
||||
!!! error TS2339: Property 'c' does not exist on type 'typeof Inner'.
|
||||
[this.c] = 123;
|
||||
~~~~~~~~
|
||||
!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type.
|
||||
~~~~
|
||||
!!! error TS2465: 'this' cannot be referenced in a computed property name.
|
||||
~
|
||||
!!! error TS2339: Property 'c' does not exist on type 'Inner'.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,9 +11,11 @@ class C {
|
||||
|
||||
static [this.c] = 123;
|
||||
>[this.c] : Symbol(Inner[this.c], Decl(typeOfThisInStaticMembers12.ts, 2, 31))
|
||||
>this : Symbol(Inner, Decl(typeOfThisInStaticMembers12.ts, 2, 16))
|
||||
|
||||
[this.c] = 123;
|
||||
>[this.c] : Symbol(Inner[this.c], Decl(typeOfThisInStaticMembers12.ts, 3, 30))
|
||||
>this : Symbol(Inner, Decl(typeOfThisInStaticMembers12.ts, 2, 16))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,14 +14,14 @@ class C {
|
||||
static [this.c] = 123;
|
||||
>[this.c] : number
|
||||
>this.c : any
|
||||
>this : any
|
||||
>this : typeof Inner
|
||||
>c : any
|
||||
>123 : 123
|
||||
|
||||
[this.c] = 123;
|
||||
>[this.c] : number
|
||||
>this.c : any
|
||||
>this : any
|
||||
>this : this
|
||||
>c : any
|
||||
>123 : 123
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers12.ts(4,16): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers12.ts(4,17): error TS2465: 'this' cannot be referenced in a computed property name.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers12.ts(4,22): error TS2339: Property 'c' does not exist on type 'typeof Inner'.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers12.ts(5,9): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers12.ts(5,10): error TS2465: 'this' cannot be referenced in a computed property name.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers12.ts(5,15): error TS2339: Property 'c' does not exist on type 'Inner'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers12.ts (4 errors) ====
|
||||
==== tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers12.ts (6 errors) ====
|
||||
class C {
|
||||
static readonly c: "foo" = "foo"
|
||||
static bar = class Inner {
|
||||
@@ -13,11 +15,15 @@ tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInSta
|
||||
!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type.
|
||||
~~~~
|
||||
!!! error TS2465: 'this' cannot be referenced in a computed property name.
|
||||
~
|
||||
!!! error TS2339: Property 'c' does not exist on type 'typeof Inner'.
|
||||
[this.c] = 123;
|
||||
~~~~~~~~
|
||||
!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type.
|
||||
~~~~
|
||||
!!! error TS2465: 'this' cannot be referenced in a computed property name.
|
||||
~
|
||||
!!! error TS2339: Property 'c' does not exist on type 'Inner'.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,9 +11,11 @@ class C {
|
||||
|
||||
static [this.c] = 123;
|
||||
>[this.c] : Symbol(Inner[this.c], Decl(typeOfThisInStaticMembers12.ts, 2, 31))
|
||||
>this : Symbol(Inner, Decl(typeOfThisInStaticMembers12.ts, 2, 16))
|
||||
|
||||
[this.c] = 123;
|
||||
>[this.c] : Symbol(Inner[this.c], Decl(typeOfThisInStaticMembers12.ts, 3, 30))
|
||||
>this : Symbol(Inner, Decl(typeOfThisInStaticMembers12.ts, 2, 16))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,14 +14,14 @@ class C {
|
||||
static [this.c] = 123;
|
||||
>[this.c] : number
|
||||
>this.c : any
|
||||
>this : any
|
||||
>this : typeof Inner
|
||||
>c : any
|
||||
>123 : 123
|
||||
|
||||
[this.c] = 123;
|
||||
>[this.c] : number
|
||||
>this.c : any
|
||||
>this : any
|
||||
>this : this
|
||||
>c : any
|
||||
>123 : 123
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers12.ts(4,16): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers12.ts(4,17): error TS2465: 'this' cannot be referenced in a computed property name.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers12.ts(4,22): error TS2339: Property 'c' does not exist on type 'typeof Inner'.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers12.ts(5,9): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers12.ts(5,10): error TS2465: 'this' cannot be referenced in a computed property name.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers12.ts(5,15): error TS2339: Property 'c' does not exist on type 'Inner'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers12.ts (4 errors) ====
|
||||
==== tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers12.ts (6 errors) ====
|
||||
class C {
|
||||
static readonly c: "foo" = "foo"
|
||||
static bar = class Inner {
|
||||
@@ -13,11 +15,15 @@ tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInSta
|
||||
!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type.
|
||||
~~~~
|
||||
!!! error TS2465: 'this' cannot be referenced in a computed property name.
|
||||
~
|
||||
!!! error TS2339: Property 'c' does not exist on type 'typeof Inner'.
|
||||
[this.c] = 123;
|
||||
~~~~~~~~
|
||||
!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type.
|
||||
~~~~
|
||||
!!! error TS2465: 'this' cannot be referenced in a computed property name.
|
||||
~
|
||||
!!! error TS2339: Property 'c' does not exist on type 'Inner'.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,9 +11,11 @@ class C {
|
||||
|
||||
static [this.c] = 123;
|
||||
>[this.c] : Symbol(Inner[this.c], Decl(typeOfThisInStaticMembers12.ts, 2, 31))
|
||||
>this : Symbol(Inner, Decl(typeOfThisInStaticMembers12.ts, 2, 16))
|
||||
|
||||
[this.c] = 123;
|
||||
>[this.c] : Symbol(Inner[this.c], Decl(typeOfThisInStaticMembers12.ts, 3, 30))
|
||||
>this : Symbol(Inner, Decl(typeOfThisInStaticMembers12.ts, 2, 16))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,14 +14,14 @@ class C {
|
||||
static [this.c] = 123;
|
||||
>[this.c] : number
|
||||
>this.c : any
|
||||
>this : any
|
||||
>this : typeof Inner
|
||||
>c : any
|
||||
>123 : 123
|
||||
|
||||
[this.c] = 123;
|
||||
>[this.c] : number
|
||||
>this.c : any
|
||||
>this : any
|
||||
>this : this
|
||||
>c : any
|
||||
>123 : 123
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers13.ts(4,16): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers13.ts(4,17): error TS2465: 'this' cannot be referenced in a computed property name.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers13.ts(4,22): error TS2339: Property 'c' does not exist on type 'typeof Inner'.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers13.ts(5,9): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers13.ts(5,10): error TS2465: 'this' cannot be referenced in a computed property name.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers13.ts(5,15): error TS2339: Property 'c' does not exist on type 'Inner'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers13.ts (4 errors) ====
|
||||
==== tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers13.ts (6 errors) ====
|
||||
class C {
|
||||
static readonly c: "foo" = "foo"
|
||||
static bar = class Inner {
|
||||
@@ -13,11 +15,15 @@ tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInSta
|
||||
!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type.
|
||||
~~~~
|
||||
!!! error TS2465: 'this' cannot be referenced in a computed property name.
|
||||
~
|
||||
!!! error TS2339: Property 'c' does not exist on type 'typeof Inner'.
|
||||
[this.c] = 123;
|
||||
~~~~~~~~
|
||||
!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type.
|
||||
~~~~
|
||||
!!! error TS2465: 'this' cannot be referenced in a computed property name.
|
||||
~
|
||||
!!! error TS2339: Property 'c' does not exist on type 'Inner'.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,9 +11,11 @@ class C {
|
||||
|
||||
static [this.c] = 123;
|
||||
>[this.c] : Symbol(Inner[this.c], Decl(typeOfThisInStaticMembers13.ts, 2, 31))
|
||||
>this : Symbol(Inner, Decl(typeOfThisInStaticMembers13.ts, 2, 16))
|
||||
|
||||
[this.c] = 123;
|
||||
>[this.c] : Symbol(Inner[this.c], Decl(typeOfThisInStaticMembers13.ts, 3, 30))
|
||||
>this : Symbol(Inner, Decl(typeOfThisInStaticMembers13.ts, 2, 16))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,14 +14,14 @@ class C {
|
||||
static [this.c] = 123;
|
||||
>[this.c] : number
|
||||
>this.c : any
|
||||
>this : any
|
||||
>this : typeof Inner
|
||||
>c : any
|
||||
>123 : 123
|
||||
|
||||
[this.c] = 123;
|
||||
>[this.c] : number
|
||||
>this.c : any
|
||||
>this : any
|
||||
>this : this
|
||||
>c : any
|
||||
>123 : 123
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers13.ts(4,16): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers13.ts(4,17): error TS2465: 'this' cannot be referenced in a computed property name.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers13.ts(4,22): error TS2339: Property 'c' does not exist on type 'typeof Inner'.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers13.ts(5,9): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers13.ts(5,10): error TS2465: 'this' cannot be referenced in a computed property name.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers13.ts(5,15): error TS2339: Property 'c' does not exist on type 'Inner'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers13.ts (4 errors) ====
|
||||
==== tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers13.ts (6 errors) ====
|
||||
class C {
|
||||
static readonly c: "foo" = "foo"
|
||||
static bar = class Inner {
|
||||
@@ -13,11 +15,15 @@ tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInSta
|
||||
!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type.
|
||||
~~~~
|
||||
!!! error TS2465: 'this' cannot be referenced in a computed property name.
|
||||
~
|
||||
!!! error TS2339: Property 'c' does not exist on type 'typeof Inner'.
|
||||
[this.c] = 123;
|
||||
~~~~~~~~
|
||||
!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type.
|
||||
~~~~
|
||||
!!! error TS2465: 'this' cannot be referenced in a computed property name.
|
||||
~
|
||||
!!! error TS2339: Property 'c' does not exist on type 'Inner'.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,9 +11,11 @@ class C {
|
||||
|
||||
static [this.c] = 123;
|
||||
>[this.c] : Symbol(Inner[this.c], Decl(typeOfThisInStaticMembers13.ts, 2, 31))
|
||||
>this : Symbol(Inner, Decl(typeOfThisInStaticMembers13.ts, 2, 16))
|
||||
|
||||
[this.c] = 123;
|
||||
>[this.c] : Symbol(Inner[this.c], Decl(typeOfThisInStaticMembers13.ts, 3, 30))
|
||||
>this : Symbol(Inner, Decl(typeOfThisInStaticMembers13.ts, 2, 16))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,14 +14,14 @@ class C {
|
||||
static [this.c] = 123;
|
||||
>[this.c] : number
|
||||
>this.c : any
|
||||
>this : any
|
||||
>this : typeof Inner
|
||||
>c : any
|
||||
>123 : 123
|
||||
|
||||
[this.c] = 123;
|
||||
>[this.c] : number
|
||||
>this.c : any
|
||||
>this : any
|
||||
>this : this
|
||||
>c : any
|
||||
>123 : 123
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers13.ts(4,16): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers13.ts(4,17): error TS2465: 'this' cannot be referenced in a computed property name.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers13.ts(4,22): error TS2339: Property 'c' does not exist on type 'typeof Inner'.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers13.ts(5,9): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers13.ts(5,10): error TS2465: 'this' cannot be referenced in a computed property name.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers13.ts(5,15): error TS2339: Property 'c' does not exist on type 'Inner'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers13.ts (4 errors) ====
|
||||
==== tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers13.ts (6 errors) ====
|
||||
class C {
|
||||
static readonly c: "foo" = "foo"
|
||||
static bar = class Inner {
|
||||
@@ -13,11 +15,15 @@ tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInSta
|
||||
!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type.
|
||||
~~~~
|
||||
!!! error TS2465: 'this' cannot be referenced in a computed property name.
|
||||
~
|
||||
!!! error TS2339: Property 'c' does not exist on type 'typeof Inner'.
|
||||
[this.c] = 123;
|
||||
~~~~~~~~
|
||||
!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type.
|
||||
~~~~
|
||||
!!! error TS2465: 'this' cannot be referenced in a computed property name.
|
||||
~
|
||||
!!! error TS2339: Property 'c' does not exist on type 'Inner'.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,9 +11,11 @@ class C {
|
||||
|
||||
static [this.c] = 123;
|
||||
>[this.c] : Symbol(Inner[this.c], Decl(typeOfThisInStaticMembers13.ts, 2, 31))
|
||||
>this : Symbol(Inner, Decl(typeOfThisInStaticMembers13.ts, 2, 16))
|
||||
|
||||
[this.c] = 123;
|
||||
>[this.c] : Symbol(Inner[this.c], Decl(typeOfThisInStaticMembers13.ts, 3, 30))
|
||||
>this : Symbol(Inner, Decl(typeOfThisInStaticMembers13.ts, 2, 16))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,14 +14,14 @@ class C {
|
||||
static [this.c] = 123;
|
||||
>[this.c] : number
|
||||
>this.c : any
|
||||
>this : any
|
||||
>this : typeof Inner
|
||||
>c : any
|
||||
>123 : 123
|
||||
|
||||
[this.c] = 123;
|
||||
>[this.c] : number
|
||||
>this.c : any
|
||||
>this : any
|
||||
>this : this
|
||||
>c : any
|
||||
>123 : 123
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers13.ts(4,16): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers13.ts(4,17): error TS2465: 'this' cannot be referenced in a computed property name.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers13.ts(4,22): error TS2339: Property 'c' does not exist on type 'typeof Inner'.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers13.ts(5,9): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers13.ts(5,10): error TS2465: 'this' cannot be referenced in a computed property name.
|
||||
tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers13.ts(5,15): error TS2339: Property 'c' does not exist on type 'Inner'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers13.ts (4 errors) ====
|
||||
==== tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers13.ts (6 errors) ====
|
||||
class C {
|
||||
static readonly c: "foo" = "foo"
|
||||
static bar = class Inner {
|
||||
@@ -13,11 +15,15 @@ tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInSta
|
||||
!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type.
|
||||
~~~~
|
||||
!!! error TS2465: 'this' cannot be referenced in a computed property name.
|
||||
~
|
||||
!!! error TS2339: Property 'c' does not exist on type 'typeof Inner'.
|
||||
[this.c] = 123;
|
||||
~~~~~~~~
|
||||
!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type.
|
||||
~~~~
|
||||
!!! error TS2465: 'this' cannot be referenced in a computed property name.
|
||||
~
|
||||
!!! error TS2339: Property 'c' does not exist on type 'Inner'.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,9 +11,11 @@ class C {
|
||||
|
||||
static [this.c] = 123;
|
||||
>[this.c] : Symbol(Inner[this.c], Decl(typeOfThisInStaticMembers13.ts, 2, 31))
|
||||
>this : Symbol(Inner, Decl(typeOfThisInStaticMembers13.ts, 2, 16))
|
||||
|
||||
[this.c] = 123;
|
||||
>[this.c] : Symbol(Inner[this.c], Decl(typeOfThisInStaticMembers13.ts, 3, 30))
|
||||
>this : Symbol(Inner, Decl(typeOfThisInStaticMembers13.ts, 2, 16))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,14 +14,14 @@ class C {
|
||||
static [this.c] = 123;
|
||||
>[this.c] : number
|
||||
>this.c : any
|
||||
>this : any
|
||||
>this : typeof Inner
|
||||
>c : any
|
||||
>123 : 123
|
||||
|
||||
[this.c] = 123;
|
||||
>[this.c] : number
|
||||
>this.c : any
|
||||
>this : any
|
||||
>this : this
|
||||
>c : any
|
||||
>123 : 123
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user