Skip to content

Partial Contracts Type Safety #1177

Answered by askoufis
joerobot asked this question in Q&A
Sep 8, 2023 · 1 comments · 4 replies
Discussion options

You must be logged in to vote

Oh, I think we've both just been circling around the createTheme API, which is really just a wrapper around creating a style with assignVars anyway, with the option to pass a contract if you want. I feel like it would be simpler to just derive some types from partial theme objects and then stitch themes together with createTheme, rather than passing objects of CSSVarFunctions around:

import { createTheme } from "@vanilla-extract/css";

const base = {
  space: { small: "1", large: "2" },
  radius: { small: "1", large: "2" },
};

type BaseTokens = typeof base;

const typefaceA = {
  fontSize: { small: "1", large: "2" },
  lineHeight: { small: "1", large: "2" },
};

type TypefaceTokens = typeof

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@joerobot
Comment options

@joerobot
Comment options

@askoufis
Comment options

Answer selected by joerobot
@joerobot
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants