34 lines
887 B
Plaintext
34 lines
887 B
Plaintext
|
==== tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithParameterInitializers2.ts (4 errors) ====
|
||
|
// Optional parameters allow initializers only in implementation signatures
|
||
|
// All the below declarations are errors
|
||
|
|
||
|
function foo(x = 2);
|
||
|
~~~~~
|
||
|
!!! A parameter initializer is only allowed in a function or constructor implementation.
|
||
|
function foo(x = 1) { }
|
||
|
|
||
|
foo(1);
|
||
|
foo();
|
||
|
|
||
|
class C {
|
||
|
foo(x = 2);
|
||
|
~~~~~
|
||
|
!!! A parameter initializer is only allowed in a function or constructor implementation.
|
||
|
foo(x = 1) { }
|
||
|
}
|
||
|
|
||
|
var c: C;
|
||
|
c.foo();
|
||
|
c.foo(1);
|
||
|
|
||
|
var b = {
|
||
|
foo(x = 1),
|
||
|
~
|
||
|
!!! '{' expected.
|
||
|
foo(x = 1) { },
|
||
|
~~~
|
||
|
!!! Duplicate identifier 'foo'.
|
||
|
}
|
||
|
|
||
|
b.foo();
|
||
|
b.foo(1);
|