amplify-js: type errors when using client.models.mymodel.create
Before opening, please confirm:
- I have searched for duplicate or closed issues and discussions.
- I have read the guide for submitting bug reports.
- I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
JavaScript Framework
Vue
Amplify APIs
GraphQL API
Amplify Version
v6
Amplify Categories
function
Backend
Amplify Gen 2 (Preview)
Environment information
Type script errors are being generated incorrectly when using the create method from a model generated with amplify v2
</details>
### Describe the bug
### Expected behavior
See screenshot. I expect the typescript errors to not be there!
### Reproduction steps
create a simple model through amplify v2. Use typescript. Addec code for example.
### Code Snippet
```javascript
Run: a
.model({
prompt: a.belongsTo('Prompt', 'promptId'),
promptId: a.id(),
trigger: a.string(),
promptContent: a.string(),
promptName: a.string(),
promptCron: a.string(),
runLabel: a.string(),
startTimestamp: a.timestamp(),
endTimestamp: a.timestamp(),
isRunning: a.boolean(),
accessToken: a.string(),
messages: a.hasMany('Message', 'runId')
})
const createCommand = await client.models.Run.create({
trigger: 'manual',
promptId: selectedPrompt.value.id,
promptName: selectedPrompt.value.name,
promptContent: selectedPrompt.value.content,
promptCron: selectedPrompt.value.cron,
runLabel: runLabel,
isRunning: false,
startTimestamp: startEpoc,
accessToken: session.tokens.accessToken.toString(),
endTimestamp: null
})
Log output
// Put your logs below this line
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
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 15 (5 by maintainers)
It looks like the project where Amplify is installed must have
strictset totruein its tsconfig.json file. After adding that my compile errors went away.