Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
type the return values so that typescript tells the user how the var string and variable looks like
Oleg Isonen1d5540e3f541
diff --git a/packages/css-vars/src/index.ts b/packages/css-vars/src/index.tsindex 167e31a717..c6a967dc81 100644--- a/packages/css-vars/src/index.ts+++ b/packages/css-vars/src/index.ts@@ -1,11 +1,12 @@let counter = -1;-const define = (name: string) => {+const define = <Name extends string>(name: Name) => {return `--${name}-${++counter}` as const;};-const use = (variable: string, ...fallbacks: Array<string>) => {- return `var(${variable}, ${fallbacks})` as const;+const use = <Args extends string[]>(...args: Args) => {+ type JoinedArgs = `${typeof args[0]}, ${typeof args[1]}, ${typeof args[2]}`;+ return `var(${args.join(", ") as JoinedArgs})` as const;};export const cssVars = { define, use };