Skip to content

Typescript definition: NestedArray doesn't have array methods #10

@ikokostya

Description

@ikokostya

Versions

  • array-flatten version: 2.1.0
  • typescript version: 2.1.5

Problem

When I try to compile the following example

import * as flatten from 'array-flatten';

const arr = flatten.depth<number>([[[1, 2]]], 1);
arr.push(1);

I get the error:

index.ts(4,5): error TS2339: Property 'push' does not exist on type 'NestedArray<number>'.

Expected behavior

No errors. NestedArray interface has methods from Array. Maybe define NestedArray like this:

interface NestedArray<T> extends Array<T | NestedArray<T>> {}

?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions