Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support "equivalent to" for values #252

Merged
merged 6 commits into from Mar 10, 2024
Merged

Support "equivalent to" for values #252

merged 6 commits into from Mar 10, 2024

Conversation

danvk
Copy link
Owner

@danvk danvk commented Mar 10, 2024

Fixes #167

Weirdly the Resolve helper only resolves types at the top level, not in functions:

interface Point {
  x: number;
  y: number;
}

type Resolve<Raw> = Raw extends Function ? Raw : { [K in keyof Raw]: Raw[K] };
function foo(pt: Point) {
  let k: keyof Point;
  for (k in pt) {
    // ^? let k: keyof Point
    type SynthK = Resolve<keyof Point>;
    //   ^? type SynthK = keyof Point
  }
}

type SynthT2 = Resolve<keyof Point>;
//   ^? type SynthT2 = "x" | "y"`);

This might be microsoft/TypeScript#49852

@danvk danvk marked this pull request as ready for review March 10, 2024 13:42
@danvk danvk merged commit 944d48d into main Mar 10, 2024
2 of 3 checks passed
@danvk danvk deleted the infer-equiv-167 branch March 10, 2024 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inferred type equivalent to
1 participant