Skip to content

Commit

Permalink
[tcgc] deprecate .isError on SdkModelType (#503)
Browse files Browse the repository at this point in the history
  • Loading branch information
iscai-msft authored Mar 22, 2024
1 parent 0939bc2 commit 129f8e5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .chronus/changes/remove_error-2024-2-22-15-16-58.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: deprecation
packages:
- "@azure-tools/typespec-client-generator-core"
---

Deprecate `.isError` on an `SdkModelType`. With `SdkPackage`, you should not need to know that a model is used as an error.
3 changes: 3 additions & 0 deletions packages/typespec-client-generator-core/src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,9 @@ export interface SdkModelType extends SdkTypeBase {
properties: SdkModelPropertyType[];
name: string;
isFormDataType: boolean;
/**
* @deprecated This property is deprecated. You should not need to check whether a model is an error model.
*/
isError: boolean;
generatedName: boolean;
description?: string;
Expand Down
3 changes: 3 additions & 0 deletions packages/typespec-client-generator-core/test/types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2719,6 +2719,7 @@ describe("typespec-client-generator-core: types", () => {
const models = getAllModels(runner.context);
strictEqual(models.length, 1);
strictEqual(models[0].kind, "model");
// eslint-disable-next-line deprecation/deprecation
strictEqual(models[0].isError, true);
const rawModel = models[0].__raw;
ok(rawModel);
Expand Down Expand Up @@ -2759,13 +2760,15 @@ describe("typespec-client-generator-core: types", () => {
`);
const models = getAllModels(runner.context);
strictEqual(models.length, 5);
// eslint-disable-next-line deprecation/deprecation
const errorModels = models.filter((x) => x.kind === "model" && x.isError);
deepStrictEqual(errorModels.map((x) => x.name).sort(), [
"ApiError",
"FiveHundredError",
"FourHundredError",
"FourZeroFourError",
]);
// eslint-disable-next-line deprecation/deprecation
const validModel = models.filter((x) => x.kind === "model" && !x.isError);
deepStrictEqual(
validModel.map((x) => x.name),
Expand Down

0 comments on commit 129f8e5

Please sign in to comment.