-
Notifications
You must be signed in to change notification settings - Fork 669
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
refactor: add typing to all non-generated functions of speech-to-text #954
refactor: add typing to all non-generated functions of speech-to-text #954
Conversation
Codecov Report
@@ Coverage Diff @@
## release-candidate-v5 #954 +/- ##
=======================================================
Coverage ? 64.28%
=======================================================
Files ? 2
Lines ? 14
Branches ? 3
=======================================================
Hits ? 9
Misses ? 4
Partials ? 1 Continue to review full report at Codecov.
|
Codacy quality review is on adding the |
@MasterOdin I actually couldn't care less about what Codacy says, a lot of times it even contradicts our own style/linting guides. That said, I was going to comment on the introduction of namespaces here since I believe they are generally recommended against and I've been thinking about trying to refactor how we organize the other files to remove them. Now I see why you would want them for the STT class so that it's consistent for the other services but for the RecognizeStream class, would it make a big difference to do something like this? export interface RecognizeStreamOptions extends DuplexOptions, SpeechToTextV1.Options {
// these options represent the superset of the base params,
// query params, and opening message params, with the keys
// in lowerCamelCase format so we can expose a consistent style
// to the user.
authenticator: Authenticator;
url?: string;
} |
Unfortunately,
which essentially binds this to using the |
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.
This all looks pretty good. Just had one question but otherwise I'm ready to approve it
That's a good point, we can do that.
That's something I've been wanting to get to recently but just have not had the time. If you want to take a stab at the design for that, that would be great and I'd be happy to review it with you. I think the big limitation there is that we are pretty ingrained with the import naming structure for the SDK ( Another thing to think about is that if it would help to define our own |
You'd only want to do the
|
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.
Looks good, thanks again for the PR!
This adds typing for the three functions of
./speech-to-text/v1.ts
that lacked them, as well as removes any implicit definitions of any in the file.I decided it would be more pragmatic to make
RecognizeStream.Options
a superset ofDuplex.Options
andSpeechToTextV1.RecognizeWebSocketParams
and not duplicate the definitions across the two files, especially given the stream is only used for that particular method in the SDK itself.I also added the optional bit to all optional properties of
RecognizeStream.Options
as part of this.I used
extend
a couple of times (as it was already in the project and in this file) so that I wouldn't have to make (for example)WhenCorporaAnalyzedOptions.errorFilter
"optional" to allow it to be defined on the next line. I didn't do that withSpeechToTextError
as it's not possible to define a second class in the file per the tslint and so had to make due with a weaker interface design with optionalcode
even though it should never actually be undefined in usage.Checklist
npm test
passes (tip:npm run autofix
can correct most style issues)