-
-
Notifications
You must be signed in to change notification settings - Fork 534
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
noUnusedLocals causes problems working in repl #850
Comments
I was able to run |
There's also the existing |
Become affected by this issue too, couldn't understand why |
@blakeembrey it's been a year. I haven't used the REPL in a while but assuming this is still an issue, would a) be possible and b) make sense, to have |
To consider this feature, we'll need to receive a pull request with tests. The creation of a PR will lock down the behavior -- how it interacts with all the other ways we load options -- and enable a proper review. @thw0rted You say you haven't used the REPL in a while, so you're not sure if this is still a problem. Does this mean that, if we implemented a change, it would not affect you at all? This affects how we prioritize tickets. For people who use the REPL. what do they use it for? I never use it. I wrote code in an editor, taking advantage of TypeScript's excellent tooling. So it's difficult for me to understand the value of the REPL to other users. |
I use REPL to check how some functions work, because ts/js usually has no documentation, typings are frequently not precise enough (if exist at all), and to explore behavior in corner cases, like what function return on invalid input (will it throw exception, return null/undefined or some sentinel value). TS/JS ecosystem just have so bad infrastructure (docs, typings, code explorability), that you either try code in REPL or go to sources |
What benefits do you get from the ts-node REPL as opposed to the node REPL? If you are trying third-party code, it should not need compilation. If the issue is inaccurate declarations, I assume you would want typechecking turned off. When I don't need typechecking or compilation, I use the node REPL directly. When I want typechecking, I write a temp file in my editor and run it with |
Yes, this feature would have little impact on me personally, this was more of a sideline commentary. I used the REPL somewhat often, off and on, for a project I haven't needed in a while. At the time, the use case was that I had written a service that stored its state in a flat-file database. Using the REPL, I could I will probably need it again at some point, but as I say, for now I can use a workaround, either with the option override when launching |
As a casual visitor of the node universe, I am not familiar with the differences between javascript and typescript. Because of that, it is easier for me if my REPL experience matches code written in |
... or copy and paste lines from the REPL into my TS file (as I would do with test cases, for instance). Even as an everyday visitor of the node universe, I second this. A few reasons:
Bottom line, as someone who came originally from the Python world, I see the REPL as an integral part of both learning a language and developing in it day to day, and the fact that I can't just import stuff without extra flags/workarounds/etc is something I'd love to see fixed. Thanks! |
For anybody just coming to this now, here's a very simple workaround you can use unless/until somebody decides to implement the suggestion I made a while back: // Save as tsconfig.repl.json.
// Run `TS_NODE_PROJECT=tsconfig.repl.json npm exec ts-node`
{
"extends": "./tsconfig.base.json", // Assumes you have a "base" tsconfig
"compilerOptions": {
"strict": false, // Strict mode in REPL is not helpful
"strictNullChecks": false,
"noUnusedLocals": false, // ts-node issue #850
}
} You could also make a script entry in your |
When ts-node is launched in console mode the
noUnusedLocals
option causes problems and makes the console hard to use:Can we ignore this compiler option when running in console mode or find any other workaround?
The text was updated successfully, but these errors were encountered: