Comments (2)
Hi there thanks for the issue. I found out what was going on here. For types-ramda
we updated to the latest ts-toolkit
as that was needed to fix some existing types. The way the mergeAll
was previously types used type functions from ts-toolkit
that no longer exists. So we had to re-type them.
The current type is this:
export function mergeAll<O extends object, Os extends readonly object[]>(list: [O, ...Os]): _.O.Assign<O, Os>;
_.O.Assign
is defined here and as the name suggests, a type for Object.assign
, which is exactly what mergeAll
is under the hood
Our tests included the following
const foo = { foo: 'foo' };
const bar = { bar: 'bar' };
const foo2 = { foo: 2 };
expectType<{ foo: string; }>(mergeAll([foo]));
expectType<{ foo: string; bar: string; }>(mergeAll([foo, bar]));
expectType<{ foo: number; }>(mergeAll([foo, foo2]));
Those tests, as it turns out, only account for passing in array literals of either the same or different types. It turns out, that when you pass in an Array<any>
or any[]
, the typings break down. It breaks down specifically because when you have Array<any>
or any[]
, [O, ...Os]
cannot be inferred in the same way when passing an array literal or tuple, Giving you the Source provides no match for required element at position 0 in target.
error
Fortunately, this is an easy fix. Since when you mergeAll
an Array<T>
you simple get back T
. Which means the solution is just to add this overload
export function mergeAll<T>(list: readonly T[]): T;
MR here: #23
I'll try to get this merged and released today for you
from types.
Thank you for the swift fix an in depth explanation
from types.
Related Issues (17)
- @types/ramda parity HOT 1
- How to type curried functions HOT 3
- mergeDeepLeft behaves differently than in @types/ramda HOT 4
- The Master List
- 0.29.2 breaks tests on DT HOT 2
- Conditional types HOT 2
- What to do about transducers
- transduce's accumulator type
- `pluck` does not work with argument typed as `any` HOT 2
- `assoc` returns a narrower type than what is passed HOT 2
- `of` now receives two parameters instead of one HOT 2
- Github Actions and npm publish HOT 1
- Clean up `tools.d.ts`
- addIndex
- Automate release HOT 2
- MR template and merge requirements HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from types.