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
65
votes
14 answers

Can't find Typescript compiler: Command "tsc" is not valid

Just installed Typescript extension to VS2012 and followed Install TypeScript for Visual Studio 2012 and then the tutorial to call the compiler: > tsc greeter.ts But when i try to compile .ts file where should i type: tsc greeter.ts? Tried it in VS…
0x49D1
  • 8,505
  • 11
  • 76
  • 127
47
votes
6 answers

How can I pass multiple source files to the TypeScript compiler?

TypeScript is designed for large-scale JavaScripty projects which typically consist of multiple internally produced files along with externally produced libraries. How does the TypeScript compiler (tsc) expect you to provide it with the complete set…
CCoder
  • 676
  • 1
  • 5
  • 8
45
votes
5 answers

How to get tsc to Resolve Absolute Paths when Importing Modules using baseUrl?

Consider a simple typescript project with the following directory structure: | package.json | tsconfig.json | \---src | app.ts | \---foobar Foo.ts Bar.ts tsconfig.json has been configured…
Zsw
  • 3,920
  • 4
  • 29
  • 43
44
votes
15 answers

This is not the tsc command you are looking for

When I run tsc in the terminal (it does not matter where) I get returned: $ npx tsc --version This is not the tsc command you are looking for To get access to the TypeScript compiler, tsc, from the command line either: - Use npm…
Björn Hjorth
  • 2,459
  • 5
  • 25
  • 31
38
votes
4 answers

tsc not excluding node_modules

{ "compilerOptions": { "target": "es5", "module": "commonjs", "moduleResolution": "node", "sourceMap": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "removeComments": false, "noImplicitAny":…
Alex Kibler
  • 4,674
  • 9
  • 44
  • 74
37
votes
2 answers

TypeScript: compiling removes unreferenced imports

In our project we're using RequireJS as our module loader. Some of our modules will influence global libraries, and hence won't be directly used within the module they are referenced…
thomaux
  • 19,133
  • 10
  • 76
  • 103
36
votes
3 answers

Declare dynamically added class properties in TypeScript

I want to assign properties to the instance of a class without knowing the property names, values and types of values in TypeScript. Lets assume we have the following example.ts script: // This could be a server response and could look totally…
headacheCoder
  • 4,503
  • 8
  • 30
  • 33
35
votes
5 answers

tsc - doesn't compile alias paths

I have typescript and uses the aliases. Here is part of tsconfig.json "compilerOptions": { "baseUrl": "./src", ... }, By setting the base url, I can change import User from "src/models/User.model.ts" to import User from…
ahadortiz
  • 916
  • 1
  • 9
  • 20
35
votes
3 answers

Mute/ignore TS2307 error from TypeScript tsc

Is there a way to mute the TS2307 error from the TypeScript tsc compiler? It makes it really hard to spot real/new errors and warnings as there are many TS2307 errors in our codebase. Update: This error occurs when an external module is imported…
P Varga
  • 19,174
  • 12
  • 70
  • 108
30
votes
3 answers

Type for non-false, aka truthy

In TypeScript, is there a type for truthy? I have this method: Object.keys(lck.lockholders).length; enqueue(k: any, obj?: any): void think with TS there is a way to check for empty strings '', by the way. and I want to convert it to: enqueue(k:…
user7898461
29
votes
4 answers

What are the proper typescript types for addEventListener mousemove and it's event argument?

Question: Without using any, What is the proper typing for my onMouseMove function? export class Main { private dTimer: number; constructor() { this.init(); } private init() { this.mouseHandlers(); } private mouseHandlers() { …
Armeen Moon
  • 18,061
  • 35
  • 120
  • 233
29
votes
6 answers

Typescript build getting errors from node_modules folder

I am running a typescript build and getting errors in node_modules. Why isn't it ignoring this folder? I have it in the exclude section of my tsconfig.json. The really strange thing is that I have another project that I have done a file…
Ryan Langton
  • 6,294
  • 15
  • 53
  • 103
28
votes
2 answers

How to resolve 'Assertions require every name in the call target to be declared with an explicit type annotation.ts(2775)'?

I have the JavaScript code below, and I'm using the TypeScript Compiler (TSC) to provide type-checking as per the Typescript Docs JSDoc Reference. const assert = require('assert'); const mocha = require('mocha'); mocha.describe('Array', () => { …
derekbaker783
  • 8,109
  • 4
  • 36
  • 50
28
votes
4 answers

typescript compiler (tsc) command not working with tsconfig

I installed typescript globally ( npm install typescript -g ) Then created a folder, ran npm --init, then npm intall typescript --save-dev - it installed typescript@2.1.4 In the folder , I create 'helloworld.ts` var msg = 'Hello World'; console.log…
bnsaa
  • 283
  • 1
  • 3
  • 5
26
votes
1 answer

Typescript "error TS2532: Object is possibly 'undefined'" even after undefined check

I'm trying to use the --strict option on tsc but I ran into the following "weird" case that I don't seem to understand. If I write: function testStrict(input: {query?: {[prop: string]: string}}) { if (input.query) { …
Marco
  • 363
  • 1
  • 4
  • 8
1
2
3
61 62