tsc

How to export a TypeScript module for SystemJS?

ぐ巨炮叔叔 提交于 2019-12-05 22:53:21
On my website I want to import a FancyModule using SystemJS , so that I can create instances of classes which this module exports. So what I want to achieve is this (within a ECMAScript 2015-compatible website): SystemJS.import('MyFancyModule').then(function(MyFancyModule) { var myFancyInstance = new MyFancyModule.MyFancyClass('Test'); console.log(myFancyInstance.text); }); Unfortunately, I am getting the following error: TypeError: MyFancyModule.MyFancyClass is not a constructor(…) Here is my TypeScript module: export module MyFancyModule { export class MyFancyClass { public text: string;

TypeScript 1.3 for Visual Studio 2013 missing SDK directory (tsc.exe)

岁酱吖の 提交于 2019-12-05 22:43:16
问题 Typescript v1.3 was announced today, so I installed the power tools update for VS2013. After installation I can see that Visual Studio now knows about "protected" keyword and tuple types, which is great! But then I changed the TypeScriptToolsVersion attribute in my *.csproj file from 1.1 to 1.3: <TypeScriptToolsVersion>1.3</TypeScriptToolsVersion> After doing this, I get the following error when building: The specified task executable location "C:\Program Files (x86)\Microsoft SDKs\TypeScript

Why is ES7/array polyfill needed despite the tsconfig target is set to ES5

拈花ヽ惹草 提交于 2019-12-05 20:31:49
I have the following settings in the tsconfig.json . I added "es2017" to use Array.includes .: { "compilerOptions": { "lib": [ "es6", "es2017", "dom" ], "module": "es6", "target": "es5" } } Now, I realized, that I have to add import 'core-js/es7/array'; to the polyfills.ts , to use Array.includes also for the Internet Explorer 11. The target in the tsconfig.json is set to es5 , which does not have Array.includes . Why do I need to add the polyfill? TypeScript does not auto-polyfill code. The "official" reason from the relevant GitHub issue seems to be, as @RyanCavanaugh said : Having the

Ubuntu16.04下安装OpenStack

限于喜欢 提交于 2019-12-05 02:06:59
1.首先查看自己电脑CPU是否支持虚拟化: grep - E "vmx|svm" /proc/cpuinfo 如果打印结果像下面一样又臭又长: flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3 dnowprefetch epb intel_pt tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep

TypeScript compile and keep comments

試著忘記壹切 提交于 2019-12-05 00:39:19
I like to have my comments intact in the resulting javascript file, by default the compiler removes them. Is there a tsc parameter for that? (The use case is to keep /// reference path's = ... for chutzpah unit testing. ) Yes, the -c (or --comments) option; Syntax: tsc [options] [file ..] Examples: tsc hello.ts tsc --out foo.js foo.ts tsc @args.txt Options: -c, --comments Emit comments to output ... Comments that start with /*! are preserved. example: /*! this comment remains untouched */ /* but this one will be removed */ Imanou Petit Since 2015 you can create a tsconfig.json in your project

typescript outDir setting in tsconfig.json not working

眉间皱痕 提交于 2019-12-05 00:06:13
I can't seem to get the outDir flag working when used in package.json . Directory structure is pretty simple: tsconfig.json at the root level, together with a src/ directory and a single index.ts file plus other directories representing other modules. When running the tsc command on the index file, it creates a new one beside it instead of in the build directory. What am I doing wrong? My tsconfig: { "compilerOptions": { "outDir": "build" } } My npm build script: "build": "tsc src/index.ts" I'm calling the script from the root dir of the project. Interestingly, running the same script with an

Run TypeScript compiler from Java

偶尔善良 提交于 2019-12-04 10:49:06
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. Looking at the source code, the tsc command invokes a JS script tsc.js , which has 2 backends: Node.js and Windows

Programmatically compile typescript in C#?

匆匆过客 提交于 2019-12-04 08:05:35
问题 I'm trying to write a function in C# that takes in a string containing typescript code and returns a string containing JavaScript code. Is there a library function for this? 回答1: You can use Process to invoke the compiler, specify --out file.js to a temporary folder and read the contents of the compiled file. I made a little app to do that: Usage TypeScriptCompiler.Compile(@"C:\tmp\test.ts"); To get the JS string string javascriptSource = File.ReadAllText(@"C:\tmp\test.js"); Full source with

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

房东的猫 提交于 2019-12-04 05:50:41
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 build process is still trying to run on /server (and in my other post, showing a compilation error from

Mute/ignore TS2307 error from TypeScript tsc

我的未来我决定 提交于 2019-12-03 22:24:52
Is there a way to mute the TS2307 error from the TypeScript tsc compiler? It makes it really hard to spot real/new errors and warnings as there are many TS2307 errors in our codebase. Update : This error occurs when an external module is import ed without its type definition .d.ts being present. I'm aware of tsd but for many libraries we use, no type definitions exist. No, there is not a way to direct the compiler to suppress TS2307. There has been some discussion about it for exactly the reason you describe. For large projects, this becomes a huge barrier to entry. Details here: Making