-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Fresh create-react-app
- Typescript
#143
Comments
@mikepatrick thanks so much for the awesome feedback! 👍 I tested what you mentioned on the typescript stuff and it seems good with other projects as well i.e. typings in package.json etc. Feel free to submit a PR for that stuff for sure and we can get that merged in. More typescript support (and cleanup), including samples is in our backlog as well just fyi. For the vscode issue, I'm not sure, let me look into that for you and see if we can clean this up. We also have some more vscode integrations (snippets) in our backlog as well. |
@mlabieniec Thanks for looking into this and getting back to me so quickly! I submitted a PR for issues 1 and 2. With respect to issue 3, I fear that I may have raised a false alarm. I went back to do some testing, and everything works fine without any So, please disregard my "issue" 3. I'm very glad to hear VSCode integrations are in the works. Thanks again for the speedy reply, and for being so genuinely receptive to feedback. |
@mikepatrick no problem, thanks a lot for catching this! I also didn't see that (issue 3) when running through tests in vscode. |
This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs. Looking for a help forum? We recommend joining the Amplify Community Discord server |
First, I'd like to say that I'm impressed with what I've seen so far. Nice work. I'm hoping to use Amplify in an existing React application written in Typescript.
So, I pulled
aws-amplify
andaws-amplify-react
into a freshcreate-react-app
project of the Typescript variety:create-react-app sample-app --scripts-version=react-scripts-ts
I ran into a few issues, and I'm not sure if a PR is appropriate, or if I just need advice.
Issue 1
I'm importing Amplify into my React application like this:
import Amplify from 'aws-amplify';
And I get this error both in VSCode and when I try
yarn build
:The work around
I worked around this by adding the following to
package.json
inaws-amplify/packages/aws-amplify
:"typings": "./lib/index.d.ts",
Issue 2
Next issue is that
aws-amplify/lib/Common/Logger/ConsoleLogger.d.ts
complains:error TS2307: Cannot find module './logger-interface'.
This also happens in VSCode as well as with
yarn build
.The work around
I worked around this by renaming
aws-amplify/src/Common/Logger/logger-interface.d.ts
tologger-interface.ts
, and rebuilding Amplify. This waylogger-interface.d.ts
(along with a.js
file and a source map) are generated by the build.After these two work arounds, the React app compiles and runs as expected.
Issue 3
This one isn't a problem with the React app; this one is a problem I'm having when I actually clone
aws-amplify
. I considered a separate issue for this, but I don't want to clutter up what's bound to be a rapidly growing backlog. Nevertheless, I figured I'd mention it while I've got the mic.When I open the tests, VSCode barks at me about all the Jest Globals - can't find
describe
, can't findexpect
, etc. The tests do run fine, so it seems like something specific to VSCode (perhaps my VSCode environment, in particular?).The work around
I worked around this by adding a
jsconfig.json
file inaws-amplify/packages/aws-amplify
, with the following contents:This made VSCode happy.
Any advice?
I'd be happy to submit a PR for any of this, if it's appropriate. I'd also be happy to help with documentation or testing that might help smooth the path for Typescript developers.
These few minor changes have been checked into my fork, if anybody wants a closer look.
I feel like there's a reasonable chance I'm just doing something(s) wrong or missing something. I'm really excited about this library, so any advice is most welcome.
Version Notes
create-react-app
version 1.4.3 using Typescript version 2.5.3.The text was updated successfully, but these errors were encountered: