-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
docs: add jsdoc comments to plugin/generator types #4644
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
base: main
Are you sure you want to change the base?
Conversation
View your CI Pipeline Execution ↗ for commit 0364a41
☁️ Nx Cloud last updated this comment at |
More templates
@tanstack/arktype-adapter
@tanstack/directive-functions-plugin
@tanstack/eslint-plugin-router
@tanstack/history
@tanstack/react-router
@tanstack/react-router-devtools
@tanstack/react-router-with-query
@tanstack/react-start
@tanstack/react-start-client
@tanstack/react-start-plugin
@tanstack/react-start-server
@tanstack/router-cli
@tanstack/router-core
@tanstack/router-devtools
@tanstack/router-devtools-core
@tanstack/router-generator
@tanstack/router-plugin
@tanstack/router-utils
@tanstack/router-vite-plugin
@tanstack/server-functions-plugin
@tanstack/solid-router
@tanstack/solid-router-devtools
@tanstack/solid-start
@tanstack/solid-start-client
@tanstack/solid-start-plugin
@tanstack/solid-start-server
@tanstack/start-client-core
@tanstack/start-plugin-core
@tanstack/start-server-core
@tanstack/start-server-functions-client
@tanstack/start-server-functions-fetcher
@tanstack/start-server-functions-server
@tanstack/valibot-adapter
@tanstack/virtual-file-routes
@tanstack/zod-adapter
commit: |
we could assert type equality using this // copied from https://github.com/sindresorhus/type-fest/blob/4d7cc50fbec6ae631fca98ae8d7e498f0d5f61ab/source/is-equal.d.ts#L27
type IsEqual<A, B> =
(<G>() => G extends A & G | G ? 1 : 2) extends
(<G>() => G extends B & G | G ? 1 : 2)
? true
: false;
type Expect<T extends true> = T;
// this would error if X and Y are not equal
type E = Expect<IsEqual<X,Y>> |
|
||
export type Config = z.infer<typeof configSchema> | ||
export type Config = z.output<typeof configSchema> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export type Config = z.output<typeof configSchema> | |
export type ValidatedConfig = z.output<typeof configSchema> |
|
||
export const getConfig = (inlineConfig: Partial<Config>, root: string) => { | ||
export const getConfig = (inlineConfig: ConfigInput, root: string) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be unknown
yeah?
export const getConfig = (inlineConfig: ConfigInput, root: string) => { | |
export const getConfig = (inlineConfig: unknown, root: string) => { |
Also, please see the conflict with |
This PR adds JSDoc comments to the plugin/bundle config options, as discussed in #3790, giving usage hints inline and to hopefully pave the way for auto generated docs too.
The content for these docs were largely copied directly from the Router API docs with some tweaks to make it logical in the code context.
No logic changes have been made, purely type annotations.
Note about Zod
When adding JSDoc comments to fields with Zod, they are lost when using the
z.input
utility types (issue). To get around this, an interface is created, which is annotated with JSDoc, and then the accuracy of this is checked against again the schema withsatisfies
. This interface is then using for the type arguments in the plugin/generator.A small drawback in this approach is that the compiler won't detect extraneous options being added to the schema.
Example output:
