-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Explicitly list error targets in chat stateful client (#636)
- Loading branch information
1 parent
370cb99
commit 3329ea7
Showing
7 changed files
with
70 additions
and
46 deletions.
There are no files selected for viewing
7 changes: 0 additions & 7 deletions
7
change/@internal-chat-stateful-client-1590f6eb-8e49-4add-8856-500109777482.json
This file was deleted.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
change/@internal-chat-stateful-client-4ab8067f-e02d-4ae7-af21-7644e44a1c93.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "prerelease", | ||
"comment": "Add explicit string literals for error targets", | ||
"packageName": "@internal/chat-stateful-client", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
import { ChatClient, ChatThreadClient } from '@azure/communication-chat'; | ||
import { ChatErrorTargets } from './ChatClientState'; | ||
|
||
/** | ||
* Internal type-assertion that explicitly listed {@Link ChatErrorTargets} correspond to the underlying base SDK API. | ||
*/ | ||
export const ensureChatErrorTargetsContainsOnlyValidValues = (target: ChatErrorTargets): InferredChatErrorTargets => | ||
target; | ||
|
||
/** | ||
* Internal type-assertion that explicitly listed {@Link ChatErrorTargets} correspond to the underlying base SDK API. | ||
*/ | ||
export const ensureChatErrorTargetsContainsAllValidValues = (target: InferredChatErrorTargets): ChatErrorTargets => | ||
target; | ||
|
||
/** | ||
* String literal type for all permissible keys in {@Link ChatErrors}. | ||
*/ | ||
type InferredChatErrorTargets = | ||
| ChatObjectMethodNames<'ChatClient', ChatClient> | ||
| ChatObjectMethodNames<'ChatThreadClient', ChatThreadClient>; | ||
|
||
/** | ||
* Helper type to build a string literal type containing methods of an object. | ||
*/ | ||
export type ChatObjectMethodNames<TName extends string, T> = { | ||
[K in keyof T]: `${TName}.${ChatMethodName<T, K>}`; | ||
}[keyof T]; | ||
|
||
/** | ||
* Helper type to build a string literal type containing methods of an object. | ||
*/ | ||
// eslint complains on all uses of `Function`. Using it as a type constraint is legitimate. | ||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
export type ChatMethodName<T, K extends keyof T> = T[K] extends Function ? (K extends string ? K : never) : never; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters