Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sparse traits not considered when generating Records for Map shapes #1101

Open
miloszwatroba opened this issue Dec 6, 2023 · 0 comments
Open

Comments

@miloszwatroba
Copy link

miloszwatroba commented Dec 6, 2023

Hi,

I'd like to report a bug in the smithy-typescript-codegen package.

@sparse traits added to the Map shapes (https://smithy.io/2.0/spec/type-refinement-traits.html#sparse-trait) are not reflected by TypeScript Records generated by smithy-typescript-codegen.

For instance, the following definition:

structure ExampleStructure {
    sparseMap: SparseMap,
}

@sparse
map SparseMap {
    key: String,
    value: String
}

results in the following TypeScript code:

export interface ExampleStructure {
    environment?: Record<string, string>;
}

while according to the specification ("sparse Indicates that lists and maps MAY contain null values. The sparse trait has no effect on map keys; map keys are never allowed to be null."), it should rather generate the following:

export interface ExampleStructure {
    environment?: Record<string, string | null>;
}

Tested with latest version: 0.19.0

Cheers,
Milosz

sugmanue pushed a commit to sugmanue/smithy-typescript that referenced this issue Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant