Skip to content

Unable to reflect inferred type #14

@mindplay-dk

Description

@mindplay-dk

I don't know if you currently want feedback, since you're working on major changes? let me know if this is wanted or not? 🙂

This issue is best explained by example:

class UserRepo {
  getUsers() {
    return [{ name: "Bob", age: "42" }];
  }
}

function run<T>(fn: () => T): T {
  const type = getType<T>();

  console.log(type.id);

  return fn();
}

run(() => new UserRepo()); // 👎 ::invalid::Invalid

run<UserRepo>(() => new UserRepo()); // 👍 @try-rttist/dist/index::UserRepo

The two run calls should return the same type - as you can see here, it's being inferred:

image

With an explicit type argument, it works, but I'm assuming this should work with inference as well?

Here's a repro for this issue:

https://github.com/mindplay-dk/try-rttist/tree/inference-repro

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingchallengingChallenging to implement due to technical complexity or time constraints

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions