Skip to content

Crash in getJSDocTags with typescript 2.9.2 #26253

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
marvec opened this issue Aug 7, 2018 · 7 comments
Closed

Crash in getJSDocTags with typescript 2.9.2 #26253

marvec opened this issue Aug 7, 2018 · 7 comments
Labels
Duplicate An existing issue was already created

Comments

@marvec
Copy link

marvec commented Aug 7, 2018

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

@ghost
Copy link

ghost commented Aug 7, 2018

May be a duplicate of #25067 -- please test with typescript@next.

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Aug 7, 2018
@marvec
Copy link
Author

marvec commented Aug 7, 2018

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;
};

@marvec
Copy link
Author

marvec commented Aug 7, 2018

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

@marvec
Copy link
Author

marvec commented Aug 7, 2018

@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?

@ghost
Copy link

ghost commented Aug 7, 2018

We're not likely to backport that change to ts2.9 at this point. What dependencies are incomatible with ts3.0?

@marvec
Copy link
Author

marvec commented Aug 7, 2018

@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;

@typescript-bot
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants