New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

inferred-types

Package Overview
Dependencies
Maintainers
1
Versions
250
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

inferred-types - npm Package Compare versions

Comparing version 0.20.0 to 0.22.0

.github/workflows/main.yml

12

.vscode/settings.json
{
"git.ignoreLimitWarning": true,
"editor.formatOnSave": true
}
"editor.formatOnSave": true,
"cSpell.words": [
"Aint",
"Dasherize",
"dasherized",
"ruleset",
"tokei",
"Uncapitalize"
]
}

77

dist/index.js

@@ -0,23 +1,6 @@

"use strict";
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
var __export = (target, all) => {

@@ -27,15 +10,11 @@ for (var name in all)

};
var __reExport = (target, module2, copyDefault, desc) => {
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
for (let key of __getOwnPropNames(module2))
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return target;
return to;
};
var __toCommonJS = /* @__PURE__ */ ((cache) => {
return (module2, temp) => {
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
};
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

@@ -48,3 +27,2 @@ // src/index.ts

FluentConfigurator: () => FluentConfigurator,
KeyStorage: () => KeyStorage,
Model: () => Model,

@@ -102,5 +80,5 @@ MutationIdentity: () => MutationIdentity,

valueTypes: () => valueTypes,
valuesOfProp: () => valuesOfProp,
withValue: () => withValue
});
module.exports = __toCommonJS(src_exports);

@@ -206,3 +184,3 @@ // src/Mutation/MutationFunction.ts

const key = i;
return __spreadProps(__spreadValues({}, acc), { [key]: transform(input, key) });
return { ...acc, [key]: transform(input, key) };
}, {});

@@ -231,3 +209,3 @@ }

return strings.reduce((acc, str) => {
acc = __spreadProps(__spreadValues({}, acc), { [str]: true });
acc = { ...acc, [str]: true };
return acc;

@@ -237,6 +215,2 @@ }, {});

// src/utility/dictionary/valuesOfProp.ts
function valuesOfProp() {
}
// src/utility/dictionary/kv/dictToKv.ts

@@ -261,3 +235,3 @@ function dictToKv(obj, _makeTuple = false) {

const config = configuration();
const updated = __spreadValues(__spreadValues({}, config), keyValue);
const updated = { ...config, ...keyValue };
configuration = () => updated;

@@ -286,3 +260,3 @@ return updated;

const keyValue = { [key]: value };
const updated = __spreadValues(__spreadValues({}, keyValue), current);
const updated = { ...keyValue, ...current };
return api2(updated);

@@ -301,14 +275,2 @@ },

// src/utility/state/KeyStorage.ts
function KeyStorage() {
const api2 = (state) => ({
add: (...store) => {
return api2([...state, ...store]);
},
remove: (key) => api2(state.filter((i) => i !== key)),
done: () => state
});
return api2([]);
}
// src/utility/dictionary/kv/filterDictArray.ts

@@ -345,4 +307,2 @@ function filterDictArray(dictArr, cb) {

throw new Error("not implemented");
return (_groupBy) => {
};
}

@@ -358,5 +318,5 @@

const transform = (arr) => {
const result = unique !== false ? arr.reduce((acc, v) => __spreadProps(__spreadValues({}, acc), { [v[prop]]: v }), {}) : arr.reduce((acc, v) => {
const result = unique !== false ? arr.reduce((acc, v) => ({ ...acc, [v[prop]]: v }), {}) : arr.reduce((acc, v) => {
const existing = acc[v[prop]] || [];
return __spreadProps(__spreadValues({}, acc), { [v[prop]]: [...existing, v] });
return { ...acc, [v[prop]]: [...existing, v] };
}, {});

@@ -371,3 +331,3 @@ return result;

return (wide = {}) => {
return literal2 ? __spreadValues(__spreadValues({}, wide), literal2) : wide;
return literal2 ? { ...wide, ...literal2 } : wide;
};

@@ -381,3 +341,3 @@ }

function idLiteral(o) {
return __spreadProps(__spreadValues({}, o), { id: o.id });
return { ...o, id: o.id };
}

@@ -651,3 +611,2 @@ function nameLiteral(o) {

}
module.exports = __toCommonJS(src_exports);
// Annotate the CommonJS export names for ESM import in node:

@@ -658,3 +617,2 @@ 0 && (module.exports = {

FluentConfigurator,
KeyStorage,
Model,

@@ -712,4 +670,3 @@ MutationIdentity,

valueTypes,
valuesOfProp,
withValue
});
{
"name": "inferred-types",
"version": "0.20.0",
"version": "0.22.0",
"description": "Functions which provide useful type inference on TS projects",

@@ -16,40 +16,48 @@ "license": "MIT",

"build:force": "run-s clean autoindex build:bundle",
"build:bundle": "npx tsup src/index.ts --dts --format='esm,cjs'",
"build:bundle": "npx tsup src/index.ts --dts --format=esm,cjs --clean",
"watch": "run-p watch:*",
"watch:autoindex": "npx dd autoindex --watch",
"watch:bundle": "npx tsup src/index.ts --dts --format='esm,cjs' --watch",
"watch:bundle": "npx tsup src/index.ts --dts --format=esm,cjs --watch",
"clean": "rimraf dist/**/*",
"lint": "eslint src/**/*.ts --fix && tsc --noEmit ",
"lint:full": "eslint src/**/*.ts && eslint test/**/*.ts && tsc --noEmit",
"test": "jest"
"test": "vitest",
"test:ci": "vitest run",
"audit:fix": "pnpm audit --fix",
"release": "run-s lint release:latest test:ci audit:fix release:bump",
"release:latest": "pnpm install",
"release:bump": "bumpp"
},
"devDependencies": {
"@type-challenges/utils": "~0.1.1",
"@types/jest": "^27.4.0",
"@types/node": "^14.18.5",
"@typescript-eslint/eslint-plugin": "^5.9.1",
"@typescript-eslint/parser": "^5.9.1",
"@types/node": "^16.11.45",
"@typescript-eslint/eslint-plugin": "^5.30.7",
"@typescript-eslint/parser": "^5.30.7",
"bumpp": "^8.2.1",
"common-types": "^1.30.0",
"cross-env": "^7.0.3",
"dd": "^0.18.0",
"dotenv": "^10.0.0",
"eslint": "^8.6.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-prettier": "^4.0.0",
"dd": "^0.21.0",
"dotenv": "^16.0.1",
"eslint": "^8.20.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-promise": "^6.0.0",
"eslint-plugin-unicorn": "^40.0.0",
"jest": "^27.4.7",
"jest-extended": "~1.2.0",
"npm-run-all": "~4.1.5",
"prettier": "~2.5.1",
"prettier": "~2.7.1",
"rimraf": "^3.0.2",
"ts-jest": "^27.1.2",
"ts-node": "^10.4.0",
"tsup": "^5.11.11",
"typescript": "^4.5.4"
"tsup": "^6.1.3",
"typescript": "^4.7.4",
"vite": "^3.0.2",
"vitest": "^0.19.0"
},
"dependencies": {
"common-types": "^1.31.0"
"common-types": "^1.31.1"
},
"pnpm": {
"overrides": {
"simple-git@<3.3.0": ">=3.3.0",
"simple-git@<3.5.0": ">=3.5.0"
}
}
}
}

@@ -1,2 +0,2 @@

import { Narrowable } from "~/types/Narrowable";
import { Narrowable } from "src/types/Narrowable";

@@ -3,0 +3,0 @@ export type ValueTuple = [type: any, narrowable: boolean];

@@ -1,3 +0,3 @@

import { PascalCase } from "~/types/alphabetic";
import { PascalCase } from "./PascalCase";
export type CamelCase<S extends string> = Uncapitalize<PascalCase<S>>;

@@ -1,2 +0,3 @@

import type { NonAlpha, Replace } from "~/types";
import { Replace } from "../string-literals";
import { NonAlpha } from "./alpha-characters";

@@ -6,3 +7,7 @@ /**

*/
export type StripLeftNonAlpha<S extends string> = S extends `${infer First}${infer Rest}` ? First extends NonAlpha ? StripLeftNonAlpha<Rest> : S : never;
export type StripLeftNonAlpha<S extends string> = S extends `${infer First}${infer Rest}`
? First extends NonAlpha
? StripLeftNonAlpha<Rest>
: S
: never;

@@ -20,2 +25,1 @@ /**

: Capitalize<T>;
/* eslint-disable @typescript-eslint/no-unused-vars */
import { DashUppercase, LowerAllCaps } from "~/types";
import { Trim } from "../string-literals";
import { DashUppercase } from "./DashUppercase";
import { LowerAllCaps } from "./LowerAllCaps";
/**
* Converts a string literal into a _dasherized_ format while ignoring _exterior_ whitepace.
*
* Converts a string literal into a _dasherized_ format while ignoring _exterior_ whitespace.
*
* ```ts

@@ -17,5 +19,6 @@ * // "foo-bar"

*/
export type Dasherize<S extends string> = string extends S ? string :
DashUppercase<Trim<LowerAllCaps<S>>> extends `${infer Begin}${"_" | " "}${infer Rest}`
export type Dasherize<S extends string> = string extends S
? string
: DashUppercase<Trim<LowerAllCaps<S>>> extends `${infer Begin}${"_" | " "}${infer Rest}`
? Dasherize<`${Lowercase<Begin>}-${Rest}`>
: Lowercase<DashUppercase<Uncapitalize<Trim<LowerAllCaps<S>>>>>;

@@ -1,2 +0,2 @@

import type { Dasherize } from "~/types/alphabetic";
import { Dasherize } from "./Dasherize";

