Skip to content

Commit

Permalink
bugfix 238 (#240)
Browse files Browse the repository at this point in the history
  • Loading branch information
mlhaufe authored Aug 21, 2022
1 parent 727afc3 commit 242e9de
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 14 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## v0.24.1

* Bugfix of generated type declaration (#238)
* Updated README to reflect current features (#)

## v0.24.0

* Updated debugger settings to leverage modern VSCode
Expand Down
4 changes: 2 additions & 2 deletions 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": "@final-hill/decorator-contracts",
"version": "0.24.0",
"version": "0.24.1",
"description": "Code Contracts for TypeScript and ECMAScript classes",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions src/assert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import AssertionError from './AssertionError';
import { ASSERTION_FAILED } from './Messages';
import type { Constructor } from 'lib/ClassType';
import { Constructor } from './';

/**
* An assertion is an expression of a property that must be true at a particular
Expand All @@ -32,7 +32,7 @@ import type { Constructor } from 'lib/ClassType';
* assert(name.trim().length > 0, 'Name is required', TypeError)
*/
export default function assert(condition: unknown, message = ASSERTION_FAILED, ErrorConstructor: Constructor<Error> = AssertionError): asserts condition {
if(Boolean(condition) == false) {
if (Boolean(condition) == false) {
throw new ErrorConstructor(message);
}
}
10 changes: 4 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
*/

import AssertionError from './AssertionError';
import {Contract, extend, invariant, Invariant, checkedMode, Rescue} from './Contract';
import Contracted, {innerContract} from './Contracted';
import Contracted, { innerContract } from './Contracted';
import override from './override';
import assert from './assert';
import implies from './implies';

export {
AssertionError, Contract, Contracted, Invariant, Rescue, implies,
invariant, innerContract, extend, checkedMode, override, assert
};
export { AssertionError, Contracted, implies, innerContract, override, assert };
export { Contract, extend, invariant, Invariant, checkedMode, Rescue } from './Contract';
export { Constructor, AbstractConstructor, ClassType } from './lib/ClassType';
8 changes: 5 additions & 3 deletions src/lib/ClassType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
/**
* Constructs a type representing a class
*/
export type Constructor<T> = new (...args: any[]) => T;
type Constructor<T> = new (...args: any[]) => T;

export type AbstractConstructor<T> = abstract new (...args: any[]) => T;
type AbstractConstructor<T> = abstract new (...args: any[]) => T;

export type ClassType<T> = Constructor<T> | AbstractConstructor<T>;
type ClassType<T> = Constructor<T> | AbstractConstructor<T>;

export { Constructor, AbstractConstructor, ClassType };

0 comments on commit 242e9de

Please sign in to comment.