Следуя инструкциям на этой странице: https://cdkworkshop.com/20-typescript/40-hit-counter/300-resources.html
Я полагаю, что this
, переданный конструктору Table
, должен быть HitCounter
, суб-конструктором cdk.Construct
Возвращает эту строку:
this: this
Argument of type 'this' is not assignable to parameter of type 'Construct'.
Type 'HitCounter' is not assignable to type 'Construct'.
Property 'onValidate' is protected but type 'Construct' is not a class derived from 'Construct'.ts(2345)
Я также получаю внутреннюю ошибку сервера на этом шаге. Кто-нибудь знает, в чем проблема?
import * as cdk from "@aws-cdk/core";
import * as lambda from "@aws-cdk/aws-lambda";
import * as dynamodb from "@aws-cdk/aws-dynamodb";
export interface HitCounterProps { downstream : lambda.IFunction; }
export class HitCounter extends cdk.Construct {
public readonly handler: lambda.Function;
constructor(scope: cdk.Construct, id: string, props: HitCounterProps) {
super(scope, id);
const table = new dynamodb.Table(this, "Hits", { // lints `this`
partitionKey : {
name : "path",
type : dynamodb.AttributeType.STRING
}
});
<more code removed>
}
}