@@ -3,0 +3,0 @@ /**

/* eslint @typescript-eslint/no-unused-vars: "off" */
import type { LowerAllCaps, Trim } from "~/types";
import { Trim } from "../string-literals";
import { LowerAllCaps } from "./LowerAllCaps";
type Delimiter = "_" | "-" | " ";

@@ -5,0 +7,0 @@

/* eslint @typescript-eslint/no-unused-vars: "off" */
import type { DashUppercase, LowerAllCaps, Trim } from "~/types";
import { Trim } from "../string-literals";
import { DashUppercase } from "./DashUppercase";
import { LowerAllCaps } from "./LowerAllCaps";

@@ -19,5 +21,8 @@ /** convert space to dash */

* ``` */
export type SnakeCase<S extends string> = string extends S ? string :
DashUppercase<Uncapitalize<SpaceToDash<Trim<LowerAllCaps<S>>>>> extends `${infer Begin}${"-"}${infer Rest}`
export type SnakeCase<S extends string> = string extends S
? string
: DashUppercase<
Uncapitalize<SpaceToDash<Trim<LowerAllCaps<S>>>>
> extends `${infer Begin}${"-"}${infer Rest}`
? SnakeCase<`${Lowercase<Begin>}_${Rest}`>
: Lowercase<DashUppercase<Uncapitalize<Trim<LowerAllCaps<S>>>>>;
// #autoindex
// #region autoindexed files
// index last changed at: 6th Jun, 2022, 03:36 AM ( GMT-7 )
// hash-code: 1f3a5076
// index last changed at: 7th Jul, 2022, 02:28 PM ( GMT-7 )
// hash-code: 6e90bc78
// file exports
export * from "./DictPartialApplication";
export * from "./DictPrependWithFn";
export * from "./DictReturnValues";
export * from "./Get";
export * from "./NotEmptyObject";
export * from "./RequireProps";
export * from "./SameKeys";
export * from "./props";

@@ -10,0 +15,0 @@ // #endregion

@@ -0,3 +1,12 @@

/**
* Recursively goes over an object based structure and tries to reduce
* it down to just a simple key/value type.
*/
export type ExpandRecursively<T> = T extends object
? { [K in keyof T]: ExpandRecursively<T[K]> }
? T extends (...args: any[]) => any
// Functions should be treated like any other non-object value
// but will/can identify as an object in JS
? T
: { [K in keyof T]: ExpandRecursively<T[K]> }
: T;
// #autoindex
// #region autoindexed files
// index last changed at: 1st Jan, 2022, 03:27 PM ( GMT-8 )
// hash-code: 7e6e29a0
// index last changed at: 7th Jul, 2022, 01:15 PM ( GMT-7 )
// hash-code: f976e182

@@ -25,2 +25,3 @@ // file exports

export * from "./Retain";
export * from "./SimplifyObject";
export * from "./Transformer";

@@ -31,3 +32,2 @@ export * from "./TypeGuard";

export * from "./maybe";
export * from "./props";
export * from "./ruleset-types";

@@ -40,2 +40,3 @@ export * from "./runtime";

export * from "./fluent/index";
export * from "./functions/index";
export * from "./kv/index";

@@ -42,0 +43,0 @@ export * from "./lists/index";

@@ -1,4 +0,4 @@

import type { TypeCondition } from "~/utility/runtime/ifTypeOf";
import { OptionalKeys } from "./props";
import { SameKeys } from "./type-conversion/SameKeys";
import { TypeCondition } from "src/utility/runtime";
import { OptionalKeys } from "./dictionary/props";
import { SameKeys } from "./dictionary/SameKeys";

@@ -5,0 +5,0 @@ /**

@@ -1,5 +0,5 @@

import { TypeGuard } from "~/types";
// runtime types relate to the types coming out of the runtime utilities
import { TypeGuard } from "./TypeGuard";
export type RuntimeType<T> = {

@@ -17,17 +17,17 @@ __kind: "type";

/**
* Provides the _type_ to the type system when used with `typeof`.
*
* ```ts
* const t = number();
* // number
* type T = typeof t.type;
* ```
*
* **Note:** _the runtime system will get a string equivalent name:_
* ```ts
* const t = number();
* // "number"
* console.log(t.type);
* ```
*/
* Provides the _type_ to the type system when used with `typeof`.
*
* ```ts
* const t = number();
* // number
* type T = typeof t.type;
* ```
*
* **Note:** _the runtime system will get a string equivalent name:_
* ```ts
* const t = number();
* // "number"
* console.log(t.type);
* ```
*/
type: Record<P, T["type"]>;

@@ -40,2 +40,2 @@ is: TypeGuard<Record<P, T["type"]>>;

typeGuard?: TypeGuard<T>;
} & T;
} & T;

@@ -1,2 +0,3 @@

import type { Replace, TrimLeft } from "~/types";
import { Replace } from "./Replace";
import { TrimLeft } from "./TrimLeft";

@@ -10,2 +11,4 @@ /**

*/
export type LeftWhitespace<S extends string> = string extends S ? string : Replace<S, TrimLeft<S>, "">;
export type LeftWhitespace<S extends string> = string extends S
? string
: Replace<S, TrimLeft<S>, "">;

@@ -1,2 +0,3 @@

import type { Replace, TrimRight } from "~/types";
import { Replace } from "./Replace";
import { TrimRight } from "./TrimRight";

@@ -10,2 +11,4 @@ /**

*/
export type RightWhitespace<S extends string> = string extends S ? string : Replace<S, TrimRight<S>, "">;
export type RightWhitespace<S extends string> = string extends S
? string
: Replace<S, TrimRight<S>, "">;

@@ -1,2 +0,2 @@

import { SameKeys } from "./type-conversion/SameKeys";
import { SameKeys } from "./dictionary/SameKeys";

@@ -3,0 +3,0 @@ /**

@@ -1,6 +0,7 @@

import type { Keys, UnionToTuple } from "~/types";
import { Keys } from "../Keys";
import { UnionToTuple } from "../type-conversion/UnionToTuple";
/**
* Returns the _first_ key in an object.
*
*
* **Note:** key order is not guarenteed so typically this is used

@@ -10,2 +11,1 @@ * for a key/value pair where only one key is expected

export type FirstKey<T extends object> = UnionToTuple<Keys<T>>[0];

@@ -1,4 +0,4 @@

import { ExpandRecursively, UnionToIntersection } from "~/types";
import { ExpandRecursively } from "../ExpandRecursively";
import { UnionToIntersection } from "../type-conversion";
/**

@@ -12,3 +12,4 @@ * Typescript utility which receives `T` as shape which resembles `DictArray<D>`

*/
export type FromDictArray<T extends [string, Record<string, unknown>][]> =
ExpandRecursively<UnionToIntersection<T[number][1]>>;
export type FromDictArray<T extends [string, Record<string, unknown>][]> = ExpandRecursively<
UnionToIntersection<T[number][1]>
>;
// #autoindex
// #region autoindexed files
// index last changed at: 6th Jun, 2022, 03:36 AM ( GMT-7 )
// hash-code: ac142b94
// index last changed at: 6th Jun, 2022, 10:18 AM ( GMT-7 )
// hash-code: b346a5f3
// file exports
export * from "./SameKeys";
export * from "./TupleToUnion";
export * from "./UnionToIntersection";
export * from "./UnionToTuple";
export * from "./UnwrapValue";
export * from "./WrapValue";

@@ -15,0 +12,0 @@ // #endregion

@@ -1,9 +0,10 @@

import { Narrowable } from "~/types";
import { Narrowable } from "src/types/Narrowable";
export const api = <N extends Narrowable, TPrivate extends Readonly<Record<any, N>>>(priv: TPrivate) => <TPublic extends object>(pub: TPublic) => {
const surface = () => pub as TPublic;
surface.prototype.priv = () => priv as TPrivate;
export const api =
<N extends Narrowable, TPrivate extends Readonly<Record<any, N>>>(priv: TPrivate) =>
<TPublic extends object>(pub: TPublic) => {
const surface = () => pub as TPublic;
surface.prototype.priv = () => priv as TPrivate;
return surface;
};
return surface;
};
/* eslint-disable no-use-before-define */
import { keys } from "~/utility/keys";
import { SameKeys, Transformer } from "~/types";
import { SameKeys } from "src/types/dictionary";
import { Transformer } from "src/types/Transformer";
import { keys } from "../keys";
/**

@@ -16,7 +18,6 @@ * Takes a dictionary of type `I` and converts it to a dictionary of type `O` where

) {
return keys(input).reduce((acc, i) => {
const key = i as string & keyof I;
return {...acc, [key]: transform(input, key)};
return { ...acc, [key]: transform(input, key) };
}, {} as O);
}

@@ -1,2 +0,3 @@

import { KeyValue, Narrowable } from "~/types";
import { KeyValue } from "src/types/kv";
import { Narrowable } from "src/types/Narrowable";
import { keys } from "../keys";

@@ -7,3 +8,3 @@

*
* Provides an _interable_ over the passed in dictionary object where each iteration
* Provides an _iterable_ over the passed in dictionary object where each iteration
* provides a tuple of `[ key, value ]` which preserve type literals.

@@ -18,4 +19,7 @@ *

*/
export function entries<N extends Narrowable, T extends Record<string, N>, I extends KeyValue<T, keyof T>>(obj: T) {
export function entries<
N extends Narrowable,
T extends Record<string, N>,
I extends KeyValue<T, keyof T>
>(obj: T) {
const iterable = {

@@ -31,2 +35,2 @@ *[Symbol.iterator]() {

return iterable;
}
}
// #autoindex
// #region autoindexed files
// index last changed at: 1st Jan, 2022, 03:27 PM ( GMT-8 )
// hash-code: c3587066
// index last changed at: 7th Jul, 2022, 01:47 PM ( GMT-7 )
// hash-code: dd2bf50a

@@ -12,3 +12,2 @@ // file exports

export * from "./strArrayToDict";
export * from "./valuesOfProp";
// directory exports

@@ -15,0 +14,0 @@ export * from "./kv/index";

@@ -1,4 +0,6 @@

import { Mutable, Narrowable, UnionToTuple } from "~/types";
import { KvFrom } from "~/types/kv/KvFrom";
import { keys } from "~/utility/keys";
import { KvFrom } from "src/types/kv";
import { Mutable } from "src/types/Mutable";
import { Narrowable } from "src/types/Narrowable";
import { UnionToTuple } from "src/types/type-conversion";
import { keys } from "src/utility/keys";

@@ -5,0 +7,0 @@ /**

@@ -1,3 +0,3 @@

import type { DictArray, DictArrayFilterCallback } from "~/types";
import { Configurator, IConfigurator } from "~/utility/state";
import { DictArray, DictArrayFilterCallback } from "src/types/tuples";
import { Configurator, IConfigurator } from "src/utility/state";

@@ -14,8 +14,7 @@ export interface Array<T> {

T extends object,
C extends DictArrayFilterCallback<keyof T, T, true | false>,
>(dictArr: DictArray<T>, cb: C) {
C extends DictArrayFilterCallback<keyof T, T, true | false>
>(dictArr: DictArray<T>, cb: C) {
const state: IConfigurator = Configurator();
const updated = dictArr.filter(i => {
const updated = dictArr.filter((i) => {
const [k, v] = i;

@@ -34,2 +33,1 @@ const keep = cb(k, v);

}

@@ -1,2 +0,3 @@

import { ExpandRecursively, Narrowable } from "~/types";
import { ExpandRecursively } from "src/types/ExpandRecursively";
import { Narrowable } from "src/types/Narrowable";

@@ -8,7 +9,11 @@ /**

* > note: the value will be inferred but if you need to constrain it
* > to a narrower type then both inferrences will break and you should
* > to a narrower type then both inferences will break and you should
* > instead use `KV2` to get this capability.
*/
export function kv<K extends string, N extends Narrowable, V extends Record<any, N> | boolean | number | string | null | undefined>(key: K, value: V) {
export function kv<
K extends string,
N extends Narrowable,
V extends Record<any, N> | boolean | number | string | null | undefined
>(key: K, value: V) {
return { [key]: value } as ExpandRecursively<Record<K, V>>;
}

@@ -1,3 +0,4 @@

import { Mutable, Narrowable } from "~/types";
import { DictFromKv } from "~/types/kv";
import { DictFromKv } from "src/types/kv";
import { Mutable } from "src/types/Mutable";
import { Narrowable } from "src/types/Narrowable";

@@ -4,0 +5,0 @@ /**

@@ -1,2 +0,2 @@

import { Narrowable } from "~/types";
import { Narrowable } from "src/types/Narrowable";
import { entries } from "./entries";

@@ -6,5 +6,5 @@

* **mapValues**
*
*
* Maps over a dictionary, preserving the keys but allowing the values to be mutated.
*
*
* ```ts

