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

Maximum call stack size exceeded with two mapped types #57786

Closed
autologie opened this issue Mar 15, 2024 · 1 comment Β· Fixed by #57837
Closed

Maximum call stack size exceeded with two mapped types #57786

autologie opened this issue Mar 15, 2024 · 1 comment Β· Fixed by #57837
Assignees
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue
Milestone

Comments

@autologie
Copy link

πŸ”Ž Search Terms

"Maximum call stack size exceeded", "mapped types"

πŸ•— Version & Regression Information

  • This is a crash

⏯ Playground Link

https://www.typescriptlang.org/play?ts=5.4.2#code/C4TwDgpgBAYg9nAPANQHxQLxQN4CgoFQDaA0lAJYB2UA1hCHAGZTIC6AXLAiqa6gNy4AvrlyhIUAEIBDAE4p0WPIWJkqtekxYcWvKBAAewCJQAmAZyhwARgCsIAY2BQA-FLk8SfKJ3PBZVADmgiK4jACulE7kcNTGfgoAFABu0gA24RCc8EhoAJQ4+FAOseZwaRAAdGlwgSnpmXkhoiWUflDWcpwy8tKUIIo4QoJiEH6JnbJNuEA

πŸ’» Code

type Foo<V> = {
    [K in keyof V]: Foo<V[K]>;
}

type Bar<V> = {
    [K in keyof V]: V[K] extends object ? Bar<V[K]> : string;
}

function test<V>(value: Foo<V>) {
  console.log(value);
}

const bar: Bar<any> = {};

test(bar);

πŸ™ Actual behavior

Throws an exception

Uncaught (in promise) RangeError: Maximum call stack size exceeded

πŸ™‚ Expected behavior

Either passes type check or reports a problem

Additional information about the issue

No response

@RyanCavanaugh
Copy link
Member

Repros as far back as 4.0, possibly earlier. Wild.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants