File tree 3 files changed +7
-5
lines changed
tests/baselines/reference
3 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -1132,8 +1132,10 @@ namespace ts {
1132
1132
// it if it's not a well known symbol. In that case, the text of the name will be exactly
1133
1133
// what we want, namely the name expression enclosed in brackets.
1134
1134
writeTextOfNode ( currentText , node . name ) ;
1135
- // If optional property emit ?
1136
- if ( ( node . kind === SyntaxKind . PropertyDeclaration || node . kind === SyntaxKind . PropertySignature || node . kind === SyntaxKind . Parameter ) && hasQuestionToken ( node ) ) {
1135
+ // If optional property emit ? but in the case of parameterProperty declaration with "?" indicating optional parameter for the constructor
1136
+ // we don't want to emit property declaration with "?"
1137
+ if ( ( node . kind === SyntaxKind . PropertyDeclaration || node . kind === SyntaxKind . PropertySignature ||
1138
+ ( node . kind === SyntaxKind . Parameter && ! isParameterPropertyDeclaration ( node ) ) ) && hasQuestionToken ( node ) ) {
1137
1139
write ( "?" ) ;
1138
1140
}
1139
1141
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 {
247
247
constructor ( x : string ) ;
248
248
}
249
249
export declare class ConstructorWithOptionalParameterProperty {
250
- x ? : string ;
250
+ x : string ;
251
251
constructor ( x ? : string ) ;
252
252
}
253
253
export declare class ConstructorWithParameterInitializer {
@@ -281,7 +281,7 @@ declare class GlobalConstructorWithPrivateParameterProperty {
281
281
constructor ( x : string ) ;
282
282
}
283
283
declare class GlobalConstructorWithOptionalParameterProperty {
284
- x ? : string ;
284
+ x : string ;
285
285
constructor ( x ?: string ) ;
286
286
}
287
287
declare class GlobalConstructorWithParameterInitializer {
Original file line number Diff line number Diff line change @@ -126,7 +126,7 @@ interface Foo {
126
126
}
127
127
declare function test1 ( x : Foo ) : void ;
128
128
declare class Bar {
129
- d ? : number ;
129
+ d: number ;
130
130
e: number ;
131
131
a: number ;
132
132
b ? : number ;
You can’t perform that action at this time.
0 commit comments