Skip to content
This repository was archived by the owner on Feb 15, 2023. It is now read-only.

Commit f92a0a4

Browse files
authored
Update svelte-check and tsconfig-base in setupTypeScript (#246)
- since `svelte-check` 1.6.0, one can pass a tsconfig path and get better diagnostics (scoped to the project files, including TS/JS) -> update accordingly - `svelte-check` got a major version bump, update accordingly - `@tsconfig/svelte` 2.0.0 doesn't includes `"types": ["svelte"]` anymore, which will avoid confusion around other global types not getting picked up. To not get errors in TS files when importing Svelte files, a new `global.d.ts` is added which contains a reference so those types which were previously provided through the `"types"` option are picked up
1 parent d80f672 commit f92a0a4

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

scripts/setupTypeScript.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ const projectRoot = argv[2] || path.join(__dirname, "..")
2222
// Add deps to pkg.json
2323
const packageJSON = JSON.parse(fs.readFileSync(path.join(projectRoot, "package.json"), "utf8"))
2424
packageJSON.devDependencies = Object.assign(packageJSON.devDependencies, {
25-
"svelte-check": "^1.0.0",
25+
"svelte-check": "^2.0.0",
2626
"svelte-preprocess": "^4.0.0",
2727
"@rollup/plugin-typescript": "^8.0.0",
2828
"typescript": "^4.0.0",
2929
"tslib": "^2.0.0",
30-
"@tsconfig/svelte": "^1.0.0"
30+
"@tsconfig/svelte": "^2.0.0"
3131
})
3232

3333
// Add script for checking
3434
packageJSON.scripts = Object.assign(packageJSON.scripts, {
35-
"validate": "svelte-check"
35+
"check": "svelte-check --tsconfig ./tsconfig.json"
3636
})
3737

3838
// Write the package JSON
@@ -85,6 +85,10 @@ const tsconfig = `{
8585
const tsconfigPath = path.join(projectRoot, "tsconfig.json")
8686
fs.writeFileSync(tsconfigPath, tsconfig)
8787

88+
// Add global.d.ts
89+
const dtsPath = path.join(projectRoot, "src", "global.d.ts")
90+
fs.writeFileSync(dtsPath, `/// <reference types="svelte" />`)
91+
8892
// Delete this script, but not during testing
8993
if (!argv[2]) {
9094
// Remove the script

0 commit comments

Comments
 (0)