TypeStrong / fork-ts-checker-webpack-plugin

Webpack plugin that runs typescript type checker on a separate process.
MIT License
1.95k stars 240 forks source link

Vue SFC TS check was broken on vue2.7 #765

Closed iceprosurface closed 1 year ago

iceprosurface commented 2 years ago

Current behavior

https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/blob/main/src/typescript/extension/vue/type-script-vue-extension.ts#L113

vue2.7 hit isVueTemplateCompilerV3,but there is no descriptor on parsed

const parsed = compiler.parse(vueSourceText);

if (parsed.descriptor && parsed.descriptor.script) {
  const scriptV3 = parsed.descriptor.script;

parsed shows like following codes

 {
  source: undefined,
  filename: 'anonymous.vue',
  template: null,
  script: null,
  scriptSetup: null,
  styles: [],
  customBlocks: [],
  cssVars: [],
  errors: [],
  shouldForceReload: [Function (anonymous)]
}

So that any ts check on vue will fail.

export { default as FilteredSearchToken } from './FilteredSearchToken.vue';
image

Error shows:

TS2322: Type '{}' is not assignable to type 'VueConstructor<Vue<Record<string, any>, Record<string, any>, never, never, never, never, (event: string, ...args: any[]) => Vue<Record<string, any>, Record<string, any>, ... 4 more ..., ...>>>'.

Expected behavior

Checker should work fine.

Steps to reproduce the issue

yarn serve

Issue reproduction repository

https://github.com/iceprosurface/vue2.7-tsx-error

Environment

piotr-oles commented 1 year ago

I'm dropping support for Vue.js. For the last few years, support for Vue.js has been broken, and the implementation of Vue.js integration was a hacky work-around. Unfortunately, TypeScript doesn't expose an API to do that properly, and while I created a https://github.com/microsoft/TypeScript/issues/38736 on the TypeScript repository, the TypeScript team has other priorities. As I won't have time to support this feature and am receiving justified bug reports, I believe it's better to make it clear that Vue.js is not supported by the plugin instead of pretending that it is.