-
Notifications
You must be signed in to change notification settings - Fork 18
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
Demo cli #177
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool start!
I was trying a different path before (run ts-node --eval "my code"
or ts-node --print "my code"
) but this always ends execution instead of starting a repl.
@@ -5751,6 +5751,19 @@ ts-node@^6.0.3: | |||
source-map-support "^0.5.6" | |||
yn "^2.0.0" | |||
|
|||
ts-node@^7.0.0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have "ts-node": "^6.0.3",
in the main package.json. I Think we should upgrade that instead of adding a new one
"test-node": "./jasmine-testrunner.js", | ||
"test": "yarn build-or-skip && yarn test-node", | ||
"prebuild": "yarn format && yarn lint", | ||
"build": "tsc", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is nothing to be built in this package, right?
@@ -0,0 +1,26 @@ | |||
// I tried to add these but they just broke tsc | |||
// so it seems we can add globals defined in the same module, | |||
// but if we import anything it breaks??? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you cannot change global
in a typesafe way, because it is of type NodeJS.Global
. I was able to hack in some values but could not read them from the repl anymore because it type checked global
before accessing the existing values.
I think the way to go is rather patch https://github.com/TypeStrong/ts-node/blob/master/src/bin.ts to let it consume some inital commands. That would bring them into the proper scope directly.
After thinking about this, maybe just running normal ts-node and then force the user to do something like
on the first line of the repl to load in all the features. I had no intention of merging this, feel free to push other experiments on this branch to try them out |
Experiment how to get a nice cli that can import all the typescript code, along with some initialization stuff (not as easy with ts-node as node).
I got some globals set from an import, try
yarn cli
then typefx(value)
for an exported number and exported function. However, it seems to break as soon as I import anything from that file...Working out how to handle #111