From 124cdc22ff7691e68865e4e956acf3a0f29d843e Mon Sep 17 00:00:00 2001 From: Simon Holthausen Date: Wed, 12 Apr 2023 09:22:31 +0200 Subject: [PATCH] remove obsolete workarounds --- generate-type-definitions.js | 23 ----------------------- package.json | 2 +- src/compiler/index.ts | 2 +- src/runtime/index.ts | 2 +- tsconfig.json | 2 +- 5 files changed, 4 insertions(+), 27 deletions(-) delete mode 100644 generate-type-definitions.js diff --git a/generate-type-definitions.js b/generate-type-definitions.js deleted file mode 100644 index 4a36330b13..0000000000 --- a/generate-type-definitions.js +++ /dev/null @@ -1,23 +0,0 @@ -// 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', { stdio: 'inherit' }); -// We need to add these types to the .d.ts files 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. - -function modify(path, modifyFn) { - const content = readFileSync(path, 'utf8'); - writeFileSync(path, modifyFn(content)); -} - -modify( - 'types/runtime/index.d.ts', - content => content.replace('SvelteComponentTyped', 'SvelteComponentTyped, ComponentType, ComponentConstructorOptions, ComponentProps, ComponentEvents') -); -modify( - 'types/compiler/index.d.ts', - content => content + '\nexport { CompileOptions, ModuleFormat, EnableSourcemap, CssHashGetter } from "./interfaces"' -); diff --git a/package.json b/package.json index db976724a3..33d64b4c28 100644 --- a/package.json +++ b/package.json @@ -99,7 +99,7 @@ "dev": "rollup -cw", "posttest": "agadoo internal/index.mjs", "prepublishOnly": "node check_publish_env.js && npm run lint && npm run build && npm test", - "tsd": "node ./generate-type-definitions.js", + "tsd": "tsc -p src/compiler --emitDeclarationOnly && tsc -p src/runtime --emitDeclarationOnly", "lint": "eslint \"{src,test}/**/*.{ts,js}\" --cache" }, "repository": { diff --git a/src/compiler/index.ts b/src/compiler/index.ts index 76eb45d37f..6ab256c59b 100644 --- a/src/compiler/index.ts +++ b/src/compiler/index.ts @@ -2,6 +2,6 @@ export { default as compile } from './compile/index'; export { default as parse } from './parse/index'; export { default as preprocess } from './preprocess/index'; export { walk } from 'estree-walker'; +export type { CompileOptions, ModuleFormat, EnableSourcemap, CssHashGetter } from './interfaces'; export const VERSION = '__VERSION__'; -// additional exports added through generate-type-definitions.js diff --git a/src/runtime/index.ts b/src/runtime/index.ts index 2029f67a04..3bce9163ca 100644 --- a/src/runtime/index.ts +++ b/src/runtime/index.ts @@ -13,5 +13,5 @@ export { createEventDispatcher, SvelteComponentDev as SvelteComponent, SvelteComponentTyped - // additional exports added through generate-type-definitions.js } from 'svelte/internal'; +export type { ComponentType, ComponentConstructorOptions, ComponentProps, ComponentEvents } from 'svelte/internal'; diff --git a/tsconfig.json b/tsconfig.json index f2e055a2a9..39532bfe48 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,7 +6,7 @@ // target node v8+ (https://node.green/) // the only missing feature is Array.prototype.values - "lib": ["es2017"], + "lib": ["es2017", "DOM"], "target": "es2017", "declaration": true,