Subscribe on changes!

interface Props works, but type Props does not

avatar
Apr 16th 2022

Version

3.2.31

Reproduction link

demo1

Steps to reproduce

Steps

  1. git checkout demo1

  2. pnpm i

  3. open main.tsx

  4. there is a error hint at line 19

    src/main.tsx:19:33 - error TS2322: Type '() => number' is not assignable to type 'void'.
    
    19 const app = createApp(<div><App onClick={() => 1} /></div>)
    
  5. comment out type Props(lines 7 ~ 9), uncomment interface Props(lines 4 ~ 6), then it works without errors.

What is expected?

type Props works without type errors in code below

type Props = {
  onClick: () => void
}

const App = defineComponent<Props>({
  setup() {
    return () => (
      <div>App</div>
    )
  }
})

const app = createApp(<div><App onClick={() => 1} /></div>)
app.mount('#app')

What is actually happening?

type Props does not work as expected

avatar
Apr 16th 2022

edit: I misread your issue. reopened