TypeScript——使用npm安装和编译

简介: TypeScript——使用npm安装和编译

前言

为了改造一个开源项目,安装typescript进行编译

内容

安装

npm install -g typescript
tsc -v

编译

tsc

命令参数

$ tsc --help
Version 4.2.4
Syntax:   tsc [options] [file...]
Examples: tsc hello.ts
          tsc --outFile file.js file.ts
          tsc @args.txt
          tsc --build tsconfig.json
Options:
 -h, --help                                         Print this message.
 -w, --watch                                        Watch input files.
 --pretty                                           Stylize errors and messages
using color and context (experimental).
 --all                                              Show all compiler options.
 -v, --version                                      Print the compiler's version
.
 --init                                             Initializes a TypeScript pro
ject and creates a tsconfig.json file.
 -p FILE OR DIRECTORY, --project FILE OR DIRECTORY  Compile the project given th
e path to its configuration file, or to a folder with a 'tsconfig.json'.
 -b, --build                                        Build one or more projects a
nd their dependencies, if out of date
 -t VERSION, --target VERSION                       Specify ECMAScript target ve
rsion: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019',
 'ES2020', or 'ESNEXT'.
 -m KIND, --module KIND                             Specify module code generati
on: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'.
 --lib                                              Specify library files to be
included in the compilation.
                                                      'es5' 'es6' 'es2015' 'es7'
 'es2016' 'es2017' 'es2018' 'es2019' 'es2020' 'esnext' 'dom' 'dom.iterable' 'web
worker' 'webworker.importscripts' 'webworker.iterable' 'scripthost' 'es2015.core
' 'es2015.collection' 'es2015.generator' 'es2015.iterable' 'es2015.promise' 'es2
015.proxy' 'es2015.reflect' 'es2015.symbol' 'es2015.symbol.wellknown' 'es2016.ar
ray.include' 'es2017.object' 'es2017.sharedmemory' 'es2017.string' 'es2017.intl'
 'es2017.typedarrays' 'es2018.asyncgenerator' 'es2018.asynciterable' 'es2018.int
l' 'es2018.promise' 'es2018.regexp' 'es2019.array' 'es2019.object' 'es2019.strin
g' 'es2019.symbol' 'es2020.bigint' 'es2020.promise' 'es2020.sharedmemory' 'es202
0.string' 'es2020.symbol.wellknown' 'es2020.intl' 'esnext.array' 'esnext.symbol'
 'esnext.asynciterable' 'esnext.intl' 'esnext.bigint' 'esnext.string' 'esnext.pr
omise' 'esnext.weakref'
 --allowJs                                          Allow javascript files to be
 compiled.
 --jsx KIND                                         Specify JSX code generation:
 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'.
 -d, --declaration                                  Generates corresponding '.d.
ts' file.
 --declarationMap                                   Generates a sourcemap for ea
ch corresponding '.d.ts' file.
 --sourceMap                                        Generates corresponding '.ma
p' file.
 --outFile FILE                                     Concatenate and emit output
to single file.
 --outDir DIRECTORY                                 Redirect output structure to
 the directory.
 --removeComments                                   Do not emit comments to outp
ut.
 --noEmit                                           Do not emit outputs.
 --strict                                           Enable all strict type-check
ing options.
 --noImplicitAny                                    Raise error on expressions a
nd declarations with an implied 'any' type.
 --strictNullChecks                                 Enable strict null checks.
 --strictFunctionTypes                              Enable strict checking of fu
nction types.
 --strictBindCallApply                              Enable strict 'bind', 'call'
, and 'apply' methods on functions.
 --strictPropertyInitialization                     Enable strict checking of pr
operty initialization in classes.
 --noImplicitThis                                   Raise error on 'this' expres
sions with an implied 'any' type.
 --alwaysStrict                                     Parse in strict mode and emi
t "use strict" for each source file.
 --noUnusedLocals                                   Report errors on unused loca
ls.
 --noUnusedParameters                               Report errors on unused para
meters.
 --noImplicitReturns                                Report error when not all co
de paths in function return a value.
 --noFallthroughCasesInSwitch                       Report errors for fallthroug
h cases in switch statement.
 --types                                            Type declaration files to be
 included in compilation.
 --esModuleInterop                                  Enables emit interoperabilit
y between CommonJS and ES Modules via creation of namespace objects for all impo
rts. Implies 'allowSyntheticDefaultImports'.
 @<file>                                            Insert command line options
and files from a file.

学无止境,谦卑而行.

目录
相关文章
|
2月前
|
缓存 资源调度 持续交付
在清空NPM缓存后,检查是否所有依赖都已正确安装
在清空NPM缓存后,检查是否所有依赖都已正确安装
|
11天前
|
资源调度 前端开发 JavaScript
React 安装(NPM)
10月更文挑战第6天
40 1
|
11天前
|
缓存 资源调度 持续交付
在清空NPM缓存后,我如何检查是否所有依赖都已正确安装?
【10月更文挑战第5天】在清空NPM缓存后,我如何检查是否所有依赖都已正确安装?
|
3月前
|
JavaScript 前端开发 开发工具
TypeScript的介绍,let age:number = xxx,可以直接看出数据类型,Type由微软开发,可以在任何浏览器和系统中运行,比较适合大型项目,TypeScript的安装
TypeScript的介绍,let age:number = xxx,可以直接看出数据类型,Type由微软开发,可以在任何浏览器和系统中运行,比较适合大型项目,TypeScript的安装
|
4天前
|
缓存 JavaScript 前端开发
拿下奇怪的前端报错(三):npm install卡住了一个钟- 从原理搞定安装的全链路问题
本文详细分析了 `npm install` 过程中可能出现的卡顿问题及解决方法,包括网络问题、Node.js 版本不兼容、缓存问题、权限问题、包冲突、过时的 npm 版本、系统资源不足和脚本问题等,并提供了相应的解决策略。同时,还介绍了开启全部日志、使用替代工具和使用 Docker 提供 Node 环境等其他处理方法。
|
29天前
9-14|npm install --global windows-build-tools 安装太慢了,能够指定国内源
9-14|npm install --global windows-build-tools 安装太慢了,能够指定国内源
|
9天前
|
JavaScript 索引
TypeScript(TS)安装指南与基础教程学习全攻略(二)
TypeScript(TS)安装指南与基础教程学习全攻略(二)
40 0
|
9天前
|
JavaScript 前端开发 安全
TypeScript(TS)安装指南与基础教程学习全攻略(一)
TypeScript(TS)安装指南与基础教程学习全攻略(一)
17 0
|
2月前
|
敏捷开发 缓存 前端开发
阿里云云效产品使用合集之前端打包时npm安装卡住一般是什么导致的
云效作为一款全面覆盖研发全生命周期管理的云端效能平台,致力于帮助企业实现高效协同、敏捷研发和持续交付。本合集收集整理了用户在使用云效过程中遇到的常见问题,问题涉及项目创建与管理、需求规划与迭代、代码托管与版本控制、自动化测试、持续集成与发布等方面。
|
2月前
|
缓存 资源调度 持续交付
在清空NPM缓存后,如何检查是否所有依赖都已正确安装
在清空NPM缓存后,如何检查是否所有依赖都已正确安装

推荐镜像

更多