@@ -16,3 +16,6 @@ * const colors = { red: 4, blue: 2, green: 3 };

*/
export function mapValues<N extends Narrowable, T extends Record<string, N>, V>(obj: T, valueMapper: (k: T[keyof T]) => V) {
export function mapValues<N extends Narrowable, T extends Record<string, N>, V>(
obj: T,
valueMapper: (k: T[keyof T]) => V
) {
return Object.fromEntries(

@@ -22,2 +25,2 @@ // TODO: fix the type error with v and valueMapper

) as { [K in keyof T]: V };
}
}

@@ -1,4 +0,3 @@

import { ExpandRecursively } from "~/types/ExpandRecursively";
import { ExpandRecursively } from "src/types/ExpandRecursively";
/**

@@ -5,0 +4,0 @@ * converts an array of strings `["a", "b", "c"]` into a more type friendly

@@ -1,2 +0,3 @@

import { Keys, Length } from "~/types";
import { Keys } from "src/types/Keys";
import { Length } from "src/types/Length";

@@ -7,7 +8,10 @@ /**

export function keys<T extends {}, W extends readonly string[]>(obj: T, ...without: W) {
const v = without.length > 0
? Object.keys(obj).filter(k => !without.includes(k)) as unknown as Array<Exclude<keyof T, Keys<W>>>
: Object.keys(obj) as unknown as Array<keyof T>;
const v =
without.length > 0
? (Object.keys(obj).filter((k) => !without.includes(k)) as unknown as Array<
Exclude<keyof T, Keys<W>>
>)
: (Object.keys(obj) as unknown as Array<keyof T>);
return v as unknown as Length<W> extends 0 ? Array<keyof T> : Array<Exclude<keyof T, Keys<W>>>;
}

@@ -1,3 +0,2 @@

import { Narrowable } from "~/types";
// import { UniqueForProp } from "~/types/lists/UniqueForProp";
import { Narrowable } from "src/types/Narrowable";

@@ -14,10 +13,4 @@ /**

*/
export function groupBy<T extends Record<string, Narrowable>, K extends keyof T & string>(
_data: Readonly<T[]>
) {
export function groupBy<T extends Record<string, Narrowable>>(_data: Readonly<T[]>) {
throw new Error("not implemented");
return (_groupBy: K) => {
// type _GroupedBy = UniqueForProp<typeof data, K>;
// const _output = {} as Record<GroupedBy, Narrowable>;
};
}

@@ -1,21 +0,27 @@

import { Narrowable } from "~/types/Narrowable";
import { Narrowable } from "src/types/Narrowable";
/**
* **UniqueDictionary**
*
*
* A dictionary converted by `arrayToObject()` which expects each key `S` to have a only a
* single/unique value.
*/
export type UniqueDictionary<S extends PropertyKey, N extends Narrowable, T extends Record<keyof T, N> & Record<S, any>> = { [V in T as V[S]]: V };
export type UniqueDictionary<
S extends PropertyKey,
N extends Narrowable,
T extends Record<keyof T, N> & Record<S, any>
> = { [V in T as V[S]]: V };
/**
* **GeneralDictionary**
*
*
* A dictionary converted by `arrayToObject()` which expects each key `S` to have an
* array of values.
*/
export type GeneralDictionary<S extends PropertyKey, N extends Narrowable, T extends Record<keyof T, N> & Record<S, any>> = { [V in T as V[S]]: V[] };
export type GeneralDictionary<
S extends PropertyKey,
N extends Narrowable,
T extends Record<keyof T, N> & Record<S, any>
> = { [V in T as V[S]]: V[] };
export type ArrayConverter<S extends PropertyKey, U extends boolean> =

@@ -31,9 +37,8 @@ /**

/**
* Converts an array of objects into a dictionary by picking a property name contained
* by all objects and using that as the key to the dictionary.
*
*
* ```ts
* const arr = [
* const arr = [
* { kind: "color", favorite: "blue", likes: 100 },

@@ -44,30 +49,26 @@ * { kind: "song", favorite: "some song", likes: 25 }

* ```
*
*
* This will produce a dictionary with keys of `color` and `song`.
*/
export function arrayToObject<
S extends PropertyKey,
U extends boolean
>(prop: S, unique?: U) {
export function arrayToObject<S extends PropertyKey, U extends boolean>(prop: S, unique?: U) {
type X = true extends U ? true : false;
/**
* **arrayToObject** - partially applied
*
*
* pass in an array of objects to complete application of arrayToObject()
*/
const transform: ArrayConverter<S, X> = <N extends Narrowable, T extends Record<keyof T, N> & Record<S, any>>(
const transform: ArrayConverter<S, X> = <
N extends Narrowable,
T extends Record<keyof T, N> & Record<S, any>
>(
arr: readonly T[]
): true extends X ? UniqueDictionary<S, N, T> : GeneralDictionary<S, N, T> => {
const result =
unique !== false
? arr.reduce((acc, v) => ({ ...acc, [v[prop]]: v }), {} as UniqueDictionary<S, N, T>)
: arr.reduce((acc, v) => {
const existing = acc[v[prop] as T[S]] || [];
return { ...acc, [v[prop]]: [...existing, v] };
}, {} as GeneralDictionary<S, N, T>);
const result = unique !== false
? arr.reduce(
(acc, v) => ({ ...acc, [v[prop]]: v }), {} as UniqueDictionary<S, N, T>
)
: arr.reduce(
(acc, v) => {
const existing = acc[v[prop] as T[S]] || [];
return { ...acc, [v[prop]]: [...existing, v] };
}, {} as GeneralDictionary<S, N, T>
);
// type cast based on `U`

@@ -80,2 +81,1 @@ return result as true extends X ? UniqueDictionary<S, N, T> : GeneralDictionary<S, N, T>;

}

@@ -1,13 +0,13 @@

import { ExpandRecursively, Narrowable } from "~/types";
import { ExpandRecursively } from "src/types/ExpandRecursively";
import { Narrowable } from "src/types/Narrowable";
/**
* Build a _type_ from two run-time dictionaries.
*
*
* 1. The _first_ -- which is optional -- is interpreted as a _literal_ type definition
* 2. The _second_ dictionary is interpreted as a "wide" definition of prop types
*/
export function defineType<
N extends Narrowable,
TLiteral extends Record<string, N>
>(literal: TLiteral = {} as TLiteral) {
export function defineType<N extends Narrowable, TLiteral extends Record<string, N>>(
literal: TLiteral = {} as TLiteral
) {
/**

@@ -14,0 +14,0 @@ * Add any key/value pairs which you want to have _wide_ types associated;

@@ -1,2 +0,3 @@

import { Narrowable } from "~/types/Narrowable";
import { Narrowable } from "src/types/Narrowable";
/**

@@ -9,2 +10,4 @@ * An identity function for any type, with the goal of preserving literal type information

T extends Record<any, N> | number | string | boolean | symbol | undefined | null
>(v: T) => v;
>(
v: T
) => v;
/* eslint-disable no-use-before-define */
import { Narrowable } from "~/types";
import { Narrowable } from "src/types/Narrowable";

@@ -42,4 +42,4 @@ /**

* values on the object.
*
* > Note: this addresses this [a known TS gap](https://github.com/microsoft/TypeScript/issues/30680).
*
* > Note: this addresses this [a known TS gap](https://github.com/microsoft/TypeScript/issues/30680).
* > Hopefully at some point this will be addressed in the language.

@@ -46,0 +46,0 @@ */

/* eslint-disable no-use-before-define */
import type { Narrowable } from "~/types";
import { Narrowable } from "src/types/Narrowable";
// TODO: get ruleset functionality working!

@@ -18,17 +19,19 @@

* **ruleSet**
*
*
* Defines a ruleset composed of _dynamic_ and _static_ boolean operators.
*
*
* - the first function call defines _dynamic_ props (_optional_)
* - the second function call defines static values
*
*
* ```ts
* const rs = ruleSet(
* const rs = ruleSet(
* r => r.state()( { maybe: r => r.extends({ foo: 1 }) })
* )(
* { color: true, age: false }
* )(
* { color: true, age: false }
* );
* ```
*/
export function ruleSet<N extends Narrowable, TState extends Record<keyof TState, N>>(defn?: TState) {
export function ruleSet<N extends Narrowable, TState extends Record<keyof TState, N>>(
defn?: TState
) {
// return <

@@ -41,2 +44,1 @@ // TStatic extends { [K in keyof TStatic]: Readonly<true | false> },

}

@@ -1,2 +0,2 @@

import { Narrowable } from "~/types";
import { Narrowable } from "src/types/Narrowable";

@@ -3,0 +3,0 @@ export type Condition<TInput extends Narrowable, TResult extends boolean> = (

@@ -1,3 +0,3 @@

import { Narrowable } from "~/types";
import { IsBoolean } from "~/utility";
import { Narrowable } from "src/types/Narrowable";
import { IsBoolean } from "./isBoolean";

@@ -4,0 +4,0 @@ export type IsFalse<T extends Narrowable> = IsBoolean<T> extends true

@@ -1,2 +0,2 @@

import { FunctionType } from "~/types";
import { FunctionType } from "src/types/FunctionType";

@@ -14,3 +14,3 @@ export type IsFunction<T> = T extends FunctionType ? true : false;

* Note: the runtime `typeof [variable]` will correctly say "function" when a function is
* encounted but if that function also has object types defined then the type will be a big
* encountered but if that function also has object types defined then the type will be a big
* and ugly union type. This function will give you a proper boolean value in both cases.

@@ -17,0 +17,0 @@ */

@@ -1,2 +0,5 @@

import { FunctionType, Mutable, Narrowable, Not } from "~/types";
import { FunctionType } from "src/types/FunctionType";
import { Mutable } from "src/types/Mutable";
import { Narrowable } from "src/types/Narrowable";
import { Not } from "src/types/Not";

@@ -3,0 +6,0 @@ export type IsObject<T> = Mutable<T> extends Record<string, any>

@@ -1,2 +0,2 @@

import { Narrowable } from "~/types";
import { Narrowable } from "src/types/Narrowable";
import type { IsBoolean } from "./isBoolean";

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

import { Narrowable } from "~/types/Narrowable";
import { Narrowable } from "src/types/Narrowable";
import { keys } from "../keys";

@@ -3,0 +3,0 @@

@@ -1,2 +0,4 @@

import { FunctionType, Narrowable, TypeGuard } from "~/types";
import { FunctionType } from "src/types/FunctionType";
import { Narrowable } from "src/types/Narrowable";
import { TypeGuard } from "src/types/TypeGuard";
import {

@@ -3,0 +5,0 @@ isString,

/* eslint-disable @typescript-eslint/no-unused-vars */
import { ExpandRecursively, Narrowable, WithValue } from "~/types";
import { entries } from "~/utility/dictionary";
import { type, TypeDefinition } from "~/utility/runtime";
import { WithValue } from "src/types/dictionary";
import { ExpandRecursively } from "src/types/ExpandRecursively";
import { Narrowable } from "src/types/Narrowable";
import { entries } from "../dictionary/entries";
import { type, TypeDefinition } from "./type";

@@ -7,0 +9,0 @@ /**

@@ -1,2 +0,3 @@

/* eslint-disable unicorn/consistent-function-scoping */
import { ExpandRecursively } from "src/types/ExpandRecursively";
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;

@@ -11,3 +12,2 @@ function omit<T extends {}, K extends Array<keyof T>>(obj: T, ...removals: K) {

import { ExpandRecursively } from "~/types";
export interface IConfigurator<C = {}> {

@@ -14,0 +14,0 @@ set<V, K extends string, KV = { [U in K]: V }>(

@@ -1,2 +0,2 @@

import type { ExpandRecursively } from "~/types";
import { ExpandRecursively } from "src/types/ExpandRecursively";

@@ -31,3 +31,3 @@ export interface IFluentConfigurator<C> {

set<V, K extends string, KV = { [U in K]: V }>(key: K, value: V) {
const keyValue = ({ [key]: value as V } as unknown) as KV;
const keyValue = { [key]: value as V } as unknown as KV;
const updated = { ...keyValue, ...current };

@@ -34,0 +34,0 @@

// #autoindex
// #region autoindexed files
// index last changed at: 1st Jan, 2022, 03:27 PM ( GMT-8 )
// hash-code: fd5dfde8
// index last changed at: 7th Jul, 2022, 01:15 PM ( GMT-7 )
// hash-code: 14769606

@@ -9,3 +9,2 @@ // file exports

export * from "./FluentConfigurator";
export * from "./KeyStorage";

@@ -12,0 +11,0 @@ // #endregion

@@ -0,3 +1,5 @@

import { describe, it, expect } from "vitest";
import { Equal, Expect } from "@type-challenges/utils";
import { arrayToKeyLookup } from "~/utility";
import { arrayToKeyLookup } from "../src/utility";

@@ -11,8 +13,6 @@ describe("arrayToKeyLookup()", () => {

type cases = [
Expect<Equal<typeof lookup, Record<"foo" | "bar" | "baz", true>>>
];
type cases = [Expect<Equal<typeof lookup, Record<"foo" | "bar" | "baz", true>>>];
const cases: cases = [true];
expect(cases).toBe(cases);
});
});
});

@@ -0,4 +1,12 @@

import { describe, it, expect } from "vitest";
import { Equal, Expect, ExpectExtends } from "@type-challenges/utils";
import { ArrayConverter, arrayToObject, GeneralDictionary, UniqueDictionary, defineType, keys } from "~/utility";
import {
ArrayConverter,
arrayToObject,
GeneralDictionary,
UniqueDictionary,
defineType,
keys,
} from "../src/utility";

@@ -10,5 +18,3 @@ const foo = { name: "foo", age: 123, color: "red" } as const;

describe("arrayToObject => ", () => {
it("partial application of arrayToObject()", () => {

@@ -32,3 +38,3 @@ const t1 = arrayToObject("name", false);

Expect<ExpectExtends<UniqueDictionary<"name", any, any>, ReturnType<T2>>>,
Expect<ExpectExtends<UniqueDictionary<"name", any, any>, ReturnType<T3>>>,
Expect<ExpectExtends<UniqueDictionary<"name", any, any>, ReturnType<T3>>>
];

@@ -76,3 +82,3 @@

// once we state that foo is not unique, the type expanded to an array
Expect<Equal<typeof dict3["foo"], SomeFoo[]>>,
Expect<Equal<typeof dict3["foo"], SomeFoo[]>>
];

@@ -106,3 +112,3 @@ const cases: cases = [true, true, true, true, true];

Expect<Equal<Id["1"]["age"], number>>,
Expect<Equal<Id["1"]["color"], string>>,
Expect<Equal<Id["1"]["color"], string>>
];

@@ -113,4 +119,2 @@

});
});

@@ -0,1 +1,3 @@

import { describe, it, expect } from "vitest";
import { CamelCase } from "../src/types";

@@ -2,0 +4,0 @@ import { Expect, Equal } from "@type-challenges/utils";

@@ -0,1 +1,3 @@

import { describe, it, expect } from "vitest";
import { Expect, Equal } from "@type-challenges/utils";

@@ -2,0 +4,0 @@ import { Constructor } from "../src/types/Constructor";

@@ -1,3 +0,3 @@

/* eslint-disable unicorn/consistent-function-scoping */
import { createFnWithProps } from "~/index";
import { describe, it, expect } from "vitest";
import { createFnWithProps } from "../src/index";

@@ -4,0 +4,0 @@ describe("createFnWithProps()", () => {

@@ -0,6 +1,7 @@

import { describe, it, expect } from "vitest";
import type { Expect, Equal } from "@type-challenges/utils";
import { ExpectExtends } from "~/types";
import { defineType } from "~/utility";
import { ExpectExtends } from "../src/types";
import { defineType } from "../src/utility";
describe("inferredType() utility", () => {

@@ -25,3 +26,12 @@ it("only specify a wide type", () => {

// we get something odd
Expect<Equal<typeof t2, { foo: string; bar: number;[x: string]: string | number | boolean | symbol | void | object | {} | null | undefined }>>,
Expect<
Equal<
typeof t2,
{
foo: string;
bar: number;
[x: string]: string | number | boolean | symbol | void | object | {} | null | undefined;
}
>
>,
// fortunately it does extend the intended type

@@ -36,5 +46,3 @@ Expect<ExpectExtends<typeof t2, { foo: string; bar: number }>>

const t = defineType({ foo: 1, bar: "hi" })();
type cases = [
Expect<Equal<typeof t, { foo: 1; bar: "hi" }>>
];
type cases = [Expect<Equal<typeof t, { foo: 1; bar: "hi" }>>];
const cases: cases = [true];

@@ -47,8 +55,6 @@ expect(cases).toBe(cases);

type cases = [
Expect<Equal<typeof t, { foo: string; bar: 1 }>>
];
type cases = [Expect<Equal<typeof t, { foo: string; bar: 1 }>>];
const cases: cases = [true];
expect(cases).toBe(cases);
});
});
});

@@ -0,4 +1,6 @@

import { describe, it, expect } from "vitest";
import { Equal, Expect } from "@type-challenges/utils";
import { Get } from "~/types";
import { defineType } from "~/utility";
import { Get } from "src/types";
import { defineType } from "src/utility";

@@ -20,3 +22,3 @@ describe("Get<T, K> type utility", () => {

Expect<Equal<Bar, string>>,
// non-existant props return never
// non-existent props return never
Expect<Equal<Nada, never>>

@@ -23,0 +25,0 @@ ];

@@ -1,5 +0,5 @@

/* eslint-disable unicorn/consistent-function-scoping */
import { dictionaryTransform, ExplicitFunction } from "~/utility";
import { describe, it, expect } from "vitest";
import { dictionaryTransform, ExplicitFunction } from "../src/utility";
import { Expect, Equal, NotEqual, ExpectExtends, ExpectFalse } from "@type-challenges/utils";
import { ToFluent, Transformer } from "~/types";
import { ToFluent, Transformer } from "../src/types";

@@ -6,0 +6,0 @@ describe("dictionaryTransform()", () => {

@@ -1,3 +0,4 @@

/* eslint-disable unicorn/consistent-function-scoping */
import { ExplicitFunction } from "~/utility";
import { describe, it, expect } from "vitest";
import { ExplicitFunction } from "../src/utility";
import type { Expect, Equal } from "@type-challenges/utils";

@@ -4,0 +5,0 @@

@@ -1,5 +0,6 @@

/* eslint-disable unicorn/consistent-function-scoping */
import { describe, it, expect } from "vitest";
/* eslint-disable @typescript-eslint/no-unused-vars */
import { Expect, Equal } from "@type-challenges/utils";
import { ifTypeOf, defineType, literal } from "~/utility";
import { ifTypeOf, defineType, literal } from "../src/utility";

@@ -15,6 +16,3 @@ describe("ifTypeOf() utility", () => {

type cases = [
Expect<Equal<typeof yup, true>>,
Expect<Equal<typeof nope, false>>,
];
type cases = [Expect<Equal<typeof yup, true>>, Expect<Equal<typeof nope, false>>];
const cases: cases = [true, true];

@@ -40,3 +38,3 @@ expect(cases).toBe(cases);

Expect<Equal<typeof nope1, false>>,
Expect<Equal<typeof nope2, false>>,
Expect<Equal<typeof nope2, false>>
];

@@ -68,3 +66,3 @@ const cases: cases = [true, true, true, true];

Expect<Equal<typeof stringIsNumber, false>>,
Expect<Equal<typeof diffNumbersNarrowly, false>>,
Expect<Equal<typeof diffNumbersNarrowly, false>>
];

@@ -82,5 +80,3 @@ const cases: cases = [true, true, true, true, true];

type cases = [
Expect<Equal<typeof fnExtends, true>>
];
type cases = [Expect<Equal<typeof fnExtends, true>>];
const cases: cases = [true];

@@ -91,13 +87,31 @@ expect(cases).toBe(cases);

it("checklist example", () => {
const noFoodOrDrink = ifTypeOf({ wakeUp: true }).extends({ wakeUp: true, eatBreakfast: true, drinkCoffee: true });
const ready = ifTypeOf({ wakeUp: true, eatBreakfast: true, drinkCoffee: true }).extends({ wakeUp: true, eatBreakfast: true, drinkCoffee: true });
const noFoodOrDrink = ifTypeOf({ wakeUp: true }).extends({
wakeUp: true,
eatBreakfast: true,
drinkCoffee: true,
});
const ready = ifTypeOf({ wakeUp: true, eatBreakfast: true, drinkCoffee: true }).extends({
wakeUp: true,
eatBreakfast: true,
drinkCoffee: true,
});
// completely wrong
const fullyBaked = ifTypeOf({ wakeUp: false, eatBreakfast: false, drinkCoffee: false }).extends({ wakeUp: true, eatBreakfast: true, drinkCoffee: true });
const fullyBaked = ifTypeOf({ wakeUp: false, eatBreakfast: false, drinkCoffee: false }).extends(
{ wakeUp: true, eatBreakfast: true, drinkCoffee: true }
);
// half-right
const halfBaked = ifTypeOf({ wakeUp: false, eatBreakfast: false, drinkCoffee: false }).extends({ wakeUp: true, eatBreakfast: true, drinkCoffee: true } as const);
const halfBaked = ifTypeOf({ wakeUp: false, eatBreakfast: false, drinkCoffee: false }).extends({
wakeUp: true,
eatBreakfast: true,
drinkCoffee: true,
} as const);
// back to right; at the cost of being very careful
const lucid = ifTypeOf({ wakeUp: false, eatBreakfast: false, drinkCoffee: false }).narrowlyExtends({ wakeUp: true, eatBreakfast: true, drinkCoffee: true } as const);
const lucid = ifTypeOf({
wakeUp: false,
eatBreakfast: false,
drinkCoffee: false,
}).narrowlyExtends({ wakeUp: true, eatBreakfast: true, drinkCoffee: true } as const);

@@ -165,3 +179,2 @@ // run-time tests of False Positives

try {

@@ -181,6 +194,4 @@ const narrow = ifTypeOf(fn).narrowlyExtends(fn2);

// an error to the run time system
};
}
});
});

@@ -1,2 +0,4 @@

import { Include, Retain } from "~/types";
import { describe, it, expect } from "vitest";
import { Include, Retain } from "../src/types";
import { Equal, Expect } from "@type-challenges/utils";

@@ -11,6 +13,3 @@

type cases = [
Expect<Equal<Foo, "foo">>,
Expect<Equal<NotFoo, never>>
];
type cases = [Expect<Equal<Foo, "foo">>, Expect<Equal<NotFoo, never>>];
const c: cases = [true, true];

@@ -37,3 +36,3 @@ expect(c).toBe(c);

// the optional `L` generic as a true value
Expect<Equal<NotLiteralFoo, never>>,
Expect<Equal<NotLiteralFoo, never>>
];

@@ -43,3 +42,2 @@ const c: cases = [true, true, true, true];

});
});

@@ -58,3 +56,3 @@

Expect<Equal<Baz, { baz: string }>>,
Expect<Equal<FooBaz, { foo: number; baz: string }>>,
Expect<Equal<FooBaz, { foo: number; baz: string }>>
];

@@ -69,9 +67,6 @@ const c: cases = [true, true, true];

type cases = [
Expect<Equal<FooBar, { foo: 1; bar?: number }>>,
];
type cases = [Expect<Equal<FooBar, { foo: 1; bar?: number }>>];
const c: cases = [true];
expect(c).toBe(c);
});
});

