-
Notifications
You must be signed in to change notification settings - Fork 923
Firestore: in tests, fix SpecWatchFilter type to work on upcoming Typescript 2.7 #310
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
Firestore: in tests, fix SpecWatchFilter type to work on upcoming Typescript 2.7 #310
Conversation
Previously, the type SpecWatchFilter in spec_test_runner was specified as a tuple, but it was later used with `push` and is actually an array with a first element that is guaranteed to be present, and of type TargetId[]. In Typescript 2.7, tuples will be fixed-length and this usage will fail. This changes the definition of SpecWatchFilter to an interface that extends Array<TargetId[] | string> and whose required '0' property is a TargetId[].
Looks like CI broke because of incorrect credentials. Not sure what is going on there. |
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.
Change LGTM, though we need to get CI sorted out.
@jshcrowthe - what can we do to get travis's credentials sorted?
@@ -1190,7 +1190,10 @@ export interface SpecWatchEntity { | |||
* Note that the last parameter is really of type ...string (spread operator) | |||
* The filter is based of a list of keys to match in the existence filter | |||
*/ | |||
export type SpecWatchFilter = [TargetId[], string]; | |||
export interface SpecWatchFilter extends Array<TargetId[] | string> { | |||
'0': TargetId[]; |
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 is surprising that this works. Thanks for digging into it.
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.
I found it when I was testing stricter tuples for Typescript 2.7. The new definition is basically equivalent to the old meaning of 'tuple' in Typescript.
All right, looks like CI passed this time. |
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.
LGTM
Fixes #309
Previously, the type SpecWatchFilter in spec_test_runner was specified as a tuple, but it was later used with
push
and is actually an array with a first element that is guaranteed to be present, and of type TargetId[].In Typescript 2.7, tuples will be fixed-length and this usage will fail. This changes the definition of SpecWatchFilter to an interface that extends Array<TargetId[] | string> and whose required '0' property is a TargetId[].