-
Notifications
You must be signed in to change notification settings - Fork 0
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
"A type annotation is necessary" for auth and schema. #496
Comments
Hey @Gsciarra, thank you for reaching out. I was able to reproduce the issue, marking as bug. |
I ran into this issue as well. I would like to add type annotation to the schema const, but I can't figure out which type definition to use, and I'm not sure a definition is exported anyway. It seems like it could be:
But then I run into an issue on this line:
|
Running into the same issue, not following: ` const schema = a export const data = defineData({ --error later in amplify cli |
I found a working version after looking back at my git repo. I've frozen these relevant packages to their exact versions. You won't like this:
It is far from ideal but it seems to bypass the Amplify backend type errors in my project for now. |
In my case, I'd like to create a client wrapper that I can use inside a monorepo. In
It's a simplified example. But ideally, we'd wrap the API code, so that we can re-use it for mobile, web and Lambdas, so we don't have to keep rewriting the fetching code, and it protects us against future changes to the API methods. In this simplified example, a client would use:
However, in the above export, I get the same "A type annotation is necessary" message. In our case, we have a combined schema of a Postgres and DynamoDB, but I get a similar message for just the DynamoDB-related schema (see the last three lines):
|
A new version of the schema builder (@aws-amplify/data-schema version 1.10.0) was released this morning that exposes many of the types discussed in this issue. @chrisl777, This release didn't include If possible, could you provide a minimal schema that replicates the problem so I can include it in our tests to ensure we protect for your use-case? Thanks, |
@stocaaro I'll try my export of the client again. In the meantime, after updating to 1.10.0, I see an error for my sqlSchema on this line:
^ I've filed this issue as aws-amplify/amplify-category-api#2934. |
@stocaaro I'm still seeing the same error message:
|
Thats unexpected. Can you confirm that If its easy to reproduce, it would be helpful to have an example app with the problem to inspect. |
@stocaaro Here's that output:
I wish I could get an example app up, but that would likely take me a bit of time that I don't have at the moment. |
Thanks and understood. Worth asking just in case you where working with a sample app that is easily published. |
@stocaaro So, I ended up deleting node_modules and yarn.lock, and reinstalling:
I still get my error when trying to build my packages/backend to share with the rest of my monorepo:
However, I do have a workaround, in that I can use just-in-time compilation by adding a
And then in my app, I can import it like:
|
I'm still seeing this issue above
And when I combine the schemas:
|
Hi @chrisl777, There is an update in the works that is expected to fix this error. Expect an update next week. Thanks, |
Hi @chrisl777 , Thank you for bringing up the issue! A new version of the schema builder (@aws-amplify/data-schema version 1.13.2) was released and Thanks, |
@stocaaro @zxl629 I am seeing this issue currently, though slightly different output than before:
|
Interesting. Do you have a sample of the schema definition code in your application that is causing this error? We're building up tests from these examples to ensure when we fix them they stay fixed. Thanks! |
Reopening while we look at the error @chrisl777 posted. |
Environment information
Description
To reproduce:
You will get:
You can "fix" this with
export const auth: ReturnType<typeof defineAuth> = defineAuth({
, and then you will end up withThe text was updated successfully, but these errors were encountered: