Skip to content

RangeError: Maximum call stack size exceeded (with await nested promises) #35289

Open
@kzok

Description

@kzok

TypeScript Version: 3.8.0-dev.20191122

Code

  • source code
interface PromiseAction extends Promise<Action> {}
type Action = {type: string} | PromiseAction;
const createFooAction = async (): Promise<Action> => {type: "foo"};
  • tsconfig.json
{
  "compilerOptions": {
    "target": "es2017",
    "allowSyntheticDefaultImports": true,
    "module": "commonjs",
    "moduleResolution": "node",
    "noImplicitAny": true,
    "noImplicitReturns": true,
    "noImplicitThis": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "strictNullChecks": true,
  },
  "include": ["src/**/*"]
}

Expected behavior:

succeed type check or raise some error

Actual behavior:

tsc crashes with RangeError: Maximum call stack size exceeded

$ npm run check

> @ check /Users/okamoto-k/sandbox
> tsc --noEmit

/Users/okamoto-k/sandbox/node_modules/typescript/lib/tsc.js:78686
                throw e;
                ^

RangeError: Maximum call stack size exceeded
    at getPromisedTypeOfPromise (/Users/okamoto-k/sandbox/node_modules/typescript/lib/tsc.js:49700:42)
    at getAwaitedType (/Users/okamoto-k/sandbox/node_modules/typescript/lib/tsc.js:49758:32)
    at getAwaitedType (/Users/okamoto-k/sandbox/node_modules/typescript/lib/tsc.js:49751:46)
    at getAwaitedType (/Users/okamoto-k/sandbox/node_modules/typescript/lib/tsc.js:49767:35)
    at getAwaitedType (/Users/okamoto-k/sandbox/node_modules/typescript/lib/tsc.js:49751:46)
    at getAwaitedType (/Users/okamoto-k/sandbox/node_modules/typescript/lib/tsc.js:49767:35)
    at getAwaitedType (/Users/okamoto-k/sandbox/node_modules/typescript/lib/tsc.js:49751:46)
    at getAwaitedType (/Users/okamoto-k/sandbox/node_modules/typescript/lib/tsc.js:49767:35)
    at getAwaitedType (/Users/okamoto-k/sandbox/node_modules/typescript/lib/tsc.js:49751:46)
    at getAwaitedType (/Users/okamoto-k/sandbox/node_modules/typescript/lib/tsc.js:49767:35)

Playground Link:
http://www.typescriptlang.org/play/#code/JYOwLgpgTgZghgYwgAgApQPYFtgGcICCCYwGIyEAHpCACa5qY74A8RJZAfMgN4C+AKDABPAA4p2pcgF5eI8QC5kuMFFABzPsgA+jbHkLEpAbgEIyK5AigQ4kAGIYMkssllxcwkAmQAKAJRK6PqsLiDc0tw8yPIQSgBEME7xyHymQA

Related Issues:

I couldn't find it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptCrashFor flagging bugs which are compiler or service crashes or unclean exits, rather than bad output

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions