diff --git a/.chronus/changes/export_more_api-2024-3-23-17-29-45.md b/.chronus/changes/export_more_api-2024-3-23-17-29-45.md new file mode 100644 index 0000000000..28c1178915 --- /dev/null +++ b/.chronus/changes/export_more_api-2024-3-23-17-29-45.md @@ -0,0 +1,7 @@ +--- +changeKind: feature +packages: + - "@azure-tools/typespec-client-generator-core" +--- + +export int and float type judgement function \ No newline at end of file diff --git a/packages/typespec-client-generator-core/src/interfaces.ts b/packages/typespec-client-generator-core/src/interfaces.ts index e3dee7ba15..98f810ebb3 100644 --- a/packages/typespec-client-generator-core/src/interfaces.ts +++ b/packages/typespec-client-generator-core/src/interfaces.ts @@ -185,13 +185,21 @@ export function getKnownScalars(): Record { export function isSdkBuiltInKind(kind: string): kind is SdkBuiltInKinds { return ( kind in SdkBuiltInKindsMiscellaneousEnum || - kind in SdkIntKindsEnum || - kind in SdkFloatKindsEnum || + isSdkIntKind(kind) || + isSdkFloatKind(kind) || kind in SdkGenericBuiltInStringKindsEnum || kind in SdkAzureBuiltInStringKindsEnum ); } +export function isSdkIntKind(kind: string): kind is keyof typeof SdkIntKindsEnum { + return kind in SdkIntKindsEnum; +} + +export function isSdkFloatKind(kind: string): kind is keyof typeof SdkFloatKindsEnum { + return kind in SdkFloatKindsEnum; +} + const SdkDatetimeEncodingsConst = ["rfc3339", "rfc7231", "unixTimestamp"] as const; export function isSdkDatetimeEncodings(encoding: string): encoding is DateTimeKnownEncoding {