0
나는 현재 타이프 스크립트 (typcript)에서 좀 더 진보 된 타이핑을 사용하고 있으며, 하이퍼 스크립트 (hyperscript)와 같은 함수를 정의하는 방법을 궁금해하고있다. 나는 다양한 접근법을 시도했지만 성공적으로 h
함수를 오버로드 할 수없고 사용법 주석 아래 나열된 모든 CallExpressions을 전달할 수 없습니다. 여기 하이퍼 스크립트 서명을위한 TypeScript 함수 오버로딩
interface IProps {
[key: string]: any;
}
function h(tag: string, props?: IProps): void;
function h(tag: string, children: string): void; // <- marked as invalid
function h(tag: string, props: IProps, children?: string): void {
// ...code goes here
}
사용법 :
h("div");
h("div", "Hello World");
h("div", { className: "test" });
h("div", { className: "test" }, "Hello World"); // <- marked as invalid