Closed stafyniaksacha closed 1 year ago
I let you review @farnabaz once you got some time :)
We need to iterate on resolving non-primitive types. Importing external types, enums...
@stafyniaksacha Do you think this should wait for vue-typescript
?
Do you think this should wait for vue-typescript?
Hum, I think not, we can not have any ETA for this, so it can be a good thing to start iterate without it.
@Atinux @farnabaz I did some improvements I'm finally happy with props detection done in https://github.com/johnsoncodehk/volar/pull/1637
What do you think about the schema
format?
cc @kevinmarrec as well for the visual editor
Also @Tahul
So far I like the schema, seems a bit verbose but give nice informations :rocket:
I'm fine with any schema, we'll adapt our editor and can benefit of extra information :)
There is still an issue when resolving inline type aliases (see: https://github.com/johnsoncodehk/volar/blob/master/packages/vue-component-meta/tests/index.spec.ts#L237-L251 / https://github.com/johnsoncodehk/volar/blob/master/packages/vue-component-meta/src/index.ts#L80)
So many things are objects, so it comes with a recursive nightmare.
Also, the defaults values are still not available
Extracting props from compiled sfc will always return base runtimes types because
defineProps
anddefineEmits
will be resolved intodefineComponent
props and emits options. compileScript.ts#L1763-L1848Also, we can note that compiler-sfc use babel parser internally and not typescript.
The idea would be to walk through original typescript ASTs to retrieve as much information as the developer provided (we may have typed strings, typed objects/arrays, reuse other components props, ...)
A better way would be to create a program context instead of using ASTs, so typescript can resolve imports for us and resolve type for anything for us, more precisely that we can do with AST).
This would require to use
vue-typescript
from volar which needs some tweaks before (see https://github.com/johnsoncodehk/volar/issues/1506)