Skip to content

Commit

Permalink
fix meta props when using Component type
Browse files Browse the repository at this point in the history
  • Loading branch information
UpperCod committed Jul 18, 2022
1 parent 3169823 commit 284b2a5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "atomico",
"version": "1.61.0",
"version": "1.61.1",
"description": "Atomico is a small library for the creation of interfaces based on web-components, only using functions and hooks.",
"type": "module",
"main": "./core.js",
Expand Down
14 changes: 10 additions & 4 deletions types/core.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ export type SyntheticProps<Props> = {
};
};

export type SyntheticMetaProps<Meta> = {
[Prop in keyof Meta]?: Prop extends `on${string}`
? (event: Meta[Prop]) => any
: Meta[Prop];
};

export type Type<Types> = TypeToConstructor<Types> & { meta?: Types };

/**
Expand Down Expand Up @@ -150,9 +156,6 @@ interface MetaComponent {
props: MetaProps<any>;
styles?: Sheets;
}
/**
* Functional component validation
*/
export type Component<props = null, meta = any> = props extends null
? {
(props: FillObject): Host<meta>;
Expand All @@ -161,7 +164,10 @@ export type Component<props = null, meta = any> = props extends null
}
: {
(props: DOMProps<props>): Host<meta>;
props: SchemaInfer<props>;
props: SchemaInfer<props> &
MetaProps<
meta extends null ? props : props & SyntheticMetaProps<meta>
>;
styles?: Sheets;
};

Expand Down

0 comments on commit 284b2a5

Please sign in to comment.