Skip to content

Commit

Permalink
[tcgc] export int and float type judgement function (#727)
Browse files Browse the repository at this point in the history
resolve: #724
  • Loading branch information
tadelesh authored Apr 23, 2024
1 parent 2f3d82d commit baf791e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .chronus/changes/export_more_api-2024-3-23-17-29-45.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: feature
packages:
- "@azure-tools/typespec-client-generator-core"
---

export int and float type judgement function
12 changes: 10 additions & 2 deletions packages/typespec-client-generator-core/src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,21 @@ export function getKnownScalars(): Record<string, SdkBuiltInKinds> {
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 {
Expand Down

0 comments on commit baf791e

Please sign in to comment.