stencil icon indicating copy to clipboard operation
stencil copied to clipboard

Type 'typeof h' has no call signatures.

Open Leandro-Albano opened this issue 6 years ago • 3 comments

Stencil version:

 @stencil/[email protected]

I'm submitting a:

[ X ] bug report

Current behavior: It's not possible to call h("tag-name") without casting it to any before. Typescript return a compile error

This expression is not callable.
  Type 'typeof h' has no call signatures.

Expected behavior: calling h("tag-name") works fine

Steps to reproduce:

Just try to call h("tag-name") in any component

Leandro-Albano avatar Nov 23 '19 14:11 Leandro-Albano

Are there any updates on this issue? I'm having trouble with this as well

BREAKING_CHANGES.md states that h is equivalent to React's React.createElement with following example:

const jsx = <ion-button>;
// is the same as:
const jsx = h('ion-button', null, null);

I took a look and they are not equivalent.

I'm facing an issue in where I can't render a component with props using h function.

  • React.createElement takes a second argument as props: any and then pass it to the component.
  • Stencil's h takes a second argument as data: vNodeData meaning that only class|className|style attributes will be passed to the component. as seen here leaving behind any other given keys in the props object.

Is there a way to achieve the same behavior as in React.createElement?

I'm just want to mount my kitchen sink components dynamically from a set of mocks, like this:

import { mocks } from 'components/index';

...
  render() {
    return (
      <div>
        {mocks.map(({ children, ...props }) => h(tag, props, children))}
      </div>
    );
  }

jhesgodi avatar Feb 18 '20 02:02 jhesgodi

Hi @Leandro-Albano 👋

Thanks for logging this issue and sorry it's sat for so long! I just ran a quick check in the latest version of Stencil and didn't run into any type of compiler warnings. If you're still experiencing issues, please update the issue with a minimum reproduction repo. Otherwise, the team will look to close out this issue in the near future. Thanks in advance!

tanner-reits avatar Sep 02 '22 19:09 tanner-reits

Thanks for the issue! This issue has been labeled as needs reproduction. This label is added to issues that need a code reproduction.

Please reproduce this issue in an Stencil starter component library and provide a way for us to access it (GitHub repo, StackBlitz, etc). Without a reliable code reproduction, it is unlikely we will be able to resolve the issue, leading to it being closed.

If you have already provided a code snippet and are seeing this message, it is likely that the code snippet was not enough for our team to reproduce the issue.

For a guide on how to create a good reproduction, see our Contributing Guide.

ionitron-bot[bot] avatar Sep 02 '22 19:09 ionitron-bot[bot]

Thanks for the issue! This issue is being closed due to inactivity. If this is still an issue with the latest version of Stencil, please create a new issue and ensure the template is fully filled out.

Thank you for using Stencil!

ionitron-bot[bot] avatar Oct 02 '22 20:10 ionitron-bot[bot]