-
Notifications
You must be signed in to change notification settings - Fork 1
/
typescript:configure.js
50 lines (44 loc) · 1.12 KB
/
typescript:configure.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import update from '../lib/update.js';
import contains from '../lib/contains.js';
import stringify from '../lib/json/stringify.js';
const filename = 'tsconfig.json';
export const description = `Create ${filename}.`;
export const commit = {
type: 'config',
scope: 'typescript',
subject: description,
};
export async function postcondition({readJSON, assert}) {
await contains({
assert,
read: () => readJSON(filename),
test: (contents) => assert.deepStrictEqual(contents, expected),
});
}
export async function precondition({exists, assert}) {
assert(!(await exists(filename)));
}
export async function apply({read, write}) {
await update({
create: true,
overwrite: false,
read: () => read(filename),
write: (data) => write(filename, data),
edit: () => stringify(expected) + '\n',
});
}
const expected = {
$schema: 'https://json.schemastore.org/tsconfig',
compilerOptions: {
allowJs: true,
emitDeclarationOnly: true,
declaration: true,
outDir: 'types',
checkJs: true,
target: 'es2020',
module: 'es2020',
moduleResolution: 'node',
allowSyntheticDefaultImports: true,
},
include: ['src/**/*'],
};