Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions types/ClientContext.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { NullstackWorker } from './Worker'
/**
* @see https://nullstack.app/context
*/
interface BaseNullstackClientContext {
interface BaseNullstackClientContext<TProps = unknown> {
/**
* Callback function that bootstrap the context for the application.
*/
Expand Down Expand Up @@ -120,15 +120,17 @@ interface BaseNullstackClientContext {
*
* @see https://nullstack.app/refs#complex-refable-components
*/
ref?: { property?: string | number; object?: any } | ((context: NullstackClientContext) => void)
ref?: TProps extends { ref: any } ? TProps['ref'] : {
object: any
property: string | number
}

/**
* Ref element.
*
* @see https://nullstack.app/refs#complex-refable-components
*/

element?: HTMLElement
}

export type NullstackClientContext<TProps = unknown> = BaseNullstackClientContext & TProps
export type NullstackClientContext<TProps = unknown> = BaseNullstackClientContext<TProps> & TProps
16 changes: 8 additions & 8 deletions types/JSX.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,22 @@ type Booleanish = boolean | 'true' | 'false'
// Nullstack Elements
// ----------------------------------------------------------------------

export interface Attributes<HTMLElementType> {
export interface Attributes<HTMLElementType = unknown> {
html?: string
source?: object
bind?: any
debounce?: number
ref?: HTMLElementType | ((context?: Partial<NullstackClientContext>) => void)
ref?: HTMLElementType | ((context?: Partial<NullstackClientContext>) => void) | NullstackClientContext['ref']
'data-'?: any
children?: NullstackNode
route?: string
persistent?: boolean
[key: string]: any
}

export interface NullstackAttributes<T> extends Attributes<T> {}
export interface NullstackAttributes extends Attributes {}

export interface ClassAttributes<T> extends Attributes<T> {
export interface ClassAttributes<T = unknown> extends Attributes<T> {
key?: string
}

Expand Down Expand Up @@ -1233,18 +1233,18 @@ export interface SVGAttributes<T> extends AriaAttributes, DOMAttributes<T> {
y?: number | string
}

export type ElementTagHTMLAttributes = AllHTMLAttributes<'div'> & {
export type ElementTagHTMLAttributes = AllHTMLAttributes<HTMLDivElement> & {
tag?: string
}

type ExoticElements = Record<string, DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>>
type ExoticElements = Record<string, DetailedHTMLProps<HTMLAttributes<HTMLElement> | SVGProps<any> | ElementTagHTMLAttributes, HTMLElement>>

declare global {
namespace JSX {
type Element = NullstackNode

type IntrinsicAttributes = NullstackAttributes<unknown>
type IntrinsicClassAttributes = ClassAttributes<unknown>
type IntrinsicAttributes = NullstackAttributes
type IntrinsicClassAttributes = ClassAttributes

interface AllElements {
// HTML
Expand Down