Skip to content

Commit

Permalink
Do not crash if hitting a unsupported intrinsic type (#3077)
Browse files Browse the repository at this point in the history
fix #3073

This still doesn't provide an optimal experience as the error shows up
on the void type instead of where it is referenced but solving that is
that long standing issue about tracing back where an error should be
  • Loading branch information
timotheeguerin committed Mar 28, 2024
1 parent 85fa7ae commit 6d54aeb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking
changeKind: fix
packages:
- "@typespec/openapi3"
---

Do not crash if using an unsupported intrinsic type
7 changes: 6 additions & 1 deletion packages/openapi3/src/schema-emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,12 @@ export class OpenAPI3SchemaEmitter extends TypeEmitter<
return { nullable: true };
}

throw new Error("Unknown intrinsic type " + name);
reportDiagnostic(this.emitter.getProgram(), {
code: "invalid-schema",
format: { type: name },
target: intrinsic,
});
return {};
}

programContext(program: Program): Context {
Expand Down

0 comments on commit 6d54aeb

Please sign in to comment.