Is your feature request related to a problem? Please describe.
When developing a React Native app with aws-amplify-react-native, adding the following line:
import { withAuthenticator } from 'aws-amplify-react-native';
results in the following warning:
{
"resource": "/Users/adrianha/GitHub/restaurant-reviews/mobile-app/src/screens/UserScreen.tsx",
"owner": "typescript",
"code": "7016",
"severity": 8,
"message": "Could not find a declaration file for module 'aws-amplify-react-native'. '/Users/adrianha/GitHub/restaurant-reviews/mobile-app/node_modules/aws-amplify-react-native/dist/index.js' implicitly has an 'any' type.\n Try `npm install @types/aws-amplify-react-native` if it exists or add a new declaration (.d.ts) file containing `declare module 'aws-amplify-react-native';`",
"source": "ts",
"startLineNumber": 1,
"startColumn": 35,
"endLineNumber": 1,
"endColumn": 61
}
Describe the solution you'd like
Generate and publish typings information that is distributed with aws-amplify-react-native.
Describe alternatives you've considered
I have added a custom typings file to my project that provides this information.
@adrianhall will you share your types?
I don't have that project available any more.
will you share your types?
I'm using these: https://github.com/dantasfiles/AmplifyReactNativeTypes
@dantasfiles how can I use them? Where should I place this type definition in my project so that it works?
Why doesn't this just work? The module is written in Typescript, but the build script does not include the declaration files. I tried adding tsc --emitDeclarationOnly, but so far there are many errors. I'm going to try to work through them.
Are there any insights for why this module was written in Typescript but get built without the declaration files? This seems more like a bug than a feature request.
Since the library is written in Typescript, one should expect typings work out-of-box. Is this some build config that the amplify team can easily fix? It's been two years
Any updates on this,
You would expect to have typescript support with type definition out of the box,
It seems that any project now and a specially with the scale of amplify to be with typescript in mind.
Not recommended, But for now I ended up with:
// @ts-expect-error
import { withAuthenticator } from "aws-amplify-react-native";
// @ts-expect-error
import config from "./aws-exports";
Most helpful comment
I'm using these: https://github.com/dantasfiles/AmplifyReactNativeTypes