unplugin-dts icon indicating copy to clipboard operation
unplugin-dts copied to clipboard

有没有办法支持scopedSlots props?

Open ccqgithub opened this issue 3 years ago • 4 comments

貌似生成的.vue.d.ts文件中没有scopedSlots props的类型信息?

Volar在本项目中引用vue文件时,有提示slots类型,生成库之后第三方引用组件时,slot props 变为了any

相关issue: https://github.com/johnsoncodehk/volar/discussions/640

ccqgithub avatar Apr 10 '22 09:04 ccqgithub

目前暂时没法办支持,在编译 vue 文件时只把 <script> 的内容作为主体得到 ts 代码,<template> 的内容没有参与。

不过我看现在 <template> 中也支持 ts,或许有办法在编译时加入模版的内容。空闲的时候我会做一些尝试,这个 issue 可以保持打开用来跟进。

qmhc avatar Apr 11 '22 04:04 qmhc

目前暂时没法办支持,在编译 vue 文件时只把 <script> 的内容作为主体得到 ts 代码,<template> 的内容没有参与。

不过我看现在 <template> 中也支持 ts,或许有办法在编译时加入模版的内容。空闲的时候我会做一些尝试,这个 issue 可以保持打开用来跟进。

谢谢,我看volar同一个项目的时候可以支持template slot 提示,不知道咋做到的。

ccqgithub avatar Apr 11 '22 08:04 ccqgithub

我快速的检索了一下 volar,似乎是用更加底层的 ast 树进行分析的。

这个插件仅仅是用 veu/compiler-sfc 进来 vue 文件的编译,将其中的 <script> 部分推入 ts,整体逻辑并不复杂。

我个人在 ast 树这一块也并不是很熟悉 😂


刚刚我也试了 veu/compiler-sfc 编译 <template> 的内容,但其并不能得到模版中的类型信息。

qmhc avatar Apr 11 '22 09:04 qmhc

我快速的检索了一下 volar,似乎是用更加底层的 ast 树进行分析的。

这个插件仅仅是用 veu/compiler-sfc 进来 vue 文件的编译,将其中的 <script> 部分推入 ts,整体逻辑并不复杂。

我个人在 ast 树这一块也并不是很熟悉 😂

刚刚我也试了 veu/compiler-sfc 编译 <template> 的内容,但其并不能得到模版中的类型信息。

Vue 本身应该是没有的,因为我看DefineComponent 里都没有slots信息,应该是volar自己做的。不过最近几个版本的volar又不提示了, 看来得等vue类型增强了😂

ccqgithub avatar Apr 19 '22 10:04 ccqgithub