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

treat-unknown-as-any-in-modular #2546

Merged
merged 6 commits into from
May 27, 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
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ export type APIVersion = "2023-10-01-preview";

// @public
export interface ChatChoiceRecord {
context?: Record<string, unknown>;
context?: Record<string, any>;
finishReason: FinishReason;
index: number;
message: ChatMessage;
sessionState?: unknown;
sessionState?: any;
}

// @public
Expand All @@ -29,9 +29,9 @@ export interface ChatCompletionChunkRecord {

// @public
export interface ChatCompletionOptionsRecord {
context?: Record<string, unknown>;
context?: Record<string, any>;
messages: ChatMessage[];
sessionState?: unknown;
sessionState?: any;
stream: false;
}

Expand All @@ -44,14 +44,14 @@ export interface ChatCompletionRecord {
export interface ChatMessage {
content: string;
role: ChatRole;
sessionState?: unknown;
sessionState?: any;
}

// @public
export interface ChatMessageDelta {
content?: string;
role?: ChatRole;
sessionState?: unknown;
sessionState?: any;
}

// @public (undocumented)
Expand All @@ -71,11 +71,11 @@ export type ChatRole = "user" | "system" | "assistant";

// @public
export interface ChoiceDeltaRecord {
context?: Record<string, unknown>;
context?: Record<string, any>;
delta: ChatMessageDelta;
finishReason?: FinishReason;
index: number;
sessionState?: unknown;
sessionState?: any;
}

// @public (undocumented)
Expand All @@ -91,9 +91,9 @@ export type FinishReason = "stop" | "length";

// @public
export interface StreamingChatCompletionOptionsRecord {
context?: Record<string, unknown>;
context?: Record<string, any>;
messages: ChatMessage[];
sessionState?: unknown;
sessionState?: any;
stream: true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface ChatMessage {
* sends a new one. The data in this field can be used to implement stateful services, such as remembering previous
* conversations or user preferences.
*/
sessionState?: unknown;
sessionState?: any;
}

/** A representation of the intended purpose of a message. */
Expand All @@ -32,12 +32,12 @@ export interface StreamingChatCompletionOptionsRecord {
* sends a new one. The data in this field can be used to implement stateful services, such as remembering previous
* conversations or user preferences.
*/
sessionState?: unknown;
sessionState?: any;
/**
* Context allows the chat app to receive extra parameters from the client, such as temperature, functions, or
* customer_info. These parameters are specific to the chat app and not understood by the generic clients.
*/
context?: Record<string, unknown>;
context?: Record<string, any>;
}

/** A single response to a streaming completion request. */
Expand All @@ -58,12 +58,12 @@ export interface ChoiceDeltaRecord {
* sends a new one. The data in this field can be used to implement stateful services, such as remembering previous
* conversations or user preferences.
*/
sessionState?: unknown;
sessionState?: any;
/**
* Context allows the chat app to receive extra parameters from the client, such as temperature, functions, or
* customer_info. These parameters are specific to the chat app and not understood by the generic clients.
*/
context?: Record<string, unknown>;
context?: Record<string, any>;
/** The reason this chat completion completed its generation. */
finishReason?: FinishReason;
}
Expand All @@ -80,7 +80,7 @@ export interface ChatMessageDelta {
* sends a new one. The data in this field can be used to implement stateful services, such as remembering previous
* conversations or user preferences.
*/
sessionState?: unknown;
sessionState?: any;
}

/** Representation of the reason why a chat session has finished processing. */
Expand All @@ -99,12 +99,12 @@ export interface ChatCompletionOptionsRecord {
* sends a new one. The data in this field can be used to implement stateful services, such as remembering previous
* conversations or user preferences.
*/
sessionState?: unknown;
sessionState?: any;
/**
* Context allows the chat app to receive extra parameters from the client, such as temperature, functions, or
* customer_info. These parameters are specific to the chat app and not understood by the generic clients.
*/
context?: Record<string, unknown>;
context?: Record<string, any>;
}

/** Representation of the response to a chat completion request. */
Expand All @@ -125,12 +125,12 @@ export interface ChatChoiceRecord {
* sends a new one. The data in this field can be used to implement stateful services, such as remembering previous
* conversations or user preferences.
*/
sessionState?: unknown;
sessionState?: any;
/**
* Context allows the chat app to receive extra parameters from the client, such as temperature, functions, or
* customer_info. These parameters are specific to the chat app and not understood by the generic clients.
*/
context?: Record<string, unknown>;
context?: Record<string, any>;
/** The reason this chat completion completed its generation. */
finishReason: FinishReason;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export interface BrokerProperties {

// @public
export interface CloudEvent {
data?: unknown;
data?: any;
dataBase64?: Uint8Array;
datacontenttype?: string;
dataschema?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export interface CloudEvent {
/** Identifies the context in which an event happened. The combination of id and source must be unique for each distinct event. */
source: string;
/** Event data specific to the event type. */
data?: unknown;
data?: any;
/** Event data specific to the event type, encoded as a base64 string. */
dataBase64?: Uint8Array;
/** Type of event related to the originating occurrence. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export interface ChatCompletionFunctionCallOption {
}

// @public (undocumented)
export interface ChatCompletionFunctionParameters extends Record<string, unknown> {
export interface ChatCompletionFunctionParameters extends Record<string, any> {
}

// @public (undocumented)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -773,8 +773,7 @@ export interface ChatCompletionFunctions {
parameters: ChatCompletionFunctionParameters;
}

export interface ChatCompletionFunctionParameters
extends Record<string, unknown> {}
export interface ChatCompletionFunctionParameters extends Record<string, any> {}

export interface ChatCompletionFunctionCallOption {
/** The name of the function to call. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ export type FunctionCallPreset = "auto" | "none";
export interface FunctionDefinition {
description?: string;
name: string;
parameters?: unknown;
parameters?: any;
}

// @public
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ export interface FunctionDefinition {
*/
description?: string;
/** The parameters the function accepts, described as a JSON Schema object. */
parameters?: unknown;
parameters?: any;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export interface ChatCompletionFunctionCallOption {
}

// @public (undocumented)
export interface ChatCompletionFunctionParameters extends Record<string, unknown> {
export interface ChatCompletionFunctionParameters extends Record<string, any> {
}

// @public (undocumented)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -772,8 +772,7 @@ export interface ChatCompletionFunctions {
parameters: ChatCompletionFunctionParameters;
}

export interface ChatCompletionFunctionParameters
extends Record<string, unknown> {}
export interface ChatCompletionFunctionParameters extends Record<string, any> {}

export interface ChatCompletionFunctionCallOption {
/** The name of the function to call. */
Expand Down
2 changes: 1 addition & 1 deletion packages/typespec-ts/src/modular/helpers/typeHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const simpleTypeMap: Record<string, TypeMetadata> = {
"byte-array": { name: "Uint8Array" },
string: { name: "string" },
any: { name: "Record<string, any>" },
unknown: { name: "unknown" }
unknown: { name: "any" }
};

function handleAnomymousModelName(type: Type) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function _unknownValueGetSend(

export async function _unknownValueGetDeserialize(
result: UnknownValueGet200Response,
): Promise<unknown[]> {
): Promise<any[]> {
if (result.status !== "200") {
throw createRestError(result);
}
Expand All @@ -38,14 +38,14 @@ export async function _unknownValueGetDeserialize(
export async function unknownValueGet(
context: Client,
options: UnknownValueGetOptionalParams = { requestOptions: {} },
): Promise<unknown[]> {
): Promise<any[]> {
const result = await _unknownValueGetSend(context, options);
return _unknownValueGetDeserialize(result);
}

export function _unknownValuePutSend(
context: Client,
body: unknown[],
body: any[],
options: UnknownValuePutOptionalParams = { requestOptions: {} },
): StreamableMethod<UnknownValuePut204Response> {
return context
Expand All @@ -65,7 +65,7 @@ export async function _unknownValuePutDeserialize(

export async function unknownValuePut(
context: Client,
body: unknown[],
body: any[],
options: UnknownValuePutOptionalParams = { requestOptions: {} },
): Promise<void> {
const result = await _unknownValuePutSend(context, body, options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,15 @@ import {
} from "../../models/options.js";

export interface UnknownValueOperations {
get: (options?: UnknownValueGetOptionalParams) => Promise<unknown[]>;
put: (
body: unknown[],
options?: UnknownValuePutOptionalParams,
) => Promise<void>;
get: (options?: UnknownValueGetOptionalParams) => Promise<any[]>;
put: (body: any[], options?: UnknownValuePutOptionalParams) => Promise<void>;
}

export function getUnknownValue(context: ArrayContext) {
return {
get: (options?: UnknownValueGetOptionalParams) =>
unknownValueGet(context, options),
put: (body: unknown[], options?: UnknownValuePutOptionalParams) =>
put: (body: any[], options?: UnknownValuePutOptionalParams) =>
unknownValuePut(context, body, options),
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ export interface IsUnknownAdditionalPropertiesDerived

/** The model extends from Record<unknown> with a discriminator. */
export interface ExtendsUnknownAdditionalPropertiesDiscriminated
extends Record<string, unknown> {
extends Record<string, any> {
/** The name property */
name: string;
/** the discriminator possible values: derived */
Expand All @@ -239,7 +239,7 @@ export interface ExtendsUnknownAdditionalPropertiesDiscriminatedDerived

/** The model extends from Record<unknown> type. */
export interface ExtendsUnknownAdditionalProperties
extends Record<string, unknown> {
extends Record<string, any> {
/** The name property */
name: string;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,25 +56,25 @@ export interface StringLiteralProperty {
/** Model with a property unknown, and the data is an array. */
export interface UnknownArrayProperty {
/** Property */
property: unknown;
property: any;
}

/** Model with a property unknown, and the data is a dictionnary. */
export interface UnknownDictProperty {
/** Property */
property: unknown;
property: any;
}

/** Model with a property unknown, and the data is a int32. */
export interface UnknownIntProperty {
/** Property */
property: unknown;
property: any;
}

/** Model with a property unknown, and the data is a string. */
export interface UnknownStringProperty {
/** Property */
property: unknown;
property: any;
}

/** Model with a property never. (This property should not be included). */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function _unknownGetSend(

export async function _unknownGetDeserialize(
result: UnknownGet200Response,
): Promise<unknown> {
): Promise<any> {
if (result.status !== "200") {
throw createRestError(result);
}
Expand All @@ -39,14 +39,14 @@ export async function _unknownGetDeserialize(
export async function unknownGet(
context: Client,
options: UnknownGetOptionalParams = { requestOptions: {} },
): Promise<unknown> {
): Promise<any> {
const result = await _unknownGetSend(context, options);
return _unknownGetDeserialize(result);
}

export function _unknownPutSend(
context: Client,
body: unknown,
body: any,
options: UnknownPutOptionalParams = { requestOptions: {} },
): StreamableMethod<UnknownPut204Response> {
return context
Expand All @@ -67,7 +67,7 @@ export async function _unknownPutDeserialize(
/** put unknown value */
export async function unknownPut(
context: Client,
body: unknown,
body: any,
options: UnknownPutOptionalParams = { requestOptions: {} },
): Promise<void> {
const result = await _unknownPutSend(context, body, options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import {
} from "../../models/options.js";

export interface UnknownOperations {
get: (options?: UnknownGetOptionalParams) => Promise<unknown>;
put: (body: unknown, options?: UnknownPutOptionalParams) => Promise<void>;
get: (options?: UnknownGetOptionalParams) => Promise<any>;
put: (body: any, options?: UnknownPutOptionalParams) => Promise<void>;
}

export function getUnknown(context: ScalarContext) {
return {
get: (options?: UnknownGetOptionalParams) => unknownGet(context, options),
put: (body: unknown, options?: UnknownPutOptionalParams) =>
put: (body: any, options?: UnknownPutOptionalParams) =>
unknownPut(context, body, options),
};
}
Expand Down
Loading
Loading