Skip to content
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

feat(types): support custom VitePreloadErrorEvent #17615

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

btea
Copy link
Collaborator

@btea btea commented Jul 5, 2024

Description

close #17508

Copy link

stackblitz bot commented Jul 5, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

packages/vite/client.d.ts Outdated Show resolved Hide resolved
@MathiasWP
Copy link

Would it also be relevant to cast the actual error being thrown in https://github.com/vitejs/vite/blob/main/packages/vite/src/node/plugins/importAnalysisBuild.ts#L148

Doing something like this in the importAnalysisBuild.ts file:

const e: VitePreloadErrorEvent = new Event('vite:preloadError', { cancelable: true })
e.payload = err
window.dispatchEvent(e)
if (!e.defaultPrevented) {
    throw err
}

I think that will also make it possible to remove the // @ts-expect-error comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Declare missing vite:preloadErrorevent on Window namespace
2 participants