From 20b75a99e3de2bb73af482bbbfd3f4b27a434ca7 Mon Sep 17 00:00:00 2001 From: qiang Date: Tue, 27 Aug 2019 14:20:49 +0800 Subject: [PATCH] feat: add types --- generator.js | 27 ++++++++++++++------------- template/common-ts/tsconfig.json | 4 +++- template/common/tsconfig.json | 10 ++++++++++ 3 files changed, 27 insertions(+), 14 deletions(-) create mode 100644 template/common/tsconfig.json diff --git a/generator.js b/generator.js index 2988146..43342de 100644 --- a/generator.js +++ b/generator.js @@ -31,16 +31,19 @@ async function generate (dir, files, base = '', rootOptions = {}) { }) } -module.exports = (api, options, rootOptions) => { - api.extendPackage(pkg => { - return { - dependencies: { - 'regenerator-runtime': '^0.12.1'// 锁定版本,避免高版本在小程序中出错 - }, - devDependencies: { - 'postcss-comment': '^2.0.0' - } - } +module.exports = (api, options, rootOptions) => { + api.extendPackage(pkg => { + return { + dependencies: { + 'regenerator-runtime': '^0.12.1',// 锁定版本,避免高版本在小程序中出错 + '@dcloudio/uni-helper-json': '*' + }, + devDependencies: { + 'postcss-comment': '^2.0.0', + 'miniprogram-api-typings': '*', + 'mini-types': '*' + } + } }) if (options.template !== 'default-ts') { api.extendPackage(pkg => { @@ -86,7 +89,7 @@ module.exports = (api, options, rootOptions) => { const template = options.repo || options.template const base = 'src' - + await generate(path.resolve(__dirname, './template/common'), files) if (template === 'default') { await generate(path.resolve(__dirname, './template/default'), files, base, rootOptions) } else if (template === 'default-ts') { @@ -122,7 +125,5 @@ module.exports = (api, options, rootOptions) => { await generate(tmp, files, base) } - - await generate(path.resolve(__dirname, './template/common'), files) }) } diff --git a/template/common-ts/tsconfig.json b/template/common-ts/tsconfig.json index dfeadd6..7302934 100644 --- a/template/common-ts/tsconfig.json +++ b/template/common-ts/tsconfig.json @@ -13,7 +13,9 @@ "baseUrl": ".", "types": [ "webpack-env", - "@dcloudio/types/uni-app" + "@dcloudio/types/uni-app", + "miniprogram-api-typings", + "mini-types" ], "paths": { "@/*": [ diff --git a/template/common/tsconfig.json b/template/common/tsconfig.json new file mode 100644 index 0000000..7289402 --- /dev/null +++ b/template/common/tsconfig.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "types": [ + "uni-app", + "html5plus", + "miniprogram-api-typings", + "mini-types" + ] + } +}