Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tcgc] export int and float type judgement function #727

Merged
merged 3 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading