Conversation
449bcea to
2d4c1ba
Compare
…ion/classes - Added `ExtractCallSignature` type to extract call signatures from function types. - Moved `HasMultipleCallSignatures` type to `internal/function.d.ts`. - Updated `SetOptional`, `SetReadonly`, and `SetRequired` types to utilize `ExtractCallSignature`. - Updated tests to reflect changes in type behavior and ensure correctness.
2d4c1ba to
aeb2ff8
Compare
|
One thing to note is that when passing a function, the resulting type becomes This seems to be the best solution so far, at least until we find a proper fix for |
som-sm
left a comment
There was a problem hiding this comment.
Looks like the PR has some unintended formatting changes, can you please go through the PR once and clean it up.
som-sm
left a comment
There was a problem hiding this comment.
Apart from MergeDeep and a couple of test cases does anything else break if we simply add a Function check in Simplify? Like:
- export type Simplify<T> = {[KeyType in keyof T]: T[KeyType]} & {};
+ export type Simplify<T> = T extends Function ? T : {[KeyType in keyof T]: T[KeyType]};It'd be nice if we could keep the implementation simple. The test cases should be easily fixable. So, if it's just MergeDeep, then it'd be better if we could somehow fix MergeDeep itself.
| ? IsUnknown<This> extends true // TODO: replace with `FunctionWithMaybeThisParameter` | ||
| ? (...args: Parameters) => Return | ||
| : (this: This, ...args: Parameters) => Return | ||
| : unknown; |
There was a problem hiding this comment.
Returning unknown for non-functions doesn't seem correct in general. It shouldn't be designed just for the specific use case in Simplify (ExtractCallSignature<Type> & _Simplify<Type>).
|
Bump :) |
Simplifytype to improve flattening and support of union/function/classesExtractCallSignatureinternal type to extract call signatures from function types.HasMultipleCallSignaturesinternal type tointernal/function.d.ts.SetOptional,SetReadonly, andSetRequiredtypes to utilizeExtractCallSignatureandSimplify.