-
8000 li> -
Notifications
You must be signed in to change notification settings - Fork 36
run check
command on all-addon
test
#344
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
Comments
Adding |
Ok, still think this would be a reasonable enhancement |
Would you want it to run 'tsc' before the alladdons test kicks off proper since it is a long running test? |
I don't understand how running the typescript compiler is related to this, can you explain? Edit: Do you potentially want to build the types of the "all-addon" test with that command? That should in theory already be handled by the |
I was down the wrong rabbit hole. Thought this was to do with type mismatching. With type mismatch in #341 I thought short circuiting with tsc was the aim before bogging down in e2e tests. |
Is it the script 'check' inside the test output that needs to be run? |
Yeah, that's what I was thinking about. But I remember this logged a bunch an of errors in the past, but it might be better now that #380. But I'm not convinced this is currently feasibly, as it might require us to go down the |
I ran it manually from a test out put for all addons. No errors or warnings. > kit-ts@0.0.1 check .../cli/.test-output/addons/all-addons/-754882197_1
> svelte-kit sync && svelte-check --tsconfig ./tsconfig.json
====================================
Loading svelte-check in workspace: .../cli/.test-output/addons/all-addons/-754882197_1
Getting Svelte diagnostics...
====================================
svelte-check found 0 errors and 0 warnings
|
That's perfect, apparently I misremember. Then we should probably only change that test to execute the |
Sounds good I'll have a look in my next session |
19 Errors occur on check within the JS test output. TS test output passes check. This means this check cmd doesn't work out of the box for users using JS instead of TS. Do these need fixing and this check to pass on js? if so how do you want to go about it, as in issue per one, checklist etc? Initial thoughts would be to add jsdoc or update the jsconfig.json, am open to ideas if there is a better way forward here? ====================================
Loading svelte-check in workspace: /home/brett/7_open_source/cli/.test-output/addons/all-addons/-754882197_0
Getting Svelte diagnostics...
.../cli/.test-output/addons/all-addons/-754882197_0/src/routes/demo/lucia/+page.server.js:5:20
Error: Property 'user' does not exist on type 'Locals'.
export const load = async (event) => {
if (!event.locals.user) {
return redirect(302, '/demo/lucia/login');
.../cli/.test-output/addons/all-addons/-754882197_0/src/routes/demo/lucia/+page.server.js:8:30
Error: Property 'user' does not exist on type 'Locals'.
}
return { user: event.locals.user };
};
.../cli/.test-output/addons/all-addons/-754882197_0/src/routes/demo/lucia/+page.server.js:13:21
Error: Property 'session' does not exist on type 'Locals'.
logout: async (event) => {
if (!event.locals.session) {
return fail(401);
.../cli/.test-output/addons/all-addons/-754882197_0/src/routes/demo/lucia/+page.server.js:16:45
Error: Property 'session' does not exist on type 'Locals'.
}
await auth.invalidateSession(event.locals.session.id);
auth.deleteSessionTokenCookie(event);
.../cli/.test-output/addons/all-addons/-754882197_0/src/routes/demo/lucia/login/+page.server.js:10:19
Error: Property 'user' does not exist on type 'Locals'.
export const load = async (event) => {
if (event.locals.user) {
return redirect(302, '/demo/lucia');
.../cli/.test-output/addons/all-addons/-754882197_0/src/routes/demo/lucia/login/+page.server.js:32:11
Error: No overload matches this call.
Overload 1 of 3, '(left: SQLiteColumn<{ name: "username"; tableName: "user"; dataType: "string"; columnType: "SQLiteText"; data: string; driverParam: string; notNull: true; hasDefault: false; isPrimaryKey: false; isAutoincrement: false; ... 4 more ...; generated: undefined; }, {}, { ...; }>, right: string | SQLWrapper): SQL<...>', gave the following error.
Argument of type 'FormDataEntryValue | null' is not assignable to parameter of type 'string | SQLWrapper'.
Type 'null' is not assignable to type 'string | SQLWrapper'.
Overload 2 of 3, '(left: Aliased<string | File | null>, right: string | SQLWrapper | File | null): SQL<unknown>', gave the following error.
Argument of type 'SQLiteColumn<{ name: "username"; tableName: "user"; dataType: "string"; columnType: "SQLiteText"; data: string; driverParam: string; notNull: true; hasDefault: false; isPrimaryKey: false; isAutoincrement: false; ... 4 more ...; generated: undefined; }, {}, { ...; }>' is not assignable to parameter of type 'Aliased<string | File | null>'.
Type 'SQLiteColumn<{ name: "username"; tableName: "user"; dataType: "string"; columnType: "SQLiteText"; data: string; driverParam: string; notNull: true; hasDefault: false; isPrimaryKey: false; isAutoincrement: false; ... 4 more ...; generated: undefined; }, {}, { ...; }>' is missing the following properties from type 'Aliased<string | File | null>': sql, fieldAlias
Overload 3 of 3, '(left: never, right: unknown): SQL<unknown>', gave the following error.
Argument of type 'SQLiteColumn<{ name: "username"; tableName: "user"; dataType: "string"; columnType: "SQLiteText"; data: string; driverParam: string; notNull: true; hasDefault: false; isPrimaryKey: false; isAutoincrement: false; ... 4 more ...; generated: undefined; }, {}, { ...; }>' is not assignable to parameter of type 'never'.
.from(table.user)
.where(eq(table.user.username, username));
.../cli/.test-output/addons/all-addons/-754882197_0/src/routes/demo/lucia/login/+page.server.js:39:65
Error: Argument of type 'FormDataEntryValue | null' is not assignable to parameter of type 'string | Uint8Array<ArrayBufferLike>'.
Type 'null' is not assignable to type 'string | Uint8Array<ArrayBufferLike>'.
const validPassword = await verify(existingUser.passwordHash, password, {
memoryCost: 19456,
.../cli/.test-output/addons/all-addons/-754882197_0/src/routes/demo/lucia/login/+page.server.js:68:35
Error: Argument of type 'FormDataEntryValue | null' is not assignable to parameter of type 'string | Uint8Array<ArrayBufferLike>'.
Type 'null' is not assignable to type 'string | Uint8Array<ArrayBufferLike>'.
const userId = generateUserId();
const passwordHash = await hash(password, {
// recommended minimum parameters
.../cli/.test-output/addons/all-addons/-754882197_0/src/routes/demo/lucia/login/+page.server.js:77:32
Error: No overload matches this call.
Overload 1 of 2, '(value: { id: string | SQL<unknown> | Placeholder<string, any>; username: string | SQL<unknown> | Placeholder<string, any>; passwordHash: string | SQL<unknown> | Placeholder<...>; age?: number | ... 3 more ... | undefined; }): SQLiteInsertBase<...>', gave the following error.
Type 'FormDataEntryValue | null' is not assignable to type 'string | SQL<unknown> | Placeholder<string, any>'.
Type 'null' is not assignable to type 'string | SQL<unknown> | Placeholder<string, any>'.
Overload 2 of 2, '(values: { id: string | SQL<unknown> | Placeholder<string, any>; username: string | SQL<unknown> | Placeholder<string, any>; passwordHash: string | SQL<unknown> | Placeholder<...>; age?: number | ... 3 more ... | undefined; }[]): SQLiteInsertBase<...>', gave the following error.
Object literal may only specify known properties, and 'id' does not exist in type '{ id: string | SQL<unknown> | Placeholder<string, any>; username: string | SQL<unknown> | Placeholder<string, any>; passwordHash: string | SQL<unknown> | Placeholder<...>; age?: number | ... 3 more ... | undefined; }[]'.
try {
await db.insert(table.user).values({ id: userId, username, passwordHash });
.../cli/.test-output/addons/all-addons/-754882197_0/src/routes/demo/lucia/login/+page.server.js:96:27
Error: Parameter 'username' implicitly has an 'any' type.
function validateUsername(username) {
return (
.../cli/.test-output/addons/all-addons/-754882197_0/src/routes/demo/lucia/login/+page.server.js:105:27
Error: Parameter 'password' implicitly has an 'any' type.
function validatePassword(password) {
return (
.../cli/.test-output/addons/all-addons/-754882197_0/src/hooks.server.js:5:28
Error: Binding element 'event' implicitly has an 'any' type.
const handleParaglide = ({ event, resolve }) => paraglideMiddleware(event.request, ({ request, locale }) => {
event.request = request;
.../cli/.test-output/addons/all-addons/-754882197_0/src/hooks.server.js:5:35
Error: Binding element 'resolve' implicitly has an 'any' type.
const handleParaglide = ({ event, resolve }) => paraglideMiddleware(event.request, ({ request, locale }) => {
event.request = request;
.../cli/.test-output/addons/all-addons/-754882197_0/src/hooks.server.js:9:26
Error: Binding element 'html' implicitly has an 'any' type.
return resolve(event, {
transformPageChunk: ({ html }) => html.replace('%paraglide.lang%', locale)
});
.../cli/.test-output/addons/all-addons/-754882197_0/src/hooks.server.js:13:29
Error: Binding element 'event' implicitly has an 'any' type.
const handleAuth = async ({ event, resolve }) => {
const sessionToken = event.cookies.get(auth.sessionCookieName);
.../cli/.test-output/addons/all-addons/-754882197_0/src/hooks.server.js:13:36
Error: Binding element 'resolve' implicitly has an 'any' type.
const handleAuth = async ({ event, resolve }) => {
const sessionToken = event.cookies.get(auth.sessionCookieName);
.../cli/.test-output/addons/all-addons/-754882197_0/src/stories/Page.svelte:10:6
Error: Type 'null' is not assignable to type '{ name: string; } | undefined'. (js)
<Header
{user}
onLogin={() => (user = { name: 'Jane Doe' })}
.../cli/.test-output/addons/all-addons/-754882197_0/src/stories/Page.svelte:11:21
Error: Type '{ name: string; }' is not assignable to type 'null'. (js)
{user}
onLogin={() => (user = { name: 'Jane Doe' })}
onLogout={() => (user = null)}
.../cli/.test-output/addons/all-addons/-754882197_0/src/stories/Page.svelte:13:29
Error: Type '{ name: string; }' is not assignable to type 'null'. (js)
onLogout={() => (user = null)}
onCreateAccount={() => (user = { name: 'Jane Doe' })}
/> |
The story book errors are solved by aligning the story book templates upstream. See storybookjs/storybook#31450 |
Jsdoc solves the rest with type comments in: and will need to extend the type of locals in app.d.ts for lucia after adding jsdoc comments for the js version. if (typescript) {
sv.file('src/app.d.ts', (content) => {
const { ast, generateCode } = parseScript(content);
const locals = js.kit.addGlobalAppInterface(ast, 'Locals');
if (!locals) {
throw new Error('Failed detecting `locals` interface in `src/app.d.ts`');
}
const user = locals.body.body.find((prop) => js.common.hasTypeProp('user', prop));
const session = locals.body.body.find((prop) => js.common.hasTypeProp('session', prop));
if (!user) {
locals.body.body.push(createLuciaType('user'));
}
if (!session) {
locals.body.body.push(createLuciaType('session'));
}
return generateCode();
});
} |
@manuel3108 I have a prototype returning 0 errors and warnings from check after these changes. Happy for me to start proper PR process? |
Absolutely, would love to see what you had to change! |
With the hooks file ast, it is only paraglide and Lucia that writes to it. Ben did mention making more just into strings #557. These currently use the ast and to solve this the way I planned I need jsdoc comment for svelte type per hook function. Currently it seems I can only add this comment to top of the file as ast.common puts it there? |
What about this method? Should be viable on nearly every AST node i think cli/packages/core/tooling/js/common.ts Line 28 in 324f2ea
|
This should prevent stuff like #341 to happen again
The text was updated successfully, but these errors were encountered: