Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(declarations): use correct TypeScript JSX typings #5307

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/declarations/stencil-public-runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -596,12 +596,12 @@ export interface ChildNode {
*
* For further information: https://stenciljs.com/docs/host-element
*/
export declare const Host: FunctionalComponent<HostAttributes>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I understand the motivation for this change, I don't think we can make this change in Stencil v4. This changes the output of typeof Host, which would constitute a breaking change.

In Stencil v4, the following code type checks without error:

import { Host } from '@stencil/core';

const Hello: typeof Host = (_props: any, children: any, utils: any) =>
  utils.map(children, child => ({
    ...child,
    vattrs: {
      ...child.vattrs,
      class: `${child.vattrs.class} add-class`,
    },
  }));

Whereas with this commit/change, it fails with:

[ ERROR ]  TypeScript: src/components/my-component/my-component.tsx:4:7
           Type '(_props: any, children: any, utils: any) => any' is not assignable to type '(props: HostAttributes) =>
           VNode'.Target signature provides too few arguments. Expected 3 or more, but got 1.

      L4:  const Hello: typeof Host = (_props: any, children: any, utils: any) =>
      L5:    utils.map(children, child => ({

export declare const Host: (props: HostAttributes) => VNode;

/**
* Fragment
*/
export declare const Fragment: FunctionalComponent<{}>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to my comment above - while I understand the motivation for this change, it would also be a breaking change.

In Stencil v4, the following code type checks without error:

import { Fragment } from '@stencil/core';

const Hello: typeof Fragment = (_props: any, children: any, utils: any) =>
  utils.map(children, child => ({
    ...child,
    vattrs: {
      ...child.vattrs,
      class: `${child.vattrs.class} add-class`,
    },
  }));

Whereas with this commit/change, it fails with:

[ ERROR ]  TypeScript: src/components/my-component/my-component.tsx:4:7
           Type '(_props: any, children: any, utils: any) => any' is not assignable to type '(props: {}) =>
           VNode'.Target signature provides too few arguments. Expected 3 or more, but got 1.

      L4:  const Hello: typeof Fragment = (_props: any, children: any, utils: any) =>
      L5:    utils.map(children, child => ({

export declare const Fragment: (props: {}) => VNode;

/* eslint-disable jsdoc/require-param, jsdoc/require-returns -- we don't want to JSDoc these overloads at this time */
/**
Expand All @@ -619,6 +619,7 @@ export declare namespace h {
export function h(sel: any, data: VNodeData | null, children: VNode): VNode;

export namespace JSX {
type Element = VNode;
interface IntrinsicElements extends LocalJSX.IntrinsicElements, JSXBase.IntrinsicElements {
[tagName: string]: any;
}
Expand Down
Loading