question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: Cannot read property 'kind' of undefined at getErrorSpanForNode

See original GitHub issue

There’s a PR open for this one.

Under some set of rituals and incantations I have not been able to replicate, tsc throws the following error:

image

There’s been several bugs open - and fixed - around this.

I could not replicate, it was easier to fix. The fix addresses a simple logical inconsistency where a safety check happened after it was necessary.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
threecommented, Oct 15, 2020

After some more testing typescript@next seems to handle the above case correctly,

$ ./node_modules/.bin/tsc --version
Version 4.1.0-dev.20201015
$ ./node_modules/.bin/tsc
test.js:1:1 - error TS8006: 'import type' declarations can only be used in TypeScript files.

1 import type { x } from 'y'
  ~~~~~~~~~~~~~~~~~~~~~~~~~~

Found 1 error.
0reactions
threecommented, Oct 15, 2020

I believe I’m having the same issue as you having to do with legacy flow types tripping up the compiler. Typescript seems to be tripping up on import type statements if they appear in js files. Not sure if the pr already fixed this but here’s a more contained test case if the Needs more Info tag still applies.

$ ./node_modules/.bin/tsc --version
Version 4.0.3

$ ./node_modules/.bin/tsc
/Users/eric/tmp/tserror/node_modules/typescript/lib/tsc.js:84774
                throw e;
                ^

TypeError: Cannot read property 'kind' of undefined
    at getErrorSpanForNode (/Users/eric/tmp/tserror/node_modules/typescript/lib/tsc.js:10173:22)
    at Object.createDiagnosticForNodeInSourceFile (/Users/eric/tmp/tserror/node_modules/typescript/lib/tsc.js:10124:20)
    at createDiagnosticForNode (/Users/eric/tmp/tserror/node_modules/typescript/lib/tsc.js:85010:31)
    at walk (/Users/eric/tmp/tserror/node_modules/typescript/lib/tsc.js:84876:50)
    at visitAllPossibleChildren (/Users/eric/tmp/tserror/node_modules/typescript/lib/tsc.js:22063:31)
    at Object.forEachChildRecursively (/Users/eric/tmp/tserror/node_modules/typescript/lib/tsc.js:22024:23)
    at /Users/eric/tmp/tserror/node_modules/typescript/lib/tsc.js:84849:20
    at runWithCancellationToken (/Users/eric/tmp/tserror/node_modules/typescript/lib/tsc.js:84767:24)
    at getJSSyntacticDiagnosticsForFile (/Users/eric/tmp/tserror/node_modules/typescript/lib/tsc.js:84846:20)
    at getSyntacticDiagnosticsForFile (/Users/eric/tmp/tserror/node_modules/typescript/lib/tsc.js:84759:65)

tsconfig.json

{
    "compilerOptions": {
        "noEmit": true,
        "allowJs": true
    },

    "include": ["test.js"]
}

test.js

import type { x } from 'y'
Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: Cannot read property 'kind' of undefined at ...
This problem started to occur when updating my Angular 6 project to 7.x. I opened an issue on the angular-cli github repo but...
Read more >
react-redux-typescript-guide/Lobby - Gitter
「atl」: Child process failed to process the request: TypeError: Cannot read property 'kind' of undefined at getErrorSpanForNode ...
Read more >
Toolips ng build –prod error - Material Design for Bootstrap
when I was trying to build production of my project we got this error: in Error: TypeError: Cannot read property 'kind' of undefined...
Read more >
TypeError: Cannot read property 'kind' of undefined at ... - Dirask
I have got following error during my TypeScript project compilation into single file: I run my project with: tsconfig.prod.json file looks following way:...
Read more >
Cannot Read Property 'Type' Of Undefined Angular 9 - ADocLib
BUILD ERROR Cannot read property 'type' of null TypeError: Cannot read property 'type' of Describe what the desired behavior would be. -->. Provide...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found