Open rnrnstar2 opened 6 months ago
Hi @rnrnstar2, this seems similar to an issue we are currently aware of and working on a fix for. Can you share your schema to reproduce locally so we can confirm?
import { type ClientSchema, a, defineData } from "@aws-amplify/backend";
import { oripaPostConfirmation } from "../functions/OripaPostConfirmation/resource";
const schema = a
.schema({
Team: a
.model({
name: a.string().required(),
s3ImgKey: a.string(),
shops: a.hasMany("Shop", "teamId"),
teamMembers: a.hasMany("TeamMembers", "teamId"),
})
.authorization(allow => [allow.owner().to(['create', 'read', 'update']), allow.authenticated().to(["read", "update"])]),
Shop: a
.model({
name: a.string().required(),
s3ImgKey: a.string(),
teamId: a.id(),
team: a.belongsTo("Team", "teamId"),
shopMembers: a.hasMany("ShopMembers", "shopId"),
})
.authorization(allow => [allow.owner().to(['create', 'read', 'update']), allow.authenticated().to(["read", "update"])]),
Member: a
.model({
name: a.string().required(),
s3ImgKey: a.string(),
email: a.email().required(),
teamMembers: a.hasMany("TeamMembers", "memberId"),
shopMembers: a.hasMany("ShopMembers", "memberId"),
})
.secondaryIndexes((index) => [
index("email").sortKeys(["name"]).queryField("listByEmail"),
])
.authorization(allow => [allow.owner().to(['create', 'read', 'update']), allow.authenticated().to(["read"])]),
TeamMembersType: a.enum(["OWNER", "MEMBER"]),
TeamMembers: a
.model({
type: a.ref("TeamMembersType").required(),
teamId: a.id().required(),
memberId: a.id().required(),
team: a.belongsTo("Team", "teamId"),
member: a.belongsTo("Member", "memberId"),
})
.authorization(allow => [allow.owner().to(['create', 'read', 'update']), allow.authenticated().to(["read", "update", "create"])]),
ShopMembersType: a.enum(["OWNER", "MEMBER"]),
ShopMembers: a
.model({
type: a.ref("ShopMembersType").required(),
shopId: a.id().required(),
memberId: a.id().required(),
shop: a.belongsTo("Shop", "shopId"),
member: a.belongsTo("Member", "memberId"),
})
.authorization(allow => [allow.owner().to(['create', 'read', 'update']), allow.authenticated().to(["read", "update", "create"])]),
OnePieceType: a.enum(["CHARACTER", "EVENT", "STAGE", "LEADER"]),
OnePieceColor: a.enum([
"RED",
"BLUE",
"GREEN",
"YELLOW",
"PURPLE",
"BLACK",
]),
OnePieceAttribute: a.enum([
"STRIKE",
"SLASH",
"WISDOM",
"RANGED",
"SPECIAL",
]),
OnePieceRarity: a.enum(["C", "UC", "R", "SR", "SEC", "P", "L", "SP"]),
OnePieceItem: a
.model({
name: a.string().required(),
s3ImgKey: a.string().required(),
type: a.ref("OnePieceType").required(),
colors: a.ref("OnePieceColor").array().required(),
features: a.string().array().required(),
attributes: a.ref("OnePieceAttribute").array(),
rarity: a.ref("OnePieceRarity").required(),
cost: a.integer(),
power: a.integer(),
counter: a.integer(),
text: a.string(),
getInfo: a.string(),
colorKey: a.string(), // ソートキー用
featureKey: a.string(), // ソートキー用
attributeKey: a.string(), // ソートキー用
})
.secondaryIndexes((index) => [
index("getInfo").sortKeys(["colorKey", "type"]).queryField("listByGetInfo"),
])
.authorization(allow => [allow.owner().to(['create', 'read', 'update']), allow.authenticated().to(["read", "update", "create"])]),
})
.authorization(allow => [allow.resource(oripaPostConfirmation)]);
export type Schema = ClientSchema<typeof schema>;
export const data = defineData({
schema,
name: "OripaData",
authorizationModes: {
defaultAuthorizationMode: "userPool",
},
});
this is data resource.ts.
@rnrnstar2 can you check your tsconfig and confirm that you have strict mode enabled? If it's enabled and you are still experiencing this issue, please let us know.
created a repo with this issue - still a blocker for me
@waynet-ihm thank you! I was able to reproduce your error right away.
Although now I realize it's different from the one originally described here. Perhaps this deserves its own issue. If you create a new issue, I'll mark it a bug for the team to investigate further.
Hi @rnrnstar2 , just wanted to share an update on this: the team is aware of and working on a fix for these reference/type annotation errors
Hi @chrisbonifacio or @stocaaro any update on when this will be resolved? I am facing similar issue described here.
@neerajvisal - the issue should be resolved now. Please run npm update @aws-amplify/data-schema
to patch the relevant package.
@waynet-ihm - I was able to successfully run npm run build
in your repo after:
@aws-amplify/data-schema
to latestskipLibCheck: true
to the top-level tsconfig
in your repo.
Environment information
Description
I'm encountering a TypeScript type inference error when using AWS Amplify's data schema in a monorepo environment. The node_modules directory is present only at the root level of the monorepo.
Steps to Reproduce:
Expected Behavior: The type inference should correctly recognize the string type for the
name
property without any errors.Current Behavior: TypeScript throws an error, indicating that the string type is not assignable to the expected type, which includes various methods and properties.
Environment: Turborepo