-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐛 Bug Report: Document autocompletion for Databases.createDocument broken #76
Comments
I'm not sure why the Personally, I want the type safety of Typescript, so I would prefer if the /* models.ts */
export type Document = {
$id: string;
$collectionId: string;
$databaseId: string;
$createdAt: string;
$updatedAt: string;
$permissions: string[];
};
export interface AnyDocument extends Document {
[key: string]: any;
}
/* databases.ts */
async createDocument<Document extends Models.Document = Models.AnyDocument>(
databaseId: string,
collectionId: string,
documentId: string,
data: Omit<Document, keyof Models.Document>,
permissions?: string[],
): Promise<Document> {
/* ... */
} That would probably solve this issue as well. |
Correct, this is to prevent errors when someone just calls
This is a great idea! We generate our SDKs using our sdk-generator and the template for the |
Opening this for contributors to see if they can update the SDK generator to add this behavior. |
👟 Reproduction steps
When using an IDE/editor supporting autocompletion with the Typescript Language Server, such as VS Code.
Calling
Databases.createDocument
with a type parameter:👍 Expected behavior
I should see the properties I defined in the
ProjectModel
interface when VS Code autocompletes the code inside the curly brackets.👎 Actual Behavior
VS Code shows identifiers from the function scope, but not the properties defined in the
ProjectModel
interface:Possible solution
I think this is caused by the
data
argument ofDatabases.createDocument
having the typeOmit<Document, keyof Models.Document>
.Since
Models.Document
contains a string index signature, the value ofkeyof Models.Document
is probablystring | number
. That would remove all properties from theDocument
type parameter, basically turning it into an empty object type ({}
).🎲 Appwrite version
Different version (specify in environment)
💻 Operating system
MacOS
🧱 Your Environment
Appwrite Cloud
Appwrite web SDK version:
VS Code version information:
MacOS version:
👀 Have you spent some time to check if this issue has been raised before?
🏢 Have you read the Code of Conduct?
The text was updated successfully, but these errors were encountered: