cssta icon indicating copy to clipboard operation
cssta copied to clipboard

Typescript + Props

Open fera765 opened this issue 5 years ago • 3 comments

How to configure the use of typescript, and how to pass a property into the component using typescript

fera765 avatar Jul 29 '20 20:07 fera765

Sorry, I need to add the types to the project. You can use this though,


declare module 'cssta/native' {
  type CssConstructor<T> = (
    css: TemplateStringsArray,
    ...values: (string | number | (() => any))[]
  ) => T;

  type ComponentConstructor = <T = {}>(
    component: React.ElementType<T>,
  ) => CssConstructor<React.ElementType<T & Record<string, any>>>;

  type Mixin = {
    mixin: CssConstructor<any>;
  };

  const styled: ComponentConstructor & Mixin;
  export default styled;
}

jacobp100 avatar Jul 29 '20 21:07 jacobp100

Old this lib has everything to be better than Styled-Components ... Not to update it, because this lib is fantastic ....

fera765 avatar Jul 29 '20 22:07 fera765

I used it today I did some tests and I loved it, I'm thinking about abandoning the styled components kkkk I just had a little problem with typescript, and also with the extension of the styled components of vscode

fera765 avatar Jul 29 '20 22:07 fera765