Skip to content

Commit 8776d18

Browse files
authored
feat: add jsconfig.json to the 'no type checking' template (#290)
* add jsconfig to no typechecking template * changeset * simplify
1 parent 5941575 commit 8776d18

File tree

3 files changed

+25
-8
lines changed

3 files changed

+25
-8
lines changed

.changeset/sharp-rocks-scream.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'sv': minor
3+
---
4+
5+
feat: add `jsconfig.json` to the 'no type checking' template

packages/create/index.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ import path from 'node:path';
33
import { mkdirp, copy, dist } from './utils.ts';
44

55
export type TemplateType = (typeof templateTypes)[number];
6-
export type LanguageType = 'typescript' | 'checkjs' | 'none';
6+
export type LanguageType = (typeof languageTypes)[number];
77

88
const templateTypes = ['minimal', 'demo', 'library'] as const;
9+
const languageTypes = ['typescript', 'checkjs', 'none'] as const;
910

1011
export type Options = {
1112
name: string;
@@ -18,7 +19,7 @@ export type File = {
1819
contents: string;
1920
};
2021

21-
export type Condition = Exclude<TemplateType | LanguageType, 'none'>;
22+
export type Condition = TemplateType | LanguageType;
2223

2324
export type Common = {
2425
files: Array<{
@@ -42,7 +43,7 @@ export const templates: TemplateMetadata[] = templateTypes.map((dir) => {
4243
const { title, description } = JSON.parse(fs.readFileSync(meta_file, 'utf8'));
4344

4445
return {
45-
name: dir as TemplateType,
46+
name: dir,
4647
title,
4748
description
4849
};
@@ -95,13 +96,13 @@ function write_common_files(cwd: string, options: Options, name: string) {
9596
}
9697

9798
function matches_condition(condition: Condition, options: Options) {
98-
if (condition === 'demo' || condition === 'minimal' || condition === 'library') {
99+
if (templateTypes.includes(condition as TemplateType)) {
99100
return options.template === condition;
100101
}
101-
if (condition === 'typescript' || condition === 'checkjs') {
102+
if (languageTypes.includes(condition as LanguageType)) {
102103
return options.types === condition;
103104
}
104-
return !!options[condition];
105+
return Boolean(options[condition as never]);
105106
}
106107

107108
function merge(target: any, source: any) {
@@ -144,8 +145,6 @@ function sort_keys(obj: Record<string, any>) {
144145
/**
145146
* Sort files so that those which apply more generically come first so they
146147
* can be overwritten by files for more precise cases later.
147-
*
148-
* @param {import('./types/internal.js').Common['files']} files
149148
*/
150149
function sort_files(files: Common['files']) {
151150
return files.sort((f1, f2) => {
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"extends": "./.svelte-kit/tsconfig.json",
3+
"compilerOptions": {
4+
"allowJs": true,
5+
"checkJs": false,
6+
"moduleResolution": "bundler"
7+
}
8+
// Path aliases are handled by https://svelte.dev/docs/kit/configuration#alias
9+
// except $lib which is handled by https://svelte.dev/docs/kit/configuration#files
10+
//
11+
// If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes
12+
// from the referenced tsconfig.json - TypeScript does not merge them in
13+
}

0 commit comments

Comments
 (0)