mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
48 lines
908 B
TypeScript
48 lines
908 B
TypeScript
//// [tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithParameterInitializers2.ts] ////
|
|
|
|
//// [callSignaturesWithParameterInitializers2.ts]
|
|
// Optional parameters allow initializers only in implementation signatures
|
|
// All the below declarations are errors
|
|
|
|
function foo(x = 2);
|
|
function foo(x = 1) { }
|
|
|
|
foo(1);
|
|
foo();
|
|
|
|
class C {
|
|
foo(x = 2);
|
|
foo(x = 1) { }
|
|
}
|
|
|
|
declare var c: C;
|
|
c.foo();
|
|
c.foo(1);
|
|
|
|
var b = {
|
|
foo(x = 1), // error
|
|
foo(x = 1) { }, // error
|
|
}
|
|
|
|
b.foo();
|
|
b.foo(1);
|
|
|
|
//// [callSignaturesWithParameterInitializers2.js]
|
|
"use strict";
|
|
// Optional parameters allow initializers only in implementation signatures
|
|
// All the below declarations are errors
|
|
function foo(x = 1) { }
|
|
foo(1);
|
|
foo();
|
|
class C {
|
|
foo(x = 1) { }
|
|
}
|
|
c.foo();
|
|
c.foo(1);
|
|
var b = {
|
|
foo(x = 1) { }, // error
|
|
foo(x = 1) { }, // error
|
|
};
|
|
b.foo();
|
|
b.foo(1);
|