phoenix-ru / fervid

All-in-One Vue compiler written in Rust

Home Page:https://phoenix-ru.github.io/fervid/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Research TS development experience

phoenix-ru opened this issue · comments

I am still not sure how TS is used in the official compiler to generate .d.ts of .vue files. It uses defineComponent in the generated code but I want to find a balance between generating the most optimal code (i.e. omitting defineComponent) and supporting TS definitions.

Spec:
https://github.com/vuejs/core/blob/main/packages/compiler-sfc/__tests__/compileScript.spec.ts#L1393-L1424

Tasks:

  • Implement defineComponent when in TS mode;
  • Add any to some parameters and variables:
    • __props impl
    • __temp and __restore impl (todo because no context restoration is present)
  • Implement type-only defineProps;
    • Also implement withDefaults
  • Implement type-only defineEmits

Supporting imported types in defineProps and defineEmits requires filesystem access -> a filesystem interface needs to be provided to compiler similar to https://github.com/vuejs/core/blob/ae97e5053895eeaaa443306e72cd8f45da001179/packages/compiler-sfc/src/script/resolveType.ts#L849-L875