inferred-types 0.22.0 → 0.22.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +88 -47
- package/dist/index.js +40 -16
- package/dist/index.mjs +39 -15
- package/package.json +18 -14
- package/src/Mutation/index.ts +6 -29
- package/src/index.ts +6 -29
- package/src/shared/index.ts +6 -29
- package/src/types/Keys.ts +10 -6
- package/src/types/alphabetic/CamelCase.ts +1 -1
- package/src/types/alphabetic/alpha-characters.ts +33 -9
- package/src/types/alphabetic/index.ts +6 -29
- package/src/types/dictionary/DictChangeValue.ts +26 -0
- package/src/types/dictionary/MutableProps.ts +19 -0
- package/src/types/dictionary/index.ts +8 -29
- package/src/types/dictionary/props.ts +1 -1
- package/src/types/fluent/index.ts +6 -29
- package/src/types/functions/index.ts +6 -29
- package/src/types/index.ts +6 -29
- package/src/types/kv/index.ts +6 -29
- package/src/types/lists/index.ts +6 -29
- package/src/types/string-literals/index.ts +6 -29
- package/src/types/tuples/index.ts +6 -29
- package/src/types/type-conversion/index.ts +6 -29
- package/src/utility/api/index.ts +6 -29
- package/src/utility/dictionary/defineProperties.ts +35 -0
- package/src/utility/dictionary/index.ts +7 -29
- package/src/utility/dictionary/kv/index.ts +6 -29
- package/src/utility/errors/ReadOnlyViolation.ts +3 -0
- package/src/utility/errors/index.ts +12 -0
- package/src/utility/index.ts +7 -29
- package/src/utility/lists/index.ts +6 -29
- package/src/utility/literals/index.ts +6 -29
- package/src/utility/map-reduce/index.ts +6 -29
- package/src/utility/modelling/index.ts +6 -29
- package/src/utility/runtime/conditions/index.ts +6 -30
- package/src/utility/runtime/ifTypeOf.ts +4 -3
- package/src/utility/runtime/index.ts +6 -29
- package/src/utility/state/index.ts +6 -29
- package/tests/data/index.ts +6 -29
- package/tests/dictionary/DictChangeValue.test.ts +30 -0
- package/tests/dictionary/DictReturnValues.test.ts +5 -1
- package/tests/dictionary/MutableProps.test.ts +30 -0
- package/src/utility/runtime/conditions/isLiteral.ts +0 -7
|
@@ -25,7 +25,11 @@ describe("DictReturnValues<T, R, O>", () => {
|
|
|
25
25
|
multiply: (v1: number, v2: number) => null;
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
type cases = [
|
|
28
|
+
type cases = [
|
|
29
|
+
//
|
|
30
|
+
Expect<Equal<T1, Expected1>>,
|
|
31
|
+
Expect<Equal<T2, Expected2>>
|
|
32
|
+
];
|
|
29
33
|
|
|
30
34
|
const cases: cases = [true, true];
|
|
31
35
|
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import type { Expect, Equal } from "@type-challenges/utils";
|
|
3
|
+
|
|
4
|
+
import { MutableProps } from "src/types/dictionary";
|
|
5
|
+
|
|
6
|
+
describe("MutableProps<T,M>", () => {
|
|
7
|
+
it("works as expected", () => {
|
|
8
|
+
type Test = { foo: string; bar?: number; baz: Readonly<boolean> };
|
|
9
|
+
type Foo = MutableProps<Test, "foo" | "bar">;
|
|
10
|
+
type Bar = MutableProps<Test, "bar">;
|
|
11
|
+
type FooBar = MutableProps<Test, "foo" | "bar">;
|
|
12
|
+
type FooBaz = MutableProps<Test, "foo" | "baz">;
|
|
13
|
+
|
|
14
|
+
type cases = [
|
|
15
|
+
Expect<Equal<Foo, { foo: string; bar?: Readonly<number>; readonly baz: Readonly<boolean> }>>,
|
|
16
|
+
Expect<
|
|
17
|
+
Equal<
|
|
18
|
+
Bar,
|
|
19
|
+
{ readonly foo: Readonly<string>; bar?: number; readonly baz: Readonly<boolean> }
|
|
20
|
+
>
|
|
21
|
+
>,
|
|
22
|
+
Expect<Equal<FooBar, { foo: string; bar?: number; readonly baz: Readonly<boolean> }>>,
|
|
23
|
+
Expect<
|
|
24
|
+
Equal<FooBaz, { foo: string; readonly bar?: Readonly<number>; baz: Readonly<boolean> }>
|
|
25
|
+
>
|
|
26
|
+
];
|
|
27
|
+
const cases: cases = [true, true, true, true];
|
|
28
|
+
expect(cases).toBe(cases);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export type IsLiteral<L extends string | number, T extends any> = T extends L ? true : false;
|
|
2
|
-
|
|
3
|
-
export function isLiteral<L extends Readonly<string>>(...allowed: L[]) {
|
|
4
|
-
return <T extends unknown>(i: T) => {
|
|
5
|
-
return !allowed.every((v) => i !== v) as IsLiteral<L, T>;
|
|
6
|
-
};
|
|
7
|
-
}
|