-
Notifications
You must be signed in to change notification settings - Fork 2
Refactor data parameter in TranscriptionWorkerClient.ts to use explicit types instead of any
#220
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -99,6 +99,16 @@ export interface WorkerMessageMap { | |||||
| V4_FINALIZE_TIMEOUT: { payload: void; response: V4ProcessResult | null }; | ||||||
| V4_RESET: { payload: void; response: void }; | ||||||
| } | ||||||
|
|
||||||
| /** Valid incoming messages from the worker */ | ||||||
| export type WorkerIncomingMessage = | ||||||
| | { type: 'MODEL_PROGRESS'; payload: ModelProgress; id?: number } | ||||||
| | { type: 'MODEL_STATE'; payload: ModelState; id?: number } | ||||||
| | { type: 'V3_CONFIRMED'; payload: { text: string; words: any[] }; id?: number } | ||||||
| | { type: 'V3_PENDING'; payload: { text: string; words: any[] }; id?: number } | ||||||
| | { type: 'ERROR'; payload: string; id?: number } | ||||||
| | { type: string; payload?: any; id: number }; | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This generic catch-all with
Suggested change
Comment on lines
+104
to
+110
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 1. Missing transcription_result variant WorkerIncomingMessage cannot represent { type: 'TRANSCRIPTION_RESULT', payload: ... } messages
emitted by transcription.worker.ts because the union’s fallback branch requires id: number, but
that worker message has no id.
Agent Prompt
|
||||||
|
|
||||||
| export class TranscriptionWorkerClient { | ||||||
| private static readonly DISPOSED_ERROR_MESSAGE = 'TranscriptionWorkerClient disposed'; | ||||||
| private worker: Worker; | ||||||
|
|
@@ -126,7 +136,7 @@ export class TranscriptionWorkerClient { | |||||
| }; | ||||||
| } | ||||||
|
|
||||||
| private handleMessage(data: any) { | ||||||
| private handleMessage(data: WorkerIncomingMessage) { | ||||||
| const { type, payload, id } = data; | ||||||
|
|
||||||
| // Handle promise resolutions | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using
any[]for thewordsproperty is a missed opportunity to improve type safety, which is the main goal of this pull request. Consider using a more specific type for the elements in thewordsarray. The existingTranscriptionWordtype (which would need to be added to the imports from./types) seems like a good candidate. If its structure doesn't match, a new interface should be defined for these V3 tokens.