Skip to content

Commit

Permalink
fix: export unions (#21)
Browse files Browse the repository at this point in the history
* [fix] export unions

Unions should be exported along with interfaces

* test(render): fix tests

* test(render): fix tests

* fix(render): fix renderDefaultLocale

* ci rebuild

Co-authored-by: Steven Petryk <petryk.steven@gmail.com>
  • Loading branch information
zernie and stevenpetryk authored Mar 31, 2020
1 parent 774b88d commit 2359ab8
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/renderers/contentful/renderDefaultLocale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ export default function renderDefaultLocale(locales: Locale[]): string {
throw new Error("Could not find a default locale in Contentful.")
}

return `type CONTENTFUL_DEFAULT_LOCALE_CODE = '${defaultLocale.code}';`
return `export type CONTENTFUL_DEFAULT_LOCALE_CODE = '${defaultLocale.code}';`
}
2 changes: 1 addition & 1 deletion src/renderers/typescript/renderUnion.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default function renderUnion(name: string, values: string[]): string {
return `
type ${name} = ${renderUnionValues(values)};
export type ${name} = ${renderUnionValues(values)};
`
}

Expand Down
2 changes: 1 addition & 1 deletion test/renderers/contentful/renderAllLocales.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe("renderSymbol()", () => {

it("works with a list of locales", () => {
expect(format(renderAllLocales(locales))).toMatchInlineSnapshot(
`"type LOCALE_CODE = \\"en-US\\" | \\"pt-BR\\";"`,
`"export type LOCALE_CODE = \\"en-US\\" | \\"pt-BR\\";"`,
)
})
})
2 changes: 1 addition & 1 deletion test/renderers/contentful/renderDefaultLocale.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe("renderSymbol()", () => {

it("works with a list of locales", () => {
expect(format(renderDefaultLocale(locales))).toMatchInlineSnapshot(
`"type CONTENTFUL_DEFAULT_LOCALE_CODE = \\"en-US\\";"`,
`"export type CONTENTFUL_DEFAULT_LOCALE_CODE = \\"en-US\\";"`,
)
})

Expand Down
6 changes: 3 additions & 3 deletions test/renderers/render.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ describe("render()", () => {
}
}
type CONTENT_TYPE = \\"myContentType\\"
export type CONTENT_TYPE = \\"myContentType\\"
type LOCALE_CODE = \\"en-US\\" | \\"pt-BR\\"
export type LOCALE_CODE = \\"en-US\\" | \\"pt-BR\\"
type CONTENTFUL_DEFAULT_LOCALE_CODE = \\"en-US\\"
export type CONTENTFUL_DEFAULT_LOCALE_CODE = \\"en-US\\"
"
`)
})
Expand Down
2 changes: 1 addition & 1 deletion test/renderers/typescript/renderUnion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import format from "../../support/format"
describe("renderUnion()", () => {
it("renders a union", () => {
expect(format(renderUnion("name", ["1", "2", "3"]))).toMatchInlineSnapshot(
`"type name = 1 | 2 | 3;"`,
`"export type name = 1 | 2 | 3;"`,
)
})
})
Expand Down

0 comments on commit 2359ab8

Please sign in to comment.