tsc

RxJS5 TypeScript typings fail

折月煮酒 提交于 2019-12-08 07:21:02
问题 I run tsc on my project, and I get these errors relating to the RxJS5 lib: $ tsc node_modules/rxjs/observable/FromEventObservable.d.ts(11,39): error TS2304: Cannot find name 'EventTarget'. node_modules/rxjs/observable/FromEventObservable.d.ts(11,103): error TS2304: Cannot find name 'NodeList'. node_modules/rxjs/observable/FromEventObservable.d.ts(11,114): error TS2304: Cannot find name 'HTMLCollection'. node_modules/rxjs/observable/dom/AjaxObservable.d.ts(16,23): error TS2304: Cannot find

Using Gulp how to first compile Typescript then concatenate the result and uglify it?

半腔热情 提交于 2019-12-07 18:19:40
问题 I'm working on a project using Typescript currently I'm facing a problem compiling Typescript and then concatenate the result using Gulp . var gulp = require('gulp'); var ts = require('gulp-typescript'); var concat = require('gulp-concat'); var uglify = require('gulp-uglify'); gulp.task('default', function () { gulp.src('vendor/**/*.js') // I want to add ts files then combile and concat .gulp.src('src/**/*.ts') .pipe(sourcemaps.init()) .pipe(ts({ noImplicitAny: true, out: 'output.js' }))

Why does Typescript compiler not change .ts to .js?

徘徊边缘 提交于 2019-12-07 08:34:14
问题 In the image below on the left in the folders you can see my /src Typescript (blue) compiled into my /dist (purple) Javascript using tsc. You can see in the source file on the left that references a .ts module file that it isn't compiled into referencing a .js module file on the right. Why not? How could the Javascript possibly run if tsc doesn't convert references? Second question: I then tried manually changing the compiled reference from .ts to .js and running node dist/server.js but I get

tsc unknown compiler option allowNonTsExtensions

删除回忆录丶 提交于 2019-12-07 05:49:25
问题 I am getting error TS5023: Unknown compiler option 'allowNonTsExtensions' when trying to run tsc on a project. Here is my tsconfig.json file. { "compilerOptions": { "target": "ES5", "allowNonTsExtensions": true, "module": "commonjs", "sourceMap": true, "isolatedModules": true, "noEmitOnError": false, "rootDir": ".", "emitDecoratorMetadata": true, "experimentalDecorators": true }, "compileOnSave": false } Using typescript@1.6.2 globally in npm . Link to the project being used. 回答1: The option

Cannot transpile TypeScript containing async await

我是研究僧i 提交于 2019-12-07 03:09:59
问题 When trying to transpile the following TypeScript code containing async and await keywords async function foo() { await bar(); } I get the following error src/aa.ts(1,7): error TS1005: ';' expected. src/aa.ts(2,11): error TS1005: ';' expected. The result is a .js file with this content async; function foo() { await; bar(); } I'm using these tsc options: -t es6 -m commonjs , following instructions on this MSDN blog. I have TypeScript 1.8.9 installed. Any ideas? 回答1: For some reason the

node.js: Unexpected token {

穿精又带淫゛_ 提交于 2019-12-07 00:00:55
问题 So I have a unit test written for mocha using TypeScript. I am trying to run it using gulp (which doesn't really play a part here). I get the following exception: (function (exports, require, module, __filename, __dirname) { import { assert } from 'chai'; ^ SyntaxError: Unexpected token { at new Script (vm.js:74:7) at createScript (vm.js:246:10) at Object.runInThisContext (vm.js:298:10) at Module._compile (internal/modules/cjs/loader.js:657:28) at Object.Module._extensions..js (internal

Run TypeScript compiler from Java

≡放荡痞女 提交于 2019-12-06 05:48:45
问题 I am trying to run the TypeScript compiler from my Java application. To start, I am trying to figure out, whether I can run the compiler from command-line without Node.js: $ jsc tsc.js But this way I don't get any errors, nor help. $ jsc tsc.js myscript.ts Will get me nowhere. It is easy to run js code directly from java (and I am hoping to run the compiler in this way), but is it possible to run TypeScript compiler without node.js? EDIT: I confirm the same behaviour with rhino. 回答1: Looking

Conditional types with TypeScript

纵然是瞬间 提交于 2019-12-06 05:07:55
问题 Say I have this: type TypeMapping = { Boolean: boolean, String: string, Number: number, ArrayOfString: Array<string>, ArrayOfBoolean: Array<boolean> } export interface ElemType { foo: keyof TypeMapping, default: valueof TypeMapping } instead of using any for default, I want to conditionally define it, I tried this: export interface ElemType<T extends TypeMapping> { foo: keyof T, default: T } but that doesn't seem quite right, does anyone know the right way to do this? if it's not clear, for

Why does Typescript compiler not change .ts to .js?

喜欢而已 提交于 2019-12-06 02:50:32
In the image below on the left in the folders you can see my /src Typescript (blue) compiled into my /dist (purple) Javascript using tsc. You can see in the source file on the left that references a .ts module file that it isn't compiled into referencing a .js module file on the right. Why not? How could the Javascript possibly run if tsc doesn't convert references? Second question: I then tried manually changing the compiled reference from .ts to .js and running node dist/server.js but I get the error cannot find module tools/typescriptImport.js' . Why does node fail to find the module when

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

戏子无情 提交于 2019-12-06 02:23:53
问题 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 breaking changes in webpack ts-loader In short, I have Gulp and WebPack set to an entry point of /client/app.ts which for now has almost nothing in it (certainly nothing referencing /server/) but the TypeScript compilation stage of the WebPack