Skip to content
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

Sync types of NextNodeServer and BaseServer #62694

Open
wants to merge 1 commit into
base: canary
Choose a base branch
from

Conversation

alecmev
Copy link

@alecmev alecmev commented Feb 29, 2024

Otherwise these don't pass with exactOptionalPropertyTypes: true and skipLibCheck: false:

TypeScript output
node_modules/next/dist/server/next-server.d.ts:66:15 - error TS2416: Property 'sendRenderResult' in type 'NextNodeServer' is not assignable to the same property in base type 'Server<Options>'.
  Type '(req: NodeNextRequest, res: NodeNextResponse, options: { result: RenderResult<RenderResultMetadata>; type: "json" | "html"; generateEtags: boolean; poweredByHeader: boolean; revalidate: Revalidate | undefined; }) => Promise<...>' is not assignable to type '(req: BaseNextRequest<any>, res: BaseNextResponse<any>, options: { result: RenderResult<RenderResultMetadata>; type: "json" | ... 1 more ... | "rsc"; generateEtags: boolean; poweredByHeader: boolean; revalidate?: Revalidate; }) => Promise<...>'.
    Types of parameters 'options' and 'options' are incompatible.
      Type '{ result: RenderResult<RenderResultMetadata>; type: "json" | "html" | "rsc"; generateEtags: boolean; poweredByHeader: boolean; revalidate?: Revalidate; }' is not assignable to type '{ result: RenderResult<RenderResultMetadata>; type: "json" | "html"; generateEtags: boolean; poweredByHeader: boolean; revalidate: Revalidate | undefined; }'.
        Types of property 'type' are incompatible.
          Type '"json" | "html" | "rsc"' is not assignable to type '"json" | "html"'.
            Type '"rsc"' is not assignable to type '"json" | "html"'.

66     protected sendRenderResult(req: NodeNextRequest, res: NodeNextResponse, options: {
                 ~~~~~~~~~~~~~~~~

node_modules/next/dist/server/next-server.d.ts:82:15 - error TS2416: Property 'renderPageComponent' in type 'NextNodeServer' is not assignable to the same property in base type 'Server<Options>'.
  Type '(ctx: RequestContext, bubbleNoFallback: boolean) => Promise<false | { type: "json" | "html" | "rsc"; body: RenderResult<RenderResultMetadata>; revalidate?: Revalidate | undefined; } | null>' is not assignable to type '(ctx: RequestContext, bubbleNoFallback: boolean) => Promise<false | ResponsePayload | null>'.
    Type 'Promise<false | { type: "json" | "html" | "rsc"; body: RenderResult<RenderResultMetadata>; revalidate?: Revalidate | undefined; } | null>' is not assignable to type 'Promise<false | ResponsePayload | null>'.
      Type 'false | { type: "json" | "html" | "rsc"; body: RenderResult<RenderResultMetadata>; revalidate?: Revalidate | undefined; } | null' is not assignable to type 'false | ResponsePayload | null'.
        Type '{ type: "json" | "html" | "rsc"; body: RenderResult<RenderResultMetadata>; revalidate?: Revalidate | undefined; }' is not assignable to type 'false | ResponsePayload | null'.
          Type '{ type: "json" | "html" | "rsc"; body: RenderResult<RenderResultMetadata>; revalidate?: Revalidate | undefined; }' is not assignable to type 'ResponsePayload' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
            Types of property 'revalidate' are incompatible.
              Type 'Revalidate | undefined' is not assignable to type 'Revalidate'.
                Type 'undefined' is not assignable to type 'Revalidate'.

82     protected renderPageComponent(ctx: RequestContext, bubbleNoFallback: boolean): Promise<false | {
                 ~~~~~~~~~~~~~~~~~~~

node_modules/next/dist/server/next-server.d.ts:135:15 - error TS2416: Property 'renderErrorToResponseImpl' in type 'NextNodeServer' is not assignable to the same property in base type 'Server<Options>'.
  Type '(ctx: RequestContext, err: Error | null) => Promise<{ type: "json" | "html" | "rsc"; body: RenderResult<RenderResultMetadata>; revalidate?: Revalidate | undefined; } | null>' is not assignable to type '(ctx: RequestContext, err: Error | null) => Promise<ResponsePayload | null>'.
    Type 'Promise<{ type: "json" | "html" | "rsc"; body: RenderResult<RenderResultMetadata>; revalidate?: Revalidate | undefined; } | null>' is not assignable to type 'Promise<ResponsePayload | null>'.
      Type '{ type: "json" | "html" | "rsc"; body: RenderResult<RenderResultMetadata>; revalidate?: Revalidate | undefined; } | null' is not assignable to type 'ResponsePayload | null'.
        Type '{ type: "json" | "html" | "rsc"; body: RenderResult<RenderResultMetadata>; revalidate?: Revalidate | undefined; }' is not assignable to type 'ResponsePayload' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
          Types of property 'revalidate' are incompatible.
            Type 'Revalidate | undefined' is not assignable to type 'Revalidate'.

135     protected renderErrorToResponseImpl(ctx: RequestContext, err: Error | null): Promise<{
                  ~~~~~~~~~~~~~~~~~~~~~~~~~

I don't know how to add tests for this, as this repo isn't using exactOptionalPropertyTypes.

@ijjk
Copy link
Member

ijjk commented Apr 27, 2024

Allow CI Workflow Run

  • approve CI run for commit: 1cf61d0

Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer

@alecmev
Copy link
Author

alecmev commented Apr 27, 2024

Still relevant in 14.2.3.

Otherwise these don't pass with `exactOptionalPropertyTypes: true` and
`skipLibCheck: false`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants