question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Documentation is not compatible with Typescript

See original GitHub issue

Expected Behavior

As a developer I expect the documentation to contain working snippets/guides.

Actual Behavior

Several guides and snippets are incompatible with the typings.

Possible Solution

One of the points listed could resolve this issue.

  • Documentation should reflect the actual API
  • Typescript should have a better documentation
  • Typings should handle required and optional properties correctly

Ugly workaround

The only way to use the API is to fool typescript via as.

space.createContentType({
    name: "Foo",
    fields: [],
} as Omit<ContentTypeProps, "sys">)

Steps to Reproduce

The example below is just one of several cases. In general it seems like several methods are not typed correctly, making this library incompatible with typescript environments.

  1. Go to https://www.contentful.com/developers/docs/references/content-management-api/#/reference/content-types/content-type-collection/create-a-content-type/console/js
  2. Go to: https://github.com/contentful/contentful-management.js/blob/c4a7e33eda7c2dea6fd3357420ec0be5652e9de8/lib/create-environment-api.ts#L272
  3. The examples or typings are wrong (See: code comments and contentful.com/docs)

displayType and description are required in ContentTypeProps since only sys is omitted via:

Omit<ContentTypeProps, "sys">

As mentioned there are likely several of these issues.

Context

The library is incompatible with typescript.

Environment

  • Language Version: v12.15.0
  • Package Manager Version: yarn 1.22.4
  • Browser Version:
  • Operating System: Darwin Kernel Version 19.4.0: Wed Mar 4 22:28:40 PST 2020; root:xnu-6153.101.6~15/RELEASE_X86_64 x86_64
  • Package Version: 5.27.1
  • Which API are you using?: Management

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
pixelasscommented, Jun 25, 2020

@suevalov you are right about ContentFields, I missed the extends Item, I still had an error in that section, will report back tomorrow.

0reactions
phoebeschmidtcommented, Jun 29, 2020

🎉 This issue has been resolved in version 5.27.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

Read more comments on GitHub >

github_iconTop Results From Across the Web

Documentation - Type Compatibility - TypeScript
Type compatibility in TypeScript is based on structural subtyping. ... When a type system has this property, it is said to not be...
Read more >
What do you not like about the TypeScript Website ... - GitHub
What do you not like about the TypeScript Website and Documentation? Hey folks, we, the TypeScript team at Microsoft, are planning a full ......
Read more >
Documenting Your TypeScript Projects: There Are Options
Documenting Your TypeScript Projects: There Are Options · Good code does not need documentation · TypeDoc: here to solve all your problems.
Read more >
Documentation lists the incorrect compatible version of ...
Open this URL TypeScript | SonarQube Docs run a Sonar sca… ... [ERROR] You are using version of TypeScript 3.1.6 which is not...
Read more >
TypeScript configuration - Angular
Many libraries —jQuery, Jasmine, and Lodash among them— do not include d.ts files in their npm packages. Fortunately, either their authors or community ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found