Skip to content

Commit 2359ab8

Browse files
zerniestevenpetryk
andauthored
fix: export unions (#21)
* [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 <[email protected]>
1 parent 774b88d commit 2359ab8

File tree

6 files changed

+8
-8
lines changed

6 files changed

+8
-8
lines changed

Diff for: src/renderers/contentful/renderDefaultLocale.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ export default function renderDefaultLocale(locales: Locale[]): string {
77
throw new Error("Could not find a default locale in Contentful.")
88
}
99

10-
return `type CONTENTFUL_DEFAULT_LOCALE_CODE = '${defaultLocale.code}';`
10+
return `export type CONTENTFUL_DEFAULT_LOCALE_CODE = '${defaultLocale.code}';`
1111
}

Diff for: src/renderers/typescript/renderUnion.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export default function renderUnion(name: string, values: string[]): string {
22
return `
3-
type ${name} = ${renderUnionValues(values)};
3+
export type ${name} = ${renderUnionValues(values)};
44
`
55
}
66

Diff for: test/renderers/contentful/renderAllLocales.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe("renderSymbol()", () => {
2222

2323
it("works with a list of locales", () => {
2424
expect(format(renderAllLocales(locales))).toMatchInlineSnapshot(
25-
`"type LOCALE_CODE = \\"en-US\\" | \\"pt-BR\\";"`,
25+
`"export type LOCALE_CODE = \\"en-US\\" | \\"pt-BR\\";"`,
2626
)
2727
})
2828
})

Diff for: test/renderers/contentful/renderDefaultLocale.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe("renderSymbol()", () => {
2222

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

Diff for: test/renderers/render.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ describe("render()", () => {
8080
}
8181
}
8282
83-
type CONTENT_TYPE = \\"myContentType\\"
83+
export type CONTENT_TYPE = \\"myContentType\\"
8484
85-
type LOCALE_CODE = \\"en-US\\" | \\"pt-BR\\"
85+
export type LOCALE_CODE = \\"en-US\\" | \\"pt-BR\\"
8686
87-
type CONTENTFUL_DEFAULT_LOCALE_CODE = \\"en-US\\"
87+
export type CONTENTFUL_DEFAULT_LOCALE_CODE = \\"en-US\\"
8888
"
8989
`)
9090
})

Diff for: test/renderers/typescript/renderUnion.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import format from "../../support/format"
44
describe("renderUnion()", () => {
55
it("renders a union", () => {
66
expect(format(renderUnion("name", ["1", "2", "3"]))).toMatchInlineSnapshot(
7-
`"type name = 1 | 2 | 3;"`,
7+
`"export type name = 1 | 2 | 3;"`,
88
)
99
})
1010
})

0 commit comments

Comments
 (0)