mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 21:53:42 -06:00
strip QuestionToken from MethodDeclaration and PropertyDeclaration emit (#34954)
* strip QuestionToken from MethodDeclartion emit Fixes: #34953 * test property emit
This commit is contained in:
parent
5c951635e5
commit
94f85901d7
@ -3595,7 +3595,8 @@ namespace ts {
|
||||
|| hasModifier(node, ModifierFlags.TypeScriptModifier)
|
||||
|| node.typeParameters
|
||||
|| node.type
|
||||
|| !node.body) {
|
||||
|| !node.body
|
||||
|| node.questionToken) {
|
||||
transformFlags |= TransformFlags.AssertTypeScript;
|
||||
}
|
||||
|
||||
@ -3642,7 +3643,7 @@ namespace ts {
|
||||
let transformFlags = subtreeFlags | TransformFlags.ContainsClassFields;
|
||||
|
||||
// Decorators, TypeScript-specific modifiers, and type annotations are TypeScript syntax.
|
||||
if (some(node.decorators) || hasModifier(node, ModifierFlags.TypeScriptModifier) || node.type) {
|
||||
if (some(node.decorators) || hasModifier(node, ModifierFlags.TypeScriptModifier) || node.type || node.questionToken) {
|
||||
transformFlags |= TransformFlags.AssertTypeScript;
|
||||
}
|
||||
|
||||
|
||||
10
tests/baselines/reference/optionalMethod.js
Normal file
10
tests/baselines/reference/optionalMethod.js
Normal file
@ -0,0 +1,10 @@
|
||||
//// [optionalMethod.ts]
|
||||
class Base {
|
||||
method?() { }
|
||||
}
|
||||
|
||||
|
||||
//// [optionalMethod.js]
|
||||
class Base {
|
||||
method() { }
|
||||
}
|
||||
10
tests/baselines/reference/optionalProperty.js
Normal file
10
tests/baselines/reference/optionalProperty.js
Normal file
@ -0,0 +1,10 @@
|
||||
//// [optionalProperty.ts]
|
||||
class C {
|
||||
prop?;
|
||||
}
|
||||
|
||||
|
||||
//// [optionalProperty.js]
|
||||
class C {
|
||||
prop;
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
// @target: esnext
|
||||
// @noTypesAndSymbols: true
|
||||
class Base {
|
||||
method?() { }
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
// @target: esnext
|
||||
// @useDefineForClassFields: true
|
||||
// @noTypesAndSymbols: true
|
||||
class C {
|
||||
prop?;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user