Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various type improvements #120

Merged
merged 3 commits into from
Jun 13, 2024
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
5 changes: 5 additions & 0 deletions .changeset/poor-suits-hide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@knuckles/typescript": patch
---

Various type improvements
13 changes: 7 additions & 6 deletions packages/typescript/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ declare global {
n: Comment | Element,
v: any,
c: BindingContext,
) => void;
) => any;
export type ReturnsChildContext = (
n: Comment | Element,
v: any,
Expand Down Expand Up @@ -198,7 +198,8 @@ declare global {
* @see https://knockoutjs.com/documentation/options-binding.html
*/
options: PreserveBinding<
MaybeSubscribable<readonly unknown[]> | ko.ObservableArray<unknown>,
| MaybeSubscribable<unknown[] | readonly unknown[]>
| ko.ObservableArray<unknown>,
HTMLSelectElement
>;
/**
Expand Down Expand Up @@ -370,7 +371,7 @@ declare global {
* @see https://knockoutjs.com/documentation/options-binding.html
*/
options: PreserveBinding<
MaybeSubscribable<readonly any[]> | ko.ObservableArray<any>,
MaybeSubscribable<any[] | readonly any[]> | ko.ObservableArray<any>,
HTMLSelectElement
>;
/**
Expand Down Expand Up @@ -502,7 +503,7 @@ declare global {
* @see https://knockoutjs.com/documentation/checked-binding.html
*/
checked: PreserveBinding<
| MaybeSubscribable<boolean | readonly string[]>
| MaybeSubscribable<boolean | string | readonly string[]>
| ko.ObservableArray<string>,
HTMLInputElement
>;
Expand Down Expand Up @@ -583,9 +584,9 @@ declare global {

export interface Settings {}

type Instanciate<T> = T extends new () => infer U
type Instanciate<T> = T extends new (...args: any) => infer U
? U
: T extends () => infer U
: T extends (...args: any) => infer U
? U
: T;
type DefaultInterop<T> = Instanciate<
Expand Down
Loading