Comments (16)
Hey @voxpelli, we were just updating our code repository in my company to 5.4.2 and this test started breaking so I figured I would send an early signal. I'm not really looking for contribution opportunities at the moment.
Here's the ConditionalKeys
test rewritten in TS Playground: link (change the version to "5.3.3" to see the old behavior)
from type-fest.
How come the canary is not picking up on this? https://github.com/sindresorhus/type-fest/actions/workflows/ts-canary.yml
We don't use tsd
in our internal fork, but have (programmatically) rewritten the tests to use a simpler typechecking assertion library. My guess about why your CI workflow didn't pick up the breakage is that it was using tsd
for type checking, which has its own version of typescript built into it - so it's still effectively testing against the old version. (FWIW, this is the main reason we don't use tsd
- we want a single typescript import to control all type checking everywhere).
from type-fest.
from type-fest.
How come the canary is not picking up on this? https://github.com/sindresorhus/type-fest/actions/workflows/ts-canary.yml
from type-fest.
@trevorade Extending the tests to highlight this failure would be a good first step I think 👍
This is the second breakage in the 5.4-line, after #784
from type-fest.
For ConditionalKeys
, looks like the fix is to just add -?
and drop the NonNullable
:
export type ConditionalKeys<Base, Condition> = {
// Map through all the keys of the given base type.
[Key in keyof Base]-?:
// Pick only keys with types extending the given `Condition` type.
Base[Key] extends Condition
// Retain this key since the condition passes.
? Key
// Discard this key since the condition fails.
: never;
// Convert the produced object into a union type of the keys which passed the conditional test.
}[keyof Base];
Fixes the tests on our end anyways.
from type-fest.
Here's some debugging info for SerParameterType
. Specifically, the issue appears to be with MergeObjectToTuple
:
TS Playground link (change the version to 5.3.3 to see the difference)
This one may indicate a TypeScript bug
from type-fest.
Simpler repro of the underlying issue.
TS Playground link (change the version to 5.3.3 to see the difference)
I'll see about logging an issue.
from type-fest.
Hi @trevorade
I did some test, If we focus only on the results of type A
, it looks like 5.4.2 is correct?
But whatever this is a breaking change..
type Test<Tuple extends unknown[]> = {
[K in keyof Tuple]: K
};
type A = Test<[a: number, b: string, c: Object, ...arguments: boolean[]]>
// v5.3.3 type A = [a: "0", b: "1", c: "2", ...arguments: "3"[]]
// v5.4.2 type A = [a: "0", b: "1", c: "2", ...arguments: number[]]
from type-fest.
Looks like SetParameterType
is failing for rest arguments due to this TSC PR: microsoft/TypeScript#57031
I haven't looked closer to see what the correct rewrite would be.
from type-fest.
SetParameterType
should be fixed in https://github.com/sindresorhus/type-fest/releases/tag/v4.13.0
from type-fest.
Thanks. I'll verify the fix on our end later today
from type-fest.
Confirmed on our end that [See update below]SetParameterType
is fixed. Thx!
ConditionalKeys
should be easy to fix:
#831 (comment)
from type-fest.
Apologies, SetParameterType
is not quite fixed.
For this case in tsc 5.4.2:
// Test another define way
declare const test3: SetParameterType<typeof fn, [a: string, b: boolean]>;
expectType<(a: string, b: boolean, c: Object, ...args: boolean[]) => null>(test3);
test3('1', true, {}, true);
I'm seeing the type of test3
resolve to:
type test3Type = (_a: string, _b: boolean, _c: Object, ..._arguments: (string | boolean)[]) => null
You can ignore the difference in parameter names but the last rest parameter is resolving to (string | boolean)[]
rather than the expected boolean[]
.
Here's a reproduction of this error in TS Playground.
from type-fest.
Sorry, I made a mistake that ignore the number key when input is an array. I'm fixing it right now.
It seems that the improvement of the testing system is more urgent.
from type-fest.
It seems that the improvement of the testing system is more urgent.
from type-fest.
Related Issues (20)
- Use `NoInfer`?
- Type for serializable objects? HOT 3
- Proposal: SetKeyRequired with key required, but allow undefined value HOT 2
- OverrideProperties changes undefined as optional HOT 2
- Exclude / Pick type in Paths / only add leaf nodes HOT 2
- `Proposal`: add option with exclude/keep specified type on deep type HOT 5
- Unify `Get` and `Paths` / `PickDeep` etc HOT 1
- `Paths` is unable to escape dots in property names
- DistributedOmit may not need to constraint the second type argument HOT 6
- A type util to produce an alternation of function overloads. HOT 1
- PositiveIntegerString type HOT 4
- Type-fest based prelude HOT 1
- ArrayExceptLastElement type HOT 7
- Zero is not exported by ... HOT 1
- `And` and `Or` is not exported at `index.d.ts`
- ConditionalKeys does not correctly filter out `never` type HOT 3
- Paths<T> should handle recursive types
- `PickDeep` strips `null` HOT 7
- `schema` should properly set type of objects in arrays
- `SimplifyDeep` doesn't deep simplify lists
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 type-fest.