swup / preload-plugin

A swup plugin for preloading pages to speed up navigation 🚀
https://swup.js.org/plugins/preload-plugin
MIT License
14 stars 14 forks source link

Properly overwrite `preloadVisibleLinks` in `PluginInitOptions` #90

Closed hirasso closed 1 year ago

hirasso commented 1 year ago

Description

When trying to test-drive the new preloadVisibleLinks option, I got the following TS error:

Type 'true' is not assignable to type '(VisibleLinkPreloadOptions & (boolean | Partial)) | undefined'.

While I don't really understand the error, I was able to solve it by using Omit<PluginOptions, 'preloadVisibleLinks'> for the init options.

Checks

daun commented 1 year ago

Great catch!

daun commented 1 year ago

To be honest, I have no idea why it wouldn't have worked in the first place, but the solution looks solid :)

hirasso commented 1 year ago

😁 I don't know either, but followed this advice and the warning went away: https://stackoverflow.com/a/74813590/586823