Im trying to update my project to v1: Im trying to...
# help
g
Im trying to update my project to v1: Im trying to update the api construct but i keep getting this TS error but the deploy works:
Copy code
Type 'Api<Record<string, ApiAuthorizer>>' is not assignable to type 'Api<Record<string, never>>'.
  Type 'Record<string, ApiAuthorizer>' is not assignable to type 'Record<string, never>'.
    'string' index signatures are incompatible.
      Type 'ApiAuthorizer' is not assignable to type 'never'.
        Type 'ApiUserPoolAuthorizer' is not assignable to type 'never'.ts(2322
for
Copy code
return new sst.Api(this, "Api", {
      authorizers: {
        Authorizer: {
          type: "jwt",
          jwt: {
            issuer: "<https://myorg.us.auth0.com>",
            audience: ["UsGRQJJz5sDfPQDs6bhQ9Oc3hNISuVif"],
          }
        },
      },
      defaults: {
        authorizer: "Authorizer",
        authorizationScopes: ["user.id", "user.email"],
      },
      routes: {
        "GET /notes": "src/list.main",
        "POST /notes": {
          function: "create.main",
          authorizer: "Authorizer",
          authorizationScopes: ["user.id", "user.email"],
        }
      },
    });
f
Hey @Gabriel Araújo, where is this being return to?
g
I call this function in my stack constructor.. it sets a this.api property. typed as
sst.Api
f
I see.
new sst.Api
returns a Api<Generic> type with the authorizer names included in the Generic.
I will let @thdxr suggest a good fix here.
^ it doesn’t affect the deploy
t
are you setting a return type in the function definition?
don't do that! let ts inference handle it for you
g
from
Copy code
private createApi(scope: <http://sst.App|sst.App>): sst.Api
To
Copy code
private createApi(scope: <http://sst.App|sst.App>)