frenic / csstype

Strict TypeScript and Flow types for style based on MDN data
MIT License
1.7k stars 69 forks source link

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

Closed KutnerUri closed 2 years ago

KutnerUri commented 2 years ago

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

maurer2 commented 2 years ago

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

frenic commented 2 years ago

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