diff --git a/generator.js b/generator.js index 0f423e5..25b9d7d 100644 --- a/generator.js +++ b/generator.js @@ -46,7 +46,7 @@ module.exports = (api, options, rootOptions) => { devDependencies: { "@babel/runtime": "~7.17.9",// 临时指定版本,7.13.x 会报错 'postcss-comment': '^2.0.0', - '@dcloudio/types': '^2.6.7', + '@dcloudio/types': '^3.0.4', 'miniprogram-api-typings': '*', 'mini-types': '*' }, @@ -94,6 +94,17 @@ module.exports = (api, options, rootOptions) => { } else if (template === 'default-ts') { await generate(path.resolve(__dirname, './template/common-ts'), files) await generate(path.resolve(__dirname, './template/default-ts'), files, base, rootOptions) + + // default-ts 模板删除 jsconfig.json + process.nextTick(() => { + const folderPath = path.resolve(process.cwd(),rootOptions.projectName) + const jsconfigPath = path.resolve(folderPath,'./jsconfig.json') + const tsconfigPath = path.resolve(folderPath,'./tsconfig.json') + + if(fs.existsSync(jsconfigPath) && fs.existsSync(tsconfigPath)){ + fs.unlinkSync(jsconfigPath) + } + }) } else { const ora = require('ora') const home = require('user-home') diff --git a/template/common/tsconfig.json b/template/common/jsconfig.json similarity index 100% rename from template/common/tsconfig.json rename to template/common/jsconfig.json diff --git a/template/common/sfc.d.ts b/template/common/sfc.d.ts new file mode 100644 index 0000000..c22cbc2 --- /dev/null +++ b/template/common/sfc.d.ts @@ -0,0 +1,11 @@ +import Vue from 'vue' + +declare module "vue/types/options" { + type Hooks = App.AppInstance & Page.PageInstance; + interface ComponentOptions extends Hooks { + /** + * 组件类型 + */ + mpType?: string; + } +} \ No newline at end of file diff --git a/template/default-ts/pages/index/index.vue b/template/default-ts/pages/index/index.vue index f20fe5b..7a086d7 100644 --- a/template/default-ts/pages/index/index.vue +++ b/template/default-ts/pages/index/index.vue @@ -8,7 +8,8 @@