core icon indicating copy to clipboard operation
core copied to clipboard

feat(runtime-core): support "exposed" type constraints via paradigm

Open jason-chang opened this issue 2 years ago • 1 comments

jason-chang avatar Dec 13 '22 08:12 jason-chang

You can use satisfies operator with TypeScript 4.9 instead, to constraint exposed type. Also, please create an issue before PR.

For example:

defineComponent({
  setup(props, { expose }) {
    expose({
      foo: 1,
    } satisfies { foo: boolean })
  },
})

sxzz avatar Dec 13 '22 17:12 sxzz

@sxzz Thanks for the suggestion, but if I use typescript before version 4.9, my decision should be in the right direction, right?

jason-chang avatar Dec 16 '22 08:12 jason-chang

@jason-chang Not really necessary.

defineComponent({
  setup(props, { expose }) {
    const exposed: Type = { foo: 1 }
    expose(exposed)
  },
})

sxzz avatar Dec 17 '22 13:12 sxzz