Skip to content

Fix TypeScript error caused by duplicate Request identifiers #35

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

devoto13
Copy link

@devoto13 devoto13 commented Nov 8, 2022

Only interface declarations can be merged and using type results in the below error.

node_modules/@types/express-serve-static-core/index.d.ts:19:19 - error TS2300: Duplicate identifier 'Request'.

19         interface Request {}
                     ~~~~~~~

  node_modules/express-request-id/types.d.ts:7:8
    7   type Request = {
             ~~~~~~~
    'Request' was also declared here.

node_modules/express-request-id/types.d.ts:7:8 - error TS2300: Duplicate identifier 'Request'.

7   type Request = {
         ~~~~~~~

  node_modules/@types/express-serve-static-core/index.d.ts:19:19
    19         interface Request {}
                         ~~~~~~~
    'Request' was also declared here.

See https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#differences-between-type-aliases-and-interfaces

Only `interface` declarations can be merged and using `type` results in the below error.

```
node_modules/@types/express-serve-static-core/index.d.ts:19:19 - error TS2300: Duplicate identifier 'Request'.

19         interface Request {}
                     ~~~~~~~

  node_modules/express-request-id/types.d.ts:7:8
    7   type Request = {
             ~~~~~~~
    'Request' was also declared here.

node_modules/express-request-id/types.d.ts:7:8 - error TS2300: Duplicate identifier 'Request'.

7   type Request = {
         ~~~~~~~

  node_modules/@types/express-serve-static-core/index.d.ts:19:19
    19         interface Request {}
                         ~~~~~~~
    'Request' was also declared here.
```

See https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#differences-between-type-aliases-and-interfaces
@cpinkerton-kpler
Copy link

Is there a work-around for this issue or is express-request-id currently not compatible with a TypeScript project?

@devoto13
Copy link
Author

devoto13 commented May 5, 2023

You can use old version, 1.x works IIRC.

@pgcalixto
Copy link

I had the same problem, glad to see that a PR is open to fix this.

Hey, @floatdrop, any idea about when this is gonna be merged? :) Thanks!

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.

4 participants