Skip to content

[Bug]: TypeScript errors TS2416 and TS2694 in @rspack/core #8277

@andersk

Description

@andersk

System Info

  System:
    OS: Linux 6.11 NixOS 24.11 (Vicuna) 24.11 (Vicuna)
    CPU: (12) x64 Intel(R) Core(TM) i7-10710U CPU @ 1.10GHz
    Memory: 6.97 GB / 15.26 GB
    Container: Yes
    Shell: 5.2.32 - /run/current-system/sw/bin/bash
  Binaries:
    Node: 20.17.0 - ~/.nix-profile/bin/node
    npm: 10.8.2 - ~/.nix-profile/bin/npm
    pnpm: 9.12.0 - ~/.nix-profile/bin/pnpm
    bun: 1.1.31 - ~/.nix-profile/bin/bun
  Browsers:
    Chromium: 130.0.6723.58
  npmPackages:
    @rspack/core: ^1.0.14 => 1.0.14 

Details

I get many TypeScript errors just from doing import "@rspack/core" in a TypeScript file.

node_modules/@rspack/core/dist/Compilation.d.ts:399:5 - error TS2416: Property 'entries' in type 'Entries' is not assignable to the same property in base type 'Map<string, JsEntryData>'.
node_modules/@rspack/core/dist/Compilation.d.ts:400:5 - error TS2416: Property 'values' in type 'Entries' is not assignable to the same property in base type 'Map<string, JsEntryData>'.
node_modules/@rspack/core/dist/Compilation.d.ts:401:5 - error TS2416: Property '[Symbol.iterator]' in type 'Entries' is not assignable to the same property in base type 'Map<string, JsEntryData>'.
node_modules/@rspack/core/dist/Compilation.d.ts:407:5 - error TS2416: Property 'keys' in type 'Entries' is not assignable to the same property in base type 'Map<string, JsEntryData>'.
node_modules/@rspack/core/dist/config/zod.d.ts:2751:48 - error TS2694: Namespace 'z' has no exported member 'objectUtil'.

(The first four are new with TypeScript 5.6, the last is not.)

Reproduce link

No response

Reproduce Steps

From an empty directory:

$ npm i @rspack/core @types/graceful-fs @types/node tapable typescript webpack webpack-dev-server
$ echo 'import "@rspack/core"' > test.ts
$ npx tsc --strict --moduleResolution node --esModuleInterop --target ESNext test.ts
node_modules/@rspack/core/dist/Compilation.d.ts:399:5 - error TS2416: Property 'entries' in type 'Entries' is not assignable to the same property in base type 'Map<string, JsEntryData>'.
  Type '() => MapIterator<[string, import("/tmp/r/node_modules/@rspack/binding/binding").JsEntryData]>' is not assignable to type '() => MapIterator<[string, import("/tmp/r/node_modules/@rspack/binding/binding").JsEntryData]>'. Two different types with this name exist, but they are unrelated.
    Type 'MapIterator<[string, JsEntryData]>' is missing the following properties from type 'MapIterator<[string, JsEntryData]>': map, filter, take, drop, and 9 more.

399     entries(): MapIterator<[string, binding.JsEntryData]>;
        ~~~~~~~

node_modules/@rspack/core/dist/Compilation.d.ts:400:5 - error TS2416: Property 'values' in type 'Entries' is not assignable to the same property in base type 'Map<string, JsEntryData>'.
  Type '() => MapIterator<import("/tmp/r/node_modules/@rspack/binding/binding").JsEntryData>' is not assignable to type '() => MapIterator<import("/tmp/r/node_modules/@rspack/binding/binding").JsEntryData>'. Two different types with this name exist, but they are unrelated.
    Type 'MapIterator<JsEntryData>' is missing the following properties from type 'MapIterator<JsEntryData>': map, filter, take, drop, and 9 more.

400     values(): MapIterator<binding.JsEntryData>;
        ~~~~~~

node_modules/@rspack/core/dist/Compilation.d.ts:401:5 - error TS2416: Property '[Symbol.iterator]' in type 'Entries' is not assignable to the same property in base type 'Map<string, JsEntryData>'.
  Type '() => MapIterator<[string, import("/tmp/r/node_modules/@rspack/binding/binding").JsEntryData]>' is not assignable to type '() => MapIterator<[string, import("/tmp/r/node_modules/@rspack/binding/binding").JsEntryData]>'. Two different types with this name exist, but they are unrelated.
    Type 'MapIterator<[string, JsEntryData]>' is missing the following properties from type 'MapIterator<[string, JsEntryData]>': map, filter, take, drop, and 9 more.

401     [Symbol.iterator](): MapIterator<[string, binding.JsEntryData]>;
        ~~~~~~~~~~~~~~~~~

node_modules/@rspack/core/dist/Compilation.d.ts:407:5 - error TS2416: Property 'keys' in type 'Entries' is not assignable to the same property in base type 'Map<string, JsEntryData>'.
  Type '() => MapIterator<string>' is not assignable to type '() => MapIterator<string>'. Two different types with this name exist, but they are unrelated.
    Type 'MapIterator<string>' is missing the following properties from type 'MapIterator<string>': map, filter, take, drop, and 9 more.

407     keys(): MapIterator<string>;
        ~~~~

node_modules/@rspack/core/dist/config/zod.d.ts:2751:48 - error TS2694: Namespace 'z' has no exported member 'objectUtil'.

2751             asset: z.ZodOptional<z.ZodObject<z.objectUtil.extendShape<{
                                                    ~~~~~~~~~~


Found 5 errors in 2 files.

Errors  Files
     4  node_modules/@rspack/core/dist/Compilation.d.ts:399
     1  node_modules/@rspack/core/dist/config/zod.d.ts:2751

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions