49 lines
1.8 KiB
Plaintext
49 lines
1.8 KiB
Plaintext
|
==== tests/cases/conformance/types/objectTypeLiteral/callSignatures/stringLiteralTypesInImplementationSignatures.ts (11 errors) ====
|
||
|
// String literal types are only valid in overload signatures
|
||
|
|
||
|
function foo(x: 'hi') { }
|
||
|
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||
|
!!! A signature with an implementation cannot use a string literal type.
|
||
|
var f = function foo(x: 'hi') { }
|
||
|
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||
|
!!! A signature with an implementation cannot use a string literal type.
|
||
|
var f2 = (x: 'hi', y: 'hi') => { }
|
||
|
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||
|
!!! A signature with an implementation cannot use a string literal type.
|
||
|
|
||
|
class C {
|
||
|
foo(x: 'hi') { }
|
||
|
~~~~~~~~~~~~~~~~
|
||
|
!!! A signature with an implementation cannot use a string literal type.
|
||
|
}
|
||
|
|
||
|
interface I {
|
||
|
(x: 'hi');
|
||
|
~~~~~~~~~~
|
||
|
!!! Specialized overload signature is not assignable to any non-specialized signature.
|
||
|
foo(x: 'hi', y: 'hi');
|
||
|
~~~~~~~~~~~~~~~~~~~~~~
|
||
|
!!! Specialized overload signature is not assignable to any non-specialized signature.
|
||
|
}
|
||
|
|
||
|
var a: {
|
||
|
(x: 'hi');
|
||
|
~~~~~~~~~~
|
||
|
!!! Specialized overload signature is not assignable to any non-specialized signature.
|
||
|
foo(x: 'hi');
|
||
|
~~~~~~~~~~~~~
|
||
|
!!! Specialized overload signature is not assignable to any non-specialized signature.
|
||
|
}
|
||
|
|
||
|
var b = {
|
||
|
foo(x: 'hi') { },
|
||
|
~~~~~~~~~~~~~~~~
|
||
|
!!! A signature with an implementation cannot use a string literal type.
|
||
|
a: function foo(x: 'hi', y: 'hi') { },
|
||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||
|
!!! A signature with an implementation cannot use a string literal type.
|
||
|
b: (x: 'hi') => { }
|
||
|
~~~~~~~~~~~~~~~~
|
||
|
!!! A signature with an implementation cannot use a string literal type.
|
||
|
}
|
||
|
|