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
Fix errors
istarkov466ae357d8d6
diff --git a/apps/designer/app/designer/features/style-panel/shared/get-inherited-style.ts b/apps/designer/app/designer/features/style-panel/shared/get-inherited-style.tsindex 3125f6f817..67810914af 100644--- a/apps/designer/app/designer/features/style-panel/shared/get-inherited-style.ts+++ b/apps/designer/app/designer/features/style-panel/shared/get-inherited-style.ts@@ -10,12 +10,13 @@ export type InheritedStyle = {};type InheritableProperties = { [property in StyleProperty]: true };-const propertyNames = Object.keys(properties) as Array<StyleProperty>;+// Object keys should give `keyof typeof ...` but now it gives string[]+const propertyNames = Object.keys(properties) as (keyof typeof properties)[];// All inheritable properties we supportconst inheritableProperties: InheritableProperties = propertyNames.reduce(- (acc: InheritableProperties, property: StyleProperty) => {+ (acc: InheritableProperties, property) => {// @todo- const config = (properties as any)[property];+ const config = properties[property];if (config.inherited) {acc[property as StyleProperty] = true;}diff --git a/apps/designer/app/designer/features/style-panel/shared/use-style-data.ts b/apps/designer/app/designer/features/style-panel/shared/use-style-data.tsindex 85ca10fa72..942716ed3c 100644--- a/apps/designer/app/designer/features/style-panel/shared/use-style-data.ts+++ b/apps/designer/app/designer/features/style-panel/shared/use-style-data.ts@@ -1,6 +1,6 @@import { useState, useMemo, useEffect, useCallback } from "react";import type { SelectedInstanceData, StyleUpdates } from "@webstudio-is/project";-import type { StyleProperty } from "@webstudio-is/css-data";+import type { Style, StyleProperty } from "@webstudio-is/css-data";import { type Publish } from "~/shared/pubsub";import { useSelectedBreakpoint } from "~/designer/shared/nano-states";import { parseCssValue } from "./parse-css-value";@@ -46,7 +46,7 @@ export const useStyleData = ({[selectedInstanceData?.cssRules, selectedBreakpoint]);- const getCurrentStyle = useCallback(+ const getCurrentStyle = useCallback<() => Style>(() => ({...selectedInstanceData?.browserStyle,...cssRule?.style,@@ -136,7 +136,7 @@ export const useStyleData = ({const nextStyle = updates.reduce((currentStyle, { property, value }) => {// @todo- (currentStyle as any)[property] = value;+ currentStyle[property] = value;return currentStyle;},{ ...currentStyle }diff --git a/apps/designer/app/designer/shared/design-tokens-manager/design-tokens-manager.tsx b/apps/designer/app/designer/shared/design-tokens-manager/design-tokens-manager.tsxindex b7771b2806..159ae5fee5 100644--- a/apps/designer/app/designer/shared/design-tokens-manager/design-tokens-manager.tsx+++ b/apps/designer/app/designer/shared/design-tokens-manager/design-tokens-manager.tsx@@ -76,7 +76,7 @@ const TokenEditor = ({if (isOpen === false && errors.hasErrors) {setErrors(initialErrors);}- }, [isOpen]);+ }, [isOpen, errors.hasErrors]);const handleChange = (event: FormEvent<HTMLFormElement>) => {if (errors.hasErrors === false) return;diff --git a/apps/designer/app/designer/shared/design-tokens-manager/schema.ts b/apps/designer/app/designer/shared/design-tokens-manager/schema.tsindex 09e085ca83..d720c6d6a6 100644--- a/apps/designer/app/designer/shared/design-tokens-manager/schema.ts+++ b/apps/designer/app/designer/shared/design-tokens-manager/schema.ts@@ -1,20 +1,35 @@import { z } from "zod";import { groups } from "./groups";+type UnionToIntersection<U> = (+ U extends never ? never : (arg: U) => never+) extends (arg: infer I) => void+ ? I+ : never;++type UnionToTuple<T> = UnionToIntersection<+ T extends never ? never : (t: T) => T+> extends (_: never) => infer W+ ? [...UnionToTuple<Exclude<T, W>>, W]+ : [];+type Type = typeof groups[number]["type"];type Group = typeof groups[number]["group"];-const types: Array<Type> = groups.map((group) => group.type);-const groupNames: Array<Group> = groups.map((group) => group.group);+// zod is super restrictive on enum type https://github.com/colinhacks/zod/issues/1118+// so we convert union to tuple here its seriously safer than any as it will break on things like+// ['a', 'b'] as UnionToTuple<Type> etc+const types = groups.map((group) => group.type) as UnionToTuple<Type>;+const groupNames = groups.map((group) => group.group) as UnionToTuple<Group>;export const DesignToken = z.object({name: z.string(),- // @todo- type: z.enum(types as any),+ // @todo if https://github.com/colinhacks/zod/issues/1118+ type: z.enum(types),value: z.string(),description: z.optional(z.string()),- // @todo- group: z.enum(groupNames as any),+ // @todo if https://github.com/colinhacks/zod/issues/1118+ group: z.enum(groupNames),});export type DesignToken = z.infer<typeof DesignToken>;diff --git a/packages/react-sdk/src/css/get-browser-style.ts b/packages/react-sdk/src/css/get-browser-style.tsindex 452e11c093..41635fbc3d 100644--- a/packages/react-sdk/src/css/get-browser-style.ts+++ b/packages/react-sdk/src/css/get-browser-style.ts@@ -1,16 +1,14 @@import { detectFont } from "detect-font";-import type {- StyleProperty,- Style,- StyleValue,- Unit,-} from "@webstudio-is/css-data";+import type { Style, StyleValue, Unit } from "@webstudio-is/css-data";import { properties, units } from "@webstudio-is/css-data";const unitRegex = new RegExp(`${units.join("|")}`);// @todo use a parser-const parseValue = (property: StyleProperty, value: string): StyleValue => {+const parseValue = (+ property: keyof typeof properties,+ value: string+): StyleValue => {const number = parseFloat(value);const parsedUnit = unitRegex.exec(value);if (value === "rgba(0, 0, 0, 0)") value = "transparent";@@ -23,7 +21,7 @@ const parseValue = (property: StyleProperty, value: string): StyleValue => {if (number === 0 && property in properties) {// @todo- return (properties as any)[property].initial;+ return properties[property].initial;}return {@@ -36,7 +34,7 @@ const parseValue = (property: StyleProperty, value: string): StyleValue => {export const getBrowserStyle = (element?: Element): Style => {const browserStyle: Style = {};if (element === undefined) return browserStyle;- let knownProperty: StyleProperty;+ let knownProperty: keyof typeof properties;const computedStyle = getComputedStyle(element);for (knownProperty in properties) {if (knownProperty in computedStyle === false) continue;