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
1 answer

Freezing exports with TypeScript

I assume this is the best way to do it: export const stdMarker = '@json-stdio'; export const stdEventName = '@json-stdio-event'; Object.defineProperties(module.exports, { 'stdMarker': { writable: false }, 'stdEventName': { …
user7898461
0
votes
0 answers

Importing class is not working between files after transpilation with TS

I am getting a runtime error - after transpilation with TS. I am getting this error: /home/oleg/WebstormProjects/oresoftware/live-mutex/dist/rw-client.js:23 class RWLockClient extends client_1.Client { …
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
0
votes
1 answer

Typescript tsc getting 'never' error in es6 promise?

I'm migrating a simple JavaScript node module and server code that utilizes it to TypeScript, But something really strange happens somehow... I used promise chaining syntax below: api.Promise1().then(resultOfPromise1 => …
y3k00000
  • 11
  • 1
  • 3
0
votes
1 answer

TS creates .d.ts file that is less descriptive

I have this input in a .ts file: export const OverSizedItems = <{ [key: string]: OverSizedItemType }>{ NONE: { factor: 1, count: 0, mooversNeeded: 1, }, ONE: { factor: 1.01, count: 1, mooversNeeded: 4, }, TWO: { …
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
0
votes
0 answers

running tsc on all files in the folder

I've found various tutor websites which refer to the tsc command to run and watch for source file changes. Nevertheless, when I write: tsc -w or tsc --watch I'm getting messages in the command line asking to write the filename (in all the tutors…
roy.me
  • 421
  • 2
  • 7
  • 19
0
votes
1 answer

Compiling VSTS Extension in VisualStudio 2017

How to build a VSTS extension in Visual Studio 2017. The post build event configured in package.json doesn't work from Visual Studio. Only the Command npm run build triggers the build and postbuild events. I want vsix file to be created on building…
Siva
  • 13
  • 4
0
votes
1 answer

issue when applying function reduce to empty array

The typescript compiler does not mark any errors with the following code. const numbers: number[] = []; const sum: number = numbers.reduce((a, num) => (a + num)); However, when executing the transposed code, nodejs returns the following…
0
votes
1 answer

Why doesn't my typescript compiler work correctly?

I just reinistalled windows and wanted to code a bit, while i was trying to compile typescript to a node module (.js file) the typescript compiler didn't output the correct code. i'll give an example: import { Size } from "./Utils/Size"; export…
0
votes
1 answer

Derive type from JS object

I have this object: export interface ClientOpts { key: string, listener: Function, host: string, port: number unlockRequestTimeout: number; lockRequestTimeout: number; unlockRetryMax: number; lockRetryMax: number; ttl: number } I…
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
0
votes
1 answer

Get string union, dynamically from array

I have this: const goodKeys = { 'integer': 1, 'string': 1, 'number': 1, 'function': 1, 'boolean': 1, 'null': 1, 'undefined': 1, 'symbol': 1 }; And I am looking to extrace/derive the following from the above dynamically: export type…
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
0
votes
1 answer

Cannot find name Symbol

For the below code: const MY_KEY: symbol = Symbol(); let obj: object = {}; obj[MY_KEY] = 123; console.log(obj[MY_KEY]); // 123 For the below configuration tscconfig.json: { "compilerOptions": { "lib": ["es2015"] }, } Files $…
overexchange
  • 15,768
  • 30
  • 152
  • 347
0
votes
1 answer

Runtime type checking of constructor options that get passed to super

I have this: export class XMLParser extends Transform { constructor(opts?: XMLParserOpts, to?: TransformOptions) { super(Object.assign({}, to || {}, {objectMode: true})); } } basically I always need objectMode to be true. However, what…
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
0
votes
0 answers

tsconfig error when encountering = inside <>

When I run tsc, I get the following error export type Handler = ( ~ functions/node_modules/@types/aws-lambda/index.d.ts(600,28): error TS1005: ',' expected. Note: It shows error for the TEvent…
suku
  • 10,507
  • 16
  • 75
  • 120
0
votes
1 answer

TypeScript enforce all files in a folder export a class which extends another class

If I have a folder: jobs/ a.ts b.ts c.ts is there a way to use TypeScript so that all the files in the jobs folder export the same interface? I'd like for a.ts, b.ts, c.ts to all export the same interface.
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
0
votes
1 answer

Use generics to declare type of return value of class method

I have the following: export class RootCtrl { m: Model; constructor(m: Model) { this.m = m; } doFindMany(query: object, options?: CDTModelOpts, cb?: MongoErrorCB){ const Model = this.m; // cb is optional, if cb ==…
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817