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

How to import a Typescript module inside a Node.js library?

I'm writing a Node.js library that needs to import modules written by the user. If the user writes a module in Typescript he needs to transpile it into Javscript before feeds it into the library. I want to go one step further and make the library…
pouya
  • 3,400
  • 6
  • 38
  • 53
0
votes
0 answers

tsc cli - check if src files are newer than destination files

When using tsc with a tsconfig.json file, is there a check we can use to determine if the source files have been updated since the destination files have been written? I want to run something like: tsc --check && node . that way I am ensuring that…
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
0
votes
1 answer

Why does referencing a non-exported class not generate a transpilation error?

I'm relatively new to both Typescript and Javascript (and node.js), from a Java background, but learning fast the painful way. I recently converted from one giant Typescript file with a number of classes to using multiple classes. This took some…
ojchase
  • 1,041
  • 1
  • 10
  • 22
0
votes
2 answers

How to compile two projects that reference each other

I am having issues building a project (@red5/middleware) that references another project (@red5/router) and in return that project references this project (@red5/middleware). So, when I run the command: rm -rf types && tsc -p . I get an error that…
Get Off My Lawn
  • 34,175
  • 38
  • 176
  • 338
0
votes
1 answer

How can I run tsserver as a background process on mobile (i.e. with JavaScriptCore but without node; and avoiding webview-based solutions)?

I have made a simple JS text editor app for iOS; I'd like to use tsserver to get intellisense and transpilation. I can see how to run tsserver via node or via the browser (as part of TypeScript Playground – however, it comes along with the Monaco…
Jamie Birch
  • 5,839
  • 1
  • 46
  • 60
0
votes
1 answer

Regex for matching ts files but not test

I need regex to add to the tsconfig file. I'm trying to match only ts source files, but not test files. Tried something like; "include": [ "src/**/*", "../../node_modules/@web/common/src/app/views/**/*.ts" …
Mohamed
  • 71
  • 3
  • 7
0
votes
0 answers

Can I choose between develop config file and production config file in TypeScript?

I'm having a problem. I need to use some configs file when I'm working in a develop environment and other when I'm working in Production environment. I'd like to compile using something like this: tsc --production=true And then in my code: …
Lucas Segura
  • 91
  • 2
  • 10
0
votes
1 answer

Array Prototype will included in the List of the Array

I am using typescript to add in new prototype in the Array. I found out that i am able to print out the prototype function in the for loop. .ts declare global { interface Array { group(groupByKey: T): Array; } } if…
Brian
  • 41
  • 5
0
votes
2 answers

Save hardcoded date from Typescript in generated Javascript?

I have a REST API backend project written in TypeScript where I want to be able to see when the Javascripts were generated. In my Express routes I want to have a route called '/version' which only returns a string, '2018-12-19 08:39:00.000'. Is…
Frode Lillerud
  • 7,324
  • 17
  • 58
  • 69
0
votes
0 answers

TypeScript/tsc module resolution peculiarity

So I have this structure: node_modules/ @types/express/ express/ express/index.ts main.ts in express/index.ts, I had this: import {RequestHandler} from 'express'; and it wouldn't resolve. I had the same call in main.ts and that import would…
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
0
votes
0 answers

Convert type back to value

I am converting a class to a type, but I want to convert that type back to a class. Say I have this class: export namespace Entities{ export namespace Bar{ export class Foo { } } } and then I have a reference to the type: type F =…
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
0
votes
1 answer

Cannot pass Class to helper method

I have this which compiles: export namespace Foo { export namespace GET { export namespace Basic { export class Req {} } } } type Req = Foo.GET.Basic.Req; e.setRequestBodyType(Foo.GET.Basic.Req); what I would like do…
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
0
votes
1 answer

Store reference to namespace instead of type

Say I have a namespace like so: export namespace Foo1 { export namespace Foo2 { export namespace Foo3 { export interface Foo4 {} export interface Foo5 {} } } } in a .ts file I have something like this: import {Foo1} from…
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
0
votes
1 answer

Prevent compilation unless all fields exist

I have this typescript code: interface Foo { foo1: string, foo2: number, foo3: boolean } const v = {foo1: '4'}; this compiles - how can I prevent it from compiling unless all 3 fields are present in the object? Right now only one of…
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
0
votes
0 answers

Running tsc generate errors

I am following 5-minute tutorial of typescript (https://www.typescriptlang.org/docs/handbook/typescript-in-5-minutes.html), and after running tsc greeter.ts, I am having few warnings/errors including Duplicate identifier PropertyKey. Since I am…
Mayank
  • 17
  • 4