Comments (7)
@BernardHymmen To generate types for v10 you need to add the --v10
or -X
option. That will create the new EntrySkeleton format and you’re good to go.
from cf-content-types-generator.
@BernardHymmen I've used uppercase X and everything works fine
from cf-content-types-generator.
Hi, we do need a bit more info to help you out.
- What were you trying to do when you got the error?
- What does your setup look like? Especially, which flags were you using for the type generator?
- What does
<Generated Type>
look like?
from cf-content-types-generator.
I just ran into the exact same issue. This is my first time trying to do type generation for Contentful objects so I was just gettting started and following the steps laid out in this very nice blog post
https://www.seancdavis.com/posts/generating-workable-typescript-types-from-contentful-content/
There's no date on that post (boo!), but it looks like the embedded video was uploaded in early May, FWIW. Anyway, don't recall making any changes to what the post describes, other than consolidating it all into a single npm script like so:
"contentful-export": "contentful space export --config contentful/export-config.json --management-token %CONTENTFUL_MANAGEMENT_PAT% --space-id %CONTENTFUL_SPACE_ID%",
"contentful-typegen": "cf-content-types-generator contentful/export.json --out types/contentful",
"contentful-update": "npm run contentful-export && npm run contentful-typegen"
Other than that, the post describes my setup and process accurately. I've got a pre-build.cmd
script that I run as part of my build to automatically update my Contentful models for both my C# and (hopefully soon) TypeScript types. Here's the command for the TypeScript part of it:
call npm run contentful-update
This process generates a JSON schema file that looks just fine to my casual eye, and the TypeScript type definitions all look fine too...except for the red squiggles in VSCode on the type parameter in every instance of Entry<T>
. Here's an example of one of my objects...
import type { Asset, Entry, EntryFields } from "contentful";
import type { TypePersonFields } from "./TypePerson";
export interface TypeBlogPostFields {
title: EntryFields.Symbol;
slug: EntryFields.Symbol;
heroImage?: Asset;
description: EntryFields.Text;
body?: EntryFields.Text;
author?: Entry<TypePersonFields>; // <== squiggles on TypePersonFields
publishDate: EntryFields.Date;
project?: Entry<Record<string, any>>[]; // <== squiggles on Record<string, any>
}
export type TypeBlogPost = Entry<TypeBlogPostFields>; // <== squiggles on TypeBlogPostFields
All the error messages are versions of
Type 'TypePersonFields' does not satisfy the constraint 'EntrySkeletonType'.
Type 'TypePersonFields' is missing the following properties from type 'EntrySkeletonType': fields, contentTypeId ts(2344)
Here are the various package versions I'm using:
dependencies
"contentful": "^10.2.3",
"contentful-cli": "^2.6.22",
devDependencies
"cf-content-types-generator": "^2.12.2",
"typescript": "^4.7.4"
from cf-content-types-generator.
@veu - Thanks for your help! Yes, adding the --v10 option did the trick for me. Yay!
I thought you might want to know that, curiously, the -x option threw an error for me. Here's what I got:
> cf-content-types-generator contentful/export.json -x --out types/contentful
» Error: Unexpected argument: -x
» See more help with --help
from cf-content-types-generator.
@SimonyanGrno - D'OH! All the other arguments are lowercase and I failed to notice that -X is, in fact, uppercase. <FacePalm/>
Yes, it worked just fine when I switched it to uppercase. Thanks for pointing this out!
from cf-content-types-generator.
This issue seems to be solved - will close for now
from cf-content-types-generator.
Related Issues (20)
- v10 typing includes EntryFieldTypes, but mismatches actual API response HOT 4
- Type error after Contentful `10.0.0-beta-v10.32` HOT 4
- oclif dependencies are deprecated HOT 2
- How to actually use fields? HOT 13
- Use with Contentful GraphQL endpoint? HOT 1
- 2.12.3 introduces bug HOT 2
- Property does not exist on type {} | {} HOT 2
- Include description and help text in JSDoc comments? HOT 5
- Support a config file
- Support custom prefixes of generics and interfaces HOT 2
- Command hangs after generating the export
- Generated TypeScript Models Lack File Extensions in Import Statements When Using Node 16 Module Resolution HOT 1
- Fields not typed correctly HOT 2
- Generated field interface does not satisfy the constraint 'EntrySkeletonType' HOT 5
- Generated types don't seem to match those expected by Contentful v10 HOT 2
- Support EU Data Center HOT 2
- Release a new version with updated contentful and allow minor version differences if possible HOT 1
- Type Not Satisfying Entry Requirements HOT 6
- Why can `EntryFieldTypes.Array<EntryFieldTypes.EntryLink<EntrySkeletonType>>` array include `undefined`? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cf-content-types-generator.