-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compile error when code contains export declaration-like string #3089
Comments
This comment has been minimized.
This comment has been minimized.
@nayeemrmn Oh, sorry. I edited the description. |
@keroxp I can take a look later, can you provide repro commands? EDIT: Nvm, running |
Interesting bug @keroxp! I looks like output from
Calling @kitsonk for help EDIT: IMHO this is a TypeScript bug - it shouldn't treat imports inside template string as an actual import in the file. @keroxp a quick workaround for now would be to replace template strings and just add strings old-school ( |
I suspect it is something with preprocess, and preprocess potentially related to how we analyse the |
Actually, thinking through it, it has to be an issue with preprocess, or with how we are using preprocess. It can't be the type directives. |
Yeah, it is a TypeScript issue with |
I glanced the implementation of ts.preProcessFile it just do something like a regular expression does, so it's quick but missing some correctness because the syntax rules is a recursive structure and not very easy being processed via a linear process. I don't know why |
Yes, correct. As far as fixing the bug, I am sure the TypeScript team would welcome the contribution. |
The first target in our case is the correctness rather than performance in their situation. Although the
Good to know that, thank you |
Actually, we introduced it to improve our performance and allow the whole of the TypeScript compiler to operate in an asynchronous fashion. There is a work around, to not use string literals that contain something that looks like an import statement. |
Another test case that doesn't involve string literals: function define(foo) {}
define(["long"]); |
@seishun please provide more information, like that actual error output and the version of Deno you are using. |
master, same error output:
|
And version of Deno? Note to self, check if preprocess analyses AMD type of structures and if there is anyway to modify that. |
As I said, master, which is 0.33.0. |
fixed in #4009 |
@ry no this only fixed part of the issue. String literal with export like statements are still awaiting a fix in TypeScript. Please re-open. |
@kitsonk, not sure if that's related, but after #4030 I tried to run
Can't really pin-point what's the problem here, but it looks a lot like something's treated as import statement while it shouldn't. |
@bartlomieju what does |
@kitsonk here's the full output: https://gist.github.com/bartlomieju/10fdab8ee91665b3f802f4b5711dc5b8 window["global"] = window
import "https://dev.jspm.io/jsdom"; The first line is added because jsdom complains that If I change the file to
|
Ok, so what is triggering it is the preprocess file, and imports. Basically we shouldn't analyse dependencies on JS modules if |
(different than this issue though) |
Landing #5029 might eliminate this bug altogether |
should eliminate, I mean it would be a full AST parse so it is unlikely to persist. |
Fixed in #5029 |
[EDITED]
Previous example has unrelated mistake but I don' know which code can reproduce error I met.
I met this error when I ran -> https://raw.githubusercontent.com/keroxp/dink/v0.5.1/main.ts
That can be compiled with [email protected]. But got error below with v0.20.0:
The text was updated successfully, but these errors were encountered: