Skip to content

Commit e4faa78

Browse files
authored
chore: typecheck scripts (#11838)
* chore: typecheck scripts * typecast
1 parent 311b524 commit e4faa78

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
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: 14 additions & 1 deletion
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) => {
@@ -225,7 +238,7 @@ function transform(name, dest) {
225238
Block(node, context) {
226239
if (!node.value.includes('PARAMETER')) return;
227240

228-
const value = node.value
241+
const value = /** @type {string} */ (node.value)
229242
.split('\n')
230243
.map((line) => {
231244
if (line === ' * MESSAGE') {

packages/svelte/tsconfig.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,12 @@
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": ["./scripts/process-messages/templates/", "./src/compiler/optimizer/"]
4042
}

0 commit comments

Comments
 (0)