-
-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve TsInfo support #34
base: main
Are you sure you want to change the base?
Conversation
Now expands type aliases and interfaces with literal only types. Also allows to expand inherited props. Example: ```mdx <TsInfo src='./Button.tsx' name='ButtonProps'` /> <TsInfo src='./Button.tsx' name='ButtonProps:*'` /> <TsInfo src='./Button.tsx' name='ButtonProps:AsProp'` /> <TsInfo src='./Button.tsx' name='ButtonProps:AsProp:BaseProps'` /> ``` Fixes vitejs#33
Thanks for your contribution!I will look into this in this week. There is some design detail I want to discuss: does this feature mean we need to support 'pulling' tsInfo from multiple files? Things will get very complicated(and slow) when it involve multiple files & project tsconfig & ts error. I want to avoid analyzing the whole ts project for a single tsInfo request. I think we should design some rules and restrictions to users. So that is feature can be simple and powerful. |
No, only the given file but typescript compiler is already pulling other modules to resolve the imported types.
Yes, I suggest following restrictions:
BTW, the MR has few issues. I am working on a better implementation. |
I want to encourage users to extract the types that they want to document into a seperate file tree (a minimal sub-project) that can be analyzed efficiently.
So that we can analyzed tsInfo from the To enforce this restriction, we should ensure only the explicit-granted files will be analyzed. We can pull in the files within the given directory by default. If users want to pull in another file, need to write a comment explicitly in the entry file to instruct this loader. A tool that we can consider: typescript-vfs. For even better performance, we can consider reusing same ts program between multiple tsInfo requests. For example:
These two requests can use the same ts program (with entry point being
That would be a great default behavor. I also suggest supporting comment directives like |
By the way, If you encounter problems like "virtule modules not supporting hmr", don't worry about it. I am planning a new fs-watching machanism to support hmr of all virtule modules (not only virtual page modules). |
Thanks for the updates. It's a really good project for documenting components. We have just started developing ui components so took a chance to use vite and vite-pages and the experience so far is really good. I would also love to see docz like Playground and Props to support live playground and PropTypes based properties listing. |
Now expands type aliases and interfaces with literal only types.
Also allows to expand inherited props.
Example:
Fixes #33