16 lines
632 B
Plaintext
16 lines
632 B
Plaintext
==== tests/cases/compiler/propertyParameterWithQuestionMark.ts (2 errors) ====
|
|
class C {
|
|
constructor(public x?) { }
|
|
}
|
|
|
|
// x should not be an optional property
|
|
var v: C = {}; // Should fail
|
|
~
|
|
!!! error TS2322: Type '{}' is not assignable to type 'C':
|
|
!!! error TS2322: Property 'x' is missing in type '{}'.
|
|
var v2: { x? }
|
|
v = v2; // Should fail
|
|
~
|
|
!!! error TS2322: Type '{ x?: any; }' is not assignable to type 'C':
|
|
!!! error TS2322: Required property 'x' cannot be reimplemented with optional property in '{ x?: any; }'.
|
|
var v3: { x } = new C; // Should succeed |