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

Add types for vue h #1356

Closed
xiaoxiangmoe opened this issue Jun 13, 2020 · 6 comments
Closed

Add types for vue h #1356

xiaoxiangmoe opened this issue Jun 13, 2020 · 6 comments

Comments

@xiaoxiangmoe
Copy link
Contributor

Add these codes in vue-next/packages/runtime-dom/types/jsx.d.ts

import {
  VNode,
  VNodeArrayChildren,
  VNodeProps,
  ComponentInternalInstance,
} from '@vue/runtime-core';

declare module 'vue' {
  // copy from @vue/runtime-core
  type RawChildren =
    | string
    | number
    | boolean
    | VNode
    | VNodeArrayChildren
    | (() => any);
  // copy from @vue/runtime-core
  type RawProps = VNodeProps & {
    __v_isVNode?: never;
    [Symbol.iterator]?: never;
  };
  // copy from @vue/runtime-core
  type RawSlots = {
    [name: string]: unknown;
    $stable?: boolean;
    _ctx?: ComponentInternalInstance | null;
    _?: 1;
  }; 
  
  export function h<K extends StringKeyOf<IntrinsicElementAttributes>>(
    type: K ,
    props?: RawProps & ElementAttrs< 
    IntrinsicElementAttributes[K]
  > | null,
    children?: RawChildren | RawSlots
  ): VNode;
}

These codes will help us to do type checking with @vuedx/typecheck


Another Question: What help does @vuedx need? It seems that its development has stoped for several weeks.

@LinusBorg
Copy link
Member

@xiaoxiangmoe is this still relevant? There have been significant changes been done to jsx.d.ts, so can you please respond wether this issue is still actionable or can be closed?

Thanks!

@xiaoxiangmoe
Copy link
Contributor Author

this issue is still actionable.

See example:

import { h } from 'vue'
// @ts-expect-error Parameter 'event' implicitly has an 'any' type.ts(7006)
export default h('button',{ onClick: event => { console.log(event) } })

@LinusBorg
Copy link
Member

Thanks

@znck
Copy link
Member

znck commented Oct 29, 2020

Now, I'm not using h in TS plugin but I'll confirm if this affects JSX or not.

@xiaoxiangmoe
Copy link
Contributor Author

@znck Could you sharing us the reason why not using h in TS plugin. Thank you.

@znck
Copy link
Member

znck commented Oct 29, 2020

Template is converted to TSX so h is not required for type checking.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants