grant / ts2gas

A function that transpiles TypeScript to Google Apps Script.

Home Page:http://npmjs.com/ts2gas

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

(minor) multiple lines import statement improperly commented out

PopGoesTheWza opened this issue · comments

This is minor but if you have a long import statement and spread it on multiple lines, only the first line gets commented out... which cause errors obviously.

Yes, this is a bug.
I'm not sure how to fix it. Maybe it would require parsing the TS.

Looking at this sample linter https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#traversing-the-ast-with-a-little-linter I will try to implement a basic parser to filter out SyntaxKind.ImportDeclaration

@grant looking at TypeScript source I ran into its TransformationAPI. It is not documented on the website nor the GitHub wiki but there are a few tests using it.
Broadly, it allows to attach to the transpiler options arrays of callback functions before and after transpiling (not relevant here but there is also an afterDeclaration which is used when emiting .d.ts)
Those callbacks can check the context (import/export declarations for example) and modify the output.
I have good hopes of using this to handle the pre and post transformations.

LMK if #9 fixes this, so we can close this issue.
Thanks!

Latest PR address the issue