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
Update types for Promises on Auth calls #9286
Comments
Thanks for this feedback @jhechtf. I have marked this as a feature request as this is something we are currently evaluating for the Auth Category. While we don't have a timeline at this moment as to when to expect for this TypeScript work to be completed, we will keep you updated once we have an update on this front. Thanks! |
Thanks; let me know if there is anything i can do to assist. |
Any word on this @sammartinez ? |
Upon reviewing the code in Auth.ts there are 25 instances of This type: These usecases should ideally just be For example, Auth.currentAuthenticatedUser appears to raise an exception (rejecting the promise) whenever a user doesn’t exist, so the return type should just be let user = null;
try {
user = await this.currentUserPoolUser(params);
} catch (e) {
…
}
this.user = user;
return this.user; to this: try {
this.user = await this.currentUserPoolUser(params); // also this function needs updating typing
return this.user;
} catch (e) {
…
} This would be a great improvement on TypeScript support! |
We have published an RFC on our plan for improving TypeScript support in Amplify JS & would love to get your feedback & suggestions! |
The developer preview for v6 of Amplify has officially been released with improved support for TypeScript and much more! Please check out our announcement and updated documentation to see what has changed. This issue should be resolved within the dev preview and upcoming General Availability for Amplify v6, but let us know with a comment if there are further issues. |
With the release of the latest major version of Amplify (aws-amplify@>6), this issue should now be resolved! Please refer to our release announcement, migration guide, and documentation for more information. |
Before opening, please confirm:
JavaScript Framework
React, Not applicable
Amplify APIs
Authentication
Amplify Categories
auth
Environment information
Describe the bug
Note: I do not use the Amplify CLI, and I am only using the @aws-amplify/auth package directly. I am also currently using the following packages/versions
The TypeScript definitions for the Auth package heavily use the
any
as a return type when they should be denoted as some other type.Expected behavior
The return types for the typescript definitions should entirely remove the use of
any
in the return types of the methods.Reproduction steps
@aws-amplify/core
and@aws-amplfiy/auth
Code Snippet
the project that got this all started is located at https://github.com/vini-vici/front-end
Some examples:
Log output
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
Currently the work around is to have to manually type the statements, e.g.
This becomes harder in more obscure places where it's much harder to tell what the return result actually is, or if it has an associated type in the definitions.
The text was updated successfully, but these errors were encountered: