Skip to content

Commit e1bb300

Browse files
Fix emit resolver to use same name resolver as the checker.
Signed-off-by: Titian Cernicova-Dragomir <[email protected]>
1 parent 3188a82 commit e1bb300

16 files changed

+1179
-705
lines changed

src/compiler/checker.ts

Lines changed: 87 additions & 563 deletions
Large diffs are not rendered by default.

src/compiler/transformers/declarations/emitResolver.ts

Lines changed: 185 additions & 87 deletions
Large diffs are not rendered by default.

src/compiler/utilities.ts

Lines changed: 583 additions & 2 deletions
Large diffs are not rendered by default.

tests/baselines/reference/isolated-declarations/auto-fixed/diff/isolatedDeclarationErrorsClasses.d.ts.diff

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
===================================================================
66
--- TSC declarations
77
+++ DTE declarations
8-
@@ -17,15 +17,23 @@
8+
@@ -17,15 +17,21 @@
99
set getSetOk2(value: number);
1010
get getSetOk3(): number;
1111
set getSetOk3(value: number);
@@ -18,8 +18,6 @@
1818
+ [missing]: number;
1919
[noAnnotationLiteralName](): void;
2020
[noParamAnnotationLiteralName](v: string): void;
21-
+ [noAnnotationStringName](): void;
22-
+ [noParamAnnotationStringName](v: invalid): void;
2321
+ get [noAnnotationStringName](): number;
2422
+ set [noParamAnnotationStringName](value: invalid);
2523
}
@@ -29,12 +27,9 @@
2927
}
3028
export {};
3129

