cevek / ttypescript

Over TypeScript tool to use custom transformers in the tsconfig.json
1.53k stars 56 forks source link

Typescript 3.8 Support #101

Closed samcooke98 closed 4 years ago

samcooke98 commented 4 years ago

I'm having issues getting a transformer working with anything from typescript version 3.8 upwards. Reading through the code I see a couple of // todo typescript 3.8 kind of comments.

My transformer looks something like;

  const visitor = (node: ts.Node): ts.Node | ts.Node[] => {
    console.log(node.kind, `\t# ts.SyntaxKind.${ts.SyntaxKind[node.kind]}`);
    return ts.visitEachChild(node, visitor, context);
  };

  ts.visitNode(sourceFile, visitor);

On Typescript 3.7, this output something like:

/Users/samcooke/work/misc/test/node_modules/.bin/ttsc
288     # ts.SyntaxKind.SourceFile
253     # ts.SyntaxKind.ImportDeclaration
254     # ts.SyntaxKind.ImportClause
[  ...more

On Typescript 3.8, this outputs

$ /Users/samcooke/work/misc/test/node_modules/.bin/ttsc
290     # ts.SyntaxKind.UnparsedSource
undefined

I'd be willing to work on this, maybe with some pointers.

samcooke98 commented 4 years ago

It seems this issue was caused by having multiple versions of typescript in the repo.

I solved this by adding a resolutions property to package.json.

  "resolutions": {
    "typescript": "3.8.3"
  }