mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-13 14:09:06 -05:00
Merge pull request #12594 from Microsoft/indexTypeNotFound
Handle parameter type error for index signature in declaration emit
This commit is contained in:
@@ -1625,6 +1625,12 @@ namespace ts {
|
||||
Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 :
|
||||
Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1;
|
||||
|
||||
case SyntaxKind.IndexSignature:
|
||||
// Interfaces cannot have parameter types that cannot be named
|
||||
return symbolAccessibilityResult.errorModuleName ?
|
||||
Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 :
|
||||
Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1;
|
||||
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
if (hasModifier(node.parent, ModifierFlags.Static)) {
|
||||
|
||||
@@ -2300,6 +2300,14 @@
|
||||
"category": "Message",
|
||||
"code": 4090
|
||||
},
|
||||
"Parameter '{0}' of index signature from exported interface has or is using name '{1}' from private module '{2}'.": {
|
||||
"category": "Error",
|
||||
"code": 4091
|
||||
},
|
||||
"Parameter '{0}' of index signature from exported interface has or is using private name '{1}'.": {
|
||||
"category": "Error",
|
||||
"code": 4092
|
||||
},
|
||||
|
||||
"The current host does not support the '{0}' option.": {
|
||||
"category": "Error",
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
tests/cases/compiler/declarationEmitIndexTypeNotFound.ts(3,6): error TS1023: An index signature parameter type must be 'string' or 'number'.
|
||||
tests/cases/compiler/declarationEmitIndexTypeNotFound.ts(3,13): error TS2304: Cannot find name 'TypeNotFound'.
|
||||
tests/cases/compiler/declarationEmitIndexTypeNotFound.ts(3,13): error TS4092: Parameter 'index' of index signature from exported interface has or is using private name 'TypeNotFound'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/declarationEmitIndexTypeNotFound.ts (3 errors) ====
|
||||
|
||||
export interface Test {
|
||||
[index: TypeNotFound]: any;
|
||||
~~~~~
|
||||
!!! error TS1023: An index signature parameter type must be 'string' or 'number'.
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2304: Cannot find name 'TypeNotFound'.
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS4092: Parameter 'index' of index signature from exported interface has or is using private name 'TypeNotFound'.
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
//// [declarationEmitIndexTypeNotFound.ts]
|
||||
|
||||
export interface Test {
|
||||
[index: TypeNotFound]: any;
|
||||
}
|
||||
|
||||
|
||||
//// [declarationEmitIndexTypeNotFound.js]
|
||||
"use strict";
|
||||
5
tests/cases/compiler/declarationEmitIndexTypeNotFound.ts
Normal file
5
tests/cases/compiler/declarationEmitIndexTypeNotFound.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
// @declaration: true
|
||||
|
||||
export interface Test {
|
||||
[index: TypeNotFound]: any;
|
||||
}
|
||||
Reference in New Issue
Block a user