Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/sharp-rocks-scream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'sv': minor
---

feat: add `jsconfig.json` to the 'no type checking' template
15 changes: 7 additions & 8 deletions packages/create/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import path from 'node:path';
import { mkdirp, copy, dist } from './utils.ts';

export type TemplateType = (typeof templateTypes)[number];
export type LanguageType = 'typescript' | 'checkjs' | 'none';
export type LanguageType = (typeof languageTypes)[number];

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

export type Options = {
name: string;
Expand All @@ -18,7 +19,7 @@ export type File = {
contents: string;
};

export type Condition = Exclude<TemplateType | LanguageType, 'none'>;
export type Condition = TemplateType | LanguageType;

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

return {
name: dir as TemplateType,
name: dir,
title,
description
};
Expand Down Expand Up @@ -95,13 +96,13 @@ function write_common_files(cwd: string, options: Options, name: string) {
}

function matches_condition(condition: Condition, options: Options) {
if (condition === 'demo' || condition === 'minimal' || condition === 'library') {
if (templateTypes.includes(condition as TemplateType)) {
return options.template === condition;
}
if (condition === 'typescript' || condition === 'checkjs') {
if (languageTypes.includes(condition as LanguageType)) {
return options.types === condition;
}
return !!options[condition];
return Boolean(options[condition as never]);
}

function merge(target: any, source: any) {
Expand Down Expand Up @@ -144,8 +145,6 @@ function sort_keys(obj: Record<string, any>) {
/**
* Sort files so that those which apply more generically come first so they
* can be overwritten by files for more precise cases later.
*
* @param {import('./types/internal.js').Common['files']} files
*/
function sort_files(files: Common['files']) {
return files.sort((f1, f2) => {
Expand Down
13 changes: 13 additions & 0 deletions packages/create/shared/+none/jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "./.svelte-kit/tsconfig.json",
"compilerOptions": {
"allowJs": true,
"checkJs": false,
"moduleResolution": "bundler"
}
// Path aliases are handled by https://svelte.dev/docs/kit/configuration#alias
// except $lib which is handled by https://svelte.dev/docs/kit/configuration#files
//
// If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes
// from the referenced tsconfig.json - TypeScript does not merge them in
}