Skip to content

Commit 72c12c9

Browse files
Isolated declarations fix signature serialization scoping (microsoft#58409)
1 parent 0c1b36f commit 72c12c9

259 files changed

Lines changed: 4756 additions & 3916 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/compiler/checker.ts

Lines changed: 147 additions & 103 deletions
Large diffs are not rendered by default.

src/compiler/utilities.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11106,7 +11106,8 @@ export function createNameResolver({
1110611106
if (meaning & result.flags & SymbolFlags.Type && lastLocation.kind !== SyntaxKind.JSDoc) {
1110711107
useResult = result.flags & SymbolFlags.TypeParameter
1110811108
// type parameters are visible in parameter list, return type and type parameter list
11109-
? lastLocation === (location as FunctionLikeDeclaration).type ||
11109+
? !!(lastLocation.flags & NodeFlags.Synthesized) || // Synthetic fake scopes are added for signatures so type parameters are accessible from them
11110+
lastLocation === (location as FunctionLikeDeclaration).type ||
1111011111
lastLocation.kind === SyntaxKind.Parameter ||
1111111112
lastLocation.kind === SyntaxKind.JSDocParameterTag ||
1111211113
lastLocation.kind === SyntaxKind.JSDocReturnTag ||
@@ -11125,6 +11126,7 @@ export function createNameResolver({
1112511126
// however it is detected separately when checking initializers of parameters
1112611127
// to make sure that they reference no variables declared after them.
1112711128
useResult = lastLocation.kind === SyntaxKind.Parameter ||
11129+
!!(lastLocation.flags & NodeFlags.Synthesized) || // Synthetic fake scopes are added for signatures so parameters are accessible from them
1112811130
(
1112911131
lastLocation === (location as FunctionLikeDeclaration).type &&
1113011132
!!findAncestor(result.valueDeclaration, isParameter)

src/compiler/utilitiesPublic.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2320,7 +2320,8 @@ function isDeclarationKind(kind: SyntaxKind) {
23202320
|| kind === SyntaxKind.VariableDeclaration
23212321
|| kind === SyntaxKind.JSDocTypedefTag
23222322
|| kind === SyntaxKind.JSDocCallbackTag
2323-
|| kind === SyntaxKind.JSDocPropertyTag;
2323+
|| kind === SyntaxKind.JSDocPropertyTag
2324+
|| kind === SyntaxKind.NamedTupleMember;
23242325
}
23252326

23262327
function isDeclarationStatementKind(kind: SyntaxKind) {

tests/baselines/reference/1.0lib-noErrors.types

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2411,8 +2411,8 @@ interface Array<T> {
24112411
> : ^^^^^^
24122412
}
24132413
declare var Array: {
2414-
>Array : { (arrayLength?: number): any[]; <T>(arrayLength: number): T[]; <T_1>(...items: T_1[]): T_1[]; new (arrayLength?: number): any[]; new <T_2>(arrayLength: number): T_2[]; new <T_3>(...items: T_3[]): T_3[]; isArray(arg: any): boolean; prototype: Array<any>; }
2415-
> : ^^^ ^^^ ^^^ ^^^ ^^ ^^ ^^^ ^^^ ^^^^^ ^^ ^^^ ^^^^^^^ ^^^ ^^^ ^^^^^^^ ^^ ^^ ^^^ ^^^^^^^ ^^^^^ ^^ ^^^ ^^^^^^^^^^ ^^ ^^^ ^^^^^^^^^^^^^ ^^^
2414+
>Array : { (arrayLength?: number): any[]; <T>(arrayLength: number): T[]; <T>(...items: T[]): T[]; new (arrayLength?: number): any[]; new <T>(arrayLength: number): T[]; new <T>(...items: T[]): T[]; isArray(arg: any): boolean; prototype: Array<any>; }
2415+
> : ^^^ ^^^ ^^^ ^^^ ^^ ^^ ^^^ ^^^ ^^^^^ ^^ ^^^ ^^^^^^^ ^^^ ^^^ ^^^^^^^ ^^ ^^ ^^^ ^^^^^^^ ^^^^^ ^^ ^^^ ^^^^^^^^^^ ^^ ^^^ ^^^^^^^^^^^^^ ^^^
24162416

24172417
new (arrayLength?: number): any[];
24182418
>arrayLength : number

tests/baselines/reference/argumentsReferenceInFunction1_Js.types

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@ const debuglog = function() {
9292
return format.apply(null, arguments);
9393
>format.apply(null, arguments) : string
9494
> : ^^^^^^
95-
>format.apply : { <T, R>(this: (this: T) => R, thisArg: T): R; <T_1, A extends any[], R_1>(this: (this: T_1, ...args: A) => R_1, thisArg: T_1, args: A): R_1; }
96-
> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^^^^^ ^^ ^^^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^^^^^^^
95+
>format.apply : { <T, R>(this: (this: T) => R, thisArg: T): R; <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T, args: A): R; }
96+
> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^^^^^ ^^ ^^^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^^^^^
9797
>format : (f: any, ...args: any[]) => string
9898
> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
99-
>apply : { <T, R>(this: (this: T) => R, thisArg: T): R; <T_1, A extends any[], R_1>(this: (this: T_1, ...args: A) => R_1, thisArg: T_1, args: A): R_1; }
100-
> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^^^^^ ^^ ^^^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^^^^^^^
99+
>apply : { <T, R>(this: (this: T) => R, thisArg: T): R; <T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T, args: A): R; }
100+
> : ^^^ ^^ ^^ ^^ ^^ ^^ ^^^^^^^ ^^ ^^^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^^^^^
101101
>arguments : IArguments
102102
> : ^^^^^^^^^^
103103

tests/baselines/reference/arrayDestructuringInSwitch1.types

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ export function evaluate(expression: Expression): boolean {
4646
return operands.every((child) => evaluate(child));
4747
>operands.every((child) => evaluate(child)) : boolean
4848
> : ^^^^^^^
49-
>operands.every : { <S extends Expression>(predicate: (value: Expression, index: number, array: Expression[]) => value is S, thisArg?: any): this is S[]; (predicate: (value: Expression, index: number, array: Expression[]) => unknown, thisArg?: any): boolean; } | { <S_1 extends Expression>(predicate: (value: Expression, index: number, array: Expression[]) => value is S_1, thisArg?: any): this is S_1[]; (predicate: (value: Expression, index: number, array: Expression[]) => unknown, thisArg?: any): boolean; }
50-
> : ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^
49+
>operands.every : { <S extends Expression>(predicate: (value: Expression, index: number, array: Expression[]) => value is S, thisArg?: any): this is S[]; (predicate: (value: Expression, index: number, array: Expression[]) => unknown, thisArg?: any): boolean; } | { <S extends Expression>(predicate: (value: Expression, index: number, array: Expression[]) => value is S, thisArg?: any): this is S[]; (predicate: (value: Expression, index: number, array: Expression[]) => unknown, thisArg?: any): boolean; }
50+
> : ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^
5151
>operands : Expression[] | [Expression]
5252
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^
53-
>every : { <S extends Expression>(predicate: (value: Expression, index: number, array: Expression[]) => value is S, thisArg?: any): this is S[]; (predicate: (value: Expression, index: number, array: Expression[]) => unknown, thisArg?: any): boolean; } | { <S_1 extends Expression>(predicate: (value: Expression, index: number, array: Expression[]) => value is S_1, thisArg?: any): this is S_1[]; (predicate: (value: Expression, index: number, array: Expression[]) => unknown, thisArg?: any): boolean; }
54-
> : ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^
53+
>every : { <S extends Expression>(predicate: (value: Expression, index: number, array: Expression[]) => value is S, thisArg?: any): this is S[]; (predicate: (value: Expression, index: number, array: Expression[]) => unknown, thisArg?: any): boolean; } | { <S extends Expression>(predicate: (value: Expression, index: number, array: Expression[]) => value is S, thisArg?: any): this is S[]; (predicate: (value: Expression, index: number, array: Expression[]) => unknown, thisArg?: any): boolean; }
54+
> : ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^
5555
>(child) => evaluate(child) : (child: Expression) => boolean
5656
> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^
5757
>child : Expression

0 commit comments

Comments
 (0)