-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
- Loading branch information
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,2 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules | ||
jspm_packages | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
.vscode | ||
|
||
.DS_Store | ||
|
||
/dist | ||
/deno_dist | ||
|
||
/node_modules |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import type { Unite } from "./tools/Unite"; | ||
import type { StrictEquals } from "./tools/StrictEquals"; | ||
/** https://docs.tsafe.dev/main/equals */ | ||
export type Equals<A1, A2> = StrictEquals<Unite<A1>, Unite<A2>>; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { StrictEquals } from "./tools/StrictEquals"; | ||
/** | ||
* @see <https://docs.tsafe.dev/main/extends> | ||
* | ||
* Usage example: assert<Extends<A, B>>(); | ||
**/ | ||
export type Extends<A1, A2> = StrictEquals<A1, never> extends true ? true : StrictEquals<A2, never> extends true ? false : StrictEquals<A2, any> extends true ? true : StrictEquals<A2, unknown> extends true ? true : StrictEquals<A1, any> extends true ? false : StrictEquals<A1, unknown> extends true ? false : A1 extends A2 ? true : false; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/** https://docs.tsafe.dev/methodnames */ | ||
export type MethodNames<Api> = NonNullable<{ | ||
[Key in keyof Api]: Api[Key] extends ((...args: any[]) => unknown) | undefined ? Key : never; | ||
}[keyof Api]>; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/** https://docs.tsafe.dev/main/not */ | ||
export type Not<B extends boolean> = B extends true ? false : true; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import type { Parameters } from "./Parameters"; | ||
type NonUndefined<T> = T extends undefined ? never : T; | ||
/** Shorthand for Parameters<typeof f>[0] https://docs.tsafe.dev/param0 */ | ||
export type Param0<T extends ((...args: any[]) => unknown) | null | undefined | false | ""> = [ | ||
Parameters<T> | ||
] extends [never] ? never : Parameters<T> extends [] ? void : NonUndefined<Parameters<T>[0]>; | ||
export {}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/** https://docs.tsafe.dev/parameters */ | ||
export type Parameters<T extends ((...args: any[]) => unknown) | null | undefined | false | ""> = T extends (...args: infer P) => any ? P : never; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
type OptionalKeyof<T extends Record<string, unknown>> = Exclude<{ | ||
[Key in keyof T]: T extends Record<Key, T[Key]> ? never : Key; | ||
}[keyof T], undefined>; | ||
/** | ||
* PickOptionals<{ p1: string; p2?: string; p3?: number; }> | ||
* is the type | ||
* { p2: string; p3: number; } | ||
*/ | ||
export type PickOptionals<T extends Record<string, unknown>> = Required<Pick<T, OptionalKeyof<T>>>; | ||
export {}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { PickOptionals } from "./PickOptionals"; | ||
/** | ||
* PickRequired<{ p1: string; p2?: string; p3?: number; p4: string; }> | ||
* is the type | ||
* { p1: string; p4: number; } | ||
*/ | ||
export type PickRequired<T extends Record<string, unknown>> = Omit<T, keyof PickOptionals<T>>; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/** Always return null but pretends it returns an object of type T */ | ||
export declare function Reflect<T>(): T; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/** https://docs.tsafe.dev/returntype */ | ||
export type ReturnType<T extends ((...args: any[]) => unknown) | undefined | null | false | ""> = T extends (...args: any[]) => infer R ? (R extends PromiseLike<infer J> ? J : R) : never; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/** @see <https://docs.tsafe.dev/uniontointersection> **/ | ||
export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** | ||
* Use case: | ||
* declare const pr: Promise<string[]>; | ||
* const x: UnpackPromise<typeof pr>; <== x is string[] | ||
*/ | ||
export type UnpackPromise<T extends PromiseLike<unknown> | undefined | null | false | ""> = T extends PromiseLike<infer U> ? U : never; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export type { Equals } from "./Equals"; | ||
/** @see <https://docs.tsafe.dev/assert#error-thrown> */ | ||
export declare class AssertionError extends Error { | ||
constructor(msg: string | undefined); | ||
} | ||
/** https://docs.tsafe.dev/assert */ | ||
export declare function assert<_T extends true>(condition?: any, msg?: string): asserts condition; |