Skip to content

Crash in getJSDocTags with typescript 2.9.2 #26253

Closed

Description

I saw similar issues around alredy but not this specific place. It happens when buildOptimizer and sourceMap are both true:

Module build failed: Error: Debug Failure. False expression.
    at getJSDocTags (/home/.../node_modules/typescript/lib/typescript.js:13197:22)
    at getFirstJSDocTag (/home/.../node_modules/typescript/lib/typescript.js:13205:24)
    at Object.getJSDocType (/home/.../node_modules/typescript/lib/typescript.js:13173:19)
    at getContextualSignature (/home/.../node_modules/typescript/lib/typescript.js:41002:32)
    at checkFunctionExpressionOrObjectLiteralMethod (/home/.../node_modules/typescript/lib/typescript.js:44621:43)
    at checkExpressionWorker (/home/.../node_modules/typescript/lib/typescript.js:45681:28)
    at checkExpression (/home/.../node_modules/typescript/lib/typescript.js:45609:42)
    at checkBinaryLikeExpression (/home/.../node_modules/typescript/lib/typescript.js:45155:29)
    at checkBinaryExpression (/home/.../node_modules/typescript/lib/typescript.js:45147:20)
    at checkExpressionWorker (/home/.../node_modules/typescript/lib/typescript.js:45702:28)
    at checkExpression (/home/.../node_modules/typescript/lib/typescript.js:45609:42)
    at checkExpressionCached (/home/.../node_modules/typescript/lib/typescript.js:45457:38)
    at getTypeOfExpression (/home/.../node_modules/typescript/lib/typescript.js:45577:28)
    at checkDeclarationInitializer (/home/.../node_modules/typescript/lib/typescript.js:45469:24)
    at getTypeForVariableLikeDeclaration (/home/.../node_modules/typescript/lib/typescript.js:30738:28)
    at getWidenedTypeForVariableLikeDeclaration (/home/.../node_modules/typescript/lib/typescript.js:30961:24)

I have no idea which comment in the polygon.js causes that. I am able to provide the source code. The package is plotly.js 1.39.4.

npm 6.3.0

Activity

  1. added
    Duplicate
    on Aug 7, 2018
  2. marvec commented on Aug 7, 2018

    @marvec
    Author

    This seems to be the problematic code that make typescript fail:

    /**
     * Test if a segment of a points array is bent or straight
     *
     * @param pts Array of [x, y] pairs
     * @param start the index of the proposed start of the straight section
     * @param end the index of the proposed end point
     * @param tolerance the max distance off the line connecting start and end
     *      before the line counts as bent
     * @returns boolean: true means this segment is bent, false means straight
     */
    var isBent = polygon.isSegmentBent = function isBent(pts, start, end, tolerance) {
        var startPt = pts[start],
            segment = [pts[end][0] - startPt[0], pts[end][1] - startPt[1]],
            segmentSquared = dot(segment, segment),
            segmentLen = Math.sqrt(segmentSquared),
            unitPerp = [-segment[1] / segmentLen, segment[0] / segmentLen],
            i,
            part,
            partParallel;
    
        for(i = start + 1; i < end; i++) {
            part = [pts[i][0] - startPt[0], pts[i][1] - startPt[1]];
            partParallel = dot(part, segment);
    
            if(partParallel < 0 || partParallel > segmentSquared ||
                Math.abs(dot(part, unitPerp)) > tolerance) return true;
        }
        return false;
    };
    
  3. marvec commented on Aug 7, 2018

    @marvec
    Author

    And my wild guess is that this can be the cause - #24997 and #24996

  4. marvec commented on Aug 7, 2018

    @marvec
    Author

    Andy (Andrewkraft) (@Andy-MS) Unfortunatelly, I am not able to try with typescript@next easily. Our project has a lot of dependencies that are incompatible with typescript>2.10. I spent half an hour trying to make it it work but without luck. Is there just a change/patch I can introduce in typescript to verify it?

  5. marvec commented on Aug 7, 2018

    @marvec
    Author

    Andy (Andrewkraft) (@Andy-MS) It is probably the same case as #25067 because when I split the defnition in the problematic file like the following, it went fine:

    polygon.isSegmentBent = function isBent( ....
    ...
    var isBent = polygon.isSegmentBent;
    
  6. typescript-bot commented on Dec 15, 2018

    @typescript-bot
    Contributor

    This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

  7. 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

Assignees

No one assigned

    Labels

    Duplicate

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions