Skip to content

missing types for window.prestashop #618

Open

Description

@davidglezz

The objective of this issue is to request and coordinate the definition of types of the global variable window.prestashop.

Any is not good. We lost type safety, IDE suggestions, ...

prestashop: any;

Activity

  1. boo-code commented on Sep 10, 2026

    @boo-code
    Contributor

    window.prestashop was the last any in the theme's TypeScript - src/js has none left outside test fixtures - and CONTEXT.md already forbids it.

    Typed it against what the theme actually consumes, each member sourced rather than guessed:

    • the emitter, since src/js/prestashop.ts copies EventEmitter.prototype onto the global
    • responsive, which the theme itself writes in src/js/responsive-toggler.ts
    • urls, from FrontController::getTemplateVarUrls()
    • checkPasswordScore, whose zxcvbn result is narrowed to score and feedback because the theme has no zxcvbn dependency to import the upstream type from
    • blockcart, optional, added by src/js/modules/blockcart.ts

    The payload of on/once/off is a type parameter inferred from the listener. A fixed payload type rejects nine existing call sites, because the emitting sides genuinely differ: {event: Event}, {context: 'main' | 'quickview'}, HTMLElement, Record<string, unknown>, a bare string.

    No index signature. Core publishes more than this, and an open map is the same any under another name; a member that is needed later gets declared with its type, which is the coordination this issue asks for.

    Two call sites move as a result. blockcart.ts built its entry as prestashop.blockcart || {} then assigned showModal, which the correctly-optional type rejects, so it is one assignment that spreads what was already there. quickview.ts drops prestashop.urls.pages.product as string, a cast that existed only because the global was untyped.

    Verified: tsc --noEmit --skipLibCheck clean, jest 39 tests green, eslint exit 0. Mutation both ways - prestashop.thisMemberDoesNotExist now fails with TS2339 and prestashop.urls.pages.product.toFixed(2) with TS2551, while the same two lines compile clean against the current prestashop: any.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions