Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: type modifier on imports #172

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ src
tsconfig.json
rollup.config.ts
jest.config.js
.travis.yml
size.txt
.vscode

3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"typescript.tsdk": "node_modules/typescript/lib"
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 4 additions & 1 deletion src/-private/change.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* import { IChange } from '../types'; */
import isObject from '../utils/is-object';

export const VALUE = Symbol('__value__');
Expand All @@ -20,3 +19,7 @@ export function getChangeValue(maybeChange: Change | unknown): any {
return maybeChange[VALUE];
}
}

export interface Changes {
[s: string]: any;
}
17 changes: 16 additions & 1 deletion src/-private/err.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { IErr, ValidationErr } from '../types';
import type { ValidationErr } from '../types';

export default class Err implements IErr<any> {
value: any;
Expand All @@ -9,3 +9,18 @@ export default class Err implements IErr<any> {
this.validation = validation;
}
}

export interface IErr<T> {
value: T;
validation: ValidationErr | ValidationErr[];
}

export type Errors<T> = {
[s: string]: IErr<T>;
};

export type PublicErrors = {
key: string;
value: any;
validation: ValidationErr | ValidationErr[];
}[];
7 changes: 2 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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,
Expand Down
12 changes: 4 additions & 8 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> {
value: T;
validation: ValidationErr | ValidationErr[];
Expand Down