Skip to content
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

undefined error in isPropertyAccessExpression #27032

Closed
ivogabe opened this issue Sep 11, 2018 · 18 comments
Closed

undefined error in isPropertyAccessExpression #27032

ivogabe opened this issue Sep 11, 2018 · 18 comments
Assignees
Labels
Bug A bug in TypeScript High Priority

Comments

@ivogabe
Copy link
Contributor

ivogabe commented Sep 11, 2018

TypeScript Version: 3.1.0-dev.20180907
(3.0.3 works fine)

Search Terms:
isPropertyAccessExpression undefined kind

Code
I couldn't replicate this in a small example. The bug can be reproduced with the following steps:

Expected behavior:
Compilation succeeds without errors

Actual behavior:

[..]/node_modules/typescript/lib/tsc.js:68651
                throw e;
                ^

TypeError: Cannot read property 'kind' of undefined
    at Object.isPropertyAccessExpression ([..]/node_modules/typescript/lib/tsc.js:9975:20)
    at [..]/node_modules/typescript/lib/tsc.js:46202:91
    at Object.forEachEntry ([..]/node_modules/typescript/lib/tsc.js:5689:26)
    at Object.isJSContainerFunctionDeclaration ([..]/node_modules/typescript/lib/tsc.js:46202:25)
    at transformTopLevelDeclaration ([..]/node_modules/typescript/lib/tsc.js:63058:43)
    at visitDeclarationStatements ([..]/node_modules/typescript/lib/tsc.js:63020:26)
    at Object.visitNodes ([..]/node_modules/typescript/lib/tsc.js:51643:48)
    at transformRoot ([..]/node_modules/typescript/lib/tsc.js:62524:33)
    at [..]/node_modules/typescript/lib/tsc.js:1203:42
    at transformRoot ([..]/node_modules/typescript/lib/tsc.js:63498:82)

Related Issues:
#26964
#26978
#26832

@sandersn
Copy link
Member

sandersn commented Sep 12, 2018

Probably due to expando functions, because I think the only thing in lib/ is .ts files.

Edit: That is, it's not likely related to the 3 linked issues, but is related to a few already-closed issues.

@sandersn
Copy link
Member

sandersn commented Sep 12, 2018

isExpandoFunctionDeclaration assumes that all exports are values, which have valueDeclarations. But namespaces can export types, which do not. Here's a short repro:

// @declaration: true
function compile(): void { }
namespace compile {
    export interface Settings { }
}

I have a fix and as soon as I add a test, I'll send out a PR.

@ivogabe
Copy link
Contributor Author

ivogabe commented Sep 12, 2018

Thanks for the quick fix! I'll test the next nightly

@blink1073
Copy link

@sandersn, I am still seeing this behavior with ~3.1.0-dev.20180922

@blink1073
Copy link

Repro:

git clone https://github.com/blink1073/jupyterlab --branch use-ts-31
cd jupyterlab
yarn
yarn build:packages

@blink1073
Copy link

I tried @ivogabe's repro with ~3.1.0-dev.20180922 and that now builds fine.

@sandersn
Copy link
Member

@blink1073 I’ll try your repro when I’m at my desk. Unless your stack trace is identical, then it’s likely a different issue.

@blink1073
Copy link

I'm afk, but my stack trace was identical, and was what led me to this issue.

@sandersn
Copy link
Member

Hmm. I just tried the repro and it doesn't happen with builds from Friday (9/21) or today (9/24) or 3.1.0-dev.20180922.

Note that I couldn't get yarn build:packages to work because of its dependency on jlpm, which seems just to be a custom-wrapped yarn (?). So I followed the tasks in package.json and it looks like build:packages just calls tsc -b src inside packages/metapackage. If that's not right, let me know.

@blink1073
Copy link

Thanks for checking! That sounds right as far as procedure. I'll try again when I get back.

@blink1073
Copy link

Hmm, this is still happening for me with "typescript": "~3.1.0-dev.20180925":

$ ./node_modules/.bin/tsc -b src
/Users/ssilvester/workspace/jupyter/lab/node_modules/typescript/lib/tsc.js:69059
                throw e;
                ^

