Skip to content

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

Merged
merged 3 commits into from
Nov 10, 2017

Conversation

sandersn
Copy link
Contributor

@sandersn sandersn commented Nov 9, 2017

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[].

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[].
@sandersn
Copy link
Contributor Author

sandersn commented Nov 9, 2017

Looks like CI broke because of incorrect credentials. Not sure what is going on there.

Copy link
Contributor

@wilhuff wilhuff left a 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[];
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@jshcrowthe
Copy link
Contributor

Hey @sandersn, if you'll update this branch, you should pick up a change that will run the tests properly 👍.

Thanks for the ping @wilhuff

@sandersn
Copy link
Contributor Author

All right, looks like CI passed this time.

Copy link
Contributor

@wilhuff wilhuff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@wilhuff wilhuff merged commit 1f0712e into firebase:master Nov 10, 2017
@firebase firebase locked and limited conversation to collaborators Oct 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SpecWatchFilter type in Firestore tests will not compile with upcoming Typescript 2.7
4 participants