Azure / Azure/typespec-azure

[typespec-ts] `ErrorModel` missing exported/re-exported types

Open
#4,780 0 comments 0 reactions 1 assignee Claimed by @MaryGao View on GitHub
emitter:typescript
Dominant language
TypeScript
Stars
27
Forks
90
Avg merge
1d 22h
Merged PRs (30d)
156

Description

We refered the core error model and we need to re-export or generate them directly in client side to fix missing exporting issue. See [original one](https://github.com/Azure/azure-sdk-for-js/issues/33333).

We have client library A, its model `FooResponse` which references a model in core like `ErrorResponse`, and in core model it references another core model `ErrorModel` which refers `InnerError`.
- FooResponse(client) -> ErrorResponse(core)
- ErrorResponse(core) -> ErrorModel(core)
- ErrorModel(core) -> InnerError(core)

Should we re-export only top-level direct references in client side e.g ErrorResponse or should we calculate the graph to export all underneath models e.g ErrorResponse, ErrorModel and InnerError?

Personally I would prefer to re-export only top-level references in dependencies, coupling with any underneath Nth references or depedencies would require client to know detailed definition due to model nested models and if the depedency has other transitive dependencies that also means we may need to import them directly. I don't think that's a good idea.

But for original issue `ErrorModel` issue is different and I think the root cause for missing types is because these models are defined in [core](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/core/core-client-rest/src/common.ts#L429-L454) but only used in client side. So this is a definition and usage speration issue and I would propose to generate these models in client side directly.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.