Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run TypeScript for validation without generating js files?

Tags:

typescript

I'm using TypeScript v2.0 and ts-node. I don't need js files, but I want use typescript for validation in my tests. So how can I run TypeScript for validation, without generating js files?

like image 218
galkin Avatar asked Oct 26 '16 09:10

galkin


People also ask

How do I run a TypeScript file without compiling?

npm install -g ts-node makes ts-node your-script. ts a breeze. Since the release of deno, you can now execute deno run path/to/file. ts and it will run typescript files in a single command without compiling it to a separate JS file.

Can JavaScript run TypeScript?

TypeScript is JavaScript with syntax for types. TypeScript is a strongly typed programming language that builds on JavaScript, giving you better tooling at any scale.


1 Answers

You can use the --noEmit flag.

tsc file.ts --noEmit

For validation purposes, you may also consider adding a linter compatible with TypeScript (such as ESLint with TypeScript support).

like image 71
E_net4 stands with Ukraine Avatar answered Nov 06 '22 02:11

E_net4 stands with Ukraine