@@ -0,1 +1,3 @@

import { describe, it, expect } from "vitest";
import type { Includes } from "../src/types";

@@ -2,0 +4,0 @@ import type { ExpectTrue, ExpectFalse } from "@type-challenges/utils";

@@ -0,1 +1,3 @@

import { describe, it } from "vitest";
import type { KebabCase } from "../src/types";

@@ -2,0 +4,0 @@ import type { Expect, Equal } from "@type-challenges/utils";

@@ -0,5 +1,7 @@

import { describe, it, expect } from "vitest";
import { Equal, Expect, NotEqual } from "@type-challenges/utils";
import { DictFromKv } from "~/types/kv/DictFromKv";
import { keys } from "~/utility";
import { dictToKv, kvToDict } from "~/utility/dictionary/kv";
import { dictToKv, kvToDict } from "src/utility/dictionary";
import { DictFromKv } from "src/types/kv";
import { keys } from "src/utility";

@@ -10,3 +12,2 @@ describe("dictToKv()", () => {

const val = dictToKv(obj, true);
// type Val = typeof val;

@@ -13,0 +14,0 @@ expect(Array.isArray(val)).toBeTruthy();

@@ -0,3 +1,5 @@

import { describe, it, expect } from "vitest";
import type { Expect, NotEqual, Equal, ExpectExtends } from "@type-challenges/utils";
import { entries } from "~/utility";
import { entries } from "src/utility";

@@ -28,5 +30,5 @@ describe("entries() => ", () => {

Expect<Equal<typeof k, "foo">>,
// but the value is still a union of all KV
// values which makes it far less valueable
Expect<Equal<typeof v, Value>>,
// but the value is still a union of all KV
// values which makes it far less valuable
Expect<Equal<typeof v, Value>>
];

@@ -47,4 +49,4 @@ const c: cases2 = [true, true];

// Expect<Equal<typeof entry[0], "foo">>,
// // but the value is still a union of all KV
// // values which makes it far less valueable
// // but the value is still a union of all KV
// // values which makes it far less valuable
// Expect<Equal<typeof v, Value>>,

@@ -56,5 +58,2 @@ // ];

// }
});

@@ -61,0 +60,0 @@

@@ -1,4 +0,6 @@

import { Keys } from "../../src/types/Keys";
import { describe, it, expect } from "vitest";
import { Keys } from "src/types/Keys";
import type { Expect, Equal } from "@type-challenges/utils";
import { defineType, keys } from "~/utility";
import { defineType, keys } from "src/utility";

@@ -21,5 +23,3 @@ describe("Keys<T>", () => {

type cases = [
Expect<Equal<MyKeys, "foo" | "bar">>
];
type cases = [Expect<Equal<MyKeys, "foo" | "bar">>];
const cases: cases = [true];

@@ -35,6 +35,3 @@ expect(cases).toBe(cases);

type cases = [
Expect<Equal<OKeys, "bar">>,
Expect<Equal<OArr, "bar">>
];
type cases = [Expect<Equal<OKeys, "bar">>, Expect<Equal<OArr, "bar">>];
const cases: cases = [true, true];

@@ -46,3 +43,2 @@ expect(cases).toBe(cases);

describe("keys() utility", () => {
it("with just object passed in, keys are extracted as expected", () => {

@@ -57,5 +53,3 @@ const obj = defineType({ id: "123" })({ color: "red", isFavorite: false });

type cases = [
Expect<Equal<typeof k, ("color" | "id" | "isFavorite")[]>>
];
type cases = [Expect<Equal<typeof k, ("color" | "id" | "isFavorite")[]>>];
const cases: cases = [true];

@@ -72,10 +66,6 @@ expect(cases).toBe(cases);

type cases = [
Expect<Equal<typeof k, ("isFavorite")[]>>
];
type cases = [Expect<Equal<typeof k, "isFavorite"[]>>];
const cases: cases = [true];
expect(cases).toBe(cases);
});
});
});

@@ -0,6 +1,7 @@

import { describe, it, expect } from "vitest";
import { Equal, Expect } from "@type-challenges/utils";
import { KeyValue } from "~/types";
import { KeyValue } from "src/types";
describe("KeyValue<T, K> type utility", () => {
it("explicit KeyValue<T,K> definitions retain literal type info", () => {

@@ -16,3 +17,3 @@ const obj = { foo: 1, bar: "hi", baz: { a: 1, b: 2 } } as const;

Expect<Equal<Bar, ["bar", "hi"]>>,
Expect<Equal<Baz, ["baz", { readonly a: 1; readonly b: 2 }]>>,
Expect<Equal<Baz, ["baz", { readonly a: 1; readonly b: 2 }]>>
];

@@ -22,3 +23,2 @@ const c: cases = [true, true, true];

});
});

