-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unhandled Rejection - Server doesn't start #142
Comments
Hi! I think it's not related to nuxt-typed-router. Have you tried removing some other modules? |
Is this #135? |
Had the same error. |
Thanks for the report, the error is only when there i a single |
Yes, at least that is what i experienced. |
Ran into this issue in another project. Tried debugging it a bit. The raw text prettier is trying to format \n \n // @ts-nocheck\n // eslint-disable\n // ---------------------------------------------------\n // 🚗🚦 Generated by nuxt-typed-router. Do not modify !\n // ---------------------------------------------------\n \n \n \n\n\n \n \n export type RoutePathSchema = \n "/"|"/dashboard"|"/de/dashboard"|"/de"|"/de/test"|"/en/dashboard"|"/en"|"/en/test"|"/test"\n ;\n\n export type LocaleRoutePathSchema = \n any\n \n\n type ValidStringPath<T> = T extends ${string} ${string} ? false : T extends \'\' ? false : true;\n\n type ValidParam<T, R extends boolean = true> = T extends ${infer A}/${infer B}\n ? A extends ${string} ${string}\n ? false\n : A extends ?${string}\n ? false\n : A extends ${string} ${string}\n ? false\n : A extends \'\'\n ? B extends \'\'\n ? true\n
: false\n : B extends ?${string}\n ? false\n : B extends #${string}\n ? true\n : B extends \'\'\n ? true\n : false\n : R extends true\n ? T extends \'\'\n ? false\n : ValidParam<T, false>\n : T
extends ?${string}\n ? false\n : T extends ${string} ${string}\n ? false\n : true;\n\n type ValidEndOfPath<T> = T extends /\n ? true\n : T extends \'\'\n ? true\n : T extends ${string} ${string}\n ? false \n
: T extends ?${string}\n ? true\n : T extends #${string}\n ? true\n : false;\n\n \n type ValidateDashboard<T> = T extends /dashboard${infer TDashboard}\n ? ValidEndOfPath<TDashboard> extends false ? "End of path \'/dashboard\' is invalid" : true : false ;\n\ntype ValidateDeDashboard<T> = T extends /de/dashboard${infer TDashboard}\n ? ValidEndOfPath<TDashboard> extends false ? "End of path \'/de/dashboard\' is invalid" : true :
false ;\n\ntype ValidateDe<T> = T extends /de${infer TDe}\n ? ValidEndOfPath<TDe> extends false ? "End of path \'/de\' is invalid" : true : false ;\n\ntype ValidateDeTest<T> = T extends /de/test${infer TTest}\n ? ValidEndOfPath<TTest> extends false ? "End of path \'/de/test\' is invalid" : true :
false ;\n\ntype ValidateEnDashboard<T> = T extends /en/dashboard${infer TDashboard}\n ? ValidEndOfPath<TDashboard> extends false ? "End of path \'/en/dashboard\' is invalid" : true : false ;\n\ntype ValidateEn<T> = T extends
/en${infer TEn}\n ? ValidEndOfPath<TEn> extends false ? "End of path \'/en\' is invalid" : true : false ;\n\ntype ValidateEnTest<T> = T extends /en/test${infer TTest}\n ? ValidEndOfPath<TTest> extends false ? "End of path
\'/en/test\' is invalid" : true : false ;\n\ntype ValidateTest<T> = T extends /test${infer TTest}\n ? ValidEndOfPath<TTest> extends false ? "End of path \'/test\' is invalid" : true : false ;\n\n export type ValidatePath<T extends string> = T extends string \n ? T extends \'/\' \n ? T
\n :ValidateDashboard<T> extends true ? T: ValidateDeDashboard<T> extends true ? T: ValidateDe<T> extends true ? T: ValidateDeTest<T> extends true ? T: ValidateEnDashboard<T> extends true ? T: ValidateEn<T> extends true
? T: ValidateEnTest<T> extends true ? T: ValidateTest<T> extends true ? T \n : string extends T\n ? T\n : Error: ${ValidateDashboard<T>|ValidateDeDashboard<T>|ValidateDe<T>|ValidateDeTest<T>|ValidateEnDashboard<T>|ValidateEn<T>|ValidateEnTest<T>|ValidateTest<T>}\n : never;\n \n // RouteNameFromPath, RouteNameFromLocalePath\n export type RouteNameFromPath<T extends string> = T extends string \n ? T extends \'/\' \n
? "index"\n : any : never \n : never; \n \n \n \n
\n\n export type ValidateLocalePath<T extends string> = T extends string \n ? T extends \'/\' \n ? T \n \n : string extends T\n ? T\n : never\n : never;\n \n // RouteNameFromPath, RouteNameFromLocalePath\n export type RouteNameFromLocalePath<T extends
string> = T extends string \n ? T extends \'/\' \n ? "index"\n
: never \n : never; \n \n \n\n\n export type TypedPathParameter<T extends string> = ValidatePath<T> | RoutePathSchema;\n export type TypedLocalePathParameter<T extends string> = ValidateLocalePath<T> | LocaleRoutePathSchema;\n\n \n Did wonder if the \ Tried adding some try catch statements in my node modules.
Which does make sense, if prettier is failing and returning undefined. But the error being thrown is referring to RouteNameFromLocalePath. Found this bit 34f1442#diff-8d6881a5d61ba44d753b4583902935a332c085f5b9967aac88ee229853cc67b4L78-R80 It is weird, since i got two projects, one it is working, the other is not. |
This comment is just the steps i took to fix this issue - Might be very unreadable. Tried cloning and replicating the problem in playground. Tried digging into the code. export async function formatOutputWithPrettier(template: string): Promise<string> {
let prettierFoundOptions = await prettier.resolveConfig(process.cwd());
if (!prettierFoundOptions) {
prettierFoundOptions = defaultPrettierOptions;
}
// const formatedTemplate = template;
let formatedTemplate
try {
formatedTemplate = await prettier.format(template, {
...prettierFoundOptions,
parser: 'typescript',
});
} catch (e) {
}
if (!formatedTemplate) {
return template;
}
return formatedTemplate;
} So it will return the unformatted code if it cant format. The specific part is generated at routes-paths.block.ts:L73-80 ${JSON.stringify({ routesList, pathConditions, length: pathConditions.filter((f) => routesList.includes(f.routeName)).length })} Which resulted in {
"routesList": ["index"],
"pathConditions": [
{
"typeName": "ValidateEn",
"condition": "type ValidateEn<T> = T extends `/en${infer TEn}`\n ? ValidEndOfPath<TEn> extends false ? \"End of path '/en' is invalid\" : true : false ;",
"routeName": "index___en",
"isLocale": true
},
{
"typeName": "ValidateZh",
"condition": "type ValidateZh<T> = T extends `/zh${infer TZh}`\n ? ValidEndOfPath<TZh> extends false ? \"End of path '/zh' is invalid\" : true : false ;",
"routeName": "index___zh",
"isLocale": true
}
],
"length": 0
} The routesList does not contain the i18n route names. Meaning it go to the "any" value. Which causing the entire filter thing to return As i am looking at the code, im questioning if the I tried moving it to add onto .join ${pathConditions.length
? `: ${pathConditions.filter((f) => routesList.includes(f.routeName)).length
? pathConditions
.filter((f) => routesList.includes(f.routeName))
.map((t) => `${t.typeName}<T> extends true ? "${t.routeName}"`)
.join(': ') + ": never"
: 'any'
}`
: ': never'
} And it would now generate fine with and without i18n enabled. Then i tried to go back to the old pages folder i renamed to pages_old which also generated just fine.. So thats working. And should logically be working as intended now. |
.............. |
@PerryProjects Its still open #148 Nuxt have experimental support for typed pages now - https://nuxt.com/docs/api/nuxt-config#typedpages |
Describe the bug
Just when I install the package and I added it to the nuxt config and try to start the server, it gives me an error message
about an unhandled rejection
Expected behavior
That the server start without any errors
Screenshots
Environnement infos
Your
pages
folder structurepages
├── index.vue
└── team
└── [name].vue
Your nuxt.config.ts
nuxt.config.ts
i18n.config.ts
The text was updated successfully, but these errors were encountered: