Skip to content

Commit 87b859e

Browse files
Improve typing
Signed-off-by: Andrei Floricel <andrei.floricel@gmail.com>
1 parent 265eed8 commit 87b859e

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

src/api/DesktopAgent.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { PrivateChannel } from './PrivateChannel';
1414
import { AppIdentifier } from './AppIdentifier';
1515
import { AppMetadata } from './AppMetadata';
1616
import { Intent } from '../intents/Intents';
17+
import { ContextType } from '../context/ContextType';
1718

1819
/**
1920
* A Desktop Agent is a desktop component (or aggregate of components) that serves as a
@@ -372,7 +373,7 @@ export interface DesktopAgent {
372373
* });
373374
* ```
374375
*/
375-
addContextListener(contextType: string | null, handler: ContextHandler): Promise<Listener>;
376+
addContextListener(contextType: ContextType | null, handler: ContextHandler): Promise<Listener>;
376377

377378
/**
378379
* Retrieves a list of the User channels available for the app to join.

src/api/Methods.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
StandardContextType,
1919
StandardIntent,
2020
ContextTypeFor,
21+
ContextType,
2122
} from '..';
2223
import { IntentsConfiguration, StandardContextsSet, StandardIntentsSet } from '../intents/IntentsConfiguration';
2324

@@ -112,7 +113,7 @@ export function addIntentListener(intent: Intent, handler: IntentHandler): Promi
112113
}
113114

114115
export function addContextListener(
115-
contextTypeOrHandler: string | null | ContextHandler,
116+
contextTypeOrHandler: ContextType | null | ContextHandler,
116117
handler?: ContextHandler
117118
): Promise<Listener> {
118119
//Handle (deprecated) function signature that allowed contextType argument to be omitted
@@ -187,15 +188,15 @@ export function findInstances(app: AppIdentifier): Promise<AppIdentifier[]> {
187188
* Check if the given context is a standard context type.
188189
* @param contextType
189190
*/
190-
export function isStandardContextType(contextType: string): contextType is StandardContextType {
191+
export function isStandardContextType(contextType: ContextType): contextType is StandardContextType {
191192
return StandardContextsSet.has(contextType as StandardContextType);
192193
}
193194

194195
/**
195196
* Check if the given intent is a standard intent.
196197
* @param intent
197198
*/
198-
export function isStandardIntent(intent: string): intent is StandardIntent {
199+
export function isStandardIntent(intent: Intent): intent is StandardIntent {
199200
return StandardIntentsSet.has(intent as StandardIntent);
200201
}
201202

0 commit comments

Comments
 (0)