Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript added when not requested #8189

Closed
johndeighan opened this issue Dec 16, 2022 · 5 comments · Fixed by #8484
Closed

TypeScript added when not requested #8189

johndeighan opened this issue Dec 16, 2022 · 5 comments · Fixed by #8484

Comments

@johndeighan
Copy link

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

@johndeighan
Copy link
Author

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.

@johndeighan
Copy link
Author

If TypeScript is included when the library is originally set up, then npm run build runs without error.

@dummdidumm
Copy link
Member

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.

@KAVA-Leigh
Copy link

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.

@idleman

This comment was marked as off-topic.

dummdidumm added a commit that referenced this issue Jan 12, 2023
Rich-Harris added a commit that referenced this issue Jan 13, 2023
* docs: explain why typescript is added either way

for a library project
closes #8189

* add jsconfig for lib, closes #7475

* Update documentation/docs/30-advanced/70-packaging.md

* replace icon with warning sign

* changeset

* unicode warning symbol looks strangely shit - use a yellow triangle instead

* the bold does nothing

Co-authored-by: Rich Harris <richard.a.harris@gmail.com>
Co-authored-by: Rich Harris <hello@rich-harris.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants
@idleman @johndeighan @dummdidumm @KAVA-Leigh and others