Skip to content

Issue with CloudWatch MetricDatum Unit types #2877

Closed
@EHadoux

Description

@EHadoux

Describe the bug

When using PutMetricDataCommand the field MetricData expects a MetricDatum[]. The Unit field of MetricDatum has in theory the type StandardUnit | string. It looks like it gets coerced to string only because StardardUnit is a union of string. We lose the autocompletion of the possible values for the unit. See

Unit?: StandardUnit | string;

Your environment

SDK version number

@aws-sdk/[email protected]

Is the issue in the browser/Node.js/ReactNative?

Node.js

Details of the browser/Node.js/ReactNative version

v16.9.1

Steps to reproduce

import { PutMetricDataCommand } from '@aws-sdk/client-cloudwatch';

const cmd = new PutMetricDataCommand({
  MetricData: [{
    Unit: 'Count' // of type string so no autocompletion
  }]
});

Observed behavior

The Unit field is of type string, preventing autocompletion.

Expected behavior

The Unit field should be of type StandardUnit to allow for autocompletion.

Screenshots

image

Additional context

Using Typescript v4.4.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.p3This is a minor priority issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions