Skip to content

Commit

Permalink
Merge pull request #33 from wentout/proto
Browse files Browse the repository at this point in the history
some types improvements
  • Loading branch information
wentout committed Mar 13, 2024
2 parents 61195b7 + af47613 commit fc06e2a
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 5 deletions.
4 changes: 4 additions & 0 deletions lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ export declare const BaseConstructorPrototype: <P extends object, S extends Prot
export declare class BaseClass extends BaseConstructorPrototype {
}
export { FieldConstructor } from './fields';
type StrictRuntime = {
<T extends object>(...args: unknown[]): T;
};
export declare const Strict: StrictRuntime;
11 changes: 10 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
exports.FieldConstructor = exports.BaseClass = exports.BaseConstructorPrototype = void 0;
exports.Strict = exports.FieldConstructor = exports.BaseClass = exports.BaseConstructorPrototype = void 0;
const errors_1 = require("./errors");
const types_1 = require("./types");
const fields_1 = require("./fields");
Expand Down Expand Up @@ -107,6 +107,9 @@ class BaseClass extends exports.BaseConstructorPrototype {
exports.BaseClass = BaseClass;
var fields_2 = require("./fields");
Object.defineProperty(exports, "FieldConstructor", { enumerable: true, get: function () { return fields_2.FieldConstructor; } });
exports.Strict = {
Strict: exports.BaseConstructorPrototype,
}.Strict;
Object.defineProperty(module.exports, 'BaseClass', {
get() {
return BaseClass;
Expand All @@ -119,3 +122,9 @@ Object.defineProperty(module.exports, 'FieldConstructor', {
},
enumerable: true
});
Object.defineProperty(module.exports, 'Strict', {
get() {
return exports.BaseConstructorPrototype;
},
enumerable: true
});
2 changes: 1 addition & 1 deletion package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typeomatica",
"version": "0.3.32",
"version": "0.3.33",
"description": "type logic against javascript metaprogramming",
"engines": {
"node": ">=14"
Expand Down
26 changes: 26 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,20 @@ Object.defineProperty(module, 'exports', {
export class BaseClass extends BaseConstructorPrototype { }
export { FieldConstructor } from './fields';

type StrictRuntime = {
// eslint-disable-next-line no-unused-vars
<T extends object>(...args: unknown[]): T
}

// export const { StrictPrototype, Strict } = {
export const { Strict } = {
// StrictPrototype: BaseConstructorPrototype,
Strict: BaseConstructorPrototype,
} as {
// StrictPrototype: StrictRuntime
Strict: StrictRuntime
};

Object.defineProperty(module.exports, 'BaseClass', {
get() {
return BaseClass;
Expand All @@ -206,3 +220,15 @@ Object.defineProperty(module.exports, 'FieldConstructor', {
},
enumerable: true
});
// Object.defineProperty(module.exports, 'StrictPrototype', {
// get() {
// return BaseConstructorPrototype;
// },
// enumerable: true
// });
Object.defineProperty(module.exports, 'Strict', {
get() {
return BaseConstructorPrototype;
},
enumerable: true
});
4 changes: 2 additions & 2 deletions test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { describe, expect, test } from '@jest/globals';
// go as you want for being meaningfull
// or meaningless
const BasePrototype = require('..');
import { BaseClass, FieldConstructor } from '..';
import { BaseClass, FieldConstructor, Strict } from '..';

const { SymbolInitialValue } = FieldConstructor;

Expand All @@ -26,7 +26,7 @@ let decoratedSomeProp = 0;


// eslint-disable-next-line new-cap
@BasePrototype({ someProp: 123 })
@Strict({ someProp: 123 })
class DecoratedByBase {
someProp!: number;
}
Expand Down

0 comments on commit fc06e2a

Please sign in to comment.