Skip to content

Missing property in type from ActionData #7004

@harrylaulau

Description

@harrylaulau

Describe the bug

This is to reopen issue #6823

First of all, thanks everyone for helping with this issue, but even after upgrading to the newest sveltekit version, the bug still persists. I have updated the example repo for clearer demonstration of the bug: https://github.com/harrylaulau/sveltekittest

First issue is that when one property exist in one invalid() but not another, the type of return object with that property does not exist.

Second issue is when a property is of object type, it seems to override all other type

+page.server.ts

import { invalid, redirect } from '@sveltejs/kit';
import type { Actions } from './$types';
export const actions: Actions = {
	default: async ({ request, url }) => {
		if (url.searchParams.get('v') === '0') return invalid(400, { common: '1' });
		if (url.searchParams.get('v') === '1') return invalid(400, { common: '2', something: '' });

		if (url.searchParams.get('v') === '2') return invalid(400, { common2: 1 });
		if (url.searchParams.get('v') === '3') return invalid(400, { common2: '1' });
		if (url.searchParams.get('v') === '4') return invalid(400, { common2: {} });
	}
};

CleanShot 2022-09-23 at 23 33 43

+page.svelte
CleanShot 2022-09-23 at 23 35 27

  1. return type with something does not exist
  2. return type with common2 having the string type or a number type does not exist

Reproduction

https://github.com/harrylaulau/sveltekittest

Logs

No response

System Info

System:
    OS: macOS 12.6
    CPU: (10) arm64 Apple M1 Max
    Memory: 7.60 GB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.15.0 - ~/.nvm/versions/node/v16.15.0/bin/node
    Yarn: 1.22.19 - ~/Library/pnpm/yarn
    npm: 8.12.1 - ~/.nvm/versions/node/v16.15.0/bin/npm
    Watchman: 2022.09.12.00 - /opt/homebrew/bin/watchman
  Browsers:
    Chrome: 105.0.5195.125
    Safari: 16.0
  npmPackages:
    @sveltejs/adapter-auto: next => 1.0.0-next.80 
    @sveltejs/kit: next => 1.0.0-next.502 
    svelte: ^3.44.0 => 3.50.1 
    vite: ^3.1.0 => 3.1.3

Severity

serious, but I can work around it

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions