-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed as not planned
Labels
DataStoreRelated to DataStore categoryRelated to DataStore categoryTypeScriptRelated to TypeScript issuesRelated to TypeScript issuesquestionGeneral questionGeneral questionto-be-reproducedUsed in order for Amplify to reproduce said issueUsed in order for Amplify to reproduce said issue
Milestone
Description
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
React, React Native
Amplify APIs
DataStore
Amplify Categories
No response
Environment information
System:
OS: macOS 12.2.1
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Memory: 34.95 GB / 64.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 12.22.1 - ~/.nvm/versions/node/v12.22.1/bin/node
Yarn: 1.22.17 - ~/.yvm/shim/yarn
npm: 8.3.0 - ~/.nvm/versions/node/v12.22.1/bin/npm
Watchman: 2021.10.18.00 - /usr/local/bin/watchman
Browsers:
Chrome: 98.0.4758.102
Firefox: 97.0
Safari: 15.3
npmGlobalPackages:
@aws-amplify/cli: 7.6.21
@nestjs/cli: 8.1.5
@teambit/bvm: 0.0.34
aws-cdk: 2.3.0
detox-cli: 19.0.0
eas-cli: 0.47.0
expo-cli: 5.2.0
http-server: 14.1.0
npm: 8.3.0
nx: 13.2.3
pm2: 5.1.2
prisma: 3.5.0
Describe the bug
Not a bug. But usage question discussion never gets an answer. So I am writing bug report.
As documentation suggest wrote selective sync function
my generated model
export declare class Door {
readonly id: string;
readonly index: number;
...
}
selective sync code
DataStore.configure({
syncExpressions: [
syncExpression(Door, (): ((post: Door) => any) => { // <------ problem 1
const s = (door: Door) => door.index('gt', 5) // <------ problem 2
return s
}),
],
})
problem 1
Argument of type '() => (post: Door) => any' is not assignable to parameter of type 'ConditionProducer<Door, []>'.
Type '(post: Door) => any' is not assignable to type 'unique symbol | ProducerModelPredicate<Door> | Promise<ProducerModelPredicate<Door>>'.
Type '(post: Door) => any' is not assignable to type 'ProducerModelPredicate<Door>'.
Types of parameters 'post' and 'condition' are incompatible.
Type 'ModelPredicate<Door>' is not assignable to type 'Door'.
Types of property 'id' are incompatible.
Type '(operator: keyof EqualityOperators<string> | "le" | "lt" | "ge" | "gt" | "beginsWith" | "contains" | "notContains", operand: string) => ModelPredicate<Door>' is not assignable to type 'string'.ts(2345)
problem 2
Type 'Number' has no call signatures.ts(2349)
I checked syncExpression
type but no idea what it wants to be
export declare function syncExpression<T extends PersistentModel, A extends Option<T>>(modelConstructor: PersistentModelConstructor<T>, conditionProducer: ConditionProducer<T, A>): Promise<{
modelConstructor: PersistentModelConstructor<T>;
conditionProducer: ConditionProducer<T, A>;
}>;
Expected behavior
syncExpression to be typed
Reproduction steps
- create new amplify project
- setup data store
- write selective sync code (https://docs.amplify.aws/lib/datastore/sync/q/platform/js/#clear-local-data)
Can someone tell me how to write this code in typescript strict mode? ( without any )
DataStore.configure({
syncExpressions: [
syncExpression(Door, () => {
const s = (door: Door) => door.index('gt', 5)
return s
}),
],
})
Metadata
Metadata
Assignees
Labels
DataStoreRelated to DataStore categoryRelated to DataStore categoryTypeScriptRelated to TypeScript issuesRelated to TypeScript issuesquestionGeneral questionGeneral questionto-be-reproducedUsed in order for Amplify to reproduce said issueUsed in order for Amplify to reproduce said issue