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

Closed
P00HB33R opened this issue Jul 1, 2024 · 4 comments
Labels
bug Something isn't working

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/.

@jahaganiev jahaganiev added the bug Something isn't working label Sep 22, 2024
@jahaganiev
Copy link
Member

Hey @P00HB33R - please check out the latest version, the issue has been fixed. Thanks!

@bonclairvoyante
Copy link

bonclairvoyante commented Sep 26, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants