-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
I am running into an issue that makes it hard to use nullable types. For instance, a table could have an auto-generated ID (UUID or sequential number) and I'd try to match that with a nullable property on an interface: id?: string.
TS error:
Property 'id' of type 'string | undefined' is not assignable to string index type 'RDSDataParameterValue'.
Code:
import { RDSDataParameters } from 'rds-data/lib/RDSData';
export interface Message extends RDSDataParameters {
id?: string; // error here
message: string;
}
const m: Message = { message: "hi" };
const { data } = await db.query(
`INSERT INTO messages(message)
VALUES(:message)
RETURNING *`,
m,
);What is the recommended approach here?
Metadata
Metadata
Assignees
Labels
No labels