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

[EFv2] cleanup error and warnings #6704

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

joheredi
Copy link
Member

Addressing #6575 making sure there are no unnecessary throws and clean up the diagnostics in Typekit, Efv2 and http-client-js

Copy link
Contributor

github-actions bot commented Mar 26, 2025

All changed packages have been documented.

  • @typespec/compiler
  • @typespec/emitter-framework
  • @typespec/http-client-js
  • @typespec/http-client
  • @typespec/http
Show changes

@typespec/compiler - internal ✏️

Cleanup errors and diagnostics in Typekit, efv2 and http-client-js

@typespec/emitter-framework - internal ✏️

Cleanup errors and diagnostics in Typekit, efv2 and http-client-js

@typespec/http-client-js - internal ✏️

Cleanup errors and diagnostics in Typekit, efv2 and http-client-js

@typespec/http-client - internal ✏️

Cleanup errors and diagnostics in Typekit, efv2 and http-client-js

@typespec/http - internal ✏️

Cleanup errors and diagnostics in Typekit, efv2 and http-client-js

@azure-sdk
Copy link
Collaborator

azure-sdk commented Mar 26, 2025

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

@joheredi joheredi force-pushed the internal/js-cleanup-errors branch from 18072df to 519256f Compare March 27, 2025 17:20
@joheredi joheredi force-pushed the internal/js-cleanup-errors branch from 519256f to e8d97f6 Compare March 27, 2025 23:26
@joheredi joheredi force-pushed the internal/js-cleanup-errors branch from e8d97f6 to e406e41 Compare March 28, 2025 21:46
@joheredi joheredi enabled auto-merge March 28, 2025 21:46
@joheredi joheredi force-pushed the internal/js-cleanup-errors branch from e406e41 to 97e8497 Compare April 2, 2025 19:45
@@ -43,7 +44,12 @@ defineKit<TypekitExtension>({
},
getElementType(type) {
if (!this.record.is(type)) {
throw new Error("Type is not a record.");
reportTypekitDiagnostic(this.program, {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reporting diagnostic from a getter is a bad pattern, it carries the error to the user potentially multiple times without expoissting that to the library author.

Any getter that report diagnmostic should return the error tuple

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in general the same applies to probably all typekits

Copy link
Member

@timotheeguerin timotheeguerin Apr 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think it might make more sense to also throw if invalid inputs are used, this means that the library author made an error calling this intead of pushing that onto the user

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.

5 participants