Skip to content

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

@whoisYeshua

Description

@whoisYeshua

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]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions