Skip to content
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

TypeScript errors TS4023, TS4094 #1182

Closed
bobgubko opened this issue Sep 30, 2023 · 11 comments · Fixed by #1189
Closed

TypeScript errors TS4023, TS4094 #1182

bobgubko opened this issue Sep 30, 2023 · 11 comments · Fixed by #1189
Labels
breaking Backward incompatible changes

Comments

@bobgubko
Copy link

I recently upgraded to the latest epxress-zod-api version from 9.*, adjusted the codebase and at the end got a bunch of TS4023, TS4094 errors. I know I'm not the first one to open this issue and I know that you recommend to disable declarations in tsconfig.json:

If facing Typescript errors TS4023 or TS4094, ensure disabling declaration option in your tsconfig.json.

However in my case declarations cannot be disabled. Is there a way to make it work with declarations enabled or my only option is to stay on 9.* version?

@RobinTail
Copy link
Owner

RobinTail commented Sep 30, 2023

Could you please provide the complete text of the error messages, @bobgubko ?

——
Continuation of the issue #952

@RobinTail
Copy link
Owner

However in my case declarations cannot be disabled. Is there a way to make it work with declarations enabled or my only option is to stay on 9.* version?

No, I can fix it by exposing the types needed for you to keep the declarations, but I need to know which ones are missing.
For that I'd like to ask you to provide the complete error messages so I could help you, @bobgubko

@RobinTail RobinTail added the breaking Backward incompatible changes label Sep 30, 2023
@bobgubko
Copy link
Author

Here are the errors I'm getting:

Errors
error TS4023: Exported variable '[..]' has or is using name 'BasicSecurity' from external module "[...]/node_modules/express-zod-api/dist/index" but cannot be named.
error TS4023: Exported variable '[..]' has or is using name 'BearerSecurity' from external module "[...]/node_modules/express-zod-api/dist/index" but cannot be named.
error TS4023: Exported variable '[..]' has or is using name 'CommonConfig' from external module "[...]/node_modules/express-zod-api/dist/index" but cannot be named.
error TS4023: Exported variable '[..]' has or is using name 'CookieSecurity' from external module "[...]/node_modules/express-zod-api/dist/index" but cannot be named.
error TS4023: Exported variable '[..]' has or is using name 'CustomHeaderSecurity' from external module "[...]/node_modules/express-zod-api/dist/index" but cannot be named.
error TS4023: Exported variable '[..]' has or is using name 'InputSecurity' from external module "[...]/node_modules/express-zod-api/dist/index" but cannot be named.
error TS4023: Exported variable '[..]' has or is using name 'MiddlewareDefinition' from external module "[...]/node_modules/express-zod-api/dist/index" but cannot be named.
error TS4023: Exported variable '[..]' has or is using name 'OAuth2Security' from external module "[...]/node_modules/express-zod-api/dist/index" but cannot be named.
error TS4023: Exported variable '[..]' has or is using name 'OpenIdSecurity' from external module "[...]/node_modules/express-zod-api/dist/index" but cannot be named.
error TS4023: Exported variable '[..]' has or is using name 'ResultHandlerDefinition' from external module "[...]/node_modules/express-zod-api/dist/index" but cannot be named.
error TS4094: Property 'descriptions' of exported class expression may not be private or protected.
error TS4094: Property 'handler' of exported class expression may not be private or protected.
error TS4094: Property 'methods' of exported class expression may not be private or protected.
error TS4094: Property 'middlewares' of exported class expression may not be private or protected.
error TS4094: Property 'mimeTypes' of exported class expression may not be private or protected.
error TS4094: Property 'resultHandler' of exported class expression may not be private or protected.
error TS4094: Property 'schemas' of exported class expression may not be private or protected.
error TS4094: Property 'scopes' of exported class expression may not be private or protected.
error TS4094: Property 'siblingMethods' of exported class expression may not be private or protected.
error TS4094: Property 'statusCodes' of exported class expression may not be private or protected.
error TS4094: Property 'tags' of exported class expression may not be private or protected.

Isn't it easier to simply export all types used in the library so there's no need to worry about those errors?

@RobinTail
Copy link
Owner

Thank you for elaborating, @bobgubko .

Isn't it easier to simply export all types used in the library so there's no need to worry about those errors?

I'm trying to be careful with what I export, because making backwards incompatible changes to the exposed entities is a breaking change requiring next major version according to SemVer.

TS4023

Ok. This is clear how to fix, exactly by exposing those types.

TS4094

This is weird. Need to do a research.

@RobinTail
Copy link
Owner

RobinTail commented Sep 30, 2023

What is your version of Typescript, @bobgubko ?

Question withdrawn.
I think I found a way to fix TS4094.

@RobinTail
Copy link
Owner

RobinTail commented Oct 1, 2023

Dear @bobgubko ,

could you please try version 12.1.0-beta2 and tell me if it fixes the issue?

@bobgubko
Copy link
Author

bobgubko commented Oct 1, 2023

It did fix the issue! 0 errors during build.

@RobinTail
Copy link
Owner

Awesome, thank you for letting me know.
I'm going to release it then, @bobgubko

@alindsay55661
Copy link

I am getting the same error for a different type (Metadata):

error TS4023: Exported variable '[...]' has or is using name Metadata from external module '[...]node_modules/.pnpm/express-zod-api@14.0.0_@types+express@4.17.20_@types+http-errors@2.0.3_@types+node@20.8.7_exp_ul3mzpgqwyhnfja3iatztge55q/node_modules/express-zod-api/dist/index' but cannot be named.

@RobinTail
Copy link
Owner

You should have created an issue for that, @alindsay55661 .
I may have not noticed your comment.

@RobinTail
Copy link
Owner

Fixed in version 14.0.3, @alindsay55661

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Backward incompatible changes
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants