Skip to content

Use namespace other than Preact with #core/dom/jsx #36680

@alanorozco

Description

@alanorozco

We import #core/dom/jsx under the Preact namespace:

import * as Preact from '#core/dom/jsx';

We should use @jsx with a namespace other than Preact since it's misleading:

#36640 (comment)
Nit: I'm a bit worried we'll confuse this with actual Preact (and the ability to diff). Can we use a different name and @jsxPragma?

// input
/** @jsx StaticTree.createElement */

<div/>



// output
StaticTree.createElement("div");

Closure does not play nice with the @jsx annotation:

WARNING - [JSC_BAD_JSDOC_ANNOTATION] Parse error. illegal use of unknown JSDoc tag "jsx"; ignoring it.
Place another character before the @ to stop JSCompiler from parsing it as an annotation.

If we ever figure this out, or move away from Closure (#35264), we should:

  • Replace all uses with JsxStaticTree
  • Update local/preact lint rule so that it allows namespaces other than Preact. (It would be convenient if namespace has to start withJsx)

Metadata

Metadata

Assignees

Labels

StaleInactive for one year or moreWG: infra

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions