Skip to content

feat: Adds ts types to library#29

Open
danielbertolozi wants to merge 2 commits into
masterfrom
addTSTypes
Open

feat: Adds ts types to library#29
danielbertolozi wants to merge 2 commits into
masterfrom
addTSTypes

Conversation

@danielbertolozi

@danielbertolozi danielbertolozi commented Aug 21, 2025

Copy link
Copy Markdown
Contributor

still used & loved

@Psidium Psidium left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Comment thread tsconfig.json
"isolatedModules": true,
"noUncheckedSideEffectImports": true,
"moduleDetection": "force",
"skipLibCheck": true,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

skipLibCheck... skips the typescript compilation of types.d.ts...

Suggested change
"skipLibCheck": true,

Comment thread types.d.ts
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>,
};
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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; };
}

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants