Short for TypeScript Node. Built to execute TypeScript for Node.js. You might also include TypeScript and/or Node.js - tags if you use this tag.
Questions tagged [ts-node]
487 questions
-1
votes
2 answers
What is the signature of express middlewares using typescript?
I have been learning and working with typescript. I am just curious to find out the correct signatures of express middlewares.
I have been defining middlewares as:
const middleware = async(req: Request, res: Response, next: NextFunction) => {
//…

Saurav Ghimire
- 500
- 2
- 9
-1
votes
1 answer
When using ts-node, how to manipulate Typescript AST at runtime and execute it?
Im executing a ts file with:
npx ts-node ./tinker.ts
The file reads and parses the AST of another file sample.ts containing a single line:
console.log(123)
Next it should execute that code, but manipulate it before doing so - for example I want to…

ajthinking
- 3,386
- 8
- 45
- 75
-1
votes
2 answers
TypeScript - type cast not returning falsey value as expected
I would like the casting of a string at runtime to return a falsey value if the type is mismatched. Namely, when I run the following with ts-node@10.7.0, I encounter unexpected results:
$ ts-node
> 0 as 'B' | 'C' | 'D' || 'foo' // ✅ throws…

rolling_codes
- 15,174
- 22
- 76
- 112
-1
votes
1 answer
How to run "TS" code snippets in ts-node?
In Solana docs they use a lot of TS code snippets, for example in the below link (the first code snippet) should run and return a value:
https://solanacookbook.com/guides/get-program-accounts.html#filters
I tried to run the first snippet using:…

Web Three
- 3
- 1
-1
votes
2 answers
Why for..in do not work when I run script with ts-node?
Here's ./src/repro.ts
class P {
do() { console.log('d'); }
}
const x = new P();
console.log('for in:');
for (const key in x) {
console.log(key);
}
I'm compiling it using this ./tsconfig.json (also tried without config at all, or with…

astef
- 8,575
- 4
- 56
- 95
-1
votes
1 answer
ts-node - how can I configure input/source file location?
I have TypeScript and ts-node installed globally and have the following files/directories -
+tsproject
+src
-main.ts
-tsconfig.json
I can compile the main.ts file with tsc src/main.ts command or execute it directly with ts-node…

atiyar
- 7,762
- 6
- 34
- 75
-2
votes
1 answer
Why wait new Promise is causeing immediate exit?
I have very simple case scenarios, where I need to wait for few seconds before doing further execution.
I tried to set timeout function separately, exporting module or function only. nothing seems to work.
module.exports.tests = async () =>…

ZAM
- 47
- 1
- 4