Skip to content

Commit

Permalink
[tcgc] unknown format (#286)
Browse files Browse the repository at this point in the history
  • Loading branch information
iscai-msft authored Feb 21, 2024
1 parent 7f98934 commit 8c958fc
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .chronus/changes/unknown_format-2024-1-20-16-12-31.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: fix
packages:
- "@azure-tools/typespec-client-generator-core"
---

don't throw for unknown format
2 changes: 1 addition & 1 deletion packages/typespec-client-generator-core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ function addFormatInfo(
propertyType.kind = "azureLocation";
break;
default:
throw Error(`Unknown format ${format}`);
break;
}
}
}
Expand Down
16 changes: 16 additions & 0 deletions packages/typespec-client-generator-core/test/types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,22 @@ describe("typespec-client-generator-core: types", () => {
}
});

it("unknown format", async function () {
await runner.compileWithBuiltInService(
`
@usage(Usage.input | Usage.output)
@access(Access.public)
model Test {
@format("unknown")
unknownProp: string;
}
`
);
const models = getAllModelsAssertNoDiagnostics(runner.context);
strictEqual(models[0].kind, "model");
strictEqual(models[0].properties[0].type.kind, "string");
});

it("known values", async function () {
await runner.compileWithBuiltInService(
`
Expand Down

0 comments on commit 8c958fc

Please sign in to comment.