Skip to content

Commit

Permalink
Fix emit resolver to use same name resolver as the checker.
Browse files Browse the repository at this point in the history
  • Loading branch information
dragomirtitian committed Jan 19, 2024
1 parent 3188a82 commit a229141
Show file tree
Hide file tree
Showing 16 changed files with 1,179 additions and 705 deletions.
650 changes: 87 additions & 563 deletions src/compiler/checker.ts

Large diffs are not rendered by default.

272 changes: 185 additions & 87 deletions src/compiler/transformers/declarations/emitResolver.ts

Large diffs are not rendered by default.

585 changes: 583 additions & 2 deletions src/compiler/utilities.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
===================================================================
--- TSC declarations
+++ DTE declarations
@@ -17,15 +17,23 @@
@@ -17,15 +17,21 @@
set getSetOk2(value: number);
get getSetOk3(): number;
set getSetOk3(value: number);
Expand All @@ -18,8 +18,6 @@
+ [missing]: number;
[noAnnotationLiteralName](): void;
[noParamAnnotationLiteralName](v: string): void;
+ [noAnnotationStringName](): void;
+ [noParamAnnotationStringName](v: invalid): void;
+ get [noAnnotationStringName](): number;
+ set [noParamAnnotationStringName](value: invalid);
}
Expand All @@ -29,12 +27,9 @@
}
export {};

@@ -33,16 +41,18 @@

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.
@@ -35,14 +41,15 @@
isolatedDeclarationErrorsClasses.ts(36,6): error TS2304: Cannot find name 'missing'.
isolatedDeclarationErrorsClasses.ts(44,35): error TS7006: Parameter 'v' implicitly has an 'any' type.
+isolatedDeclarationErrorsClasses.ts(44,35): error TS9011: Parameter must have an explicit type annotation with --isolatedDeclarations.
isolatedDeclarationErrorsClasses.ts(48,9): error TS7032: Property '[noParamAnnotationStringName]' implicitly has type 'any', because its set accessor lacks a parameter type annotation.
isolatedDeclarationErrorsClasses.ts(48,39): error TS7006: Parameter 'value' implicitly has an 'any' type.
+isolatedDeclarationErrorsClasses.ts(48,39): error TS9009: At least one accessor must have an explicit return type annotation with --isolatedDeclarations.
Expand All @@ -44,23 +39,12 @@


