-
Notifications
You must be signed in to change notification settings - Fork 201
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
Types issue #2017
Comments
Hi @damian-turek 👋 |
I'm getting the same issue: import { contentfulClient } from '@/contentful/api/contentfulClient'
import { TypeProjectSkeleton } from '@/contentful/types'
export const getAllProjects = async (locale: string) => {
const response =
await contentfulClient.withoutUnresolvableLinks.getEntries<TypeProjectSkeleton>(
{
content_type: 'project',
locale,
order: '-fields.startYear', // TS2322: Type string is not assignable to type (OrderFilterPaths<EntrySys, 'sys'> | 'sys.contentType.sys.id' | '-sys.contentType.sys.id')[]
},
)
return response.items
} My types: import type { ChainModifiers, Entry, EntryFieldTypes, EntrySkeletonType, LocaleCode } from "contentful";
export interface TypeProjectFields {
title: EntryFieldTypes.Symbol;
shortTitle?: EntryFieldTypes.Symbol;
subtitle?: EntryFieldTypes.Symbol;
slug: EntryFieldTypes.Symbol;
body: EntryFieldTypes.RichText;
startYear?: EntryFieldTypes.Integer;
endYear?: EntryFieldTypes.Integer;
images?: EntryFieldTypes.Array<EntryFieldTypes.AssetLink>;
}
export type TypeProjectSkeleton = EntrySkeletonType<TypeProjectFields, "project">;
export type TypeProject<Modifiers extends ChainModifiers, Locales extends LocaleCode> = Entry<TypeProjectSkeleton, Modifiers, Locales>; I'm generating the types with |
I just ran into this myself and I think the solution is to use an array instead e.g.
Seems to work perfectly for me |
If that is the way to do it, then the docs should be updated. They don't mention the need for array brackets: https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters/order/query-entries/console/js |
Concur with the above - the only place where I've seen the need for an array mentioned is on the TypeScript-specific docs page: https://github.com/contentful/contentful.js/blob/master/TYPESCRIPT.md#breaking-change
|
Hi, I have a problem adding types when I fetch photos from contentful. In the src section I type "https:'+e.fields.portrait.fields.file?.url", but it shows me an error in "fields" that reads: Property fields does not exist on type never.
The second problem is with the order setting. While querying "content type" and "order" in the order section an error pops up for me: (OrderFilterPaths<EntrySys, 'sys'> | 'sys.contentType.sys.id' | '-sys.contentType.sys.id')[]
I can't solve these problems. Could someone help me with this?
Translated with www.DeepL.com/Translator (free version)
The text was updated successfully, but these errors were encountered: