2014-10-28 08:28:59 +01:00
|
|
|
tests/cases/compiler/propertyParameterWithQuestionMark.ts(6,5): error TS2323: Type '{}' is not assignable to type 'C'.
|
2014-09-12 22:35:07 +02:00
|
|
|
Property 'x' is missing in type '{}'.
|
2014-10-28 08:28:59 +01:00
|
|
|
tests/cases/compiler/propertyParameterWithQuestionMark.ts(8,1): error TS2323: Type '{ x?: any; }' is not assignable to type 'C'.
|
2014-09-18 02:05:45 +02:00
|
|
|
Property 'x' is optional in type '{ x?: any; }' but required in type 'C'.
|
2014-09-12 22:35:07 +02:00
|
|
|
|
|
|
|
|
2014-07-13 01:04:16 +02:00
|
|
|
==== tests/cases/compiler/propertyParameterWithQuestionMark.ts (2 errors) ====
|
|
|
|
class C {
|
|
|
|
constructor(public x?) { }
|
|
|
|
}
|
|
|
|
|
|
|
|
// x should not be an optional property
|
|
|
|
var v: C = {}; // Should fail
|
2014-07-19 02:30:06 +02:00
|
|
|
~
|
2014-10-28 08:28:59 +01:00
|
|
|
!!! error TS2323: Type '{}' is not assignable to type 'C'.
|
|
|
|
!!! error TS2323: Property 'x' is missing in type '{}'.
|
2014-07-13 01:04:16 +02:00
|
|
|
var v2: { x? }
|
|
|
|
v = v2; // Should fail
|
|
|
|
~
|
2014-10-28 08:28:59 +01:00
|
|
|
!!! error TS2323: Type '{ x?: any; }' is not assignable to type 'C'.
|
|
|
|
!!! error TS2323: Property 'x' is optional in type '{ x?: any; }' but required in type 'C'.
|
2014-07-13 01:04:16 +02:00
|
|
|
var v3: { x } = new C; // Should succeed
|