kit
kit copied to clipboard
TypeScript added when not requested
Describe the bug
When I create a new SvelteKit Library project using npm create svelte@latest <name>
, I specifically request to have no TypeScript, but the package.json file has typescript and tslib as dev dependencies. Very annoying to have to remove them.
Reproduction
create a new SvelteKit library project, requesting no typescript.
Logs
$ npm create svelte@latest temp
create-svelte version 2.0.1
Welcome to SvelteKit!
√ Which Svelte app template? » Library skeleton project
√ Add type checking with TypeScript? » No
√ Add ESLint for code linting? ... No / Yes
√ Add Prettier for code formatting? ... No / Yes
√ Add Playwright for browser testing? ... No / Yes
√ Add Vitest for unit testing? ... No / Yes
Your project is ready!
Install community-maintained integrations:
https://github.com/svelte-add/svelte-adders
Next steps:
1: cd temp
2: npm install (or pnpm install, etc)
3: git init && git add -A && git commit -m "Initial commit" (optional)
4: npm run dev -- --open
To close the dev server, hit Ctrl-C
Stuck? Visit us at https://svelte.dev/chat
System Info
System:
OS: Windows 10 10.0.22621
CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
Memory: 8.60 GB / 15.77 GB
Binaries:
Node: 18.3.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
npm: 9.2.0 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: Spartan (44.22621.963.0), Chromium (108.0.1462.46)
Internet Explorer: 11.0.22621.1
Severity
annoyance
Additional Information
No response
When I attempt to package my library, I get the error message: Failed to locate tsconfig or jsconfig.
At first, I thought that the problem was that I had removed typescript and tslib via npm uninstall typescript tslib
. But when I rebuilt the entire project (it's quite small) by not asking for TypeScript, but then not uninstalling typescript and tslib, I encountered the very same error message when trying to package it via npm run build
. I'm going to try including TypeScript from the start, even though I don't want it as part of my project.
If TypeScript is included when the library is originally set up, then npm run build
runs without error.
This happens because you chose Library skeleton project
, which is the template for creating Svelte packages, for which it's best for the greater good of the community to also provide type definitions, which is why TypeScript etc is added in this case either way. Chosing no typescript
contradicts this though, and leads to this inconsistent outcome. I'm not sure what the best solution is in this case - either omitting the "no typescript" option in this case or adjust the package.json and package config settings.
Omitting the option or simply adding a comment for Skeleton selection, stating that TS will be automatically added sounds ok in my mind.
As long as the user is aware of why they are getting TS, it's just fine.
It would be a terrible thing to add TypeScript by default in just a skeleton if the user do not explicit asks for it. Terrible.
TypeScript adds complexity and has a lot of cons and one of those cons are code complexity. A lot of it. You may have forgotten the basic things, but as most typed programming languages, types are not free. The code get more complicated and the developer must know more stuff. The Development time increases with TS as well (Google typed vs not typed programming language and compare it to development speed, but this discussion is at least 40 years old). You may love it, and want everyone to use your new lover (TypeScript), but it will increase the complexity and make sveltekit harder to use.
Of course, I don´t think you want it and I am sure you don´t think TypeScript makes it harder, but it 100% does. TypeScript is the new C#/Java. In 5 years will everyone says it is too bloated anyway. It has all the signs for it already were it is heading.