32-
@@ -33,16 +41,18 @@
33-
34-
isolatedDeclarationErrorsClasses.ts(36,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type.
30+
@@ -35,14 +41,15 @@
3531
isolatedDeclarationErrorsClasses.ts(36,6): error TS2304: Cannot find name 'missing'.
3632
isolatedDeclarationErrorsClasses.ts(44,35): error TS7006: Parameter 'v' implicitly has an 'any' type.
37-
+isolatedDeclarationErrorsClasses.ts(44,35): error TS9011: Parameter must have an explicit type annotation with --isolatedDeclarations.
3833
isolatedDeclarationErrorsClasses.ts(48,9): error TS7032: Property '[noParamAnnotationStringName]' implicitly has type 'any', because its set accessor lacks a parameter type annotation.
3934
isolatedDeclarationErrorsClasses.ts(48,39): error TS7006: Parameter 'value' implicitly has an 'any' type.
4035
+isolatedDeclarationErrorsClasses.ts(48,39): error TS9009: At least one accessor must have an explicit return type annotation with --isolatedDeclarations.
@@ -44,23 +39,12 @@
4439

4540

4641
-==== isolatedDeclarationErrorsClasses.ts (8 errors) ====
47-
+==== isolatedDeclarationErrorsClasses.ts (10 errors) ====
42+
+==== isolatedDeclarationErrorsClasses.ts (9 errors) ====
4843
export class Cls {
4944

5045
field: number = 1 + 1;
5146
method(): void {}
52-
@@ -91,16 +101,22 @@
53-
54-
[noParamAnnotationStringName](v): void { }
55-
~
56-
!!! error TS7006: Parameter 'v' implicitly has an 'any' type.
57-
+ ~
58-
+!!! error TS9011: Parameter must have an explicit type annotation with --isolatedDeclarations.
59-
+!!! related TS9028 isolatedDeclarationErrorsClasses.ts:44:35: Add a type annotation to the parameter v.
60-
61-
get [noAnnotationStringName](): number { return 0;}
62-
63-
set [noParamAnnotationStringName](value) { }
47+
@@ -99,8 +106,11 @@
6448
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6549
!!! error TS7032: Property '[noParamAnnotationStringName]' implicitly has type 'any', because its set accessor lacks a parameter type annotation.
6650
~~~~~
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// [[Reason: Function declarations are not fixed.]] ////
2+
3+
//// [tests/cases/compiler/isolatedDeclarationErrorsExpandoFunctions.ts] ////
4+
5+
===================================================================
6+
--- TSC declarations
7+
+++ DTE declarations
8+
@@ -1,12 +1,38 @@
9+
10+
11+
//// [isolatedDeclarationErrorsExpandoFunctions.d.ts]
12+
export declare function foo(): void;
13+
-export declare namespace foo {
14+
- var apply: () => void;
15+
- var call: () => void;
16+
- var bind: () => void;
17+
- var caller: () => void;
18+
- var toString: () => void;
19+
- var length: number;
20+
-}
21+
+
22+
+/// [Errors] ////
23+
+
24+
+isolatedDeclarationErrorsExpandoFunctions.ts(3,1): error TS9023: Assigning properties to functions without declaring them is not supported with --isolatedDeclarations. Add an explicit declaration for the properties assigned to this function.
25+
+isolatedDeclarationErrorsExpandoFunctions.ts(4,1): error TS9023: Assigning properties to functions without declaring them is not supported with --isolatedDeclarations. Add an explicit declaration for the properties assigned to this function.
26+
+isolatedDeclarationErrorsExpandoFunctions.ts(5,1): error TS9023: Assigning properties to functions without declaring them is not supported with --isolatedDeclarations. Add an explicit declaration for the properties assigned to this function.
27+
+isolatedDeclarationErrorsExpandoFunctions.ts(6,1): error TS9023: Assigning properties to functions without declaring them is not supported with --isolatedDeclarations. Add an explicit declaration for the properties assigned to this function.
28+
+isolatedDeclarationErrorsExpandoFunctions.ts(7,1): error TS9023: Assigning properties to functions without declaring them is not supported with --isolatedDeclarations. Add an explicit declaration for the properties assigned to this function.
29+
+isolatedDeclarationErrorsExpandoFunctions.ts(8,1): error TS9023: Assigning properties to functions without declaring them is not supported with --isolatedDeclarations. Add an explicit declaration for the properties assigned to this function.
30+
+
31+
+
32+
+==== isolatedDeclarationErrorsExpandoFunctions.ts (6 errors) ====
33+
+ export function foo(): void {}
34+
+
35+
+ foo.apply = () => {}
36+
+ ~~~~~~~~~
37+
+!!! error TS9023: Assigning properties to functions without declaring them is not supported with --isolatedDeclarations. Add an explicit declaration for the properties assigned to this function.
38+
+ foo.call = ()=> {}
39+
+ ~~~~~~~~
40+
+!!! error TS9023: Assigning properties to functions without declaring them is not supported with --isolatedDeclarations. Add an explicit declaration for the properties assigned to this function.
41+
+ foo.bind = ()=> {}
42+
+ ~~~~~~~~
43+
+!!! error TS9023: Assigning properties to functions without declaring them is not supported with --isolatedDeclarations. Add an explicit declaration for the properties assigned to this function.
44+
+ foo.caller = ()=> {}
45+
+ ~~~~~~~~~~
46+
+!!! error TS9023: Assigning properties to functions without declaring them is not supported with --isolatedDeclarations. Add an explicit declaration for the properties assigned to this function.
47+
+ foo.toString = ()=> {}
48+
+ ~~~~~~~~~~~~
49+
+!!! error TS9023: Assigning properties to functions without declaring them is not supported with --isolatedDeclarations. Add an explicit declaration for the properties assigned to this function.
50+
+ foo.length = 10
51+
+ ~~~~~~~~~~
52+
+!!! error TS9023: Assigning properties to functions without declaring them is not supported with --isolatedDeclarations. Add an explicit declaration for the properties assigned to this function.
53+
+ foo.length = 10
54+
+
55+
\ No newline at end of file

tests/baselines/reference/isolated-declarations/auto-fixed/dte/isolatedDeclarationErrorsClasses.d.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,6 @@ export declare class C {
8989
[missing]: number;
9090
[noAnnotationLiteralName](): void;
9191
[noParamAnnotationLiteralName](v: string): void;
92-
[noAnnotationStringName](): void;
93-
[noParamAnnotationStringName](v: invalid): void;
9492
get [noAnnotationStringName](): number;
9593
set [noParamAnnotationStringName](value: invalid);
9694
}
@@ -105,7 +103,6 @@ export {};
105103
isolatedDeclarationErrorsClasses.ts(36,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type.
106104
isolatedDeclarationErrorsClasses.ts(36,6): error TS2304: Cannot find name 'missing'.
107105
isolatedDeclarationErrorsClasses.ts(44,35): error TS7006: Parameter 'v' implicitly has an 'any' type.
108-
isolatedDeclarationErrorsClasses.ts(44,35): error TS9011: Parameter must have an explicit type annotation with --isolatedDeclarations.
109106
isolatedDeclarationErrorsClasses.ts(48,9): error TS7032: Property '[noParamAnnotationStringName]' implicitly has type 'any', because its set accessor lacks a parameter type annotation.
110107
isolatedDeclarationErrorsClasses.ts(48,39): error TS7006: Parameter 'value' implicitly has an 'any' type.
111108
isolatedDeclarationErrorsClasses.ts(48,39): error TS9009: At least one accessor must have an explicit return type annotation with --isolatedDeclarations.
@@ -114,7 +111,7 @@ isolatedDeclarationErrorsClasses.ts(55,5): error TS1169: A computed property nam
114111
isolatedDeclarationErrorsClasses.ts(56,5): error TS7010: '[noAnnotationLiteralName]', which lacks return-type annotation, implicitly has an 'any' return type.
115112

116113

117-
==== isolatedDeclarationErrorsClasses.ts (10 errors) ====
114+
==== isolatedDeclarationErrorsClasses.ts (9 errors) ====
118115
export class Cls {
119116

120117
field: number = 1 + 1;
@@ -165,9 +162,6 @@ isolatedDeclarationErrorsClasses.ts(56,5): error TS7010: '[noAnnotationLiteralNa
165162
[noParamAnnotationStringName](v): void { }
166163
~
167164
!!! error TS7006: Parameter 'v' implicitly has an 'any' type.
168-
~
169-
!!! error TS9011: Parameter must have an explicit type annotation with --isolatedDeclarations.
170-
!!! related TS9028 isolatedDeclarationErrorsClasses.ts:44:35: Add a type annotation to the parameter v.
171165

172166
get [noAnnotationStringName](): number { return 0;}
173167

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
//// [tests/cases/compiler/isolatedDeclarationErrorsExpandoFunctions.ts] ////
2+
3+
//// [isolatedDeclarationErrorsExpandoFunctions.ts]
4+
export function foo(): void {}
5+
6+
foo.apply = () => {}
7+
foo.call = ()=> {}
8+
foo.bind = ()=> {}
9+
foo.caller = ()=> {}
10+
foo.toString = ()=> {}
11+
foo.length = 10
12+
foo.length = 10
13+
14+
15+
/// [Declarations] ////
16+
17+
18+
19+
//// [isolatedDeclarationErrorsExpandoFunctions.d.ts]
20+
export declare function foo(): void;
21+
22+
/// [Errors] ////
23+
24+
isolatedDeclarationErrorsExpandoFunctions.ts(3,1): error TS9023: Assigning properties to functions without declaring them is not supported with --isolatedDeclarations. Add an explicit declaration for the properties assigned to this function.
25+
isolatedDeclarationErrorsExpandoFunctions.ts(4,1): error TS9023: Assigning properties to functions without declaring them is not supported with --isolatedDeclarations. Add an explicit declaration for the properties assigned to this function.
26+
isolatedDeclarationErrorsExpandoFunctions.ts(5,1): error TS9023: Assigning properties to functions without declaring them is not supported with --isolatedDeclarations. Add an explicit declaration for the properties assigned to this function.
27+
isolatedDeclarationErrorsExpandoFunctions.ts(6,1): error TS9023: Assigning properties to functions without declaring them is not supported with --isolatedDeclarations. Add an explicit declaration for the properties assigned to this function.
28+
isolatedDeclarationErrorsExpandoFunctions.ts(7,1): error TS9023: Assigning properties to functions without declaring them is not supported with --isolatedDeclarations. Add an explicit declaration for the properties assigned to this function.
29+
isolatedDeclarationErrorsExpandoFunctions.ts(8,1): error TS9023: Assigning properties to functions without declaring them is not supported with --isolatedDeclarations. Add an explicit declaration for the properties assigned to this function.
30+
31+
32+
==== isolatedDeclarationErrorsExpandoFunctions.ts (6 errors) ====
33+
export function foo(): void {}
34+
35+
foo.apply = () => {}
36+
~~~~~~~~~
37+
!!! error TS9023: Assigning properties to functions without declaring them is not supported with --isolatedDeclarations. Add an explicit declaration for the properties assigned to this function.
38+
foo.call = ()=> {}
39+
~~~~~~~~
40+
!!! error TS9023: Assigning properties to functions without declaring them is not supported with --isolatedDeclarations. Add an explicit declaration for the properties assigned to this function.
41+
foo.bind = ()=> {}
42+
~~~~~~~~
43+
!!! error TS9023: Assigning properties to functions without declaring them is not supported with --isolatedDeclarations. Add an explicit declaration for the properties assigned to this function.
44+
foo.caller = ()=> {}
45+
~~~~~~~~~~
46+
!!! error TS9023: Assigning properties to functions without declaring them is not supported with --isolatedDeclarations. Add an explicit declaration for the properties assigned to this function.
47+
foo.toString = ()=> {}
48+
~~~~~~~~~~~~
49+
!!! error TS9023: Assigning properties to functions without declaring them is not supported with --isolatedDeclarations. Add an explicit declaration for the properties assigned to this function.
50+
foo.length = 10
51+
~~~~~~~~~~
52+
!!! error TS9023: Assigning properties to functions without declaring them is not supported with --isolatedDeclarations. Add an explicit declaration for the properties assigned to this function.
53+
foo.length = 10
54+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//// [tests/cases/compiler/isolatedDeclarationErrorsExpandoFunctions.ts] ////
2+
3+
//// [isolatedDeclarationErrorsExpandoFunctions.ts]
4+
export function foo(): void {}
5+
6+
foo.apply = () => {}
7+
foo.call = ()=> {}
8+
foo.bind = ()=> {}
9+
foo.caller = ()=> {}
10+
foo.toString = ()=> {}
11+
foo.length = 10
12+
foo.length = 10
13+
14+
15+
/// [Declarations] ////
16+
17+
18+
19+
//// [isolatedDeclarationErrorsExpandoFunctions.d.ts]
20+
export declare function foo(): void;
21+
export declare namespace foo {
22+
var apply: () => void;
23+
var call: () => void;
24+
var bind: () => void;
25+
var caller: () => void;
26+
var toString: () => void;
27+
var length: number;
28+
}

tests/baselines/reference/isolated-declarations/original/diff/isolatedDeclarationErrorsClasses.d.ts.diff

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
===================================================================
66
--- TSC declarations
77
+++ DTE declarations
8-
@@ -17,15 +17,23 @@
8+
@@ -17,15 +17,21 @@
99
set getSetOk2(value: number);
1010
get getSetOk3(): number;
1111
set getSetOk3(value: number);
@@ -18,8 +18,6 @@
1818
+ [missing]: number;
1919
[noAnnotationLiteralName](): void;
2020
[noParamAnnotationLiteralName](v: string): void;
21-
+ [noAnnotationStringName](): invalid;
22-
+ [noParamAnnotationStringName](v: invalid): void;
2321
+ get [noAnnotationStringName](): invalid;
2422
+ set [noParamAnnotationStringName](value: invalid);
2523
}
@@ -29,17 +27,15 @@
2927
}
3028
export {};
3129

32-
@@ -42,15 +50,15 @@
30+
@@ -42,21 +48,19 @@
3331
isolatedDeclarationErrorsClasses.ts(12,17): error TS9009: At least one accessor must have an explicit return type annotation with --isolatedDeclarations.
3432
isolatedDeclarationErrorsClasses.ts(14,9): error TS9009: At least one accessor must have an explicit return type annotation with --isolatedDeclarations.
3533
isolatedDeclarationErrorsClasses.ts(36,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type.
3634
isolatedDeclarationErrorsClasses.ts(36,6): error TS2304: Cannot find name 'missing'.
3735
-isolatedDeclarationErrorsClasses.ts(42,5): error TS9014: Computed properties must be number or string literals, variables or dotted expressions with --isolatedDeclarations.
3836
-isolatedDeclarationErrorsClasses.ts(44,5): error TS9014: Computed properties must be number or string literals, variables or dotted expressions with --isolatedDeclarations.
39-
+isolatedDeclarationErrorsClasses.ts(42,5): error TS9008: Method must have an explicit return type annotation with --isolatedDeclarations.
4037
isolatedDeclarationErrorsClasses.ts(44,35): error TS7006: Parameter 'v' implicitly has an 'any' type.
4138
-isolatedDeclarationErrorsClasses.ts(46,9): error TS9014: Computed properties must be number or string literals, variables or dotted expressions with --isolatedDeclarations.
42-
+isolatedDeclarationErrorsClasses.ts(44,35): error TS9011: Parameter must have an explicit type annotation with --isolatedDeclarations.
4339
+isolatedDeclarationErrorsClasses.ts(46,9): error TS9009: At least one accessor must have an explicit return type annotation with --isolatedDeclarations.
4440
isolatedDeclarationErrorsClasses.ts(48,9): error TS7032: Property '[noParamAnnotationStringName]' implicitly has type 'any', because its set accessor lacks a parameter type annotation.
4541
-isolatedDeclarationErrorsClasses.ts(48,9): error TS9014: Computed properties must be number or string literals, variables or dotted expressions with --isolatedDeclarations.
@@ -49,23 +45,26 @@
4945
isolatedDeclarationErrorsClasses.ts(55,5): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type.
5046
isolatedDeclarationErrorsClasses.ts(56,5): error TS7010: '[noAnnotationLiteralName]', which lacks return-type annotation, implicitly has an 'any' return type.
5147

52-
@@ -130,27 +138,31 @@
48+
49+
-==== isolatedDeclarationErrorsClasses.ts (22 errors) ====
50+
+==== isolatedDeclarationErrorsClasses.ts (20 errors) ====
51+
export class Cls {
52+
53+
field = 1 + 1;
54+
~~~~~
55+
@@ -129,28 +133,26 @@
56+
5357
[noParamAnnotationLiteralName](v: string): void { }
5458

5559
[noAnnotationStringName]() { }
56-
~~~~~~~~~~~~~~~~~~~~~~~~
60+
- ~~~~~~~~~~~~~~~~~~~~~~~~
5761
-!!! error TS9014: Computed properties must be number or string literals, variables or dotted expressions with --isolatedDeclarations.
58-
+!!! error TS9008: Method must have an explicit return type annotation with --isolatedDeclarations.
59-
+!!! related TS9034 isolatedDeclarationErrorsClasses.ts:42:5: Add a return type to the method
6062

6163
[noParamAnnotationStringName](v): void { }
6264
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6365
-!!! error TS9014: Computed properties must be number or string literals, variables or dotted expressions with --isolatedDeclarations.
6466
~
6567
!!! error TS7006: Parameter 'v' implicitly has an 'any' type.
66-
+ ~
67-
+!!! error TS9011: Parameter must have an explicit type annotation with --isolatedDeclarations.
68-
+!!! related TS9028 isolatedDeclarationErrorsClasses.ts:44:35: Add a type annotation to the parameter v.
6968

7069
get [noAnnotationStringName]() { return 0;}
7170
~~~~~~~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)