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

Is there a type in @types/express for Express middleware functions

Right now I have this in a custom .d.ts file: import { Request, Response, NextFunction } from 'express'; export type MiddleWareFn = (req: Request, res: Response, next: NextFunction) => void; and I reference that file like so: router.use('/foo',…
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
24
votes
1 answer

WebPack ts-loader compiling all files when I only want it to run in one folder/file

I found a problem in my app structure and build process using WebPack, TypeScript, and TS-Loader that I thought was caused by TypeScript 2.1.4, but apparently was there the whole time. You can see all the details from my other post: TypeScript 2.1.4…
user358089
24
votes
6 answers

TypeScript compile and keep comments

I like to have my comments intact in the resulting javascript file, by default the compiler removes them. Is there a tsc parameter for that? (The use case is to keep /// reference path's = ... for chutzpah unit testing. )
joeriks
  • 3,382
  • 8
  • 32
  • 42
23
votes
6 answers

How to prevent typescript from transpiling dynamic imports into require()?

I'm building a discord.js Discord bot. Now for some reason, discord.js doesn't work with ESM modules (a totally separate issue), so my bot app uses CommonJS modules. Now I have another project on my system called Lib, which has a lot of utility…
The Freeze
  • 271
  • 2
  • 5
23
votes
6 answers

Create Electron Menu in TypeScript?

Just started a simple Electron app using TypeScript and I'm trying to get my custom menu setup. I followed the example in JS, but the line menu = Menu.buildFromTemplate(template); fails to compile with the error: main.ts(109,35): error TS2345:…
stwissel
  • 20,110
  • 6
  • 54
  • 101
23
votes
2 answers

Where does Yarn add global binaries on Windows?

I'm on Windows 7, and I tried to install typescript with yarn: yarn global add typescript success Installed typescript@2.0.6 with binaries: - tsc - tsserver Done in 11.59s. After successful installation, I type tsc in the command line, only to…
Nick
  • 8,451
  • 13
  • 57
  • 106
23
votes
3 answers

Run a npm script from gulp task

How to run a npm script command from inside a gulp task? package.json "scripts": { "tsc": "tsc -w" } gulpfile.js gulp.task('compile:app', function(){ return gulp.src('src/**/*.ts') .pipe(/*npm run tsc*/) .pipe(gulp.dest('./dist')) …
lbrahim
  • 3,710
  • 12
  • 57
  • 95
22
votes
3 answers

@Types/Sequelize Error TS1086: An accessor cannot be declared in ambient context

I have a project that shows this error when I run 'tsc': ../modules/node_modules/sequelize/types/lib/transaction.d.ts:33:14 - error TS1086: An accessor cannot be declared in an ambient context. 33 static get LOCK(): LOCK; …
Josel567
  • 387
  • 1
  • 2
  • 9
22
votes
2 answers

How can I get the list of Typescript files that tsc will compile?

I'm trying to write a grunt task in a Typescript project to measure some statistics of the source files. To do that, I have a function that takes a single source file, runs typescript.createSourceFile from it, and does some stuff to the returned…
Dan Hulme
  • 14,779
  • 3
  • 46
  • 95
21
votes
2 answers

How to type check a single file from command line, using the setting in tsconfig.json?

Normally I run tsc -p ./tsconfig.json which type checks all files in the ./src folder relative to tsconfig. But if I run tsc -p ./tsconfig.json src/specific-file.ts, it complains error TS5042: Option 'project' cannot be mixed with source files on a…
trusktr
  • 44,284
  • 53
  • 191
  • 263
21
votes
4 answers

tsc - ignore errors at command line

I have this: $ tsc -m amd --outFile dist/out.js lib/index.ts lib/index.ts(87,48): error TS1005: ';' expected. Is there a command line option I can use to ignore errors?
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
21
votes
1 answer

Exclude folder when compiling typescript

I use Atom to write code. It uses tsconfig.json to include and exclude folders. In order to use intellisense I need node_modules to be included, but when I want to compile it to js I don't want node_modules to be compiled. So I need to call tsc in…
FCin
  • 3,804
  • 4
  • 20
  • 49
21
votes
3 answers

Ignore certain TypeScript compile errors?

I am wondering if there is a way to ignore certain TypeScript errors upon compilation? I basically have the same issues most people with large projects have around using the this keyword, and I don't want to put all my classes methods into the…
Grofit
  • 17,693
  • 24
  • 96
  • 176
21
votes
1 answer

Is it possible to compile a single TypeScript file to an output path using the tsc command?

In an attempt to separate my .ts source files from the .js output, I'm trying to implement a formal file-watcher in TypeScript and it seems as though the ability to specify an output path for a single file does not exist. The flow, just to be…
cnp
  • 1,010
  • 2
  • 9
  • 20
20
votes
2 answers

Include CSS files in tsc TypeScript compilation

I am trying to create a React TypeScript NPM package. I have finished my code and created package.json and tsconfig.json. But inside my package I also have a bunch of CSS files that I want to include in my package. This is my tsconfig.json: { …
BluePrint
  • 1,926
  • 4
  • 28
  • 49
1 2
3
61 62