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
How to load file repeatedly #472
Comments
This happens because the function is already defined in the same context. > .load a
function a() {}
{}
> function a() {}
Thrown: ⨯ Unable to compile TypeScript
[eval].ts (-1,10): Duplicate function implementation. (2393)
[eval].ts (1,10): Duplicate function implementation. (2393)
> delete a
Thrown: ⨯ Unable to compile TypeScript
[eval].ts (1,8): The operand of a delete operator must be a property reference. (2703)
> a = undefined
Thrown: ⨯ Unable to compile TypeScript
[eval].ts (1,1): Cannot assign to 'a' because it is not a variable. (2539) The REPL interface behaves the same way as a single ts file; the cache is a compile cache, and has nothing to do with what happens at runtime. |
Hmmm yeah you're right. I just thought |
How does load work in node.js with constant variables? If that works, we can try and find a way around this. The other alternative (and related to a similar issue on the REPL) is to disable a set of warnings automatically when using the REPL. |
> .load a.js
const a = 1;
undefined
> const a = 1;
SyntaxError: Identifier 'a' has already been declared
> |
@stelcheck That is standard behavior yes. But the |
Since under the hood we use Node.js' REPL library - which, itself, is used when you run the actual Of course, if you have any suggestions on how this would be implemented, I would be happy to help. |
Today, users can avoid this issue via In both the standard nodejs REPL and in ts-node,
You get a REPL session that internally looks like:
node will throw an error because the If we added magic to our REPL that invalidates previous declarations, this wouldn't be consistent with node's own REPL. I think this would also be incorrect. Plus it'd be super-complicated. I feel pretty confident saying we can't / shouldn't do either of these solutions. Closing to whittle down the list of open issues. If I'm wrong, let me know and I'll re-open. |
I've got a
foo.ts
file I'm editing and I want to.load foo.ts
in the repl. First time works fine but subsequent times compilation fails because ofDuplicate function implementation
. I thought it was a cache issue but it also happens withts-node --no-cache
. Any way to clear compilation cache?The text was updated successfully, but these errors were encountered: