mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
fix(37150): ignore private fields in string index type checking (#37183)
This commit is contained in:
parent
aa6be6ee6f
commit
795a5c83fe
@ -32950,6 +32950,10 @@ namespace ts {
|
||||
const propDeclaration = prop.valueDeclaration;
|
||||
const name = propDeclaration && getNameOfDeclaration(propDeclaration);
|
||||
|
||||
if (name && isPrivateIdentifier(name)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// index is numeric and property name is not valid numeric literal
|
||||
if (indexKind === IndexKind.Number && !(name ? isNumericName(name) : isNumericLiteralName(prop.escapedName))) {
|
||||
return;
|
||||
|
||||
17
tests/baselines/reference/classIndexer5.js
Normal file
17
tests/baselines/reference/classIndexer5.js
Normal file
@ -0,0 +1,17 @@
|
||||
//// [classIndexer5.ts]
|
||||
class Foo {
|
||||
[key: string]: number;
|
||||
|
||||
#a: boolean;
|
||||
#b = false;
|
||||
}
|
||||
|
||||
|
||||
//// [classIndexer5.js]
|
||||
class Foo {
|
||||
constructor() {
|
||||
this.#b = false;
|
||||
}
|
||||
#a;
|
||||
#b;
|
||||
}
|
||||
14
tests/baselines/reference/classIndexer5.symbols
Normal file
14
tests/baselines/reference/classIndexer5.symbols
Normal file
@ -0,0 +1,14 @@
|
||||
=== tests/cases/compiler/classIndexer5.ts ===
|
||||
class Foo {
|
||||
>Foo : Symbol(Foo, Decl(classIndexer5.ts, 0, 0))
|
||||
|
||||
[key: string]: number;
|
||||
>key : Symbol(key, Decl(classIndexer5.ts, 1, 5))
|
||||
|
||||
#a: boolean;
|
||||
>#a : Symbol(Foo.#a, Decl(classIndexer5.ts, 1, 26))
|
||||
|
||||
#b = false;
|
||||
>#b : Symbol(Foo.#b, Decl(classIndexer5.ts, 3, 16))
|
||||
}
|
||||
|
||||
15
tests/baselines/reference/classIndexer5.types
Normal file
15
tests/baselines/reference/classIndexer5.types
Normal file
@ -0,0 +1,15 @@
|
||||
=== tests/cases/compiler/classIndexer5.ts ===
|
||||
class Foo {
|
||||
>Foo : Foo
|
||||
|
||||
[key: string]: number;
|
||||
>key : string
|
||||
|
||||
#a: boolean;
|
||||
>#a : boolean
|
||||
|
||||
#b = false;
|
||||
>#b : boolean
|
||||
>false : false
|
||||
}
|
||||
|
||||
8
tests/cases/compiler/classIndexer5.ts
Normal file
8
tests/cases/compiler/classIndexer5.ts
Normal file
@ -0,0 +1,8 @@
|
||||
// @target: esnext
|
||||
|
||||
class Foo {
|
||||
[key: string]: number;
|
||||
|
||||
#a: boolean;
|
||||
#b = false;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user