hperrin / svelte-material-ui

Svelte Material UI Components
https://sveltematerialui.com/
Apache License 2.0
3.28k stars 288 forks source link

sortDirection type overcomplicated? #564

Open pboguslawski opened 1 year ago

pboguslawski commented 1 year ago

Describe the bug

Why not just

export let sortDirection: SortValue;

in https://github.com/hperrin/svelte-material-ui/blob/master/packages/data-table/src/DataTable.svelte#L121 ?

Expected behavior Setting sortDirection using enum values from @material>data-table>constants.d.ts

/**
 * Sort values defined by ARIA.
 * See https://www.w3.org/WAI/PF/aria/states_and_properties#aria-sort
 */
export declare enum SortValue {
    ASCENDING = "ascending",
    DESCENDING = "descending",
    NONE = "none",
    OTHER = "other"
}

like

sortDirection = SortValue.ASCENDING

not

sortDirection = "ascending"
Cschlaefli commented 1 year ago

You can't get enum imports from d.ts files because those types don't get transpiled to javascript. If you want this functionality and syntax you could probably import it directly from @material library like so

import { SortValue } from "@material/data-table";

pboguslawski commented 1 year ago

those types don't get transpiled to javascript

Issue is about using simpler constants like sortDirection = SortValue.ASCENDING in TS not after transpilation. Developer should not care about transpilation probably when developing and use enums properly. Correct me if I'm wrong.