Skip to content

How to properly alias Preact/compat with TypeScript? #2150

@v1rtl

Description

@v1rtl

Reproducing

  1. git clone https://github.com/talentlessguy/preact-emotion-ts.git
  2. yarn install
  3. Open vscode, with these settings:
{
    "eslint.packageManager": "yarn",
    "npm.packageManager": "yarn",
    "editor.formatOnSave": true,
    "typescript.updateImportsOnFileMove.enabled": "always",
    "editor.suggestSelection": "first",
    "eslint.autoFixOnSave": true,
    "eslint.alwaysShowStatus": true,
    "prettier.configPath": "/home/v1rtl/.prettierrc.yml",
    "[typescriptreact]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    }

And see this error on <Header> component:

JSX element type 'Header' does not have any construct or call signatures.

Versions

emotion: 10.0.22
preact: 10.0.5
eslint: 6.7
typescript: 3.7.2

Screenshot

image

The weirdiest thing is that npx eslint doesn't show anything like this

preact-emotion-ts is 📦 v1.0.0 via ⬢ v13.2.0 
❯ npx eslint src/*.tsx --fix
Warning: React version was set to "detect" in eslint-plugin-react settings, but the "react" package is not installed. Assuming latest React version for linting.

I don't what the issue is coming from but I suppose it is a problem with typings of preact (?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions