Skip to content

TypeScript 4.7.4: Exponential behavior in strict type checking #49845

@imirkin

Description

@imirkin

When upgrading from TypeScript 4.6.4 to 4.7.4 in a large Angular application, I'm seeing an infinite loop when trying to compile. Adding --trace-sigint to the node invocation, I see some traces like:

KEYBOARD_INTERRUPT: Script execution was interrupted by `SIGINT`
    at isInParameterInitializerBeforeContainingFunction (/node_modules/typescript/lib/typescript.js:72539:13)
    at tryGetThisTypeAt (/node_modules/typescript/lib/typescript.js:72003:19)
    at checkThisExpression (/node_modules/typescript/lib/typescript.js:71979:24)
    at checkExpressionWorker (/node_modules/typescript/lib/typescript.js:79915:28)
    at checkExpression (/node_modules/typescript/lib/typescript.js:79860:38)
    at checkParenthesizedExpression (/node_modules/typescript/lib/typescript.js:79895:20)
    at checkExpressionWorker (/node_modules/typescript/lib/typescript.js:79960:28)
    at checkExpression (/node_modules/typescript/lib/typescript.js:79860:38)
    at checkNonNullExpression (/node_modules/typescript/lib/typescript.js:74469:37)
    at checkPropertyAccessExpression (/node_modules/typescript/lib/typescript.js:74514:85)
KEYBOARD_INTERRUPT: Script execution was interrupted by `SIGINT`
    at isWriteAccess (/node_modules/typescript/lib/typescript.js:19568:27)
    at checkPropertyAccessExpressionOrQualifiedName (/node_modules/typescript/lib/typescript.js:74722:34)
    at checkPropertyAccessExpression (/node_modules/typescript/lib/typescript.js:74514:17)
    at checkExpressionWorker (/node_modules/typescript/lib/typescript.js:79945:28)
    at checkExpression (/node_modules/typescript/lib/typescript.js:79860:38)
    at checkParenthesizedExpression (/node_modules/typescript/lib/typescript.js:79895:20)
    at checkExpressionWorker (/node_modules/typescript/lib/typescript.js:79960:28)
    at checkExpression (/node_modules/typescript/lib/typescript.js:79860:38)
    at checkParenthesizedExpression (/node_modules/typescript/lib/typescript.js:79895:20)
    at checkExpressionWorker (/node_modules/typescript/lib/typescript.js:79960:28)

The trace is generally different each time, but usually in checkExpressionWorker somewhere. Unfortunately this is hardcoded to 10 calls in the trace. Sometimes the traces just have a lot of getTypeAtFlowNode without much additional context.

This is a large, proprietary application, so unfortunately I can't provide a repro. The project has a number of the "advanced" type checking bits enabled (and one disabled):

    "strict": true,
    "strictPropertyInitialization": false,
    "noImplicitAny": true,
    "noImplicitReturns": true,
    "noImplicitThis": true,
    "noFallthroughCasesInSwitch": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "strictNullChecks": true,

I'm happy to apply any local patches to improve the ability to pinpoint the bit of code it's unhappy with, but I'm entirely unfamiliar with the codebase, so some hints could be useful. Also let me know if any additional info would be useful.

Node version v14.19.3, in case it matters.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs More InfoThe issue still hasn't been fully clarified

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions