-
Notifications
You must be signed in to change notification settings - Fork 819
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
Docs are misleading for getting TypeScript up and running for Lambdas #8668
Comments
Additionally I've had all this working last night by mocking (yeah me! woot!) however trying to push today and I bump up to this one #6398 which never got resolved. I'm not using the "funky" folder structure they are, I'm literally trying to keep it as vanilla as possible (thought it would be faster that way...) Folder structure...nice and simple ts.config
script in /package.json at the root of the whole app
The error when I deploy |
Fixed the above comment (#8668 (comment)) which was caused by my windows development machine not caring about the casing on the import file but the Lambda caring very much! had this in my file: Hope that helps someone else. Original issue with the docs though still stands. |
@PeteDuncanson I reproduced this and you are right about the gap in our documentation thanks for the detailed issue. We will work on getting it fixed asap. |
I was also recently fighting with with TS for Lambda setup and was wondering if there was a good way to exclude *.ts files from being zipped and uploaded to Lambda. AFAICT the entire Current [documentation] (https://docs.amplify.aws/cli/function/build-options/) says:
I took this to mean that the desired layout was In this layout, the ts files in lib are indeed not zipped, which seems desirable. However, to get this to work there are a couple undocumented gotchas:
Is this the layout that the documentation intended? |
I'm still struggling with this and hoping Amplify can clarify its guidance on underlying file structure? I notice #6398 has a similar parallel structure to the one I mentioned, except that node_modules etc are in the ./lib dir, not the src/ dir. I noticed @attilah gave some great guidance in #6398 ... Any chance Amplify pros could chime in here? |
related #659 |
Before opening, please confirm:
How did you install the Amplify CLI?
No response
If applicable, what version of Node.js are you using?
No response
Amplify CLI Version
6.3.1
What operating system are you using?
Windows
Amplify Categories
function
Amplify Commands
add
Describe the bug
The docs on how to get TypeScript running here https://docs.amplify.aws/cli/function/build-options/ do not match the default layout that
amplify function add
generates. This leads to a lot of wasted time and confusion. Better to give the examples for a vanilla setup rather than losing people with a custom hack around setup.Expected behavior
The location of the ts.config file should be made more clear, it should be "in the root of your function's folder" which it states but then the script we are told to add to our package.json assumes this file is in the
<functionname>/src
folder.The right package.json script if the ts.config is in the root is:
and not
as listed in the docs.
I've no idea what the
&& cd -
does at the end of the listed script comment in the docs but it blows up on Windows so I removed it.There is talk of a '/lib' folder which in the example given is now a requirement to get this to work. Out of the box there is no lib folder so why not assume that they user can add their code directly into the
/src
folder. As its a *.ts file it will be ignored anyway. Chances are you might only have a few of your own files in here, why complicate it for first time users?The ts.config doesn't work for the location mentioned in the docs for the script file, the values in it for /lib and /src are wrong. I've had to fix it to this with trial and error (it might not be 100% "right" but at least its working) with ts.config in the function root is:
Reproduction steps
amplify function add
import test from 'test';
and call it in your handler so show we are doing funky TS stuff.GraphQL schema(s)
# Put schemas below this line
Log output
Additional information
No response
The text was updated successfully, but these errors were encountered: