Skip to content

Library project tsconfig errors - module value, overwrite input file #11023

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

Closed
hyunbinseo opened this issue Nov 13, 2023 · 2 comments · Fixed by #11029
Closed

Library project tsconfig errors - module value, overwrite input file #11023

hyunbinseo opened this issue Nov 13, 2023 · 2 comments · Fixed by #11029

Comments

@hyunbinseo
Copy link
Contributor

hyunbinseo commented Nov 13, 2023

Describe the bug

Out-of-the box, two errors occur in the tsconfig.json file.

Cannot write file '/src/lib/index.js' because it would overwrite input file. // ts

  1. Provided index.ts instead of index.js if TypeScript is selected.
  2. Related: Svelte kit demo project tsconfig errors #9552

Option 'module' must be set to 'NodeNext' when option 'moduleResolution' is set to 'NodeNext'. // ts

  1. The documentation does mention setting "moduleResolution": "NodeNext" in the caveats section.

Reproduction

pnpm create svelte@latest
create-svelte version 5.1.1

┌  Welcome to SvelteKit!
│
◇  Where should we create your project?
│  [email protected]
│
◇  Which Svelte app template?
│  Library project
│
◇  Add type checking with TypeScript?
│  Yes, using TypeScript syntax
│
◇  Select additional options (use arrow keys/space bar)
│  none
│
└  Your project is ready!
  • Open the workspace in VS Code.
pnpm i
pnpm check
  • Reload VS Code Window
  • Open src/lib/index.js
  • Open tsconfig.json -- 1st error message is shown
  • Rename to src/lib/index.ts
  • Open tsconfig.json -- 2nd error message is shown

Logs

No response

System Info

System:
  OS: macOS 14.0
  CPU: (10) arm64 Apple M1 Pro
  Memory: 60.42 MB / 16.00 GB
  Shell: 5.9 - /bin/zsh
Binaries:
  Node: 20.8.1 - ~/Library/pnpm/node
  npm: 10.1.0 - ~/Library/pnpm/npm
  pnpm: 8.10.2 - ~/Library/pnpm/pnpm
Browsers:
  Chrome: 119.0.6045.123
  Edge: 119.0.2151.58
  Safari: 17.0
npmPackages:
  @sveltejs/adapter-auto: ^2.0.0 => 2.1.1 
  @sveltejs/kit: ^1.20.4 => 1.27.5 
  @sveltejs/package: ^2.0.0 => 2.2.2 
  svelte: ^4.0.5 => 4.2.3 
  vite: ^4.4.2 => 4.5.0

Severity

annoyance

Additional Information

No response

@eltigerchino
Copy link
Member

eltigerchino commented Nov 13, 2023

I can't reproduce this issue given the reproduction steps. Can you re-confirm the issue?

@hyunbinseo
Copy link
Contributor Author

I've updated the reproduction steps.

dummdidumm added a commit that referenced this issue Nov 14, 2023
…properties (#11029)

fixes #11023
fixes #9552

This PR fixes the errors found in tsconfig.json when scaffolding a typescript library project then running pnpm check.

> Cannot write file '/src/lib/index.js' because it would overwrite input file.

This one is fixed by providing a index.ts file instead of .js in the example lib folder and adding noEmit to tsconfig

> Option 'module' must be set to 'NodeNext' when option 'moduleResolution' is set to 'NodeNext'.

This one is fixed by adding the module: NodeNext to the library project tsconfig.json and jsconfig.json files

Also added moduleResolution: bundler to the app tsconfigs which is the recommended setting in TS 5.0+

---------

Co-authored-by: Simon H <[email protected]>
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.

2 participants