首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >TypeScript——使用npm安装和编译

TypeScript——使用npm安装和编译

作者头像
思索
发布2024-08-16 14:38:58
发布2024-08-16 14:38:58
5610
举报

前言

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

内容

安装

代码语言:javascript
复制
npm install -g typescript
tsc -v

编译

代码语言:javascript
复制
tsc

命令参数

代码语言:javascript
复制
$ 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.
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2021-04-14,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 前言
  • 内容
    • 安装
    • 编译
    • 命令参数
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档