File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -23,12 +23,19 @@ async function postprocess() {
2323
2424 // strip out lib="dom", types="node", and types="react" references; these
2525 // are needed at build time, but would pollute the user's TS environment
26- const transformed = code . replace (
26+ let transformed = code . replace (
2727 / ^ * \/ \/ \/ * < r e f e r e n c e + ( l i b = " d o m " | t y p e s = " ( n o d e | r e a c t ) " ) .* ?\n / gm,
2828 // replace with same number of characters to avoid breaking source maps
2929 ( match ) => ' ' . repeat ( match . length - 1 ) + '\n' ,
3030 ) ;
3131
32+ // TypeScript's declaration emitter collapses /** @ts-ignore */ onto the same
33+ // line as the type declaration, which doesn't work. So we convert to // @ts-ignore
34+ // on its own line to properly suppresses errors.
35+ if ( file . endsWith ( '.d.ts' ) || file . endsWith ( '.d.mts' ) || file . endsWith ( '.d.cts' ) ) {
36+ transformed = transformed . replace ( / \/ \* \* @ t s - i g n o r e \b [ ^ * ] * \* \/ / gm, '// @ts-ignore\n' ) ;
37+ }
38+
3239 if ( transformed !== code ) {
3340 console . error ( `wrote ${ path . relative ( process . cwd ( ) , file ) } ` ) ;
3441 await fs . promises . writeFile ( file , transformed , 'utf8' ) ;
You can’t perform that action at this time.
0 commit comments