Description
TypeScript Version: 2.1.5
Code
/**
* Foo bar qux
*/
var a = true;
Background: Supporting TypeScript 2.1.x in typescript-eslint-parser
I am a member of the ESLint Team working on the the typescript-eslint-parser, you may have seen issues from me before 😄 As always I am excited about enabling ESLint users to work with TypeScript!
As part of the project we are naturally exposed to breaking changes in the TypeScript AST between versions.
The only remaining issue with supporting TS 2.1.x in the parser is accommodating the changes that were made around JSDoc comments between TS 2.0.x and TS 2.1.x.
For reference: eslint/typescript-eslint-parser#128 (comment)
I cannot find any information on this change at all, despite numerous attempts. Please can you point me towards any relevant documentation if there is any?
At the AST level, I can observe that the code sample above would previously produce just a leadingComment
node in TS 2.0.x, but it now contains a new jsDoc
property and corresponding new node in TS 2.1.x.
The actual issue for the typescript-eslint-parser, however, is the fact that the behaviour of TypeScript node utility functions seems to have been affected by this change.
ast.getFirstToken()
for this code in TS 2.0.x would return a TokenObject
, but in TS 2.1.x it returns undefined
.
Is this the intended behaviour?
For the ESTree AST, we need to produce an array of all the tokens in the program, and so we iterate through them, starting with the first token, so this is currently a blocker.
As a final note, if you remove the second asterisk to turn the JSDoc comment into a standard multi-line comment, the behaviour is identical to TS 2.0.x. Perhaps this is a related issue #9975?
Many thanks in advance for your help!