Comments (8)
You're definitely correct and I was thinking about this after you logged it. We need to load all the files by default, since there could be type information in the files array. However, it should be possible to filter those to only .d.ts
files for the initial load. Interestingly, this is actually going to be an issue with all current tooling - including Webpack loaders, Browserify plugins, etc. that don't implement this.
Awesome point 👍 Do you have any thoughts on filtering the results for only .d.ts
to start?
from ts-node.
I don't have enough background here to understand why it's necessary? I imagined that ts-node
is a pretty thin shell on top of TypeScript.
from ts-node.
For interested parties: I'm using the TypeScript language services which requires entry points and definition files on load (E.g. to declare modules, etc). However, since this isn't tsc
and we have the entry points, we only need the definition files known upfront.
I'll be implementing a patch for this tonight in any case, but if someone has a better approach please chime in 😄 Otherwise I'll be implementing a flag in tsconfig
for definition files only. Then I'll keep the same code about (but I need to switch to using ts.getPreEmitDiagnostics
). It may be possible to switch to using a program instance, but the REPL relies on a lot of the language service specifics to function.
The issue from #13 was that when noEmitOnError
is enabled, you won't get any diagnostics unless you explicitly check for them. There's a code path that just emits skipped. Anyway, that's a brain dump for anyone listening - I'll patch this tonight.
from ts-node.
Thanks for the explanation! Is it possible to separate how REPL and /register
work and would that make /register
lighter?
from ts-node.
Most of the code would end up identical in either case, so it's not a huge change. I'd be able to wrap either API internally depending on whether we're using the REPL interface too. It is probably lighter, just how much I haven't tested.
@basarat Do you have any idea how much lighter using only the program interface over the language services would be?
@alexgorbatchev There's a lot of other things to consider with a change like that. For example, when someone invalids the node require cache this would require restarting a new program instance which would be much slower and would result in potentially different state/errors. These are all probably reasonable trade-offs though, but I'd love to solve it better, not just differently.
from ts-node.
Do you have any idea how much lighter using only the program interface over the language services would be?
Not a significant difference at all. Language Service is mostly a program
snapshotting tool (so it just passes it down to program if code doesn't change). In fact most calls to Language service are like syncHostData
-> getProgram
-> call function on program
. Hope that helps 🌹
from ts-node.
Released with v0.4.0
. Please let me know how well it works for you 👍 I'm opening anew issues for the program replacement.
from ts-node.
very cool, thank you very much!
from ts-node.
Related Issues (20)
- console.log('hi'); fails in REPL with "module": "esnext" HOT 1
- UnhandledPromiseRejection: ts-node-esm does not display type checking results HOT 6
- ts-node doesn't run ESM modules as expected, either refusing`import` statements in ts file or not being able to run `.ts` files HOT 6
- In REPL, can't access the previous line's return value via `_`
- Error when using ts-node with tsonfig/bases and typescript 5.3.2 HOT 3
- "TypeError: require(...) is not a function" in ts-node dependecy
- extends of tsconfig.json doesn't work when it reference to other package HOT 2
- add --env-file environment variable similar to node v:20.6.0 HOT 9
- ERR_UNKNOWN_FILE_EXTENSION since Node.js 18.19.0 (works fine with 18.18.2) HOT 17
- Support clearing the local context with .clear when starting programmatically
- In #!/bin/bash clear apt update apt upgrade apt install figlet -y figlet Basic Installation apt install toilet -y apt install cowsay -y apt install nano -y apt install ruby -y gem install lolcat figlet -f big Done !!! | lolcat echo echo -e "\e[1m Now Run \e[32mbash t-ban.sh\e[0m...!!!" echo echo -e "\e[1m\e[32m Developed by :\e[33m Sutariya Parixit (8h4i)" echo echo( there are Issu for In title The Over view and synonyms Not Seen in his real formet
- ts-node is unable to resolve tsconfig files in Yarn workspace HOT 2
- ESM: Cannot find module './index.js' and requiring "imaginaryUncacheableRequireResolveScript" HOT 1
- TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" in Node v21.5.0 HOT 36
- "Cannot find package" when running mocha and importing between packages in monorepo HOT 1
- Can't use `--eval` with ESM
- calling `repl.start()` causes a doubling of stdin/stdout
- ts-node cannot run mixed ESM/CJS project HOT 2
- Cryptic error on invalid tsconfig.json, e.g. if attempting to extend nonexistent tsconfig file
- ts-node doesn't resolve extended tsconfigs if they originate from the export fields of packages
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ts-node.