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

Sveltekit Error : Property 'HSStaticMethods' does not exist on type 'Window & typeof globalThis' #401

Open
P00HB33R opened this issue Jul 1, 2024 · 2 comments

Comments

@P00HB33R
Copy link

P00HB33R commented Jul 1, 2024

Summary

Getting the error "Property 'HSStaticMethods' does not exist on type 'Window & typeof globalThis'" when adding the afterNavigate function as per documentation for sveltekit

Steps to Reproduce

  1. Create new sveltekit project as per docs.
  2. Add afterNavigate function HSStatic

Demo Link

Expected Behavior

There should be no error

Actual Behavior

Property 'HSStaticMethods' does not exist on type 'Window & typeof globalThis'

Screenshots

No response

@olegpix
Copy link
Collaborator

olegpix commented Jul 11, 2024

Summary

Getting the error "Property 'HSStaticMethods' does not exist on type 'Window & typeof globalThis'" when adding the afterNavigate function as per documentation for sveltekit

Steps to Reproduce

  1. Create new sveltekit project as per docs.
  2. Add afterNavigate function HSStatic

Demo Link

Expected Behavior

There should be no error

Actual Behavior

Property 'HSStaticMethods' does not exist on type 'Window & typeof globalThis'

Screenshots

No response

Hi,
For now you can declare static methods in a file. We'll add it globally in future versions.

import { IStaticMethods } from 'preline/src/static/interfaces';

declare global {
	interface Window {
		HSStaticMethods: IStaticMethods;
	}
}

@bonclairvoyante
Copy link

bonclairvoyante commented Jul 18, 2024

Summary

Getting the error "Property 'HSStaticMethods' does not exist on type 'Window & typeof globalThis'" when adding the afterNavigate function as per documentation for sveltekit

Steps to Reproduce

  1. Create new sveltekit project as per docs.
  2. Add afterNavigate function HSStatic

Demo Link

Expected Behavior

There should be no error

Actual Behavior

Property 'HSStaticMethods' does not exist on type 'Window & typeof globalThis'

Screenshots

No response

Hi, For now you can declare static methods in a file. We'll add it globally in future versions.

import { IStaticMethods } from 'preline/src/static/interfaces';

declare global {
	interface Window {
		HSStaticMethods: IStaticMethods;
	}
}

You comment is timely as I also had a similar issue. Thank you.

However, on implemantation, I did not know where to declare it (just getting started with Sveltekit). So, I gathered that this should be done in a global.d.ts or index.d.ts file (I prefered setting it up within the src folder). I found further reading on it here, check it out in case you need more infor on it:

https://robkendal.co.uk/blog/how-to-fix-property-does-not-exist-on-window-type-in-typescript/.

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

No branches or pull requests

3 participants