feat: Adds ts types to library#29
Open
danielbertolozi wants to merge 2 commits into
Open
Conversation
cassianobartZ
approved these changes
Aug 21, 2025
Psidium
reviewed
Aug 21, 2025
Psidium
left a comment
Member
There was a problem hiding this comment.
The types.d.ts file was being ignored, I tried to clean the .d.ts a bit, but I couldn't get far without a UI5 project to test this against (I am not digging up the project that spawned this package no no no)
| "isolatedModules": true, | ||
| "noUncheckedSideEffectImports": true, | ||
| "moduleDetection": "force", | ||
| "skipLibCheck": true, |
Member
There was a problem hiding this comment.
skipLibCheck... skips the typescript compilation of types.d.ts...
Suggested change
| "skipLibCheck": true, |
Comment on lines
+1
to
+43
| type LoadedFactory<T> = { | ||
| fn: () => T; | ||
| sap: Record<string, object>; | ||
| }; | ||
|
|
||
| type ExtendFn = (name: string, prototype: T) => InstanceType<T>; | ||
|
|
||
| declare module "ui5-simple-require" { | ||
| const loaded_factories: Record<string, LoadedFactory>; | ||
| const loaded_factories: Record<string, LoadedFactory>; | ||
| const importLib: <T>( | ||
| libRootPath: string, | ||
| libFilePath: string, | ||
| ui5LibNamespace: string | ||
| ) => InstanceType<T>; | ||
| const createExtendableFromPrototype: ( | ||
| prototype: T | ||
| ) => T & { extend: ExtendFn }; | ||
| const createExtendableFromObj: (prototype: T) => T & { extend: ExtendFn }; | ||
| const getExtendableStub: ExtendFn; | ||
| const globalContext: (context: Record<string, object>) => void; | ||
| const clearGlobalContext: () => void; | ||
| const inject: (path: string, dep: object) => void; | ||
| const clearInjection: () => void; | ||
| const ui5require: <T>( | ||
| module_path, | ||
| position_dependencies, | ||
| context | ||
| ) => InstanceType<T>; | ||
| export = { | ||
| loaded_factories, | ||
| importLib, | ||
| createExtendableFromPrototype, | ||
| createExtendableFromObj, | ||
| getExtendableStub, | ||
| globalContext, | ||
| clearGlobalContext, | ||
| inject, | ||
| clearInjection, | ||
| ui5require, | ||
| import: <T>() => InstanceType<T>, | ||
| }; | ||
| } |
Member
There was a problem hiding this comment.
Suggested change
| type LoadedFactory<T> = { | |
| fn: () => T; | |
| sap: Record<string, object>; | |
| }; | |
| type ExtendFn = (name: string, prototype: T) => InstanceType<T>; | |
| declare module "ui5-simple-require" { | |
| const loaded_factories: Record<string, LoadedFactory>; | |
| const loaded_factories: Record<string, LoadedFactory>; | |
| const importLib: <T>( | |
| libRootPath: string, | |
| libFilePath: string, | |
| ui5LibNamespace: string | |
| ) => InstanceType<T>; | |
| const createExtendableFromPrototype: ( | |
| prototype: T | |
| ) => T & { extend: ExtendFn }; | |
| const createExtendableFromObj: (prototype: T) => T & { extend: ExtendFn }; | |
| const getExtendableStub: ExtendFn; | |
| const globalContext: (context: Record<string, object>) => void; | |
| const clearGlobalContext: () => void; | |
| const inject: (path: string, dep: object) => void; | |
| const clearInjection: () => void; | |
| const ui5require: <T>( | |
| module_path, | |
| position_dependencies, | |
| context | |
| ) => InstanceType<T>; | |
| export = { | |
| loaded_factories, | |
| importLib, | |
| createExtendableFromPrototype, | |
| createExtendableFromObj, | |
| getExtendableStub, | |
| globalContext, | |
| clearGlobalContext, | |
| inject, | |
| clearInjection, | |
| ui5require, | |
| import: <T>() => InstanceType<T>, | |
| }; | |
| } | |
| type LoadedFactory<T> = { | |
| fn: () => T; | |
| sap: Record<string, object>; | |
| }; | |
| type ExtendFn<T> = (name: string, prototype: T) => InstanceType<T>; | |
| declare module "ui5-simple-require" { | |
| export const loaded_factories: Record<string, LoadedFactory<string>>; | |
| export function importLib<T>( | |
| libRootPath: string, | |
| libFilePath: string, | |
| ui5LibNamespace: string | |
| ): InstanceType<T>; | |
| function createExtendableFromPrototype<T extends new(...args: any): any>( | |
| prototype: T | |
| ): T & { extend: ExtendFn<T> }; | |
| export function createExtendableFromObj(prototype: T): T & { extend: ExtendFn }; | |
| export const getExtendableStub: ExtendFn<T>; | |
| export function globalContext(context: Record<string, object>): void; | |
| export function clearGlobalContext(): void; | |
| export function inject(path: string, dep: object): void; | |
| export function clearInjection(): void; | |
| export function ui5require<T>( | |
| module_path: string, | |
| position_dependencies: string[], | |
| context: T | |
| ): InstanceType<T>; | |
| export default { ['import']<T>(): T; }; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
still used & loved