Skip to content

fix: migrate to TypeScript 6 — nodenext resolution + subpath imports#1147

Merged
Belphemur merged 2 commits intodependabot/npm_and_yarn/typescript-6.0.2from
copilot/sub-pr-1146
Apr 4, 2026
Merged

fix: migrate to TypeScript 6 — nodenext resolution + subpath imports#1147
Belphemur merged 2 commits intodependabot/npm_and_yarn/typescript-6.0.2from
copilot/sub-pr-1146

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 4, 2026

TypeScript 6 deprecates moduleResolution: "node" (errors on build) and requires an explicit rootDir. This PR fixes all TS6 breaking changes and adopts modern Node.js subpath imports (#/).

tsconfig.json

  • module + moduleResolution: "commonjs" / "node""nodenext" — correct semantic choice for a Node.js library; keeps CJS output (no "type": "module")
  • Added rootDir: "src" (now required by TS6)
  • lib: simplified to ["es2020", "dom"]; added explicit types: ["node"]
  • Removed unused experimentalDecorators / emitDecoratorMetadata

Explicit .js extensions on all imports

nodenext resolution requires explicit extensions on relative imports (mirrors what Node.js needs at runtime). Updated all src/ and test/ files. jest.config.js gains a moduleNameMapper to strip .js so ts-jest resolves .ts source files:

moduleNameMapper: {
  '^(\\.{1,2}/.*)\\.js$': '$1',
  '^#/(.*)\\.js$': '<rootDir>/src/$1',
}

#/ subpath imports in src/

All intra-package imports now use Node.js subpath imports instead of relative paths:

// before
import { DataError } from '../../lib/Errors.js'

// after
import { DataError } from '#/lib/Errors.js'

package.json imports field wires the resolution:

"imports": {
  "#/*": {
    "types": "./src/*",
    "default": "./dist/*"
  }
}
  • types condition → src/ (TypeScript resolves .js.ts during compilation)
  • default condition → dist/ (Node.js runtime on published package)

Copilot AI changed the title [WIP] Build(deps-dev): bump typescript from 5.9.3 to 6.0.2 fix: migrate to TypeScript 6 — nodenext resolution + subpath imports Apr 4, 2026
Copilot AI requested a review from Belphemur April 4, 2026 02:27
@Belphemur Belphemur marked this pull request as ready for review April 4, 2026 02:34
Copilot AI review requested due to automatic review settings April 4, 2026 02:34
@Belphemur Belphemur merged commit 504f551 into dependabot/npm_and_yarn/typescript-6.0.2 Apr 4, 2026
3 checks passed
@Belphemur Belphemur deleted the copilot/sub-pr-1146 branch April 4, 2026 02:34
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Migrates the project to TypeScript 6 by switching to nodenext module/moduleResolution, adding rootDir, and updating code/tests to use explicit .js extensions and internal #/ subpath imports.

Changes:

  • Update tsconfig.json for TS6 (module/moduleResolution: nodenext, add rootDir, simplify lib, set types: ["node"]).
  • Convert internal source imports to #/.../*.js and update tests to import ../src/.../*.js.
  • Add package.json#imports and jest.config.js#moduleNameMapper to support #/ and .js-suffixed specifiers in TS/Jest.

Reviewed changes

Copilot reviewed 25 out of 27 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tsconfig.json Switch compiler to nodenext, set rootDir, adjust libs/types for TS6.
package.json Add imports map for #/ self-references.
jest.config.js Add moduleNameMapper to resolve .js-suffixed specifiers + #/ to src/ in tests.
src/JsonDB.ts Replace relative imports with #/ imports and add .js extensions; update re-exports accordingly.
src/lib/JsonDBConfig.ts Update adapter/lib imports to #/.../*.js.
src/lib/DBParentData.ts Update imports to #/.../*.js.
src/lib/ArrayInfo.ts Update imports to #/.../*.js.
src/lock/ReadWriteLock.ts Update imports to #/.../*.js.
src/lock/Lock.ts Update imports to #/.../*.js.
src/lock/Error.ts Update imports to #/.../*.js.
src/adapter/data/JsonAdapter.ts Update imports to #/.../*.js.
src/adapter/data/Serializers.ts Update imports to #/.../*.js.
src/adapter/file/FileAdapter.ts Update imports to #/.../*.js.
src/adapter/file/CipheredFileAdapter.ts Update imports to #/.../*.js.
test/01-utils.test.ts Add .js extensions to project-local imports.
test/02-jsondb.test.ts Add .js extensions to project-local imports.
test/03-existing-db.test.ts Add .js extensions to project-local imports.
test/04-array-utils.test.ts Add .js extensions to project-local imports.
test/06-concurrency.test.ts Add .js extensions to project-local imports.
test/07-cyphered.test.ts Add .js extensions to project-local imports.
test/JsonDB.test.ts Add .js extensions to project-local imports.
test/DBParentData.test.ts Update mock/import paths to match new resolution approach.
test/ArrayInfo.test.ts Add .js extensions to project-local imports.
test/adapter/Serializers.test.ts Add .js extensions to project-local imports.
test/adapter/adapters.test.ts Add .js extensions to project-local imports (and one local require).
test/lock/locks.test.ts Add .js extensions to project-local imports.
test/lock/performance.test.ts Add .js extensions to project-local imports.

Comment thread package.json
"types": "dist/JsonDB.d.ts",
"imports": {
"#/*": {
"types": "./src/*",
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

package.json sets imports["#/*"].types to ./src/*, but src/ is not included in the published files list (only dist/, README, LICENSE, CHANGELOG). That will break TypeScript resolution of the package’s internal #/... specifiers for consumers because the .d.ts files in dist/ will reference #/... and TS will follow the types condition to a path that isn’t shipped. Fix by either publishing src/ (add it to files) or by pointing the types condition at ./dist/* and using a separate dev-only mapping (e.g. tsconfig.paths) for building from src/.

Suggested change
"types": "./src/*",
"types": "./dist/*",

Copilot uses AI. Check for mistakes.
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

Successfully merging this pull request may close these issues.

3 participants