diff --git a/.chronus/changes/unknown_format-2024-1-20-16-12-31.md b/.chronus/changes/unknown_format-2024-1-20-16-12-31.md new file mode 100644 index 0000000000..5d405e1421 --- /dev/null +++ b/.chronus/changes/unknown_format-2024-1-20-16-12-31.md @@ -0,0 +1,7 @@ +--- +changeKind: fix +packages: + - "@azure-tools/typespec-client-generator-core" +--- + +don't throw for unknown format \ No newline at end of file diff --git a/packages/typespec-client-generator-core/src/types.ts b/packages/typespec-client-generator-core/src/types.ts index dbd0ab0b26..bec7ee3a06 100644 --- a/packages/typespec-client-generator-core/src/types.ts +++ b/packages/typespec-client-generator-core/src/types.ts @@ -134,7 +134,7 @@ function addFormatInfo( propertyType.kind = "azureLocation"; break; default: - throw Error(`Unknown format ${format}`); + break; } } } diff --git a/packages/typespec-client-generator-core/test/types.test.ts b/packages/typespec-client-generator-core/test/types.test.ts index 79cdd23a46..c4bab9c57f 100644 --- a/packages/typespec-client-generator-core/test/types.test.ts +++ b/packages/typespec-client-generator-core/test/types.test.ts @@ -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( `