htmlstreamofficial / preline

Preline UI is an open-source set of prebuilt UI components based on the utility-first Tailwind CSS framework.
https://preline.co
Other
4.9k stars 309 forks source link

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

Closed P00HB33R closed 1 month ago

P00HB33R commented 4 months ago

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 commented 4 months ago

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 commented 4 months ago

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 commented 1 month ago

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

bonclairvoyante commented 1 month ago

Thank you. Barry Sande.

On Tue, Sep 24, 2024, 00:21 Jaha Ganiev @.***> wrote:

Hey @P00HB33R https://github.com/P00HB33R - please check out the latest version, the issue has been fixed. Thanks!

— Reply to this email directly, view it on GitHub https://github.com/htmlstreamofficial/preline/issues/401#issuecomment-2369415667, or unsubscribe https://github.com/notifications/unsubscribe-auth/BDC7UR6ND57NWIWHOX6SPG3ZYCA5DAVCNFSM6AAAAABKE6V6ZWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNRZGQYTKNRWG4 . You are receiving this because you commented.Message ID: @.***>