Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/renderers/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import renderAllLocales from "./contentful/renderAllLocales"
import renderDefaultLocale from "./contentful/renderDefaultLocale"
import renderNamespace from "./contentful/renderNamespace"
import renderLocalizedTypes from "./contentful/renderLocalizedTypes"
import renderContentTypeId from "./contentful/renderContentTypeId"

interface Options {
localization?: boolean
Expand All @@ -26,6 +27,7 @@ export default async function render(
const typingsSource = [
renderAllContentTypes(sortedContentTypes, localization),
renderAllContentTypeIds(sortedContentTypes),
renderEntryType(sortedContentTypes),
renderAllLocales(sortedLocales),
renderDefaultLocale(sortedLocales),
renderLocalizedTypes(localization),
Expand All @@ -50,3 +52,10 @@ function renderAllContentTypeIds(contentTypes: ContentType[]): string {
contentTypes.map(contentType => `'${contentType.sys.id}'`),
)
}

function renderEntryType(contentTypes: ContentType[]) {
return renderUnion(
"IEntry",
contentTypes.map(contentType => renderContentTypeId(contentType.sys.id)),
)
}
6 changes: 6 additions & 0 deletions test/renderers/render.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ describe("render()", () => {

export type CONTENT_TYPE = \\"myContentType\\"

export type IEntry = IMyContentType

export type LOCALE_CODE = \\"en-US\\" | \\"pt-BR\\"

export type CONTENTFUL_DEFAULT_LOCALE_CODE = \\"en-US\\"
Expand Down Expand Up @@ -152,6 +154,8 @@ describe("render()", () => {

export type CONTENT_TYPE = \\"myContentType\\"

export type IEntry = IMyContentType

export type LOCALE_CODE = \\"en-US\\" | \\"pt-BR\\"

export type CONTENTFUL_DEFAULT_LOCALE_CODE = \\"en-US\\"
Expand Down Expand Up @@ -215,6 +219,8 @@ describe("render()", () => {

export type CONTENT_TYPE = \\"myContentType\\"

export type IEntry = IMyContentType

export type LOCALE_CODE = \\"en-US\\" | \\"pt-BR\\"

export type CONTENTFUL_DEFAULT_LOCALE_CODE = \\"en-US\\"
Expand Down