Skip to content

RangeError: Maximum call stack size exceeded at getAwaitedTypeNoAliasย #49723

Closed

Description

Bug Report

Moved from #47208 (comment)

๐Ÿ”Ž Search Terms

RangeError Maximum call stack size exceeded getAwaitedTypeNoAlias

๐Ÿ•— Version & Regression Information

  • This is the behavior in every version I tried.

โฏ Playground Link

Playground Link

๐Ÿ’ป Code

type T = 1 | Promise<T> | T[];

export async function myFunction(param: T) {
  const awaited = await param
}

๐Ÿ™ Actual behavior

     RangeError: Maximum call stack size exceeded
      at getAwaitedTypeNoAlias (src\compiler\checker.ts:36632:70)
      at mapper (src\compiler\checker.ts:36628:71)
      at mapType (src\compiler\checker.ts:23959:95)
      at getAwaitedTypeNoAlias (src\compiler\checker.ts:36629:60)
      at getAwaitedTypeNoAlias (src\compiler\checker.ts:36678:37)
      at mapper (src\compiler\checker.ts:36628:71)
      at mapType (src\compiler\checker.ts:23959:95)
      at getAwaitedTypeNoAlias (src\compiler\checker.ts:36629:60)
      at getAwaitedTypeNoAlias (src\compiler\checker.ts:36678:37)
      at mapper (src\compiler\checker.ts:36628:71)
      at mapType (src\compiler\checker.ts:23959:95)
      at getAwaitedTypeNoAlias (src\compiler\checker.ts:36629:60)
      at getAwaitedTypeNoAlias (src\compiler\checker.ts:36678:37)
      at mapper (src\compiler\checker.ts:36628:71)
      at mapType (src\compiler\checker.ts:23959:95)
      at getAwaitedTypeNoAlias (src\compiler\checker.ts:36629:60)
      at getAwaitedTypeNoAlias (src\compiler\checker.ts:36678:37)

๐Ÿ™‚ Expected behavior

No crash.

Activity

  1. jakebailey commented on Jun 29, 2022

    @jakebailey
    MemberAuthor

    Actually, this is a dupe of #49646 and should be fixed by #49677.

  2. fatcerberus commented on Jun 29, 2022

    @fatcerberus

    type T = 1 | Promise<T> | T[];

    I'm not sure how to read this type. Does this mean T is either:

    • A 1
    • An array of 1s
    • An array of arrays of 1s
    • A promise for a 1
    • An array of promises for 1s
    • A promise for an array of 1s
    • A promise for an array of promises for 1s
    • etc., inductively

    ...or is it just a completely circular definition?

  3. jakebailey commented on Jun 29, 2022

    @jakebailey
    MemberAuthor

    It's just circular; there's an error message for types like these that can't be resolved (see the linked PR).

  4. fatcerberus commented on Jun 29, 2022

    @fatcerberus

    That's what I thought; I guess I'm just confused because I thought when TS produced an error for a circular type it subsequently treated the type as any, which should be enough to prevent the crash on await... I guess the bug is that this case isn't being detected as circular

  5. Andarist commented on Jun 29, 2022

    @Andarist
    Contributor

    I guess the bug is that this case isn't being detected as circular

    Yep, notice how I've fixed this by just adding the circularity tracking~ here:
    https://github.com/microsoft/TypeScript/pull/49677/files#diff-d9ab6589e714c71e657f601cf30ff51dfc607fc98419bf72e04f6b0fa92cc4b8R36628

  6. locked as resolved and limited conversation to collaborators on Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions