tsc-ts 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/compiler/ast.d.ts +57 -18
- package/dist/api/compiler/ast.js +134 -39
- package/dist/api/compiler/binder-utilities.js +2 -2
- package/dist/api/compiler/binder.js +6 -6
- package/dist/api/compiler/checker-calls.js +4 -4
- package/dist/api/compiler/checker-contextual.js +1 -1
- package/dist/api/compiler/checker-emit-helpers.d.ts +2 -1
- package/dist/api/compiler/checker-emit-helpers.js +5 -4
- package/dist/api/compiler/checker-grammar.js +5 -5
- package/dist/api/compiler/checker-inference.d.ts +20 -10
- package/dist/api/compiler/checker-inference.js +48 -25
- package/dist/api/compiler/checker-members.d.ts +27 -0
- package/dist/api/compiler/checker-members.js +165 -0
- package/dist/api/compiler/checker-modules.d.ts +14 -0
- package/dist/api/compiler/checker-modules.js +73 -1
- package/dist/api/compiler/checker.d.ts +16 -0
- package/dist/api/compiler/checker.js +17 -0
- package/dist/api/compiler/diagnostics.js +9 -5
- package/dist/api/compiler/parallel-parse.js +3 -1
- package/dist/api/compiler/parser.js +33 -23
- package/dist/api/compiler/printer/factory-base.js +8 -8
- package/dist/api/compiler/printer/factory.js +4 -4
- package/dist/api/compiler/printer/printer.js +6 -6
- package/dist/api/compiler/program-checker.d.ts +5 -0
- package/dist/api/compiler/program-checker.js +11 -1
- package/dist/api/compiler/relations.js +8 -3
- package/dist/api/compiler/reparser.js +13 -5
- package/dist/api/compiler/transformers/class-fields.js +3 -3
- package/dist/api/compiler/transformers/commonjs-module.js +3 -3
- package/dist/api/compiler/transformers/declarations-pseudo.js +2 -2
- package/dist/api/compiler/transformers/module.js +2 -2
- package/dist/api/compiler/transformers/optional-chain.js +3 -3
- package/dist/api/compiler/transformers/subtree-facts.js +2 -2
- package/dist/api/compiler/transformers/tagged-template.js +2 -2
- package/dist/api/compiler/transformers/type-eraser.js +2 -2
- package/dist/api/compiler/transformers/visitor-base.js +3 -3
- package/dist/api/compiler/tsconfig.js +2 -2
- package/package.json +8 -8
- package/src/compiler/ast.ts +184 -59
- package/src/compiler/binder-utilities.ts +2 -1
- package/src/compiler/binder.ts +11 -5
- package/src/compiler/checker-calls.ts +5 -3
- package/src/compiler/checker-contextual.ts +1 -1
- package/src/compiler/checker-emit-helpers.ts +5 -4
- package/src/compiler/checker-grammar.ts +5 -3
- package/src/compiler/checker-inference.ts +49 -25
- package/src/compiler/checker-members.ts +164 -0
- package/src/compiler/checker-modules.ts +92 -1
- package/src/compiler/checker.ts +19 -0
- package/src/compiler/decoder.ts +5 -4
- package/src/compiler/diagnostics.ts +10 -5
- package/src/compiler/encoder.ts +10 -5
- package/src/compiler/parallel-parse.ts +3 -1
- package/src/compiler/parser.ts +53 -23
- package/src/compiler/printer/factory-base.ts +14 -7
- package/src/compiler/printer/factory.ts +5 -3
- package/src/compiler/printer/printer.ts +8 -6
- package/src/compiler/program-checker.ts +10 -1
- package/src/compiler/relations.ts +10 -2
- package/src/compiler/reparser.ts +14 -4
- package/src/compiler/transformers/class-fields.ts +12 -2
- package/src/compiler/transformers/commonjs-module.ts +3 -2
- package/src/compiler/transformers/declarations-pseudo.ts +2 -1
- package/src/compiler/transformers/declarations.ts +1 -1
- package/src/compiler/transformers/module.ts +2 -1
- package/src/compiler/transformers/optional-chain.ts +5 -2
- package/src/compiler/transformers/subtree-facts.ts +2 -1
- package/src/compiler/transformers/tagged-template.ts +2 -2
- package/src/compiler/transformers/type-eraser.ts +2 -1
- package/src/compiler/transformers/visitor-base.ts +10 -5
- package/src/compiler/tsconfig.ts +2 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Removes TypeScript-only syntax: type annotations and declarations, `declare`d statements,
|
|
2
2
|
// type-only imports and exports, and modifiers such as `public` and `readonly`.
|
|
3
|
-
import { CallExpression, ClassDeclaration, ClassExpression, ConstructorDeclaration, ExportDeclaration, ExportSpecifier, ExpressionWithTypeArguments, FunctionDeclaration, FunctionExpression, GetAccessorDeclaration, HeritageClause, Identifier, ImportClause, ImportDeclaration, ImportAttributes, ImportEqualsDeclaration, ImportSpecifier, JsxAttributes, JsxOpeningElement, JsxSelfClosingElement, MethodDeclaration, ModuleDeclaration, NamedExports, NamedImports, NewExpression, ParameterDeclaration, ParenthesizedExpression, PartiallyEmittedExpression, PropertyDeclaration, SetAccessorDeclaration, TaggedTemplateExpression, VariableDeclaration, ArrowFunction, getExpression, } from '../ast.js';
|
|
3
|
+
import { CallExpression, ClassDeclaration, ClassExpression, ConstructorDeclaration, ExportDeclaration, ExportSpecifier, ExpressionWithTypeArguments, FunctionDeclaration, FunctionExpression, GetAccessorDeclaration, HeritageClause, Identifier, ImportClause, ImportDeclaration, ImportAttributes, ImportEqualsDeclaration, ImportSpecifier, JsxAttributes, JsxOpeningElement, JsxSelfClosingElement, MethodDeclaration, ModuleDeclaration, NamedExports, NamedImports, NewExpression, ParameterDeclaration, ParenthesizedExpression, PartiallyEmittedExpression, PropertyDeclaration, SetAccessorDeclaration, TaggedTemplateExpression, VariableDeclaration, ArrowFunction, getExpression, callQuestionDotToken, } from '../ast.js';
|
|
4
4
|
import { nodeIsMissing } from '../ast-utilities.js';
|
|
5
5
|
import { shouldPreserveConstEnums } from '../options.js';
|
|
6
6
|
import { isStatement } from '../printer/utilities.js';
|
|
@@ -176,7 +176,7 @@ export class TypeEraser extends Transformer {
|
|
|
176
176
|
break;
|
|
177
177
|
case 214 /* SyntaxKind.CallExpression */:
|
|
178
178
|
if (node instanceof CallExpression)
|
|
179
|
-
return factory.updateCallExpression(node, this.required(node.expression), node
|
|
179
|
+
return factory.updateCallExpression(node, this.required(node.expression), callQuestionDotToken(node), undefined, this.visitNodes(node.arguments), node.flags);
|
|
180
180
|
break;
|
|
181
181
|
case 215 /* SyntaxKind.NewExpression */:
|
|
182
182
|
if (node instanceof NewExpression)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Generated by scripts/generate-visitor.mjs; do not edit.
|
|
2
|
-
import { ArrayLiteralExpression, ArrayTypeNode, ArrowFunction, AsExpression, AwaitExpression, BinaryExpression, BindingElement, BindingPattern, Block, BreakStatement, CallExpression, CallSignatureDeclaration, CaseBlock, CaseOrDefaultClause, CatchClause, ClassDeclaration, ClassExpression, ClassStaticBlockDeclaration, ComputedPropertyName, ConditionalExpression, ConditionalTypeNode, ConstructSignatureDeclaration, ConstructorDeclaration, ConstructorTypeNode, ContinueStatement, Decorator, DeleteExpression, DoStatement, ElementAccessExpression, EnumDeclaration, EnumMember, ExportAssignment, ExportDeclaration, ExportSpecifier, ExpressionStatement, ExpressionWithTypeArguments, ExternalModuleReference, ForInOrOfStatement, ForStatement, FunctionDeclaration, FunctionExpression, FunctionTypeNode, GetAccessorDeclaration, HeritageClause, Identifier, IfStatement, ImportAttribute, ImportAttributes, ImportClause, ImportDeclaration, ImportEqualsDeclaration, ImportSpecifier, ImportTypeNode, IndexSignatureDeclaration, IndexedAccessTypeNode, InferTypeNode, InterfaceDeclaration, IntersectionTypeNode, JSDoc, JSDocAugmentsTag, JSDocCallbackTag, JSDocDeprecatedTag, JSDocImplementsTag, JSDocImportTag, JSDocLink, JSDocLinkCode, JSDocLinkPlain, JSDocNameReference, JSDocNonNullableType, JSDocNullableType, JSDocOptionalType, JSDocOverloadTag, JSDocOverrideTag, JSDocParameterOrPropertyTag, JSDocPrivateTag, JSDocProtectedTag, JSDocPublicTag, JSDocReadonlyTag, JSDocReturnTag, JSDocSatisfiesTag, JSDocSeeTag, JSDocSignature, JSDocTemplateTag, JSDocThisTag, JSDocThrowsTag, JSDocTypeExpression, JSDocTypeTag, JSDocTypedefTag, JSDocUnknownTag, JSDocVariadicType, JsxAttribute, JsxAttributes, JsxClosingElement, JsxClosingFragment, JsxElement, JsxExpression, JsxFragment, JsxNamespacedName, JsxOpeningElement, JsxOpeningFragment, JsxSelfClosingElement, JsxSpreadAttribute, LabeledStatement, LiteralTypeNode, MappedTypeNode, MetaProperty, MethodDeclaration, MethodSignatureDeclaration, MissingDeclaration, ModuleBlock, ModuleDeclaration, NamedExports, NamedImports, NamedTupleMember, NamespaceExport, NamespaceExportDeclaration, NamespaceImport, NewExpression, NonNullExpression, ObjectLiteralExpression, OptionalTypeNode, ParameterDeclaration, ParenthesizedExpression, ParenthesizedTypeNode, PartiallyEmittedExpression, PostfixUnaryExpression, PrefixUnaryExpression, PropertyAccessExpression, PropertyAssignment, PropertyDeclaration, PropertySignatureDeclaration, QualifiedName, RestTypeNode, ReturnStatement, SatisfiesExpression, SetAccessorDeclaration, ShorthandPropertyAssignment, SourceFile, SpreadAssignment, SpreadElement, SwitchStatement, SyntheticReferenceExpression, TaggedTemplateExpression, TemplateExpression, TemplateHead, TemplateLiteralTypeNode, TemplateLiteralTypeSpan, TemplateSpan, ThrowStatement, Token, TryStatement, TupleTypeNode, TypeAliasDeclaration, TypeAssertion, TypeLiteralNode, TypeOfExpression, TypeOperatorNode, TypeParameterDeclaration, TypePredicateNode, TypeQueryNode, TypeReferenceNode, UnionTypeNode, VariableDeclaration, VariableDeclarationList, VariableStatement, VoidExpression, WhileStatement, WithStatement, YieldExpression, } from '../ast.js';
|
|
2
|
+
import { ArrayLiteralExpression, ArrayTypeNode, ArrowFunction, AsExpression, AwaitExpression, BinaryExpression, BindingElement, BindingPattern, Block, BreakStatement, CallExpression, CallSignatureDeclaration, CaseBlock, CaseOrDefaultClause, CatchClause, ClassDeclaration, ClassExpression, ClassStaticBlockDeclaration, ComputedPropertyName, ConditionalExpression, ConditionalTypeNode, ConstructSignatureDeclaration, ConstructorDeclaration, ConstructorTypeNode, ContinueStatement, Decorator, DeleteExpression, DoStatement, ElementAccessExpression, EnumDeclaration, EnumMember, ExportAssignment, ExportDeclaration, ExportSpecifier, ExpressionStatement, ExpressionWithTypeArguments, ExternalModuleReference, ForInOrOfStatement, ForStatement, FunctionDeclaration, FunctionExpression, FunctionTypeNode, GetAccessorDeclaration, HeritageClause, Identifier, IfStatement, ImportAttribute, ImportAttributes, ImportClause, ImportDeclaration, ImportEqualsDeclaration, ImportSpecifier, ImportTypeNode, IndexSignatureDeclaration, IndexedAccessTypeNode, InferTypeNode, InterfaceDeclaration, IntersectionTypeNode, JSDoc, JSDocAugmentsTag, JSDocCallbackTag, JSDocDeprecatedTag, JSDocImplementsTag, JSDocImportTag, JSDocLink, JSDocLinkCode, JSDocLinkPlain, JSDocNameReference, JSDocNonNullableType, JSDocNullableType, JSDocOptionalType, JSDocOverloadTag, JSDocOverrideTag, JSDocParameterOrPropertyTag, JSDocPrivateTag, JSDocProtectedTag, JSDocPublicTag, JSDocReadonlyTag, JSDocReturnTag, JSDocSatisfiesTag, JSDocSeeTag, JSDocSignature, JSDocTemplateTag, JSDocThisTag, JSDocThrowsTag, JSDocTypeExpression, JSDocTypeTag, JSDocTypedefTag, JSDocUnknownTag, JSDocVariadicType, JsxAttribute, JsxAttributes, JsxClosingElement, JsxClosingFragment, JsxElement, JsxExpression, JsxFragment, JsxNamespacedName, JsxOpeningElement, JsxOpeningFragment, JsxSelfClosingElement, JsxSpreadAttribute, LabeledStatement, LiteralTypeNode, MappedTypeNode, MetaProperty, MethodDeclaration, MethodSignatureDeclaration, MissingDeclaration, ModuleBlock, ModuleDeclaration, NamedExports, NamedImports, NamedTupleMember, NamespaceExport, NamespaceExportDeclaration, NamespaceImport, NewExpression, NonNullExpression, ObjectLiteralExpression, OptionalTypeNode, ParameterDeclaration, ParenthesizedExpression, ParenthesizedTypeNode, PartiallyEmittedExpression, PostfixUnaryExpression, PrefixUnaryExpression, PropertyAccessExpression, PropertyAssignment, PropertyDeclaration, PropertySignatureDeclaration, QualifiedName, RestTypeNode, ReturnStatement, SatisfiesExpression, SetAccessorDeclaration, ShorthandPropertyAssignment, SourceFile, SpreadAssignment, SpreadElement, SwitchStatement, SyntheticReferenceExpression, TaggedTemplateExpression, TemplateExpression, TemplateHead, TemplateLiteralTypeNode, TemplateLiteralTypeSpan, TemplateSpan, ThrowStatement, Token, TryStatement, TupleTypeNode, TypeAliasDeclaration, TypeAssertion, TypeLiteralNode, TypeOfExpression, TypeOperatorNode, TypeParameterDeclaration, TypePredicateNode, TypeQueryNode, TypeReferenceNode, UnionTypeNode, VariableDeclaration, VariableDeclarationList, VariableStatement, VoidExpression, WhileStatement, WithStatement, YieldExpression, propertyAssignmentPostfixToken, propertyAssignmentType, callQuestionDotToken, propertyAssignmentModifiers, callTypeArguments, } from '../ast.js';
|
|
3
3
|
import { VisitorHooks } from './visitor-hooks.js';
|
|
4
4
|
// A removed required child keeps the original, as tsgo's nil child is never printed.
|
|
5
5
|
function required(node, original) {
|
|
@@ -192,7 +192,7 @@ export class VisitorBase extends VisitorHooks {
|
|
|
192
192
|
break;
|
|
193
193
|
case 214 /* SyntaxKind.CallExpression */:
|
|
194
194
|
if (node instanceof CallExpression)
|
|
195
|
-
return this.factory.updateCallExpression(node, required(this.visitNode(node.expression), node.expression), asOptionalToken(this.visitNode(node
|
|
195
|
+
return this.factory.updateCallExpression(node, required(this.visitNode(node.expression), node.expression), asOptionalToken(this.visitNode(callQuestionDotToken(node))), this.visitNodes(callTypeArguments(node)), this.visitNodes(node.arguments), node.flags);
|
|
196
196
|
break;
|
|
197
197
|
case 180 /* SyntaxKind.CallSignature */:
|
|
198
198
|
if (node instanceof CallSignatureDeclaration)
|
|
@@ -656,7 +656,7 @@ export class VisitorBase extends VisitorHooks {
|
|
|
656
656
|
break;
|
|
657
657
|
case 303 /* SyntaxKind.PropertyAssignment */:
|
|
658
658
|
if (node instanceof PropertyAssignment)
|
|
659
|
-
return this.factory.updatePropertyAssignment(node, this.visitModifiers(node
|
|
659
|
+
return this.factory.updatePropertyAssignment(node, this.visitModifiers(propertyAssignmentModifiers(node)), required(this.visitNode(node.name), node.name), asOptionalToken(this.visitNode(propertyAssignmentPostfixToken(node))), this.visitNode(propertyAssignmentType(node)), required(this.visitNode(node.initializer), node.initializer));
|
|
660
660
|
break;
|
|
661
661
|
case 173 /* SyntaxKind.PropertyDeclaration */:
|
|
662
662
|
if (node instanceof PropertyDeclaration)
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* const config = new ConfigParser(fs, '/app').parseConfigFile('/app/tsconfig.json', {}, undefined, errors);
|
|
7
7
|
* ```
|
|
8
8
|
*/
|
|
9
|
-
import { ArrayLiteralExpression, ComputedPropertyName, ExpressionStatement, ExternalModuleIndicatorOptions, getText, Identifier, NumericLiteral, ObjectLiteralExpression, ParseOptions, PrefixUnaryExpression, PropertyAssignment, StringLiteral, } from './ast.js';
|
|
9
|
+
import { ArrayLiteralExpression, ComputedPropertyName, ExpressionStatement, ExternalModuleIndicatorOptions, getText, Identifier, NumericLiteral, ObjectLiteralExpression, ParseOptions, PrefixUnaryExpression, PropertyAssignment, StringLiteral, propertyAssignmentPostfixToken, } from './ast.js';
|
|
10
10
|
import { enumNamesList } from './command-line.js';
|
|
11
11
|
import { compareCodePoints, createCompilerDiagnostic, Diagnostic, } from './diagnostics.js';
|
|
12
12
|
import { isValidLocale } from './locale.js';
|
|
@@ -767,7 +767,7 @@ class ConfigFileConverter {
|
|
|
767
767
|
this.errors.push(diagnosticAtRange(this.file, element, 102 /* Diagnostics.Property_assignment_expected */));
|
|
768
768
|
continue;
|
|
769
769
|
}
|
|
770
|
-
const postfix = element
|
|
770
|
+
const postfix = propertyAssignmentPostfixToken(element);
|
|
771
771
|
if (postfix !== undefined && postfix.kind === 57 /* SyntaxKind.QuestionToken */) {
|
|
772
772
|
this.errors.push(diagnosticAtRange(this.file, postfix, 1741 /* Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files */, '?'));
|
|
773
773
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tsc-ts",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "The TypeScript 7 compiler, ported to TypeScript and compiled to a native executable.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -35,12 +35,12 @@
|
|
|
35
35
|
"node": ">=20"
|
|
36
36
|
},
|
|
37
37
|
"optionalDependencies": {
|
|
38
|
-
"@tsc-ts/darwin-arm64": "0.0.
|
|
39
|
-
"@tsc-ts/darwin-x64": "0.0.
|
|
40
|
-
"@tsc-ts/linux-arm64-gnu": "0.0.
|
|
41
|
-
"@tsc-ts/linux-arm64-musl": "0.0.
|
|
42
|
-
"@tsc-ts/linux-x64-gnu": "0.0.
|
|
43
|
-
"@tsc-ts/linux-x64-musl": "0.0.
|
|
44
|
-
"@tsc-ts/win32-x64-msvc": "0.0.
|
|
38
|
+
"@tsc-ts/darwin-arm64": "0.0.7",
|
|
39
|
+
"@tsc-ts/darwin-x64": "0.0.7",
|
|
40
|
+
"@tsc-ts/linux-arm64-gnu": "0.0.7",
|
|
41
|
+
"@tsc-ts/linux-arm64-musl": "0.0.7",
|
|
42
|
+
"@tsc-ts/linux-x64-gnu": "0.0.7",
|
|
43
|
+
"@tsc-ts/linux-x64-musl": "0.0.7",
|
|
44
|
+
"@tsc-ts/win32-x64-msvc": "0.0.7"
|
|
45
45
|
}
|
|
46
46
|
}
|
package/src/compiler/ast.ts
CHANGED
|
@@ -4075,9 +4075,45 @@ export class ElementAccessExpression extends Node {
|
|
|
4075
4075
|
|
|
4076
4076
|
export class CallExpression extends Node {
|
|
4077
4077
|
expression: Expression;
|
|
4078
|
+
arguments: NodeList;
|
|
4079
|
+
|
|
4080
|
+
constructor(expression: Expression, args: NodeList, flags: NodeFlags) {
|
|
4081
|
+
super(SyntaxKind.CallExpression);
|
|
4082
|
+
this.expression = expression;
|
|
4083
|
+
this.arguments = args;
|
|
4084
|
+
this.flags |= flags & NodeFlags.OptionalChain;
|
|
4085
|
+
}
|
|
4086
|
+
|
|
4087
|
+
forEachChild(v: NodeVisitor): boolean {
|
|
4088
|
+
if (v.visitNode(this.expression)) return true;
|
|
4089
|
+
return v.visitList(this.arguments);
|
|
4090
|
+
}
|
|
4091
|
+
|
|
4092
|
+
setParentOfChildren(): void {
|
|
4093
|
+
this.expression.parent = this;
|
|
4094
|
+
setParents(this.arguments.nodes, this);
|
|
4095
|
+
}
|
|
4096
|
+
|
|
4097
|
+
deepClone(): Node {
|
|
4098
|
+
return this.copy();
|
|
4099
|
+
}
|
|
4100
|
+
|
|
4101
|
+
copy(): CallExpression {
|
|
4102
|
+
const node = new CallExpression(this.expression.deepClone(), cloneList(this.arguments), this.flags);
|
|
4103
|
+
node.flags = this.flags;
|
|
4104
|
+
node.pos = this.pos;
|
|
4105
|
+
node.end = this.end;
|
|
4106
|
+
return node;
|
|
4107
|
+
}
|
|
4108
|
+
}
|
|
4109
|
+
|
|
4110
|
+
/**
|
|
4111
|
+
* A call with `?.` or type arguments, or in a JavaScript file, where the binder can declare a symbol
|
|
4112
|
+
* for it (`Object.defineProperty`). Other calls are a plain `CallExpression`, without these fields.
|
|
4113
|
+
*/
|
|
4114
|
+
export class FullCallExpression extends CallExpression {
|
|
4078
4115
|
questionDotToken: Token | undefined;
|
|
4079
4116
|
typeArguments: NodeList | undefined;
|
|
4080
|
-
arguments: NodeList;
|
|
4081
4117
|
// Set by the binder.
|
|
4082
4118
|
symbol: Symbol | undefined;
|
|
4083
4119
|
|
|
@@ -4088,12 +4124,9 @@ export class CallExpression extends Node {
|
|
|
4088
4124
|
args: NodeList,
|
|
4089
4125
|
flags: NodeFlags,
|
|
4090
4126
|
) {
|
|
4091
|
-
super(
|
|
4092
|
-
this.expression = expression;
|
|
4127
|
+
super(expression, args, flags);
|
|
4093
4128
|
this.questionDotToken = questionDotToken;
|
|
4094
4129
|
this.typeArguments = typeArguments;
|
|
4095
|
-
this.arguments = args;
|
|
4096
|
-
this.flags |= flags & NodeFlags.OptionalChain;
|
|
4097
4130
|
this.symbol = undefined;
|
|
4098
4131
|
}
|
|
4099
4132
|
|
|
@@ -4111,12 +4144,8 @@ export class CallExpression extends Node {
|
|
|
4111
4144
|
setParents(this.arguments.nodes, this);
|
|
4112
4145
|
}
|
|
4113
4146
|
|
|
4114
|
-
deepClone(): Node {
|
|
4115
|
-
return this.copy();
|
|
4116
|
-
}
|
|
4117
|
-
|
|
4118
4147
|
copy(): CallExpression {
|
|
4119
|
-
const node = new
|
|
4148
|
+
const node = new FullCallExpression(
|
|
4120
4149
|
this.expression.deepClone(),
|
|
4121
4150
|
this.questionDotToken === undefined ? undefined : this.questionDotToken.copy(),
|
|
4122
4151
|
this.typeArguments === undefined ? undefined : cloneList(this.typeArguments),
|
|
@@ -4130,6 +4159,28 @@ export class CallExpression extends Node {
|
|
|
4130
4159
|
}
|
|
4131
4160
|
}
|
|
4132
4161
|
|
|
4162
|
+
/** A `FullCallExpression` when one of its fields is set or `inJavaScript`, else a `CallExpression`. */
|
|
4163
|
+
export function newCallExpression(
|
|
4164
|
+
expression: Expression,
|
|
4165
|
+
questionDotToken: Token | undefined,
|
|
4166
|
+
typeArguments: NodeList | undefined,
|
|
4167
|
+
args: NodeList,
|
|
4168
|
+
flags: NodeFlags,
|
|
4169
|
+
inJavaScript: boolean,
|
|
4170
|
+
): CallExpression {
|
|
4171
|
+
if (inJavaScript || questionDotToken !== undefined || typeArguments !== undefined)
|
|
4172
|
+
return new FullCallExpression(expression, questionDotToken, typeArguments, args, flags);
|
|
4173
|
+
return new CallExpression(expression, args, flags);
|
|
4174
|
+
}
|
|
4175
|
+
|
|
4176
|
+
export function callQuestionDotToken(node: CallExpression): Token | undefined {
|
|
4177
|
+
return node instanceof FullCallExpression ? node.questionDotToken : undefined;
|
|
4178
|
+
}
|
|
4179
|
+
|
|
4180
|
+
export function callTypeArguments(node: CallExpression): NodeList | undefined {
|
|
4181
|
+
return node instanceof FullCallExpression ? node.typeArguments : undefined;
|
|
4182
|
+
}
|
|
4183
|
+
|
|
4133
4184
|
export class NewExpression extends Node {
|
|
4134
4185
|
expression: Expression;
|
|
4135
4186
|
typeArguments: NodeList | undefined;
|
|
@@ -4511,14 +4562,51 @@ export class SpreadAssignment extends Node {
|
|
|
4511
4562
|
}
|
|
4512
4563
|
|
|
4513
4564
|
export class PropertyAssignment extends Node {
|
|
4514
|
-
modifiers: ModifierList | undefined;
|
|
4515
4565
|
name: PropertyName;
|
|
4516
|
-
postfixToken: Token | undefined;
|
|
4517
|
-
type: TypeNode | undefined;
|
|
4518
4566
|
initializer: Expression;
|
|
4519
4567
|
// Set by the binder.
|
|
4520
4568
|
symbol: Symbol | undefined;
|
|
4521
4569
|
|
|
4570
|
+
constructor(name: PropertyName, initializer: Expression) {
|
|
4571
|
+
super(SyntaxKind.PropertyAssignment);
|
|
4572
|
+
this.name = name;
|
|
4573
|
+
this.initializer = initializer;
|
|
4574
|
+
this.symbol = undefined;
|
|
4575
|
+
}
|
|
4576
|
+
|
|
4577
|
+
forEachChild(v: NodeVisitor): boolean {
|
|
4578
|
+
if (v.visitNode(this.name)) return true;
|
|
4579
|
+
return v.visitNode(this.initializer);
|
|
4580
|
+
}
|
|
4581
|
+
|
|
4582
|
+
setParentOfChildren(): void {
|
|
4583
|
+
this.name.parent = this;
|
|
4584
|
+
this.initializer.parent = this;
|
|
4585
|
+
}
|
|
4586
|
+
|
|
4587
|
+
deepClone(): Node {
|
|
4588
|
+
return this.copy();
|
|
4589
|
+
}
|
|
4590
|
+
|
|
4591
|
+
copy(): PropertyAssignment {
|
|
4592
|
+
const node = new PropertyAssignment(this.name.deepClone(), this.initializer.deepClone());
|
|
4593
|
+
node.flags = this.flags;
|
|
4594
|
+
node.pos = this.pos;
|
|
4595
|
+
node.end = this.end;
|
|
4596
|
+
return node;
|
|
4597
|
+
}
|
|
4598
|
+
}
|
|
4599
|
+
|
|
4600
|
+
/**
|
|
4601
|
+
* A property assignment with modifiers, a `?` or `!`, or a type annotation (which the grammar checker
|
|
4602
|
+
* reports), or in a JavaScript file, where JSDoc can give it a type or modifiers. Other property
|
|
4603
|
+
* assignments are a plain `PropertyAssignment`, without these fields.
|
|
4604
|
+
*/
|
|
4605
|
+
export class FullPropertyAssignment extends PropertyAssignment {
|
|
4606
|
+
modifiers: ModifierList | undefined;
|
|
4607
|
+
postfixToken: Token | undefined;
|
|
4608
|
+
type: TypeNode | undefined;
|
|
4609
|
+
|
|
4522
4610
|
constructor(
|
|
4523
4611
|
modifiers: ModifierList | undefined,
|
|
4524
4612
|
name: PropertyName,
|
|
@@ -4526,13 +4614,10 @@ export class PropertyAssignment extends Node {
|
|
|
4526
4614
|
type: TypeNode | undefined,
|
|
4527
4615
|
initializer: Expression,
|
|
4528
4616
|
) {
|
|
4529
|
-
super(
|
|
4617
|
+
super(name, initializer);
|
|
4530
4618
|
this.modifiers = modifiers;
|
|
4531
|
-
this.name = name;
|
|
4532
4619
|
this.postfixToken = postfixToken;
|
|
4533
4620
|
this.type = type;
|
|
4534
|
-
this.initializer = initializer;
|
|
4535
|
-
this.symbol = undefined;
|
|
4536
4621
|
}
|
|
4537
4622
|
|
|
4538
4623
|
forEachChild(v: NodeVisitor): boolean {
|
|
@@ -4551,12 +4636,8 @@ export class PropertyAssignment extends Node {
|
|
|
4551
4636
|
this.initializer.parent = this;
|
|
4552
4637
|
}
|
|
4553
4638
|
|
|
4554
|
-
deepClone(): Node {
|
|
4555
|
-
return this.copy();
|
|
4556
|
-
}
|
|
4557
|
-
|
|
4558
4639
|
copy(): PropertyAssignment {
|
|
4559
|
-
const node = new
|
|
4640
|
+
const node = new FullPropertyAssignment(
|
|
4560
4641
|
this.modifiers === undefined ? undefined : cloneModifiers(this.modifiers),
|
|
4561
4642
|
this.name.deepClone(),
|
|
4562
4643
|
this.postfixToken === undefined ? undefined : this.postfixToken.copy(),
|
|
@@ -4570,6 +4651,32 @@ export class PropertyAssignment extends Node {
|
|
|
4570
4651
|
}
|
|
4571
4652
|
}
|
|
4572
4653
|
|
|
4654
|
+
/** A `FullPropertyAssignment` when one of its fields is set or `inJavaScript`, else a `PropertyAssignment`. */
|
|
4655
|
+
export function newPropertyAssignment(
|
|
4656
|
+
modifiers: ModifierList | undefined,
|
|
4657
|
+
name: PropertyName,
|
|
4658
|
+
postfixToken: Token | undefined,
|
|
4659
|
+
type: TypeNode | undefined,
|
|
4660
|
+
initializer: Expression,
|
|
4661
|
+
inJavaScript: boolean,
|
|
4662
|
+
): PropertyAssignment {
|
|
4663
|
+
if (inJavaScript || modifiers !== undefined || postfixToken !== undefined || type !== undefined)
|
|
4664
|
+
return new FullPropertyAssignment(modifiers, name, postfixToken, type, initializer);
|
|
4665
|
+
return new PropertyAssignment(name, initializer);
|
|
4666
|
+
}
|
|
4667
|
+
|
|
4668
|
+
export function propertyAssignmentModifiers(node: PropertyAssignment): ModifierList | undefined {
|
|
4669
|
+
return node instanceof FullPropertyAssignment ? node.modifiers : undefined;
|
|
4670
|
+
}
|
|
4671
|
+
|
|
4672
|
+
export function propertyAssignmentPostfixToken(node: PropertyAssignment): Token | undefined {
|
|
4673
|
+
return node instanceof FullPropertyAssignment ? node.postfixToken : undefined;
|
|
4674
|
+
}
|
|
4675
|
+
|
|
4676
|
+
export function propertyAssignmentType(node: PropertyAssignment): TypeNode | undefined {
|
|
4677
|
+
return node instanceof FullPropertyAssignment ? node.type : undefined;
|
|
4678
|
+
}
|
|
4679
|
+
|
|
4573
4680
|
export class ShorthandPropertyAssignment extends Node {
|
|
4574
4681
|
modifiers: ModifierList | undefined;
|
|
4575
4682
|
name: PropertyName;
|
|
@@ -8109,6 +8216,24 @@ export class JSDocParameterOrPropertyTag extends Node {
|
|
|
8109
8216
|
}
|
|
8110
8217
|
}
|
|
8111
8218
|
|
|
8219
|
+
// The lists of a source file that has none. Most files have no diagnostics, references, pragmas
|
|
8220
|
+
// or ambient modules, so they share these instead of holding empty arrays of their own. A list
|
|
8221
|
+
// that grows replaces an empty one rather than pushing to it (appendToList).
|
|
8222
|
+
export const emptyDiagnostics: readonly Diagnostic[] = [];
|
|
8223
|
+
export const emptyNodes: readonly Node[] = [];
|
|
8224
|
+
export const emptyStrings: readonly string[] = [];
|
|
8225
|
+
export const emptyCommentDirectives: readonly CommentDirective[] = [];
|
|
8226
|
+
export const emptyPragmas: readonly Pragma[] = [];
|
|
8227
|
+
export const emptyFileReferences: readonly FileReference[] = [];
|
|
8228
|
+
export const emptyPatternAmbientModules: readonly PatternAmbientModule[] = [];
|
|
8229
|
+
|
|
8230
|
+
/** `list` with `item` appended: a new array when `list` is empty (it may be shared), else `list` itself. */
|
|
8231
|
+
export function appendToList<T>(list: readonly T[], item: T): readonly T[] {
|
|
8232
|
+
if (list.length === 0) return [item];
|
|
8233
|
+
(list as T[]).push(item);
|
|
8234
|
+
return list;
|
|
8235
|
+
}
|
|
8236
|
+
|
|
8112
8237
|
export class SourceFile extends Node {
|
|
8113
8238
|
readonly fileName: string;
|
|
8114
8239
|
readonly path: string;
|
|
@@ -8118,10 +8243,10 @@ export class SourceFile extends Node {
|
|
|
8118
8243
|
endOfFileToken: Token;
|
|
8119
8244
|
|
|
8120
8245
|
// Set by the parser.
|
|
8121
|
-
diagnostics: Diagnostic[];
|
|
8246
|
+
diagnostics: readonly Diagnostic[];
|
|
8122
8247
|
/** Diagnostics for TypeScript-only syntax in JavaScript files. */
|
|
8123
|
-
jsDiagnostics: Diagnostic[];
|
|
8124
|
-
jsDocDiagnostics: Diagnostic[];
|
|
8248
|
+
jsDiagnostics: readonly Diagnostic[];
|
|
8249
|
+
jsDocDiagnostics: readonly Diagnostic[];
|
|
8125
8250
|
languageVariant: LanguageVariant;
|
|
8126
8251
|
scriptKind: ScriptKind;
|
|
8127
8252
|
isDeclarationFile: boolean;
|
|
@@ -8136,20 +8261,20 @@ export class SourceFile extends Node {
|
|
|
8136
8261
|
/** Module specifiers of imports, exports, `require` calls and `import()` types, in source order. */
|
|
8137
8262
|
imports: Node[];
|
|
8138
8263
|
/** Names of `declare module "x"` augmentations and `declare global` blocks in modules. */
|
|
8139
|
-
moduleAugmentations: Node[];
|
|
8140
|
-
ambientModuleNames: string[];
|
|
8264
|
+
moduleAugmentations: readonly Node[];
|
|
8265
|
+
ambientModuleNames: readonly string[];
|
|
8141
8266
|
commentDirectives: readonly CommentDirective[];
|
|
8142
|
-
pragmas: Pragma[];
|
|
8143
|
-
referencedFiles: FileReference[];
|
|
8144
|
-
typeReferenceDirectives: FileReference[];
|
|
8145
|
-
libReferenceDirectives: FileReference[];
|
|
8267
|
+
pragmas: readonly Pragma[];
|
|
8268
|
+
referencedFiles: readonly FileReference[];
|
|
8269
|
+
typeReferenceDirectives: readonly FileReference[];
|
|
8270
|
+
libReferenceDirectives: readonly FileReference[];
|
|
8146
8271
|
checkJsDirective: CheckJsDirective | undefined;
|
|
8147
8272
|
/** The first CommonJS `module.exports`/`exports.x` use in a JavaScript file. */
|
|
8148
8273
|
commonJSModuleIndicator: Node | undefined;
|
|
8149
8274
|
/** What makes this file a module: an import or export statement, `import.meta`, a JSX tag, or the file itself when forced. */
|
|
8150
8275
|
externalModuleIndicator: Node | undefined;
|
|
8151
8276
|
/** Nodes cloned by JSDoc reparsing, sorted by position. */
|
|
8152
|
-
reparsedClones: Node[];
|
|
8277
|
+
reparsedClones: readonly Node[];
|
|
8153
8278
|
/** Whether JSDoc of TypeScript files is parsed on first use. */
|
|
8154
8279
|
hasLazyJSDoc: boolean;
|
|
8155
8280
|
/**
|
|
@@ -8164,12 +8289,12 @@ export class SourceFile extends Node {
|
|
|
8164
8289
|
locals: SymbolTable | undefined;
|
|
8165
8290
|
nextContainer: Node | undefined;
|
|
8166
8291
|
isBound: boolean;
|
|
8167
|
-
bindDiagnostics: Diagnostic[];
|
|
8292
|
+
bindDiagnostics: readonly Diagnostic[];
|
|
8168
8293
|
/** The flow at the end of the file. */
|
|
8169
8294
|
endFlowNode: FlowNode | undefined;
|
|
8170
8295
|
symbolCount: number;
|
|
8171
8296
|
/** Ambient modules with a `*` in their name, like `declare module "*.css"`. */
|
|
8172
|
-
patternAmbientModules: PatternAmbientModule[];
|
|
8297
|
+
patternAmbientModules: readonly PatternAmbientModule[];
|
|
8173
8298
|
/** UMD exports from `export as namespace N`. */
|
|
8174
8299
|
globalExports: SymbolTable | undefined;
|
|
8175
8300
|
|
|
@@ -8188,9 +8313,9 @@ export class SourceFile extends Node {
|
|
|
8188
8313
|
this.externalModuleIndicatorOptions = externalModuleIndicatorOptions;
|
|
8189
8314
|
this.statements = statements;
|
|
8190
8315
|
this.endOfFileToken = endOfFileToken;
|
|
8191
|
-
this.diagnostics =
|
|
8192
|
-
this.jsDiagnostics =
|
|
8193
|
-
this.jsDocDiagnostics =
|
|
8316
|
+
this.diagnostics = emptyDiagnostics;
|
|
8317
|
+
this.jsDiagnostics = emptyDiagnostics;
|
|
8318
|
+
this.jsDocDiagnostics = emptyDiagnostics;
|
|
8194
8319
|
this.languageVariant = 0;
|
|
8195
8320
|
this.scriptKind = ScriptKind.Unknown;
|
|
8196
8321
|
this.isDeclarationFile = false;
|
|
@@ -8201,17 +8326,17 @@ export class SourceFile extends Node {
|
|
|
8201
8326
|
this.nodeCount = 0;
|
|
8202
8327
|
this.textCount = 0;
|
|
8203
8328
|
this.imports = [];
|
|
8204
|
-
this.moduleAugmentations =
|
|
8205
|
-
this.ambientModuleNames =
|
|
8206
|
-
this.commentDirectives =
|
|
8207
|
-
this.pragmas =
|
|
8208
|
-
this.referencedFiles =
|
|
8209
|
-
this.typeReferenceDirectives =
|
|
8210
|
-
this.libReferenceDirectives =
|
|
8329
|
+
this.moduleAugmentations = emptyNodes;
|
|
8330
|
+
this.ambientModuleNames = emptyStrings;
|
|
8331
|
+
this.commentDirectives = emptyCommentDirectives;
|
|
8332
|
+
this.pragmas = emptyPragmas;
|
|
8333
|
+
this.referencedFiles = emptyFileReferences;
|
|
8334
|
+
this.typeReferenceDirectives = emptyFileReferences;
|
|
8335
|
+
this.libReferenceDirectives = emptyFileReferences;
|
|
8211
8336
|
this.checkJsDirective = undefined;
|
|
8212
8337
|
this.commonJSModuleIndicator = undefined;
|
|
8213
8338
|
this.externalModuleIndicator = undefined;
|
|
8214
|
-
this.reparsedClones =
|
|
8339
|
+
this.reparsedClones = emptyNodes;
|
|
8215
8340
|
this.hasLazyJSDoc = false;
|
|
8216
8341
|
this.jsDocs = undefined;
|
|
8217
8342
|
this.diagnosticFileCache = undefined;
|
|
@@ -8219,10 +8344,10 @@ export class SourceFile extends Node {
|
|
|
8219
8344
|
this.locals = undefined;
|
|
8220
8345
|
this.nextContainer = undefined;
|
|
8221
8346
|
this.isBound = false;
|
|
8222
|
-
this.bindDiagnostics =
|
|
8347
|
+
this.bindDiagnostics = emptyDiagnostics;
|
|
8223
8348
|
this.endFlowNode = undefined;
|
|
8224
8349
|
this.symbolCount = 0;
|
|
8225
|
-
this.patternAmbientModules =
|
|
8350
|
+
this.patternAmbientModules = emptyPatternAmbientModules;
|
|
8226
8351
|
this.globalExports = undefined;
|
|
8227
8352
|
}
|
|
8228
8353
|
|
|
@@ -8703,8 +8828,8 @@ export function getModifiers(node: Node): ModifierList | undefined {
|
|
|
8703
8828
|
}
|
|
8704
8829
|
break;
|
|
8705
8830
|
case SyntaxKind.PropertyAssignment:
|
|
8706
|
-
if (node instanceof
|
|
8707
|
-
const holder:
|
|
8831
|
+
if (node instanceof FullPropertyAssignment) {
|
|
8832
|
+
const holder: FullPropertyAssignment = node;
|
|
8708
8833
|
return holder.modifiers;
|
|
8709
8834
|
}
|
|
8710
8835
|
break;
|
|
@@ -9077,8 +9202,8 @@ export function getType(node: Node): Node | undefined {
|
|
|
9077
9202
|
}
|
|
9078
9203
|
break;
|
|
9079
9204
|
case SyntaxKind.PropertyAssignment:
|
|
9080
|
-
if (node instanceof
|
|
9081
|
-
const holder:
|
|
9205
|
+
if (node instanceof FullPropertyAssignment) {
|
|
9206
|
+
const holder: FullPropertyAssignment = node;
|
|
9082
9207
|
return holder.type;
|
|
9083
9208
|
}
|
|
9084
9209
|
break;
|
|
@@ -9566,8 +9691,8 @@ export function getPostfixToken(node: Node): Node | undefined {
|
|
|
9566
9691
|
}
|
|
9567
9692
|
break;
|
|
9568
9693
|
case SyntaxKind.PropertyAssignment:
|
|
9569
|
-
if (node instanceof
|
|
9570
|
-
const holder:
|
|
9694
|
+
if (node instanceof FullPropertyAssignment) {
|
|
9695
|
+
const holder: FullPropertyAssignment = node;
|
|
9571
9696
|
return holder.postfixToken;
|
|
9572
9697
|
}
|
|
9573
9698
|
break;
|
|
@@ -9584,8 +9709,8 @@ export function getPostfixToken(node: Node): Node | undefined {
|
|
|
9584
9709
|
export function getTypeArguments(node: Node): NodeList | undefined {
|
|
9585
9710
|
switch (node.kind) {
|
|
9586
9711
|
case SyntaxKind.CallExpression:
|
|
9587
|
-
if (node instanceof
|
|
9588
|
-
const holder:
|
|
9712
|
+
if (node instanceof FullCallExpression) {
|
|
9713
|
+
const holder: FullCallExpression = node;
|
|
9589
9714
|
return holder.typeArguments;
|
|
9590
9715
|
}
|
|
9591
9716
|
break;
|
|
@@ -10839,8 +10964,8 @@ export function getSymbol(node: Node): Symbol | undefined {
|
|
|
10839
10964
|
}
|
|
10840
10965
|
break;
|
|
10841
10966
|
case SyntaxKind.CallExpression:
|
|
10842
|
-
if (node instanceof
|
|
10843
|
-
const holder:
|
|
10967
|
+
if (node instanceof FullCallExpression) {
|
|
10968
|
+
const holder: FullCallExpression = node;
|
|
10844
10969
|
return holder.symbol;
|
|
10845
10970
|
}
|
|
10846
10971
|
break;
|
|
@@ -11171,8 +11296,8 @@ export function setSymbol(node: Node, value: Symbol | undefined): void {
|
|
|
11171
11296
|
}
|
|
11172
11297
|
break;
|
|
11173
11298
|
case SyntaxKind.CallExpression:
|
|
11174
|
-
if (node instanceof
|
|
11175
|
-
const target:
|
|
11299
|
+
if (node instanceof FullCallExpression) {
|
|
11300
|
+
const target: FullCallExpression = node;
|
|
11176
11301
|
target.symbol = value;
|
|
11177
11302
|
}
|
|
11178
11303
|
break;
|
|
@@ -47,6 +47,7 @@ import {
|
|
|
47
47
|
getTagName,
|
|
48
48
|
getText,
|
|
49
49
|
getType,
|
|
50
|
+
callQuestionDotToken,
|
|
50
51
|
} from './ast.js';
|
|
51
52
|
import { getJSDoc } from './parser.js';
|
|
52
53
|
import { isAssignmentOperator, isLeftHandSideExpression, isStringLiteralLike, nodeIsMissing } from './ast-utilities.js';
|
|
@@ -343,7 +344,7 @@ export function skipParentheses(node: Node): Node {
|
|
|
343
344
|
function getQuestionDotToken(node: Node): Node | undefined {
|
|
344
345
|
if (node instanceof PropertyAccessExpression) return (node as PropertyAccessExpression).questionDotToken;
|
|
345
346
|
if (node instanceof ElementAccessExpression) return (node as ElementAccessExpression).questionDotToken;
|
|
346
|
-
if (node instanceof CallExpression) return (node as CallExpression)
|
|
347
|
+
if (node instanceof CallExpression) return callQuestionDotToken(node as CallExpression);
|
|
347
348
|
if (node instanceof TaggedTemplateExpression) return (node as TaggedTemplateExpression).questionDotToken;
|
|
348
349
|
return undefined;
|
|
349
350
|
}
|
package/src/compiler/binder.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// Fields of `instanceof`-narrowed nodes are read through `as` casts: scriptc reads them
|
|
5
5
|
// statically, but reads fields of a narrowed value dynamically.
|
|
6
6
|
import {
|
|
7
|
+
appendToList,
|
|
7
8
|
BinaryExpression,
|
|
8
9
|
BindingElement,
|
|
9
10
|
CallExpression,
|
|
@@ -72,6 +73,8 @@ import {
|
|
|
72
73
|
setNextContainer,
|
|
73
74
|
setReturnFlowNode,
|
|
74
75
|
setSymbol,
|
|
76
|
+
callQuestionDotToken,
|
|
77
|
+
callTypeArguments,
|
|
75
78
|
} from './ast.js';
|
|
76
79
|
import {
|
|
77
80
|
isAmbientModule,
|
|
@@ -795,7 +798,7 @@ class Binder extends NodeVisitor {
|
|
|
795
798
|
}
|
|
796
799
|
|
|
797
800
|
addDiagnostic(diagnostic: Diagnostic): void {
|
|
798
|
-
this.file.bindDiagnostics.
|
|
801
|
+
this.file.bindDiagnostics = appendToList(this.file.bindDiagnostics, diagnostic);
|
|
799
802
|
}
|
|
800
803
|
|
|
801
804
|
// Traversal
|
|
@@ -1885,8 +1888,8 @@ class Binder extends NodeVisitor {
|
|
|
1885
1888
|
this.bindOptional((node as ElementAccessExpression).questionDotToken);
|
|
1886
1889
|
this.bind((node as ElementAccessExpression).argumentExpression);
|
|
1887
1890
|
} else if (node instanceof CallExpression) {
|
|
1888
|
-
this.bindOptional((node as CallExpression)
|
|
1889
|
-
this.bindNodes((node as CallExpression)
|
|
1891
|
+
this.bindOptional(callQuestionDotToken(node as CallExpression));
|
|
1892
|
+
this.bindNodes(callTypeArguments(node as CallExpression));
|
|
1890
1893
|
this.bindNodes((node as CallExpression).arguments);
|
|
1891
1894
|
}
|
|
1892
1895
|
}
|
|
@@ -1897,7 +1900,7 @@ class Binder extends NodeVisitor {
|
|
|
1897
1900
|
// An IIFE's flow node includes the evaluation of its arguments.
|
|
1898
1901
|
const callee = skipParentheses(node.expression);
|
|
1899
1902
|
if (callee.kind === SyntaxKind.FunctionExpression || callee.kind === SyntaxKind.ArrowFunction) {
|
|
1900
|
-
this.bindNodes(node
|
|
1903
|
+
this.bindNodes(callTypeArguments(node));
|
|
1901
1904
|
this.bindNodes(node.arguments);
|
|
1902
1905
|
this.bind(node.expression);
|
|
1903
1906
|
} else {
|
|
@@ -1973,7 +1976,10 @@ class Binder extends NodeVisitor {
|
|
|
1973
1976
|
if (starIndex >= 0 && text.indexOf('*', starIndex + 1) >= 0)
|
|
1974
1977
|
this.errorOnFirstToken(name, Diagnostics.Pattern_0_can_have_at_most_one_Asterisk_character, [text]);
|
|
1975
1978
|
else if (starIndex >= 0)
|
|
1976
|
-
this.file.patternAmbientModules
|
|
1979
|
+
this.file.patternAmbientModules = appendToList(
|
|
1980
|
+
this.file.patternAmbientModules,
|
|
1981
|
+
new PatternAmbientModule(text, starIndex, symbol),
|
|
1982
|
+
);
|
|
1977
1983
|
}
|
|
1978
1984
|
return;
|
|
1979
1985
|
}
|
|
@@ -25,6 +25,8 @@ import {
|
|
|
25
25
|
getNodeId,
|
|
26
26
|
getBody,
|
|
27
27
|
getSymbol,
|
|
28
|
+
callQuestionDotToken,
|
|
29
|
+
callTypeArguments,
|
|
28
30
|
} from './ast.js';
|
|
29
31
|
import {
|
|
30
32
|
canHaveDecorators,
|
|
@@ -238,7 +240,7 @@ export function checkCallExpression(c: Checker, node: Node, checkMode: CheckMode
|
|
|
238
240
|
return getESSymbolLikeTypeForNode(c, walkUpParenthesizedExpressions(node.parent!));
|
|
239
241
|
// An assertion call must name its target through explicitly typed declarations.
|
|
240
242
|
if (
|
|
241
|
-
call
|
|
243
|
+
callQuestionDotToken(call) === undefined &&
|
|
242
244
|
node.parent!.kind === SyntaxKind.ExpressionStatement &&
|
|
243
245
|
(returnType.flags & TypeFlags.Void) !== 0 &&
|
|
244
246
|
getTypePredicateOfSignature(c, signature) !== undefined
|
|
@@ -368,7 +370,7 @@ function resolveCallExpression(c: Checker, node: CallExpression, checkMode: Chec
|
|
|
368
370
|
const callSignatures = getSignaturesOfType(c, apparentType, SignatureKind.Call);
|
|
369
371
|
const numConstructSignatures = getSignaturesOfType(c, apparentType, SignatureKind.Construct).length;
|
|
370
372
|
if (isUntypedFunctionCall(c, funcType, apparentType, callSignatures.length, numConstructSignatures)) {
|
|
371
|
-
if (!isErrorType(c, funcType) && node
|
|
373
|
+
if (!isErrorType(c, funcType) && callTypeArguments(node) !== undefined)
|
|
372
374
|
c.error(node, Diagnostics.Untyped_function_calls_may_not_accept_type_arguments);
|
|
373
375
|
return resolveUntypedCall(c, node);
|
|
374
376
|
}
|
|
@@ -382,7 +384,7 @@ function resolveCallExpression(c: Checker, node: CallExpression, checkMode: Chec
|
|
|
382
384
|
// inferences can flow through function composition.
|
|
383
385
|
if (
|
|
384
386
|
(checkMode & CheckMode.SkipGenericFunctions) !== 0 &&
|
|
385
|
-
node
|
|
387
|
+
callTypeArguments(node) === undefined &&
|
|
386
388
|
someGenericFunctionReturningFunction(c, callSignatures)
|
|
387
389
|
) {
|
|
388
390
|
skippedGenericFunction(c, node, checkMode);
|
|
@@ -277,7 +277,7 @@ export function checkExpressionWithContextualType(
|
|
|
277
277
|
checkMode | CheckMode.Contextual | (inferenceContext !== undefined ? CheckMode.Inferential : 0),
|
|
278
278
|
);
|
|
279
279
|
// Intra-expression inference sites only matter during this check.
|
|
280
|
-
if (inferenceContext !== undefined) inferenceContext.intraExpressionInferenceSites =
|
|
280
|
+
if (inferenceContext !== undefined) inferenceContext.intraExpressionInferenceSites = undefined;
|
|
281
281
|
// Contextually typed literals keep their literal types rather than widening during inference.
|
|
282
282
|
if (
|
|
283
283
|
maybeTypeOfKind(t, TypeFlags.Literal) &&
|