Skip to content

Commit

Permalink
Fix #105 JSX types to include observable
Browse files Browse the repository at this point in the history
Co-authored-by: Brecert <Brecert@users.noreply.github.com>
  • Loading branch information
luwes and brecert committed May 5, 2020
1 parent d8db6ee commit 5c307b2
Showing 1 changed file with 11 additions and 21 deletions.
32 changes: 11 additions & 21 deletions packages/sinuous/src/jsx.d.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,9 @@
type Defaultize<Props, Defaults> =
// Distribute over unions
Props extends any // Make any properties included in Default optional
? Partial<Pick<Props, Extract<keyof Props, keyof Defaults>>> &
// Include the remaining properties from Props
Pick<Props, Exclude<keyof Props, keyof Defaults>>
: never;
import { Observable } from '../observable/src';

export namespace JSXInternal {
type LibraryManagedAttributes<Component, Props> = Component extends {
defaultProps: infer Defaults;
}
? Defaultize<Props, Defaults>
: Props;

// interface IntrinsicAttributes {
// key?: any;
// }

// interface Element extends preact.VNode<any> {}
type AllowObservable<Props> = { [K in keyof Props]: Props[K] | Observable<Props[K]> }

// interface ElementClass extends preact.Component<any, any> {}
interface Element extends HTMLElement { }

interface ElementAttributesProperty {
props: any;
Expand All @@ -29,7 +13,10 @@ export namespace JSXInternal {
children: any;
}

interface SVGAttributes<Target extends EventTarget = SVGElement>
type SVGAttributes<Target extends EventTarget = SVGElement>
= AllowObservable<_SVGAttributes<Target>>

interface _SVGAttributes<Target extends EventTarget = SVGElement>
extends HTMLAttributes<Target> {
accentHeight?: number | string;
accumulate?: 'none' | 'sum';
Expand Down Expand Up @@ -583,7 +570,10 @@ export namespace JSXInternal {
onTransitionEndCapture?: TransitionEventHandler<Target>;
}

interface HTMLAttributes<RefType extends EventTarget = EventTarget>
type HTMLAttributes<RefType extends EventTarget = EventTarget>
= AllowObservable<_HTMLAttributes<RefType>>

interface _HTMLAttributes<RefType extends EventTarget = EventTarget>
extends DOMAttributes<RefType> {
// Standard HTML Attributes
accept?: string;
Expand Down

0 comments on commit 5c307b2

Please sign in to comment.