1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
=== tests/cases/compiler/propertyParameterWithQuestionMark.ts ===
class C {
>C : Symbol(C, Decl(propertyParameterWithQuestionMark.ts, 0, 0))
constructor(public x?) { }
>x : Symbol(C.x, Decl(propertyParameterWithQuestionMark.ts, 1, 16))
}
// x should be an optional property
var v: C = {}; // Should succeed
>v : Symbol(v, Decl(propertyParameterWithQuestionMark.ts, 5, 3))
>C : Symbol(C, Decl(propertyParameterWithQuestionMark.ts, 0, 0))
var v2: { x? }
>v2 : Symbol(v2, Decl(propertyParameterWithQuestionMark.ts, 6, 3))
>x : Symbol(x, Decl(propertyParameterWithQuestionMark.ts, 6, 9))
v = v2; // Should succeed
>v : Symbol(v, Decl(propertyParameterWithQuestionMark.ts, 5, 3))
>v2 : Symbol(v2, Decl(propertyParameterWithQuestionMark.ts, 6, 3))
var v3: { x } = new C; // Should fail
>v3 : Symbol(v3, Decl(propertyParameterWithQuestionMark.ts, 8, 3))
>x : Symbol(x, Decl(propertyParameterWithQuestionMark.ts, 8, 9))
>C : Symbol(C, Decl(propertyParameterWithQuestionMark.ts, 0, 0))
|