TypeError: Cannot read property 'kind' of undefined
    at Object.isPropertyAccessExpression (/Users/ssilvester/workspace/jupyter/lab/node_modules/typescript/lib/tsc.js:10282:20)
    at /Users/ssilvester/workspace/jupyter/lab/node_modules/typescript/lib/tsc.js:46606:91
    at Object.forEachEntry (/Users/ssilvester/workspace/jupyter/lab/node_modules/typescript/lib/tsc.js:5976:26)
    at Object.isJSContainerFunctionDeclaration (/Users/ssilvester/workspace/jupyter/lab/node_modules/typescript/lib/tsc.js:46606:25)
    at transformTopLevelDeclaration (/Users/ssilvester/workspace/jupyter/lab/node_modules/typescript/lib/tsc.js:63465:43)
    at visitDeclarationStatements (/Users/ssilvester/workspace/jupyter/lab/node_modules/typescript/lib/tsc.js:63427:26)
    at Object.visitNodes (/Users/ssilvester/workspace/jupyter/lab/node_modules/typescript/lib/tsc.js:52047:48)
    at transformRoot (/Users/ssilvester/workspace/jupyter/lab/node_modules/typescript/lib/tsc.js:62928:33)
    at /Users/ssilvester/workspace/jupyter/lab/node_modules/typescript/lib/tsc.js:1204:42
    at transformRoot (/Users/ssilvester/workspace/jupyter/lab/node_modules/typescript/lib/tsc.js:63905:82)

@blink1073
Copy link

False alarm, I ran git clean -dfx and tried again, and all is well. Thanks again!

@blink1073
Copy link

blink1073 commented Sep 25, 2018

No, something is definitely not right. It is still failing on CI: https://travis-ci.org/blink1073/jupyterlab/jobs/432833170#L638.

git clone https://github.com/blink1073/jupyterlab --branch use-ts-31
cd jupyterlab/packages/metapackage
yarn
yarn build
$ ./node_modules/.bin/tsc -b src
/Users/ssilvester/temp/jupyterlab/node_modules/typescript/lib/tsc.js:69059
                throw e;
                ^

TypeError: Cannot read property 'kind' of undefined
    at Object.isPropertyAccessExpression (/Users/ssilvester/temp/jupyterlab/node_modules/typescript/lib/tsc.js:10282:20)
    at /Users/ssilvester/temp/jupyterlab/node_modules/typescript/lib/tsc.js:46606:91
    at Object.forEachEntry (/Users/ssilvester/temp/jupyterlab/node_modules/typescript/lib/tsc.js:5976:26)
    at Object.isJSContainerFunctionDeclaration (/Users/ssilvester/temp/jupyterlab/node_modules/typescript/lib/tsc.js:46606:25)
    at transformTopLevelDeclaration (/Users/ssilvester/temp/jupyterlab/node_modules/typescript/lib/tsc.js:63465:43)
    at visitDeclarationStatements (/Users/ssilvester/temp/jupyterlab/node_modules/typescript/lib/tsc.js:63427:26)
    at Object.visitNodes (/Users/ssilvester/temp/jupyterlab/node_modules/typescript/lib/tsc.js:52047:48)
    at transformRoot (/Users/ssilvester/temp/jupyterlab/node_modules/typescript/lib/tsc.js:62928:33)
    at /Users/ssilvester/temp/jupyterlab/node_modules/typescript/lib/tsc.js:1204:42
    at transformRoot (/Users/ssilvester/temp/jupyterlab/node_modules/typescript/lib/tsc.js:63905:82)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@blink1073
Copy link

$ cat package.json | grep typescript
    "typescript": "~3.1.0-dev.20180925"

@blink1073
Copy link

If I change the tsc code to return node && node.kind === 187;, it builds fine.

@blink1073
Copy link

Interestingly, if I replace tsc.js with the one in the release-3.1 branch, it builds. If I still see the error with the final 3.1 release I'll open a new issue.

@jasongrout
Copy link

3.1 final is released now

@blink1073
Copy link

Works now locally and on CI! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript High Priority
Projects
None yet
Development

No branches or pull requests

5 participants