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

Commit

Permalink
Update svelte-check and tsconfig-base in setupTypeScript (#246)
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
dummdidumm authored Jun 3, 2021
1 parent d80f672 commit f92a0a4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions scripts/setupTypeScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ const projectRoot = argv[2] || path.join(__dirname, "..")
// Add deps to pkg.json
const packageJSON = JSON.parse(fs.readFileSync(path.join(projectRoot, "package.json"), "utf8"))
packageJSON.devDependencies = Object.assign(packageJSON.devDependencies, {
"svelte-check": "^1.0.0",
"svelte-check": "^2.0.0",
"svelte-preprocess": "^4.0.0",
"@rollup/plugin-typescript": "^8.0.0",
"typescript": "^4.0.0",
"tslib": "^2.0.0",
"@tsconfig/svelte": "^1.0.0"
"@tsconfig/svelte": "^2.0.0"
})

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

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

// Add global.d.ts
const dtsPath = path.join(projectRoot, "src", "global.d.ts")
fs.writeFileSync(dtsPath, `/// <reference types="svelte" />`)

// Delete this script, but not during testing
if (!argv[2]) {
// Remove the script
Expand Down

0 comments on commit f92a0a4

Please sign in to comment.