Skip to content

Unable to import JSX types, Error: "no interface JSX.IntrinsicElements exists", although it exists #41813

Closed
@trusktr

Description

@trusktr

TypeScript Version: 4.1.2

Search Terms:

no interface JSX.IntrinsicElements exists

Code

This works:

namespace JSX {
    export interface IntrinsicElements {
        div: {[k: string]: any}
    }
}

const d = <div /> // <-- no error
type test = JSX.IntrinsicElements // <-- no error

playground

But this does not work:

import type {JSX} from 'solid-js'

const d = <div /> // Error: JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists.

// But JSX is in scope, just that JSX expressions do not see it.
// As an example, the following non-JSX code works fine:
type test = JSX.IntrinsicElements // <-- no error

playground

Expected behavior:

It should see the definition of JSX.IntrinsicElements which is clearly present due to the import statement.

Actual behavior:

The JSX definition in the second example (imported) appears to be invisible to TS.

As you can see from both examples, only a locally-defined JSX works, but not one that is imported.

Metadata

Metadata

Assignees

Labels

Working as IntendedThe behavior described is the intended behavior; this is not a bug

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions