54 lines
2 KiB
Plaintext
54 lines
2 KiB
Plaintext
==== tests/cases/conformance/types/objectTypeLiteral/callSignatures/stringLiteralTypesInImplementationSignatures2.ts (12 errors) ====
|
|
// String literal types are only valid in overload signatures
|
|
|
|
function foo(x: any);
|
|
function foo(x: 'hi') { }
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
!!! error TS2381: A signature with an implementation cannot use a string literal type.
|
|
|
|
class C {
|
|
foo(x: string);
|
|
foo(x: 'hi') { }
|
|
~~~~~~~~~~~~~~~~
|
|
!!! error TS2381: A signature with an implementation cannot use a string literal type.
|
|
}
|
|
|
|
interface I {
|
|
(x: 'a');
|
|
~~~~~~~~~
|
|
!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature.
|
|
(x: 'hi');
|
|
~~~~~~~~~~
|
|
!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature.
|
|
foo(x: 'a', y: 'a');
|
|
~~~~~~~~~~~~~~~~~~~~
|
|
!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature.
|
|
foo(x: 'hi', y: 'hi');
|
|
~~~~~~~~~~~~~~~~~~~~~~
|
|
!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature.
|
|
}
|
|
|
|
var a: {
|
|
(x: 'hi');
|
|
~~~~~~~~~~
|
|
!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature.
|
|
(x: 'a');
|
|
~~~~~~~~~
|
|
!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature.
|
|
foo(x: 'hi');
|
|
~~~~~~~~~~~~~
|
|
!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature.
|
|
foo(x: 'a');
|
|
~~~~~~~~~~~~
|
|
!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature.
|
|
}
|
|
|
|
var b = {
|
|
foo(x: 'hi') { },
|
|
~~~~~~~~~~~~~~~~
|
|
!!! error TS2381: A signature with an implementation cannot use a string literal type.
|
|
foo(x: 'a') { },
|
|
~~~
|
|
!!! error TS2300: Duplicate identifier 'foo'.
|
|
}
|
|
|