[Solved] Hi everybody! I've just upgraded to v1 an...
# help
v
[Solved] Hi everybody! I've just upgraded to v1 and everything is compiling ok. However I'm getting a typescript error on the Api construct using a User Pool Authorizer (called 'userPoolAuthorizer'):
Copy code
TS2322: Type 'Api<{ userPoolAuthorizer: { type: "user_pool"; userPool: { id: string; clientIds: string[]; }; }; }>' is not assignable to type 'Api<Record<string, ApiAuthorizer>>'.
Types of property 'createFunctionIntegration' are incompatible.
Type '(scope: Construct, routeKey: string, routeProps: ApiFunctionRouteProps<"userPoolAuthorizer">, postfixName: string) => HttpRouteIntegration' is not assignable to
type '(scope: Construct, routeKey: string, routeProps: ApiFunctionRouteProps<string>, postfixName: string) => HttpRouteIntegration'.
Types of parameters 'routeProps' and 'routeProps' are incompatible.
Type 'ApiFunctionRouteProps<string>' is not assignable to type 'ApiFunctionRouteProps<"userPoolAuthorizer">'.
Types of property 'authorizer' are incompatible.
Type '"none" | "iam" | Omit<string, "none" | "iam"> | undefined' is not assignable to type '"userPoolAuthorizer" | "none" | "iam" | undefined'.
Type 'Omit<string, "none" | "iam">' is not assignable to type '"userPoolAuthorizer" | "none" | "iam" | undefined'.
Nevermind, turns out Api now takes a generic:
Api => Api<{ userPoolAuthorizer: { userPool: { id: string; clientIds: string[] }; type: 'user_pool' } }>
f
Hey @Victor Garcia, you shouldn’t need to explicitly specify the type. Can I see where you need to do this?
v
hey @Frank, I'm storing the API construct as
private readonly api: Api<ApiAuthorizers>;
and then initialising it in the constructor
this.api = new Api(this, 'api', {...
.
ApiAuthorizers
is
type ApiAuthorizers = { userPoolAuthorizer: { userPool: { id: string; clientIds: string[] }; type: 'user_pool' } };