-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
It's impossible to reference the child type
{
/** The content of the user's message. */
content: string;
current_files?: {
[key: string]: number[];
};
/**
* {
* "nullable": true,
* "description": "The project name, if any. This can be used to associate the message with a specific project."
* }
*/
project_name?: string;
/** The source ranges the user suggested to change. If empty, the content (prompt) will be used and is required. */
source_ranges?: SourceRangePrompt[];
type: 'user';
}
Without having to redefine it.
This makes type narrowing more difficult and causes duplicate types which has been voiced to be particularly annoying.
I don't know the derivation happens but to fix this, type MlCopilotClientMessageUser = ... would solve the issue.
Edit: It's possible to use conditional typing to extract out the type but it should not be necessary to do type gymnastics to get access:
type MlCopilotClientMessageUser<T = MlCopilotClientMessage> = T extends { type: 'user' }
? T
: never
function isMlCopilotUserRequest(x: unknown): x is MlCopilotClientMessageUser {
return 'type' in x && x.type === 'user'
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels