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

Compatibility with "module": "nodenext" in tsconfig.json #59

Open
whoisYeshua opened this issue Sep 14, 2024 · 0 comments
Open

Compatibility with "module": "nodenext" in tsconfig.json #59

whoisYeshua opened this issue Sep 14, 2024 · 0 comments

Comments

@whoisYeshua
Copy link

Hi. I'm using @nanostores/query in a TypeScript project with the "module": "nodenext" in tsconfig.json configuration.

However, I encountered an issue where some imports inside @nanostores/query are not working correctly with "module": "nodenext". Specifically, imports in "type files" (.d.ts) like import('./factory') are missing explicit extensions (.d.ts). This translates into the fact that all types from createFetcherStore become any.

Alternatively, if I switch to "module": "esnext" with "moduleResolution": "bundler", the imports work without needing explicit extensions, but then i lose "nodenext" mode.

Steps to Reproduce

  1. Set up a TypeScript project with the following tsconfig.json:
{
	"compilerOptions": {
		/* Language and Environment */
		"target": "ESNext",

		/* Modules */
		"module": "nodenext",
		"resolveJsonModule": true,

		/* Emit */
		"noEmit": true,

		/* Interop Constraints */
		"isolatedModules": true,
		"allowSyntheticDefaultImports": true,
		"esModuleInterop": false,
		"forceConsistentCasingInFileNames": true,

		/* Type Checking */
		"strict": true,
		"noUnusedLocals": true,
		"noUnusedParameters": true,
		"noFallthroughCasesInSwitch": true,
		"verbatimModuleSyntax": true,

		/* Completeness */
		"skipLibCheck": true
	}
}
  1. Install nanostores & @nanostores/query and try to use it in the project.

  2. Try to create nanoquery store

or check this stackblitz example

Expected Behavior

The imports should work correctly with "module": "nodenext".

Suggested Fix

To ensure compatibility with "module": "nodenext", it would be helpful to add explicit extensions to the imports in @nanostores/query, such as:

import('./factory.d.ts');

Environment

  • TypeScript version: [5.5.2 & 5.6.2]
  • Node.js version: [18.20.3 & 22.7.0]
  • @nanostores/query version: [0.3.4]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant