How to use the tiny-decoders.triple function in tiny-decoders

To help you get started, we’ve selected a few tiny-decoders examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lydell / tiny-decoders / typescript / decoders.ts View on Github external
array(string)(undefined, []);
// $ExpectError
array(string)(undefined, {});
dict(string)(undefined, []);
// $ExpectError
dict(string)(undefined, {});
record(() => "")(undefined, []);
// $ExpectError
record(() => "")(undefined, {});
tuple(() => "")(undefined, []);
// $ExpectError
tuple(() => "")(undefined, {});
pair(string, boolean)(undefined, []);
// $ExpectError
pair(string, boolean)(undefined, {});
triple(string, boolean, boolean)(undefined, []);
// $ExpectError
triple(string, boolean, boolean)(undefined, {});
autoRecord({})(undefined, []);
// $ExpectError
autoRecord({})(undefined, {});
deep([], string)(undefined, []);
// $ExpectError
deep({}, string)(undefined, []);
optional(string)(undefined, []);
// $ExpectError
optional(string)(undefined, {});
map(string, string)(undefined, []);
// $ExpectError
map(string, string)(undefined, {});
either(string, number)(undefined, []);
// $ExpectError
github lydell / tiny-decoders / typescript / decoders.ts View on Github external
// $ExpectType { [key: string]: string; }
dict(string)(undefined);
// $ExpectType string
record(() => "")(undefined);
// $ExpectType { a: string; }
record(field => ({ a: field("a", string) }))(undefined);
// $ExpectType string
tuple(() => "")(undefined);
// $ExpectType string[]
tuple(item => [item(0, string)])(undefined);
// $ExpectType [string]
tuple<[string]>(item => [item(0, string)])(undefined);
// $ExpectType [string, boolean]
pair(string, boolean)(undefined);
// $ExpectType [string, boolean, boolean]
triple(string, boolean, boolean)(undefined);
// $ExpectType {}
autoRecord<{}>({})(undefined);
// $ExpectType { a: string; }
autoRecord({ a: string })(undefined);
// $ExpectType { a: string; b: number; }
autoRecord({ a: string, b: number })(undefined);
// $ExpectType { a: string; b: number; }
autoRecord({ a: string, b: number })(undefined);
// $ExpectType { a: string; b: number; c: boolean | undefined; }
autoRecord({ a: string, b: number, c: optional(boolean) })(undefined);
// $ExpectType string
deep([], string)(undefined);
// $ExpectType string | undefined
optional(string)(undefined);
// $ExpectType string
optional(string, "default")(undefined);