cdk-eks-blueprints icon indicating copy to clipboard operation
cdk-eks-blueprints copied to clipboard

Non-idiomatic use of Map throughout

Open otterley opened this issue 3 years ago • 3 comments

Map types aren't idiomatic for Typescript. Where types like Map<String,T> are used, they should be replaced with { [key:string]: T }.

For example, this code looks quite clumsy:

  fargateProfiles: new Map([
    ['karpenter', { selectors: [{ namespace: 'karpenter'}]}]
  ]),

vs. the much cleaner (and idiomatic) looking:

  fargateProfiles: {
    karpenter: { 
      selectors: [{ namespace: 'karpenter'}]
    }
  },

See index signatures for additional information.

otterley avatar May 06 '22 01:05 otterley

Thank you, @otterley. I see the API usability issue. I spotted this a bit late and this feature is part of the stable API.

We are using the record style map approach in the new GenericClusterProvider here.

What I can do to address the usability and preserve backwards compatibility is simplify construction of the fargate profiles for the users by adding convenience methods.

shapirov103 avatar May 06 '22 17:05 shapirov103

Have you considered the possibility of using union types to fix the problem without breaking existing code?

otterley avatar Jul 17 '22 01:07 otterley

@otterley I will take a look.

shapirov103 avatar Jul 28 '22 04:07 shapirov103

@otterley Closing this issue because of your PR.

elamaran11 avatar Oct 12 '23 12:10 elamaran11