mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 11:54:44 -06:00
Merge pull request #21217 from Microsoft/fix20146
Symbol-named properties do not need to align with string indexer type
This commit is contained in:
commit
7a89c963b0
@ -22298,7 +22298,8 @@ namespace ts {
|
||||
indexType: Type,
|
||||
indexKind: IndexKind): void {
|
||||
|
||||
if (!indexType) {
|
||||
// ESSymbol properties apply to neither string nor numeric indexers.
|
||||
if (!indexType || isKnownSymbol(prop)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
25
tests/baselines/reference/symbolProperty60.js
Normal file
25
tests/baselines/reference/symbolProperty60.js
Normal file
@ -0,0 +1,25 @@
|
||||
//// [symbolProperty60.ts]
|
||||
// https://github.com/Microsoft/TypeScript/issues/20146
|
||||
interface I1 {
|
||||
[Symbol.toStringTag]: string;
|
||||
[key: string]: number;
|
||||
}
|
||||
|
||||
interface I2 {
|
||||
[Symbol.toStringTag]: string;
|
||||
[key: number]: boolean;
|
||||
}
|
||||
|
||||
declare const mySymbol: unique symbol;
|
||||
|
||||
interface I3 {
|
||||
[mySymbol]: string;
|
||||
[key: string]: number;
|
||||
}
|
||||
|
||||
interface I4 {
|
||||
[mySymbol]: string;
|
||||
[key: number]: boolean;
|
||||
}
|
||||
|
||||
//// [symbolProperty60.js]
|
||||
48
tests/baselines/reference/symbolProperty60.symbols
Normal file
48
tests/baselines/reference/symbolProperty60.symbols
Normal file
@ -0,0 +1,48 @@
|
||||
=== tests/cases/conformance/es6/Symbols/symbolProperty60.ts ===
|
||||
// https://github.com/Microsoft/TypeScript/issues/20146
|
||||
interface I1 {
|
||||
>I1 : Symbol(I1, Decl(symbolProperty60.ts, 0, 0))
|
||||
|
||||
[Symbol.toStringTag]: string;
|
||||
>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
|
||||
>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --))
|
||||
>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
|
||||
|
||||
[key: string]: number;
|
||||
>key : Symbol(key, Decl(symbolProperty60.ts, 3, 5))
|
||||
}
|
||||
|
||||
interface I2 {
|
||||
>I2 : Symbol(I2, Decl(symbolProperty60.ts, 4, 1))
|
||||
|
||||
[Symbol.toStringTag]: string;
|
||||
>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
|
||||
>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --))
|
||||
>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
|
||||
|
||||
[key: number]: boolean;
|
||||
>key : Symbol(key, Decl(symbolProperty60.ts, 8, 5))
|
||||
}
|
||||
|
||||
declare const mySymbol: unique symbol;
|
||||
>mySymbol : Symbol(mySymbol, Decl(symbolProperty60.ts, 11, 13))
|
||||
|
||||
interface I3 {
|
||||
>I3 : Symbol(I3, Decl(symbolProperty60.ts, 11, 38))
|
||||
|
||||
[mySymbol]: string;
|
||||
>mySymbol : Symbol(mySymbol, Decl(symbolProperty60.ts, 11, 13))
|
||||
|
||||
[key: string]: number;
|
||||
>key : Symbol(key, Decl(symbolProperty60.ts, 15, 5))
|
||||
}
|
||||
|
||||
interface I4 {
|
||||
>I4 : Symbol(I4, Decl(symbolProperty60.ts, 16, 1))
|
||||
|
||||
[mySymbol]: string;
|
||||
>mySymbol : Symbol(mySymbol, Decl(symbolProperty60.ts, 11, 13))
|
||||
|
||||
[key: number]: boolean;
|
||||
>key : Symbol(key, Decl(symbolProperty60.ts, 20, 5))
|
||||
}
|
||||
48
tests/baselines/reference/symbolProperty60.types
Normal file
48
tests/baselines/reference/symbolProperty60.types
Normal file
@ -0,0 +1,48 @@
|
||||
=== tests/cases/conformance/es6/Symbols/symbolProperty60.ts ===
|
||||
// https://github.com/Microsoft/TypeScript/issues/20146
|
||||
interface I1 {
|
||||
>I1 : I1
|
||||
|
||||
[Symbol.toStringTag]: string;
|
||||
>Symbol.toStringTag : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>toStringTag : symbol
|
||||
|
||||
[key: string]: number;
|
||||
>key : string
|
||||
}
|
||||
|
||||
interface I2 {
|
||||
>I2 : I2
|
||||
|
||||
[Symbol.toStringTag]: string;
|
||||
>Symbol.toStringTag : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>toStringTag : symbol
|
||||
|
||||
[key: number]: boolean;
|
||||
>key : number
|
||||
}
|
||||
|
||||
declare const mySymbol: unique symbol;
|
||||
>mySymbol : unique symbol
|
||||
|
||||
interface I3 {
|
||||
>I3 : I3
|
||||
|
||||
[mySymbol]: string;
|
||||
>mySymbol : unique symbol
|
||||
|
||||
[key: string]: number;
|
||||
>key : string
|
||||
}
|
||||
|
||||
interface I4 {
|
||||
>I4 : I4
|
||||
|
||||
[mySymbol]: string;
|
||||
>mySymbol : unique symbol
|
||||
|
||||
[key: number]: boolean;
|
||||
>key : number
|
||||
}
|
||||
23
tests/cases/conformance/es6/Symbols/symbolProperty60.ts
Normal file
23
tests/cases/conformance/es6/Symbols/symbolProperty60.ts
Normal file
@ -0,0 +1,23 @@
|
||||
// @target: es2015
|
||||
// https://github.com/Microsoft/TypeScript/issues/20146
|
||||
interface I1 {
|
||||
[Symbol.toStringTag]: string;
|
||||
[key: string]: number;
|
||||
}
|
||||
|
||||
interface I2 {
|
||||
[Symbol.toStringTag]: string;
|
||||
[key: number]: boolean;
|
||||
}
|
||||
|
||||
declare const mySymbol: unique symbol;
|
||||
|
||||
interface I3 {
|
||||
[mySymbol]: string;
|
||||
[key: string]: number;
|
||||
}
|
||||
|
||||
interface I4 {
|
||||
[mySymbol]: string;
|
||||
[key: number]: boolean;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user