Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

typelevel-ts

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typelevel-ts - npm Package Compare versions

Comparing version 0.0.2 to 0.1.0

64

lib/index.d.ts

@@ -24,3 +24,2 @@ export declare type Bool = 'true' | 'false';

}[B1][B2];
export declare type NotEq<B1 extends Bool, B2 extends Bool> = Not<Eq<B1, B2>>;
export declare type If<B extends Bool, Then, Else> = {

@@ -64,3 +63,2 @@ true: Then;

}[IsZero<N1>];
export declare type NotNatEq<N1 extends Nat, N2 extends Nat> = Not<NatEq<N1, N2>>;
export declare type Add<N1 extends Nat, N2 extends Nat> = {

@@ -92,3 +90,3 @@ true: N2;

export declare type Lte<N1 extends Nat, N2 extends Nat> = IsSome<Sub<N2, N1>>;
export declare type Lt<N1 extends Nat, N2 extends Nat> = And<Lte<N1, N2>, NotNatEq<N1, N2>>;
export declare type Lt<N1 extends Nat, N2 extends Nat> = And<Lte<N1, N2>, Not<NatEq<N1, N2>>>;
export declare type Gte<N1 extends Nat, N2 extends Nat> = Not<Lt<N1, N2>>;

@@ -120,3 +118,12 @@ export declare type Gt<N1 extends Nat, N2 extends Nat> = Not<Lte<N1, N2>>;

export declare type _10 = Succ<_9>;
export declare type ContainsLiteral<S extends string, L extends string> = ({
export declare type StringOmit<L1 extends string, L2 extends string> = ({
[P in L1]: P;
} & {
[P in L2]: never;
} & {
[key: string]: never;
})[L1];
export declare type StringEq<L1 extends string, L2 extends string> = And<StringContains<L1, L2>, StringContains<L2, L1>>;
export declare type StringIntersection<L1 extends string, L2 extends string> = StringOmit<L1, StringOmit<L1, L2>>;
export declare type StringContains<S extends string, L extends string> = ({
[K in S]: 'true';

@@ -126,45 +133,6 @@ } & {

})[L];
export declare type NotContainsLiteral<S extends string, L extends string> = Not<ContainsLiteral<S, L>>;
export declare type HasKey<O, L extends string> = ContainsLiteral<keyof O, L>;
export declare type NotHasKey<O, L extends string> = Not<ContainsLiteral<keyof O, L>>;
export declare type MergeFields<O1, O2> = {
[K in keyof O1 | keyof O2]: {
true: O2[K];
false: O1[K];
}[HasKey<O2, K>];
};
export declare type AddFields<O1, O2> = {
[K in keyof O1 | keyof O2]: {
true: O1[K];
false: O2[K];
}[HasKey<O1, K>];
};
/** private */
export declare type __Omit<O, U extends string, O_ extends any = {
[K in keyof O]: {
true: K;
false: never;
}[NotContainsLiteral<U, K>];
}, K_ extends string = keyof Pick<O_, keyof O>> = {
[K in O_[K_]]: O[K];
};
export declare type Omit<O, U extends string> = __Omit<O, U>;
/** private */
export declare type __Diff<O1 extends O2, O2, O1_ extends any = {
[K in keyof O1]: {
true: K;
false: never;
}[NotContainsLiteral<keyof O2, K>];
}, K1_ extends string = keyof Pick<O1_, keyof O1>> = {
[K in O1_[K1_]]: O1[K];
} & {
[K in keyof O2]?: O2[K];
};
export declare type Diff<O1 extends O2, O2> = __Diff<O1, O2>;
export declare type StringEq<L1 extends string, L2 extends string> = HasKey<{
[K in L1]: any;
}, L2>;
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];
};
export declare type ObjectHasKey<O, L extends string> = StringContains<keyof O, L>;
export declare type ObjectOverwrite<O1, O2> = Pick<O1, StringOmit<keyof O1, keyof O2>> & O2;
export declare type ObjectOmit<O, K extends string> = Pick<O, StringOmit<keyof O, K>>;
export declare type ObjectDiff<O1 extends O2, O2> = ObjectOmit<O1, keyof O2> & Partial<O2>;
export declare type ObjectClean<T> = Pick<T, keyof T>;
"use strict";
// adapted from
// - https://github.com/Microsoft/TypeScript/issues/14833
// - https://github.com/Microsoft/TypeScript/issues/16392
// - https://github.com/Microsoft/TypeScript/issues/12215
//
// Bool - type level booleans
//
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=index.js.map
{
"name": "typelevel-ts",
"version": "0.0.2",
"version": "0.1.0",
"description": "Type level programming in TypeScript",
"files": [
"lib"
],
"files": ["lib"],
"main": "lib/index.js",

@@ -13,3 +11,3 @@ "typings": "lib/index.d.ts",

"typings-checker": "typings-checker --allow-expect-error --project typings-checker/tsconfig.json typings-checker/index.ts",
"prettier": "prettier --no-semi --single-quote --print-width 120 --parser typescript --list-different \"{src,test}/**/*.ts\"",
"prettier": "prettier --no-semi --single-quote --print-width 120 --parser typescript --list-different \"{src,typings-checker}/**/*.ts\"",
"test": "npm run prettier && npm run lint && npm run typings-checker",

@@ -31,6 +29,6 @@ "clean": "rm -rf lib/*",

"devDependencies": {
"prettier": "^1.4.2",
"prettier": "1.5.2",
"tslint": "4.4.2",
"tslint-config-standard": "4.0.0",
"typescript": "2.3.4",
"typescript": "2.4.1",
"typings-checker": "1.1.2"

@@ -37,0 +35,0 @@ },

@@ -0,1 +1,10 @@

**Requires TypeScript v2.4.1+**
Adapted from
- https://github.com/Microsoft/TypeScript/issues/14833
- https://github.com/Microsoft/TypeScript/issues/16392
- https://github.com/Microsoft/TypeScript/issues/12215
# `Nat`urals

@@ -46,3 +55,3 @@

# The `Omit` operator
# The `ObjectOmit` operator

@@ -53,3 +62,3 @@ **Example**. A `withDefaults` function (React)

import * as React from 'react'
import { Omit, Clean } from 'typelevel-ts'
import { ObjectOmit } from 'typelevel-ts'

@@ -59,3 +68,3 @@ export default function withDefaults<A, D extends keyof A>(

defaults: Pick<A, D>
): React.SFC<Clean<Omit<A, D> & Partial<Pick<A, D>>>> {
): React.SFC<ObjectOmit<A, D> & Partial<Pick<A, D>>> {
return (props: any) => <C {...Object.assign({}, defaults, props)} />

@@ -65,4 +74,4 @@ }

class Foo extends React.Component<{ bar: string; baz: number }, void> {}
const FilledFoo = withDefaults(Foo, { baz: 1 })
const x = <FilledFoo bar="bar" /> // ok
const DefaultedFoo = withDefaults(Foo, { baz: 1 })
const x = <DefaultedFoo bar="bar" /> // ok
```

@@ -73,6 +82,6 @@

```ts
import { Omit } from 'typelevel-ts'
import { ObjectOmit } 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>> {
function withProps<D, P extends D>(C: React.ComponentType<P>, values: D): React.SFC<ObjectOmit<P, keyof D>> {
return (props: any) => <C {...Object.assign({}, props, values)} />

@@ -86,3 +95,3 @@ }

# The `Diff` operator
# The `ObjectDiff` operator

@@ -89,0 +98,0 @@ ```ts

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc