-
Notifications
You must be signed in to change notification settings - Fork 11
Description
An error is produced when building expect-type
with tsgo
or when building a project that depends on expect-type
with tsgo
.
To reproduce
- Clone the
expect-type
repo. - Run these commands (see Announcing TypeScript Native Previews):
npm install -D @typescript/native-preview
npx tsgo --project tsconfig.lib.json
Output
src/index.ts:68:3 - error TS2300: Duplicate identifier 'toExtend'.
68 toExtend<Expected extends Extends<Actual, Expected> extends true ? unknown : MismatchInfo<Actual, Expected>>(
~~~~~~~~
src/index.ts:154:3 - error TS2300: Duplicate identifier 'toExtend'.
154 toExtend: <Expected extends Extends<Actual, Expected> extends true ? unknown : MismatchInfo<Actual, Expected>>(
~~~~~~~~
Found 2 errors in the same file, starting at: src/index.ts:68
The same error is produced when building a project that depends on expect-type
with tsgo
.
Versions used
- Node: v22.12.0
- npm: v10.9.0
- @typescript/native-preview: 7.0.0-dev.20250525.1
Discussion
There are indeed two declarations of toExtend
in the PositiveExpectTypeOf
interface:
Line 68 in 8ad226f
toExtend<Expected extends Extends<Actual, Expected> extends true ? unknown : MismatchInfo<Actual, Expected>>( Line 154 in 8ad226f
toExtend: <Expected extends Extends<Actual, Expected> extends true ? unknown : MismatchInfo<Actual, Expected>>(
Commenting out either of the toExtend
declarations allows the tsgo
build to work.
The two declarations are almost identical. The only difference is that one uses method shorthand syntax and the other does not. They were both added in the same commit: 8ad226f.
The TypeScript team have deliberately made tsgo
more strict than TypeScript 5.x when it comes to detecting duplicate declarations which may explain the difference.
microsoft/typescript-go#693
I understand that expect-type
doesn't support tsgo
yet. Just wanted to give a heads up!