Skip to content

Commit

Permalink
feat: exposing KeySetTypesEnumValues + deps upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
eturino committed Oct 23, 2020
1 parent 8604e8f commit 4affd1d
Show file tree
Hide file tree
Showing 6 changed files with 1,117 additions and 1,495 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ All KeySet expose a `type` property that will return a member of the `KeySetType
- `KeySetNone` returns `NONE`
- `KeySetSome` returns `SOME`

The types are also exposed as a union of strings TypeScript type `KeySetTypesEnumValues`.

#### `type` in v1.x vs v2.x

`v2.0` changed the values returned by `type`, make them SCREAMING_SNAKE_CASE, which allows for easier integration with GraphQL enums.
Expand Down
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,19 @@
"npm-run-all": "^4.1.5",
"open-cli": "^6.0.1",
"prettier": "^2.0.4",
"standard-version": "^8.0.0",
"standard-version": "^9.0.0",
"strip-json-comments": "^3.0.1",
"trash-cli": "^3.0.0",
"ts-enum-util": "^4.0.2",
"ts-jest": "^26.1.0",
"ts-loader": "^7.0.0",
"ts-node": "^8.3.0",
"ts-loader": "^8.0.6",
"ts-node": "^9.0.0",
"tslint": "^6.1.1",
"tslint-config-prettier": "^1.18.0",
"tslint-immutable": "^6.0.1",
"typedoc": "^0.17.4",
"typedoc": "^0.19.2",
"typedoc-themes-color": "^0.0.10",
"typescript": "^3.8.3"
"typescript": "^4.0.3"
},
"config": {
"commitizen": {
Expand Down
2 changes: 2 additions & 0 deletions src/lib/key-set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
KeySetSerialized,
KeySetSomeSerialized,
KeySetTypes,
KeySetTypesEnumValues,
} from "./key-set/-base";
import { all, KeySetAll } from "./key-set/all";
import { allExceptSome, allExceptSomeForced, KeySetAllExceptSome } from "./key-set/all-except-some";
Expand Down Expand Up @@ -83,6 +84,7 @@ export {
InvalidEmptySetError,
// enums
KeySetTypes,
KeySetTypesEnumValues,
// serialize functions
serializeKeySet,
parseKeySet,
Expand Down
2 changes: 2 additions & 0 deletions src/lib/key-set/-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export enum KeySetTypes {
some = "SOME",
}

export type KeySetTypesEnumValues = "ALL" | "ALL_EXCEPT_SOME" | "NONE" | "SOME";

export type KeySetAllSerialized<T extends Key = Key> =
| { type: KeySetTypes.all }
| { type: KeySetTypes.all; elements: EmptyArray<T> };
Expand Down
13 changes: 13 additions & 0 deletions src/lib/key-set/__tests__/base.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { KeySetTypesEnumValues, KeySetTypes } from "../../..";
import { $enum } from "ts-enum-util";

function acceptEnumValue(_x: KeySetTypesEnumValues): boolean {
return true;
}

test("KeySetTypesEnumValues and KeySetTypes are compatible", () => {
// if the types are not compatible TS will complain
$enum(KeySetTypes).forEach((value) => {
expect(acceptEnumValue(value)).toBeTruthy();
});
});
Loading

0 comments on commit 4affd1d

Please sign in to comment.