@@ -1,5 +0,6 @@

import { keys, kv } from "~/utility";
import { describe, it, expect } from "vitest";
import { keys, kv } from "src/utility";
describe("kv utils", () => {
it("simple assignment works with strong literal support", () => {

@@ -19,3 +20,2 @@ const t1 = kv("foo", { a: 1, b: 2, c: "hi" });

});
});
});

@@ -0,6 +1,7 @@

import { describe, it, expect } from "vitest";
import { Equal, Expect, ExpectFalse } from "@type-challenges/utils";
import { SameKeys } from "~/types";
import { SameKeys } from "src/types";
describe("SameKeys<T> utility", () => {
it("keys must be same type but value can be anything", () => {

@@ -11,8 +12,5 @@ const origin = { id: "abc", favorite: false };

type cases = [
Expect<Equal<SK, { id: any; favorite: any }>>
];
type cases = [Expect<Equal<SK, { id: any; favorite: any }>>];
const c: cases = [true];
expect(c).toBe(c);
});

@@ -31,5 +29,5 @@

// but more importantly P can not be assigned to SameKeys<O>
// this ensures that you'd get a type error with:
// this ensures that you'd get a type error with:
// `const p: SameKeys<O> = { id: "abc" }`
ExpectFalse<Equal<SameKeys<O>, P>>,
ExpectFalse<Equal<SameKeys<O>, P>>
];

@@ -39,3 +37,2 @@ const c: cases = [false, false];

});
});

