60 lines
No EOL
1.8 KiB
Text
60 lines
No EOL
1.8 KiB
Text
==== tests/cases/compiler/constructorsWithSpecializedSignatures.ts (8 errors) ====
|
|
// errors
|
|
declare class C {
|
|
constructor(x: "hi");
|
|
~~~~~~~~~~~~~~~~~~~~~
|
|
!!! Specialized overload signature is not assignable to any non-specialized signature.
|
|
constructor(x: "foo");
|
|
~~~~~~~~~~~~~~~~~~~~~~
|
|
!!! Specialized overload signature is not assignable to any non-specialized signature.
|
|
constructor(x: number);
|
|
}
|
|
|
|
// ok
|
|
declare class C2 {
|
|
constructor(x: "hi");
|
|
constructor(x: "foo");
|
|
constructor(x: string);
|
|
}
|
|
|
|
// errors
|
|
class D {
|
|
constructor(x: "hi");
|
|
~~~~~~~~~~~~~~~~~~~~~
|
|
!!! Specialized overload signature is not assignable to any non-specialized signature.
|
|
constructor(x: "foo");
|
|
~~~~~~~~~~~~~~~~~~~~~~
|
|
!!! Specialized overload signature is not assignable to any non-specialized signature.
|
|
constructor(x: number);
|
|
constructor(x: "hi") { }
|
|
~~~~~~~~~~~~~~~~~~~~~~~~
|
|
!!! A signature with an implementation cannot use a string literal type.
|
|
}
|
|
|
|
// overloads are ok
|
|
class D2 {
|
|
constructor(x: "hi");
|
|
constructor(x: "foo");
|
|
constructor(x: string);
|
|
constructor(x: "hi") { } // error
|
|
~~~~~~~~~~~~~~~~~~~~~~~~
|
|
!!! A signature with an implementation cannot use a string literal type.
|
|
}
|
|
|
|
// errors
|
|
interface I {
|
|
new (x: "hi");
|
|
~~~~~~~~~~~~~~
|
|
!!! Specialized overload signature is not assignable to any non-specialized signature.
|
|
new (x: "foo");
|
|
~~~~~~~~~~~~~~~
|
|
!!! Specialized overload signature is not assignable to any non-specialized signature.
|
|
new (x: number);
|
|
}
|
|
|
|
// ok
|
|
interface I2 {
|
|
new (x: "hi");
|
|
new (x: "foo");
|
|
new (x: string);
|
|
} |