@@ -300,6 +300,34 @@ namespace ts {
300300 } ) ;
301301 } ) ;
302302
303+ // https://github.com/microsoft/TypeScript/issues/33295
304+ testBaseline ( "transformParameterProperty" , ( ) => {
305+ return transpileModule ( "" , {
306+ transformers : {
307+ before : [ transformAddParameterProperty ] ,
308+ } ,
309+ compilerOptions : {
310+ target : ScriptTarget . ES5 ,
311+ newLine : NewLineKind . CarriageReturnLineFeed ,
312+ }
313+ } ) . outputText ;
314+
315+ function transformAddParameterProperty ( _context : TransformationContext ) {
316+ return ( sourceFile : SourceFile ) : SourceFile => {
317+ return visitNode ( sourceFile ) ;
318+ } ;
319+ function visitNode ( sf : SourceFile ) {
320+ // produce `class Foo { constructor(@Dec private x) {} }`;
321+ // The decorator is required to trigger ts.ts transformations.
322+ const classDecl = createClassDeclaration ( [ ] , [ ] , "Foo" , /*typeParameters*/ undefined , /*heritageClauses*/ undefined , [
323+ createConstructor ( /*decorators*/ undefined , /*modifiers*/ undefined , [
324+ createParameter ( /*decorators*/ [ createDecorator ( createIdentifier ( "Dec" ) ) ] , /*modifiers*/ [ createModifier ( SyntaxKind . PrivateKeyword ) ] , /*dotDotDotToken*/ undefined , "x" ) ] , createBlock ( [ ] ) )
325+ ] ) ;
326+ return updateSourceFileNode ( sf , [ classDecl ] ) ;
327+ }
328+ }
329+ } ) ;
330+
303331 function baselineDeclarationTransform ( text : string , opts : TranspileOptions ) {
304332 const fs = vfs . createFromFileSystem ( Harness . IO , /*caseSensitive*/ true , { documents : [ new documents . TextDocument ( "/.src/index.ts" , text ) ] } ) ;
305333 const host = new fakes . CompilerHost ( fs , opts . compilerOptions ) ;
@@ -389,7 +417,7 @@ class Clazz {
389417}
390418` , {
391419 transformers : {
392- before : [ addSyntheticComment ( n => isPropertyDeclaration ( n ) || isParameterPropertyDeclaration ( n ) || isClassDeclaration ( n ) || isConstructorDeclaration ( n ) ) ] ,
420+ before : [ addSyntheticComment ( n => isPropertyDeclaration ( n ) || isParameterPropertyDeclaration ( n , n . parent ) || isClassDeclaration ( n ) || isConstructorDeclaration ( n ) ) ] ,
393421 } ,
394422 compilerOptions : {
395423 target : ScriptTarget . ES2015 ,
0 commit comments