Skip to content

Commit

Permalink
Probably better to use all prop keys in auto-complete
Browse files Browse the repository at this point in the history
  • Loading branch information
Tao-VanJS committed Oct 26, 2023
1 parent 2e5060a commit 8f763a5
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 64 deletions.
14 changes: 6 additions & 8 deletions public/van-1.2.5.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,21 @@ export type Primitive = string | number | boolean | bigint

export type PropValue = Primitive | ((e: any) => void) | null

export type Props = Record<string, PropValue | StateView<PropValue> | (() => PropValue)>
export type PropValueOrDerived = PropValue | StateView<PropValue> | (() => PropValue)

type KeysWithPrefix<T, Prefix extends string> = {
[K in keyof T]: K extends `${Prefix}${infer Rest}` ? K : never
}[keyof T]
export interface Props extends Record<string, PropValueOrDerived> {
class?: PropValueOrDerived
}

type PropsWithEventHandlers<ElementType> = Partial<{
[K in keyof KeysWithPrefix<ElementType, "on">]: PropValue | StateView<PropValue> | (() => PropValue)
}>
type PropsWithKnownKeys<ElementType> = Partial<{[K in keyof ElementType]: PropValueOrDerived}>

export type ValidChildDomValue = Primitive | Node | null | undefined

export type BindingFunc = ((dom?: Node) => ValidChildDomValue) | ((dom?: Element) => Element)

export type ChildDom = ValidChildDomValue | StateView<Primitive | null | undefined> | BindingFunc | readonly ChildDom[]

export type TagFunc<Result> = (first?: Props & PropsWithEventHandlers<Result> | ChildDom, ...rest: readonly ChildDom[]) => Result
export type TagFunc<Result> = (first?: Props & PropsWithKnownKeys<Result> | ChildDom, ...rest: readonly ChildDom[]) => Result