@@ -0,3 +1,5 @@

import { describe, it, expect } from "vitest";
import { Expect, Equal, ExpectExtends } from "@type-challenges/utils";
import { UniqueForProp } from "~/types/lists";
import { UniqueForProp } from "src/types/lists";

@@ -4,0 +6,0 @@ describe("UniqueForProp<T, P>", () => {

@@ -1,2 +0,4 @@

import { idLiteral, literal } from "~/utility";
import { describe, it, expect } from "vitest";
import { idLiteral, literal } from "../src/utility";
import { Equal, NotEqual, Expect, ExpectExtends, ExpectFalse } from "@type-challenges/utils";

@@ -60,4 +62,4 @@

type Narrow = typeof narrow;
/**
* would be nice if this worked but it doesn't; once the type is set, it's set
/**
* would be nice if this worked but it doesn't; once the type is set, it's set
*/

@@ -64,0 +66,0 @@ const nope = literal(wide);

@@ -0,1 +1,3 @@

import { describe, it, expect } from "vitest";
import { mapValues, literal } from "../src/utility";

@@ -7,3 +9,3 @@ import type { Expect, Equal, ExpectFalse } from "@type-challenges/utils";

const colors = { red: 4, blue: 2, green: 3 };
const x2 = mapValues(colors, v => v * 2);
const x2 = mapValues(colors, (v) => v * 2);

@@ -29,3 +31,3 @@ expect(x2.red).toBe(colors.red * 2);

const colors = literal({ red: 4, blue: 2, green: 3 });
const x2 = mapValues(colors, v => v * 2);
const x2 = mapValues(colors, (v) => v * 2);

@@ -50,2 +52,2 @@ expect(x2.red).toBe(colors.red * 2);

});
});
});

@@ -1,2 +0,3 @@

/* eslint-disable unicorn/consistent-function-scoping */
import { describe, it, expect } from "vitest";
import { MutationIdentity } from "../src/Mutation";

@@ -3,0 +4,0 @@ import type { Expect, Equal, ExpectExtends } from "@type-challenges/utils";

@@ -0,1 +1,3 @@

import { describe, it, expect } from "vitest";
import type { PascalCase } from "../src/types";

@@ -2,0 +4,0 @@ import type { Expect, Equal } from "@type-challenges/utils";

@@ -0,1 +1,3 @@

import { describe, it } from "vitest";
import type { Pluralize } from "../src/types";

@@ -2,0 +4,0 @@ import type { Expect, Equal } from "@type-challenges/utils";

@@ -1,2 +0,3 @@

/* eslint-disable unicorn/consistent-function-scoping */
import { describe, it, expect } from "vitest";
import type { Expect, Equal } from "@type-challenges/utils";

@@ -14,3 +15,3 @@ import {

WithNumericKeys,
} from "~/types/props";
} from "src/types/dictionary/props";

@@ -17,0 +18,0 @@ type T0 = { foo: number; bar: number; baz: string };

@@ -1,2 +0,3 @@

import { condition, isFunction, isTrue } from "~/utility";
import { describe, it, expect } from "vitest";
import { condition, isFunction, isTrue } from "src/utility";

