6

I’m writing an app in typescript to compile to adobe extendscript (an es3-based javascript syntax).

I am trying to use the extendscript-only syntax

#include "path_to_file";

which is not valid typescript (and not even valid javascript). I would like to tell typescript to just include it as-is, without parsing it.

I know about @ts-ignore, and @ts-except-error, but though these prevent typescript from throwing an error, they don’t prevent it from messing the line while transpiling it. In the end the output line is :

#include;

which kinds of defeats the purpose.

Is it possible to tell typescript not to parse next line and to just include it as-is in javascript code ?

(otherwise I’m going to have to resort to some dark Makefile / cat magic)

tbrugere
  • 755
  • 7
  • 17

2 Answers2

3

You can achieve what you're looking for by using the alternative extendscript-directive syntax that uses //@ instead of #. The fact it's effectively a comment means typescript will ignore it, but extendscript still sees it.

So change your:

#include "path_to_file";

to be:

//@include "path_to_file";
ryecroft
  • 352
  • 2
  • 9
  • Thank you ! Though it doesn't really answer the question (how to include a line verbatim), it does solve my problem, so I'll accept your answer. For the record, iirc I had it solved by using this https://github.com/yellcorp/extendscript-commonjs , and telling typescript to transpile imports to commonjs, so I could just use the native typescript `import` syntax – tbrugere May 17 '21 at 07:58
  • (and the toplevel include of extendscript-commonjs was done in a pure jsx file) – tbrugere May 17 '21 at 08:00
0

Solves the problem without answering the question

const root = File($.fileName).parent
const file = new File(`${root}/../polyFill/index.jsx`);
$.evalFile(file);
mindlid
  • 1,679
  • 14
  • 17