Skip to content

Commit ff7132a

Browse files
authored
Handle unkown type as any type in m4 (#1412)
1 parent db95d41 commit ff7132a

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

packages/typespec-powershell/src/utils/modelUtils.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ import {
4949
import { SdkContext, isReadOnly } from "@azure-tools/typespec-client-generator-core";
5050

5151
import { reportDiagnostic } from "../lib.js";
52-
import { SealedChoiceSchema, ChoiceSchema, ChoiceValue, SchemaType, ArraySchema, Schema, DictionarySchema, ObjectSchema, Discriminator as M4Discriminator, Property, StringSchema, NumberSchema, ConstantSchema, ConstantValue } from "@autorest/codemodel";
52+
import { AnySchema, SealedChoiceSchema, ChoiceSchema, ChoiceValue, SchemaType, ArraySchema, Schema, DictionarySchema, ObjectSchema, Discriminator as M4Discriminator, Property, StringSchema, NumberSchema, ConstantSchema, ConstantValue } from "@autorest/codemodel";
5353
import {
5454
getHeaderFieldName,
5555
getPathParamName,
@@ -290,11 +290,9 @@ export function getSchemaForType(
290290
return getSchemaForEnumMember(program, type);
291291
}
292292
if (isUnknownType(type)) {
293-
const returnType: any = { type: "unknown" };
294-
if (usage && usage.includes(SchemaContext.Output)) {
295-
returnType.outputTypeName = "any";
296-
returnType.typeName = "unknown";
297-
}
293+
// Unknown type, return any schema
294+
const returnType = new AnySchema("any");
295+
schemaCache.set(type, returnType);
298296
return returnType;
299297
}
300298
if (isNeverType(type)) {

0 commit comments

Comments
 (0)