https://serverless-stack.com/ logo
#help
Title
# help
a

Adrian Schweizer

05/17/2022, 11:22 PM
Why do I get this console output:
Copy code
stacks/StorageStack.js (15,36): Type '"GET"' is not assignable to type 'HttpMethods'.
13.                   allowedHeaders: ["*"],
14.                   allowedMethods: ["GET", "PUT", "POST", "DELETE", "HEAD"],
15.                },
Seems weird to me, because "GET" is indeed in HttpMethods. Some Typescript thing I'm not getting?
This is CORS config for a Bucket, by the way
r

Ross Coundon

05/18/2022, 5:07 AM
If you’re inside the
cdk.bucket
property you need to use the HttpMethods.GET enumeration value not the string.
a

Adrian Schweizer

05/18/2022, 11:09 AM
ah, ok, thx. What's weird is that my IDE is not finding this enum for some reason, any idea why?
It's a new install of sst and i've already installed npm dependencies
r

Ross Coundon

05/18/2022, 11:10 AM
Have you imported it?
Copy code
import {HttpMethods} from 'aws-cdk-lib/aws-s3';
a

Adrian Schweizer

05/18/2022, 11:11 AM
well no, what I mean is that usually, I can just write the construct Name and the ide then finds it when i do ctrl + space
but not in this case
for example for the Bucket construct, it works
r

Ross Coundon

05/18/2022, 11:18 AM
It seems to be a little hit and miss as whether my IDE automatically finds type from packages in node_modules. Sometimes I need to hunt them down myself
a

Adrian Schweizer

05/18/2022, 11:27 AM
hmmm, okay, good to know, thanks
anyway, it seems to work with the HttpMethods.GET enum, thx
f

Frank

05/19/2022, 2:43 AM
Thanks @Ross Coundon. How u spotted it’s inside
cdk.bucket
feels like magic to me 🤯