Typescript error when I refer to a component as selector
See original GitHub issueEnvironment
- typescript 3.3.3
- linaria 1.3.1
Description
I got a type error like below when I try to refer to a component.
`Argument of type 'FunctionComponent<ClassAttributes<HTMLDivElement> & HTMLAttributes<HTMLDivElement> & { as?: "symbol" | "object" | "big" | "link" | "small" | "sub" | "sup" | "track" | "progress" | "a" | "abbr" | ... 163 more ... | undefined; }>' is not assignable to parameter of type 'string | number | CSSProperties | ((props: PropsWithChildren<ClassAttributes<HTMLDivElement> & HTMLAttributes<HTMLDivElement> & { as?: "symbol" | "object" | "big" | "link" | "small" | "sub" | ... 168 more ... | undefined; }>) => string | number)'.
Type 'FunctionComponent<ClassAttributes<HTMLDivElement> & HTMLAttributes<HTMLDivElement> & { as?: "symbol" | "object" | "big" | "link" | "small" | "sub" | "sup" | "track" | "progress" | "a" | "abbr" | ... 163 more ... | undefined; }>' is not assignable to type '(props: PropsWithChildren<ClassAttributes<HTMLDivElement> & HTMLAttributes<HTMLDivElement> & { as?: "symbol" | "object" | "big" | "link" | "small" | "sub" | "sup" | "track" | "progress" | "a" | "abbr" | ... 163 more ... | undefined; }>) => string | number'.
Type 'ReactElement<any, string | ((props: any) => ReactElement<any, string | ... | (new (props: any) => Component<any, any, any>)> | null) | (new (props: any) => Component<any, any, any>)> | null' is not assignable to type 'string | number'.
Type 'null' is not assignable to type 'string | number'.`
Reproducible Demo
import { styled } from 'linaria/react';
const a = styled.div`
width: 1px;
`;
const b = styled.div`
${a} b { // -> error at ${a}
width: 2px;
}
`;
I think that it has to be fixed on linaria/react.d.ts
.
from
type StyledTag<T> = <Props = T>(
strings: TemplateStringsArray,
...exprs: Array<
string | number | CSSProperties | ((props: Props) => string | number)
>
) => StyledComponent<Props>;
to
type StyledTag<T> = <Props = T>(
strings: TemplateStringsArray,
...exprs: Array<
string | number | CSSProperties | ((props: Props) => string | number) | StyledComponent<any>
>
) => StyledComponent<Props>;
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (2 by maintainers)
Top Results From Across the Web
If '<selector>' is an Angular component, then verify that it is ...
I have tried to create a component but showing an error. This is the app.component.ts file. import { Component } from '@angular ...
Read more >Component - Angular
Decorator that marks a class as an Angular component and provides configuration metadata that determines how the component should be processed, instantiated ...
Read more >Codiga Analysis TypeScript Rules
@angular-eslint/component-selector. Unknown. Error. Detect if component selector isn't a hyphenated, lowercase value or doesn't have a descriptive prefix to ...
Read more >API Reference - styled-components
API Reference of styled-components. ... as the CSS syntax has support for pseudo selectors, media queries, nesting, etc., ... Usage with TypeScript.
Read more >Chapter 4, Understanding and Using Angular Components
Each component in turn has some behavior and a template that gets rendered. ... The very basic component only needs a selector (to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You’re right! It’ll be awesome if you can send a PR for that
The problem with
styled
is solved in 1.4, but there was the same problem withcss
tag. Fix forcss
will be released with the next beta.