1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
|
tests/cases/compiler/overloadsWithComputedNames.ts(4,5): error TS2389: Function implementation name must be '["B"]'.
tests/cases/compiler/overloadsWithComputedNames.ts(14,5): error TS2391: Function implementation is missing or not immediately following the declaration.
tests/cases/compiler/overloadsWithComputedNames.ts(16,5): error TS2389: Function implementation name must be '["bar"]'.
tests/cases/compiler/overloadsWithComputedNames.ts(28,5): error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type.
tests/cases/compiler/overloadsWithComputedNames.ts(29,5): error TS2391: Function implementation is missing or not immediately following the declaration.
tests/cases/compiler/overloadsWithComputedNames.ts(35,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.
tests/cases/compiler/overloadsWithComputedNames.ts(42,5): error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type.
tests/cases/compiler/overloadsWithComputedNames.ts(47,5): error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type.
tests/cases/compiler/overloadsWithComputedNames.ts(52,5): error TS2391: Function implementation is missing or not immediately following the declaration.
==== tests/cases/compiler/overloadsWithComputedNames.ts (9 errors) ====
// https://github.com/microsoft/TypeScript/issues/52329
class Person {
["B"](a: number): string;
["A"](a: string|number): number | string {
~~~~~
!!! error TS2389: Function implementation name must be '["B"]'.
return 0;
}
}
let p = new Person();
p.A(0)
p.B(0)
// https://github.com/microsoft/TypeScript/issues/17345
class C {
["foo"](): void
~~~~~~~
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
["bar"](): void;
["foo"]() {
~~~~~~~
!!! error TS2389: Function implementation name must be '["bar"]'.
return 0;
}
}
declare const uniqueSym: unique symbol;
declare const uniqueSym2: unique symbol;
declare const sym: symbol;
declare const strUnion: 'foo' | 'bar';
class C1 {
[sym](): void; // should error
~~~~~
!!! error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type.
[uniqueSym2](): void; // should error
~~~~~~~~~~~~
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
[uniqueSym](): void;
[uniqueSym]() { }
}
interface I1 {
[sym](): void; // should error
~~~~~
!!! 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.
[uniqueSym2](): void;
[uniqueSym](): void;
[uniqueSym](): void;
}
class C2 {
[strUnion](): void; // should error
~~~~~~~~~~
!!! error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type.
[strUnion]() { }
}
class I2 {
[strUnion](): void; // should error
~~~~~~~~~~
!!! error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type.
[strUnion]() { }
}
class C3 {
[1](): void; // should error
~~~
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
[2](): void;
[2]() { }
}
interface I3 {
[1](): void;
[2](): void;
[2](): void;
}
|