Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2d47953

Browse files
authored
Declaration emit should avoid issuing errors on unresolved names (microsoft#58536)
1 parentef01ea1 commit2d47953

File tree

39 files changed

+395
-88
lines changed

39 files changed

+395
-88
lines changed

‎src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5864,7 +5864,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
58645864

58655865
// Verify if the symbol is accessible
58665866
return (symbol && hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible)) || {
5867-
accessibility: SymbolAccessibility.NotAccessible,
5867+
accessibility: SymbolAccessibility.NotResolved,
58685868
errorSymbolName: getTextOfNode(firstIdentifier),
58695869
errorNode: firstIdentifier,
58705870
};

‎src/compiler/transformers/declarations.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,8 @@ export function transformDeclarations(context: TransformationContext) {
324324
}
325325
// TODO: Do all these accessibility checks inside/after the first pass in the checker when declarations are enabled, if possible
326326
}
327-
else{
327+
// The checker should issue errors on unresolvable names, skip the declaration emit error for using a private/unreachable name for those
328+
elseif(symbolAccessibilityResult.accessibility!==SymbolAccessibility.NotResolved){
328329
// Report error
329330
consterrorInfo=getSymbolAccessibilityDiagnostic(symbolAccessibilityResult);
330331
if(errorInfo){

‎src/compiler/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5544,6 +5544,7 @@ export const enum SymbolAccessibility {
55445544
Accessible,
55455545
NotAccessible,
55465546
CannotBeNamed,
5547+
NotResolved,
55475548
}
55485549

55495550
/**@internal */
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
accessorDeclarationEmitVisibilityErrors.ts(2,18): error TS2304: Cannot find name 'DoesNotExist'.
2-
accessorDeclarationEmitVisibilityErrors.ts(2,18): error TS4106: Parameter 'arg' of accessor has or is using private name 'DoesNotExist'.
32

43

5-
==== accessorDeclarationEmitVisibilityErrors.ts (2 errors) ====
4+
==== accessorDeclarationEmitVisibilityErrors.ts (1 errors) ====
65
export class Q {
76
set bet(arg: DoesNotExist) {}
87
~~~~~~~~~~~~
98
!!! error TS2304: Cannot find name 'DoesNotExist'.
10-
~~~~~~~~~~~~
11-
!!! error TS4106: Parameter 'arg' of accessor has or is using private name 'DoesNotExist'.
129
}

‎tests/baselines/reference/accessorDeclarationEmitVisibilityErrors.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,9 @@ export class Q {
99
exportclassQ{
1010
setbet(arg){}
1111
}
12+
13+
14+
//// [accessorDeclarationEmitVisibilityErrors.d.ts]
15+
exportdeclareclassQ{
16+
setbet(arg:DoesNotExist);
17+
}

‎tests/baselines/reference/declarationEmitExpressionInExtends4.errors.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
declarationEmitExpressionInExtends4.ts(5,17): error TS2315: Type 'D' is not generic.
22
declarationEmitExpressionInExtends4.ts(9,18): error TS2304: Cannot find name 'SomeUndefinedFunction'.
33
declarationEmitExpressionInExtends4.ts(14,18): error TS2304: Cannot find name 'SomeUndefinedFunction'.
4-
declarationEmitExpressionInExtends4.ts(14,18): error TS4020: 'extends' clause of exported class 'C3' has or is using private name 'SomeUndefinedFunction'.
54

65

7-
==== declarationEmitExpressionInExtends4.ts (4 errors) ====
6+
==== declarationEmitExpressionInExtends4.ts (3 errors) ====
87
function getSomething() {
98
return class D { }
109
}
@@ -25,7 +24,5 @@ declarationEmitExpressionInExtends4.ts(14,18): error TS4020: 'extends' clause of
2524
class C3 extends SomeUndefinedFunction {
2625
~~~~~~~~~~~~~~~~~~~~~
2726
!!! error TS2304: Cannot find name 'SomeUndefinedFunction'.
28-
~~~~~~~~~~~~~~~~~~~~~
29-
!!! error TS4020: 'extends' clause of exported class 'C3' has or is using private name 'SomeUndefinedFunction'.
3027

3128
}

‎tests/baselines/reference/declarationEmitExpressionInExtends4.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,19 @@ var C3 = /** @class */ (function (_super) {
6262
}
6363
returnC3;
6464
}(SomeUndefinedFunction));
65+
66+
67+
//// [declarationEmitExpressionInExtends4.d.ts]
68+
declarefunctiongetSomething():{
69+
new():{};
70+
};
71+
declareconstC_base:{
72+
new():{};
73+
};
74+
declareclassCextendsC_base<number,string>{
75+
}
76+
declareconstC2_base:any;
77+
declareclassC2extendsC2_base<number,string>{
78+
}
79+
declareclassC3extendsSomeUndefinedFunction{
80+
}
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
declarationEmitExpressionInExtends7.ts(1,30): error TS2304: Cannot find name 'SomeUndefinedFunction'.
2-
declarationEmitExpressionInExtends7.ts(1,30): error TS4021: 'extends' clause of exported class has or is using private name 'SomeUndefinedFunction'.
32

43

5-
==== declarationEmitExpressionInExtends7.ts (2 errors) ====
4+
==== declarationEmitExpressionInExtends7.ts (1 errors) ====
65
export default class extends SomeUndefinedFunction {}
76
~~~~~~~~~~~~~~~~~~~~~
87
!!! error TS2304: Cannot find name 'SomeUndefinedFunction'.
9-
~~~~~~~~~~~~~~~~~~~~~
10-
!!! error TS4021: 'extends' clause of exported class has or is using private name 'SomeUndefinedFunction'.
118

‎tests/baselines/reference/declarationEmitExpressionInExtends7.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,8 @@ var default_1 = /** @class */ (function (_super) {
3030
returndefault_1;
3131
}(SomeUndefinedFunction));
3232
exports.default=default_1;
33+
34+
35+
//// [declarationEmitExpressionInExtends7.d.ts]
36+
exportdefaultclassextendsSomeUndefinedFunction{
37+
}
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
declarationEmitIndexTypeNotFound.ts(2,6): error TS1268: An index signature parameter type must be 'string', 'number', 'symbol', or a template literal type.
22
declarationEmitIndexTypeNotFound.ts(2,13): error TS2304: Cannot find name 'TypeNotFound'.
3-
declarationEmitIndexTypeNotFound.ts(2,13): error TS4092: Parameter 'index' of index signature from exported interface has or is using private name 'TypeNotFound'.
43

54

6-
==== declarationEmitIndexTypeNotFound.ts (3 errors) ====
5+
==== declarationEmitIndexTypeNotFound.ts (2 errors) ====
76
export interface Test {
87
[index: TypeNotFound]: any;
98
~~~~~
109
!!! error TS1268: An index signature parameter type must be 'string', 'number', 'symbol', or a template literal type.
1110
~~~~~~~~~~~~
1211
!!! error TS2304: Cannot find name 'TypeNotFound'.
13-
~~~~~~~~~~~~
14-
!!! error TS4092: Parameter 'index' of index signature from exported interface has or is using private name 'TypeNotFound'.
1512
}
1613

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp