Skip to content

chore: typecheck scripts #11838

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/svelte/scripts/check-treeshakeability.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import virtual from '@rollup/plugin-virtual';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import { compile } from 'svelte/compiler';

/**
* @param {string} entry
*/
async function bundle_code(entry) {
const bundle = await rollup({
input: '__entry__',
Expand Down
15 changes: 14 additions & 1 deletion packages/svelte/scripts/process-messages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,23 @@ for (const category of fs.readdirSync('messages')) {
}
}

/**
* @param {string} name
* @param {string} dest
*/
function transform(name, dest) {
const source = fs
.readFileSync(new URL(`./templates/${name}.js`, import.meta.url), 'utf-8')
.replace(/\r\n/g, '\n');

/**
* @type {Array<{
* type: string;
* value: string;
* start: number;
* end: number
* }>}
*/
const comments = [];

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

for (const code in category) {
const { messages } = category[code];
/** @type {string[]} */
const vars = [];

const group = messages.map((text, i) => {
Expand Down Expand Up @@ -225,7 +238,7 @@ function transform(name, dest) {
Block(node, context) {
if (!node.value.includes('PARAMETER')) return;

const value = node.value
const value = /** @type {string} */ (node.value)
.split('\n')
.map((line) => {
if (line === ' * MESSAGE') {
Expand Down
6 changes: 4 additions & 2 deletions packages/svelte/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@
}
},
"include": [
"./src",
"./*.js",
"./scripts/",
"./src/",
"./tests/*/test.ts",
"./tests/runtime-browser/test-ssr.ts",
"./tests/*/samples/*/_config.js"
],
"exclude": ["./src/compiler/optimizer"]
"exclude": ["./scripts/process-messages/templates/", "./src/compiler/optimizer/"]
}
Loading