mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-04 20:21:46 +00:00
[ramda] cleanup (#40738)
* chore: replace `Ensure` with `Clean` alias * chore: update ts-toolbelt * fix: return type of match * chore: moved type utilities to tools.d.ts * chore: move merge type utilities to tools * chore: move merge utilities + info header * chore: update ts-toolbelt * fix: lint, tool imports * fix: import * fix: comment lint * fix: lint * chore: move MergeAll * fix: export utility types * fix: lint * chore: flatten declaration * fix: typo * chore: remove references * chore: remove old project * chore: move references to OTHER_FILES.txt * chore: readme * fix: export global nsp
This commit is contained in:
committed by
Ron Buckton
parent
7ebf9c4e34
commit
e8add0e478
@@ -0,0 +1,505 @@
|
||||
es/add.d.ts
|
||||
es/addIndex.d.ts
|
||||
es/adjust.d.ts
|
||||
es/all.d.ts
|
||||
es/allPass.d.ts
|
||||
es/always.d.ts
|
||||
es/and.d.ts
|
||||
es/any.d.ts
|
||||
es/anyPass.d.ts
|
||||
es/ap.d.ts
|
||||
es/aperture.d.ts
|
||||
es/append.d.ts
|
||||
es/apply.d.ts
|
||||
es/applySpec.d.ts
|
||||
es/applyTo.d.ts
|
||||
es/ascend.d.ts
|
||||
es/assoc.d.ts
|
||||
es/assocPath.d.ts
|
||||
es/binary.d.ts
|
||||
es/bind.d.ts
|
||||
es/both.d.ts
|
||||
es/call.d.ts
|
||||
es/chain.d.ts
|
||||
es/clamp.d.ts
|
||||
es/clone.d.ts
|
||||
es/comparator.d.ts
|
||||
es/complement.d.ts
|
||||
es/compose.d.ts
|
||||
es/composeK.d.ts
|
||||
es/composeP.d.ts
|
||||
es/composeWith.d.ts
|
||||
es/concat.d.ts
|
||||
es/cond.d.ts
|
||||
es/construct.d.ts
|
||||
es/constructN.d.ts
|
||||
es/contains.d.ts
|
||||
es/converge.d.ts
|
||||
es/countBy.d.ts
|
||||
es/curry.d.ts
|
||||
es/curryN.d.ts
|
||||
es/dec.d.ts
|
||||
es/defaultTo.d.ts
|
||||
es/descend.d.ts
|
||||
es/difference.d.ts
|
||||
es/differenceWith.d.ts
|
||||
es/dissoc.d.ts
|
||||
es/dissocPath.d.ts
|
||||
es/divide.d.ts
|
||||
es/drop.d.ts
|
||||
es/dropLast.d.ts
|
||||
es/dropLastWhile.d.ts
|
||||
es/dropRepeats.d.ts
|
||||
es/dropRepeatsWith.d.ts
|
||||
es/either.d.ts
|
||||
es/empty.d.ts
|
||||
es/endsWith.d.ts
|
||||
es/eqBy.d.ts
|
||||
es/eqProps.d.ts
|
||||
es/equals.d.ts
|
||||
es/evolve.d.ts
|
||||
es/F.d.ts
|
||||
es/filter.d.ts
|
||||
es/find.d.ts
|
||||
es/findIndex.d.ts
|
||||
es/findLast.d.ts
|
||||
es/findLastIndex.d.ts
|
||||
es/flatten.d.ts
|
||||
es/flip.d.ts
|
||||
es/forEach.d.ts
|
||||
es/forEachObjIndexed.d.ts
|
||||
es/fromPairs.d.ts
|
||||
es/groupBy.d.ts
|
||||
es/groupWith.d.ts
|
||||
es/gt.d.ts
|
||||
es/gte.d.ts
|
||||
es/has.d.ts
|
||||
es/hasIn.d.ts
|
||||
es/hasPath.d.ts
|
||||
es/head.d.ts
|
||||
es/identical.d.ts
|
||||
es/identity.d.ts
|
||||
es/ifElse.d.ts
|
||||
es/inc.d.ts
|
||||
es/indexBy.d.ts
|
||||
es/indexOf.d.ts
|
||||
es/init.d.ts
|
||||
es/innerJoin.d.ts
|
||||
es/insertAll.d.ts
|
||||
es/insert.d.ts
|
||||
es/intersection.d.ts
|
||||
es/intersectionWith.d.ts
|
||||
es/intersperse.d.ts
|
||||
es/into.d.ts
|
||||
es/invert.d.ts
|
||||
es/invertObj.d.ts
|
||||
es/invoker.d.ts
|
||||
es/is.d.ts
|
||||
es/isEmpty.d.ts
|
||||
es/isNil.d.ts
|
||||
es/join.d.ts
|
||||
es/juxt.d.ts
|
||||
es/keys.d.ts
|
||||
es/keysIn.d.ts
|
||||
es/last.d.ts
|
||||
es/lastIndexOf.d.ts
|
||||
es/length.d.ts
|
||||
es/lens.d.ts
|
||||
es/lensIndex.d.ts
|
||||
es/lensPath.d.ts
|
||||
es/lensProp.d.ts
|
||||
es/lift.d.ts
|
||||
es/lt.d.ts
|
||||
es/lte.d.ts
|
||||
es/mapAccum.d.ts
|
||||
es/mapAccumRight.d.ts
|
||||
es/map.d.ts
|
||||
es/mapObjIndexed.d.ts
|
||||
es/match.d.ts
|
||||
es/mathMod.d.ts
|
||||
es/maxBy.d.ts
|
||||
es/max.d.ts
|
||||
es/mean.d.ts
|
||||
es/median.d.ts
|
||||
es/memoizeWith.d.ts
|
||||
es/mergeAll.d.ts
|
||||
es/mergeDeepLeft.d.ts
|
||||
es/mergeDeepRight.d.ts
|
||||
es/mergeDeepWith.d.ts
|
||||
es/mergeDeepWithKey.d.ts
|
||||
es/mergeLeft.d.ts
|
||||
es/mergeRight.d.ts
|
||||
es/merge.d.ts
|
||||
es/mergeWith.d.ts
|
||||
es/mergeWithKey.d.ts
|
||||
es/minBy.d.ts
|
||||
es/min.d.ts
|
||||
es/modulo.d.ts
|
||||
es/move.d.ts
|
||||
es/multiply.d.ts
|
||||
es/nAry.d.ts
|
||||
es/negate.d.ts
|
||||
es/none.d.ts
|
||||
es/not.d.ts
|
||||
es/nthArg.d.ts
|
||||
es/nth.d.ts
|
||||
es/o.d.ts
|
||||
es/objOf.d.ts
|
||||
es/of.d.ts
|
||||
es/omit.d.ts
|
||||
es/once.d.ts
|
||||
es/or.d.ts
|
||||
es/over.d.ts
|
||||
es/otherwise.d.ts
|
||||
es/pair.d.ts
|
||||
es/partial.d.ts
|
||||
es/partialRight.d.ts
|
||||
es/partition.d.ts
|
||||
es/path.d.ts
|
||||
es/pathEq.d.ts
|
||||
es/pathOr.d.ts
|
||||
es/pathSatisfies.d.ts
|
||||
es/pickAll.d.ts
|
||||
es/pickBy.d.ts
|
||||
es/pick.d.ts
|
||||
es/pipe.d.ts
|
||||
es/pipeK.d.ts
|
||||
es/pipeP.d.ts
|
||||
es/pipeWith.d.ts
|
||||
es/pluck.d.ts
|
||||
es/prepend.d.ts
|
||||
es/product.d.ts
|
||||
es/project.d.ts
|
||||
es/prop.d.ts
|
||||
es/propEq.d.ts
|
||||
es/propIs.d.ts
|
||||
es/propOr.d.ts
|
||||
es/propSatisfies.d.ts
|
||||
es/props.d.ts
|
||||
es/range.d.ts
|
||||
es/reduceBy.d.ts
|
||||
es/reduced.d.ts
|
||||
es/reduce.d.ts
|
||||
es/reduceRight.d.ts
|
||||
es/reduceWhile.d.ts
|
||||
es/reject.d.ts
|
||||
es/remove.d.ts
|
||||
es/repeat.d.ts
|
||||
es/replace.d.ts
|
||||
es/reverse.d.ts
|
||||
es/scan.d.ts
|
||||
es/set.d.ts
|
||||
es/slice.d.ts
|
||||
es/sortBy.d.ts
|
||||
es/sort.d.ts
|
||||
es/sortWith.d.ts
|
||||
es/splitAt.d.ts
|
||||
es/split.d.ts
|
||||
es/splitEvery.d.ts
|
||||
es/splitWhen.d.ts
|
||||
es/startsWith.d.ts
|
||||
es/subtract.d.ts
|
||||
es/sum.d.ts
|
||||
es/symmetricDifference.d.ts
|
||||
es/symmetricDifferenceWith.d.ts
|
||||
es/tail.d.ts
|
||||
es/take.d.ts
|
||||
es/takeLast.d.ts
|
||||
es/takeLastWhile.d.ts
|
||||
es/takeWhile.d.ts
|
||||
es/tap.d.ts
|
||||
es/T.d.ts
|
||||
es/test.d.ts
|
||||
es/then.d.ts
|
||||
es/thunkify.d.ts
|
||||
es/times.d.ts
|
||||
es/toLower.d.ts
|
||||
es/toPairs.d.ts
|
||||
es/toPairsIn.d.ts
|
||||
es/toString.d.ts
|
||||
es/toUpper.d.ts
|
||||
es/transduce.d.ts
|
||||
es/transpose.d.ts
|
||||
es/traverse.d.ts
|
||||
es/trim.d.ts
|
||||
es/tryCatch.d.ts
|
||||
es/type.d.ts
|
||||
es/unapply.d.ts
|
||||
es/unary.d.ts
|
||||
es/uncurryN.d.ts
|
||||
es/unfold.d.ts
|
||||
es/union.d.ts
|
||||
es/unionWith.d.ts
|
||||
es/uniqBy.d.ts
|
||||
es/uniq.d.ts
|
||||
es/uniqWith.d.ts
|
||||
es/unless.d.ts
|
||||
es/unnest.d.ts
|
||||
es/until.d.ts
|
||||
es/update.d.ts
|
||||
es/useWith.d.ts
|
||||
es/values.d.ts
|
||||
es/valuesIn.d.ts
|
||||
es/view.d.ts
|
||||
es/when.d.ts
|
||||
es/where.d.ts
|
||||
es/whereEq.d.ts
|
||||
es/without.d.ts
|
||||
es/xprod.d.ts
|
||||
es/zip.d.ts
|
||||
es/zipObj.d.ts
|
||||
es/zipWith.d.ts
|
||||
es/includes.d.ts
|
||||
|
||||
src/add.d.ts
|
||||
src/addIndex.d.ts
|
||||
src/adjust.d.ts
|
||||
src/all.d.ts
|
||||
src/allPass.d.ts
|
||||
src/always.d.ts
|
||||
src/and.d.ts
|
||||
src/any.d.ts
|
||||
src/anyPass.d.ts
|
||||
src/ap.d.ts
|
||||
src/aperture.d.ts
|
||||
src/append.d.ts
|
||||
src/apply.d.ts
|
||||
src/applySpec.d.ts
|
||||
src/applyTo.d.ts
|
||||
src/ascend.d.ts
|
||||
src/assoc.d.ts
|
||||
src/assocPath.d.ts
|
||||
src/binary.d.ts
|
||||
src/bind.d.ts
|
||||
src/both.d.ts
|
||||
src/call.d.ts
|
||||
src/chain.d.ts
|
||||
src/clamp.d.ts
|
||||
src/clone.d.ts
|
||||
src/comparator.d.ts
|
||||
src/complement.d.ts
|
||||
src/compose.d.ts
|
||||
src/composeK.d.ts
|
||||
src/composeP.d.ts
|
||||
src/composeWith.d.ts
|
||||
src/concat.d.ts
|
||||
src/cond.d.ts
|
||||
src/construct.d.ts
|
||||
src/constructN.d.ts
|
||||
src/contains.d.ts
|
||||
src/converge.d.ts
|
||||
src/countBy.d.ts
|
||||
src/curry.d.ts
|
||||
src/curryN.d.ts
|
||||
src/dec.d.ts
|
||||
src/defaultTo.d.ts
|
||||
src/descend.d.ts
|
||||
src/difference.d.ts
|
||||
src/differenceWith.d.ts
|
||||
src/dissoc.d.ts
|
||||
src/dissocPath.d.ts
|
||||
src/divide.d.ts
|
||||
src/drop.d.ts
|
||||
src/dropLast.d.ts
|
||||
src/dropLastWhile.d.ts
|
||||
src/dropRepeats.d.ts
|
||||
src/dropRepeatsWith.d.ts
|
||||
src/either.d.ts
|
||||
src/empty.d.ts
|
||||
src/endsWith.d.ts
|
||||
src/eqBy.d.ts
|
||||
src/eqProps.d.ts
|
||||
src/equals.d.ts
|
||||
src/evolve.d.ts
|
||||
src/F.d.ts
|
||||
src/filter.d.ts
|
||||
src/find.d.ts
|
||||
src/findIndex.d.ts
|
||||
src/findLast.d.ts
|
||||
src/findLastIndex.d.ts
|
||||
src/flatten.d.ts
|
||||
src/flip.d.ts
|
||||
src/forEach.d.ts
|
||||
src/forEachObjIndexed.d.ts
|
||||
src/fromPairs.d.ts
|
||||
src/groupBy.d.ts
|
||||
src/groupWith.d.ts
|
||||
src/gt.d.ts
|
||||
src/gte.d.ts
|
||||
src/has.d.ts
|
||||
src/hasIn.d.ts
|
||||
src/hasPath.d.ts
|
||||
src/head.d.ts
|
||||
src/identical.d.ts
|
||||
src/identity.d.ts
|
||||
src/ifElse.d.ts
|
||||
src/inc.d.ts
|
||||
src/indexBy.d.ts
|
||||
src/indexOf.d.ts
|
||||
src/init.d.ts
|
||||
src/innerJoin.d.ts
|
||||
src/insertAll.d.ts
|
||||
src/insert.d.ts
|
||||
src/intersection.d.ts
|
||||
src/intersectionWith.d.ts
|
||||
src/intersperse.d.ts
|
||||
src/into.d.ts
|
||||
src/invert.d.ts
|
||||
src/invertObj.d.ts
|
||||
src/invoker.d.ts
|
||||
src/is.d.ts
|
||||
src/isEmpty.d.ts
|
||||
src/isNil.d.ts
|
||||
src/join.d.ts
|
||||
src/juxt.d.ts
|
||||
src/keys.d.ts
|
||||
src/keysIn.d.ts
|
||||
src/last.d.ts
|
||||
src/lastIndexOf.d.ts
|
||||
src/length.d.ts
|
||||
src/lens.d.ts
|
||||
src/lensIndex.d.ts
|
||||
src/lensPath.d.ts
|
||||
src/lensProp.d.ts
|
||||
src/lift.d.ts
|
||||
src/lt.d.ts
|
||||
src/lte.d.ts
|
||||
src/mapAccum.d.ts
|
||||
src/mapAccumRight.d.ts
|
||||
src/map.d.ts
|
||||
src/mapObjIndexed.d.ts
|
||||
src/match.d.ts
|
||||
src/mathMod.d.ts
|
||||
src/maxBy.d.ts
|
||||
src/max.d.ts
|
||||
src/mean.d.ts
|
||||
src/median.d.ts
|
||||
src/memoizeWith.d.ts
|
||||
src/mergeAll.d.ts
|
||||
src/mergeDeepLeft.d.ts
|
||||
src/mergeDeepRight.d.ts
|
||||
src/mergeDeepWith.d.ts
|
||||
src/mergeDeepWithKey.d.ts
|
||||
src/mergeLeft.d.ts
|
||||
src/mergeRight.d.ts
|
||||
src/merge.d.ts
|
||||
src/mergeWith.d.ts
|
||||
src/mergeWithKey.d.ts
|
||||
src/minBy.d.ts
|
||||
src/min.d.ts
|
||||
src/modulo.d.ts
|
||||
src/move.d.ts
|
||||
src/multiply.d.ts
|
||||
src/nAry.d.ts
|
||||
src/negate.d.ts
|
||||
src/none.d.ts
|
||||
src/not.d.ts
|
||||
src/nthArg.d.ts
|
||||
src/nth.d.ts
|
||||
src/o.d.ts
|
||||
src/objOf.d.ts
|
||||
src/of.d.ts
|
||||
src/omit.d.ts
|
||||
src/once.d.ts
|
||||
src/or.d.ts
|
||||
src/over.d.ts
|
||||
src/otherwise.d.ts
|
||||
src/pair.d.ts
|
||||
src/partial.d.ts
|
||||
src/partialRight.d.ts
|
||||
src/partition.d.ts
|
||||
src/path.d.ts
|
||||
src/pathEq.d.ts
|
||||
src/pathOr.d.ts
|
||||
src/pathSatisfies.d.ts
|
||||
src/pickAll.d.ts
|
||||
src/pickBy.d.ts
|
||||
src/pick.d.ts
|
||||
src/pipe.d.ts
|
||||
src/pipeK.d.ts
|
||||
src/pipeP.d.ts
|
||||
src/pipeWith.d.ts
|
||||
src/pluck.d.ts
|
||||
src/prepend.d.ts
|
||||
src/product.d.ts
|
||||
src/project.d.ts
|
||||
src/prop.d.ts
|
||||
src/propEq.d.ts
|
||||
src/propIs.d.ts
|
||||
src/propOr.d.ts
|
||||
src/propSatisfies.d.ts
|
||||
src/props.d.ts
|
||||
src/range.d.ts
|
||||
src/reduceBy.d.ts
|
||||
src/reduced.d.ts
|
||||
src/reduce.d.ts
|
||||
src/reduceRight.d.ts
|
||||
src/reduceWhile.d.ts
|
||||
src/reject.d.ts
|
||||
src/remove.d.ts
|
||||
src/repeat.d.ts
|
||||
src/replace.d.ts
|
||||
src/reverse.d.ts
|
||||
src/scan.d.ts
|
||||
src/set.d.ts
|
||||
src/slice.d.ts
|
||||
src/sortBy.d.ts
|
||||
src/sort.d.ts
|
||||
src/sortWith.d.ts
|
||||
src/splitAt.d.ts
|
||||
src/split.d.ts
|
||||
src/splitEvery.d.ts
|
||||
src/splitWhen.d.ts
|
||||
src/startsWith.d.ts
|
||||
src/subtract.d.ts
|
||||
src/sum.d.ts
|
||||
src/symmetricDifference.d.ts
|
||||
src/symmetricDifferenceWith.d.ts
|
||||
src/tail.d.ts
|
||||
src/take.d.ts
|
||||
src/takeLast.d.ts
|
||||
src/takeLastWhile.d.ts
|
||||
src/takeWhile.d.ts
|
||||
src/tap.d.ts
|
||||
src/T.d.ts
|
||||
src/test.d.ts
|
||||
src/then.d.ts
|
||||
src/thunkify.d.ts
|
||||
src/times.d.ts
|
||||
src/toLower.d.ts
|
||||
src/toPairs.d.ts
|
||||
src/toPairsIn.d.ts
|
||||
src/toString.d.ts
|
||||
src/toUpper.d.ts
|
||||
src/transduce.d.ts
|
||||
src/transpose.d.ts
|
||||
src/traverse.d.ts
|
||||
src/trim.d.ts
|
||||
src/tryCatch.d.ts
|
||||
src/type.d.ts
|
||||
src/unapply.d.ts
|
||||
src/unary.d.ts
|
||||
src/uncurryN.d.ts
|
||||
src/unfold.d.ts
|
||||
src/union.d.ts
|
||||
src/unionWith.d.ts
|
||||
src/uniqBy.d.ts
|
||||
src/uniq.d.ts
|
||||
src/uniqWith.d.ts
|
||||
src/unless.d.ts
|
||||
src/unnest.d.ts
|
||||
src/until.d.ts
|
||||
src/update.d.ts
|
||||
src/useWith.d.ts
|
||||
src/values.d.ts
|
||||
src/valuesIn.d.ts
|
||||
src/view.d.ts
|
||||
src/when.d.ts
|
||||
src/where.d.ts
|
||||
src/whereEq.d.ts
|
||||
src/without.d.ts
|
||||
src/xprod.d.ts
|
||||
src/zip.d.ts
|
||||
src/zipObj.d.ts
|
||||
src/zipWith.d.ts
|
||||
src/includes.d.ts
|
||||
@@ -6,6 +6,16 @@
|
||||
|
||||
**Please read this guide in its entirety.** Doing so helps ensure that the only breaking changes will be those that bring `@types/ramda` closer to representing the behavior of the underlying `ramda` package.
|
||||
|
||||
### Adding a new entry
|
||||
|
||||
When a new function has been published by ramda
|
||||
|
||||
- Add the function type to `index.d.ts`
|
||||
- Add documentation for it, copied from ramda's website
|
||||
- Add your entry import/re-export in `es` & `src` folders
|
||||
- Add `es/<function>` & `src/<function>` to `OTHER_FILES.txt`
|
||||
- Write some tests by following the instructions below
|
||||
|
||||
### Tests
|
||||
|
||||
Tests are located in the `test/` directory. Each ramda function has its own test file, named `<function>-tests.ts`. When editing types for a function, please update the corresponding tests to prove that the behavior you seek actually works. When adding a new function, add a corresponding test file with as many tests as you can to detail the function's behavior.
|
||||
|
||||
Vendored
+2101
-3125
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"ts-toolbelt": "^4.10.7"
|
||||
"ts-toolbelt": "^4.12.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import * as R from "ramda";
|
||||
import { Dictionary } from "ramda/tools";
|
||||
|
||||
function double(x: number): number {
|
||||
return x + x;
|
||||
@@ -312,7 +313,7 @@ R.times(i, 5);
|
||||
return n % 2 === 0;
|
||||
}
|
||||
const rejectEven = R.reject(isEven);
|
||||
const objB: R.Dictionary<number> = rejectEven({ a: 0, b: 1 }); // => { b: 1 }
|
||||
const objB: Dictionary<number> = rejectEven({ a: 0, b: 1 }); // => { b: 1 }
|
||||
const listB: number[] = rejectEven([0, 1]); // => [1]
|
||||
};
|
||||
|
||||
@@ -321,7 +322,7 @@ R.times(i, 5);
|
||||
return n % 2 === 0;
|
||||
}
|
||||
|
||||
const a: R.Dictionary<number> = R.pipe(
|
||||
const a: Dictionary<number> = R.pipe(
|
||||
R.filter<number, 'object'>(isEven),
|
||||
)({ a: 0, b: 1 }); // => { a: 0 }
|
||||
|
||||
@@ -329,7 +330,7 @@ R.times(i, 5);
|
||||
R.filter<number, 'array'>(isEven),
|
||||
)([0, 1]); // => [0]
|
||||
|
||||
const c: R.Dictionary<number> = R.pipe(
|
||||
const c: Dictionary<number> = R.pipe(
|
||||
R.reject<number, 'object'>(isEven),
|
||||
)({ a: 0, b: 1 }); // => { b: 1 }
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import * as R from 'ramda';
|
||||
import { Dictionary } from 'ramda/tools';
|
||||
|
||||
() => {
|
||||
function isEven(n: number) {
|
||||
@@ -6,17 +7,17 @@ import * as R from 'ramda';
|
||||
}
|
||||
|
||||
const filterEven = R.filter(isEven);
|
||||
const objA: R.Dictionary<number> = filterEven({ a: 0, b: 1 }); // => { a: 0 }
|
||||
const objA: Dictionary<number> = filterEven({ a: 0, b: 1 }); // => { a: 0 }
|
||||
const listA: number[] = filterEven([0, 1]); // => [0]
|
||||
};
|
||||
|
||||
() => {
|
||||
const compact = R.filter(Boolean);
|
||||
const objA: R.Dictionary<number> = compact({ a: 0, b: 1 }); // => { b: 1 }
|
||||
const objA: Dictionary<number> = compact({ a: 0, b: 1 }); // => { b: 1 }
|
||||
const listA: number[] = compact([0, 1]); // => [1]
|
||||
|
||||
const omitEmptyString = R.filter((val: string) => val !== '');
|
||||
const objB: R.Dictionary<string> = omitEmptyString({ a: '', b: 'foo' }); // => { b: 'foo' }
|
||||
const objB: Dictionary<string> = omitEmptyString({ a: '', b: 'foo' }); // => { b: 'foo' }
|
||||
const listB: string[] = omitEmptyString(['', 'foo']); // => ['foo']
|
||||
|
||||
const objC = omitEmptyString({ some: 42 }); // $ExpectError
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import * as R from 'ramda';
|
||||
import { Ord } from 'ramda/tools';
|
||||
|
||||
() => {
|
||||
function cmp(obj: { x: R.Ord }) {
|
||||
function cmp(obj: { x: Ord }) {
|
||||
return obj.x;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import * as R from 'ramda';
|
||||
import { Ord } from 'ramda/tools';
|
||||
|
||||
() => {
|
||||
function cmp(obj: { x: R.Ord }) {
|
||||
function cmp(obj: { x: Ord }) {
|
||||
return obj.x;
|
||||
}
|
||||
|
||||
|
||||
Vendored
+433
-3
@@ -1,5 +1,435 @@
|
||||
/// <reference path="./index.d.ts" />
|
||||
import { A, O, T } from "ts-toolbelt";
|
||||
|
||||
declare namespace Tools {
|
||||
type ValueOfRecord<R> = R extends Record<any, infer T> ? T : never;
|
||||
// ///////////////////////////////////////////////////////////////////////////////////////
|
||||
// TOOLS /////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Here lies a loose collection of tools that compute types for the functions in "index.d.ts"
|
||||
// The goal of this file is to keep "index.d.ts" readable as well as hiding implementations
|
||||
|
||||
// WHEN ADDING A NEW TOOL
|
||||
// - Add documentation for the tool you've created
|
||||
// - Add <created by @username> on your tool's docs
|
||||
|
||||
// TODO
|
||||
// - Types need proper descriptions, so that we know what they do
|
||||
|
||||
// ---------------------------------------------------------------------------------------
|
||||
// A
|
||||
|
||||
/**
|
||||
* <needs description>
|
||||
*/
|
||||
export type Arity0Fn = () => any;
|
||||
|
||||
/**
|
||||
* <needs description>
|
||||
*/
|
||||
export type Arity1Fn = (a: any) => any;
|
||||
|
||||
/**
|
||||
* <needs description>
|
||||
*/
|
||||
export type Arity2Fn = (a: any, b: any) => any;
|
||||
|
||||
/**
|
||||
* <needs description>
|
||||
*/
|
||||
export interface ArrayLike {
|
||||
nodeType: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* <needs description>
|
||||
* @param K
|
||||
*/
|
||||
export interface AssocPartialOne<K extends keyof any> {
|
||||
<T>(val: T): <U>(obj: U) => Record<K, T> & U;
|
||||
<T, U>(val: T, obj: U): Record<K, T> & U;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------
|
||||
// C
|
||||
|
||||
/**
|
||||
* <needs description>
|
||||
*/
|
||||
export interface CharList extends String {
|
||||
push(x: string): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* <needs description>
|
||||
* @param V0
|
||||
* @param R
|
||||
*/
|
||||
export type ComposeWithFns<V0, R> = [
|
||||
(x0: V0) => R
|
||||
] | [
|
||||
(x: any) => R,
|
||||
(x: V0) => any
|
||||
] | [
|
||||
(x: any) => R,
|
||||
(x: any) => any,
|
||||
(x: V0) => any
|
||||
] | [
|
||||
(x: any) => R,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: V0) => any
|
||||
] | [
|
||||
(x: any) => R,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: V0) => any
|
||||
] | [
|
||||
(x: any) => R,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: V0) => any
|
||||
] | [
|
||||
(x: any) => R,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: V0) => any
|
||||
] | [
|
||||
(x: any) => R,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: V0) => any
|
||||
] | [
|
||||
(x: any) => R,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: V0) => any
|
||||
] | [
|
||||
(x: any) => R,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: V0) => any
|
||||
];
|
||||
|
||||
// ---------------------------------------------------------------------------------------
|
||||
// D
|
||||
|
||||
/**
|
||||
* <needs description>
|
||||
* @param A
|
||||
*/
|
||||
export interface Dictionary<A> {
|
||||
[index: string]: A;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------
|
||||
// E
|
||||
|
||||
/**
|
||||
* Represents all objects evolvable with Evolver E
|
||||
* @param E
|
||||
*/
|
||||
export type Evolvable<E extends Evolver> = {
|
||||
[P in keyof E]?: Evolved<E[P]>;
|
||||
};
|
||||
|
||||
/**
|
||||
* <needs description>
|
||||
* @param O
|
||||
* @param E
|
||||
*/
|
||||
export type Evolve<O extends Evolvable<E>, E extends Evolver> = {
|
||||
[P in keyof O]: P extends keyof E
|
||||
? EvolveValue<O[P], E[P]>
|
||||
: O[P];
|
||||
};
|
||||
|
||||
/**
|
||||
* <needs description>
|
||||
* @param A
|
||||
*/
|
||||
type Evolved<A> =
|
||||
A extends (value: infer V) => any
|
||||
? V
|
||||
: A extends Evolver
|
||||
? Evolvable<A>
|
||||
: never;
|
||||
|
||||
/**
|
||||
* <needs description>
|
||||
*/
|
||||
export interface Evolver {
|
||||
[key: string]: ((value: any) => any) | Evolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* <needs description>
|
||||
* @param O
|
||||
* @param E
|
||||
*/
|
||||
type EvolveNestedValue<O, E extends Evolver> =
|
||||
O extends object
|
||||
? O extends Evolvable<E>
|
||||
? Evolve<O, E>
|
||||
: never
|
||||
: never;
|
||||
|
||||
/**
|
||||
* <needs description>
|
||||
* @param V
|
||||
* @param E
|
||||
*/
|
||||
type EvolveValue<V, E> =
|
||||
E extends (value: V) => any
|
||||
? ReturnType<E>
|
||||
: E extends Evolver
|
||||
? EvolveNestedValue<V, E>
|
||||
: never;
|
||||
|
||||
// ---------------------------------------------------------------------------------------
|
||||
// F
|
||||
|
||||
/**
|
||||
* <needs description>
|
||||
*/
|
||||
export interface Filter {
|
||||
<T>(fn: (value: T) => boolean): FilterOnceApplied<T>;
|
||||
<T, Kind extends 'array'>(fn: (value: T) => boolean): (list: readonly T[]) => T[];
|
||||
<T, Kind extends 'object'>(fn: (value: T) => boolean): (list: Dictionary<T>) => Dictionary<T>;
|
||||
<T>(fn: (value: T) => boolean, list: readonly T[]): T[];
|
||||
<T>(fn: (value: T) => boolean, obj: Dictionary<T>): Dictionary<T>;
|
||||
}
|
||||
|
||||
/**
|
||||
* <needs description>
|
||||
* @param A
|
||||
*/
|
||||
type FilterOnceApplied<A> =
|
||||
<K extends A[] | Dictionary<A>>(source: K) =>
|
||||
K extends Array<infer U>
|
||||
? U[]
|
||||
: K extends Dictionary<infer U>
|
||||
? Dictionary<U>
|
||||
: never;
|
||||
|
||||
/**
|
||||
* <needs description>
|
||||
* @param A
|
||||
*/
|
||||
export interface Functor<A> {
|
||||
map<U>(fn: (a: A) => U): Functor<U>;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------
|
||||
// K
|
||||
|
||||
/**
|
||||
* <needs description>
|
||||
* @param K
|
||||
* @param V
|
||||
*/
|
||||
export type KeyValuePair<K, V> = [K, V];
|
||||
|
||||
// ---------------------------------------------------------------------------------------
|
||||
// L
|
||||
|
||||
/**
|
||||
* <needs description>
|
||||
*/
|
||||
export interface Lens {
|
||||
<T, U>(obj: T): U;
|
||||
set<T, U>(str: string, obj: T): U;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------
|
||||
// M
|
||||
|
||||
/**
|
||||
* Merge an object `O1` with `O2`
|
||||
* @param O1
|
||||
* @param O2
|
||||
* @param Depth
|
||||
*
|
||||
* `O1` & `O2` are intersected with `[]` so that we can
|
||||
* handle the scenario where we merge arrays (like ramda).
|
||||
* Ramda removes array props when merging arrays, and thus
|
||||
* only keeps own properties. This is what `ObjectOf` does.
|
||||
*
|
||||
* => ramda's `merge` functions are 100% properly typed.
|
||||
*
|
||||
* <created by @pirix-gh>
|
||||
*/
|
||||
export type Merge<O1 extends object, O2 extends object, Depth extends 'flat' | 'deep'> =
|
||||
O.MergeUp<T.ObjectOf<O1>, T.ObjectOf<O2>, Depth>;
|
||||
|
||||
/**
|
||||
* Merge multiple objects `Os` with each other
|
||||
* @param Os
|
||||
*
|
||||
* It essentially works like [[Merge]], since the utility
|
||||
* `MergeUp` is used by `AssignUp` internally.
|
||||
*
|
||||
* <created by @pirix-gh>
|
||||
*/
|
||||
export type MergeAll<Os extends readonly object[]> =
|
||||
O.AssignUp<{}, Os> extends infer M
|
||||
? {} extends M // nothing merged => bcs no `as const`
|
||||
? T.UnionOf<Os> // so we output the approximate types
|
||||
: T.ObjectOf<M & {}> // otherwise, we can get accurate types
|
||||
: never;
|
||||
|
||||
// ---------------------------------------------------------------------------------------
|
||||
// O
|
||||
|
||||
/**
|
||||
* <needs description>
|
||||
*/
|
||||
export type ObjPred = (value: any, key: string) => boolean;
|
||||
|
||||
/**
|
||||
* <needs description>
|
||||
*/
|
||||
export type Ord = number | string | boolean | Date;
|
||||
|
||||
// ---------------------------------------------------------------------------------------
|
||||
// P
|
||||
|
||||
/**
|
||||
* <needs description>
|
||||
*/
|
||||
export type Path = Array<(number | string)>;
|
||||
|
||||
/**
|
||||
* <needs description>
|
||||
*/
|
||||
export type Placeholder = A.x & {'@@functional/placeholder': true};
|
||||
|
||||
/**
|
||||
* <needs description>
|
||||
*/
|
||||
export type Pred = (...a: readonly any[]) => boolean;
|
||||
|
||||
/**
|
||||
* <needs description>
|
||||
* @param V0
|
||||
* @param R
|
||||
*/
|
||||
export type PipeWithFns<V0, R> = [
|
||||
(x0: V0) => R
|
||||
] | [
|
||||
(x0: V0) => any,
|
||||
(x: any) => R
|
||||
] | [
|
||||
(x0: V0) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => R
|
||||
] | [
|
||||
(x0: V0) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => R
|
||||
] | [
|
||||
(x0: V0) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => R
|
||||
] | [
|
||||
(x0: V0) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => R
|
||||
] | [
|
||||
(x0: V0) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => R
|
||||
] | [
|
||||
(x0: V0) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => R
|
||||
] | [
|
||||
(x0: V0) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => R
|
||||
] | [
|
||||
(x0: V0) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => any,
|
||||
(x: any) => R
|
||||
];
|
||||
|
||||
// ---------------------------------------------------------------------------------------
|
||||
// R
|
||||
|
||||
/**
|
||||
* <needs description>
|
||||
* @param A
|
||||
*/
|
||||
export interface Reduced<A> {
|
||||
'@@transducer/value': A;
|
||||
'@@transducer/reduced': true;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------
|
||||
// S
|
||||
|
||||
/**
|
||||
* <needs description>
|
||||
* @param A
|
||||
*/
|
||||
export type SafePred<A> = (...a: readonly A[]) => boolean;
|
||||
|
||||
// ---------------------------------------------------------------------------------------
|
||||
// V
|
||||
|
||||
/**
|
||||
* <needs description>
|
||||
* @param R
|
||||
*/
|
||||
export type ValueOfRecord<R> =
|
||||
R extends Record<any, infer T>
|
||||
? T
|
||||
: never;
|
||||
|
||||
export {};
|
||||
|
||||
Reference in New Issue
Block a user