如何生成tsconfig。Json通过命令行? 我尝试命令tsc init,但这不起作用。
当前回答
我在用这个,
yarn add -D typescript
yarn tsc --init
这为我解决了问题
其他回答
对于那些已经将TypeScript安装为本地包(也可能是作为开发依赖项)的人来说:
$ npm install typescript --save-dev
...以及谁在package.json中添加了TSC脚本:
"scripts": {
...
"tsc": "tsc"
},
你可以通过npm调用tsc——init:
$ npm run tsc -- --init
我在用这个,
yarn add -D typescript
yarn tsc --init
这为我解决了问题
运行TSC -- --init 这适用于下面的package.json
"devDependencies": {
"@types/jasmine": "^3.6.2",
"@types/node": "^14.14.19",
"jasmine": "^3.6.3",
"protractor": "^7.0.0",
"typescript": "^4.1.3"
},
这招对我很管用:
tsc --init
从2实施。您可以在.zshrc或.bashrc中添加一个函数,以快捷方式到本地bin路径。
# in .zshrc:
function npm-do { (PATH=$(npm bin):$PATH; eval $@;) }
# working inside your directory:
npm-do tsc --init
推荐文章
- 错误:'types'只能在.ts文件中使用- Visual Studio Code使用@ts-check
- Typescript ReferenceError: exports没有定义
- React组件中使用TypeScript的默认属性值
- Angular 5 -复制到剪贴板
- TypeScript枚举对象数组
- Angular 2显示和隐藏一个元素
- 具有构造签名的接口如何工作?
- 'React'指的是一个UMD全局,但当前文件是一个模块
- Angular 2中的“component”不是一个已知的元素
- TypeScript错误:属性“X”在类型“Window”上不存在
- 我怎么能计算在打字稿2日期之间的时间
- 正确使用错误
- 如何修复TS2322:“可以实例化与约束'对象'的不同子类型”?
- 如何在Angular中动态加载外部脚本?
- 当组件属性依赖于当前日期时间时,如何管理Angular2“expression has changed after it was checked”异常