-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Destructuring with rename incorrectly inferred as any
#38969
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
Comments
remcohaszing
added a commit
to remcohaszing/axios
that referenced
this issue
Jun 7, 2020
This requires TypeScript users to explicitly define the type of the data they are consuming. Before this, data was `any` by default. This means TypeScript consumers didn’t get type safety if they forgot to specify the type. Technically this is a breaking change for TypeScript users, as this will report errors if they forgot to specifiy the response type. The simplest workaround would be to explicitly set the response type to `any`, so it’s not breaking much. The `unknown` type is probably a slightly better fit, but this requires TypeScript ^3. `data` is still `any` in the very specific use case mentioned in microsoft/TypeScript#38969
any
jasonsaayman
added a commit
to axios/axios
that referenced
this issue
Sep 5, 2021
This requires TypeScript users to explicitly define the type of the data they are consuming. Before this, data was `any` by default. This means TypeScript consumers didn’t get type safety if they forgot to specify the type. Technically this is a breaking change for TypeScript users, as this will report errors if they forgot to specifiy the response type. The simplest workaround would be to explicitly set the response type to `any`, so it’s not breaking much. The `unknown` type is probably a slightly better fit, but this requires TypeScript ^3. `data` is still `any` in the very specific use case mentioned in microsoft/TypeScript#38969 Co-authored-by: Jay <[email protected]>
mbargiel
pushed a commit
to mbargiel/axios
that referenced
this issue
Jan 27, 2022
This requires TypeScript users to explicitly define the type of the data they are consuming. Before this, data was `any` by default. This means TypeScript consumers didn’t get type safety if they forgot to specify the type. Technically this is a breaking change for TypeScript users, as this will report errors if they forgot to specifiy the response type. The simplest workaround would be to explicitly set the response type to `any`, so it’s not breaking much. The `unknown` type is probably a slightly better fit, but this requires TypeScript ^3. `data` is still `any` in the very specific use case mentioned in microsoft/TypeScript#38969 Co-authored-by: Jay <[email protected]>
redsky030511
added a commit
to redsky030511/axios-server
that referenced
this issue
May 13, 2024
This requires TypeScript users to explicitly define the type of the data they are consuming. Before this, data was `any` by default. This means TypeScript consumers didn’t get type safety if they forgot to specify the type. Technically this is a breaking change for TypeScript users, as this will report errors if they forgot to specifiy the response type. The simplest workaround would be to explicitly set the response type to `any`, so it’s not breaking much. The `unknown` type is probably a slightly better fit, but this requires TypeScript ^3. `data` is still `any` in the very specific use case mentioned in microsoft/TypeScript#38969 Co-authored-by: Jay <[email protected]>
Jupev6
added a commit
to Jupev6/axios
that referenced
this issue
Aug 11, 2024
This requires TypeScript users to explicitly define the type of the data they are consuming. Before this, data was `any` by default. This means TypeScript consumers didn’t get type safety if they forgot to specify the type. Technically this is a breaking change for TypeScript users, as this will report errors if they forgot to specifiy the response type. The simplest workaround would be to explicitly set the response type to `any`, so it’s not breaking much. The `unknown` type is probably a slightly better fit, but this requires TypeScript ^3. `data` is still `any` in the very specific use case mentioned in microsoft/TypeScript#38969 Co-authored-by: Jay <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
TypeScript Version: Nightly or 3.9.x
Search Terms: never destructure
Expected behavior: The type of
shouldBeNever
isnever
.Actual behavior: The type of
shouldBeNever
isany
.The issue also exists for synchronous functions, but the asynchronous example shows that everything works as expected when using
Promise.then()
.The same issue exists for
unknown
as well.Code
Output
Compiler Options
Playground Link: Provided
The text was updated successfully, but these errors were encountered: