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
10
votes
4 answers

Duplicate string values in TS enum does not cause compilation error?

I have this in a TypeScript enum: export enum LMXLockRequestError { MaxRetries = 'bad_args', BadArgumentsError = 'bad_args', } this doesn't seem to cause a compilation error. It transpiles to this: var LMXLockRequestError; (function…
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
10
votes
1 answer

TypeScripts transpiles files which are non-executable

It appears as though TypeScript is transpiling target files that are not executable. I have to run chmod u+x after transpilation to get the files to become executable. This is the case, even if they have a hashbang: #!/usr/bin/env node How…
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
9
votes
2 answers

AWS CodeBuild tsc error TS2307: Cannot find module

I have created a couple different TypeScript cdk pipelines, and they all encounter the same tsc error during the CodeBuild phase. Two of these pipelines were replicated via the cdk…
Makuziker
  • 91
  • 1
  • 2
9
votes
4 answers

paths from tsconfig.json doesn't work after tsc

In my Express project, I import from paths like @common/foo. Thanks to paths in tsconfig.json, it's just an alias to ../common/src/foo. That's awesome and works in development with this script in nodemon.json: { "watch": ["src",…
Itay Ganor
  • 3,965
  • 3
  • 25
  • 40
9
votes
2 answers

How to represent nested array with typescript

Say I have an array of strings like: const a = ['foo', ['aa'], [['zzz',['bar']]]]; export const acceptsArray = (v: Array) : string => { returns flattenDeep(v).join(' '); }; besides using Array how can I represent a nested array of…
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
9
votes
1 answer

TS2538: Type 'unique symbol' cannot be used as an index type

I have this: const symbols = { typeMap: Symbol('type.map') } interface LangMap { [key: string]: string | true, golang: string, typescript: string, java: string, swift: string } export const setTypeMap = function(v: LangMap) :…
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
9
votes
1 answer

AOT compilation fails when factory function imported from library is used in DI in Angular

I have an Angular 6.1 application, which imports some external module. When I'm compiling the application in AOT mode: $ ng build --aot I'm getting this error: ERROR in ./src/app.component.ngfactory.js Module not found: Error: Can't resolve…
Slava Fomin II
  • 26,865
  • 29
  • 124
  • 202
9
votes
1 answer

Error MSB4064: The "ComputeInputAndOutputOnly" parameter is not supported by the "VsTsc" task

After upgrading to Typescript 2.7.2 (from 2.4) I get the following error on the build server: packages\Microsoft.TypeScript.MSBuild.2.7.2\tools\Microsoft.TypeScript.targets(378,7): Error MSB4064: The "ComputeInputAndOutputOnly" parameter is not…
9
votes
1 answer

How to use a compiled TypeScript class in Javascript

Imagine I have this simple TypeScript class, Animal.ts: export default class Animal { constructor(public name : string) { } } With this tsconfig.json file: { "compilerOptions": { "target": "es5", "module": "commonjs", "strict":…
Titulum
  • 9,928
  • 11
  • 41
  • 79
9
votes
6 answers

npm doesn't update tsc version

Typescript is updated using the following command: npm install typescript -g And latest version 2.4.2 is installed correctly and I can verify it by looking the path shown by folloing command: npm list typescript -g but the following command shown…
mehran
  • 1,314
  • 4
  • 19
  • 33
9
votes
0 answers

tsc with tsconfig does nothing. What am I doing wrong?

My directory has 2 files: a tsconfig.json with simply {} and a hello.ts with a line that says console.log('help!!');. When I run tsc hello I get the additional hello.js as expected. If I delete hello.js and run tsc intending to pick up my…
GaryB96
  • 371
  • 5
  • 13
8
votes
0 answers

Can you use tsc to type check multiple typescript projects at once without building them?

In theory, you should be able to do this by using references to make a top-level tsconfig file that includes paths to all of the different typescript projects you want to check, setting "composite": true on the tsconfig.json files for each…
neurodynamic
  • 4,294
  • 3
  • 28
  • 39
8
votes
2 answers

tsc does not recognize '--init' option

For some reason npx tsc --init prints out the following error: $ npx tsc --init npx: installed 1 in 1.467s error TS5023: Unknown compiler option 'init'. I have installed the typescript package with Yarn 2: $ yarn add -D typescript ➤ YN0000: ┌…
Don Foumare
  • 444
  • 3
  • 13
8
votes
3 answers

"Property ... does not exist on type ..." error when using Typescript

I get the error when compiling a file with typescript: Property 'qaz' does not exist on type '{ bar: string; }'. With the following code in the file: let foo = { bar: "Can you perform a Quirkafleeg?" } let { qaz = "I'm feeling manic!" } =…
Daniel Grace
  • 91
  • 1
  • 1
  • 4
8
votes
2 answers

Extending the TypeScript compiler for a DSL

Before I start: yes I do need(/want) a DSL (even if it's just for the experience), there's no other format that expresses what I'm trying to do in a not-terribly-verbose, type-safe way. Some background information, actual question at the bottom I…