ramda / types Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
The error msg:
Argument of type '{ <U extends O[keyof O], UK extends keyof U, O extends Record<string, any>>(obj: "value" extends UK ? O : never): { [OK in keyof O]: O[OK]["value"]; }; <U extends readonly unknown[] | Record<"value", any>>(list: readonly U[]): U extends readonly (infer T)[] ? T[] : U extends Record<...> ? T[] : never; }' is not assignable to parameter of type '(...args: Data[][]) => (number | null)[]'.
Type '{ [x: string]: any; }' is missing the following properties from type '(number | null)[]': length, pop, push, concat, and 25 more.
Here is a minimal repo to reproduce the error
https://codesandbox.io/p/devbox/vm2hyt?file=%2Fsrc%2Findex.ts%3A7%2C22
I am not sure if my type in pipe<...>
is wrong but it works in 0.29.4
This is the Master list for all the types and the tl;dr for what needs to happen for all
Note: "acts as a transducer" is not something can, nor should, see for more details
Overall things to do:
T
, U
, etc)aIdx
should be a type Idx = string | number | Symbol
and used throughout when constraining anything that is an object key (this will match documentation as well)Ord
and Ordering
types need to be used moreFunctions:
{ all }
and how it can work with compose
Ordering
and not Number
path
, needs testsPredTypeguard
variant, needs testsT extends Ord
, needs testsTFiltered
variant, needs tests, look into if "can be applied to any functor" needs specific typingsAtLeastOneFunctionsFlowFromRightToLeft
, needs testsconcat
method", double check curryingConstructorParameters
ConstructorParameters
ts-toolbelt
's Curry, not testing because not our responsibility to test another lib's codeRecord
constraint variant should be all that is neededts-toolbelt
'sT extends Ord
, needs testsT extends Ord
, needs tests, fantasy-land Ord support?ObjectHavingSome
T extends any
(can be just T
), needs testsreadonly string[] | string
doesn't seem right, needs testsstring[] | string
doesn't seem right, needs testsIdx
types are automatically coerced into string, should the typings for this limit the object values to be Idx
for practical purposes? it would be practical as this function doesn't hold much value for objects with values that aren't Idx
(eg, anon-funcs and objects, the later coerced to '[object Object]'
)Idx[]
readonly string[] | string
of string overloadOrd
Ord
Functor
,MergeAll
Falsy
doesn't really apply in typings, review and add curryingstring[]
variety serves no purpose, curry and testpath
, currying, testspath
, currying, testspath
, currying, testsK[]
should be K keyof U
, since properties that don't exist are ignored, it makes no sense to constrain this to only known keys. Return value Pick<>
can be used directly in this casePartial<U>
. Curry and TestPick<>
, curry and testobj.promap
variety, curry and testIdx
, not String
for key, typing should be K keyof U
, needs curing and testsReduced<T>
to return value of reducer func, curry and testReduced<T>
to return value of reducer func, curry and testOrdering
Ordering
extends any
in unnecessary, curry and testtake<T>(n: number): (xs: readonly T[]) => T[]
overload should be removed, curry and test, handle "take method" variationasserts a is R
overload is completely wrong, curry and testU
in the generic, curry and testchain(identity)
need to handle "chain method" variant. curry and testValueOfUnion
,where
bs
to have same length as as
, curry and test#50 incorrectly altered the original types for fromPairs
, keys
, toPairs
and toPairsIn
.
The implementation of these functions filter out symbol keys via for ... in
or Object.keys. The original types captured this fact. The altered types do not. This has implications for operations that work with the outputs of these functions that expect symbol key types to be excluded.
Sandbox Demo: https://stackblitz.com/edit/vitejs-vite-tqnrhv?file=src%2Framda-demo.ts&terminal=dev
Error in ramda
Error: /home/vsts/work/1/s/types/ramda/test/find-tests.ts:5:30
ERROR: 5:30 expect [email protected] compile error:
Argument of type '{ a: number; }[]' is not assignable to parameter of type 'readonly Record<2, any>[]'.
Property '2' is missing in type '{ a: number; }' but required in type 'Record<2, any>'.
ERROR: 6:30 expect [email protected] compile error:
Argument of type '{ a: number; }[]' is not assignable to parameter of type 'readonly Record<4, any>[]'.
Property '4' is missing in type '{ a: number; }' but required in type 'Record<4, any>'.
/home/vsts/work/1/s/types/ramda/test/findIndex-tests.ts:5:35
ERROR: 5:35 expect [email protected] compile error:
Argument of type '{ a: number; }[]' is not assignable to parameter of type 'readonly Record<2, any>[]'.
Property '2' is missing in type '{ a: number; }' but required in type 'Record<2, any>'.
ERROR: 6:35 expect [email protected] compile error:
Argument of type '{ a: number; }[]' is not assignable to parameter of type 'readonly Record<4, any>[]'.
Property '4' is missing in type '{ a: number; }' but required in type 'Record<4, any>'.
/home/vsts/work/1/s/types/ramda/test/findLast-tests.ts:8:34
ERROR: 8:34 expect [email protected] compile error:
Argument of type '{ a: number; b: number; }[]' is not assignable to parameter of type 'readonly Record<1, any>[]'.
Property '1' is missing in type '{ a: number; b: number; }' but required in type 'Record<1, any>'.
ERROR: 9:34 expect [email protected] compile error:
Argument of type '{ a: number; b: number; }[]' is not assignable to parameter of type 'readonly Record<4, any>[]'.
Property '4' is missing in type '{ a: number; b: number; }' but required in type 'Record<4, any>'.
/home/vsts/work/1/s/types/ramda/test/findLastIndex-tests.ts:8:39
ERROR: 8:39 expect [email protected] compile error:
Argument of type '{ a: number; b: number; }[]' is not assignable to parameter of type 'readonly Record<1, any>[]'.
Property '1' is missing in type '{ a: number; b: number; }' but required in type 'Record<1, any>'.
ERROR: 9:39 expect [email protected] compile error:
Argument of type '{ a: number; b: number; }[]' is not assignable to parameter of type 'readonly Record<4, any>[]'.
Property '4' is missing in type '{ a: number; b: number; }' but required in type 'Record<4, any>'.
/home/vsts/work/1/s/types/ramda/test/propEq-tests.ts:10:11
ERROR: 10:11 expect [email protected] compile error:
Type '(obj: Record<"bar", any>) => boolean' is not assignable to type '(obj: Record<"foo", "bar">) => boolean'.
Types of parameters 'obj' and 'obj' are incompatible.
Property 'bar' is missing in type 'Record<"foo", "bar">' but required in type 'Record<"bar", any>'.
ERROR: 12:11 expect [email protected] compile error:
Type '(obj: Record<5, any>) => boolean' is not assignable to type '(obj: Record<"baz", number>) => boolean'.
Types of parameters 'obj' and 'obj' are incompatible.
Property '5' is missing in type 'Record<"baz", number>' but required in type 'Record<5, any>'.
ERROR: 14:11 expect [email protected] compile error:
Type '(obj: Record<"qwerty", any>) => boolean' is not assignable to type '(obj: Record<number, string>) => boolean'.
Types of parameters 'obj' and 'obj' are incompatible.
Property 'qwerty' is missing in type 'Record<number, string>' but required in type 'Record<"qwerty", any>'.
ERROR: 29:22 expect [email protected] compile error:
Argument of type 'Obj' is not assignable to parameter of type 'Record<1, any>'.
Property '1' is missing in type 'Obj' but required in type 'Record<1, any>'.
ERROR: 30:22 expect [email protected] compile error:
Argument of type 'Obj' is not assignable to parameter of type 'Record<4, any>'.
Property '4' is missing in type 'Obj' but required in type 'Record<4, any>'.
ERROR: 43:28 expect [email protected] compile error:
Argument of type 'A' is not assignable to parameter of type 'Record<"", any>'.
Property '""' is missing in type 'A' but required in type 'Record<"", any>'.
Hi and thank you for the ramda!
We just upgraded to 0.29.0 and the following code does not type check
import {mergeAll} from 'ramda';
const list: Array<{x: number}> = [{x: 1}, {x: 2}];
const result = mergeAll(list);
It fails with Argument of type '{ x: number; }[]' is not assignable to parameter of type '[{ x: number; }, ...{ x: number; }[]]'. Source provides no match for required element at position 0 in target.
Have to do something like
const list: Array<{x: number}> = [{x: 1}, {x: 2}];
const result = mergeAll([list[0], ...list]);
to make it work. The js code works with passing in arrays. I this intended?
Given the following groupBy invocation using version 0.29.10 of types
const messagesByGroupId = groupBy(
message => message.groupId,
messages,
);
when using entries and strict like so
for (const [groupId, messages] of Object.entries(messagesByGroupId)) {
// messages might be undefined
}
the messages variable type is T[] | undefined
forcing us to do an extra check, but it shouldn't be possible for it to be undefined since we're iterating over object properties.
This PR introduces the change - #45 that leads to the possible undefined.
ramda
's curry function is awesome but also has abilities that are not strictly necessary to type
// all of these work!
R.divide(10, 2); // 5
R.divide()(10, 2); // 5
R.divide(R.__)(10, 2); // 5
The use cases for both R.divide()
and R.divide(R.__)
are however negligible
So when typing out, we're only going to type it as:
export function divide(a: number, b: number): number;
export function divide(__: Placeholder, b: number): (a: number) => number;
export function divide(a: number): (b: number) => number;
And leave out
export function divide(): (a: number, b: number) => number;
export function divide(__: Placeholder): (a: number, b: number) => number;
When pluck
is called with a final argument typed as any
, it results in a TypeScript error.
I'm not sure if this is actually an error or desired behavior. Casting the argument to any[]
resolves the type error. I would expect any
to be allowed since it can be a list, but perhaps that is not the intention of this lib. Of course, if this is desired behavior, please close
import { pluck } from "ramda";
const array = [{ id: 1 }, { id: 2 }] as any;
pluck("id", array);
^^^^
No overload matches this call.
Overload 1 of 4, '(p: never, list: readonly unknown[]): never[]', gave the following error.
Argument of type 'string' is not assignable to parameter of type 'never'.
Overload 2 of 4, '(p: number, list: { [k: number]: unknown; }[]): unknown[]', gave the following error.
Argument of type 'string' is not assignable to parameter of type 'number'.
The project is licensed under MIT according to package.json, but it lacks the license text and a copyright notice.
If I use forEach
like so:
const nums: number[] = [1, 2, 3];
forEach((num) => {
num + 1;
}, nums);
I'll get this error:
TS18046: num is of type unknown
I have to specify a type on the parameter, either by forEach<number, number[]>
or in the cb as forEach((num: number) => {})
.
It is able to tell when I supply it an invalid type, e.g. num: string
.
It seems like it should be able to infer the type without extra guidance?
const greet = R.replace('{name}', R.__, 'Hello, {name}!');
greet('Alice'); //=> 'Hello, Alice!'
This is example in docs
Docs for usage with typescript: It would be great to have the opportunity to write docs for typescript-specific stuff for particular functions. Some functions when using with typescript really need to be explained.
There is missing return type for AsyncFunction
.
https://github.com/ramda/types/blob/develop/types/type.d.ts
export function type(
val: any,
):
| 'Object'
| 'Number'
| 'Boolean'
| 'String'
| 'Null'
| 'Array'
| 'RegExp'
| 'Function'
| 'Undefined'
| 'Symbol'
| 'Error'
| 'Date'
| 'AsyncFunction' // this is missing
Assumption: Calling values
method with null
works by design and not by mistake (returns []
).
R.values
expects input obj
to be a T
generic that extends object
, but this produces following error when passing nullable type:
Type 'null' is not assignable to type 'object'
PS. After checking ramda/ramda#3264 and seeing that #118 is left open I've decided to post this issue here rather than in DefinitelyTyped - hope it's alright.
Hello!
I've been messing around with my example and I think I've narrowed the issue down to the fact that the following doesn't work:
expectType<string>(R.defaultTo('This file', undefined));
Here are the type definitions:
export function defaultTo<T, U>(a: T, b: U | null | undefined): T | U;
export function defaultTo<T>(a: T): <U>(b: U | null | undefined) => T | U;
I think the problem stems from the result type being T | U
, which in this case would include undefined
. I think we need to somehow use conditional types or something to make the types more aware about how the function behaves.
I assume this would be a problem for a bunch of other types too, like propOr
, etc.
I don't know much about conditional types and I'm going to read those docs and do more research tomorrow, but I just wanted to post this to see if anyone else has any insight into this issue!
There are a lot of extra, unused, deprecated, and useless type alias' in tools.d.ts
This issue to clean it up
From the v0.29 upgrade guide:
... improve of
to work with more Applicative types. of
now receives two parameters instead of one: the first parameter is type Constructor, and the second parameter is the value to be wrapped
The current typings do not yet reflect this change: export function of<T>(x: T): T[];
The following example has stopped working, since @types/ramda uses ramda-types:
import { mergeDeepLeft } from "ramda";
const translations = [
{ lang: "de", contact: { email: "[email protected]", emailLabel: "E-Mail" } },
{ lang: "en", contact: { emailLabel: "Email" } }
];
function merge<T extends { lang: string }>(arr: T[]) {
return mergeDeepLeft(arr[0], arr[1]) as T;
}
merge(translations);
Error message:
Conversion of type 'Assign<T, [T], "deep", BuiltIn, undefined>' to type 'T' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
'T' could be instantiated with an arbitrary type which could be unrelated to 'Assign<T, [T], "deep", BuiltIn, undefined>'.ts(2352)
Please ignore in case this was done intentionally.
The current typing of the take
function is this:
export function take(n: number): {
(xs: string): string;
<T>(xs: readonly T[]): T[];
};
export function take(n: number, xs: string): string;
export function take<T>(n: number, xs: readonly T[]): T[];
Right now, when you call the curried signature inside a pipe, the type of the array is not correctly inferred:
You can see the type inference is working correctly without the `R.take` call:The solution is to change the curried signature for taking from an array to this:
export function take<T>(n:number): (xs: readonly T[]) => T[]
This also applies to takeLast
.
I would be happy to open a PR for this.
What do we need to do to get Github Actions set up to either release on merge to main
or manually?
The package name is @ramda/type
, so I assume we need to set up the correct auth for npm's API to release under that namespace. Starting semver will be 0.1.0
. I plan on doing progressive releases of updates so it needs to be separate from ramda
's current semver
Let me know. Thanks again!
Hi,
I've been experiencing type inferencing problems with Typescript lately for ramda
version 0.30.1
and @types/ramda 0.30.0
Let's have a look at the omit
example when curried:
import { omit } from "ramda";
const user = { name: "some name", password: "password" };
const omitSecrets = omit(["password"]);
const result = omitSecrets(user);
The result
type is set to never
.
The "solution" to this problem is either:
omit(["password"], user);
where the result is correctly infered, i.e.
const correct_result: Omit<{
name: string;
password: string;
}, "password">
or
const secrets: ["password"] = ["password"];
const result = omit(secrets, user);
works fine too.
Is there a way how to properly infer the curried example?
The types package is currently failing in our nightly run:
Error in ramda
Error:
/home/runner/work/DefinitelyTyped/DefinitelyTyped/types/ramda/test/allPass-tests.ts
15:5 error [email protected] expected type to be:
(x: number) => boolean
got:
(a: number) => boolean @definitelytyped/expect
/home/runner/work/DefinitelyTyped/DefinitelyTyped/types/ramda/test/anyPass-tests.ts
15:5 error [email protected] expected type to be:
(x: number) => boolean
got:
(a: number) => boolean @definitelytyped/expect
/home/runner/work/DefinitelyTyped/DefinitelyTyped/types/ramda/test/assoc-tests.ts
86:20 error [email protected] compile error:
This expression is not callable.
Type 'Record<string, unknown>' has no call signatures @definitelytyped/expect
86:30 error [email protected] compile error:
No overload matches this call.
Overload 1 of 9, '(...func: [fnLast: (a: any) => Record<string, unknown>, ...func: ((a: any) => any)[], f7: (a: unknown) => unknown, f6: (a: unknown) => unknown, f5: (a: unknown) => unknown, f4: (a: unknown) => unknown, f3: (a: unknown) => unknown, f2: (a: unknown) => unknown, f1: (...args: any[]) => unknown]): (...args: any[]) => Record<string, unknown>', gave the following error.
Argument of type '{ <K extends string>(prop: K): { <T>(val: T): { <U extends Record<K, T>>(obj: U): U; <U extends Record<K, any>>(obj: U): Record<K, T> & Omit<U, K>; <U>(obj: U): U & Record<...>; }; <U extends Record<...>>(__: Placeholder, obj: U): { ...; }; <U>(__: Placeholder, obj: U): <T>(val: T) => U & Record<...>; <T, U extends ...' is not assignable to parameter of type '(a: any) => Record<string, unknown>'.
Type '{ <T>(val: T): { <U extends Record<any, T>>(obj: U): U; <U extends Record<any, any>>(obj: U): Record<any, T> & Omit<U, any>; <U>(obj: U): U & Record<...>; }; <U extends Record<...>>(__: Placeholder, obj: U): { ...; }; <U>(__: Placeholder, obj: U): <T>(val: T) => U & Record<...>; <T, U extends Record<...>>(val: T, ob...' is not assignable to type 'Record<string, unknown>'.
Index signature for type 'string' is missing in type '{ <T>(val: T): { <U extends Record<any, T>>(obj: U): U; <U extends Record<any, any>>(obj: U): Record<any, T> & Omit<U, any>; <U>(obj: U): U & Record<...>; }; <U extends Record<...>>(__: Placeholder, obj: U): { ...; }; <U>(__: Placeholder, obj: U): <T>(val: T) => U & Record<...>; <T, U extends Record<...>>(val: T, ob...'.
Overload 2 of 9, '(f2: (a: string) => Record<string, unknown>, f1: (val: unknown) => string): (val: unknown) => Record<string, unknown>', gave the following error.
Argument of type '{ <K extends string>(prop: K): { <T>(val: T): { <U extends Record<K, T>>(obj: U): U; <U extends Record<K, any>>(obj: U): Record<K, T> & Omit<U, K>; <U>(obj: U): U & Record<...>; }; <U extends Record<...>>(__: Placeholder, obj: U): { ...; }; <U>(__: Placeholder, obj: U): <T>(val: T) => U & Record<...>; <T, U extends ...' is not assignable to parameter of type '(a: string) => Record<string, unknown>'.
Type '{ <T>(val: T): { <U extends Record<any, T>>(obj: U): U; <U extends Record<any, any>>(obj: U): Record<any, T> & Omit<U, any>; <U>(obj: U): U & Record<...>; }; <U extends Record<...>>(__: Placeholder, obj: U): { ...; }; <U>(__: Placeholder, obj: U): <T>(val: T) => U & Record<...>; <T, U extends Record<...>>(val: T, ob...' is not assignable to type 'Record<string, unknown>' @definitelytyped/expect
87:20 error [email protected] compile error:
This expression is not callable.
Type 'Record<string, unknown>' has no call signatures @definitelytyped/expect
87:30 error [email protected] compile error:
No overload matches this call.
Overload 1 of 9, '(...func: [fnLast: (a: any) => Record<string, unknown>, ...func: ((a: any) => any)[], f7: (a: unknown) => unknown, f6: (a: unknown) => unknown, f5: (a: unknown) => unknown, f4: (a: unknown) => unknown, f3: (a: unknown) => unknown, f2: (a: unknown) => unknown, f1: (...args: any[]) => unknown]): (...args: any[]) => Record<string, unknown>', gave the following error.
Argument of type '{ <K extends string>(prop: K): { <T>(val: T): { <U extends Record<K, T>>(obj: U): U; <U extends Record<K, any>>(obj: U): Record<K, T> & Omit<U, K>; <U>(obj: U): U & Record<...>; }; <U extends Record<...>>(__: Placeholder, obj: U): { ...; }; <U>(__: Placeholder, obj: U): <T>(val: T) => U & Record<...>; <T, U extends ...' is not assignable to parameter of type '(a: any) => Record<string, unknown>'.
Overload 2 of 9, '(f2: (a: string) => Record<string, unknown>, f1: (val: unknown) => string): (val: unknown) => Record<string, unknown>', gave the following error.
Argument of type '{ <K extends string>(prop: K): { <T>(val: T): { <U extends Record<K, T>>(obj: U): U; <U extends Record<K, any>>(obj: U): Record<K, T> & Omit<U, K>; <U>(obj: U): U & Record<...>; }; <U extends Record<...>>(__: Placeholder, obj: U): { ...; }; <U>(__: Placeholder, obj: U): <T>(val: T) => U & Record<...>; <T, U extends ...' is not assignable to parameter of type '(a: string) => Record<string, unknown>' @definitelytyped/expect
/home/runner/work/DefinitelyTyped/DefinitelyTyped/types/ramda/test/complement-tests.ts
24:5 error [email protected] expected type to be:
(value: any) => value is any
got:
<T>(value: T) => value is Exclude<T, (null | undefined) & T> @definitelytyped/expect
/home/runner/work/DefinitelyTyped/DefinitelyTyped/types/ramda/test/filter-tests.ts
38:14 error [email protected] compile error:
No overload matches this call.
Overload 1 of 5, '(pred: (val: { type: string; }) => val is { type: string; }, list: readonly { type: string; }[]): { type: string; }[]', gave the following error.
Argument of type '<U extends Partial<Record<"type", any>>>(obj: Required<U> extends Record<"type", any> ? string extends WidenLiterals<U["type"]> ? U : never : never) => boolean' is not assignable to parameter of type '(val: { type: string; }) => val is { type: string; }'.
Signature '(obj: { type: string; }): boolean' must be a type predicate.
Overload 2 of 5, '(pred: (val: unknown) => val is unknown, dict: Record<string, unknown>): Record<string, unknown>', gave the following error.
Argument of type '<U extends Partial<Record<"type", any>>>(obj: Required<U> extends Record<"type", any> ? string extends WidenLiterals<U["type"]> ? U : never : never) => boolean' is not assignable to parameter of type '(val: unknown) => val is unknown'.
Types of parameters 'obj' and 'val' are incompatible.
Type 'unknown' is not assignable to type 'Partial<Record<"type", any>>'.
Overload 3 of 5, '(pred: (value: unknown) => boolean, collection: { type: string; }[]): { type: string; }[]', gave the following error.
Argument of type '<U extends Partial<Record<"type", any>>>(obj: Required<U> extends Record<"type", any> ? string extends WidenLiterals<U["type"]> ? U : never : never) => boolean' is not assignable to parameter of type '(value: unknown) => boolean'.
Types of parameters 'obj' and 'value' are incompatible.
Type 'unknown' is not assignable to type 'Partial<Record<"type", any>>' @definitelytyped/expect
/home/runner/work/DefinitelyTyped/DefinitelyTyped/types/ramda/test/pick-tests.ts
23:11 error [email protected] compile error:
Type 'Pick<string[], number>' is missing the following properties from type '{ 1: string; 2: string; }': 1, 2 @definitelytyped/expect
24:11 error [email protected] compile error:
Type 'Pick<["a", "b", "c", "d"], number>' is missing the following properties from type '{ 1: "b"; 2: "c"; }': 1, 2 @definitelytyped/expect
25:11 error [email protected] compile error:
Property '0' is missing in type 'Pick<[string, string, string, string], number>' but required in type '{ 0: string; }' @definitelytyped/expect
26:11 error [email protected] compile error:
Property '0' is missing in type 'Pick<["a", "b", "c", "d"], number>' but required in type '{ 0: "a"; }' @definitelytyped/expect
33:5 error [email protected] compile error:
Unused '@ts-expect-error' directive @definitelytyped/expect
/home/runner/work/DefinitelyTyped/DefinitelyTyped/types/ramda/test/propEq-tests.ts
14:11 error [email protected] compile error:
Type '<U extends Partial<Record<5, any>>>(obj: Required<U> extends Record<5, any> ? string extends WidenLiterals<U[5]> ? U : never : never) => boolean' is not assignable to type '(obj: Record<number, string>) => boolean'.
Types of parameters 'obj' and 'obj' are incompatible.
Type 'Record<number, string>' is not assignable to type 'never' @definitelytyped/expect
43:5 error [email protected] compile error:
Unused '@ts-expect-error' directive @definitelytyped/expect
✖ 15 problems (15 errors, 0 warnings)
Since the package is not on DT, I'm assuming many of the fixes need to happen here, unless some of these are intentional and should be updated. I haven't seen any specific PRs or issues related to these failures, but happy to be wrong and dedupe this elsewhere.
(The function parameter name thing is an easy fix, but the rest... no clue.)
I think the types of omit have been strengthened recently as (since minor upgrades to v0.29) I have a number of type errors that are flagged, especially for omit.
If you have a function signature, you may omit certain object keys in the sense, "I'm only interested in a subtype". This allows, say, unit tests to be more minimal and aligns with the principle of least knowledge. But in usage, the omitted keys may be present and you may want to acknowledge this in the implementation.
I'm not sure this is the most minimal example, but I hope shows what I mean:
import R from "ramda";
export interface Params {
foo: string;
bar?: string;
}
export function fn1(f: typeof fn2) {
return (params: Omit<Params, "bar">) => {
// imagine this omission is an important use case
return f(R.omit(["bar"] as const, params)); // TS2322
};
}
function fn2({ foo, bar }: Params): boolean {
return false;
}
const a: Params = {foo: "foo", bar: "bar"};
fn1(fn2)(a);
See also TS Playground link
In other words, I would expect seemingly unrelated keys not to be a type error. I can probably work around this by creating my own omit implementation, but this goes against the spirit of ramda being a useful multi-tool library when I can't actually use it in a multitude of cases.
I can already hear gnashing of teeth, because probably someone has worked hard to add the new types. Of course, I can see the opposite argument that the strong typing will flag up potential typos.
What benefit does ElementOf<T>
have over T[number]
? The conditional type and use of infer
are potentially far more expensive than is necessary.
Transducers are a particularly challenging thing to do in typescript do to how "functions that act as transformers" are isomorphic to them
const a = [1, 2, 3];
const f = R.compose(
R.map(R.multiply(2)),
R.map(R.add(3)),
);
// compose runs the array values through the first map and then the second
f(a); // [5,8,11]
// transduce runs the init transformer into the multiple transformers into the add transformer
R.transduce(f, R.flip(R.append), [], a); // [9, 12, 15]
Now while the above example works fine, once you start transitioning through the types it gets weird quickly
const a = [1, 2, 3];
// this is completely contrived but gets the point across
const f = R.compose(
R.map(R.toString()),
R.map(R.add(3)),
);
f(a); // ['3', '6', '9'];
// because now `toString` is processed first, `add` does string concatenation
R.transduce(f, R.flip(R.append), [], a); // ['13, '23', '33']
Typescript doesn't have "look-ahead" capabilities where it can see where a function is used to determine what its type should be for isomorphic behavior like this
The only way around this that I can think of is to have a separate function for compose
and pipe
that is typed specifically to the order of operation here
In this release the types of pick were changed to make it more strict so that it only accepts names of keys defined in the object. However this does not work when an object defines a list of generic properties e.g. [key: string]: string
In addition, the description of the pick function is not in line with the new types.
Returns a partial copy of an object containing only the keys specified. If the key does not exist, the property is ignored.
Specifically the part If the key does not exist, the property is ignored.
does not hold as far as I can see.
I was having an issue with type checker complaining about incompatible input type of accumulator on when trying to use transduce
to create function transforming array of values into representation of table rows.
After some investigation, I found what I believe to be a bug in definitions in transduce.d.ts
.
When transduce
is used as 4-ary and unary function, type V
seems to be intended as type of accumulator:
export function transduce<T, U, V>(
xf: (arg: readonly T[]) => U[],
fn: (acc: V, val: U) => V,
acc: V,
list: readonly T[],
): V;
export function transduce<T, U, V>(
xf: (arg: readonly T[]) => U[],
): (fn: (acc: V, val: U) => V, acc: V, list: readonly T[]) => V;
but when used as binary and ternary function, accumulator has type readonly T[]
:
export function transduce<T, U, V>(
xf: (arg: readonly T[]) => U[],
fn: (acc: V, val: U) => V,
): (acc: readonly T[], list: readonly T[]) => V;
export function transduce<T, U, V>(
xf: (arg: readonly T[]) => U[],
fn: (acc: V, val: U) => V,
acc: readonly T[],
): (list: readonly T[]) => V;
Shouldn't they be of type V
instead?
Edit: For reference this was on version 0.29.1.
the following function declaration generates a typescript compile error:
const userMatchRoles = user => roles => R.converge(R.or, [R.includes(user.role), R.isEmpty])(roles);
of course the error is not raised due to typescript strict mode (set to false) but from a bad signature in @types/ramda
tldr: passing result of keys()
into pick()
reports an error, it can be solved by doing some quite dirty casting, better fix could be by updating the typing in pick
(see Fix block bellow), but I´m not sure of the intentions of current implementation - thus this issue to discuss it.
/*
* The usecase is I have an object that gets partially modified on FE
* changes can be "flat" (on simple props like value), or also "nested" (eg on obj.body)
*/
interface Alpha {
_id: string;
name: string;
value: string;
description: string;
obj: {
head: string;
body: string;
}
}
interface AlphaPatch extends PartialDeep<Alpha> {
// to make ID required, we need it for db filter
_id: string;
}
function AlphaTest() {
// in real app patch comes from the FE in Request body
const alphaPatch: AlphaPatch = {
_id: 'id',
name: 'patched name',
obj: {
body: 'patched body',
}
};
// in real app complete object is loaded from db, _id from patch is used for identification to load it
const alpha: Alpha = {
_id: 'id',
name: 'name',
value: 'value',
description: 'description',
obj: {
head: 'obj.head',
body: 'obj.body',
},
};
/*
* now because I dont want to just deep merge whole alpha with patch but I still need deep values in my patch
* I'm trying to pick the keys, but pick reports an error:
* Argument of type '("name" | "value" | "description" | "obj")[]' is not assignable to parameter of type 'readonly [keyof Alpha, ...(keyof Alpha)[]]'.
* Source provides no match for required element at position 0 in target.ts(2345)
*/
const { _id, ...patch } = alphaPatch;
const keysToUpdate = keys(patch);
const currentAlpha = pick(keysToUpdate, alpha);
const patchWithAlphaDeep = mergeDeepRight(currentAlpha, patch);
}
Fix:
// this is current typings for pick
export function pick<U, const Names extends readonly [keyof U, ...(keyof U)[]]>(names: Names, obj: U): string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
// this will fix it, look at Names;
declare module 'ramda' {
export function pick<U, const Names extends readonly (keyof U)[]>(names: Names, obj: U): string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
}
I'm not sure whether this typing on pick is intentional or not / what kind of purpose this typings serves, but anyway it doesn´t seems right that it´s impossible to pass result of keys() into pick(). I did some experiments with trying to recasting it, I made it "work" but the type wasn't reflecting reality keys(patch) as [keyof PartialDeep<Alpha>];
- that´s not right, there can be more than just 1 item in the array. Following cast will be correct, but it just feels dirty keys(patch) as [keyof PartialDeep<Alpha>, ...(keyof PartialDeep<Alpha>)[]];
.
So my question is - is there a reasoning for having the typing for pick this way?
I found this change three weeks ago: https://github.com/ramda/types/pull/52/files @Harris-Miller
Currently, I'm just using npm publish
on my local machine. I'd much rather move to a gitflow style with develop
and main
branch. semantic-release
I like a lot, as it gives us great control of automatic semver bumps and Github release info
Open to other suggestions as well. I just want to define what that process should be and come up with a good strategy in general
Here's a sample usage of groupBy
:
it("test", () => {
type Foo = { id: number; color: string };
const byColor = groupBy(({ color }) => color, [
{ color: "red", id: 1 },
{ color: "blue", id: 2 },
{ color: "red", id: 3 },
] as Foo[]);
Object.values(byColor).map((grouping: Foo[]) => {
console.log(grouping);
});
});
which triggers this error:
The map
parameter needs to be supplied with Foo[] | undefined
to work correctly, even though that's not the right type.
Removing the Partial
wrapping the return type would fix this DX issue... I'm wondering what is the rationale for providing a partial record type?
Currently if you use isNotNil
to filter an array of type (T | undefined | null)[]
, the result will have the same type.
If, instead, we would define isNotNil
as follows:
export const isNotNil = <T>(value?: T): value is Exclude<T, null | undefined> => value != null
we could do something like
const example = [1, 23, null, 5, undefined].filter(isNotNil) // typed as `number[]`
This works:
const maybeStrings: (string | undefined)[] = ["a", undefined, "b"];
const strings: string[] = filter(isNotNil<string>)(maybeStrings);
But this doesn't, when involving a map
(which is an extremely common use case)
const arrayOfMaybeStringArrays: (string | undefined)[][] = [["a", undefined, "b"]];
const arrayOfStringArrays: string[] = map(filter(isNotNil<string>))(arrayOfMaybeStringArrays);
error TS2322: Type 'Dictionary<string>[]' is not assignable to type 'string[][]'.
Type 'Dictionary<string>' is missing the following properties from type 'string[]': length, pop, push, concat, and 35 more.
165 const arrayOfStringArrays: string[][] = map(filter(isNotNil<string>))(arrayOfMaybeStringArrays);
~~~~~~~~~~~~~~~~~~~
error TS2345: Argument of type '(string | undefined)[][]' is not assignable to parameter of type 'readonly Dictionary<string | null | undefined>[]'.
Type '(string | undefined)[]' is not assignable to type 'Dictionary<string | null | undefined>'.
Index signature for type 'string' is missing in type '(string | undefined)[]'.
165 const arrayOfStringArrays: string[][] = map(filter(isNotNil<string>))(arrayOfMaybeStringArrays);
~~~~~~~~~~~~~~~~~~~~~~~~
If you flip the order of the list
and dictionary
overrides for filter, like this, then the issue goes away:
export function filter<A, P extends A>(pred: (val: A) => val is P): {
<B extends A>(dict: Dictionary<B>): Dictionary<P>;
<B extends A>(list: readonly B[]): P[];
};
If this seems like a reasonable move, I can open a PR, just wanted to get a first impression from someone.
assoc
sometimes returns a more narrow type than what is passed to it. Since assoc
never removes props, this feels wrong from a type perspective. I would expect assoc
to only add or modify props, never remove.
In the example below, a complex type with 2 props is typed as Record<'flag', bool>
after passing through assoc
import { assoc } from "ramda";
type OriginalType = {
name: string;
flag: boolean;
};
function takesAnOriginalType(original: OriginalType) {
console.log(original);
}
const array: OriginalType[] = [{ name: "test", flag: true }];
const mapped = array.map(assoc("flag", false));
takesAnOriginalType(mapped);
^^^^^^
const mapped: Record<"flag", boolean>[]
Argument of type 'Record<"flag", boolean>[]' is not assignable to parameter of type 'OriginalType'.
Type 'Record<"flag", boolean>[]' is missing the following properties from type 'OriginalType': name, flagts(2345)
Make sure all function type definition either meets or beats what is in @types/ramda
Can we please export the new types required for isNotEmpty? I see that a PR is open for it but not yet merged (#101). Unfortunately ramda-adjunct has upgraded their release to now import isNotEmpty from ramda which has the unfortunate consequence of breaking builds.
ramda changelog: ramda/ramda#3453
type DemoType = {
optionalProp?: string
}
const filteredList = propEq('Yes', 'optionalProp')({ optionalProp: 'Yes' } as DemoType)
This produces this error:
Argument of type 'DemoType' is not assignable to parameter of type 'Record<"optionalProp", string>'. Types of property 'optionalProp' are incompatible. Type 'string | undefined' is not assignable to type 'string'. Type 'undefined' is not assignable to type 'string'.
I feel like this should work just fine? The code runs as expected, just produces a the error.
it doesn't error if you pass all parameters at the same time rather than using the curried functions. I'm really not sure why.
propEq('Yes', 'optionalProp', { optionalProp: 'Yes' } as DemoType)
I've forked the project and written a failing test, but sadly I'm not proficient enough at typescript to write something that does any type guarding but allows my use case.
Repro:
it("does not type curry correctly", () => {
type Foo = { id: string; name: string };
const transform = curry((name: string, id: string): Foo => ({ id: id, name: name }));
const b: Foo[] = map(transform("my name"))(["a"]);
expect(b).toEqual([{ id: "a", name: "my name" }]);
});
gets this error:
TS2322: Type ((x: never) => never)[] is not assignable to type Foo[]
Type (x: never) => never is not assignable to type Foo
But the runtime passes.
I'm guessing this breakage may be related to #106?
Draft branch: https://github.com/ramda/types/tree/addIndex
addIndex
is particularly unique in terms of type definitions because of how the return type depends on the given function
Let's use filter as an example
// Special case for filter
export function addIndex<T>(
fn: (f: (item: T) => boolean, list: readonly T[]) => T[],
): _.F.Curry<(a: (item: T, idx: number, list: T[]) => boolean, b: readonly T[]) => T[]>;
To actually use it...
const filterIndexed = addIndex<number>(filter);
filterIndexed(predicate, [1, 2, 3, 4]); // ok
filterIndexed(predicate, ['a', 'b', 'c', 'd']); // error
The problem here is that you have to declare the generic for the type of the Array
you intend to use it for. This defeats the purpose of generics in general, however, not passing the generic means that the type is unknown
, which means the return type for all use cases is unknown[]
const filterIndexed = addIndex(filter);
filterIndexed(predicate, [1, 2, 3, 4]); // returns `unknown[]`
filterIndexed(predicate, ['a', 'b', 'c', 'd']); // returns `unknown[]`
That at least lets you use filterIndexed
for any type, but then you lose all type inference. Not just for the the list
, but for the predicate
as well
addIndex<string>(filter)(isEven, ['a', 'b', 'c', 'd']); // error on isEven, because `(a: number) => boolean !== (a: string) => boolean`
addIndex(filter)(isEven, ['a', 'b', 'c', 'd']); // no error, because everything here is `unknown`
isEven
also needs to be isEven = (item: number, i: number, list: number[]) => boolean
otherwise it errors as well. This means that the inner fn
type needs to support all overloads
TODO
i just updated my project now its full of type errors from this package. I dont even call this package so it is a dependancy of a dependancy... oh joy
do you guys plan to update or rollback your package to fix this please?
yarn compile --fix
yarn run v1.22.19
$ tsc --noEmit && eslint --max-warnings 0 src --fix
node_modules/types-ramda/es/index.d.ts:4453:22 - error TS1139: Type parameter declaration expected.
4453 export function pick<const Names extends readonly [PropertyKey, ...PropertyKey[]]>(names: Names): <U extends Record<ElementOf<Names>, any>>(obj: U) => string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~~~~~
node_modules/types-ramda/es/index.d.ts:4453:34 - error TS1005: ',' expected.
4453 export function pick<const Names extends readonly [PropertyKey, ...PropertyKey[]]>(names: Names): <U extends Record<ElementOf<Names>, any>>(obj: U) => string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~~~~~~~
node_modules/types-ramda/es/index.d.ts:4453:51 - error TS1005: ',' expected.
4453 export function pick<const Names extends readonly [PropertyKey, ...PropertyKey[]]>(names: Names): <U extends Record<ElementOf<Names>, any>>(obj: U) => string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~
node_modules/types-ramda/es/index.d.ts:4453:79 - error TS1005: ',' expected.
4453 export function pick<const Names extends readonly [PropertyKey, ...PropertyKey[]]>(names: Names): <U extends Record<ElementOf<Names>, any>>(obj: U) => string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~
node_modules/types-ramda/es/index.d.ts:4453:82 - error TS1005: ',' expected.
4453 export function pick<const Names extends readonly [PropertyKey, ...PropertyKey[]]>(names: Names): <U extends Record<ElementOf<Names>, any>>(obj: U) => string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~
node_modules/types-ramda/es/index.d.ts:4453:89 - error TS1005: ')' expected.
4453 export function pick<const Names extends readonly [PropertyKey, ...PropertyKey[]]>(names: Names): <U extends Record<ElementOf<Names>, any>>(obj: U) => string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~
node_modules/types-ramda/es/index.d.ts:4453:91 - error TS1434: Unexpected keyword or identifier.
4453 export function pick<const Names extends readonly [PropertyKey, ...PropertyKey[]]>(names: Names): <U extends Record<ElementOf<Names>, any>>(obj: U) => string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~~~~~
node_modules/types-ramda/es/index.d.ts:4453:96 - error TS1128: Declaration or statement expected.
4453 export function pick<const Names extends readonly [PropertyKey, ...PropertyKey[]]>(names: Names): <U extends Record<ElementOf<Names>, any>>(obj: U) => string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~
node_modules/types-ramda/es/index.d.ts:4453:97 - error TS1128: Declaration or statement expected.
4453 export function pick<const Names extends readonly [PropertyKey, ...PropertyKey[]]>(names: Names): <U extends Record<ElementOf<Names>, any>>(obj: U) => string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~
node_modules/types-ramda/es/index.d.ts:4453:159 - error TS1005: ';' expected.
4453 export function pick<const Names extends readonly [PropertyKey, ...PropertyKey[]]>(names: Names): <U extends Record<ElementOf<Names>, any>>(obj: U) => string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~~~~~~~
node_modules/types-ramda/es/index.d.ts:4453:167 - error TS1434: Unexpected keyword or identifier.
4453 export function pick<const Names extends readonly [PropertyKey, ...PropertyKey[]]>(names: Names): <U extends Record<ElementOf<Names>, any>>(obj: U) => string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~~~~~
node_modules/types-ramda/es/index.d.ts:4454:25 - error TS1139: Type parameter declaration expected.
4454 export function pick<U, const Names extends readonly [keyof U, ...(keyof U)[]]>(names: Names, obj: U): string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~~~~~
node_modules/types-ramda/es/index.d.ts:4454:37 - error TS1005: ',' expected.
4454 export function pick<U, const Names extends readonly [keyof U, ...(keyof U)[]]>(names: Names, obj: U): string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~~~~~~~
node_modules/types-ramda/es/index.d.ts:4454:54 - error TS1005: ',' expected.
4454 export function pick<U, const Names extends readonly [keyof U, ...(keyof U)[]]>(names: Names, obj: U): string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~
node_modules/types-ramda/es/index.d.ts:4454:61 - error TS1005: ',' expected.
4454 export function pick<U, const Names extends readonly [keyof U, ...(keyof U)[]]>(names: Names, obj: U): string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~
node_modules/types-ramda/es/index.d.ts:4454:67 - error TS1003: Identifier expected.
4454 export function pick<U, const Names extends readonly [keyof U, ...(keyof U)[]]>(names: Names, obj: U): string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~
node_modules/types-ramda/es/index.d.ts:4454:74 - error TS1005: ')' expected.
4454 export function pick<U, const Names extends readonly [keyof U, ...(keyof U)[]]>(names: Names, obj: U): string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~
node_modules/types-ramda/es/index.d.ts:4454:75 - error TS1128: Declaration or statement expected.
4454 export function pick<U, const Names extends readonly [keyof U, ...(keyof U)[]]>(names: Names, obj: U): string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~
node_modules/types-ramda/es/index.d.ts:4454:78 - error TS1005: ';' expected.
4454 export function pick<U, const Names extends readonly [keyof U, ...(keyof U)[]]>(names: Names, obj: U): string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~
node_modules/types-ramda/es/index.d.ts:4454:79 - error TS1109: Expression expected.
4454 export function pick<U, const Names extends readonly [keyof U, ...(keyof U)[]]>(names: Names, obj: U): string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~
node_modules/types-ramda/es/index.d.ts:4454:86 - error TS1005: ')' expected.
4454 export function pick<U, const Names extends readonly [keyof U, ...(keyof U)[]]>(names: Names, obj: U): string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~
node_modules/types-ramda/es/index.d.ts:4454:98 - error TS1005: ';' expected.
4454 export function pick<U, const Names extends readonly [keyof U, ...(keyof U)[]]>(names: Names, obj: U): string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~
node_modules/types-ramda/es/index.d.ts:4454:100 - error TS1434: Unexpected keyword or identifier.
4454 export function pick<U, const Names extends readonly [keyof U, ...(keyof U)[]]>(names: Names, obj: U): string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~
node_modules/types-ramda/es/index.d.ts:4454:101 - error TS1128: Declaration or statement expected.
4454 export function pick<U, const Names extends readonly [keyof U, ...(keyof U)[]]>(names: Names, obj: U): string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~
node_modules/types-ramda/es/index.d.ts:4454:102 - error TS1128: Declaration or statement expected.
4454 export function pick<U, const Names extends readonly [keyof U, ...(keyof U)[]]>(names: Names, obj: U): string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~
node_modules/types-ramda/es/index.d.ts:4454:104 - error TS1434: Unexpected keyword or identifier.
4454 export function pick<U, const Names extends readonly [keyof U, ...(keyof U)[]]>(names: Names, obj: U): string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~~~~~~
node_modules/types-ramda/es/index.d.ts:4454:111 - error TS1128: Declaration or statement expected.
4454 export function pick<U, const Names extends readonly [keyof U, ...(keyof U)[]]>(names: Names, obj: U): string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~~~~~~~
node_modules/types-ramda/es/index.d.ts:4454:119 - error TS1434: Unexpected keyword or identifier.
4454 export function pick<U, const Names extends readonly [keyof U, ...(keyof U)[]]>(names: Names, obj: U): string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~~~~~
Found 28 errors in the same file, starting at: node_modules/types-ramda/es/index.d.ts:4453
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
➜ moralis-admin-frontend git:(feat-streams-additional-data-step) ✗ yarn compile --fix
yarn run v1.22.19
$ tsc --noEmit && eslint --max-warnings 0 src --fix
node_modules/types-ramda/es/index.d.ts:4453:22 - error TS1139: Type parameter declaration expected.
4453 export function pick<const Names extends readonly [PropertyKey, ...PropertyKey[]]>(names: Names): <U extends Record<ElementOf<Names>, any>>(obj: U) => string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~~~~~
node_modules/types-ramda/es/index.d.ts:4453:34 - error TS1005: ',' expected.
4453 export function pick<const Names extends readonly [PropertyKey, ...PropertyKey[]]>(names: Names): <U extends Record<ElementOf<Names>, any>>(obj: U) => string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~~~~~~~
node_modules/types-ramda/es/index.d.ts:4453:51 - error TS1005: ',' expected.
4453 export function pick<const Names extends readonly [PropertyKey, ...PropertyKey[]]>(names: Names): <U extends Record<ElementOf<Names>, any>>(obj: U) => string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~
node_modules/types-ramda/es/index.d.ts:4453:79 - error TS1005: ',' expected.
4453 export function pick<const Names extends readonly [PropertyKey, ...PropertyKey[]]>(names: Names): <U extends Record<ElementOf<Names>, any>>(obj: U) => string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~
node_modules/types-ramda/es/index.d.ts:4453:82 - error TS1005: ',' expected.
4453 export function pick<const Names extends readonly [PropertyKey, ...PropertyKey[]]>(names: Names): <U extends Record<ElementOf<Names>, any>>(obj: U) => string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~
node_modules/types-ramda/es/index.d.ts:4453:89 - error TS1005: ')' expected.
4453 export function pick<const Names extends readonly [PropertyKey, ...PropertyKey[]]>(names: Names): <U extends Record<ElementOf<Names>, any>>(obj: U) => string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~
node_modules/types-ramda/es/index.d.ts:4453:91 - error TS1434: Unexpected keyword or identifier.
4453 export function pick<const Names extends readonly [PropertyKey, ...PropertyKey[]]>(names: Names): <U extends Record<ElementOf<Names>, any>>(obj: U) => string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~~~~~
node_modules/types-ramda/es/index.d.ts:4453:96 - error TS1128: Declaration or statement expected.
4453 export function pick<const Names extends readonly [PropertyKey, ...PropertyKey[]]>(names: Names): <U extends Record<ElementOf<Names>, any>>(obj: U) => string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~
node_modules/types-ramda/es/index.d.ts:4453:97 - error TS1128: Declaration or statement expected.
4453 export function pick<const Names extends readonly [PropertyKey, ...PropertyKey[]]>(names: Names): <U extends Record<ElementOf<Names>, any>>(obj: U) => string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~
node_modules/types-ramda/es/index.d.ts:4453:159 - error TS1005: ';' expected.
4453 export function pick<const Names extends readonly [PropertyKey, ...PropertyKey[]]>(names: Names): <U extends Record<ElementOf<Names>, any>>(obj: U) => string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~~~~~~~
node_modules/types-ramda/es/index.d.ts:4453:167 - error TS1434: Unexpected keyword or identifier.
4453 export function pick<const Names extends readonly [PropertyKey, ...PropertyKey[]]>(names: Names): <U extends Record<ElementOf<Names>, any>>(obj: U) => string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~~~~~
node_modules/types-ramda/es/index.d.ts:4454:25 - error TS1139: Type parameter declaration expected.
4454 export function pick<U, const Names extends readonly [keyof U, ...(keyof U)[]]>(names: Names, obj: U): string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~~~~~
node_modules/types-ramda/es/index.d.ts:4454:37 - error TS1005: ',' expected.
4454 export function pick<U, const Names extends readonly [keyof U, ...(keyof U)[]]>(names: Names, obj: U): string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~~~~~~~
node_modules/types-ramda/es/index.d.ts:4454:54 - error TS1005: ',' expected.
4454 export function pick<U, const Names extends readonly [keyof U, ...(keyof U)[]]>(names: Names, obj: U): string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~
node_modules/types-ramda/es/index.d.ts:4454:61 - error TS1005: ',' expected.
4454 export function pick<U, const Names extends readonly [keyof U, ...(keyof U)[]]>(names: Names, obj: U): string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~
node_modules/types-ramda/es/index.d.ts:4454:67 - error TS1003: Identifier expected.
4454 export function pick<U, const Names extends readonly [keyof U, ...(keyof U)[]]>(names: Names, obj: U): string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~
node_modules/types-ramda/es/index.d.ts:4454:74 - error TS1005: ')' expected.
4454 export function pick<U, const Names extends readonly [keyof U, ...(keyof U)[]]>(names: Names, obj: U): string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~
node_modules/types-ramda/es/index.d.ts:4454:75 - error TS1128: Declaration or statement expected.
4454 export function pick<U, const Names extends readonly [keyof U, ...(keyof U)[]]>(names: Names, obj: U): string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~
node_modules/types-ramda/es/index.d.ts:4454:78 - error TS1005: ';' expected.
4454 export function pick<U, const Names extends readonly [keyof U, ...(keyof U)[]]>(names: Names, obj: U): string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~
node_modules/types-ramda/es/index.d.ts:4454:79 - error TS1109: Expression expected.
4454 export function pick<U, const Names extends readonly [keyof U, ...(keyof U)[]]>(names: Names, obj: U): string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~
node_modules/types-ramda/es/index.d.ts:4454:86 - error TS1005: ')' expected.
4454 export function pick<U, const Names extends readonly [keyof U, ...(keyof U)[]]>(names: Names, obj: U): string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~
node_modules/types-ramda/es/index.d.ts:4454:98 - error TS1005: ';' expected.
4454 export function pick<U, const Names extends readonly [keyof U, ...(keyof U)[]]>(names: Names, obj: U): string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~
node_modules/types-ramda/es/index.d.ts:4454:100 - error TS1434: Unexpected keyword or identifier.
4454 export function pick<U, const Names extends readonly [keyof U, ...(keyof U)[]]>(names: Names, obj: U): string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~
node_modules/types-ramda/es/index.d.ts:4454:101 - error TS1128: Declaration or statement expected.
4454 export function pick<U, const Names extends readonly [keyof U, ...(keyof U)[]]>(names: Names, obj: U): string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~
node_modules/types-ramda/es/index.d.ts:4454:102 - error TS1128: Declaration or statement expected.
4454 export function pick<U, const Names extends readonly [keyof U, ...(keyof U)[]]>(names: Names, obj: U): string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~
node_modules/types-ramda/es/index.d.ts:4454:104 - error TS1434: Unexpected keyword or identifier.
4454 export function pick<U, const Names extends readonly [keyof U, ...(keyof U)[]]>(names: Names, obj: U): string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~~~~~~
node_modules/types-ramda/es/index.d.ts:4454:111 - error TS1128: Declaration or statement expected.
4454 export function pick<U, const Names extends readonly [keyof U, ...(keyof U)[]]>(names: Names, obj: U): string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~~~~~~~
node_modules/types-ramda/es/index.d.ts:4454:119 - error TS1434: Unexpected keyword or identifier.
4454 export function pick<U, const Names extends readonly [keyof U, ...(keyof U)[]]>(names: Names, obj: U): string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
~~~~~
Found 28 errors in the same file, starting at: node_modules/types-ramda/es/index.d.ts:4453
We've recently upgraded from 0.28.25 to 0.29.1 and started having build issues along the lines of
error TS7006: Parameter 'user' implicitly has an 'any' type.
Coming from a function that looks like this (note: a lot of code has been redacted):
export const getUsers = curry(
async (id: string): Promise<User[]> => {
// ...
}
);
// ...
import { getUsers } from '@package/getUsers.js';
// the user param is the one with an implicit any
await getUsers(id)).map(async user => {
As i was looking through the differences, i've noticed that 0.28.25 produces a d.ts which includes a triple slash import
/// <reference types="ts-toolbelt" />
...
getUsers: import("Function/Curry").Curry<(id: string) => Promise<User[]>>;
whereas 0.29.1 does not do that and produces something like below
getUsers: import("ts-toolbelt/out/Function/Curry.js").Curry<(id: string) => Promise<User[]>>;
Installing ts-toolbelt in the project resolves build issues.
Hi - looks like this commit broke these types: 3f8e31d
[!] (plugin typescript) RollupError: @rollup/plugin-typescript TS1139: Type parameter declaration expected.
../../../../node_modules/@types/ramda/node_modules/types-ramda/es/index.d.ts (4453:22)
4453 export function pick<const Names extends readonly [PropertyKey, ...PropertyKey[]]>(names: Names): <U extends Record<ElementOf<Names>, any>>(obj: U) => string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
Need to make one
For typescript, when using the function R.type, the possible types are
"Object" | "Number" | "Boolean" | "String" | "Null" | "Array" | "RegExp" | "Function" | "Undefined" | "Symbol" | "Error"
However, if you pass R.type(new Date ()), a string of 'Date' gets returned
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.