Skip to content

Commit 3bd3107

Browse files
author
Simon Holthausen
committed
bump ts to 4.0, ensure no new type syntax
1 parent 5fb01cc commit 3bd3107

File tree

3 files changed

+24
-9
lines changed

3 files changed

+24
-9
lines changed

package-lock.json

Lines changed: 8 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
"pretest": "npm run build",
8484
"posttest": "agadoo internal/index.mjs",
8585
"prepublishOnly": "node check_publish_env.js && npm run lint && npm test",
86-
"tsd": "tsc -p src/compiler --emitDeclarationOnly && tsc -p src/runtime --emitDeclarationOnly",
86+
"tsd": "tsc -p src/compiler --emitDeclarationOnly && tsc -p src/runtime --emitDeclarationOnly && node ./post-typegen.js",
8787
"lint": "eslint \"{src,test}/**/*.{ts,js}\""
8888
},
8989
"repository": {
@@ -140,7 +140,7 @@
140140
"sourcemap-codec": "^1.4.8",
141141
"tiny-glob": "^0.2.6",
142142
"tslib": "^2.0.3",
143-
"typescript": "^3.7.5"
143+
"typescript": "~4.0.0"
144144
},
145145
"nyc": {
146146
"include": [

post-typegen.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Svelte 3 types are generated using TS 3.7 . Using newer type syntax is therefore technically a breaking change.
2+
// `export type` / `import type` was introduced later, and needed now in one of the files.
3+
// Replace `export type` with `export` in the `d.ts` file as it doesn't make a difference in `d.ts` files.
4+
// This keeps backwards-compatibility
5+
6+
const fs = require('fs');
7+
8+
const path = 'types/runtime/index.d.ts';
9+
const content = fs.readFileSync(path, 'utf8');
10+
const replaced = content.replace('export type', 'export');
11+
if (content === replaced) {
12+
throw new Error('types/runtime/index.d.ts changed. Update post-typegen.js')
13+
}
14+
fs.writeFileSync(path, replaced);

0 commit comments

Comments
 (0)