Following the tutorial on this page: https://cdkworkshop.com/20-typescript/40-hit-counter/300-resources.html
I believe this
, passed to the Table
constructor, should be HitCounter
, a sub-constructor of cdk.Construct
It returns this lint:
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)
I also get an internal server error on this step. Anyone know what the issue is?
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>
}
}
I had the same issue. You have to set all the different cdk packages to the same version, see https://github.com/aws/aws-cdk/issues/542#issuecomment-449694450.
npx npm-check-updates -u
npm install
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With