Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
7 changes: 5 additions & 2 deletions .eslintrc.js → .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ module.exports = {
{
files: ['*.ts'],
extends: ['@metamask/eslint-config-typescript'],
rules: {
'import/no-useless-path-segments': ['error', { noUselessIndex: false }],
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this for?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted here: 220fe62

}
},

{
Expand Down Expand Up @@ -35,8 +38,8 @@ module.exports = {
],

ignorePatterns: [
'!.eslintrc.js',
'!.prettierrc.js',
'!.eslintrc.cjs',
'!.prettierrc.cjs',
'dist/',
'docs/',
'.yarn/',
Expand Down
File renamed without changes.
25 changes: 15 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,29 @@
},
"license": "MIT",
"sideEffects": false,
"type": "module",
Copy link

@mcmire mcmire May 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to make this an ESM package? I think that using ts-bridge and upgrading the moduleResolution should work without this, no?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted here: 6c4e6cd

"exports": {
".": {
"import": "./dist/index.mjs",
"require": "./dist/index.js",
"types": "./dist/types/index.d.ts"
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"require": {
"types": "./dist/index.d.cts",
"default": "./dist/index.cjs"
}
},
"./package.json": "./package.json"
},
"main": "./dist/index.js",
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
"types": "./dist/types/index.d.ts",
"types": "./dist/index.d.cts",
"files": [
"dist"
],
"scripts": {
"build": "tsup --clean && yarn build:types",
"build": "ts-bridge --project tsconfig.build.json --clean",
"build:docs": "typedoc",
"build:types": "tsc --project tsconfig.build.json",
"lint": "yarn lint:eslint && yarn lint:misc --check && yarn lint:dependencies --check && yarn lint:changelog",
"lint:changelog": "auto-changelog validate --prettier",
"lint:dependencies": "depcheck && yarn dedupe",
Expand All @@ -78,6 +83,8 @@
"@metamask/eslint-config-jest": "^12.1.0",
"@metamask/eslint-config-nodejs": "^12.1.0",
"@metamask/eslint-config-typescript": "^12.1.0",
"@ts-bridge/cli": "^0.1.2",
"@ts-bridge/shims": "^0.1.1",
"@types/expect": "^24.3.0",
"@types/lodash": "^4.14.144",
"@types/lodash-es": "^4.17.12",
Expand All @@ -100,7 +107,6 @@
"lodash-es": "^4.17.21",
"prettier": "^2.7.1",
"prettier-plugin-packagejson": "^2.3.0",
"tsup": "patch:tsup@npm%3A8.0.2#~/.yarn/patches/tsup-npm-8.0.2-86e40f68a7.patch",
"typedoc": "^0.25.9",
"typescript": "~4.8.4",
"vitest": "^1.2.2"
Expand All @@ -115,8 +121,7 @@
},
"lavamoat": {
"allowScripts": {
"vitest>vite>esbuild": true,
"tsup>esbuild": true
"vitest>vite>esbuild": true
}
}
}
16 changes: 15 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,18 @@ export * from './structs/coercions.js';
export * from './structs/refinements.js';
export * from './structs/types.js';
export * from './structs/utilities.js';
export type { ObjectSchema, Optionalize, Simplify } from './utils.js';
export type {
AnyStruct,
EnumSchema,
InferStructTuple,
IsExactMatch,
IsMatch,
IsRecord,
IsTuple,
ObjectSchema,
OmitBy,
Optionalize,
PickBy,
Simplify,
UnionToIntersection,
} from './utils.js';
2 changes: 1 addition & 1 deletion test/api/assert.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { throws, doesNotThrow } from 'assert';
import { describe, it } from 'vitest';

import { assert, string, StructError } from '../../src';
import { assert, string, StructError } from '../../src/index.js';

describe('assert', () => {
it('valid as helper', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/api/create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
defaulted,
literal,
coerce,
} from '../../src';
} from '../../src/index.js';

describe('create', () => {
it('missing as helper', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/api/is.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { strictEqual } from 'assert';
import { describe, it } from 'vitest';

import { is, string } from '../../src';
import { is, string } from '../../src/index.js';

describe('is', () => {
it('valid as helper', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/api/mask.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
StructError,
array,
type,
} from '../../src';
} from '../../src/index.js';

describe('mask', () => {
it('object as helper', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/api/validate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
refine,
object,
any,
} from '../../src';
} from '../../src/index.js';

describe('validate', () => {
it('valid as helper', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
create as createValue,
deprecated,
StructError,
} from '../src';
} from '../src/index.js';

describe('superstruct', () => {
describe('validation', () => {
Expand Down
4 changes: 2 additions & 2 deletions test/typings/any.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assert, any } from '../../src';
import { test } from '../index.test';
import { assert, any } from '../../src/index.js';
import { test } from '../index.test.js';

test<any>((value) => {
assert(value, any());
Expand Down
4 changes: 2 additions & 2 deletions test/typings/array.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assert, array, number } from '../../src';
import { test } from '../index.test';
import { assert, array, number } from '../../src/index.js';
import { test } from '../index.test.js';

test<unknown[]>((value) => {
assert(value, array());
Expand Down
4 changes: 2 additions & 2 deletions test/typings/assign.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assert, assign, object, number, string } from '../../src';
import { test } from '../index.test';
import { assert, assign, object, number, string } from '../../src/index.js';
import { test } from '../index.test.js';

test<{
a: number;
Expand Down
4 changes: 2 additions & 2 deletions test/typings/bigint.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assert, bigint } from '../../src';
import { test } from '../index.test';
import { assert, bigint } from '../../src/index.js';
import { test } from '../index.test.js';

test<bigint>((value) => {
assert(value, bigint());
Expand Down
4 changes: 2 additions & 2 deletions test/typings/boolean.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assert, boolean } from '../../src';
import { test } from '../index.test';
import { assert, boolean } from '../../src/index.js';
import { test } from '../index.test.js';

test<boolean>((value) => {
assert(value, boolean());
Expand Down
4 changes: 2 additions & 2 deletions test/typings/coerce.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assert, coerce, string, number } from '../../src';
import { test } from '../index.test';
import { assert, coerce, string, number } from '../../src/index.js';
import { test } from '../index.test.js';

test<number>((value) => {
assert(
Expand Down
4 changes: 2 additions & 2 deletions test/typings/date.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assert, date } from '../../src';
import { test } from '../index.test';
import { assert, date } from '../../src/index.js';
import { test } from '../index.test.js';

test<Date>((value) => {
assert(value, date());
Expand Down
4 changes: 2 additions & 2 deletions test/typings/defaulted.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assert, defaulted, string } from '../../src';
import { test } from '../index.test';
import { assert, defaulted, string } from '../../src/index.js';
import { test } from '../index.test.js';

test<string>((value) => {
assert(value, defaulted(string(), 'Untitled'));
Expand Down
4 changes: 2 additions & 2 deletions test/typings/deprecated.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assert, object, deprecated, any } from '../../src';
import { test } from '../index.test';
import { assert, object, deprecated, any } from '../../src/index.js';
import { test } from '../index.test.js';

test<unknown>((value) => {
const log = () => {
Expand Down
6 changes: 3 additions & 3 deletions test/typings/describe.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Describe } from '../../src';
import type { Describe } from '../../src/index.js';
import {
any,
object,
Expand Down Expand Up @@ -27,8 +27,8 @@ import {
max,
min,
pattern,
} from '../../src';
import { test } from '../index.test';
} from '../../src/index.js';
import { test } from '../index.test.js';

test<Describe<any>>(() => {
return any();
Expand Down
4 changes: 2 additions & 2 deletions test/typings/dynamic.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assert, dynamic, string } from '../../src';
import { test } from '../index.test';
import { assert, dynamic, string } from '../../src/index.js';
import { test } from '../index.test.js';

test<string>((value) => {
assert(
Expand Down
4 changes: 2 additions & 2 deletions test/typings/empty.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assert, empty, string, array, map, set } from '../../src';
import { test } from '../index.test';
import { assert, empty, string, array, map, set } from '../../src/index.js';
import { test } from '../index.test.js';

test<string>((value) => {
assert(value, empty(string()));
Expand Down
4 changes: 2 additions & 2 deletions test/typings/enums.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assert, enums } from '../../src';
import { test } from '../index.test';
import { assert, enums } from '../../src/index.js';
import { test } from '../index.test.js';

test<'a' | 'b' | 'c'>((value) => {
assert(value, enums(['a', 'b', 'c']));
Expand Down
4 changes: 2 additions & 2 deletions test/typings/func.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assert, func } from '../../src';
import { test } from '../index.test';
import { assert, func } from '../../src/index.js';
import { test } from '../index.test.js';

// eslint-disable-next-line @typescript-eslint/ban-types
test<Function>((value) => {
Expand Down
6 changes: 3 additions & 3 deletions test/typings/infer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Infer } from '../../src';
import { object, assert } from '../../src';
import { test } from '../index.test';
import type { Infer } from '../../src/index.js';
import { object, assert } from '../../src/index.js';
import { test } from '../index.test.js';

const Struct = object();
type T = Infer<typeof Struct>;
Expand Down
4 changes: 2 additions & 2 deletions test/typings/instance.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assert, instance } from '../../src';
import { test } from '../index.test';
import { assert, instance } from '../../src/index.js';
import { test } from '../index.test.js';

test<Date>((value) => {
assert(value, instance(Date));
Expand Down
4 changes: 2 additions & 2 deletions test/typings/integer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assert, integer } from '../../src';
import { test } from '../index.test';
import { assert, integer } from '../../src/index.js';
import { test } from '../index.test.js';

test<number>((value) => {
assert(value, integer());
Expand Down
4 changes: 2 additions & 2 deletions test/typings/intersection.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assert, intersection, object, string } from '../../src';
import { test } from '../index.test';
import { assert, intersection, object, string } from '../../src/index.js';
import { test } from '../index.test.js';

test<{ a: string; b: string }>((value) => {
assert(
Expand Down
4 changes: 2 additions & 2 deletions test/typings/lazy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assert, lazy, string } from '../../src';
import { test } from '../index.test';
import { assert, lazy, string } from '../../src/index.js';
import { test } from '../index.test.js';

test<string>((value) => {
assert(
Expand Down
4 changes: 2 additions & 2 deletions test/typings/literal.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assert, literal } from '../../src';
import { test } from '../index.test';
import { assert, literal } from '../../src/index.js';
import { test } from '../index.test.js';

test<true>((value) => {
assert(value, literal(true));
Expand Down
4 changes: 2 additions & 2 deletions test/typings/map.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assert, map, string, number } from '../../src';
import { test } from '../index.test';
import { assert, map, string, number } from '../../src/index.js';
import { test } from '../index.test.js';

test<Map<string, number>>((value) => {
assert(value, map(string(), number()));
Expand Down
4 changes: 2 additions & 2 deletions test/typings/max.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assert, number, max } from '../../src';
import { test } from '../index.test';
import { assert, number, max } from '../../src/index.js';
import { test } from '../index.test.js';

test<number>((value) => {
assert(value, max(number(), 0));
Expand Down
4 changes: 2 additions & 2 deletions test/typings/min.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assert, number, min } from '../../src';
import { test } from '../index.test';
import { assert, number, min } from '../../src/index.js';
import { test } from '../index.test.js';

test<number>((value) => {
assert(value, min(number(), 0));
Expand Down
4 changes: 2 additions & 2 deletions test/typings/never.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assert, never } from '../../src';
import { test } from '../index.test';
import { assert, never } from '../../src/index.js';
import { test } from '../index.test.js';

test<never>((value) => {
assert(value, never());
Expand Down
4 changes: 2 additions & 2 deletions test/typings/nonempty.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assert, nonempty, string, array, map, set } from '../../src';
import { test } from '../index.test';
import { assert, nonempty, string, array, map, set } from '../../src/index.js';
import { test } from '../index.test.js';

test<string>((value) => {
assert(value, nonempty(string()));
Expand Down
4 changes: 2 additions & 2 deletions test/typings/nullable.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assert, nullable, string, object, enums } from '../../src';
import { test } from '../index.test';
import { assert, nullable, string, object, enums } from '../../src/index.js';
import { test } from '../index.test.js';

test<string | null>((value) => {
assert(value, nullable(string()));
Expand Down
4 changes: 2 additions & 2 deletions test/typings/number.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assert, number } from '../../src';
import { test } from '../index.test';
import { assert, number } from '../../src/index.js';
import { test } from '../index.test.js';

test<number>((value) => {
assert(value, number());
Expand Down
4 changes: 2 additions & 2 deletions test/typings/object.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assert, object, number, string } from '../../src';
import { test } from '../index.test';
import { assert, object, number, string } from '../../src/index.js';
import { test } from '../index.test.js';

test<Record<string, unknown>>((value) => {
assert(value, object());
Expand Down
Loading