Questions tagged [tsc]

1

votes
1

answer
684

Views

Debugging doesn't work in Visual Studio Code 1.19.3

I want to use Visual Studio for developing an Node.js application with Typescript and simply want the normal debug behavior of any modern IDE: Debug code, set breakpoints, look into vars etc. Following the official documentation guide, I get an error when running the task: The npm task typescript di...
Lion
1

votes
0

answer
68

Views

how to print 60*48 mm size paper in java

I am trying to print 60*48 mm size paper usnig tsc printer. I have given the size but it is not working properly. double paperWidthInInch =2.36;// double paperHeightInInch =1.88;//5.6 PrinterJob prnJob = PrinterJob.getPrinterJob(); //prnJob.setCopies(2); PageFormat pf = new PageFormat(); Paper p =...
shailesh rawte
1

votes
0

answer
121

Views

Visual Studio Code always uses old version of tsc

I am using typescript as a way of creating javascript for a webpage. My first attempt at using the tsc compiler produced error TS1005 about a missing ';'. This is apparently because Visual Studio Code is using an old version of tsc. I find I have two versions on my system (discovered using where tsc...
simonc8
1

votes
1

answer
45

Views

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 if the user passed in some weird value for to? How can I check i...
1

votes
0

answer
35

Views

Tsc works fine, gulp build fails including node_modules

I'm new to typescript and gulp and got a working project, where tsc is working fine(with tsconfig.js) but gulp build wasn't configured. I'm trying with this aproach: var gulp = require('gulp'); var tsc = require('gulp-typescript'); ... var tsProject = tsc.createProject('tsconfig.json'); gulp.task('b...
degressor
1

votes
1

answer
78

Views

Set TypeScript compiler's base/working directory

It looks like TypeScript compiler resolves files relative to the location of the tsconfig.json file. Is there a way to specify an alternative base directory, which will be used for relative paths resolution? I want to use a generic tsconfig.json file to compile multiple projects in various directori...
Slava Fomin II
1

votes
0

answer
60

Views

Typescript generic restricted by extend, returned from function

I'm not sure how to put this into words, so here is an example type NonVoid = Object | object; type Something = { test: string } & (T extends NonVoid ? { requiredWhenNonVoid: T } : { requiredWhenNonVoid?: undefined }); function testFunc1(a: A): Something { return { test: 'test', requiredWhenNonVoid:...
Tom Jenkinson
1

votes
1

answer
36

Views

Using namespaces to avoid importing from each file

According to this article, you can use TypeScript namespaces to import types/interfaces without including an import: https://scotch.io/tutorials/3-useful-typescript-tips-for-angular However if I create a namepsace: export namespace ST { export interface Ifoo { } } in order to get it recognized, I ha...
Alexander Mills
1

votes
0

answer
115

Views

is there any way to connect non certified bluetooth printer?

I have a tsc tdp 225 printer (with bluetooth accessory) that is not certified with apple. so it does not support connection directly as bluetooth printer but is there any way to connect it using core bluetooth? I need only connectivity not for print. I have tried it with light blue app but that also...
dinesh sharma
1

votes
0

answer
117

Views

Dynamically add element to typed array

I can pass a typed array to a constructor and use generics to declare the type. But after getting the object instance (via the constructor call), I want to add a new element to the array. But the dynamic typing methodology I have right now can't incorporate the new element in the array. Say I have t...
Alexander Mills
1

votes
0

answer
77

Views

Using pm2 with changed npm's default directory

I develop node.js application on typescript, and I want to deploy app to the server with pm2 deploy. I don't have sudo access on the server, so i can't just install npm packages globally. According to npm documentation, i've changed my npm's default directory to ~/.npm-global and install typescript...
baitun
1

votes
0

answer
25

Views

Compile single .ts file to stdout

I am looking to compile a single .ts file to stdout, something like this: tsc foo.ts > foo.js is this possible somehow? I want to control where the output goes without using a tsconfig.json file.
Alexander Mills
1

votes
1

answer
49

Views

Typescrpit compiler not solving Path Mapping modules

I would like to use ts-node with .ts files that use path mapping like paths: { '@/*': ['src/*'] } and import like import Sample from '@/sample' instead of import Sample from '../../src/sample' When when compiling tsc index.js, I got this: index.ts:1:18 - error TS2307: Cannot find module '@/sample. W...
Daniel Santos
1

votes
0

answer
38

Views

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 strings?
Alexander Mills
1

votes
0

answer
22

Views

Point Typescript paths to a folder outside of the project folder so it can be shared between projects

I realize the title might sound a little unclear. I have a project that is split into smaller parts. Project _ORM admin api Now, both admin and api need to be able to load modules and models from the '_ORM'. So I figured I'd simply put some paths in the tsconfig, which works, but for some reason the...
Tim VN
1

votes
0

answer
19

Views

Export import via namespace

Say I have this situation: import {ExpressRoute} from './expressjs/express-route' export namespace express { } is there a way to export the import from the namespace? something like this: export namespace express { export class Route = ExpressRoute; } alternatively, is there a way to import/export a...
MrCholo
1

votes
0

answer
153

Views

How to copy package.json in dist or build folder when running tsc (TypeScript compiler)

I have a TypeScript React component that uses a package.json file (see screenshot) and I run tsc in order to transpile it to es5 in my dist folder but the package.json file doesn't get copied. Please note that in the screenshot I manually copied it in the dist folder. So my question: Is there a way...
Gab
1

votes
1

answer
591

Views

TypeScript compile error “Unknown file Extension”

I am getting build errors for multiple *.ts files. TypeScript compiler says Unknown extension for file: '.ts'. Only .ts and .d.ts extensions are allowed. These files build alright on save. Web Essentials never complains about anything and this is the only message I am getting in the output window....
smehnawal
1

votes
1

answer
245

Views

tsc.js Microsoft JScript runtime error after installing 0.9 version

I keep getting a compile error after installing version 0.9 of TypeScript. Here's the error: tsc.js(21630, 17) Microsoft JScript runtime error: Unable to get value of the property 'trailingTrivia': object is null or undefined And this is a snippet of the code I'm getting the error on: /// /// ///...
Paul Sinnema
1

votes
1

answer
526

Views

IntelliJ Idea bundle JS files

I am working on a huge project where i am using Java, TypeScript, Jade and Less. To compile the project, i am using Maven (Java) + Grunt( TS, Jade, LESS). Grunt is called from maven, because maven drives whole project (include backend). With grunt everthing works perfect, but i want to have realtime...
Xrew
1

votes
1

answer
738

Views

Intercept rdtsc instruction from guest vm userspace in KVM

I'm stuck in the problem as the title says.I want to do this in VMM by adding the CPU_BASED_RDTSC_EXITING flag in vmx.c(arch/x86/kvm) in setup_vmcs_config function,and then handle the vm_exit by myself(ref this:mail list).The question is that I cannot tell whether the vm_exit of rdtsc is caused by...
ioilala
1

votes
1

answer
315

Views

Can I add additional comments in generated javascript with typescript?

Working on an open-source project, I'm trying to find a way to have comments in javascript header such as 'AUTO-GENERATED FILE, DO NOT MODIFY etc.' ; but of course, I don't want to put those comments in typescript files, only in JS. Is there a way to do it? Maybe via some kind of tsc post-compile sc...
Joel
1

votes
2

answer
568

Views

Set up build task in vscode with global tsc parameters

We have the following project structure +-- views +-- viewXXX +-- ts ¦ +-- controller.ts ¦ +-- helper.ts ¦ +-- ... (*.ts) +-- viewXXX.ctrl.js // this is the desired output file +-- viewXXX.ctrl.map.js +-- viewXXX.html We are trying to configure a task in VSCode that allows to compile fol...
Kutyel
1

votes
1

answer
244

Views

tsc in an ASP.NET Core and Angular 2 project

I am working on a new project using .NET Core rc2 WebAPI and Angular2 rc1 using TypeScript. Everything is setup and working well. .NET Core only handles the API and Angular2 handles all views. My ts files are in a sub-folder script of the root project folder because they need access to the node_modu...
hholtij
1

votes
1

answer
1.2k

Views

Angular 2 and TypeScript. How to compile HTML templates?

So I have files *.ts and it is easy to understand how to compile into *.js using tsc. But a question is how to compile HTML templates which I use in *.ts files? For example, this code appears after it is compiled and launched in HTML file: //
Dmitry
1

votes
1

answer
1.6k

Views

Angular 2 tsc error

I am trying to run tsc in my angular 2 application directory. It gives me: error TS5023: Unknown compiler option 'moduleResolution'. This seems to prevent it from starting up as tsc is tied to the npm start script. My code is a copy of the Angular 2 quickstart. I have searched and tried a lot of di...
Jeff
1

votes
1

answer
651

Views

Simple issue with Typescript and VSCode

I am trying to set up a VSCode environment for working with TypeScript v2.03 I start out with a simple vanilla javascript snippet I can test out in node via the integrated terminal. function Person() { this.name = ''; } Person.prototype.age = 0; let me = new Person(); I insert into the Typescrip...
tommy
1

votes
1

answer
155

Views

Compile typescript project as local module

tl;dr Can I have typescript compile different folders as separate libraries, and import the results like a node module? For example, I have a common folder with 800 files, and then a few app folders (app1, app2, etc) each with 20+/- files. All of the app folders have references to classes/interface...
Jim Buck
1

votes
1

answer
3.2k

Views

npm installing old versions of (typescript compiler) package

On a windows environment, I have: node v4.6.0 npm v3.10.8 my local typescript version is: npm run tsc -v 3.10.8 However, I sometimes want to use my global tsc (because for some reason, gulp uses the global tsc) but when I do: npm install tsc -g tsc -v I get a version 1.5.3 for my typescript compile...
Filip Novotny
1

votes
1

answer
1.1k

Views

Typescript 2.0 @Types/Express | Cannot find module

The Express type definitions for Typescript 2.0 result in unexpected errors when executing after running npm install @types/express and tsc -t ES6 for ES6. The code compiles fine without the ES6 flag. Can anyone explain? I also have issues with other type definitions such as ssh2. Here are the steps...
sparebytes
1

votes
1

answer
683

Views

Resolving paths in TypeScript outDir

I'm writing a UI page object model testing project in TypeScript and I'm trying my best to avoid hideous nested imports. I found the paths object for the .tsconfig file that fixes the issue in .ts files, but, because I compile into an outDir, my compiled .js files cannot resolve the module path. I...
Will Luce
1

votes
1

answer
595

Views

tsc not reporting errors when compiling

I'm having some issues figuring out a mysterious situation I have a tsconfig file: { 'compilerOptions': { 'outDir': './built', 'allowJs': true, 'target': 'es5' }, 'include': [ './app/**/*.ts' ] } And when I do tsc with the code below, which is clearly wrong: const credentials = Config.blahblah impo...
eddie.xie
1

votes
1

answer
164

Views

Run browserify upon file change with tsc -w

I am new to npm build tools. I want to bundle the compiled typescript files as soon as there is a change in typescript files and run lite-server concurrently. To achieve that I have written following npm build script - 'build': 'tsc', 'bundle': 'browserify -s main app/goc-common/common.module.js >...
codeomnitrix
1

votes
2

answer
256

Views

Transpile all TypeScript files to a relative adjacent directory

I am writing our JavaScript based tests with TypeScript. I would like a single tsc --watch command, to be able to handle transpiling all of our files correctly, that's the key part. I think using multiple tsconfig.json files is the way to go here. I have this structure: /tests /e2e tsconfig.json /sr...
Alexander Mills
1

votes
1

answer
268

Views

tsc generated .d.ts files giving error “Cannot find namespace 'Jimp'”

I'm working on an NPM package, and one of my classes is simply this: import { MIME_PNG } from 'jimp'; import { IDimensions } from './spritesheet'; /** * A class for a single sprite. This contains the image * and supporting data and methods */ export class Sprite { image: Jimp.Jimp; dimensions: IDime...
Jeremy
1

votes
2

answer
75

Views

How to preserve license comments in TypeScript 2.5

I create JavaScript libraries using TypeScript v2.5 (latest) and tsc, so want to add license comments to built files. A configuration file of TypeScript can be set removeComments in tsconfig.json . It removes some comments including license comments. I've referred this post and tried to use /** xxx...
Yohsuke Inoda
1

votes
1

answer
748

Views

Unknown compiler option 'outFile'

I was trying to compile some TypeScript files to single JavaScript. Getting error as below error TS5023: Unknown compiler option 'outFile'. I compile it by command tsc. if I use outDir, the .ts files are compiling as expected to .js but seperately. My tsconfig.json { 'compilerOptions': { 'module': '...
Uthistran Selvaraj
1

votes
1

answer
227

Views

Visual Studio 2017 can't change project.csproj's <TypescriptModuleKind> for typescript transpiling

This comes out of my answer at https://stackoverflow.com/a/48436147/1019307. I need to change the module kind that the transpiler VS uses to be AMD. It defaults to commonjs even when the is changed in the project.csproj's from commonjs to be AMD. To see the problem: Add the typescript addons - Typ...
HankCa
1

votes
1

answer
334

Views

How to compile TypeScript to JavaScript with jQuery, without any additional libraries or frameworks (NPM, etc.)

I have an extremely simple single-page dashboard that does things like grab the weather, the subway alerts, etc. and I refresh it locally on my machine. It looked like: project/ index.html jquery-3.3.1.min.js script.js And I wanted to convert it to TypeScript. I ported script.js to TypeScript, but i...
Craig Otis
1

votes
1

answer
36

Views

Interface that is optionally callable

I have a use case where I create a bound function with data on it, or I just use an object. So now I have this interface: export interface LMLockSuccessData { (err: any, v: LMLockSuccessData): void acquired: boolean, lockUuid: string, id: string } in some case I use: const fn = foo.bind(this, 'bar...

View additional questions