Skip to content

Commit 1b8e5a7

Browse files
committed
chore: typecheck scripts
1 parent fd942b7 commit 1b8e5a7

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

packages/svelte/scripts/check-treeshakeability.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import virtual from '@rollup/plugin-virtual';
55
import { nodeResolve } from '@rollup/plugin-node-resolve';
66
import { compile } from 'svelte/compiler';
77

8+
/**
9+
* @param {string} entry
10+
*/
811
async function bundle_code(entry) {
912
const bundle = await rollup({
1013
input: '__entry__',

packages/svelte/scripts/process-messages/index.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,23 @@ for (const category of fs.readdirSync('messages')) {
5454
}
5555
}
5656

57+
/**
58+
* @param {string} name
59+
* @param {string} dest
60+
*/
5761
function transform(name, dest) {
5862
const source = fs
5963
.readFileSync(new URL(`./templates/${name}.js`, import.meta.url), 'utf-8')
6064
.replace(/\r\n/g, '\n');
6165

66+
/**
67+
* @type {Array<{
68+
* type: string;
69+
* value: string;
70+
* start: number;
71+
* end: number
72+
* }>}
73+
*/
6274
const comments = [];
6375

6476
let ast = acorn.parse(source, {
@@ -135,6 +147,7 @@ function transform(name, dest) {
135147

136148
for (const code in category) {
137149
const { messages } = category[code];
150+
/** @type {string[]} */
138151
const vars = [];
139152

140153
const group = messages.map((text, i) => {
@@ -227,7 +240,7 @@ function transform(name, dest) {
227240

228241
const value = node.value
229242
.split('\n')
230-
.map((line) => {
243+
.map(/** @param {string} line */ (line) => {
231244
if (line === ' * MESSAGE') {
232245
return messages[messages.length - 1]
233246
.split('\n')
@@ -249,7 +262,7 @@ function transform(name, dest) {
249262

250263
return line;
251264
})
252-
.filter((x) => x !== '')
265+
.filter(/** @param {string} x */ (x) => x !== '')
253266
.join('\n');
254267

255268
if (value !== node.value) {

packages/svelte/tsconfig.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,15 @@
3131
}
3232
},
3333
"include": [
34-
"./src",
34+
"./*.js",
35+
"./scripts/",
36+
"./src/",
3537
"./tests/*/test.ts",
3638
"./tests/runtime-browser/test-ssr.ts",
3739
"./tests/*/samples/*/_config.js"
3840
],
39-
"exclude": ["./src/compiler/optimizer"]
41+
"exclude": [
42+
"./scripts/process-messages/templates/",
43+
"./src/compiler/optimizer/"
44+
]
4045
}

0 commit comments

Comments
 (0)