-==== isolatedDeclarationErrorsClasses.ts (8 errors) ====
+==== isolatedDeclarationErrorsClasses.ts (10 errors) ====
+==== isolatedDeclarationErrorsClasses.ts (9 errors) ====
export class Cls {

field: number = 1 + 1;
method(): void {}
@@ -91,16 +101,22 @@

[noParamAnnotationStringName](v): void { }
~
!!! error TS7006: Parameter 'v' implicitly has an 'any' type.
+ ~
+!!! error TS9011: Parameter must have an explicit type annotation with --isolatedDeclarations.
+!!! related TS9028 isolatedDeclarationErrorsClasses.ts:44:35: Add a type annotation to the parameter v.

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

set [noParamAnnotationStringName](value) { }
@@ -99,8 +106,11 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS7032: Property '[noParamAnnotationStringName]' implicitly has type 'any', because its set accessor lacks a parameter type annotation.
~~~~~
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// [[Reason: Function declarations are not fixed.]] ////

//// [tests/cases/compiler/isolatedDeclarationErrorsExpandoFunctions.ts] ////

===================================================================
--- TSC declarations
+++ DTE declarations
@@ -1,12 +1,38 @@


//// [isolatedDeclarationErrorsExpandoFunctions.d.ts]
export declare function foo(): void;
-export declare namespace foo {
- var apply: () => void;
- var call: () => void;
- var bind: () => void;
- var caller: () => void;
- var toString: () => void;
- var length: number;
-}
+
+/// [Errors] ////
+
+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.
+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.
+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.
+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.
+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.
+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.
+
+
+==== isolatedDeclarationErrorsExpandoFunctions.ts (6 errors) ====
+ export function foo(): void {}
+
+ foo.apply = () => {}
+ ~~~~~~~~~
+!!! 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.
+ foo.call = ()=> {}
+ ~~~~~~~~
+!!! 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.
+ foo.bind = ()=> {}
+ ~~~~~~~~
+!!! 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.
+ foo.caller = ()=> {}
+ ~~~~~~~~~~
+!!! 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.
+ foo.toString = ()=> {}
+ ~~~~~~~~~~~~
+!!! 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.
+ foo.length = 10
+ ~~~~~~~~~~
+!!! 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.
+ foo.length = 10
+
\ No newline at end of file
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ export declare class C {
[missing]: number;
[noAnnotationLiteralName](): void;
[noParamAnnotationLiteralName](v: string): void;
[noAnnotationStringName](): void;
[noParamAnnotationStringName](v: invalid): void;
get [noAnnotationStringName](): number;
set [noParamAnnotationStringName](value: invalid);
}
Expand All @@ -105,7 +103,6 @@ export {};
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.
isolatedDeclarationErrorsClasses.ts(36,6): error TS2304: Cannot find name 'missing'.
isolatedDeclarationErrorsClasses.ts(44,35): error TS7006: Parameter 'v' implicitly has an 'any' type.
isolatedDeclarationErrorsClasses.ts(44,35): error TS9011: Parameter must have an explicit type annotation with --isolatedDeclarations.
isolatedDeclarationErrorsClasses.ts(48,9): error TS7032: Property '[noParamAnnotationStringName]' implicitly has type 'any', because its set accessor lacks a parameter type annotation.
isolatedDeclarationErrorsClasses.ts(48,39): error TS7006: Parameter 'value' implicitly has an 'any' type.
isolatedDeclarationErrorsClasses.ts(48,39): error TS9009: At least one accessor must have an explicit return type annotation with --isolatedDeclarations.
Expand All @@ -114,7 +111,7 @@ isolatedDeclarationErrorsClasses.ts(55,5): error TS1169: A computed property nam
isolatedDeclarationErrorsClasses.ts(56,5): error TS7010: '[noAnnotationLiteralName]', which lacks return-type annotation, implicitly has an 'any' return type.


==== isolatedDeclarationErrorsClasses.ts (10 errors) ====
==== isolatedDeclarationErrorsClasses.ts (9 errors) ====
export class Cls {

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

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

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
//// [tests/cases/compiler/isolatedDeclarationErrorsExpandoFunctions.ts] ////

//// [isolatedDeclarationErrorsExpandoFunctions.ts]
export function foo(): void {}

foo.apply = () => {}
foo.call = ()=> {}
foo.bind = ()=> {}
foo.caller = ()=> {}
foo.toString = ()=> {}
foo.length = 10
foo.length = 10


/// [Declarations] ////



//// [isolatedDeclarationErrorsExpandoFunctions.d.ts]
export declare function foo(): void;

/// [Errors] ////

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.
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.
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.
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.
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.
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.


==== isolatedDeclarationErrorsExpandoFunctions.ts (6 errors) ====
export function foo(): void {}

foo.apply = () => {}
~~~~~~~~~
!!! 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.
foo.call = ()=> {}
~~~~~~~~
!!! 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.
foo.bind = ()=> {}
~~~~~~~~
!!! 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.
foo.caller = ()=> {}
~~~~~~~~~~
!!! 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.
foo.toString = ()=> {}
~~~~~~~~~~~~
!!! 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.
foo.length = 10
~~~~~~~~~~
!!! 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.
foo.length = 10

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//// [tests/cases/compiler/isolatedDeclarationErrorsExpandoFunctions.ts] ////

//// [isolatedDeclarationErrorsExpandoFunctions.ts]
export function foo(): void {}

foo.apply = () => {}
foo.call = ()=> {}
foo.bind = ()=> {}
foo.caller = ()=> {}
foo.toString = ()=> {}
foo.length = 10
foo.length = 10


/// [Declarations] ////



//// [isolatedDeclarationErrorsExpandoFunctions.d.ts]
export declare function foo(): void;
export declare namespace foo {
var apply: () => void;
var call: () => void;
var bind: () => void;
var caller: () => void;
var toString: () => void;
var length: number;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
===================================================================
--- TSC declarations
+++ DTE declarations
@@ -17,15 +17,23 @@
@@ -17,15 +17,21 @@
set getSetOk2(value: number);
get getSetOk3(): number;
set getSetOk3(value: number);
Expand All @@ -18,8 +18,6 @@
+ [missing]: number;
[noAnnotationLiteralName](): void;
[noParamAnnotationLiteralName](v: string): void;
+ [noAnnotationStringName](): invalid;
+ [noParamAnnotationStringName](v: invalid): void;
+ get [noAnnotationStringName](): invalid;
+ set [noParamAnnotationStringName](value: invalid);
}
Expand All @@ -29,17 +27,15 @@
}
export {};

@@ -42,15 +50,15 @@
@@ -42,21 +48,19 @@
isolatedDeclarationErrorsClasses.ts(12,17): error TS9009: At least one accessor must have an explicit return type annotation with --isolatedDeclarations.
isolatedDeclarationErrorsClasses.ts(14,9): error TS9009: At least one accessor must have an explicit return type annotation with --isolatedDeclarations.
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.
isolatedDeclarationErrorsClasses.ts(36,6): error TS2304: Cannot find name 'missing'.
-isolatedDeclarationErrorsClasses.ts(42,5): error TS9014: Computed properties must be number or string literals, variables or dotted expressions with --isolatedDeclarations.
-isolatedDeclarationErrorsClasses.ts(44,5): error TS9014: Computed properties must be number or string literals, variables or dotted expressions with --isolatedDeclarations.
+isolatedDeclarationErrorsClasses.ts(42,5): error TS9008: Method must have an explicit return type annotation with --isolatedDeclarations.
isolatedDeclarationErrorsClasses.ts(44,35): error TS7006: Parameter 'v' implicitly has an 'any' type.
-isolatedDeclarationErrorsClasses.ts(46,9): error TS9014: Computed properties must be number or string literals, variables or dotted expressions with --isolatedDeclarations.
+isolatedDeclarationErrorsClasses.ts(44,35): error TS9011: Parameter must have an explicit type annotation with --isolatedDeclarations.
+isolatedDeclarationErrorsClasses.ts(46,9): error TS9009: At least one accessor must have an explicit return type annotation with --isolatedDeclarations.
isolatedDeclarationErrorsClasses.ts(48,9): error TS7032: Property '[noParamAnnotationStringName]' implicitly has type 'any', because its set accessor lacks a parameter type annotation.
-isolatedDeclarationErrorsClasses.ts(48,9): error TS9014: Computed properties must be number or string literals, variables or dotted expressions with --isolatedDeclarations.
Expand All @@ -49,23 +45,26 @@
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.
isolatedDeclarationErrorsClasses.ts(56,5): error TS7010: '[noAnnotationLiteralName]', which lacks return-type annotation, implicitly has an 'any' return type.

@@ -130,27 +138,31 @@

-==== isolatedDeclarationErrorsClasses.ts (22 errors) ====
+==== isolatedDeclarationErrorsClasses.ts (20 errors) ====
export class Cls {

field = 1 + 1;
~~~~~
@@ -129,28 +133,26 @@

[noParamAnnotationLiteralName](v: string): void { }

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

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

get [noAnnotationStringName]() { return 0;}
~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
Loading

0 comments on commit a229141

Please sign in to comment.