johnsoncodehk / vue-tsc

vue-tsc --noEmit && vite build
https://www.npmjs.com/package/vue-tsc
MIT License
241 stars 6 forks source link

TypeError when using HTMLElement #50

Closed slauzinho closed 3 years ago

slauzinho commented 3 years ago

I got an issue with the new vue-tsc version 0.2.2. If I have this code:

const card = ref<HTMLElement | string>('');
const logCardInfo = (card: Ref<HTMLElement | string>) => {
  console.log(card.value);
}
logCardInfo(card); // This line gives a typescript error

I get the following typescript error:

Argument of type 'Ref<string | { accessKey: string; readonly accessKeyLabel: string; autocapitalize: string; dir: string; draggable: boolean; hidden: boolean; innerText: string; lang: string; readonly offsetHeight: number; ... 233 more ...; focus: (options?: FocusOptions | undefined) => void; }>' is not assignable to parameter of type 'Ref<string | HTMLElement>'.

I also creted a demo app with a repro: https://github.com/slauzinho/vue-tsc-demo-app/blob/master/src/App.vue

vue version: 3.1.5 vue-tsc version: 0.2.2 typescript version: 4.3.5

Had no issues with vue-tsc 0.2.1

johnsoncodehk commented 3 years ago

This is vue 3.1.5 ref type problem, vue 3.2 beta fixed it.