contentful.js
contentful.js copied to clipboard
Type for Sys missing archived Entry fields
Expected Behavior
Referencing fields for archived entries shouldn't result in a TypeScript compilation error
Actual Behavior
Archived entry fields are missing from type declaration, so TS errors abound when dealing w/ these fields
Possible Solution
Add archived entry fields to Sys
type definition
Steps to Reproduce
const entry: Entry<any> = req.body
const isArchived = entry.sys.archivedVersion
Context
I'm trying to consume entry events from a webhook that I've created and when trying to handle events for archived entries, I'm seeing TS errors due to none of the archived fields being present on the TS type definition here: https://github.com/contentful/contentful.js/blob/master/index.d.ts#L152-L168
Environment
-
Language Version:
v14.18.1
-
Package Manager Version:
6.14.15
-
Operating System:
Darwin Kernel Version 21.3.0: Wed Jan 5 21:37:58 PST 2022; root:xnu-8019.80.24~20/RELEASE_X86_64 x86_64
-
Package Version:
[email protected]
- Which API are you using?: Webhook request for entries
I've been able to overcome this limitation for the time being with the following work-around:
interface AugmentedContenfulSys extends Sys {
archivedVersion: number
}
interface AugmentedContenfulEntry extends Entry<any> {
sys: AugmentedContenfulSys
}
Hello,
could you maybe have a look if the same error happens with the new TypeScript version of contentful.js?
You can install it via npm i contentful@beta-v10
You can find more info and specific docs here: https://github.com/contentful/contentful.js/tree/beta-v10
Hey @RavenHursT 👋 , We expected this to be solved with the latest major release (which was a complete re-write). Please feel free to re-open again if the error still occurs.