Skip to content

Commit cca3ca2

Browse files
committed
Require TypeScript 4.7 and Node.js 14
1 parent 28f3e48 commit cca3ca2

File tree

75 files changed

+523
-532
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+523
-532
lines changed

.github/workflows/main.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ jobs:
1010
fail-fast: false
1111
matrix:
1212
node-version:
13+
- 18
1314
- 16
1415
- 14
15-
- 12
1616
steps:
17-
- uses: actions/checkout@v2
18-
- uses: actions/setup-node@v2
17+
- uses: actions/checkout@v3
18+
- uses: actions/setup-node@v3
1919
with:
2020
node-version: ${{ matrix.node-version }}
2121
- run: npm install
@@ -28,13 +28,13 @@ jobs:
2828
matrix:
2929
typescript-version:
3030
- 'latest'
31-
- '^4.3.0'
32-
- '~4.2.4'
31+
- '~4.8.0'
32+
- '~4.7.0'
3333
steps:
34-
- uses: actions/checkout@v2
35-
- uses: actions/setup-node@v2
34+
- uses: actions/checkout@v3
35+
- uses: actions/setup-node@v3
3636
with:
37-
node-version: 14
37+
node-version: 16
3838
- run: npm install
3939
- run: npm install typescript@${{ matrix.typescript-version }}
4040
- run: npx tsc

index.d.ts

Lines changed: 74 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -5,46 +5,46 @@ export * from './source/basic';
55
export * from './source/observable-like';
66

