Skip to content

Commit 8af777e

Browse files
committed
Switch synthetic call to use use 'resolveSignature' flow
1 parent 559047e commit 8af777e

File tree

6 files changed

+153
-131
lines changed

6 files changed

+153
-131
lines changed

src/compiler/checker.ts

+126-116
Large diffs are not rendered by default.

src/compiler/factory/nodeFactory.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -6212,12 +6212,11 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode
62126212
//
62136213

62146214
// @api
6215-
function createSyntheticExpression(type: Type, isSpread = false, tupleNameSource?: ParameterDeclaration | NamedTupleMember, thisArgument?: LeftHandSideExpression) {
6215+
function createSyntheticExpression(type: Type, isSpread = false, tupleNameSource?: ParameterDeclaration | NamedTupleMember) {
62166216
const node = createBaseNode<SyntheticExpression>(SyntaxKind.SyntheticExpression);
62176217
node.type = type;
62186218
node.isSpread = isSpread;
62196219
node.tupleNameSource = tupleNameSource;
6220-
node.thisArgument = thisArgument;
62216220
return node;
62226221
}
62236222

src/compiler/types.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -2453,12 +2453,11 @@ export interface YieldExpression extends Expression {
24532453
readonly expression?: Expression;
24542454
}
24552455

2456-
export interface SyntheticExpression extends LeftHandSideExpression {
2456+
export interface SyntheticExpression extends Expression {
24572457
readonly kind: SyntaxKind.SyntheticExpression;
24582458
readonly isSpread: boolean;
24592459
readonly type: Type;
24602460
readonly tupleNameSource?: ParameterDeclaration | NamedTupleMember;
2461-
readonly thisArgument?: LeftHandSideExpression;
24622461
}
24632462

24642463
// see: https://tc39.github.io/ecma262/#prod-ExponentiationExpression
@@ -3048,12 +3047,18 @@ export interface TaggedTemplateExpression extends MemberExpression {
30483047
/** @internal */ questionDotToken?: QuestionDotToken; // NOTE: Invalid syntax, only used to report a grammar error.
30493048
}
30503049

3050+
export interface InstanceofExpression extends BinaryExpression {
3051+
readonly operatorToken: Token<SyntaxKind.InstanceOfKeyword>;
3052+
}
3053+
30513054
export type CallLikeExpression =
30523055
| CallExpression
30533056
| NewExpression
30543057
| TaggedTemplateExpression
30553058
| Decorator
3056-
| JsxOpeningLikeElement;
3059+
| JsxOpeningLikeElement
3060+
| InstanceofExpression
3061+
;
30573062

30583063
export interface AsExpression extends Expression {
30593064
readonly kind: SyntaxKind.AsExpression;
@@ -6500,11 +6505,6 @@ export interface PromiseOrAwaitableType extends ObjectType, UnionType {
65006505
awaitedTypeOfType?: Type;
65016506
}
65026507

6503-
/** @internal */
6504-
export interface HasInstanceMethodType extends Type {
6505-
hasSimpleUnrestrictedSingleCallSignature?: boolean;
6506-
}
6507-
65086508
/** @internal */
65096509
export interface SyntheticDefaultModuleType extends Type {
65106510
syntheticType?: Type;
@@ -8789,7 +8789,7 @@ export interface NodeFactory {
87898789
//
87908790
// Synthetic Nodes
87918791
//
8792-
/** @internal */ createSyntheticExpression(type: Type, isSpread?: boolean, tupleNameSource?: ParameterDeclaration | NamedTupleMember, thisArgument?: LeftHandSideExpression): SyntheticExpression;
8792+
/** @internal */ createSyntheticExpression(type: Type, isSpread?: boolean, tupleNameSource?: ParameterDeclaration | NamedTupleMember): SyntheticExpression;
87938793
/** @internal */ createSyntaxList(children: Node[]): SyntaxList;
87948794

87958795
//

src/compiler/utilities.ts

+12
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ import {
231231
IndexSignatureDeclaration,
232232
InitializedVariableDeclaration,
233233
insertSorted,
234+
InstanceofExpression,
234235
InterfaceDeclaration,
235236
InternalEmitFlags,
236237
isAccessor,
@@ -3149,6 +3150,8 @@ export function getInvokedExpression(node: CallLikeExpression): Expression | Jsx
31493150
case SyntaxKind.JsxOpeningElement:
31503151
case SyntaxKind.JsxSelfClosingElement:
31513152
return node.tagName;
3153+
case SyntaxKind.BinaryExpression:
3154+
return node.right;
31523155
default:
31533156
return node.expression;
31543157
}
@@ -7269,6 +7272,15 @@ export function isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName(node
72697272
|| isPropertyAccessExpression(node.parent) && node.parent.name === node
72707273
|| isJSDocMemberName(node.parent) && node.parent.right === node;
72717274
}
7275+
/** @internal */
7276+
export function isInstanceOfExpression(node: Node): node is InstanceofExpression {
7277+
return isBinaryExpression(node) && node.operatorToken.kind === SyntaxKind.InstanceOfKeyword;
7278+
}
7279+
7280+
/** @internal */
7281+
export function isRightSideOfInstanceofExpression(node: Node) {
7282+
return isInstanceOfExpression(node.parent) && node === node.parent.right;
7283+
}
72727284

72737285
/** @internal */
72747286
export function isEmptyObjectLiteral(expression: Node): boolean {

src/compiler/utilitiesPublic.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1976,7 +1976,6 @@ function isLeftHandSideExpressionKind(kind: SyntaxKind): boolean {
19761976
case SyntaxKind.MetaProperty:
19771977
case SyntaxKind.ImportKeyword: // technically this is only an Expression if it's in a CallExpression
19781978
case SyntaxKind.MissingDeclaration:
1979-
case SyntaxKind.SyntheticExpression: // synthetic expressions are only used by the checker to substitute specific types for expression positions, so their precedence does not matter.
19801979
return true;
19811980
default:
19821981
return false;

tests/baselines/reference/api/typescript.d.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -5358,12 +5358,11 @@ declare namespace ts {
53585358
readonly asteriskToken?: AsteriskToken;
53595359
readonly expression?: Expression;
53605360
}
5361-
interface SyntheticExpression extends LeftHandSideExpression {
5361+
interface SyntheticExpression extends Expression {
53625362
readonly kind: SyntaxKind.SyntheticExpression;
53635363
readonly isSpread: boolean;
53645364
readonly type: Type;
53655365
readonly tupleNameSource?: ParameterDeclaration | NamedTupleMember;
5366-
readonly thisArgument?: LeftHandSideExpression;
53675366
}
53685367
type ExponentiationOperator = SyntaxKind.AsteriskAsteriskToken;
53695368
type MultiplicativeOperator = SyntaxKind.AsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken;
@@ -5587,7 +5586,10 @@ declare namespace ts {
55875586
readonly typeArguments?: NodeArray<TypeNode>;
55885587
readonly template: TemplateLiteral;
55895588
}
5590-
type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator | JsxOpeningLikeElement;
5589+
interface InstanceofExpression extends BinaryExpression {
5590+
readonly operatorToken: Token<SyntaxKind.InstanceOfKeyword>;
5591+
}
5592+
type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator | JsxOpeningLikeElement | InstanceofExpression;
55915593
interface AsExpression extends Expression {
55925594
readonly kind: SyntaxKind.AsExpression;
55935595
readonly expression: Expression;

0 commit comments

Comments
 (0)