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(deps): update dependency chai to v5 #544

Merged
merged 2 commits into from
Apr 30, 2024
Merged
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
5 changes: 5 additions & 0 deletions .changeset/unlucky-llamas-reply.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"generic-type-guard": minor
---

Add ESM support via a dual-package
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ dist
coverage
reports/mutation
.eslintrc.js
/generic-type-guard.*
65 changes: 0 additions & 65 deletions .eslintrc.js

This file was deleted.

4 changes: 4 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"root": true,
"extends": ["@mscharley", "@mscharley/eslint-config/node"]
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ reports/
coverage/
.vscode/settings.json
/temp
/generic-type-guard.*

lerna-debug.log
yarn-error.log
5 changes: 3 additions & 2 deletions .mocharc.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require:
- ts-node/register
- source-map-support/register
- source-map-support/register.js
loader:
- ts-node/esm
watch-extensions:
- ts
6 changes: 1 addition & 5 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
src/**/*
dist/**/*.spec.js
dist/**/*.spec.d.js
dist/**/*.d.ts
dist/**/*.d.ts.map
!dist/generic-type-guard.d.ts
dist/**/*
.editorconfig
.gitignore
.nvmrc
Expand Down
29 changes: 14 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

[![npm](https://img.shields.io/npm/v/generic-type-guard.svg)](https://www.npmjs.com/package/generic-type-guard)
[![CircleCI](https://img.shields.io/circleci/project/github/mscharley/generic-type-guard.svg)](https://circleci.com/gh/mscharley/generic-type-guard)
[![Codecov](https://img.shields.io/codecov/c/github/mscharley/generic-type-guard.svg)](https://codecov.io/gh/mscharley/generic-type-guard)

**Source:** [https://github.com/mscharley/generic-type-guard](https://github.com/mscharley/generic-type-guard)
**Author:** Matthew Scharley
Expand Down Expand Up @@ -46,18 +45,18 @@ you must define your typeguards in the following way to make them the most effec

```typescript
interface Foo {
foo: string;
bar: number;
foo: string;
bar: number;
}

// this fails.
const isBrokenFoo: tg.TypeGuard<Foo> = tg.isRecord('foo', tg.isString);

// this works.
const isFoo: tg.TypeGuard<Foo> = new tg.IsInterface()
.withProperty('foo', tg.isString)
.withProperty('bar', tg.isNumber)
.get();
.withProperty('foo', tg.isString)
.withProperty('bar', tg.isNumber)
.get();

// This works around the gotchas explained below but has other issues, especially with complex types.
// All guarantees are void if you use this format.
Expand All @@ -75,14 +74,14 @@ Some examples:
import * as tg from 'generic-type-guard';

export const isComplexInterface = new tg.IsInterface()
.withProperties({
str: tg.isString,
num: tg.isNumber,
b: tg.isBoolean,
maybeString: tg.isOptional(tg.isString),
nullableString: tg.isNullable(tg.isString),
})
.get();
.withProperties({
str: tg.isString,
num: tg.isNumber,
b: tg.isBoolean,
maybeString: tg.isOptional(tg.isString),
nullableString: tg.isNullable(tg.isString),
})
.get();
export type ComplexInterface = tg.GuardedType<typeof isComplexInterface>;
```

Expand Down Expand Up @@ -114,7 +113,7 @@ Perhaps more insidiously:

```typescript
interface Foo {
foo?: string;
foo?: string;
}

const isFoo: tg.TypeGuard<Foo> = tg.isRecord('foo', tg.isString);
Expand Down
Loading
Loading