From b359ff0eff5dfd33164d3ec8cfb1b462258f60e4 Mon Sep 17 00:00:00 2001 From: Thomas Krampl Date: Thu, 15 Dec 2022 22:31:06 +0100 Subject: [PATCH] Fix generated types referencing onError, afterLoad and beforeLoad (#768) * Fix generated types referencing onError, afterLoad and beforeLoad * Use consts for function names --- .changeset/new-plums-sing.md | 5 +++++ .../src/plugin/codegen/routes/index.ts | 6 +++--- .../src/plugin/codegen/routes/kit.test.ts | 12 ++++++------ 3 files changed, 14 insertions(+), 9 deletions(-) create mode 100644 .changeset/new-plums-sing.md diff --git a/.changeset/new-plums-sing.md b/.changeset/new-plums-sing.md new file mode 100644 index 0000000000..4c7991f680 --- /dev/null +++ b/.changeset/new-plums-sing.md @@ -0,0 +1,5 @@ +--- +'houdini-svelte': patch +--- + +Fix generated types referencing onError, afterLoad and beforeLoad diff --git a/packages/houdini-svelte/src/plugin/codegen/routes/index.ts b/packages/houdini-svelte/src/plugin/codegen/routes/index.ts index 0e6dfcd9fb..df2838cfed 100644 --- a/packages/houdini-svelte/src/plugin/codegen/routes/index.ts +++ b/packages/houdini-svelte/src/plugin/codegen/routes/index.ts @@ -297,7 +297,7 @@ function append_afterLoad( ) { return afterLoad ? ` -type AfterLoadReturn = Awaited>; +type AfterLoadReturn = Awaited>; type AfterLoadData = { ${internal_append_afterLoad(queries)} }; @@ -326,7 +326,7 @@ function append_beforeLoad(beforeLoad: boolean, type: 'Layout' | 'Page') { return beforeLoad ? ` export type BeforeLoadEvent = ${type}LoadEvent; -type BeforeLoadReturn = Awaited>; +type BeforeLoadReturn = Awaited>; ` : '' } @@ -334,7 +334,7 @@ type BeforeLoadReturn = Awaited>; +type OnErrorReturn = Awaited>; export type OnErrorEvent = { event: Kit.LoadEvent, input: ${ hasLoadInput ? 'LoadInput' : '{}' }, error: Error | Error[] }; diff --git a/packages/houdini-svelte/src/plugin/codegen/routes/kit.test.ts b/packages/houdini-svelte/src/plugin/codegen/routes/kit.test.ts index cdb8395046..02fedbea15 100644 --- a/packages/houdini-svelte/src/plugin/codegen/routes/kit.test.ts +++ b/packages/houdini-svelte/src/plugin/codegen/routes/kit.test.ts @@ -461,7 +461,7 @@ test('generates types for layout onError', async function () { MyPageLoad1Query: MyPageLoad1Query$input; }; - type OnErrorReturn = Awaited>; + type OnErrorReturn = Awaited>; export type OnErrorEvent = { event: Kit.LoadEvent; @@ -574,7 +574,7 @@ test('generates types for page onError', async function () { MyPageLoad1Query: MyPageLoad1Query$input; }; - type OnErrorReturn = Awaited>; + type OnErrorReturn = Awaited>; export type OnErrorEvent = { event: Kit.LoadEvent; @@ -688,7 +688,7 @@ test('generates types for layout beforeLoad', async function () { }; export type BeforeLoadEvent = LayoutLoadEvent; - type BeforeLoadReturn = Awaited>; + type BeforeLoadReturn = Awaited>; export type MyPageLoad1QueryVariables = VariableFunction; `) }) @@ -795,7 +795,7 @@ test('generates types for page beforeLoad', async function () { }; export type BeforeLoadEvent = PageLoadEvent; - type BeforeLoadReturn = Awaited>; + type BeforeLoadReturn = Awaited>; export type MyPageLoad1QueryVariables = VariableFunction; `) }) @@ -901,7 +901,7 @@ test('generates types for layout afterLoad', async function () { MyPageLoad1Query: MyPageLoad1Query$input; }; - type AfterLoadReturn = Awaited>; + type AfterLoadReturn = Awaited>; type AfterLoadData = { MyPageLoad1Query: MyPageLoad1Query$result; @@ -1019,7 +1019,7 @@ test('generates types for page afterLoad', async function () { MyPageLoad1Query: MyPageLoad1Query$input; }; - type AfterLoadReturn = Awaited>; + type AfterLoadReturn = Awaited>; type AfterLoadData = { MyPageLoad1Query: MyPageLoad1Query$result;