The 'gatsby' Node module needs a type parameter appended to GatsbyAPIFunctionResponse #31135
Labels
topic: DX
Developer Experience (e.g. Fast Refresh, i18n, SSR, page creation, starters)
topic: TypeScript
Issues and PRs related to TS in general, public typings or gatsby-plugin-typescript
type: bug
An issue or pull request relating to a bug in Gatsby
Description
The latest version of Gatsby in NPM-land, 3.2.1, won't compile with the standard TypeScript compiler (i.e. by running
tsc
) because the "Type 'GatsbyAPIFunctionResponse' is not generic.".It appears the GatsbyAPIFunctionResponse interface from node_modules/gatsby/index.d.ts is automatically generated, as I can't find a single instance of it being created in the GitHub codebase. The interface simply needs the type parameter appended to it for the type to be correct.
Steps to reproduce
Opening up the
node_modules/gatsby/index.d.ts
file in any IDE will show the missing type parameter error.Incorrect type
/**
* Gatsby API Function route response
*/
export interface GatsbyAPIFunctionResponse extends ServerResponse {
/**
* Send "any" data in response
*/
send: Send<T>
/**
* Send "JSON" data in response
*/
json: Send<T>
/**
* Set the HTTP status code of the response
*/
status: (statusCode: number) => GatsbyAPIFunctionResponse<T>
redirect(url: string): GatsbyAPIFunctionResponse<T>
redirect(status: number, url: string): GatsbyAPIFunctionResponse<T>
}
Correct type
The GatsbyAPIFunctionResponse just needs the type parameter appended to it so the compiler knows what T means within the interface.
/**
* Gatsby API Function route response
*/
export interface GatsbyAPIFunctionResponse<T> extends ServerResponse {
...
}
The text was updated successfully, but these errors were encountered: