chore: typecheck scripts (#11838)

* chore: typecheck scripts

* typecast
pull/11857/head
Ben McCann 1 year ago committed by GitHub
parent 311b52453e
commit e4faa7805d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -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__',

@ -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, {
@ -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) => {
@ -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') {

@ -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…
Cancel
Save