45 lines
881 B
TypeScript
45 lines
881 B
TypeScript
//// [stringLiteralTypesInImplementationSignatures.ts]
|
|
// String literal types are only valid in overload signatures
|
|
|
|
function foo(x: 'hi') { }
|
|
var f = function foo(x: 'hi') { }
|
|
var f2 = (x: 'hi', y: 'hi') => { }
|
|
|
|
class C {
|
|
foo(x: 'hi') { }
|
|
}
|
|
|
|
interface I {
|
|
(x: 'hi');
|
|
foo(x: 'hi', y: 'hi');
|
|
}
|
|
|
|
var a: {
|
|
(x: 'hi');
|
|
foo(x: 'hi');
|
|
}
|
|
|
|
var b = {
|
|
foo(x: 'hi') { },
|
|
a: function foo(x: 'hi', y: 'hi') { },
|
|
b: (x: 'hi') => { }
|
|
}
|
|
|
|
|
|
//// [stringLiteralTypesInImplementationSignatures.js]
|
|
// String literal types are only valid in overload signatures
|
|
function foo(x) { }
|
|
var f = function foo(x) { };
|
|
var f2 = function (x, y) { };
|
|
var C = (function () {
|
|
function C() {
|
|
}
|
|
C.prototype.foo = function (x) { };
|
|
return C;
|
|
})();
|
|
var a;
|
|
var b = {
|
|
foo: function (x) { },
|
|
a: function foo(x, y) { },
|
|
b: function (x) { }
|
|
};
|