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] unify datetime casing by renaming interface types #1067

Merged
merged 4 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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/rename_datetime_type-2024-5-24-14-52-19.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: fix
packages:
- "@azure-tools/typespec-client-generator-core"
---

Unify casing of datetime spelling to `DateTime`. Change interface names to `SdkDateTimeType`, `SdkUtcDateTimeType`, and `SdkOffsetDateTimeType`
2 changes: 1 addition & 1 deletion packages/typespec-client-generator-core/doc/types.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ model SdkBuiltInType extends SdkType {
* @property encode: How to encode the datetime and represent to users
* @property wireType: What type we end up sending over the wire for a datetime. Can be a string or an int type.
*/
model SdkDatetimeType extends SdkType {
model SdkDateTimeType extends SdkType {
kind: "datetime";
encode: DateTimeKnownEncoding;
wireType: SdkType;
Expand Down
16 changes: 8 additions & 8 deletions packages/typespec-client-generator-core/src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ interface SdkTypeBase {

export type SdkType =
| SdkBuiltInType
| SdkDatetimeType
| SdkDateTimeType
iscai-msft marked this conversation as resolved.
Show resolved Hide resolved
| SdkDurationType
| SdkArrayType
| SdkTupleType
Expand Down Expand Up @@ -197,26 +197,26 @@ export function isSdkFloatKind(kind: string): kind is keyof typeof SdkFloatKinds
return kind in SdkFloatKindsEnum;
}

const SdkDatetimeEncodingsConst = ["rfc3339", "rfc7231", "unixTimestamp"] as const;
const SdkDateTimeEncodingsConst = ["rfc3339", "rfc7231", "unixTimestamp"] as const;

export function isSdkDatetimeEncodings(encoding: string): encoding is DateTimeKnownEncoding {
return SdkDatetimeEncodingsConst.includes(encoding as DateTimeKnownEncoding);
export function isSdkDateTimeEncodings(encoding: string): encoding is DateTimeKnownEncoding {
return SdkDateTimeEncodingsConst.includes(encoding as DateTimeKnownEncoding);
}

interface SdkDatetimeTypeBase extends SdkTypeBase {
interface SdkDateTimeTypeBase extends SdkTypeBase {
encode: DateTimeKnownEncoding;
wireType: SdkBuiltInType;
}

interface SdkUtcDatetimeType extends SdkDatetimeTypeBase {
interface SdkUtcDateTimeType extends SdkDateTimeTypeBase {
kind: "utcDateTime";
}

interface SdkOffsetDatetimeType extends SdkDatetimeTypeBase {
interface SdkOffsetDateTimeType extends SdkDateTimeTypeBase {
kind: "offsetDateTime";
}

export type SdkDatetimeType = SdkUtcDatetimeType | SdkOffsetDatetimeType;
export type SdkDateTimeType = SdkUtcDateTimeType | SdkOffsetDateTimeType;

export interface SdkDurationType extends SdkTypeBase {
kind: "duration";
Expand Down
4 changes: 2 additions & 2 deletions packages/typespec-client-generator-core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ import {
SdkConstantType,
SdkCredentialParameter,
SdkCredentialType,
SdkDatetimeType,
SdkDateTimeType,
SdkDictionaryType,
SdkDurationType,
SdkEnumType,
Expand Down Expand Up @@ -841,7 +841,7 @@ export function getClientTypeWithDiagnostics(
...getSdkTypeBaseHelper(context, type, type.name),
encode: "rfc3339",
wireType: { ...getSdkTypeBaseHelper(context, type, "string"), encode: "string" },
} as SdkDatetimeType;
} as SdkDateTimeType;
break;
}
if (type.name === "duration") {
Expand Down
Loading