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

pkg/lib: create cockpit.ts #20417

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Commits on May 2, 2024

  1. pkg/lib: create cockpit.ts

    Rename `cockpit.js` to `cockpit-core.js`.  Import it to `cockpit.ts` and
    re-export it as the default export.  This is the traditional cockpit API
    up to this point, and you can still access it via:
    
      `import cockpit from 'cockpit';`
    
    Take our type annotations from `cockpit.d.ts` and move them into
    `cockpit.ts`, changing their format to an interface which describes the
    cockpit object (our default export).  This is actually a bit of a
    reduction in readability because it means that we can no longer keep the
    helper interface types beside the functions that use them, but it
    simplifies our setup (removing a duplicate `tsc` call, speeding up
    `test/static-code` a bit).
    
    As a side-effect of this change, we're no longer treating `cockpit` as a
    namespace, which means that we need to take the types that we've been
    publicly exporting on that namespace and export them from `cockpit.ts`,
    as non-default exports.  That means that instead of doing something
    like:
    
    ```
       import cockpit from 'cockpit';
    
       ... cockpit.JsonObject
    ```
    
    it will look like
    
    ```
       import cockpit, { JsonObject } from 'cockpit';
    
       ... JsonObject
    ```
    
    In general, we plan that, going forward, new API will be added in this
    way and made available via named exports.  Eventually (in the very
    distant future) the default export will be deprecated.
    allisonkarlitskaya committed May 2, 2024
    Configuration menu
    Copy the full SHA
    29b1df6 View commit details
    Browse the repository at this point in the history