diff --git a/.changeset/thin-grapes-dance.md b/.changeset/thin-grapes-dance.md new file mode 100644 index 000000000000..ce071dfdb3e5 --- /dev/null +++ b/.changeset/thin-grapes-dance.md @@ -0,0 +1,5 @@ +--- +'create-svelte': patch +--- + +create-svelte: globals.d.ts TSDoc fixes, add vite/client types to js/tsconfig diff --git a/packages/create-svelte/cli/modifications/add_typescript.js b/packages/create-svelte/cli/modifications/add_typescript.js index 285d78a7429a..326812b2b335 100644 --- a/packages/create-svelte/cli/modifications/add_typescript.js +++ b/packages/create-svelte/cli/modifications/add_typescript.js @@ -17,7 +17,6 @@ export default async function add_typescript(cwd, yes) { update_component(cwd, 'src/routes/index.svelte', [[' + * + * ``` + */ +declare module '*.(gif|jpg|jpeg|png|svg|webp)' { + const value: string; + export = value; +} +//#endregion diff --git a/packages/create-svelte/template/jsconfig.json b/packages/create-svelte/template/jsconfig.json index e5f26af2a360..f33a80550d85 100644 --- a/packages/create-svelte/template/jsconfig.json +++ b/packages/create-svelte/template/jsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "baseUrl": ".", "paths": { "$app/*": [".svelte/dev/runtime/app/*", ".svelte/build/runtime/app/*"], "$lib/*": ["src/lib/*"] diff --git a/packages/create-svelte/template/src/routes/index.svelte b/packages/create-svelte/template/src/routes/index.svelte index a491adb5bc46..f08c6512f71b 100644 --- a/packages/create-svelte/template/src/routes/index.svelte +++ b/packages/create-svelte/template/src/routes/index.svelte @@ -6,6 +6,7 @@

Hello world!

+

Visit svelte.dev to learn how to build Svelte apps.

diff --git a/packages/create-svelte/ts-template/src/globals.d.ts b/packages/create-svelte/ts-template/src/globals.d.ts deleted file mode 100644 index ef3b4bfef94a..000000000000 --- a/packages/create-svelte/ts-template/src/globals.d.ts +++ /dev/null @@ -1,54 +0,0 @@ -/// - -//#region Ensure Svelte file endings have a type for TypeScript -/** - * These declarations tell TypeScript that we allow import of Svelte files in TS files, e.g. - * ``` - import Component from './Component.svelte'; - ``` - */ -declare module '*.svelte' { - export { SvelteComponent as default } from 'svelte'; -} -//#endregion - -//#region Ensure image file endings have a type for TypeScript -/** - * These declarations tell TypeScript that we allow import of images, e.g. - * ``` - - - ``` - */ -declare module '*.gif' { - const value: string; - export = value; -} - -declare module '*.jpg' { - const value: string; - export = value; -} - -declare module '*.jpeg' { - const value: string; - export = value; -} - -declare module '*.png' { - const value: string; - export = value; -} - -declare module '*.svg' { - const value: string; - export = value; -} - -declare module '*.webp' { - const value: string; - export = value; -} -//#endregion diff --git a/packages/create-svelte/ts-template/tsconfig.json b/packages/create-svelte/ts-template/tsconfig.json index 9de39abd0475..23c0bfa81779 100644 --- a/packages/create-svelte/ts-template/tsconfig.json +++ b/packages/create-svelte/ts-template/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "moduleResolution": "node", - "target": "es2017", + "target": "es2018", /** svelte-preprocess cannot figure out whether you have a value or a type, so tell TypeScript to enforce using \`import type\` instead of \`import\` for Types. @@ -18,6 +18,7 @@ "forceConsistentCasingInFileNames": true, "baseUrl": ".", "allowJs": true, + "checkJs": true, "paths": { "$app/*": [".svelte/dev/runtime/app/*", ".svelte/build/runtime/app/*"], "$components/*": ["src/components/*"]