type Tags = Readonly<Record<string, TagFunc<Element>>> & {
[K in keyof HTMLElementTagNameMap]: TagFunc<HTMLElementTagNameMap[K]>
Expand Down
14 changes: 6 additions & 8 deletions public/van-1.2.5.debug.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,21 @@ export type Primitive = string | number | boolean | bigint

export type PropValue = Primitive | ((e: any) => void) | null

export type Props = Record<string, PropValue | StateView<PropValue> | (() => PropValue)>
export type PropValueOrDerived = PropValue | StateView<PropValue> | (() => PropValue)

type KeysWithPrefix<T, Prefix extends string> = {
[K in keyof T]: K extends `${Prefix}${infer Rest}` ? K : never
}[keyof T]
export interface Props extends Record<string, PropValueOrDerived> {
class?: PropValueOrDerived
}

type PropsWithEventHandlers<ElementType> = Partial<{
[K in keyof KeysWithPrefix<ElementType, "on">]: PropValue | StateView<PropValue> | (() => PropValue)
}>
type PropsWithKnownKeys<ElementType> = Partial<{[K in keyof ElementType]: PropValueOrDerived}>

export type ValidChildDomValue = Primitive | Node | null | undefined

export type BindingFunc = ((dom?: Node) => ValidChildDomValue) | ((dom?: Element) => Element)

export type ChildDom = ValidChildDomValue | StateView<Primitive | null | undefined> | BindingFunc | readonly ChildDom[]

export type TagFunc<Result> = (first?: Props & PropsWithEventHandlers<Result> | ChildDom, ...rest: readonly ChildDom[]) => Result
export type TagFunc<Result> = (first?: Props & PropsWithKnownKeys<Result> | ChildDom, ...rest: readonly ChildDom[]) => Result

type Tags = Readonly<Record<string, TagFunc<Element>>> & {
[K in keyof HTMLElementTagNameMap]: TagFunc<HTMLElementTagNameMap[K]>
Expand Down
14 changes: 6 additions & 8 deletions public/van-1.2.5.min.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,21 @@ export type Primitive = string | number | boolean | bigint

export type PropValue = Primitive | ((e: any) => void) | null

export type Props = Record<string, PropValue | StateView<PropValue> | (() => PropValue)>
export type PropValueOrDerived = PropValue | StateView<PropValue> | (() => PropValue)

type KeysWithPrefix<T, Prefix extends string> = {
[K in keyof T]: K extends `${Prefix}${infer Rest}` ? K : never
}[keyof T]
export interface Props extends Record<string, PropValueOrDerived> {
class?: PropValueOrDerived
}

type PropsWithEventHandlers<ElementType> = Partial<{
[K in keyof KeysWithPrefix<ElementType, "on">]: PropValue | StateView<PropValue> | (() => PropValue)
}>
type PropsWithKnownKeys<ElementType> = Partial<{[K in keyof ElementType]: PropValueOrDerived}>

export type ValidChildDomValue = Primitive | Node | null | undefined

export type BindingFunc = ((dom?: Node) => ValidChildDomValue) | ((dom?: Element) => Element)

export type ChildDom = ValidChildDomValue | StateView<Primitive | null | undefined> | BindingFunc | readonly ChildDom[]

export type TagFunc<Result> = (first?: Props & PropsWithEventHandlers<Result> | ChildDom, ...rest: readonly ChildDom[]) => Result
export type TagFunc<Result> = (first?: Props & PropsWithKnownKeys<Result> | ChildDom, ...rest: readonly ChildDom[]) => Result

type Tags = Readonly<Record<string, TagFunc<Element>>> & {
[K in keyof HTMLElementTagNameMap]: TagFunc<HTMLElementTagNameMap[K]>
Expand Down
14 changes: 6 additions & 8 deletions public/van-latest.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,21 @@ export type Primitive = string | number | boolean | bigint

export type PropValue = Primitive | ((e: any) => void) | null

export type Props = Record<string, PropValue | StateView<PropValue> | (() => PropValue)>
export type PropValueOrDerived = PropValue | StateView<PropValue> | (() => PropValue)

type KeysWithPrefix<T, Prefix extends string> = {
[K in keyof T]: K extends `${Prefix}${infer Rest}` ? K : never
}[keyof T]
export interface Props extends Record<string, PropValueOrDerived> {
class?: PropValueOrDerived
}

type PropsWithEventHandlers<ElementType> = Partial<{
[K in keyof KeysWithPrefix<ElementType, "on">]: PropValue | StateView<PropValue> | (() => PropValue)
}>
type PropsWithKnownKeys<ElementType> = Partial<{[K in keyof ElementType]: PropValueOrDerived}>

export type ValidChildDomValue = Primitive | Node | null | undefined

export type BindingFunc = ((dom?: Node) => ValidChildDomValue) | ((dom?: Element) => Element)

export type ChildDom = ValidChildDomValue | StateView<Primitive | null | undefined> | BindingFunc | readonly ChildDom[]

export type TagFunc<Result> = (first?: Props & PropsWithEventHandlers<Result> | ChildDom, ...rest: readonly ChildDom[]) => Result
export type TagFunc<Result> = (first?: Props & PropsWithKnownKeys<Result> | ChildDom, ...rest: readonly ChildDom[]) => Result

type Tags = Readonly<Record<string, TagFunc<Element>>> & {
[K in keyof HTMLElementTagNameMap]: TagFunc<HTMLElementTagNameMap[K]>
Expand Down
14 changes: 6 additions & 8 deletions public/van-latest.debug.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,21 @@ export type Primitive = string | number | boolean | bigint

export type PropValue = Primitive | ((e: any) => void) | null

export type Props = Record<string, PropValue | StateView<PropValue> | (() => PropValue)>
export type PropValueOrDerived = PropValue | StateView<PropValue> | (() => PropValue)

type KeysWithPrefix<T, Prefix extends string> = {
[K in keyof T]: K extends `${Prefix}${infer Rest}` ? K : never
}[keyof T]
export interface Props extends Record<string, PropValueOrDerived> {
class?: PropValueOrDerived
}

type PropsWithEventHandlers<ElementType> = Partial<{
[K in keyof KeysWithPrefix<ElementType, "on">]: PropValue | StateView<PropValue> | (() => PropValue)
}>
type PropsWithKnownKeys<ElementType> = Partial<{[K in keyof ElementType]: PropValueOrDerived}>

export type ValidChildDomValue = Primitive | Node | null | undefined

export type BindingFunc = ((dom?: Node) => ValidChildDomValue) | ((dom?: Element) => Element)

export type ChildDom = ValidChildDomValue | StateView<Primitive | null | undefined> | BindingFunc | readonly ChildDom[]

export type TagFunc<Result> = (first?: Props & PropsWithEventHandlers<Result> | ChildDom, ...rest: readonly ChildDom[]) => Result
export type TagFunc<Result> = (first?: Props & PropsWithKnownKeys<Result> | ChildDom, ...rest: readonly ChildDom[]) => Result

type Tags = Readonly<Record<string, TagFunc<Element>>> & {
[K in keyof HTMLElementTagNameMap]: TagFunc<HTMLElementTagNameMap[K]>
Expand Down
14 changes: 6 additions & 8 deletions public/van-latest.min.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,21 @@ export type Primitive = string | number | boolean | bigint

export type PropValue = Primitive | ((e: any) => void) | null

export type Props = Record<string, PropValue | StateView<PropValue> | (() => PropValue)>
export type PropValueOrDerived = PropValue | StateView<PropValue> | (() => PropValue)

type KeysWithPrefix<T, Prefix extends string> = {
[K in keyof T]: K extends `${Prefix}${infer Rest}` ? K : never
}[keyof T]
export interface Props extends Record<string, PropValueOrDerived> {
class?: PropValueOrDerived
}

type PropsWithEventHandlers<ElementType> = Partial<{
[K in keyof KeysWithPrefix<ElementType, "on">]: PropValue | StateView<PropValue> | (() => PropValue)
}>
type PropsWithKnownKeys<ElementType> = Partial<{[K in keyof ElementType]: PropValueOrDerived}>

export type ValidChildDomValue = Primitive | Node | null | undefined

export type BindingFunc = ((dom?: Node) => ValidChildDomValue) | ((dom?: Element) => Element)

export type ChildDom = ValidChildDomValue | StateView<Primitive | null | undefined> | BindingFunc | readonly ChildDom[]

export type TagFunc<Result> = (first?: Props & PropsWithEventHandlers<Result> | ChildDom, ...rest: readonly ChildDom[]) => Result
export type TagFunc<Result> = (first?: Props & PropsWithKnownKeys<Result> | ChildDom, ...rest: readonly ChildDom[]) => Result

type Tags = Readonly<Record<string, TagFunc<Element>>> & {
[K in keyof HTMLElementTagNameMap]: TagFunc<HTMLElementTagNameMap[K]>
Expand Down
14 changes: 6 additions & 8 deletions src/van.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,21 @@ export type Primitive = string | number | boolean | bigint

export type PropValue = Primitive | ((e: any) => void) | null

export type Props = Record<string, PropValue | StateView<PropValue> | (() => PropValue)>
export type PropValueOrDerived = PropValue | StateView<PropValue> | (() => PropValue)

type KeysWithPrefix<T, Prefix extends string> = {
[K in keyof T]: K extends `${Prefix}${infer Rest}` ? K : never
}[keyof T]
export interface Props extends Record<string, PropValueOrDerived> {
class?: PropValueOrDerived
}

type PropsWithEventHandlers<ElementType> = Partial<{
[K in KeysWithPrefix<ElementType, "on">]: PropValue | StateView<PropValue> | (() => PropValue)
}>
type PropsWithKnownKeys<ElementType> = Partial<{[K in keyof ElementType]: PropValueOrDerived}>

export type ValidChildDomValue = Primitive | Node | null | undefined

export type BindingFunc = ((dom?: Node) => ValidChildDomValue) | ((dom?: Element) => Element)

export type ChildDom = ValidChildDomValue | StateView<Primitive | null | undefined> | BindingFunc | readonly ChildDom[]

export type TagFunc<Result> = (first?: Props & PropsWithEventHandlers<Result> | ChildDom, ...rest: readonly ChildDom[]) => Result
export type TagFunc<Result> = (first?: Props & PropsWithKnownKeys<Result> | ChildDom, ...rest: readonly ChildDom[]) => Result

type Tags = Readonly<Record<string, TagFunc<Element>>> & {
[K in keyof HTMLElementTagNameMap]: TagFunc<HTMLElementTagNameMap[K]>
Expand Down
14 changes: 6 additions & 8 deletions src/van.debug.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,21 @@ export type Primitive = string | number | boolean | bigint

export type PropValue = Primitive | ((e: any) => void) | null

export type Props = Record<string, PropValue | StateView<PropValue> | (() => PropValue)>
export type PropValueOrDerived = PropValue | StateView<PropValue> | (() => PropValue)

type KeysWithPrefix<T, Prefix extends string> = {
[K in keyof T]: K extends `${Prefix}${infer Rest}` ? K : never
}[keyof T]
export interface Props extends Record<string, PropValueOrDerived> {
class?: PropValueOrDerived
}

type PropsWithEventHandlers<ElementType> = Partial<{
[K in keyof KeysWithPrefix<ElementType, "on">]: PropValue | StateView<PropValue> | (() => PropValue)
}>
type PropsWithKnownKeys<ElementType> = Partial<{[K in keyof ElementType]: PropValueOrDerived}>

export type ValidChildDomValue = Primitive | Node | null | undefined

export type BindingFunc = ((dom?: Node) => ValidChildDomValue) | ((dom?: Element) => Element)

export type ChildDom = ValidChildDomValue | StateView<Primitive | null | undefined> | BindingFunc | readonly ChildDom[]

export type TagFunc<Result> = (first?: Props & PropsWithEventHandlers<Result> | ChildDom, ...rest: readonly ChildDom[]) => Result
export type TagFunc<Result> = (first?: Props & PropsWithKnownKeys<Result> | ChildDom, ...rest: readonly ChildDom[]) => Result

type Tags = Readonly<Record<string, TagFunc<Element>>> & {
[K in keyof HTMLElementTagNameMap]: TagFunc<HTMLElementTagNameMap[K]>
Expand Down

0 comments on commit 8f763a5

Please sign in to comment.