Closed gpitot closed 1 year ago
Yeah this is a problem with type narrowing - if they keys are literal strings then typescript doesn't properly narrow the type.
You can workaround it by putting the "a" string as a variable and then splicing it in.
const a = "a" as string;
const res = await docClient.send(
new MyGetItemCommand({
TableName: "a",
Key: {
pk: "USERS#${a}",
sk: "USERS#b",
},
})
);
You may also be able to splice like this:
`USERS#${"a" as string}`
Not much we can do here without improvements from typescript.
In the general case where the key is constructed from an input argument, it should work.
This issue is now marked as stale because it hasn't seen activity for a while. Add a comment or it will be closed soon. If you wish to exclude this issue from being marked as stale, add the "backlog" label.
Bumping to remain open
This issue is now marked as stale because it hasn't seen activity for a while. Add a comment or it will be closed soon. If you wish to exclude this issue from being marked as stale, add the "backlog" label.
res.Item is undefined and I cannot access my expected properties on it, how can I access pk/sk/firstname here?