Skip to content

JSXElement name that starts with an underscore is assumed to be an intrinsic element #19945

Closed
@meyer

Description

@meyer

Typescript and babel both have a very similar test for deciding whether or not a JSXElement is a intrinsic element or a component.

Typescript’s test has one fatal flaw, however: it relies on a toLowerCase comparison but does not verify that the first character is a letter. I encountered an issue where a JSXElement starting with an underscore was incorrectly assumed to be an intrinsic element.

My proposal is that the Typescript JSXElement name test be more inline with the babel JSXElement name test. I’ll whip up a PR as soon as I figure out how things are done around here.

TypeScript Version: 2.6.1

Code

import { Box as _Box } from 'jsxstyle';
<_Box />;

Expected behavior:
_Box is treated like a component instead of an intrinsic element.

Actual behavior:
error TS2339: Property '_Box' does not exist on type 'JSX.IntrinsicElements'.

For reference: jsxstyle/jsxstyle#82 (comment)

Metadata

Metadata

Assignees

No one assigned

    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