Have definite assignment assertions on property signatures mark them as typescript (#35270)
This commit is contained in:
parent
9b78599c63
commit
cfa367d7f9
|
@ -3643,7 +3643,7 @@ namespace ts {
|
||||||
let transformFlags = subtreeFlags | TransformFlags.ContainsClassFields;
|
let transformFlags = subtreeFlags | TransformFlags.ContainsClassFields;
|
||||||
|
|
||||||
// Decorators, TypeScript-specific modifiers, and type annotations are TypeScript syntax.
|
// Decorators, TypeScript-specific modifiers, and type annotations are TypeScript syntax.
|
||||||
if (some(node.decorators) || hasModifier(node, ModifierFlags.TypeScriptModifier) || node.type || node.questionToken) {
|
if (some(node.decorators) || hasModifier(node, ModifierFlags.TypeScriptModifier) || node.type || node.questionToken || node.exclamationToken) {
|
||||||
transformFlags |= TransformFlags.AssertTypeScript;
|
transformFlags |= TransformFlags.AssertTypeScript;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
tests/cases/compiler/definiteAssignmentWithErrorStillStripped.ts(2,6): error TS1255: A definite assignment assertion '!' is not permitted in this context.
|
||||||
|
|
||||||
|
|
||||||
|
==== tests/cases/compiler/definiteAssignmentWithErrorStillStripped.ts (1 errors) ====
|
||||||
|
class C {
|
||||||
|
p!;
|
||||||
|
~
|
||||||
|
!!! error TS1255: A definite assignment assertion '!' is not permitted in this context.
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
//// [definiteAssignmentWithErrorStillStripped.ts]
|
||||||
|
class C {
|
||||||
|
p!;
|
||||||
|
}
|
||||||
|
|
||||||
|
//// [definiteAssignmentWithErrorStillStripped.js]
|
||||||
|
class C {
|
||||||
|
p;
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
=== tests/cases/compiler/definiteAssignmentWithErrorStillStripped.ts ===
|
||||||
|
class C {
|
||||||
|
>C : Symbol(C, Decl(definiteAssignmentWithErrorStillStripped.ts, 0, 0))
|
||||||
|
|
||||||
|
p!;
|
||||||
|
>p : Symbol(C.p, Decl(definiteAssignmentWithErrorStillStripped.ts, 0, 9))
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
=== tests/cases/compiler/definiteAssignmentWithErrorStillStripped.ts ===
|
||||||
|
class C {
|
||||||
|
>C : C
|
||||||
|
|
||||||
|
p!;
|
||||||
|
>p : any
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
// @target: esnext
|
||||||
|
// @useDefineForClassFields: true
|
||||||
|
class C {
|
||||||
|
p!;
|
||||||
|
}
|
Loading…
Reference in a new issue