Skip to content

Nested object type inference #25295

Closed
Closed
@Jomik

Description

@Jomik

TypeScript Version: 3.0.0-dev.20180628

Search Terms: infer nested type object

Code

class Foo<A> {
  private a: A;
}

class ObjectFoo<A> extends Foo<A> {
  constructor(private b: { [k in keyof A]: Foo<A[k]> }) {
    super();
  }
}

const a = new ObjectFoo({ b: new Foo<string>() });
const obj = new ObjectFoo({ a });

Expected behavior:
Expect obj to have type { a: { b: string } }

Actual behavior:
obj has type { a: { b: any } }

Playground Link:
playground

Related Issues:

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