@@ -3,0 +4,0 @@ describe("condition() utility", () => {

@@ -1,5 +0,6 @@

/* eslint-disable unicorn/consistent-function-scoping */
import { describe, it, expect } from "vitest";
import type { Expect, Equal } from "@type-challenges/utils";
import { FunctionType } from "~/types";
import { type, createFnWithProps, isFunction, isObject } from "~/utility";
import { FunctionType } from "src/types";
import { type, createFnWithProps, isFunction, isObject } from "src/utility";

@@ -6,0 +7,0 @@ describe("testing type() utility and some pre-made conditions", () => {

@@ -0,1 +1,3 @@

import { describe, it } from "vitest";
import { SnakeCase } from "../src/types";

@@ -2,0 +4,0 @@ import { Expect, Equal } from "@type-challenges/utils";

@@ -1,5 +0,6 @@

import { literal, strArrayToDict } from "~/utility";
import { describe, it } from "vitest";
import { literal, strArrayToDict } from "../src/utility";
import type { Expect, Equal, ExpectFalse } from "@type-challenges/utils";
describe("strArrayToDict() utility", () => {

@@ -32,10 +33,9 @@ it("", () => {

// and unfortunately it's lost all track of the keys
// which are involved; just knowning that they are
// which are involved; just knowning that they are
// string based keys
Expect<Equal<keyof R4, string>>,
Expect<Equal<keyof R4, string>>
];
const cases: cases = [true, true, true, false, true];
});
});
});

@@ -0,6 +1,7 @@

import { describe, it, expect } from "vitest";
import { Equal, Expect } from "@type-challenges/utils";
import { AllCaps } from "~/types";
import { AllCaps } from "src/types";
describe("AllCaps<T> type utility", () => {
it("finds AllCaps where it exists", () => {

@@ -11,7 +12,3 @@ type T1 = AllCaps<"YUP">;

type cases = [
Expect<Equal<T1, true>>,
Expect<Equal<T2, true>>,
Expect<Equal<T3, true>>,
];
type cases = [Expect<Equal<T1, true>>, Expect<Equal<T2, true>>, Expect<Equal<T3, true>>];
const c: cases = [true, true, true];

@@ -25,6 +22,3 @@ expect(c).toBe(c);

type cases = [
Expect<Equal<T1, false>>,
Expect<Equal<T2, false>>,
];
type cases = [Expect<Equal<T1, false>>, Expect<Equal<T2, false>>];
const c: cases = [true, true];

@@ -37,9 +31,6 @@ expect(c).toBe(c);

type cases = [
Expect<Equal<T1, "unknown">>,
];
type cases = [Expect<Equal<T1, "unknown">>];
const c: cases = [true];
expect(c).toBe(c);
});
});

@@ -0,3 +1,5 @@

import { describe, it, expect } from "vitest";
import { Equal, Expect } from "@type-challenges/utils";
import { CamelCase } from "~/types";
import { CamelCase } from "src/types";

@@ -8,3 +10,2 @@ const target = "twoThreeFour";

describe("CamelCase<T> type utility", () => {
it("CamelCase<T> provides an identity to a CamelCased string", () => {

@@ -14,6 +15,3 @@ type T1 = CamelCase<"TwoThreeFour">;

type cases = [
Expect<Equal<T1, TARGET>>,
Expect<Equal<T2, TARGET>>,
];
type cases = [Expect<Equal<T1, TARGET>>, Expect<Equal<T2, TARGET>>];
const c: cases = [true, true];

@@ -26,5 +24,3 @@ expect(c).toBe(c);

type cases = [
Expect<Equal<T1, TARGET>>
];
type cases = [Expect<Equal<T1, TARGET>>];
const c: cases = [true];

@@ -38,6 +34,3 @@ expect(c).toBe(c);

type cases = [
Expect<Equal<T1, TARGET>>,
Expect<Equal<T2, TARGET>>,
];
type cases = [Expect<Equal<T1, TARGET>>, Expect<Equal<T2, TARGET>>];
const c: cases = [true, true];

@@ -61,3 +54,3 @@ expect(c).toBe(c);

Expect<Equal<T5, "twoThreeFourFiveSixSevenEight">>,
Expect<Equal<T6, "twoThreeFourFiveSixSevenEightNineTenEleven">>,
Expect<Equal<T6, "twoThreeFourFiveSixSevenEightNineTenEleven">>
];

@@ -71,5 +64,3 @@ const c: cases = [true, true, true, true, true, true];

type cases = [
Expect<Equal<T1, TARGET>>
];
type cases = [Expect<Equal<T1, TARGET>>];
const c: cases = [true];

@@ -84,7 +75,3 @@ expect(c).toBe(c);

type cases = [
Expect<Equal<T1, TARGET>>,
Expect<Equal<T2, TARGET>>,
Expect<Equal<T3, TARGET>>,
];
type cases = [Expect<Equal<T1, TARGET>>, Expect<Equal<T2, TARGET>>, Expect<Equal<T3, TARGET>>];
const c: cases = [true, true, true];

@@ -98,6 +85,3 @@ expect(c).toBe(c);

type cases = [
Expect<Equal<T1, "oneTwoThree">>,
Expect<Equal<T2, "oneTwoThree">>,
];
type cases = [Expect<Equal<T1, "oneTwoThree">>, Expect<Equal<T2, "oneTwoThree">>];
const c: cases = [true, true];

@@ -110,5 +94,3 @@ expect(c).toBe(c);

type cases = [
Expect<Equal<T1, string>>,
];
type cases = [Expect<Equal<T1, string>>];
const c: cases = [true];

@@ -131,3 +113,3 @@ expect(c).toBe(c);

Expect<Equal<T4, "oneTwoThreeFourFiveSixSevenEightNine">>,
Expect<Equal<T5, "oneTwoThreeFourFiveSixSevenEightNine">>,
Expect<Equal<T5, "oneTwoThreeFourFiveSixSevenEightNine">>
];

@@ -137,3 +119,2 @@ const c: cases = [true, true, true, true, true];

});
});
});

@@ -0,3 +1,5 @@

import { describe, it, expect } from "vitest";
import { Equal, Expect } from "@type-challenges/utils";
import { Dasherize } from "~/types";
import { Dasherize } from "src/types";

@@ -8,3 +10,2 @@ const target = "two-three-four";

describe("Dasherize<T> type utility", () => {
it("Dasherize<T> provides an identity to a dasherized string", () => {

@@ -14,6 +15,3 @@ type T1 = Dasherize<"two-three-four">;

type cases = [
Expect<Equal<T1, TARGET>>,
Expect<Equal<T2, TARGET>>,
];
type cases = [Expect<Equal<T1, TARGET>>, Expect<Equal<T2, TARGET>>];
const c: cases = [true, true];

@@ -26,5 +24,3 @@ expect(c).toBe(c);

type cases = [
Expect<Equal<T1, TARGET>>
];
type cases = [Expect<Equal<T1, TARGET>>];
const c: cases = [true];

@@ -37,5 +33,3 @@ expect(c).toBe(c);

type cases = [
Expect<Equal<T1, TARGET>>
];
type cases = [Expect<Equal<T1, TARGET>>];
const c: cases = [true];

@@ -58,3 +52,3 @@ expect(c).toBe(c);

Expect<Equal<T4, "two-three-four-five-six-seven">>,
Expect<Equal<T5, "two-three-four-five-six-seven-eight">>,
Expect<Equal<T5, "two-three-four-five-six-seven-eight">>
// Expect<Equal<T6, "two-three-four-five-six-seven-eight-nine">>,

@@ -69,5 +63,3 @@ ];

type cases = [
Expect<Equal<T1, TARGET>>
];
type cases = [Expect<Equal<T1, TARGET>>];
const c: cases = [true];

@@ -82,7 +74,3 @@ expect(c).toBe(c);

type cases = [
Expect<Equal<T1, TARGET>>,
Expect<Equal<T2, TARGET>>,
Expect<Equal<T3, TARGET>>,
];
type cases = [Expect<Equal<T1, TARGET>>, Expect<Equal<T2, TARGET>>, Expect<Equal<T3, TARGET>>];
const c: cases = [true, true, true];

@@ -96,6 +84,3 @@ expect(c).toBe(c);

type cases = [
Expect<Equal<T1, "one-two-three">>,
Expect<Equal<T2, "one-two-three">>,
];
type cases = [Expect<Equal<T1, "one-two-three">>, Expect<Equal<T2, "one-two-three">>];
const c: cases = [true, true];

@@ -108,5 +93,3 @@ expect(c).toBe(c);

type cases = [
Expect<Equal<T1, string>>,
];
type cases = [Expect<Equal<T1, string>>];
const c: cases = [true];

@@ -128,3 +111,3 @@ expect(c).toBe(c);

Expect<Equal<T4, "one-two-three-four-five-six-seven-eight-nine-ten">>,
Expect<Equal<T5, "one-two-three-four-five-six-seven-eight-nine-ten">>,
Expect<Equal<T5, "one-two-three-four-five-six-seven-eight-nine-ten">>
];

@@ -134,3 +117,2 @@ const c: cases = [true, true, true, true, true];

});
});
});

@@ -0,6 +1,7 @@

import { describe, it, expect } from "vitest";
import { Equal, Expect } from "@type-challenges/utils";
import { HasUppercase } from "~/types";
import { HasUppercase } from "src/types";
describe("HasUppercase<T> type utility", () => {
it("finds capitals where they exist", () => {

@@ -11,7 +12,3 @@ type T1 = HasUppercase<"Yup">;

type cases = [
Expect<Equal<T1, true>>,
Expect<Equal<T2, true>>,
Expect<Equal<T3, true>>,
];
type cases = [Expect<Equal<T1, true>>, Expect<Equal<T2, true>>, Expect<Equal<T3, true>>];
const c: cases = [true, true, true];

@@ -25,6 +22,3 @@ expect(c).toBe(c);

type cases = [
Expect<Equal<T1, false>>,
Expect<Equal<T2, false>>,
];
type cases = [Expect<Equal<T1, false>>, Expect<Equal<T2, false>>];
const c: cases = [true, true];

@@ -37,9 +31,6 @@ expect(c).toBe(c);

type cases = [
Expect<Equal<T1, "unknown">>,
];
type cases = [Expect<Equal<T1, "unknown">>];
const c: cases = [true];
expect(c).toBe(c);
});
});

@@ -0,3 +1,5 @@

import { describe, it, expect } from "vitest";
import { Equal, Expect } from "@type-challenges/utils";
import { PascalCase } from "~/types";
import { PascalCase } from "src/types";

@@ -8,3 +10,2 @@ const target = "TwoThreeFour";

describe("PascalCase<T> type utility", () => {
it("PascalCase<T> provides an identity to a PascalCased string", () => {

@@ -14,6 +15,3 @@ type T1 = PascalCase<"TwoThreeFour">;

type cases = [
Expect<Equal<T1, TARGET>>,
Expect<Equal<T2, TARGET>>,
];
type cases = [Expect<Equal<T1, TARGET>>, Expect<Equal<T2, TARGET>>];
const c: cases = [true, true];

@@ -26,5 +24,3 @@ expect(c).toBe(c);

type cases = [
Expect<Equal<T1, TARGET>>
];
type cases = [Expect<Equal<T1, TARGET>>];
const c: cases = [true];

@@ -38,6 +34,3 @@ expect(c).toBe(c);

type cases = [
Expect<Equal<T1, TARGET>>,
Expect<Equal<T2, TARGET>>,
];
type cases = [Expect<Equal<T1, TARGET>>, Expect<Equal<T2, TARGET>>];
const c: cases = [true, true];

@@ -61,3 +54,3 @@ expect(c).toBe(c);

Expect<Equal<T5, "TwoThreeFourFiveSixSevenEight">>,
Expect<Equal<T6, "TwoThreeFourFiveSixSevenEightNineTenEleven">>,
Expect<Equal<T6, "TwoThreeFourFiveSixSevenEightNineTenEleven">>
];

@@ -71,5 +64,3 @@ const c: cases = [true, true, true, true, true, true];

type cases = [
Expect<Equal<T1, TARGET>>
];
type cases = [Expect<Equal<T1, TARGET>>];
const c: cases = [true];

@@ -84,7 +75,3 @@ expect(c).toBe(c);

type cases = [
Expect<Equal<T1, TARGET>>,
Expect<Equal<T2, TARGET>>,
Expect<Equal<T3, TARGET>>,
];
type cases = [Expect<Equal<T1, TARGET>>, Expect<Equal<T2, TARGET>>, Expect<Equal<T3, TARGET>>];
const c: cases = [true, true, true];

@@ -98,6 +85,3 @@ expect(c).toBe(c);

type cases = [
Expect<Equal<T1, "OneTwoThree">>,
Expect<Equal<T2, "OneTwoThree">>,
];
type cases = [Expect<Equal<T1, "OneTwoThree">>, Expect<Equal<T2, "OneTwoThree">>];
const c: cases = [true, true];

@@ -110,5 +94,3 @@ expect(c).toBe(c);

type cases = [
Expect<Equal<T1, string>>,
];
type cases = [Expect<Equal<T1, string>>];
const c: cases = [true];

@@ -131,3 +113,3 @@ expect(c).toBe(c);

Expect<Equal<T4, "OneTwoThreeFourFiveSixSevenEightNine">>,
Expect<Equal<T5, "OneTwoThreeFourFiveSixSevenEightNine">>,
Expect<Equal<T5, "OneTwoThreeFourFiveSixSevenEightNine">>
];

@@ -137,3 +119,2 @@ const c: cases = [true, true, true, true, true];

});
});
});

