-
Notifications
You must be signed in to change notification settings - Fork 34
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
Make the global types importable #10555
Comments
ComLock
changed the title
Make the types in @enonic-types/global importable from @enonic-types/core
Make the global types importable
May 14, 2024
ComLock
added a commit
that referenced
this issue
May 14, 2024
ComLock
added a commit
that referenced
this issue
Aug 16, 2024
ComLock
added a commit
that referenced
this issue
Aug 16, 2024
anatol-sialitski
pushed a commit
that referenced
this issue
Oct 31, 2024
* Fix #10555 Make global types importable * Define and reuse definitions both as global and export * XpBeans and XpLibraries belongs in globals * Make global depend on core (not the other way around) * Remove noImplicitUseStrict which is deprecated in TypeScript 5.5 * Remove NewBean and ScriptValue from global scope. Can be imported from core instead. * Enable strict and fix most type errors * Fix TypeScript errors in grid.ts --------- Co-authored-by: Mikita Taukachou <edloidas@gmail.com> (cherry picked from commit 1a48ac1)
anatol-sialitski
pushed a commit
that referenced
this issue
Oct 31, 2024
* Fix #10555 Make global types importable * Define and reuse definitions both as global and export * XpBeans and XpLibraries belongs in globals * Make global depend on core (not the other way around) * Remove noImplicitUseStrict which is deprecated in TypeScript 5.5 * Remove NewBean and ScriptValue from global scope. Can be imported from core instead. * Enable strict and fix most type errors * Fix TypeScript errors in grid.ts --------- Co-authored-by: Mikita Taukachou <edloidas@gmail.com> (cherry picked from commit 1a48ac1)
rymsha
pushed a commit
that referenced
this issue
Nov 1, 2024
* Fix #10555 Make global types importable * Define and reuse definitions both as global and export * XpBeans and XpLibraries belongs in globals * Make global depend on core (not the other way around) * Remove noImplicitUseStrict which is deprecated in TypeScript 5.5 * Remove NewBean and ScriptValue from global scope. Can be imported from core instead. * Enable strict and fix most type errors * Fix TypeScript errors in grid.ts --------- Co-authored-by: Mikita Taukachou <edloidas@gmail.com> (cherry picked from commit 1a48ac1)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
LongTitle: Make the types in @enonic-types/global importable from @enonic-types/core
--
The types in @enonic-types/global are working as intended for Enonic XP server-side code files in src/main/resources/*.ts
However when writing tests the global functions and object must be replaced by mocks.
Since the globals are defined as "const" in @enonic-types/global, it's a type error if one tries to replace them.
Changing the type to var (let) is not a good idea since that's actually wrong when it comes to the actual "runtime" types.
My suggestion is to
Then if I need any of those global types anywhere, I can manually import only the specific ones I need from @enonic-types/core.
One example is when implementing the classes in Mock-XP, I would like to use the type for the global log object as an interface:
The same goes then modifying the type of globalThis when mocking in test files:
I can probably make it even prettier with a local Global Type Library, or a local Global Modifying Module.
But I need the actual types. I don't want to duplicate those types locally.
Define once, use everywhere.
The text was updated successfully, but these errors were encountered: