-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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] fix: deno: type exports for isolatedModules
#19484
[typescript] fix: deno: type exports for isolatedModules
#19484
Conversation
@@ -16,7 +16,7 @@ export { Middleware } from './middleware{{importFileExtension}}'; | |||
export{{#platforms}}{{#deno}} type{{/deno}}{{/platforms}} { PromiseMiddleware as Middleware } from './middleware{{importFileExtension}}'; | |||
{{/useRxJS}} | |||
{{#useObjectParameters}} | |||
export { {{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}{{classname}}{{operationIdCamelCase}}Request, {{/operation}}Object{{classname}} as {{classname}}{{^-last}}, {{/-last}} {{/operations}}{{/apis}}{{/apiInfo}}} from './types/ObjectParamAPI{{importFileExtension}}'; | |||
export { {{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}{{#platforms}}{{#deno}}type {{/deno}}{{/platforms}}{{classname}}{{operationIdCamelCase}}Request, {{/operation}}Object{{classname}} as {{classname}}{{^-last}}, {{/-last}} {{/operations}}{{/apis}}{{/apiInfo}}} from './types/ObjectParamAPI{{importFileExtension}}'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the meaningful change of this PR.
It makes sure that any re-exported request object is exported with the type
keyword, e.g.
export { AuthApiXRequest, ObjectAuthApi as AuthApi } from './types/ObjectParamAPI.ts';
becomes
export { type AuthApiXRequest, ObjectAuthApi as AuthApi } from './types/ObjectParamAPI.ts';
e.g. meaning
export {
- AuthApiXRequest,
+ type AuthApiXRequest,
ObjectAuthApi as AuthApi
} from './types/ObjectParamAPI.ts';
An alternative, possibly more readable implementation would be to split the type exports from the classes, e.g.:
export { ObjectAuthApi as AuthApi, ObjectBlaApi as BlaApi } from './types/ObjectParamAPI.ts';
export type { AuthApiXRequest, BlaApiXRequest } from './types/ObjectParamAPI.ts';
export { RequiredError } from "./apis/baseapi.ts"; | ||
|
||
export type { PromiseMiddleware as Middleware } from './middleware.ts'; | ||
export { type PetApiAddPetRequest, type PetApiDeletePetRequest, type PetApiFindPetsByStatusRequest, type PetApiFindPetsByTagsRequest, type PetApiGetPetByIdRequest, type PetApiUpdatePetRequest, type PetApiUpdatePetWithFormRequest, type PetApiUploadFileRequest, ObjectPetApi as PetApi, type StoreApiDeleteOrderRequest, type StoreApiGetInventoryRequest, type StoreApiGetOrderByIdRequest, type StoreApiPlaceOrderRequest, ObjectStoreApi as StoreApi, type UserApiCreateUserRequest, type UserApiCreateUsersWithArrayInputRequest, type UserApiCreateUsersWithListInputRequest, type UserApiDeleteUserRequest, type UserApiGetUserByNameRequest, type UserApiLoginUserRequest, type UserApiLogoutUserRequest, type UserApiUpdateUserRequest, ObjectUserApi as UserApi } from './types/ObjectParamAPI.ts'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the meaningful change in the generated fixture. Please let me know if you prefer to introduce some newlines between the different imports/exports, which would make this a lot more readable, but also would increase the diff of this PR, because it would affect other samples as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for your contribution!
When generating code with
typescript
that contains request objects for thedeno
platform the following type error is produced in the generated code:Deno has
isolatedModules
enabled by default and it can not be disabled (see denoland/deno#12599 (comment)).Thus imports that are reexported need to have the
type
keyword.A similar change has been made in #826.
PR checklist
master
(upcoming 7.6.0 minor release - breaking changes with fallbacks),8.0.x
(breaking changes without fallbacks)