Questions tagged [tsc]

tsc is a compiler for converting TypeScript into plain JavaScript.

tsc is a compiler for converting TypeScript into plain JavaScript targeting either the ECMAScript 3 or ECMAScript 5 specifications.

927 questions
278
votes
12 answers

How to force tsc to ignore node_modules folder?

I'm using tsc build tasks. Unfortunately I'm always getting the same errors from the node modules folder Executing task: .\node_modules\.bin\tsc.cmd --watch -p .\tsconfig.json < node_modules/@types/node/index.d.ts(6208,55): error TS2304: Cannot find…
Daniel Santos
  • 14,328
  • 21
  • 91
  • 174
253
votes
28 answers

'tsc command not found' in compiling typescript

I want to install typescript, so I used the following command: npm install -g typescript and test tsc --version, but it just show 'tsc command not found'. I have tried many ways as suggested in stackoverflow, github and other sites. but it doesn't…
Aung Thet
  • 3,051
  • 3
  • 13
  • 18
222
votes
10 answers

How do you produce a .d.ts "typings" definition file from an existing JavaScript library?

I'm using a lot of libraries both my own and 3rd party. I see the "typings" directory contains some for Jquery and WinRT... but how are they created?
Hotrodmonkey
  • 2,924
  • 3
  • 20
  • 25
197
votes
9 answers

How can I get the Typescript compiler to output the compiled js to a different directory?

I'm fairly new to TypeScript, and right now I have .ts files in several places throughought my project structure: app/ |-scripts/ |-app.ts | |-classes/ | |-classA.ts | |-classB.ts | |-controllers/ | …
TheGuyWithTheFace
  • 2,615
  • 3
  • 13
  • 16
157
votes
3 answers

Typescript primitive types: any difference between the types "number" and "Number" (is TSC case-insensitive)?

I meant to write a parameter of type number, but I misspelled the type, writing Number instead. On my IDE (JetBrains WebStorm) the type Number is written with the same color that is used for the primitive type number, while if I write a name of a…
Cesco
  • 3,770
  • 7
  • 24
  • 26
130
votes
12 answers

How to find module "fs" in VS Code with TypeScript?

I'm running on a MacBook Air. I installed VS Code as an IDE and also have TypeScript installed. I have a simple file with just this line: import fs = require('fs'); I'm getting a red squiggly under the 'fs' inside the parenthesis and the error…
Brick
  • 3,998
  • 8
  • 27
  • 47
124
votes
5 answers

How to consume npm modules from typescript?

I'm giving a shot at typescript. It works fine at the hello world stage. I'm now trying to use a npm module : index.ts = import _ = require('lodash') console.log(_.toUpper('Hello, world !')) This doesn't work : tsc index.ts -> Cannot find module…
Offirmo
  • 18,962
  • 12
  • 76
  • 97
112
votes
11 answers

Is there a way to use npm scripts to run tsc -watch && nodemon --watch?

I'm looking for a way to use npm scripts to run tsc --watch && nodemon --watch at the same time. I can run these commands independently, but when I want run both of them, only the first one is executed. eg: "scripts": { "runDeb": "set…
Nicolas Dominguez
  • 1,243
  • 2
  • 10
  • 10
111
votes
8 answers

typescript outDir setting in tsconfig.json not working

I can't seem to get the outDir flag working when used in package.json. Directory structure is pretty simple: tsconfig.json at the root level, together with a src/ directory and a single index.ts file plus other directories representing other…
aryzing
  • 4,982
  • 7
  • 39
  • 42
110
votes
9 answers

Maintain src/ folder structure when building to dist/ folder with TypeScript 3

I have a TypeScript nodejs server with this structure: tsconfig.json package.json src/ middleware/ utils/ index.ts dist/ middleware/ utils/ index.js When using TypeScript 2, I was able to transpile my project from the src/…
nfadili
  • 1,232
  • 2
  • 8
  • 9
94
votes
15 answers

Cannot find module that is defined in tsconfig `paths`

I am trying to setup aliases for my mock server. Whenever I try to compile ts files, it returns error that it couldn't find proper modules even though those are defined in tsconfig,json->paths Folder structure: ├── server │   └── src │   …
Jamil Alisgenderov
  • 1,448
  • 2
  • 12
  • 23
83
votes
2 answers

What's the difference between tsc (TypeScript compiler) and ts-node?

I'm very confused about the difference between tsc and ts-node. I'm learning TypeScript and I usually transpile server .ts files with tsc command. Now, I'm approaching nestjs framework, and I see that it uses ts-node. So what's the difference…
gremo
  • 47,186
  • 75
  • 257
  • 421
78
votes
4 answers

error TS6059: File is not under 'rootDir' .. 'rootDir' is expected to contain all source files

I am getting this fairly non-sensical tsc transpilation error: error TS6059: File '/Users/alex/codes/interos/teros-cli/src/logging.ts' is not under 'rootDir' '/Users/alex/codes/teros/notifier-server/src'. 'rootDir' is expected to contain all…
user11810894
74
votes
3 answers

'Cannot redeclare block-scoped variable' in unrelated files

There is a simple TS package that is used as CommonJS modules and has no exports. TS files are compiled to JS files with the same name and used as require('package/option-foo'). tsconfig.json: { "compilerOptions": { "target": "es5" …
Estus Flask
  • 206,104
  • 70
  • 425
  • 565
67
votes
2 answers

Typescript noEmit use case

What is the use case for noEmit in Typescript? I'm interested because I want to see if I can use this for development where I'll compile and run the compiled code without outputting them onto the file system which would be more efficient. Edit:…
hwkd
  • 2,411
  • 3
  • 18
  • 27
1
2 3
61 62