Skip to content

Imported directive not defined (with TypeScript) #1005

@Ehesp

Description

@Ehesp

Describe the bug

Working with directives and TypeScript doesn't seem to be playing well together.

When importing a directive from a file, I get the error:

ReferenceError: <name> is not defined

I came across this issue: #569

Adding my Vite plugin as:

solidPlugin({ typescript: { onlyRemoveTypeImports: true } }),

then causes another issue: The requested module '/node_modules/.vite/deps/solid-js.js?v=dacde466' does not provide an export named 'Component'

Your Example Website or App

https://stackblitz.com/edit/solid-vite-sv6hn7?file=src/index.tsx

Steps to Reproduce the Bug or Issue

  1. Make a file for your directive.
  2. Import it and attach it.
  3. Open the console to see the error.

Expected behavior

The directive is recognised.

Screenshots or Videos

No response

Platform

  • OS: macOs
  • Browser: Chrome
  • Version: 101.0.4951.64

Additional context

TypeScript also complains about:

'useFoo' is declared but its value is never read. ts(6133)

Metadata

Metadata

Assignees

No one assigned

    Labels

    typescriptrelating to typescript or types

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions