File tree Expand file tree Collapse file tree 3 files changed +7
-5
lines changed
tests/baselines/reference Expand file tree Collapse file tree 3 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -1134,8 +1134,10 @@ namespace ts {
11341134 // it if it's not a well known symbol. In that case, the text of the name will be exactly
11351135 // what we want, namely the name expression enclosed in brackets.
11361136 writeTextOfNode ( currentText , node . name ) ;
1137- // If optional property emit ?
1138- if ( ( node . kind === SyntaxKind . PropertyDeclaration || node . kind === SyntaxKind . PropertySignature || node . kind === SyntaxKind . Parameter ) && hasQuestionToken ( node ) ) {
1137+ // If optional property emit ? but in the case of parameterProperty declaration with "?" indicating optional parameter for the constructor
1138+ // we don't want to emit property declaration with "?"
1139+ if ( ( node . kind === SyntaxKind . PropertyDeclaration || node . kind === SyntaxKind . PropertySignature ||
1140+ ( node . kind === SyntaxKind . Parameter && ! isParameterPropertyDeclaration ( node ) ) ) && hasQuestionToken ( node ) ) {
11391141 write ( "?" ) ;
11401142 }
11411143 if ( ( node . kind === SyntaxKind . PropertyDeclaration || node . kind === SyntaxKind . PropertySignature ) && node . parent . kind === SyntaxKind . TypeLiteral ) {
Original file line number Diff line number Diff line change @@ -247,7 +247,7 @@ export declare class ConstructorWithPrivateParameterProperty {
247247 constructor ( x : string ) ;
248248}
249249export declare class ConstructorWithOptionalParameterProperty {
250- x ? : string ;
250+ x : string ;
251251 constructor ( x ? : string ) ;
252252}
253253export declare class ConstructorWithParameterInitializer {
@@ -281,7 +281,7 @@ declare class GlobalConstructorWithPrivateParameterProperty {
281281 constructor ( x : string ) ;
282282}
283283declare class GlobalConstructorWithOptionalParameterProperty {
284- x ? : string ;
284+ x : string ;
285285 constructor ( x ?: string ) ;
286286}
287287declare class GlobalConstructorWithParameterInitializer {
Original file line number Diff line number Diff line change @@ -126,7 +126,7 @@ interface Foo {
126126}
127127declare function test1 ( x : Foo ) : void ;
128128declare class Bar {
129- d ? : number ;
129+ d: number ;
130130 e: number ;
131131 a: number ;
132132 b ? : number ;
You can’t perform that action at this time.
0 commit comments