frenic / csstype

Strict TypeScript and Flow types for style based on MDN data

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error: Property 'height' does not exist on type 'CSSProperties'

KutnerUri opened this issue · comments

Getting this very weird error when trying to read height property:

Error: Property 'height' does not exist on type 'CSSProperties'

For example:

const props: CSSProperties = {
  height: 3, // totally fine
};

const a = props.height; // ts error

any ideas?

using version ^3.0.2, coming from types/react: 18.0.7

Hello, v3 changed the way Properties are exposed (CSSProperties). The following should work:

import type * as CSS from 'csstype';

const props: CSS.Properties = {
  height: '3px',
};

const a = props.height;

Cheers

I guess it's React.CSSProperties in your example. I don't get any errors at my end so I'm not able to assist you.

image