安装
quick-module
现在的想法是,先全局安装使用,这样的话可以不用在已有的项目中添加依赖:
npm i -g quick-module
然后使用的方法是:
qmc <options> // qmc: quick module compiler
现有的命令选项:
Options:
-V, --version output the version number
-c, --compile <file_name/dir_name> compile (all) tsx file
-w, --watch <file_name/dir_name> watch and compile tsx file
-h, --help
具体例子:
qmc -c ./demo.tsx 翻译demo.tsx文件
qmc -c ./src 翻译src目录下所有tsx文件
qmc -w ./demo.tsx 监控demo.tsx文件,有变动就翻译它
qmc -w ./src 监控src目录下所有tsx文件,翻译变动的文件
quick-types
npm i -D quick-types
然后在项目根目录下创建tsconfig.json文件,里面的内容为:
{
"compilerOptions": {
"typeRoots": [
"./node_modules"
],
"jsx": "preserve"
}
}
本来包应该发布成@types/quickapp这样,就可以不用加json文件,它自己知道去node_moduels/@types找类型定义文件。
但是包名用@types开头的话,要去github DefinitelyTyped发pull request才行,暂时还没弄,所以先这样了。。