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

Mark fallback arrays as immutable #110

Closed
kripod opened this issue Aug 22, 2020 · 0 comments · Fixed by #178
Closed

Mark fallback arrays as immutable #110

kripod opened this issue Aug 22, 2020 · 0 comments · Fixed by #178

Comments

@kripod
Copy link

kripod commented Aug 22, 2020

Fallback values should be readonly to support assigning ["fallback", "values"] as const, e.g.:

import type { PropertiesFallback as CSSProperties } from "csstype";

export function placeContent<
  Align extends CSSProperties["alignContent"],
  Justify extends CSSProperties["justifyContent"] = Align
>(
  align: Align,
  justify: Justify = (align as unknown) as Justify,
): {
  alignContent: Align;
  justifyContent: Justify;
} {
  return {
    alignContent: align,
    justifyContent: justify,
  };
}

const longhands = placeContent(["space-around", "space-evenly"] as const);

// Type should be inferred as:
// {
//   alignContent: readonly ["space-around", "space-evenly"];
//   justifyContent: readonly ["space-around", "space-evenly"];
// }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant