Giter Site home page Giter Site logo

Comments (1)

maxpatiiuk avatar maxpatiiuk commented on September 12, 2024

As per preactjs/preact#1180 (comment), changing the preact.d.ts that Calcite generates like so appears to work both with the legacy and the new moduleResolution strategy:

- import { JSXInternal } from "preact/src/jsx"; 
- import { JSX } from "./components";
+ import { JSX as JSXInternal } from "preact";
+ import { JSX as CalciteJsx } from "./components";

- declare module "preact/src/jsx" {
-   namespace JSXInternal {
+ declare module 'preact' {
+   namespace createElement.JSX extends JSXInternal.IntrinsicElements {

This seems to work because new versions of TypeScript look at the jsx factory function to resolve the JSX namespace

In addition:

  • Rename usages of JSX.Calcite* in the file with CalciteJsx.Calcite*)
  • Duplicate the contents of namespace createElement.JSX extends JSXInternal.IntrinsicElements { ... } and call it namespace h.JSX extends JSXInternal.IntrinsicElements { ... } so that typing works both for people using "jsxFactory": "h" and "jsxFactory": "createElement"`

@paulcpederson Since you worked on the original Calcite types for Preact, could you please verify if the above fix looks good and if so if it can be integrated into the preact.d.ts that Calcite ships?

from calcite-design-system.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.