From f92a0a4dfda3a4eff6474ca242c8aea4be9260d1 Mon Sep 17 00:00:00 2001 From: Simon H <5968653+dummdidumm@users.noreply.github.com> Date: Thu, 3 Jun 2021 13:07:20 +0200 Subject: [PATCH] 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 --- scripts/setupTypeScript.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/setupTypeScript.js b/scripts/setupTypeScript.js index 1eb6b772..133658af 100644 --- a/scripts/setupTypeScript.js +++ b/scripts/setupTypeScript.js @@ -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 @@ -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, `/// `) + // Delete this script, but not during testing if (!argv[2]) { // Remove the script