File tree Expand file tree Collapse file tree 3 files changed +19
-6
lines changed Expand file tree Collapse file tree 3 files changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,10 @@ async function main() {
23
23
const libFiles = await getLibFiles ( ) ;
24
24
const hasDiffFiles : string [ ] = [ ] ;
25
25
for ( const [ targetFile , sourceFile ] of libFiles . entries ( ) ) {
26
- const betterLib = generate ( tsLibDir , targetFile , sourceFile , false ) ;
26
+ const betterLib = generate ( tsLibDir , targetFile , sourceFile , {
27
+ emitOriginalAsComment : false ,
28
+ emitNoDefaultLib : false ,
29
+ } ) ;
27
30
if ( betterLib === undefined ) {
28
31
continue ;
29
32
}
Original file line number Diff line number Diff line change @@ -21,7 +21,10 @@ async function main() {
21
21
22
22
// modify each lib file
23
23
for ( const [ targetFile , sourceFile ] of libFiles . entries ( ) ) {
24
- let result = generate ( tsLibDir , targetFile , sourceFile , true ) ;
24
+ let result = generate ( tsLibDir , targetFile , sourceFile , {
25
+ emitOriginalAsComment : true ,
26
+ emitNoDefaultLib : true ,
27
+ } ) ;
25
28
if ( result === undefined ) {
26
29
continue ;
27
30
}
Original file line number Diff line number Diff line change @@ -6,14 +6,19 @@ import { projectDir } from "./projectDir";
6
6
7
7
const betterLibDir = path . join ( projectDir , "lib" ) ;
8
8
9
+ type GenerateOptions = {
10
+ emitOriginalAsComment ?: boolean ;
11
+ emitNoDefaultLib ?: boolean ;
12
+ } ;
13
+
9
14
/**
10
15
* Generate one better lib file.
11
16
*/
12
17
export function generate (
13
18
tsLibDir : string ,
14
19
targetFile : string ,
15
20
sourceFile : string ,
16
- emitOriginalAsComment : boolean
21
+ { emitOriginalAsComment = false , emitNoDefaultLib = false } : GenerateOptions
17
22
) : string | undefined {
18
23
const tsLibFile = path . join ( tsLibDir , sourceFile ) ;
19
24
const originalProgram = ts . createProgram ( [ tsLibFile ] , { } ) ;
@@ -24,9 +29,11 @@ export function generate(
24
29
25
30
const printer = ts . createPrinter ( ) ;
26
31
27
- // This is used as a good indicator of being a default lib file
28
- let result = `/// <reference no-default-lib="true"/>
29
- ` ;
32
+ let result = emitNoDefaultLib
33
+ ? // This is used as a good indicator of being a default lib file
34
+ `/// <reference no-default-lib="true"/>
35
+ `
36
+ : "" ;
30
37
31
38
const replacementTargets = scanBetterFile ( printer , targetFile ) ;
32
39
You can’t perform that action at this time.
0 commit comments