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

Direct usage of Module Augmentation with @lightningjs/core #480

Closed
itsjamie opened this issue May 15, 2023 · 4 comments · Fixed by #483, #498 or #514
Closed

Direct usage of Module Augmentation with @lightningjs/core #480

itsjamie opened this issue May 15, 2023 · 4 comments · Fixed by #483, #498 or #514
Assignees
Labels

Comments

@itsjamie
Copy link
Contributor

itsjamie commented May 15, 2023

It appears there is no way to augment the FireAncestors map with @lightningjs/core.

Because it exports default module augmentation is broken.

See: https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation

Default exports also cannot be augmented, only named exports (since you need to augment an export by its exported name, and default is a reserved word - see #14080 for details)

@frank-weindel
Copy link
Contributor

frank-weindel commented May 16, 2023

Thanks for bringing this up @itsjamie. Just for anyone else who might stumble upon this, this problem only exists if you use @lightningjs/core without also utilizing @lightningjs/sdk which exports Lightning as a named export.

I've got a workaround for this that should've been documented (better yet if we can export Lightning as a named export). You can create a file that re-exports Lightning as a named export and base your augmentation file on it:

lightning-reexport.ts

import Lightning from '@lightningjs/core';
export { Lightning };

augmentations.d.ts

import './lightning-reexport'

declare module './lightning-reexport' {
  /**
   * Lightning Core Augmentations
   */
  namespace Lightning {
    namespace Component {
      // ...
    }
    // ...
  }
  //...
}

The nice thing with this is that you won't have to change the way you import Lightning Core in the rest of your application. TypeScript applies the augmentations to the actual source types irregardless as to how they are imported.

@frank-weindel frank-weindel self-assigned this May 18, 2023
@frank-weindel
Copy link
Contributor

We are going to add a named export along side the default export

@uguraslan uguraslan added the fix-in-review This issue has a PR in review label May 22, 2023
@uguraslan uguraslan added fixed and removed fix-in-review This issue has a PR in review labels Jul 12, 2023
@uguraslan uguraslan added this to the July 2023 release milestone Jul 12, 2023
@uguraslan uguraslan mentioned this issue Jul 12, 2023
2 tasks
@frank-weindel frank-weindel reopened this Jul 18, 2023
@frank-weindel
Copy link
Contributor

The original PR for this issue was reverted. It is now resolved as part of #498.

@frank-weindel frank-weindel linked a pull request Jul 18, 2023 that will close this issue
2 tasks
@uguraslan uguraslan removed this from the July 2023 release milestone Jul 24, 2023
@uguraslan uguraslan added fix-in-review This issue has a PR in review and removed fixed labels Jul 24, 2023
@uguraslan uguraslan added this to the October 2023 release milestone Jul 24, 2023
@uguraslan
Copy link
Collaborator

uguraslan commented Jul 24, 2023

Hey @frank-weindel, thanks for your comment and I am sorry about my confusion about this issue and #483. I have removed this from the July release as the fix (PR #498) has not been approved & merged yet. I hope we can include this one in the October release.

@uguraslan uguraslan added fixed and removed fix-in-review This issue has a PR in review labels Oct 10, 2023
@uguraslan uguraslan mentioned this issue Oct 11, 2023
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment