-
Notifications
You must be signed in to change notification settings - Fork 1
/
add-ts-nocheck.cjs
62 lines (53 loc) · 1.96 KB
/
add-ts-nocheck.cjs
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
51
52
53
54
55
56
57
58
59
60
61
62
/*
Fix for "tsc --noEmit" issue:
https://github.com/solidjs/solid-start/issues/255
*/
const fs = require('fs')
const ADDED_STR = '// @ts-nocheck\n\n'
const FILES = [
'node_modules/solid-start/data/createRouteAction.tsx',
'node_modules/solid-start/data/createRouteData.tsx',
'node_modules/solid-start/data/Form.tsx',
'node_modules/solid-start/entry-client/mount.tsx',
'node_modules/solid-start/entry-client/StartClient.tsx',
'node_modules/solid-start/entry-server/render.ts',
'node_modules/solid-start/entry-server/StartServer.tsx',
'node_modules/solid-start/error-boundary/ErrorBoundary.tsx',
'node_modules/solid-start/islands/index.tsx',
'node_modules/solid-start/islands/router.ts',
'node_modules/solid-start/root/InlineStyles.tsx',
'node_modules/solid-start/root/Links.tsx',
'node_modules/solid-start/root/Scripts.tsx',
'node_modules/solid-start/router.tsx',
'node_modules/solid-start/server/components/HttpHeader.tsx',
'node_modules/solid-start/server/components/HttpStatusCode.tsx',
'node_modules/solid-start/server/middleware.ts',
'node_modules/solid-start/server/responses.ts',
'node_modules/solid-start/server/server-functions/server.ts',
'node_modules/solid-start/types.ts',
'node_modules/solid-start/vite/plugin.d.ts',
]
Promise.allSettled(FILES.map(addTsNoCheck)).then(results => {
let hasErrors = false
for (const result of results) {
if (result.status === 'rejected') {
hasErrors = true
// eslint-disable-next-line no-console
console.error(result.reason)
}
}
if (hasErrors) {
process.exit(1)
}
})
async function addTsNoCheck(file) {
const content = fs.readFileSync(file).toString()
if (content.includes(ADDED_STR)) {
// eslint-disable-next-line no-console
console.log(JSON.stringify(ADDED_STR), 'is already in', file)
} else {
fs.writeFileSync(file, ADDED_STR + content)
// eslint-disable-next-line no-console
console.log(JSON.stringify(ADDED_STR), 'added into', file)
}
}