-
-
Notifications
You must be signed in to change notification settings - Fork 515
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ReadonlyDeep
does not work for objects with call signatures
#337
Labels
Comments
sindresorhus
added
bug
Something isn't working
help wanted
Extra attention is needed
labels
Jan 3, 2022
sindresorhus
changed the title
Jan 3, 2022
ReadonlyDeep
doens't work for objects with call signaturesReadonlyDeep
does not work for objects with call signatures
6 tasks
RebeccaStevens
added a commit
to RebeccaStevens/type-fest
that referenced
this issue
Jan 29, 2022
RebeccaStevens
added a commit
to RebeccaStevens/type-fest
that referenced
this issue
Jan 29, 2022
RebeccaStevens
added a commit
to RebeccaStevens/type-fest
that referenced
this issue
Jan 29, 2022
RebeccaStevens
added a commit
to RebeccaStevens/type-fest
that referenced
this issue
Jan 29, 2022
RebeccaStevens
added a commit
to RebeccaStevens/type-fest
that referenced
this issue
Jan 29, 2022
RebeccaStevens
added a commit
to RebeccaStevens/type-fest
that referenced
this issue
Jan 29, 2022
RebeccaStevens
added a commit
to RebeccaStevens/type-fest
that referenced
this issue
Jan 31, 2022
RebeccaStevens
added a commit
to RebeccaStevens/type-fest
that referenced
this issue
Jan 31, 2022
Seems to be fixed with #359 (Playground) |
Thanks, trying it out! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
I have recently stumbled upon an issue with the
ReadonlyDeep<>
type. I have a type which has both members as well as call signatures (in my case theJQueryStatic
type from@types/jquery
). When I tried to createReadonlyDeep<JQueryStatic>
, what I got back was justJQueryStatic
- no change in type...Eventually, I tracked it down to the definition:
type-fest/source/readonly-deep.d.ts
Lines 37 to 45 in f45033c
In this case, because the type has a call signature,
T extends Primitive | ((...arguments: any[]) => unknown)
evaluates totrue
and therefore what you get back is the original type...Trying to fix the issue
I tried to fix the issue by changing the first check to be just
T extends Primitive
, but then the type would lose all of its call signatures, as it would returnReadonlyObjectDeep<>
...So I tried changing
ReadonlyObjectDeep
fromtype-fest/source/readonly-deep.d.ts
Lines 62 to 64 in f45033c
to
but that just got me
TS7061: A mapped type may not declare properties or methods.
Is there any way to fix this? Also, as far as I know TS objects have members, call signatures, construct signatures and index infos - the current
ReadonlyObjectDeep
does only members and index infos, I stumbled here upon call signatures, but construct signatures should probably be solved as well...Upvote & Fund
The text was updated successfully, but these errors were encountered: