tsc

Map array to an interface

末鹿安然 提交于 2019-12-03 17:34:22
Say I have an array that looks like this: const options = [ { name: 'foo', type: 'boolean' }, { name: 'bar', type: 'string' }, { name: 'bar', // should be baz not bar type: 'number' } ] I am looking to use this array as an interface which would look something like this: export interface Opts { foo: boolean, bar: string, baz: number } so that would probably have to be something like: export type Opts = manipulate(typeof options); where manipulate is some magical TS feature I hope to discover. I believe this is a good place to start: https://blog.mariusschulz.com/2017/01/20/typescript-2-1-mapped

How to compile an Angular2 TypeScript application to a single file?

浪尽此生 提交于 2019-12-03 09:36:33
问题 I realize that I can compile my application with tsc my_app.ts --target system and it will generate a SystemJS-wrapped file for each imported module, which is awesome, but it generates anonymous (nameless) functions, so I can't just concatenate them to a single file. I thought about making this question "how to compile TypeScript to named SystemJS modules", but my goal is just to compile my Angular2 app to a single file, SystemJS or not. 回答1: The --outFile option works with the --module

typescript的安装和编译

橙三吉。 提交于 2019-12-03 09:23:59
1.安装 (可能需要管理员权限) npm i -g typescript 2.写入ts代码 3.手动编译: tsc xxx.js 4.用vsccode自动编译 (1) tsc --init // 生成一个tscconfig.json文件 (2) 修改json文件中的outDir (配置js输出路径) "outDir": "./js", (3)点击vscode里的终端--运行任务--监视tsconfig.json 【每次修改ts文件,js都会更新】 5.由于ts不会被浏览器识别,所以引入的时候应该引入js文件 来源: https://www.cnblogs.com/luguankun/p/11785323.html

tsc is not recognized as internal or external command

匿名 (未验证) 提交于 2019-12-03 08:41:19
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I updated from VSCode 0.10.6 to 0.10.8, and tried using Typescript for the first time. Unfortunately I when I tell VSCode to build, I get the error: tsc is not a recognized as an internal or external command... Here are the relevant details: I created a fresh "HelloWorld" project according to VS Code instructions . This included: I ran npm init for a new package.json I ran npm i --save-dev typescript because I want a local install, rather than a global install. I created a launch.json to define a node.js project. I created the tasks.json

How to find module “fs” in MS Code with TypeScript?

做~自己de王妃 提交于 2019-12-03 02:57:25
问题 I'm running on a MacBook Air. I installed MS Code as an IDE and also have TypeScript installed. I have a simple file with just this line: import fs = require('fs'); I'm getting a red squiggly under the 'fs' inside the parenthesis and the error message is [ts] Cannot find module 'fs'. The file has a .ts extension. I'm new to JavaScript and to TypeScript, but I was under the impression that fs was a core module, so how could it not be found? How do I fix the problem? Other things that I tried

tsc not excluding node_modules

匿名 (未验证) 提交于 2019-12-03 01:10:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: { "compilerOptions": { "target": "es5", "module": "commonjs", "moduleResolution": "node", "sourceMap": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "removeComments": false, "noImplicitAny": false }, "exclude": [ "node_modules", "typings/main", "typings/main.d.ts" ] } I'm trying to upgrade an angular2/beta8 app to RC1, and I'm doing so by basically restructuring according to the Quickstart guide. I copied its tsconfig.json into my project directory. I think I've got everything else ready,but when I run tsc , I get all

TSC打印机编程C#

匿名 (未验证) 提交于 2019-12-03 00:26:01
源码下载地址: https://download.csdn.net/download/horseroll/10473952 正常使用打印方法: public void dayin ( string url ) { TSC . openport ( "TSC TE344" ); //打开端口 TSC . clearbuffer (); //清除缓存 string strurl = "\"" + url + "\"" ; string str = "QRCODE 400,310,L,10,A,0,M2,S7," + strurl ; //确认二维码位置大小等代码 TSC . windowsfont ( 120 , 50 , 80 , 0 , 0 , 0 , "新楷体" , "有限公司" ); //打印中文字 TSC . sendcommand ( str ); //打印二维码 TSC . windowsfont ( 120 , 670 , 80 , 0 , 0 , 0 , "新楷体" , "包装日期及批号:" + DateTime . Now . ToString ()); TSC . printlabel ( "1" , "1" ); TSC . closeport (); } 首先先把TSCLIB.lib和TSCLIB.dll文件复制到C盘windows/system32目录下

babel tsc webpack

匿名 (未验证) 提交于 2019-12-03 00:15:02
如果写超过es5版本的js,或者ts等。是需要babel来进行编译的。 但是babel值编译,如果遇到模块化他就无能为力了 需要webpack对其进行模块化打包功能。 通常babel编译+webpack处理模块打包压缩等,挺好的。是完美的方案 但是webpack它不老实。它想牛逼,于是他就内置了不用任何配的情况下,就支持对es6的编译环节。您只管使用webpack命令,他就支持编译+模块处理打包了。但是稍微高端的就不行,比如我要编译ts等,就需要引入ts-loader了。 前端因为浏览器目前2019年均不直接支持模块化,所以需要进行搭配来使用 如果您的代码是es6,且没有用模块,那么用chrome直接运行即可,无需任何处理,我自己测试了,chrome支持良好。 如果你不放心,或者还要支持其他浏览器,那么你可以用babel编译一下子,是的不推荐你用webpack,因为你没有用模块化功能,所以浪费了,webpack肯定要比babel重 若果您的代码有es6以及其模块化,那么推荐您直接上webpack,因为它既能处理es6普通语法,也能处理模块化。当然你可以先用babel编译成es5+webpack去处理模块化,可这不是脱了裤子放屁多次一举么 如果你的代码有ts且没有模块化,babel和tsc都行,如果你的代码ts和模块化,webpack也行就是浪费性能呗, 如果你的代码ts和模块化

How to compile an Angular2 TypeScript application to a single file?

最后都变了- 提交于 2019-12-02 23:53:31
I realize that I can compile my application with tsc my_app.ts --target system and it will generate a SystemJS-wrapped file for each imported module, which is awesome, but it generates anonymous (nameless) functions, so I can't just concatenate them to a single file. I thought about making this question "how to compile TypeScript to named SystemJS modules", but my goal is just to compile my Angular2 app to a single file, SystemJS or not. The --outFile option works with the --module option (for AMD and SystemJS) since TypeScript 1.8, so this can be done natively. Here's the changelog .

Programmatically compile typescript in C#?

て烟熏妆下的殇ゞ 提交于 2019-12-02 20:42:16
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? 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 example and comments: using System; using System.Collections.Generic; using System.Diagnostics; using System