77
// Utilities
8-
export {EmptyObject, IsEmptyObject} from './source/empty-object';
9-
export {Except} from './source/except';
10-
export {Writable} from './source/writable';
11-
export {Merge} from './source/merge';
12-
export {MergeExclusive} from './source/merge-exclusive';
13-
export {RequireAtLeastOne} from './source/require-at-least-one';
14-
export {RequireExactlyOne} from './source/require-exactly-one';
15-
export {RequireAllOrNone} from './source/require-all-or-none';
16-
export {RemoveIndexSignature} from './source/remove-index-signature';
17-
export {PartialDeep, PartialDeepOptions} from './source/partial-deep';
18-
export {PartialOnUndefinedDeep, PartialOnUndefinedDeepOptions} from './source/partial-on-undefined-deep';
19-
export {ReadonlyDeep} from './source/readonly-deep';
20-
export {LiteralUnion} from './source/literal-union';
21-
export {Promisable} from './source/promisable';
22-
export {Opaque, UnwrapOpaque} from './source/opaque';
23-
export {InvariantOf} from './source/invariant-of';
24-
export {SetOptional} from './source/set-optional';
25-
export {SetRequired} from './source/set-required';
26-
export {SetNonNullable} from './source/set-non-nullable';
27-
export {ValueOf} from './source/value-of';
28-
export {AsyncReturnType} from './source/async-return-type';
29-
export {ConditionalExcept} from './source/conditional-except';
30-
export {ConditionalKeys} from './source/conditional-keys';
31-
export {ConditionalPick} from './source/conditional-pick';
32-
export {ConditionalPickDeep, ConditionalPickDeepOptions} from './source/conditional-pick-deep';
33-
export {UnionToIntersection} from './source/union-to-intersection';
34-
export {Stringified} from './source/stringified';
35-
export {FixedLengthArray} from './source/fixed-length-array';
36-
export {MultidimensionalArray} from './source/multidimensional-array';
37-
export {MultidimensionalReadonlyArray} from './source/multidimensional-readonly-array';
38-
export {IterableElement} from './source/iterable-element';
39-
export {Entry} from './source/entry';
40-
export {Entries} from './source/entries';
41-
export {SetReturnType} from './source/set-return-type';
42-
export {Asyncify} from './source/asyncify';
43-
export {Simplify} from './source/simplify';
44-
export {Jsonify} from './source/jsonify';
45-
export {Schema} from './source/schema';
46-
export {LiteralToPrimitive} from './source/literal-to-primitive';
47-
export {
8+
export type {EmptyObject, IsEmptyObject} from './source/empty-object';
9+
export type {Except} from './source/except';
10+
export type {Writable} from './source/writable';
11+
export type {Merge} from './source/merge';
12+
export type {MergeExclusive} from './source/merge-exclusive';
13+
export type {RequireAtLeastOne} from './source/require-at-least-one';
14+
export type {RequireExactlyOne} from './source/require-exactly-one';
15+
export type {RequireAllOrNone} from './source/require-all-or-none';
16+
export type {RemoveIndexSignature} from './source/remove-index-signature';
17+
export type {PartialDeep, PartialDeepOptions} from './source/partial-deep';
18+
export type {PartialOnUndefinedDeep, PartialOnUndefinedDeepOptions} from './source/partial-on-undefined-deep';
19+
export type {ReadonlyDeep} from './source/readonly-deep';
20+
export type {LiteralUnion} from './source/literal-union';
21+
export type {Promisable} from './source/promisable';
22+
export type {Opaque, UnwrapOpaque} from './source/opaque';
23+
export type {InvariantOf} from './source/invariant-of';
24+
export type {SetOptional} from './source/set-optional';
25+
export type {SetRequired} from './source/set-required';
26+
export type {SetNonNullable} from './source/set-non-nullable';
27+
export type {ValueOf} from './source/value-of';
28+
export type {AsyncReturnType} from './source/async-return-type';
29+
export type {ConditionalExcept} from './source/conditional-except';
30+
export type {ConditionalKeys} from './source/conditional-keys';
31+
export type {ConditionalPick} from './source/conditional-pick';
32+
export type {ConditionalPickDeep, ConditionalPickDeepOptions} from './source/conditional-pick-deep';
33+
export type {UnionToIntersection} from './source/union-to-intersection';
34+
export type {Stringified} from './source/stringified';
35+
export type {FixedLengthArray} from './source/fixed-length-array';
36+
export type {MultidimensionalArray} from './source/multidimensional-array';
37+
export type {MultidimensionalReadonlyArray} from './source/multidimensional-readonly-array';
38+
export type {IterableElement} from './source/iterable-element';
39+
export type {Entry} from './source/entry';
40+
export type {Entries} from './source/entries';
41+
export type {SetReturnType} from './source/set-return-type';
42+
export type {Asyncify} from './source/asyncify';
43+
export type {Simplify} from './source/simplify';
44+
export type {Jsonify} from './source/jsonify';
45+
export type {Schema} from './source/schema';
46+
export type {LiteralToPrimitive} from './source/literal-to-primitive';
47+
export type {
4848
PositiveInfinity,
4949
NegativeInfinity,
5050
Finite,
@@ -56,41 +56,41 @@ export {
5656
NegativeInteger,
5757
NonNegativeInteger,
5858
} from './source/numeric';
59-
export {StringKeyOf} from './source/string-key-of';
60-
export {Exact} from './source/exact';
61-
export {ReadonlyTuple} from './source/readonly-tuple';
62-
export {OptionalKeysOf} from './source/optional-keys-of';
63-
export {HasOptionalKeys} from './source/has-optional-keys';
64-
export {RequiredKeysOf} from './source/required-keys-of';
65-
export {HasRequiredKeys} from './source/has-required-keys';
66-
export {Spread} from './source/spread';
67-
export {TupleToUnion} from './source/tuple-to-union';
59+
export type {StringKeyOf} from './source/string-key-of';
60+
export type {Exact} from './source/exact';
61+
export type {ReadonlyTuple} from './source/readonly-tuple';
62+
export type {OptionalKeysOf} from './source/optional-keys-of';
63+
export type {HasOptionalKeys} from './source/has-optional-keys';
64+
export type {RequiredKeysOf} from './source/required-keys-of';
65+
export type {HasRequiredKeys} from './source/has-required-keys';
66+
export type {Spread} from './source/spread';
67+
export type {TupleToUnion} from './source/tuple-to-union';
6868

6969
// Template literal types
70-
export {CamelCase} from './source/camel-case';
71-
export {CamelCasedProperties} from './source/camel-cased-properties';
72-
export {CamelCasedPropertiesDeep} from './source/camel-cased-properties-deep';
73-
export {KebabCase} from './source/kebab-case';
74-
export {KebabCasedProperties} from './source/kebab-cased-properties';
75-
export {KebabCasedPropertiesDeep} from './source/kebab-cased-properties-deep';
76-
export {PascalCase} from './source/pascal-case';
77-
export {PascalCasedProperties} from './source/pascal-cased-properties';
78-
export {PascalCasedPropertiesDeep} from './source/pascal-cased-properties-deep';
79-
export {SnakeCase} from './source/snake-case';
80-
export {SnakeCasedProperties} from './source/snake-cased-properties';
81-
export {SnakeCasedPropertiesDeep} from './source/snake-cased-properties-deep';
82-
export {ScreamingSnakeCase} from './source/screaming-snake-case';
83-
export {DelimiterCase} from './source/delimiter-case';
84-
export {DelimiterCasedProperties} from './source/delimiter-cased-properties';
85-
export {DelimiterCasedPropertiesDeep} from './source/delimiter-cased-properties-deep';
86-
export {Join} from './source/join';
87-
export {Split} from './source/split';
88-
export {Trim} from './source/trim';
89-
export {Replace} from './source/replace';
90-
export {Includes} from './source/includes';
91-
export {Get} from './source/get';
92-
export {LastArrayElement} from './source/last-array-element';
70+
export type {CamelCase} from './source/camel-case';
71+
export type {CamelCasedProperties} from './source/camel-cased-properties';
72+
export type {CamelCasedPropertiesDeep} from './source/camel-cased-properties-deep';
73+
export type {KebabCase} from './source/kebab-case';
74+
export type {KebabCasedProperties} from './source/kebab-cased-properties';
75+
export type {KebabCasedPropertiesDeep} from './source/kebab-cased-properties-deep';
76+
export type {PascalCase} from './source/pascal-case';
77+
export type {PascalCasedProperties} from './source/pascal-cased-properties';
78+
export type {PascalCasedPropertiesDeep} from './source/pascal-cased-properties-deep';
79+
export type {SnakeCase} from './source/snake-case';
80+
export type {SnakeCasedProperties} from './source/snake-cased-properties';
81+
export type {SnakeCasedPropertiesDeep} from './source/snake-cased-properties-deep';
82+
export type {ScreamingSnakeCase} from './source/screaming-snake-case';
83+
export type {DelimiterCase} from './source/delimiter-case';
84+
export type {DelimiterCasedProperties} from './source/delimiter-cased-properties';
85+
export type {DelimiterCasedPropertiesDeep} from './source/delimiter-cased-properties-deep';
86+
export type {Join} from './source/join';
87+
export type {Split} from './source/split';
88+
export type {Trim} from './source/trim';
89+
export type {Replace} from './source/replace';
90+
export type {Includes} from './source/includes';
91+
export type {Get} from './source/get';
92+
export type {LastArrayElement} from './source/last-array-element';
9393

9494
// Miscellaneous
95-
export {PackageJson} from './source/package-json';
96-
export {TsConfigJson} from './source/tsconfig-json';
95+
export type {PackageJson} from './source/package-json';
96+
export type {TsConfigJson} from './source/tsconfig-json';

package.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"url": "https://sindresorhus.com"
1212
},
1313
"engines": {
14-
"node": ">=12.20"
14+
"node": ">=14.16"
1515
},
1616
"scripts": {
1717
"test": "xo && tsd && tsc && node script/test/source-files-extension.js"
@@ -29,21 +29,22 @@
2929
"utilities",
3030
"omit",
3131
"merge",
32-
"json"
32+
"json",
33+
"generics"
3334
],
3435
"devDependencies": {
3536
"@sindresorhus/tsconfig": "~0.7.0",
3637
"expect-type": "^0.13.0",
37-
"tsd": "^0.20.0",
38-
"typescript": "^4.6.3",
39-
"xo": "^0.43.0"
38+
"tsd": "^0.23.0",
39+
"typescript": "^4.8.2",
40+
"xo": "^0.52.2"
4041
},
4142
"types": "./index.d.ts",
4243
"xo": {
4344
"rules": {
45+
"@typescript-eslint/ban-ts-comment": "off",
4446
"@typescript-eslint/ban-types": "off",
45-
"@typescript-eslint/indent": "off",
46-
"node/no-unsupported-features/es-builtins": "off",
47+
"@typescript-eslint/naming-convention": "off",
4748
"import/extensions": "off",
4849
"@typescript-eslint/no-redeclare": "off",
4950
"@typescript-eslint/no-confusing-void-expression": "off"

readme.md

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ PR welcome for additional commonly needed types and docs improvements. Read the
9595
npm install type-fest
9696
```
9797

98-
*Requires TypeScript >=4.2*
98+
*Requires TypeScript >=4.7*
9999

100100
## Usage
101101

@@ -234,7 +234,7 @@ Click the type names for complete docs.
234234
### Miscellaneous
235235

236236
- [`PackageJson`](source/package-json.d.ts) - Type for [npm's `package.json` file](https://docs.npmjs.com/creating-a-package-json-file). It also includes support for [TypeScript Declaration Files](https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html) and [Yarn Workspaces](https://classic.yarnpkg.com/lang/en/docs/workspaces/).
237-
- [`TsConfigJson`](source/tsconfig-json.d.ts) - Type for [TypeScript's `tsconfig.json` file](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html) (TypeScript 4.4).
237+
- [`TsConfigJson`](source/tsconfig-json.d.ts) - Type for [TypeScript's `tsconfig.json` file](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html).
238238

239239
## Declined types
240240

@@ -896,15 +896,3 @@ You can find some examples in the [TypeScript docs](https://www.typescriptlang.o
896896
## License
897897

898898
SPDX-License-Identifier: (MIT OR CC0-1.0)
899-
900-
---
901-
902-
<div align="center">
903-
<b>
904-
<a href="https://tidelift.com/subscription/pkg/npm-type-fest?utm_source=npm-type-fest&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
905-
</b>
906-
<br>
907-
<sub>
908-
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
909-
</sub>
910-
</div>

source/camel-case.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ type InnerCamelCaseStringArray<Parts extends readonly any[], PreviousPart> =
1313
? FirstPart extends undefined
1414
? ''
1515
: FirstPart extends ''
16-
? InnerCamelCaseStringArray<RemainingParts, PreviousPart>
17-
: `${PreviousPart extends '' ? FirstPart : Capitalize<FirstPart>}${InnerCamelCaseStringArray<RemainingParts, FirstPart>}`
16+
? InnerCamelCaseStringArray<RemainingParts, PreviousPart>
17+
: `${PreviousPart extends '' ? FirstPart : Capitalize<FirstPart>}${InnerCamelCaseStringArray<RemainingParts, FirstPart>}`
1818
: '';
1919

2020
/**

source/camel-cased-properties-deep.d.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ const result: CamelCasedPropertiesDeep<UserWithFriends> = {
4747
export type CamelCasedPropertiesDeep<Value> = Value extends Function
4848
? Value
4949
: Value extends Array<infer U>
50-
? Array<CamelCasedPropertiesDeep<U>>
51-
: Value extends Set<infer U>
52-
? Set<CamelCasedPropertiesDeep<U>> : {
53-
[K in keyof Value as CamelCase<K>]: CamelCasedPropertiesDeep<Value[K]>;
54-
};
50+
? Array<CamelCasedPropertiesDeep<U>>
51+
: Value extends Set<infer U>
52+
? Set<CamelCasedPropertiesDeep<U>> : {
53+
[K in keyof Value as CamelCase<K>]: CamelCasedPropertiesDeep<Value[K]>;
54+
};

source/camel-cased-properties.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const result: CamelCasedProperties<User> = {
3030
export type CamelCasedProperties<Value> = Value extends Function
3131
? Value
3232
: Value extends Array<infer U>
33-
? Value
34-
: {
33+
? Value
34+
: {
3535
[K in keyof Value as CamelCase<K>]: Value[K];
36-
};
36+
};

source/conditional-except.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ type NonStringKeysOnly = ConditionalExcept<Example, string>;
4040
@category Object
4141
*/
4242
export type ConditionalExcept<Base, Condition> = Except<
43-
Base,
44-
ConditionalKeys<Base, Condition>
43+
Base,
44+
ConditionalKeys<Base, Condition>
4545
>;

source/conditional-keys.d.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,17 @@ type StringKeysAndUndefined = ConditionalKeys<Example, string | undefined>;
3131
@category Object
3232
*/
3333
export type ConditionalKeys<Base, Condition> = NonNullable<
34-
// Wrap in `NonNullable` to strip away the `undefined` type from the produced union.
35-
{
36-
// Map through all the keys of the given base type.
37-
[Key in keyof Base]:
38-
// Pick only keys with types extending the given `Condition` type.
39-
Base[Key] extends Condition
40-
// Retain this key since the condition passes.
41-
? Key
42-
// Discard this key since the condition fails.
43-
: never;
34+
// Wrap in `NonNullable` to strip away the `undefined` type from the produced union.
35+
{
36+
// Map through all the keys of the given base type.
37+
[Key in keyof Base]:
38+
// Pick only keys with types extending the given `Condition` type.
39+
Base[Key] extends Condition
40+
// Retain this key since the condition passes.
41+
? Key
42+
// Discard this key since the condition fails.
43+
: never;
4444

4545
// Convert the produced object into a union type of the keys which passed the conditional test.
46-
}[keyof Base]
46+
}[keyof Base]
4747
>;

source/conditional-pick-deep.d.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,22 @@ Assert the condition according to the {@link ConditionalPickDeepOptions.conditio
1414
type AssertCondition<Type, Condition, Options extends ConditionalPickDeepOptions> = Options['condition'] extends 'equality'
1515
? IsEqual<Type, Condition>
1616
: Type extends Condition
17-
? true
18-
: false;
17+
? true
18+
: false;
1919

2020
/**
2121
ConditionalPickDeep options.
2222
2323
@see ConditionalPickDeep
2424
*/
25-
export interface ConditionalPickDeepOptions {
25+
export type ConditionalPickDeepOptions = {
2626
/**
2727
The condition assertion mode.
2828
2929
@default 'extends'
3030
*/
3131
condition?: 'extends' | 'equality';
32-
}
32+
};
3333

3434
/**
3535
Pick keys recursively from the shape that matches the given condition.
@@ -97,6 +97,6 @@ export type ConditionalPickDeep<
9797
[Key in keyof Type]: AssertCondition<Type[Key], Condition, Options> extends true
9898
? Type[Key]
9999
: Type[Key] extends object
100-
? ConditionalPickDeep<Type[Key], Condition, Options>
101-
: ConditionalPickDeepSymbol;
100+
? ConditionalPickDeep<Type[Key], Condition, Options>
101+
: ConditionalPickDeepSymbol;
102102
}, (ConditionalPickDeepSymbol | undefined) | Record<PropertyKey, never>>>;

0 commit comments

Comments
 (0)