Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use in typescript will report type error. #730

Closed
xpol opened this issue Jan 25, 2021 · 10 comments
Closed

Use in typescript will report type error. #730

xpol opened this issue Jan 25, 2021 · 10 comments
Assignees
Labels
bug report 🦗 Issue is probably a bug, but it needs to be checked cat: typings 👮 Typescript types related issues needs: complete repro 🖥️ Issue need to have complete repro provided

Comments

@xpol
Copy link

xpol commented Jan 25, 2021

Environment

  • Linaria version: 2.0.2
  • Bundler (+ version): ?
  • Node.js version: v14.15.4
  • OS: Mac 11.1 (20C69)
  • Typescript: 3.7.0

Description

TS2345: Argument of type '(props: any) => any' is not assignable to parameter of type 'StaticPlaceholder'.   Property '__linaria' is missing in type '(props: any) => any' but required in type 'StyledMeta'.

Reproducible Demo

index.tsx:

import React from 'react'
import {View} from '@tarojs/components'
import {styled} from 'linaria/react'

type Props = {
  color: string
};

const Title = styled(View)<Props>`
  color: ${ ( props ) => props.color }
`;

const Index: React.FC = (): JSX.Element => {
  return <Title color='red'>
    Hello World!
  </Title>
}

export default Index
@xpol xpol added bug report 🦗 Issue is probably a bug, but it needs to be checked needs: complete repro 🖥️ Issue need to have complete repro provided needs: triage 🏷 Issue needs to be checked and prioritized labels Jan 25, 2021
@github-actions github-actions bot added cat: typings 👮 Typescript types related issues and removed needs: triage 🏷 Issue needs to be checked and prioritized labels Jan 25, 2021
@xpol
Copy link
Author

xpol commented Jan 25, 2021

I have to use @ts-ignore.

const Title = styled(View)<Props>`
  color: ${
    // @ts-ignore
    ( props ) => props.color
  }
`;

@Anber Anber self-assigned this Jan 25, 2021
@Adherentman
Copy link

same error

@Anber
Copy link
Collaborator

Anber commented Mar 29, 2021

It's not an issue, it's a legitimate type check error: if you use props-based values, Linaria converts them to css-variables and adds those variables to the style attribute, so this error means that your View component doesn't have style prop and prop-based values can be missed. A bit unclear, but it's the best what TS can offer right now.

@Anber Anber closed this as completed Mar 29, 2021
@gthrm
Copy link

gthrm commented Nov 15, 2021

Today I got the same error and see that it's closed without some solution. What should I do? ☹️
linaria 3.0.0-beta.13
typescript 4.4.4

// @ts-ignore doesn't work

@wcldyx
Copy link

wcldyx commented Nov 25, 2021

Brothers, I also encountered this problem, how to solve

@Anber
Copy link
Collaborator

Anber commented Nov 29, 2021

Guys, I'm so sorry. There was an error that makes impossible to wrap a class component.

@rquanx
Copy link

rquanx commented Dec 15, 2021

@Anber
get type StyledComponent<React.ComponentType<ViewProps>> after update new version, expect StyledComponent<ViewProps>

image

@Anber
Copy link
Collaborator

Anber commented Dec 16, 2021

Hi @rquanx

Looks like #887 is going to fix that issue
Screenshot 2021-12-16 12 43 20

@rquanx
Copy link

rquanx commented Dec 16, 2021

well, Can tell me when it will be released

@yepyeel
Copy link

yepyeel commented Dec 29, 2021

I want to know how to resolve it right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report 🦗 Issue is probably a bug, but it needs to be checked cat: typings 👮 Typescript types related issues needs: complete repro 🖥️ Issue need to have complete repro provided
Projects
None yet
Development

No branches or pull requests

7 participants