https://pulumi.com logo
#typescript
Title
# typescript
w

worried-engineer-33884

09/10/2019, 3:54 PM
I am running into a type issue when I try to create this IAM policy statement:
Copy code
Type '{ StringEquals: { "s3:prefix": string[]; }; StringLike?: undefined; }' is not assignable to type 'Conditions'.
              Property 'StringLike' is incompatible with index signature.
                Type 'undefined' is not assignable to type 'ConditionArguments'.
I think this is because I have different keys in the condition for each statement:
StringEquals
in one,
StringLike
in the other. Is this a possible bug in the
aws.iam.Conditions
interface? https://github.com/pulumi/pulumi-aws/blob/master/sdk/nodejs/iam/documents.ts#L98 cc @dazzling-memory-8548
w

white-balloon-205

09/10/2019, 5:06 PM
Yes - this does appear to be a case of TypeScript contextual typing not flowing as well as you might hope. You can fix by inserting a cast - for instance just
as aws.iam.PolicyStatement[]
on the second to last line.
w

worried-engineer-33884

09/10/2019, 5:11 PM
ok i'll do that — is there an opportunity for the interface to be improved to accommodate this? or is it purely a TS quirk?
w

white-balloon-205

09/10/2019, 6:18 PM
I believe this is purely a TS quirk.
2 Views