@@ -0,3 +1,5 @@

import { describe, it, expect } from "vitest";
import { Equal, Expect } from "@type-challenges/utils";
import { SnakeCase } from "~/types";
import { SnakeCase } from "src/types";

@@ -8,3 +10,2 @@ const target = "two_three_four";

describe("SnakeCase<T> type utility", () => {
it("SnakeCase<T> provides an identity to a SnakeCased string", () => {

@@ -14,6 +15,3 @@ type T1 = SnakeCase<"TwoThreeFour">;

type cases = [
Expect<Equal<T1, TARGET>>,
Expect<Equal<T2, TARGET>>,
];
type cases = [Expect<Equal<T1, TARGET>>, Expect<Equal<T2, TARGET>>];
const c: cases = [true, true];

@@ -26,5 +24,3 @@ expect(c).toBe(c);

type cases = [
Expect<Equal<T1, TARGET>>
];
type cases = [Expect<Equal<T1, TARGET>>];
const c: cases = [true];

@@ -38,6 +34,3 @@ expect(c).toBe(c);

type cases = [
Expect<Equal<T1, TARGET>>,
Expect<Equal<T2, TARGET>>,
];
type cases = [Expect<Equal<T1, TARGET>>, Expect<Equal<T2, TARGET>>];
const c: cases = [true, true];

@@ -60,3 +53,3 @@ expect(c).toBe(c);

Expect<Equal<T4, "two_three_four_five_six_seven">>,
Expect<Equal<T5, "two_three_four_five_six_seven_eight">>,
Expect<Equal<T5, "two_three_four_five_six_seven_eight">>
// Expect<Equal<T6, "TwoThreeFourFiveSixSevenEightNineTenEleven">>,

@@ -71,5 +64,3 @@ ];

type cases = [
Expect<Equal<T1, TARGET>>
];
type cases = [Expect<Equal<T1, TARGET>>];
const c: cases = [true];

@@ -84,7 +75,3 @@ expect(c).toBe(c);

type cases = [
Expect<Equal<T1, TARGET>>,
Expect<Equal<T2, TARGET>>,
Expect<Equal<T3, TARGET>>,
];
type cases = [Expect<Equal<T1, TARGET>>, Expect<Equal<T2, TARGET>>, Expect<Equal<T3, TARGET>>];
const c: cases = [true, true, true];

@@ -98,6 +85,3 @@ expect(c).toBe(c);

type cases = [
Expect<Equal<T1, "one_two_three">>,
Expect<Equal<T2, "one_two_three">>,
];
type cases = [Expect<Equal<T1, "one_two_three">>, Expect<Equal<T2, "one_two_three">>];
const c: cases = [true, true];

@@ -110,5 +94,3 @@ expect(c).toBe(c);

type cases = [
Expect<Equal<T1, string>>,
];
type cases = [Expect<Equal<T1, string>>];
const c: cases = [true];

@@ -131,3 +113,3 @@ expect(c).toBe(c);

Expect<Equal<T4, "one_two_three_four_five_six_seven_eight_nine">>,
Expect<Equal<T5, "one_two_three_four_five_six_seven_eight_nine">>,
Expect<Equal<T5, "one_two_three_four_five_six_seven_eight_nine">>
];

@@ -137,3 +119,2 @@ const c: cases = [true, true, true, true, true];

});
});
});

@@ -0,6 +1,7 @@

import { describe, it, expect } from "vitest";
import { Equal, Expect } from "@type-challenges/utils";
import { LeftWhitespace, RightWhitespace } from "~/types";
import { LeftWhitespace, RightWhitespace } from "src/types";
describe("LeftWhitespace<T> utility", () => {
it("no whitespace results in empty string literal", () => {

@@ -10,6 +11,3 @@ type T1 = LeftWhitespace<"foobar">;

type cases = [
Expect<Equal<T1, "">>,
Expect<Equal<T2, "">>,
];
type cases = [Expect<Equal<T1, "">>, Expect<Equal<T2, "">>];
const c: cases = [true, true];

@@ -23,6 +21,3 @@ expect(c).toBe(c);

type cases = [
Expect<Equal<T1, " ">>,
Expect<Equal<T2, "\n\t ">>,
];
type cases = [Expect<Equal<T1, " ">>, Expect<Equal<T2, "\n\t ">>];
const c: cases = [true, true];

@@ -35,13 +30,9 @@ expect(c).toBe(c);

type cases = [
Expect<Equal<T1, string>>,
];
type cases = [Expect<Equal<T1, string>>];
const c: cases = [true];
expect(c).toBe(c);
});
});
describe("RightWhitespace<T> utility", () => {
it("no whitespace results in empty string literal", () => {

@@ -51,6 +42,3 @@ type T1 = RightWhitespace<"foobar">;

type cases = [
Expect<Equal<T1, "">>,
Expect<Equal<T2, "">>,
];
type cases = [Expect<Equal<T1, "">>, Expect<Equal<T2, "">>];
const c: cases = [true, true];

@@ -64,6 +52,3 @@ expect(c).toBe(c);

type cases = [
Expect<Equal<T1, " ">>,
Expect<Equal<T2, " \n">>,
];
type cases = [Expect<Equal<T1, " ">>, Expect<Equal<T2, " \n">>];
const c: cases = [true, true];

@@ -76,9 +61,6 @@ expect(c).toBe(c);

type cases = [
Expect<Equal<T1, string>>,
];
type cases = [Expect<Equal<T1, string>>];
const c: cases = [true];
expect(c).toBe(c);
});
});
});

@@ -1,2 +0,4 @@

import { TupleToUnion } from "~/types";
import { describe, it, expect } from "vitest";
import { TupleToUnion } from "src/types";
import { Expect, Equal } from "@type-challenges/utils";

@@ -3,0 +5,0 @@

@@ -0,1 +1,3 @@

import { describe, it, expect } from "vitest";
import { Expect, Equal } from "@type-challenges/utils";

@@ -5,3 +7,2 @@ import { Where, WhereNot } from "../src/types/Where";

describe("Where<T,U> and WhereNot<T,U> type utility", () => {
it("readonly string array works correctly", () => {

@@ -15,7 +16,7 @@ const arr = ["foo", "bar", "baz"] as const;

//
Expect<Equal<B, "bar"| "baz">>,
Expect<Equal<B, "bar" | "baz">>,
Expect<Equal<F, "foo">>
];
const c: cases = [ true, true ];
const c: cases = [true, true];
expect(c).toBe(c);

@@ -25,3 +26,3 @@ });

it("object with literal keys works", () => {
const arr = {foo: true, bar: true, baz: true} as const;
const arr = { foo: true, bar: true, baz: true } as const;
type A = typeof arr;

@@ -33,11 +34,9 @@ type B = Where<A, `ba${string}`>;

//
Expect<Equal<B, "bar"| "baz">>,
Expect<Equal<B, "bar" | "baz">>,
Expect<Equal<F, "foo">>
];
const c: cases = [ true, true ];
const c: cases = [true, true];
expect(c).toBe(c);
});
});

@@ -1,6 +0,7 @@

import { createFnWithProps, type, withValue } from "~/utility";
import { describe, it, expect } from "vitest";
import type { Expect, Equal } from "@type-challenges/utils";
import { WithValue } from "~/types/props";
import { FunctionType } from "~/types";
import { createFnWithProps, type, withValue } from "../src/utility";
import { FunctionType, WithValue } from "../src";
describe("withValue()() utility", () => {

@@ -7,0 +8,0 @@ it("type reduction with WithValue<T> works as expected", () => {

@@ -6,3 +6,2 @@ {

"moduleResolution": "node",
"sourceMap": true,

@@ -12,3 +11,2 @@ "noEmit": true,

"resolveJsonModule": true,
"strict": true,

@@ -20,5 +18,5 @@ "skipLibCheck": true,

"allowSyntheticDefaultImports": true,
"lib": ["ES2020"],
"lib": [
"ES2020"
],
"baseUrl": ".",

@@ -28,16 +26,7 @@ "declaration": true,

"tsBuildInfoFile": ".tsbuildinfo",
"paths": {
"~/*": ["src/*"],
"/~/*": ["src/*"]
},
"plugins": [
// Transform paths in output .js files
{ "transform": "typescript-transform-paths" },
// Transform paths in output .d.ts files (Include this line if you output declarations files)
{ "transform": "typescript-transform-paths", "afterDeclarations": true }
]
},
"include": ["src", "tests"]
}
"include": [
"src",
"tests"
]
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc