wingleung / remix-aws

AWS adapter for Remix
https://www.npmjs.com/package/remix-aws
MIT License
21 stars 6 forks source link

Type incompatibility with Remix 2.0.1 #4

Closed brettdh closed 8 months ago

brettdh commented 8 months ago

Thanks for making this!

Using Remix 2.0.1, the adapter seems to work, but I see type incompatibility that mentions remix-aws when running tsc:

➜ npm run typecheck

> typecheck
> tsc && tsc -p cypress

server.ts:14:3 - error TS2322: Type 'typeof import("/path/to/project/node_modules/@remix-run/dev/server-build")' is not assignable to type 'ServerBuild'.
  The types of 'entry.module.default' are incompatible between these types.
    Type 'import("/path/to/project/node_modules/@remix-run/server-runtime/dist/build").HandleDocumentRequestFunction'.
      Types of parameters 'context' and 'context' are incompatible.
        Type 'import("/path/to/project/node_modules/@remix-run/server-runtime/dist/entry").EntryContext'.
          Types of property 'routeModules' are incompatible.
            Type 'import("/path/to/project/node_modules/@remix-run/server-runtime/dist/routeModules").EntryRouteModule>'.
              'string' index signatures are incompatible.
                Type 'import("/path/to/project/node_modules/@remix-run/server-runtime/dist/routeModules").EntryRouteModule'.
                  Types of property 'meta' are incompatible.
                    Type 'MetaFunction<unknown, {}> | V1_HtmlMetaDescriptor | undefined' is not assignable to type 'ServerRuntimeMetaFunction<unknown, Record<string, unknown>> | undefined'.
                      Type 'MetaFunction<unknown, {}>' is not assignable to type 'ServerRuntimeMetaFunction<unknown, Record<string, unknown>>'.
                        Types of parameters 'args' and 'args' are incompatible.
                          Property 'parentsData' is missing in type 'ServerRuntimeMetaArgs<unknown, Record<string, unknown>>' but required in type '{ data: any; parentsData: {} & RouteData; params: Params; location: Location; }'.

14   build,
     ~~~~~

  node_modules/path/to/project/node_modules/@remix-run/server-runtime/dist/routeModules.d.ts:141:9
    141         parentsData: {
                ~~~~~~~~~~~
    'parentsData' is declared here.
  node_modules/remix-aws/dist/index.d.ts:23:5
    23     build: ServerBuild;
           ~~~~~
    The expected type comes from property 'build' which is declared here on type '{ build: ServerBuild; getLoadContext?: GetLoadContextFunction | undefined; mode?: string | undefined; awsProxy?: AWSProxy | undefined; }'

Found 1 error in server.ts:14

server.ts is very similar to the given examples:

import { AWSProxy, createRequestHandler } from "remix-aws"
import { installGlobals } from "@remix-run/node"
import sourceMapSupport from "source-map-support"
import * as build from "@remix-run/dev/server-build"

if (process.env.NODE_ENV !== "production") {
  require("./mocks")
}

installGlobals()
sourceMapSupport.install()

export const handler = createRequestHandler({
  build,
  mode: process.env.NODE_ENV,
  awsProxy: AWSProxy.APIGatewayV2,
})
wingleung commented 8 months ago

Thanks for mentioning this!

brettdh commented 8 months ago

Thanks for the quick fix! I've confirmed that the error is gone with 0.0.3. 🎉