Skip to content

Allow JSX element attributes type to be an intersection #4362

Closed
@jbrantly

Description

@jbrantly

Consider the following:

declare module JSX {
    interface ElementAttributesProperty { props: {}; }
}

class Component<P> {
    props: P & { ref?: string };
}

This results in the error: JSX element attributes type '[type parameter] & { ref?: string; }' must be an object type.

An alternative would be an additional member of the JSX namespace that allowed specifying "global" attributes (that would apply to both value-based and intrinsic elements). For example:

declare module JSX {
    interface GlobalAttributes {
        ref?: string
    }
}

See also DefinitelyTyped/DefinitelyTyped#5347

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions