如何生成tsconfig。Json通过命令行? 我尝试命令tsc init,但这不起作用。
当前回答
对于那些已经将TypeScript安装为本地包(也可能是作为开发依赖项)的人来说:
$ npm install typescript --save-dev
...以及谁在package.json中添加了TSC脚本:
"scripts": {
...
"tsc": "tsc"
},
你可以通过npm调用tsc——init:
$ npm run tsc -- --init
其他回答
以防有人来这里找我要找的东西,tsconfig。Json文件,有更多选项
npx tsconfig.json
对我不起作用,所以
npx tsconfig.json.cmd
给了我tsconfig。json文件,我正在寻找提供更多的选项
这在Windows上很管用
我建议先用下面的命令卸载typescript:
npm uninstall -g typescript
然后使用巧克力包来运行:
choco install typescript
在PowerShell。
从2实施。您可以在.zshrc或.bashrc中添加一个函数,以快捷方式到本地bin路径。
# in .zshrc:
function npm-do { (PATH=$(npm bin):$PATH; eval $@;) }
# working inside your directory:
npm-do tsc --init
如果你不想全局安装TypeScript(这对我来说是有意义的,所以你不需要经常更新它),你可以使用npx:
npx -p typescript tsc --init
关键是使用-p标志通知npx tsc二进制文件属于typescript包。
按以下步骤安装ts项目:
安装typescript yarn global 创建一个包。Json:运行yarn init或设置默认值yarn init -yp 创建一个tsconfig。Json: TSC——init (*可选)添加tslint.json
项目结构如下:
│ package.json
│ tsconfig.json
│ tslint.json
│ yarn.lock
│
├─dist
│ index.js
│
└─src
index.ts
推荐文章
- 从元组/数组值派生联合类型
- 如何在Angular2 ngSwitch语句中使用typescript enum值
- 找到合成属性@panelState。请在您的应用程序中包含“BrowserAnimationsModule”或“NoopAnimationsModule”。
- Angular 2+和debounce
- 在TypeScript箭头函数中指定返回类型
- 如何使用jQuery与TypeScript
- Angular 2模板中的标签是什么意思?
- Typescript接口-可能使“一个或另一个”属性要求?
- 如何扩展/继承组件?
- 错误:'types'只能在.ts文件中使用- Visual Studio Code使用@ts-check
- Typescript ReferenceError: exports没有定义
- React组件中使用TypeScript的默认属性值
- Angular 5 -复制到剪贴板
- TypeScript枚举对象数组
- Angular 2显示和隐藏一个元素