From b796f7669804b9141ac70a5d889f630074a8c1ae Mon Sep 17 00:00:00 2001 From: Michael Haufe Date: Thu, 22 Apr 2021 20:08:31 -0500 Subject: [PATCH] converted type declaration to module (#183) --- package.json | 1 + src/Contracted.ts | 2 +- src/assert.ts | 1 + src/lib/CLASS_REGISTRY.ts | 2 +- src/lib/ClassRegistration.ts | 2 +- src/lib/{Constructor.d.ts => Constructor.ts} | 4 ++-- src/lib/index.ts | 2 ++ 7 files changed, 9 insertions(+), 5 deletions(-) rename src/lib/{Constructor.d.ts => Constructor.ts} (75%) diff --git a/package.json b/package.json index 8bea0d6..f5a1106 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "0.20.0", "description": "Code Contracts for TypeScript and ECMAScript classes", "main": "dist/index.js", + "types": "dist/index.d.ts", "scripts": { "prebuild": "npm run clean && npm run lint", "build": "webpack", diff --git a/src/Contracted.ts b/src/Contracted.ts index d514f44..b35f4cf 100644 --- a/src/Contracted.ts +++ b/src/Contracted.ts @@ -5,7 +5,7 @@ * @see */ -import { ClassRegistration, CLASS_REGISTRY, Feature, takeWhile, assertInvariants } from './lib'; +import { ClassRegistration, CLASS_REGISTRY, Constructor, Feature, takeWhile, assertInvariants } from './lib'; import { assert, checkedMode, Contract } from './'; import { MSG_NO_PROPERTIES, MSG_SINGLE_CONTRACT } from './Messages'; diff --git a/src/assert.ts b/src/assert.ts index c25e8ae..42e7a91 100644 --- a/src/assert.ts +++ b/src/assert.ts @@ -7,6 +7,7 @@ import AssertionError from './AssertionError'; import { ASSERTION_FAILED } from './Messages'; +import { Constructor } from './lib'; /** * An assertion is an expression of a property that must be true at a particular diff --git a/src/lib/CLASS_REGISTRY.ts b/src/lib/CLASS_REGISTRY.ts index 32b7dd0..b8e8949 100644 --- a/src/lib/CLASS_REGISTRY.ts +++ b/src/lib/CLASS_REGISTRY.ts @@ -5,7 +5,7 @@ * @see */ -import ClassRegistration from './ClassRegistration'; +import {ClassRegistration, Constructor} from './'; /** * A WeakMap that tracks class registrations. diff --git a/src/lib/ClassRegistration.ts b/src/lib/ClassRegistration.ts index eca2080..fbb286c 100644 --- a/src/lib/ClassRegistration.ts +++ b/src/lib/ClassRegistration.ts @@ -7,7 +7,7 @@ import { MSG_SINGLE_RETRY } from '../Messages'; import { assert, checkedMode, Contract } from '../'; -import { assertInvariants, assertDemands, CLASS_REGISTRY, Feature, unChecked } from './'; +import { assertInvariants, assertDemands, CLASS_REGISTRY, Constructor, Feature, unChecked } from './'; import assertEnsures from './assertEnsures'; /** diff --git a/src/lib/Constructor.d.ts b/src/lib/Constructor.ts similarity index 75% rename from src/lib/Constructor.d.ts rename to src/lib/Constructor.ts index 887b878..4eb398a 100644 --- a/src/lib/Constructor.d.ts +++ b/src/lib/Constructor.ts @@ -5,7 +5,7 @@ * @see */ - /** +/** * Constructs a type representing a constructor */ -type Constructor = new(...args: any[]) => T; \ No newline at end of file +export type Constructor = new(...args: any[]) => T; \ No newline at end of file diff --git a/src/lib/index.ts b/src/lib/index.ts index bd110fc..d1ccea3 100644 --- a/src/lib/index.ts +++ b/src/lib/index.ts @@ -10,6 +10,7 @@ import assertEnsures from './assertEnsures'; import assertInvariants from './assertInvariants'; import CLASS_REGISTRY from './CLASS_REGISTRY'; import ClassRegistration from './ClassRegistration'; +import {Constructor} from './Constructor'; import deepFreeze from './deepFreeze'; import Feature from './Feature'; import takeWhile from './takeWhile'; @@ -23,6 +24,7 @@ export { assertInvariants, CLASS_REGISTRY, ClassRegistration, + Constructor, deepFreeze, Feature, fnTrue,