diff --git a/.npmignore b/.npmignore index 30da0b7..bf07be4 100644 --- a/.npmignore +++ b/.npmignore @@ -2,6 +2,6 @@ src tsconfig.json rollup.config.ts jest.config.js -.travis.yml size.txt +.vscode diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..55712c1 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "typescript.tsdk": "node_modules/typescript/lib" +} \ No newline at end of file diff --git a/package.json b/package.json index 85cdd66..89fcc11 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "test:debug:named": "node --inspect-brk node_modules/.bin/jest --runInBand --watch --testNamePattern", "lint": "eslint . --ext=js,ts", "lint:fix": "eslint . --ext=js,ts --fix", + "lint:tsc": "tsc --noEmit", "prepare": "npm run build", "prepublishOnly": "npm run test && npm run lint", "preversion": "npm run lint", diff --git a/src/-private/change.ts b/src/-private/change.ts index 3c112a0..ad8fae5 100644 --- a/src/-private/change.ts +++ b/src/-private/change.ts @@ -1,4 +1,3 @@ -/* import { IChange } from '../types'; */ import isObject from '../utils/is-object'; export const VALUE = Symbol('__value__'); @@ -20,3 +19,7 @@ export function getChangeValue(maybeChange: Change | unknown): any { return maybeChange[VALUE]; } } + +export interface Changes { + [s: string]: any; +} diff --git a/src/-private/err.ts b/src/-private/err.ts index de4e781..003837f 100644 --- a/src/-private/err.ts +++ b/src/-private/err.ts @@ -1,4 +1,4 @@ -import type { IErr, ValidationErr } from '../types'; +import type { ValidationErr } from '../types'; export default class Err implements IErr { value: any; @@ -9,3 +9,18 @@ export default class Err implements IErr { this.validation = validation; } } + +export interface IErr { + value: T; + validation: ValidationErr | ValidationErr[]; +} + +export type Errors = { + [s: string]: IErr; +}; + +export type PublicErrors = { + key: string; + value: any; + validation: ValidationErr | ValidationErr[]; +}[]; \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 218ad4f..c2b2b02 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,8 +1,8 @@ -import Change, { getChangeValue, isChange } from './-private/change'; +import Change, { getChangeValue, isChange, type Changes } from './-private/change'; import { getKeyValues, getKeyErrorValues } from './utils/get-key-values'; import lookupValidator from './utils/validator-lookup'; import { notifierForEvent } from './-private/evented'; -import Err from './-private/err'; +import Err, { type Errors, type IErr } from './-private/err'; import { hasKey, pathInChanges } from './utils/has-key'; import normalizeObject from './utils/normalize-object'; import { hasChanges } from './utils/has-changes'; @@ -23,11 +23,8 @@ import getDeep, { getSubObject } from './utils/get-deep'; import { objectToArray, arrayToObject } from './utils/array-object'; import type { - Changes, Config, Content, - Errors, - IErr, IChangeset, INotifier, InternalMap, diff --git a/src/types/index.ts b/src/types/index.ts index ba8e0ba..e870030 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -61,19 +61,15 @@ export type ValidatorMap = | null | undefined; -// https://github.com/microsoft/TypeScript/pull/26797 -/* export interface IChange { */ -/* [s: symbol]: any; */ -/* } */ -export interface Changes { - [s: string]: any; //IChange; -} - export interface Content { save?: (...args: unknown[]) => unknown | undefined; [key: string]: any; } +export interface Changes { + [s: string]: any; +} + export interface IErr { value: T; validation: ValidationErr | ValidationErr[];