vuejs / component-compiler-utils

Lower level utilities for compiling Vue single file components
319 stars 75 forks source link

typescript definition for SFCDescriptor isn't compatible with vue-template-compiler #88

Open tjx666 opened 4 years ago

tjx666 commented 4 years ago

SFCDescriptor in component-compiler-utils: screenshot_2020-05-18_11-37-30

SFCDescriptor in vue-template-compiler: screenshot_2020-05-18_11-37-30

result:

Type 'typeof import("c:/code/vscode-fe-helper/node_modules/vue-template-compiler/types/index")' is not assignable to type 'VueTemplateCompiler'.
  The types of 'parseComponent(...).template' are incompatible between these types.
    Type 'SFCBlock | undefined' is not assignable to type 'SFCBlock | null'.
      Type 'undefined' is not assignable to type 'SFCBlock | null'

screenshot_2020-05-18_11-37-30

simonhaenisch commented 2 years ago

Similar issue for SFCBlock:

const { parse } = require('@vue/component-compiler-utils');
const compiler = require('vue-template-compiler');

const parsed = parse({
  source,
  compiler, // <-- TypeScript complains here
});
Type 'typeof import("node_modules/vue-template-compiler/types/index")' is not assignable to type 'VueTemplateCompiler'.
  The types of 'parseComponent(...).template' are incompatible between these types.
    Type 'import("node_modules/vue-template-compiler/types/index").SFCBlock' is not assignable to type 'import("node_modules/@vue/component-compiler-utils/dist/parse").SFCBlock'.
      Property 'start' is optional in type 'SFCBlock' but required in type 'SFCBlock'.

Everything runs fine though, it's just a type incompatibility.