Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

TypeScript upgrade breaks the world #15

Closed
nzakas opened this issue Feb 26, 2016 · 4 comments
Closed

TypeScript upgrade breaks the world #15

nzakas opened this issue Feb 26, 2016 · 4 comments
Labels

Comments

@nzakas
Copy link
Member

nzakas commented Feb 26, 2016

It looks like there were some changes in the TypeScript output between 1.6.x and 1.8.x that are causing identifiers to be labeled as keywords in the output. As such, most tests are failing right now.

I'm looking into this.

@nzakas nzakas added the bug label Feb 26, 2016
@nzakas
Copy link
Member Author

nzakas commented Feb 26, 2016

Ran out of energy for this. It looks like the way tokens are represented changed, so the section that translates tokens needs to be updated to account for that. Basically, this function needs to be updated:

https://github.com/eslint/typescript-eslint-parser/blob/master/lib/ast-converter.js#L278

If you run the tests now, you'll get a bunch of errors showing Keyword nodes that should be Identifier nodes.

@JamesHenry
Copy link
Member

Thanks a lot for starting this, Nicolas. I am trying to investigate a bit today in between other things.

So far I have managed to determine that this commit is the point at which TypeScript 1.7.x breaks the tests for this project: microsoft/TypeScript@85f0240

@JamesHenry
Copy link
Member

Just a guess at this point, but I think our reliance on internal SyntaxKind codes is a point of potential fragility right now. The TS authors (perhaps understandably) don't include such internal changes in release notes.

Digging into that commit above I can see that the lib/typescript.d.ts file for typescript changed here: microsoft/TypeScript@b24c3a7

And in ast-converter.js we use the codes in some checks, e.g:

if (token.kind >= 68 && token.kind <= 112) {
  return "Keyword";
}

if (token.kind >= 15 && token.kind <= 66) {
  return "Punctuator";
}

So I would assume that first check above is what is now producing Keyword node types, where it is currently expected to produce Identifier types.

@JamesHenry
Copy link
Member

Sure enough, now that I have gone through the diff on that TS commit and amended the code ranges which are checked in ast-converter.js, all the tests pass. I ran them on 1.7.3 and then on the latest release, 1.8.2, and it works on both of them.

Given this change unlocks the ability for us to start development with a working test suite on the latest version of TS, I figured it was worth submitting as a PR. If you have any thoughts as to how to mitigate the exposure to TS changing their internal codes, let me know.

Might I suggest that once that PR goes in, we start enforcing linting and tests on PRs?

@nzakas nzakas closed this as completed in #16 Mar 2, 2016
nzakas added a commit that referenced this issue Mar 2, 2016
Fix: SyntaxKind code checks, update TS peerDependency ^1.7.3 (fixes #15)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants