Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vite使用v3.8.0的create-vue生成的Vue模板使用该插件无法生成正确的类型文件 #282

Open
3 tasks done
zhangyangeng opened this issue Nov 13, 2023 · 2 comments

Comments

@zhangyangeng
Copy link

zhangyangeng commented Nov 13, 2023

Describe the bug

开发者,您好。
当我在使用最新版本的create-vue生成项目时 vuejs/tsconfig 的版本为 v0.4.0,而 0.3.0版本之后的 tsconfig 文件被分成了 tsconfig.json /tsconfig.app.json/tsconfig.node.json ,这是 tsconfig.jsontsconfig.app.json 的默认设置:

{
  "files": [],
  "references": [
    {
      "path": "./tsconfig.node.json"
    },
    {
      "path": "./tsconfig.app.json"
    }
  ]
}
{
  "extends": "@vue/tsconfig/tsconfig.dom.json",
  "include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
  "exclude": ["src/**/__tests__/*"],
  "compilerOptions": {
    "composite": true,
    "baseUrl": ".",
    "paths": {
      "@/*": ["./src/*"]
    }
  }
}

当我使用默认配置并引用该插件之后插件并没有生效,同时我在插件的源码中打印之后看到读取的是 tsconfig.json 的配置而不是 tsconfig.app.json

{
  options: {
    configFilePath: 'E:/PSAE/Shared/SharedFrontEndVite/tsconfig.json',
    outDir: undefined
  },
  watchOptions: undefined,
  fileNames: [],
  projectReferences: [
    {
      path: 'E:/PSAE/Shared/SharedFrontEndVite/tsconfig.node.json',
      originalPath: './tsconfig.node.json',
      prepend: undefined,
      circular: undefined
    },
    {
      path: 'E:/PSAE/Shared/SharedFrontEndVite/tsconfig.app.json',
      originalPath: './tsconfig.app.json',
      prepend: undefined,
      circular: undefined
    }
  ],
  typeAcquisition: { enable: false, include: [], exclude: [] },
  // 这里读取的还是 tsconfig.json 的配置
  raw: { files: [], references: [ [Object], [Object] ] },
  errors: [],
  wildcardDirectories: {},
  compileOnSave: false,
  vueOptions: { target: 3.3 }
}

想问下这应该是插件的兼容问题还是create-vue的问题呀?
现在手动配置tsconfig路径是可以正常使用的,如下:

dts({
      tsconfigPath: 'tsconfig.app.json'
 }),

Reproduction

Steps to reproduce

No response

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i5-11320H @ 3.20GHz
    Memory: 2.15 GB / 15.74 GB
  Binaries:
    Node: 16.14.2 - D:\Program Files\nodejs\node.EXE
    npm: 8.5.0 - D:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.3570.0), Chromium (119.0.2151.58)
    Internet Explorer: 11.0.19041.3570
  npmPackages:
    @vitejs/plugin-vue: ^4.4.0 => 4.4.0
    @vitejs/plugin-vue-jsx: ^3.0.2 => 3.0.2
    vite: ^4.4.11 => 4.5.0
    vite-plugin-dts: ^3.6.3 => 3.6.3

Validations

@qmhc
Copy link
Owner

qmhc commented Nov 30, 2023

因为 tsconfig.jsonfiles 指定为空数组,所以它不包含任何文件。

@zhangyangeng
Copy link
Author

因为 tsconfig.jsonfiles 指定为空数组,所以它不包含任何文件。

您好,files字段不是用来指定需要编译的文件范围吗?这个问题更像是读取tsconfig的配置时没有找到真正想要加载的tsconfig文件呢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants