mirror of https://github.com/sveltejs/svelte
parent
995c509708
commit
a8e616be78
@ -1,14 +0,0 @@
|
|||||||
// Svelte 3 types are generated using TS 3.7 . Using newer type syntax is therefore technically a breaking change.
|
|
||||||
// `export type` / `import type` was introduced later, and needed now in one of the files.
|
|
||||||
// Replace `export type` with `export` in the `d.ts` file as it doesn't make a difference in `d.ts` files.
|
|
||||||
// This keeps backwards-compatibility
|
|
||||||
|
|
||||||
const fs = require('fs');
|
|
||||||
|
|
||||||
const path = 'types/runtime/index.d.ts';
|
|
||||||
const content = fs.readFileSync(path, 'utf8');
|
|
||||||
const replaced = content.replace('export type', 'export');
|
|
||||||
if (content === replaced) {
|
|
||||||
throw new Error('types/runtime/index.d.ts changed. Update post-typegen.js')
|
|
||||||
}
|
|
||||||
fs.writeFileSync(path, replaced);
|
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
// This script generates the TypeScript definitions
|
||||||
|
|
||||||
|
const { execSync } = require('child_process');
|
||||||
|
const { readFileSync, writeFileSync } = require('fs');
|
||||||
|
|
||||||
|
execSync('tsc -p src/compiler --emitDeclarationOnly && tsc -p src/runtime --emitDeclarationOnly');
|
||||||
|
|
||||||
|
// We need to add these types to the index.d.ts here because if we add them before building, the build will fail,
|
||||||
|
// because the TS->JS transformation doesn't know these exports are types and produces code that fails at runtime.
|
||||||
|
// We can't use `export type` syntax either because the TS version we're on doesn't have this feature yet.
|
||||||
|
const path = 'types/runtime/index.d.ts';
|
||||||
|
const content = readFileSync(path, 'utf8');
|
||||||
|
writeFileSync(path, content.replace('SvelteComponentTyped', 'SvelteComponentTyped, ComponentType, ComponentConstructorParams, ComponentProps'));
|
||||||
Loading…
Reference in new issue