Skip to content

Checker crash in isWeakType #38369

Closed

Description

Reported by Yehuda Katz (@wycats), but no repro available

TypeError: Cannot read property 'length' of undefined
    at isWeakType (/home/wycats/Code/hbs-parser/node_modules/.pnpm/registry.npmjs.org/typescript/4.0.0-dev.20200506/node_modules/typescript/lib/tsc.js:42173:48)
    at isRelatedTo (/home/wycats/Code/hbs-parser/node_modules/.pnpm/registry.npmjs.org/typescript/4.0.0-dev.20200506/node_modules/typescript/lib/tsc.js:40927:58)
    at checkTypeRelatedTo (/home/wycats/Code/hbs-parser/node_modules/.pnpm/registry.npmjs.org/typescript/4.0.0-dev.20200506/node_modules/typescript/lib/tsc.js:40657:26)
    at isTypeRelatedTo (/home/wycats/Code/hbs-parser/node_modules/.pnpm/registry.npmjs.org/typescript/4.0.0-dev.20200506/node_modules/typescript/lib/tsc.js:40621:24)
    at isTypeSubtypeOf (/home/wycats/Code/hbs-parser/node_modules/.pnpm/registry.npmjs.org/typescript/4.0.0-dev.20200506/node_modules/typescript/lib/tsc.js:39909:20)
    at getNarrowedType (/home/wycats/Code/hbs-parser/node_modules/.pnpm/registry.npmjs.org/typescript/4.0.0-dev.20200506/node_modules/typescript/lib/tsc.js:45275:24)
    at narrowTypeByTypePredicate (/home/wycats/Code/hbs-parser/node_modules/.pnpm/registry.npmjs.org/typescript/4.0.0-dev.20200506/node_modules/typescript/lib/tsc.js:45295:36)
    at getTypeAtFlowCall (/home/wycats/Code/hbs-parser/node_modules/.pnpm/registry.npmjs.org/typescript/4.0.0-dev.20200506/node_modules/typescript/lib/tsc.js:44715:61)
    at getTypeAtFlowNode (/home/wycats/Code/hbs-parser/node_modules/.pnpm/registry.npmjs.org/typescript/4.0.0-dev.20200506/node_modules/typescript/lib/tsc.js:44590:32)
    at getFlowTypeOfReference (/home/wycats/Code/hbs-parser/node_modules/.pnpm/registry.npmjs.org/typescript/4.0.0-dev.20200506/node_modules/typescript/lib/tsc.js:44550:51)

Activity

  1. DanielRosenwasser commented on May 6, 2020

    @DanielRosenwasser
    MemberAuthor

    This seems to happen because the evolving array type doesn't have any resolved properties, and we actually check that as a target type when narrowing.

    Here's the repro:

    export function unsafeCast<T>(_value: unknown): asserts _value is T { }
    
    function yadda() {
        let out = [];
    
        out.push(100)
    
        unsafeCast<any>(out);
        return out;
    }
  2. added
    BugA bug in TypeScript
    CrashFor flagging bugs which are compiler or service crashes or unclean exits, rather than bad output
    and removed
    Needs InvestigationThis issue needs a team member to investigate its status.
    on May 6, 2020
  3. locked as resolved and limited conversation to collaborators on Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugA bug in TypeScriptCrashFor flagging bugs which are compiler or service crashes or unclean exits, rather than bad outputFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions