feat: add types

This commit is contained in:
qiang 2019-08-27 14:20:49 +08:00
parent b8774b1f8a
commit 20b75a99e3
3 changed files with 27 additions and 14 deletions

View File

@ -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)
})
}

View File

@ -13,7 +13,9 @@
"baseUrl": ".",
"types": [
"webpack-env",
"@dcloudio/types/uni-app"
"@dcloudio/types/uni-app",
"miniprogram-api-typings",
"mini-types"
],
"paths": {
"@/*": [

View File

@ -0,0 +1,10 @@
{
"compilerOptions": {
"types": [
"uni-app",
"html5plus",
"miniprogram-api-typings",
"mini-types"
]
}
}