Content-Length: 275162 | pFad | http://github.com/microsoft/TypeScript/issues/16805

0F TS 2.4.1: ReadonlyArray<Identifiable> not assignable to type ReadonlyArray<T> even though <T extends Identifiable> · Issue #16805 · microsoft/TypeScript · GitHub
Skip to content

TS 2.4.1: ReadonlyArray<Identifiable> not assignable to type ReadonlyArray<T> even though <T extends Identifiable> #16805

Closed
@mmc41

Description

@mmc41

TypeScript Version: 2.4.1

Code

export interface Identifiable {
 id: string;
}

export function test<T extends Identifiable>(): ReadonlyArray<T> {
    const result: ReadonlyArray<Identifiable> = [];
    return result;
}

Expected behavior:
Should compile ok.

Actual behavior:

Error: 'Type 'ReadonlyArray<Identifiable>' is not assignable to type 'ReadonlyArray<T>'.
  Type 'Identifiable' is not assignable to type 'T'.
```'

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions









      ApplySandwichStrip

      pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


      --- a PPN by Garber Painting Akron. With Image Size Reduction included!

      Fetched URL: http://github.com/microsoft/TypeScript/issues/16805

      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy