tsc

babel tsc webpack

别等时光非礼了梦想. 提交于 2019-12-02 15:15:19
如果写超过es5版本的js,或者ts等。是需要babel来进行编译的。 但是babel值编译,如果遇到模块化他就无能为力了 需要webpack对其进行模块化打包功能。 通常babel编译+webpack处理模块打包压缩等,挺好的。是完美的方案 但是webpack它不老实。它想牛逼,于是他就内置了不用任何配的情况下,就支持对es6的编译环节。您只管使用webpack命令,他就支持编译+模块处理打包了。但是稍微高端的就不行,比如我要编译ts等,就需要引入ts-loader了。 但是人家ts也不是吃白饭的啊,人家自己的语言 自己肯定要提供编译的cli呀。于是tsCli之tsc命令人家自己也能编译ts为浏览器或者node可运行的代码。 那也就是说 后端node开发人可以直接用tsCli或者babelCli来处理ts代码 前端因为浏览器目前2019年均不直接支持模块化,所以需要进行搭配来使用 如果您的代码是es6,且没有用模块,那么用chrome直接运行即可,无需任何处理,我自己测试了,chrome支持良好。 如果你不放心,或者还要支持其他浏览器,那么你可以用babel编译一下子,是的不推荐你用webpack,因为你没有用模块化功能,所以浪费了,webpack肯定要比babel重 若果您的代码有es6以及其模块化,那么推荐您直接上webpack,因为它既能处理es6普通语法,也能处理模块化

KVM虚拟化平台环境部署

烂漫一生 提交于 2019-12-02 08:52:36
一:安装依赖包 二:配置网卡 三:配置环境 实验环境: KVM01 192.168.200.10 关闭防火墙及相关的安全机制 [root@KVM01 ~]# systemctl stop firewalld [root@KVM01 ~]# iptables -F [root@KVM01 ~]# setenforce 0 一:安装依赖包 [root@KVM01 ~]# cat /proc/cpuinfo | grep vmx #查看是否支持虚拟化 flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc eagerfpu pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch ssbd

tsc is not recognized as an internal or external command

守給你的承諾、 提交于 2019-12-02 03:40:46
I am using node version 6.9.2 with npm version 5.4.2 on Windows7. I have installed typescript with the command npm install typescript -g . However, when I run a demo file using command, tsc , I get an error: "tsc is not recognized as an internal or external command". Could anybody help? Other node modules get installed correctly and working fine. Not sure why typescript isn't working. The problem is likely that tsc is not in the system path. First, check if tsc is installed correctly. Open cmd.exe and type the following. %AppData%\npm\node_modules\typescript\bin\tsc --version If there is a

Compile Angular2 ts file

喜夏-厌秋 提交于 2019-12-02 01:13:54
问题 I'm trying Angular2 using Typescript, but I have a problem with tsc. This is my tsconfig.json file: { "compilerOptions": { "module": "commonjs", "noImplicitAny": true, "removeComments": true, "preserveConstEnums": true, "out": "compiled.js", "emitDecoratorMetadata":true, "target":"es5" }, "files": [ "ts/_base/_all.ts" ] } This is my _all.ts file: ///<reference path="./typings/libs.d.ts"/> ///<reference path="../app.ts"/> ///<reference path="../controllers/loginCtrl.ts"/> And this is my app

Compile Angular2 ts file

只谈情不闲聊 提交于 2019-12-01 22:01:44
I'm trying Angular2 using Typescript, but I have a problem with tsc. This is my tsconfig.json file: { "compilerOptions": { "module": "commonjs", "noImplicitAny": true, "removeComments": true, "preserveConstEnums": true, "out": "compiled.js", "emitDecoratorMetadata":true, "target":"es5" }, "files": [ "ts/_base/_all.ts" ] } This is my _all.ts file: ///<reference path="./typings/libs.d.ts"/> ///<reference path="../app.ts"/> ///<reference path="../controllers/loginCtrl.ts"/> And this is my app controller: import {Component, View, bootstrap} from 'angular2/angular2'; @Component({ selector: 'my-app'

SystemJS: loading build file

故事扮演 提交于 2019-12-01 14:47:32
My SystemJS file looks like this: (function(global) { // map tells the System loader where to look for things var map = { 'angular2-boot': 'app', // 'dist', '@angular': 'node_modules/@angular', 'angular2-in-memory-web-api': 'node_modules/angular2-in-memory-web-api', 'rxjs': 'node_modules/rxjs' }; // packages tells the System loader how to load when no filename and/or no extension var packages = { // 'app': { main: 'js/main.js', defaultExtension: 'js' }, 'app': { main: 'dist/build.js', defaultExtension: 'js' }, 'rxjs': { defaultExtension: 'js' }, 'angular2-in-memory-web-api': { defaultExtension

SystemJS: loading build file

萝らか妹 提交于 2019-12-01 14:00:38
问题 My SystemJS file looks like this: (function(global) { // map tells the System loader where to look for things var map = { 'angular2-boot': 'app', // 'dist', '@angular': 'node_modules/@angular', 'angular2-in-memory-web-api': 'node_modules/angular2-in-memory-web-api', 'rxjs': 'node_modules/rxjs' }; // packages tells the System loader how to load when no filename and/or no extension var packages = { // 'app': { main: 'js/main.js', defaultExtension: 'js' }, 'app': { main: 'dist/build.js',

How to configure Visual Studio to combine all TypeScript files into one JavaScript file?

て烟熏妆下的殇ゞ 提交于 2019-12-01 05:16:23
Using tsc command it's as easy as running: tsc --out all.js js/*.ts How can I configure Visual Studio to do that when I build my project? I've found a potentially easier solution by just modifying the build properties of the project (.csproj / .vbproj) you are building: I'm unsure which version of Typescript that this feature was introduced in. But it seems a much simpler method than the svallory's solution Source: http://rostacik.net/2013/12/18/how-to-setup-post-build-event-in-visual-studio-to-combine-multiple-typescript-files-to-one-javascript-file/ EDIT : Since Visual Studio 2015, it's now

How to configure Visual Studio to combine all TypeScript files into one JavaScript file?

时光怂恿深爱的人放手 提交于 2019-12-01 02:09:28
问题 Using tsc command it's as easy as running: tsc --out all.js js/*.ts How can I configure Visual Studio to do that when I build my project? 回答1: I've found a potentially easier solution by just modifying the build properties of the project (.csproj / .vbproj) you are building: I'm unsure which version of Typescript that this feature was introduced in. But it seems a much simpler method than the svallory's solution Source: http://rostacik.net/2013/12/18/how-to-setup-post-build-event-in-visual

TypeScript require one parameter or the other, but not neither

南楼画角 提交于 2019-11-30 22:31:59
问题 Say I have this type: export interface Opts { paths?: string | Array<string>, path?: string | Array<string> } I want to tell the user that they must pass either paths or path, but it is not necessary to pass both. Right now the problem is that this compiles: export const foo = (o: Opts) => {}; foo({}); does anyone know to allow for 2 or more optional but at least 1 is necessary parameters with TS? 回答1: You may use export type Opts = { path: string | Array<string> } | { paths: string | Array