-
Notifications
You must be signed in to change notification settings - Fork 407
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
TS attachment required fields #277
Open
MalkovVladimir opened this issue
Aug 12, 2021
· 3 comments
· May be fixed by #358 or grepdemos/airtable.js#6
Open
TS attachment required fields #277
MalkovVladimir opened this issue
Aug 12, 2021
· 3 comments
· May be fixed by #358 or grepdemos/airtable.js#6
Labels
Comments
Hey @MalkovVladimir, thank you for the suggestion. Our team will review and get back to you when we've decided how to move forward. |
It will be great to have this bug fixed. Until the bug is fixed, i managed this bug like this: //
const AiirtableClient = new Airtable({ apiKey: AIRTABLE_API_KEY });
const AirtableBase = AirtableClient.base(AIRTABLE_BASE_ID);
const TableBooks = AirtableBase(AIRTABLE_TABLE_ID_BOOKS);
const createNewRecord = () => {
return {
fields: {
pic: [{ url: 'http://my-fancy-image.com/imageeeeee.jpg' }],
title: "My Superb Book",
year: "2001",
}
};
/* ============================================== */
// before - this trigger TS error
/* ============================================== */
const newRecord = createNewRecord();
const createdRecords = await TableBooks.create([newRecord]); // TS-Error ...
const createdRecord = createdRecords[0]; // TS-Error ...
/* ============================================== */
// after - this illude TS and suppress error
/* ============================================== */
// TODO: there is a bug in the Airtable code, and an open issue
// https://github.com/Airtable/airtable.js/issues/277
// When the bug is resolved update the use of next line
const newRecord_tsErrorSolutionHack = createNewRecord() as unknown as { fields: Airtable.FieldSet };
const createdRecords = await TableBooks.create([newRecord_tsErrorSolutionHack]);
const createdRecord = createdRecords[0]; Happy coding. |
@albreyb still having this issue in 2023 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Airtable documentation:
Attachment interface:
filename
,size
,type
etc. not so optional.Please do props optional or split type for different actions (create/update/delete).
The text was updated successfully, but these errors were encountered: