Skip to content

Commit

Permalink
Avoid re-exporting everything from the index file (leave only the ver…
Browse files Browse the repository at this point in the history
…sion, which is auto-updated). This change is so that unrelated tools don't get bundled together in downstream projects that don't need all of them.

BREAKING: These utilities can no longer be imported `from 'lowclass'`. Instead, import the utility that you need directly from the specific file it is in, f.e. `import {Constructor} from 'lowclass/dist/Constructor.js'`.
  • Loading branch information
trusktr committed Sep 10, 2024
1 parent 106e01b commit 77cbbe2
Show file tree
Hide file tree
Showing 86 changed files with 333 additions and 356 deletions.
4 changes: 2 additions & 2 deletions dist/Class.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Constructor } from './utils.js';
import { Constructor } from './Constructor.js';
import type { Id } from './types.js';
type ImplementationKeys = 'static' | 'private' | 'protected';
type FunctionToConstructor<T, TReturn> = T extends (...a: infer A) => void ? new (...a: A) => TReturn : never;
Expand Down Expand Up @@ -237,5 +237,5 @@ export declare function createClassHelper(options?: any): {
};
})[P_14]; } : never)[P_13]; } : never);
};
export default Class;
export {};
//# sourceMappingURL=Class.d.ts.map
2 changes: 1 addition & 1 deletion dist/Class.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions dist/Class.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/Class.js.map

Large diffs are not rendered by default.

55 changes: 55 additions & 0 deletions dist/Constructor.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* Without type args, this is an easy shortcut for "any non-abstract constructor
* that has any args and returns any type of object".
*
* With type args, define a non-abstract constructor type that returns a certain
* instance type (optional), accepts certain args (optional, defaults to any
* args for simplicity in cases like class-factory mixins), and has certain
* static members (optional).
*/
export type Constructor<T = object, A extends any[] = any[], Static = {}> = (new (...a: A) => T) & Static;
/**
* Cast any constructor type (abstract or not) into a specific Constructor type.
* Useful for forcing type checks inside of mixins for example. This is unsafe:
* you can incorrectly cast one constructor into an unrelated constructor type,
* so use with care.
*/
export declare function Constructor<T = object, Static = {}>(Ctor: AnyConstructor<any>): Constructor<T> & Static;
/**
* Without type args, this is an easy shortcut for "any abstract constructor
* that has any args and returns any type of object".
*
* With type args, define an abstract constructor type that returns a certain
* instance type (optional), accepts certain args (optional, defaults to any
* args for simplicity in cases like class-factory mixins), and has certain
* static members (optional).
*/
export type AbstractConstructor<T = object, A extends any[] = any[], Static = {}> = (abstract new (...a: A) => T) & Static;
/**
* Cast any constructor type (abstract or not) into a specific
* AbstractConstructor type. Useful for forcing type checks inside of mixins
* for example. This is unsafe: you can incorrectly cast one constructor into an
* unrelated constructor type, so use with care.
*/
export declare function AbstractConstructor<T = object, Static = {}>(Ctor: AnyConstructor<any>): AbstractConstructor<T> & Static;
/**
* Combines Constructor and AbstractConstructor to support assigning any type of
* constructor whether abstract or not.
*
* Without type args, this is an easy shortcut for "any constructor, abstract or not,
* that has any args and returns any type of object".
*
* With type args, define a constructor type (abstract or not) that returns a
* certain instance type (optional), accepts certain args (optional, defaults to
* any args for simplicity in cases like class-factory mixins), and has certain
* static members (optional).
*/
export type AnyConstructor<T = object, A extends any[] = any[], Static = {}> = Constructor<T, A, Static> | AbstractConstructor<T, A, Static>;
/**
* Cast any constructor type (abstract or not) into a specific
* AnyConstructor type. Useful for forcing type checks inside of mixins
* for example. This is unsafe: you can incorrectly cast one constructor into an
* unrelated constructor type, so use with care.
*/
export declare function AnyConstructor<T = object, Static = {}>(Ctor: AnyConstructor<any>): AnyConstructor<T> & Static;
//# sourceMappingURL=Constructor.d.ts.map
1 change: 1 addition & 0 deletions dist/Constructor.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions dist/Constructor.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/Constructor.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/Mixin.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Constructor } from './utils.js';
import type { Constructor } from './Constructor.js';
export type MixinFunction = <T extends Constructor<any>>(BaseClass: T) => T;
export type MixinFunctionWithDefault = <T extends Constructor<any>>(BaseClass?: T) => T;
export type MixinResult<TClass extends Constructor, TBase extends Constructor> = Constructor<InstanceType<TClass> & InstanceType<TBase>> & TClass & TBase;
Expand Down
2 changes: 1 addition & 1 deletion dist/Mixin.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/Mixin.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 77cbbe2

Please sign in to comment.