TypeScript/tests/baselines/reference/propertyParameterWithQuestionMark.errors.txt

16 lines
562 B
Text
Raw Normal View History

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-13 01:04:16 +02:00
!!! Type '{}' is not assignable to type 'C':
!!! Property 'x' is missing in type '{}'.
var v2: { x? }
v = v2; // Should fail
~
!!! Type '{ x?: any; }' is not assignable to type 'C':
!!! 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