Skip to content

Commit

Permalink
Require Node.js 18
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Jul 26, 2024
1 parent 40b2cd9 commit 614d777
Show file tree
Hide file tree
Showing 13 changed files with 46 additions and 36 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ jobs:
- 18
- 16
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm install
Expand Down
34 changes: 18 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@
"url": "https://sindresorhus.com"
},
"type": "module",
"exports": "./distribution/index.js",
"types": "./distribution/index.d.ts",
"exports": {
"types": "./distribution/index.d.ts",
"default": "./distribution/index.js"
},
"sideEffects": false,
"engines": {
"node": ">=14.16"
"node": ">=18"
},
"scripts": {
"build": "del-cli distribution && tsc",
Expand All @@ -39,31 +42,30 @@
"helpers"
],
"dependencies": {
"type-fest": "^2.18.0"
"type-fest": "^4.23.0"
},
"devDependencies": {
"@sindresorhus/tsconfig": "^3.0.1",
"ava": "^4.3.1",
"del-cli": "^5.0.0",
"expect-type": "^0.13.0",
"ts-node": "^10.9.1",
"typescript": "^4.7.4",
"xo": "^0.51.0"
"@sindresorhus/tsconfig": "^6.0.0",
"ava": "^6.1.3",
"del-cli": "^5.1.0",
"expect-type": "^0.19.0",
"tsx": "^4.16.2",
"typescript": "^5.5.4",
"xo": "^0.58.0"
},
"sideEffects": false,
"ava": {
"extensions": {
"ts": "module"
},
"nodeArguments": [
"--loader=ts-node/esm"
]
"--import=tsx/esm"
],
"workerThreads": false
},
"xo": {
"rules": {
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/naming-convention": "off",
"no-lone-blocks": "off"
"@typescript-eslint/naming-convention": "off"
}
}
}
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# ts-extras [![](https://img.shields.io/badge/unicorn-approved-ff69b4.svg)](https://giphy.com/gifs/illustration-rainbow-unicorn-26AHG5KGFxSkUWw1i) <!-- Hidden until they actually show some useful info [![npm dependents](https://badgen.net/npm/dependents/ts-extras)](https://www.npmjs.com/package/ts-extras?activeTab=dependents) [![npm downloads](https://badgen.net/npm/dt/ts-extras)](https://www.npmjs.com/package/ts-extras) --> [![Docs](https://paka.dev/badges/v0/cute.svg)](https://paka.dev/npm/ts-extras)
# ts-extras [![](https://img.shields.io/badge/unicorn-approved-ff69b4.svg)](https://giphy.com/gifs/illustration-rainbow-unicorn-26AHG5KGFxSkUWw1i) [![npm dependents](https://badgen.net/npm/dependents/ts-extras)](https://www.npmjs.com/package/ts-extras?activeTab=dependents) [![npm downloads](https://badgen.net/npm/dt/ts-extras)](https://www.npmjs.com/package/ts-extras)

> Essential utilities for TypeScript projects
*Still early in development. Ideas for additional **essential** utilities welcome. Type-only utilities belong in [type-fest](https://github.com/sindresorhus/type-fest).*
*Ideas for additional **essential** utilities welcome. Type-only utilities belong in [type-fest](https://github.com/sindresorhus/type-fest).*

## Install

Expand Down
6 changes: 3 additions & 3 deletions source/as-mutable.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Mutable} from 'type-fest';
import {type Writable} from 'type-fest';

/**
Cast the given value to be [`Mutable`](https://github.com/sindresorhus/type-fest/blob/main/source/mutable.d.ts).
Cast the given value to be [`Writable`](https://github.com/sindresorhus/type-fest/blob/main/source/writable.d.ts).
This is useful because of a TypeScript limitation: https://github.com/microsoft/TypeScript/issues/45618#issuecomment-908072756
Expand All @@ -14,6 +14,6 @@ const mutableContext = asMutable((await import('x')).context);
@category General
*/
export function asMutable<T>(value: T): Mutable<T> {
export function asMutable<T>(value: T): Writable<T> {
return value as any; // eslint-disable-line @typescript-eslint/no-unsafe-return
}
2 changes: 1 addition & 1 deletion source/is-finite.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Finite} from 'type-fest';
import {type Finite} from 'type-fest';

/**
An alternative to `Number.isFinite()` that properly acts as a type guard.
Expand Down
2 changes: 1 addition & 1 deletion source/is-infinite.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {NegativeInfinity, PositiveInfinity} from 'type-fest';
import {type NegativeInfinity, type PositiveInfinity} from 'type-fest';

/**
Check whether a value is infinite.
Expand Down
2 changes: 1 addition & 1 deletion source/is-integer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Integer} from 'type-fest';
import {type Integer} from 'type-fest';

/**
An alternative to `Number.isInteger()` that properly acts as a type guard.
Expand Down
2 changes: 1 addition & 1 deletion source/is-safe-integer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Integer} from 'type-fest';
import {type Integer} from 'type-fest';

/**
An alternative to `Number.isSafeInteger()` that properly acts as a type guard.
Expand Down
2 changes: 1 addition & 1 deletion source/object-entries.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ObjectKeys} from './object-keys.js';
import {type ObjectKeys} from './object-keys.js';

/**
A strongly-typed version of `Object.entries()`.
Expand Down
2 changes: 1 addition & 1 deletion test/is-infinite.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import test from 'ava';
import {expectTypeOf} from 'expect-type';
import {NegativeInfinity, PositiveInfinity} from 'type-fest';
import {type NegativeInfinity, type PositiveInfinity} from 'type-fest';
import {isInfinite} from '../source/index.js';

test('isInfinite()', t => {
Expand Down
5 changes: 4 additions & 1 deletion test/object-entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@ test('objectEntries()', t => {
};

const x: Foo = {};
expectTypeOf<Array<['a', string]>>(objectEntries(x));
const entries = objectEntries(x);
expectTypeOf<Array<['a', string]>>(entries);

expectTypeOf<['a', string] | undefined>(entries[0]);
}
14 changes: 11 additions & 3 deletions test/object-keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,22 @@ import test from 'ava';
import {expectTypeOf} from 'expect-type';
import {objectKeys} from '../source/index.js';

interface TestInterface {
type TestInterface = {
e: string;
f: number;
}
};

test('objectKeys()', t => {
type Item = 'a' | 'b' | 'c' | '4';
const items = objectKeys({a: 1, b: 2, c: 3, 4: 4, [Symbol('5')]: 5});

const items = objectKeys({
a: 1,
b: 2,
c: 3,
4: 4,
[Symbol('5')]: 5,
});

expectTypeOf<Item[]>(items);
t.deepEqual(items, ['4', 'a', 'b', 'c']);

Expand Down
3 changes: 0 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"extends": "@sindresorhus/tsconfig",
"compilerOptions": {
"outDir": "distribution"
},
"include": [
"source"
]
Expand Down

0 comments on commit 614d777

Please sign in to comment.