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
0
votes
2 answers

TypeScript error: Cannot find module 'React'

I've been trying to compile my project for several hours, I searched all over the internet, but I still don't understand why it doesn't work. I just run npx tsc but I get this error: $ npx tsc src/index.ts:2:24 - error TS2307: Cannot find module…
B. Branchard
  • 786
  • 1
  • 10
  • 21
0
votes
1 answer

Do path mappings work between different projects that are being referenced?

I am having trouble getting path mapping to work between two different typescript projects in a yarn workspace setting. I have 2 different projects in a yarn workspace. so the folder structure is as shown below. packages ├── common │   ├──…
Gary Becks
  • 27
  • 3
0
votes
1 answer

Extra files while compiling typescript code using tsc command

I created a new node development environment, installed the typescript npm module using the command.npm i --save-dev -g typescript I created a app.ts file app.ts console.log("Hello World") I tried to compile it using tsc --extendedDiagnostics…
mrbeepot
  • 3
  • 1
  • 4
0
votes
1 answer

Wrong build in dist/ folder when server imports module from external folder

I am using the microservice hybrid example from nestjs (https://github.com/nestjs/nest/tree/master/sample/03-microservices) to get familiar with the basics. It currently uses a microservice that is located inside the src folder (src/math). I want to…
M_M
  • 71
  • 2
  • 5
0
votes
1 answer

Typescript exclude not working with baseUrl

I am trying to exclude some files from my typescript compilation because my editor writes temporary files that are causing extraneous recompiles when making changes. I have in my tsconfig.json: "exclude": ["*flycheck*", "**/*flycheck*"] I am using…
sliptype
  • 2,804
  • 1
  • 15
  • 26
0
votes
1 answer

npm-run-all failing when running a "tsc-watch" command in parallel

I am trying to use npm-run-all to manage running two servers at the same time. For one of the servers, I am trying to run it in a watch mode using tsc-watch. The command looks like such: "start": "tsc-watch --onSuccess \"node…
NomCereal
  • 83
  • 1
  • 1
  • 3
0
votes
1 answer

object shorthand syntax in typescript compiler

interface o { name: string } const func = (obj: o): boolean => true // this should throw error message.(or warning message at least, but it doesn't) func({ name }) name is undefined in the code I wrote, so func({ name }) should throw an error I…
soonoo
  • 867
  • 1
  • 10
  • 35
0
votes
1 answer

Nest dependency resolution issue with tsconfig paths and barrel files/same directory imports

I've set a few different paths in tsconfig.json to make importing of controllers, entities, services, etc. easier to deal with. Relevant portion of tsconfig.json: ... "baseUrl": "./src", "paths": { "@hello/controllers": [ "./controllers" …
raychz
  • 1,085
  • 1
  • 8
  • 24
0
votes
1 answer

tsc strict mode - how to use early return to avoid "Object is possibly 'undefined'"

I have this: const lckTemp = this.locks.get(key); if (!lckTemp) { log.error('Missing lock for key:', key); return; } if (beginRead) { lckTemp.readers++ } if (endRead) { // in case something weird happens, never let it…
user11810894
0
votes
1 answer

How to get optional opts type signature to compile - TS2394

I have this method, with 2 possibilities: requestLockInfo(key: string, cb: EVCb): void; requestLockInfo(key: string, opts: any, cb: EVCb): void; requestLockInfo(key: string, opts: any, cb: EVCb) { // implementation …
user11810894
0
votes
1 answer

Is there a way to modify decorators option at build time?

I have an Angular standard application and I want switch some components at build time. I want change, with one ast trasformer, the @Component decorator options like this: login.component.ts @Component({ selector: 'login' .... })…
gioboa
  • 11
  • 1
0
votes
1 answer

How to represent mixins with TypeScript

I am writing a custom mixin routine, it accepts varags of objects: type HasIndex = {[key:string]:any}; // type RetType = ? const mixinAll = (...v: HasIndex[]): RetType => { return v.reduce((a,b) => doMixing(a,b,new Set()), {}); }); so my…
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
0
votes
1 answer

Transpile .ts source files without dependant configuration files

I set my node.js server in typescript this way: /src /... /dist /node_modules /... /tsconfig.json /..other conf and typings files Some files in /src get some configuration from package.json for example. This makes the transpiler creates this…
cartman
  • 189
  • 1
  • 2
  • 17
0
votes
1 answer

How do I attach custom transformers to a compiler host?

I have a custom TypeScript watcher that looks something like: const compilerHost = typescript.createWatchCompilerHost(config.fileNames, config.options, typescript.sys, undefined, reportDiagnostic) typescript.createWatchProgram(compilerHost) I want…
Micah Zoltu
  • 6,764
  • 5
  • 44
  • 72
0
votes
0 answers

tsc compiler option for output of .map files?

I'm trying to seperate my .map files from my .js files after transpiling. I have set the mapRoot so the debugger knows where to locate the map files. However I cannot seem to find the option which tells tsc to transpile the .map files to said…
basickarl
  • 37,187
  • 64
  • 214
  • 335