typelevel-ts
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -163,1 +163,4 @@ export declare type Bool = 'true' | 'false'; | ||
export declare type NotStringEq<L1 extends string, L2 extends string> = Not<StringEq<L1, L2>>; | ||
export declare type Clean<T> = { | ||
[K in keyof T]: T[K]; | ||
}; |
{ | ||
"name": "typelevel-ts", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Type level programming in TypeScript", | ||
@@ -5,0 +5,0 @@ "files": [ |
@@ -1,3 +0,5 @@ | ||
# Example: vectors | ||
# `Nat`urals | ||
**Example**. Type-safe vectors | ||
```ts | ||
@@ -43,1 +45,49 @@ import { _1, _2, _3, Nat, Add } from 'typelevel-ts' | ||
``` | ||
# The `Omit` operator | ||
**Example**. A `withDefaults` function (React) | ||
```ts | ||
import * as React from 'react' | ||
import { Omit, Clean } from 'typelevel-ts' | ||
export default function withDefaults<A, D extends keyof A>( | ||
C: React.ComponentType<A>, | ||
defaults: Pick<A, D> | ||
): React.SFC<Clean<Omit<A, D> & Partial<Pick<A, D>>>> { | ||
return (props: any) => <C {...Object.assign({}, defaults, props)} /> | ||
} | ||
class Foo extends React.Component<{ bar: string; baz: number }, void> {} | ||
const FilledFoo = withDefaults(Foo, { baz: 1 }) | ||
const x = <FilledFoo bar="bar" /> // ok | ||
``` | ||
**Example**. A `withProps` function (React) | ||
```ts | ||
import { Omit } from 'typelevel-ts' | ||
import * as React from 'react' | ||
function withProps<D, P extends D>(C: React.ComponentType<P>, values: D): React.SFC<Omit<P, keyof D>> { | ||
return (props: any) => <C {...Object.assign({}, props, values)} /> | ||
} | ||
class Foo extends React.Component<{ bar: string; baz: number }, void> {} | ||
const FilledFoo = withProps(Foo, { baz: 1 }) | ||
const x = <FilledFoo bar="bar" /> // ok | ||
``` | ||
# The `Diff` operator | ||
```ts | ||
import { Diff } from 'typelevel-ts' | ||
type Foo = { a: string; b: number } | ||
type Bar = { b: number } | ||
// Baz :: { a: string, b?: number } | ||
type Baz = Diff<Foo, Bar> | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10783
171
93