File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed
Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -300,6 +300,25 @@ export function tscEmit(tscOptions: TscOptions): TscResult {
300300 debug ( `got source file: ${ file . fileName } ` )
301301 let dtsCode : string | undefined
302302 let map : SourceMapInput | undefined
303+
304+ // fix #77
305+ const stripPrivateFields : ts . TransformerFactory < ts . SourceFile > = ( ctx ) => {
306+ const visitor = ( node : ts . Node ) => {
307+ if ( ts . isPropertySignature ( node ) && ts . isPrivateIdentifier ( node . name ) ) {
308+ return ctx . factory . updatePropertySignature (
309+ node ,
310+ node . modifiers ,
311+ ctx . factory . createStringLiteral ( node . name . text ) ,
312+ node . questionToken ,
313+ node . type ,
314+ )
315+ }
316+ return ts . visitEachChild ( node , visitor , ctx )
317+ }
318+ return ( sourceFile ) =>
319+ ts . visitNode ( sourceFile , visitor , ts . isSourceFile ) ?? sourceFile
320+ }
321+
303322 const { emitSkipped, diagnostics } = program . emit (
304323 file ,
305324 ( fileName , code ) => {
@@ -313,7 +332,7 @@ export function tscEmit(tscOptions: TscOptions): TscResult {
313332 } ,
314333 undefined ,
315334 true ,
316- undefined ,
335+ { afterDeclarations : [ stripPrivateFields ] } ,
317336 // @ts -expect-error private API: forceDtsEmit
318337 true ,
319338 )
You can’t perform that action at this time.
0 commit comments