-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
docs: add jsdoc comments to plugin/generator types #4204
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
Conversation
RELEASE_ALL
RELEASE_ALL
Currently, none of the packages (i.e `packages/*`) need `vite` bundled as a `dependency`. So its been moved to the `devDependencies` and had the version opened using `"peerDependencies": { "vite": ">=6.0.0" }`. Additionally, `vite` has been added as a `dependency` to the Start end-to-end sandboxes. In a later PR, `vite` will need to be added to all the TanStack Start examples (i.e. `examples/**/start-*`).
…anStack#4137) Only import `routeCode` if `node.fullPath` is available.
…t + matching server function handler route on Windows (TanStack#4146)
> = (options = {}) => { | ||
let ROOT: string = process.cwd() | ||
|
||
let userConfig = options as Config |
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.
As an unrelated point, this type casting here is risky. Config
is the z.output
type, which will contain defined properties due to the default option, but what's being passed it hasn't been parsed by Zod yet (and so is the z.input
type).
For example, userConfig.routesDirectory
may not have been defined yet, so the usage on L24-26 is unsafe.
There is some complexity here, because we can't immediately parse the provided schema, as there may be later config retrieved from a tsr.config.ts
file (here), and the default values would override anything provided in the config file. This could be fixed by allowing the file config to override the inline config, if that is the desired hierarchy.
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
…onventions (TanStack#4226) Renames the following virtual modules as such to have them be both consistent and more easily readable should there be an error when importing them. | Before | After | |--------|--------| | `tanstack:server-fn-manifest` | `tanstack-start-server-fn-manifest:v` | | `tanstack:start-manifest` | `tanstack-start-router-manifest:v` | | `tanstack:server-rotues` | `tanstack-start-server-routes-manifest:v` | Additionally, the [Rollup convention for resolving virtual modules](https://vite.dev/guide/api-plugin#virtual-modules-convention) is being applied to these modules.
…able (TanStack#4232) As part of the devinxi changes, the following hard-coded output path of the server functions manifest file was changed. This would have had breaking changes in the user DX for downstream frameworks building upon the `@tanstack/server-functions-plugin` package - (i.e. SolidStart). This change makes the output path of the manifest file for the `server-functions-plugin` package, configurable.
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.
IDK if tanstack team wants to add them but I'm all for it 👍
@@ -2,6 +2,192 @@ import path from 'node:path' | |||
import { existsSync, readFileSync } from 'node:fs' | |||
import { z } from 'zod' | |||
import { virtualRootRouteSchema } from './filesystem/virtual/config' | |||
import type { VirtualRootRoute } from '@tanstack/virtual-file-routes' | |||
|
|||
export interface ConfigOptions { |
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.
big fan of this, helps a lot when in middle of coding :)
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.
There's some discrepancy with how input vs. output types are used here, but I believe that may be intentional? (see PR comments).
Example output:
