Skip to content

SpecWatchFilter type in Firestore tests will not compile with upcoming Typescript 2.7 #309

Closed
@sandersn

Description

@sandersn

[REQUIRED] Describe your environment

  • Operating System version: n/a
  • Firebase SDK version: building from master
  • Firebase Product: firestore

[REQUIRED] Describe the problem

Previously, the type SpecWatchFilter in spec_test_runner was specified as a tuple, but it was later used with push. It's actually an array with a first element that is guaranteed to be present, and of type TargetId[].

In the upcoming Typescript 2.7, tuples will be fixed-length and this usage will fail. The fix is to change the definition of SpecWatchFilter to an interface that extends Array<TargetId[] | string> and whose required '0' property is a TargetId[]. I'll have a PR up shortly that does this.

Steps to reproduce:

Build with typescript@next.

Relevant Code:

// this will be an error in Typescript 2.7, because [targetIds].length === 1 
// but  [SpecFilterId[], string].length: 2
const filter: [SpecFilterId[], string] = [targetIds] as [SpecFilterId[], string];

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions