Skip to content

Commit 771f342

Browse files
committed
refactor(types)!: improve type implementations and tests
- require typescript>=5.0.4 - dropped EnsureString, Keys, MergeDefaults, OmitNative, Omit, PickNative, Pick - MergeDefaults functionality merged into Merge - TupleLength -> Length - TupleToUnion -> ArrayToUnion - Omit and Pick were improved, but are still under review - added several new types Signed-off-by: Lexus Drumgold <[email protected]>
1 parent b159afe commit 771f342

File tree

299 files changed

+12660
-2611
lines changed

Some content is hidden

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

299 files changed

+12660
-2611
lines changed

.attw.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"color": true,
3+
"emoji": true,
4+
"format": "ascii",
5+
"ignoreRules": [],
6+
"summary": true
7+
}

.codecov.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,6 @@ ignore:
8989
- '**/__mocks__/**'
9090
- '**/__tests__/**'
9191
- '**/index.ts'
92-
- src/interfaces/
93-
- src/types/
92+
- '**/interfaces'
93+
- '**/types'
9494
- src/utils/*.options.ts

.dictionary.txt

+5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
abcdefghijklmnopqrstuvwyz
12
ardatan
3+
attw
24
bdougie
35
booleanish
46
cefc
@@ -31,6 +33,9 @@ promisable
3133
stringafiable
3234
tryit
3335
tscu
36+
uncapitalize
3437
unstub
3538
vates
39+
vitest
3640
yarnrc
41+
zyxwvutsrqponmlkjihgfedcba

.eslintrc.base.cjs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1166,7 +1166,9 @@ const config = {
11661166
implementsReplacesDocs: true,
11671167
overrideReplacesDocs: true,
11681168
preferredTypes: {
1169-
'*': false
1169+
'*': false,
1170+
'.<>': false,
1171+
'Array<>': { replacement: '[]' }
11701172
},
11711173
structuredTags: {
11721174
const: {

.eslintrc.cjs

+6-22
Original file line numberDiff line numberDiff line change
@@ -13,35 +13,19 @@ const config = {
1313
overrides: [
1414
...require('./.eslintrc.base.cjs').overrides,
1515
{
16-
files: [
17-
'src/types/built-in.ts',
18-
'src/types/fn.ts',
19-
'src/types/simplify.ts'
20-
],
21-
rules: {
22-
'@typescript-eslint/ban-types': 0
23-
}
24-
},
25-
{
26-
files: ['src/types/built-in.ts'],
16+
files: ['src/interfaces/map-like.ts'],
2717
rules: {
28-
'@typescript-eslint/array-type': 0
18+
'@typescript-eslint/consistent-indexed-object-style': 0
2919
}
3020
},
3121
{
3222
files: [
33-
'src/types/head.ts',
34-
'src/types/is-tuple.ts',
35-
'src/types/tail.ts'
23+
'src/types/built-in.ts',
24+
'src/types/fn.ts',
25+
'src/types/is-index-signature.ts'
3626
],
3727
rules: {
38-
'@typescript-eslint/no-unused-vars': 0
39-
}
40-
},
41-
{
42-
files: ['src/interfaces/map-like.ts'],
43-
rules: {
44-
'@typescript-eslint/consistent-indexed-object-style': 0
28+
'@typescript-eslint/ban-types': 0
4529
}
4630
}
4731
],

.github/dependabot.yml

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ updates:
3030
prefix: build
3131
include: scope
3232
directory: /
33+
ignore:
34+
- dependency-name: vitest
3335
labels:
3436
- scope:dependencies
3537
- type:build

.github/infrastructure.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ branches:
4040
- context: test (18)
4141
- context: test (19)
4242
- context: test (20)
43-
- context: typescript (5.1.0-beta)
43+
- context: typescript (5.0.4)
44+
- context: typescript (5.1.6)
4445
- context: typescript (latest)
45-
- context: typescript (~4.9.0)
4646
strict: true
4747
restrictions: null
4848
# https://docs.github.com/rest/deployments/environments#create-or-update-an-environment

.github/workflows/ci.yml

+15-11
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ jobs:
236236
typescript-version:
237237
- ${{ needs.preflight.outputs.version-typescript }}
238238
- latest
239-
- ~4.9.0
239+
- 5.0.4
240240
steps:
241241
- id: checkout
242242
name: Checkout ${{ env.REF_NAME }}
@@ -268,15 +268,10 @@ jobs:
268268
if: steps.test-files-check.outputs.files_exists == 'true'
269269
name: Install typescript@${{ matrix.typescript-version }}
270270
run: yarn add -D typescript@${{ matrix.typescript-version }}
271-
- id: set-typescript-version
272-
if: steps.test-files-check.outputs.files_exists == 'true'
273-
name: Set env.TYPESCRIPT_VERSION
274-
run: |
275-
echo "TYPESCRIPT_VERSION=$(jq .devDependencies.typescript package.json -r)" >>$GITHUB_ENV
276271
- id: print-typescript-version
277272
if: steps.test-files-check.outputs.files_exists == 'true'
278273
name: Print TypeScript version
279-
run: echo $TYPESCRIPT_VERSION
274+
run: jq .devDependencies.typescript package.json -r
280275
- id: typecheck
281276
if: steps.test-files-check.outputs.files_exists == 'true'
282277
name: Run typecheck
@@ -352,6 +347,10 @@ jobs:
352347
- gitguardian
353348
- preflight
354349
runs-on: ubuntu-latest
350+
env:
351+
TARFILE: |
352+
${{ startsWith(github.ref_name, 'release/') && format('@{0}-{1}-{2}.tgz', github.repository_owner, github.event.repository.name, needs.preflight.outputs.version)
353+
|| format('@{0}-{1}-{2}+{3}.tgz', github.repository_owner, github.event.repository.name, needs.preflight.outputs.version, github.event.pull_request.head.sha || github.sha) }}
355354
steps:
356355
- id: checkout
357356
name: Checkout ${{ env.REF_NAME }}
@@ -372,19 +371,24 @@ jobs:
372371
with:
373372
key: ${{ runner.os }}-${{ github.run_id }}
374373
path: ${{ env.CACHE_PATH }}
374+
- id: local-binaries
375+
name: Add local binaries to $PATH
376+
run: echo "$GITHUB_WORKSPACE/$CACHE_PATH/.bin" >> $GITHUB_PATH
375377
- id: pack
376378
name: Pack project
377-
run: yarn pack -o %s-%v.tgz
379+
run: yarn pack -o ${{ env.TARFILE }}
378380
- id: typecheck
379381
name: Run typecheck
380382
run: yarn check:types:build
383+
- id: attw
384+
name: Analyze types distribution
385+
run: attw ${{ env.TARFILE }}
381386
- id: pkg-size-report
382387
name: Package size report
383388
run: yarn pkg-size
384389
- id: archive
385390
name: Archive production artifacts
386391
uses: actions/[email protected]
387392
with:
388-
name: |
389-
${{ format('@{0}-{1}-{2}', github.repository_owner, github.event.repository.name, needs.preflight.outputs.version) }}
390-
path: '*.tgz'
393+
name: ${{ env.TARFILE }}
394+
path: ${{ env.TARFILE }}

.github/workflows/typescript-canary.yml

+2-6
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ name: typescript-canary
2121
on:
2222
schedule:
2323
# every day, 3 hours after typescript@next release
24-
# https://github.com/microsoft/TypeScript/blob/v4.9.5/.github/workflows/nightly.yaml
24+
# https://github.com/microsoft/TypeScript/blob/v5.0.4/.github/workflows/nightly.yaml
2525
- cron: 0 10 * * *
2626
workflow_dispatch:
2727
permissions:
@@ -65,13 +65,9 @@ jobs:
6565
- id: typescript
6666
name: Install typescript@${{ matrix.typescript-version }}
6767
run: yarn add -D typescript@${{ matrix.typescript-version }}
68-
- id: set-typescript-version
69-
name: Set env.TYPESCRIPT_VERSION
70-
run: |
71-
echo "TYPESCRIPT_VERSION=$(jq .devDependencies.typescript package.json -r)" >>$GITHUB_ENV
7268
- id: print-typescript-version
7369
name: Print TypeScript version
74-
run: echo $TYPESCRIPT_VERSION
70+
run: jq .devDependencies.typescript package.json -r
7571
- id: build
7672
name: Build project
7773
run: yarn build

.vscode/settings.json

+1
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@
256256
"shellformat.flag": "-ci -fn -i=2 -sr",
257257
"shellformat.useEditorConfig": true,
258258
"terminal.integrated.copyOnSelection": true,
259+
"terminal.integrated.scrollback": 10000,
259260
"todo-tree.filtering.ignoreGitSubmodules": true,
260261
"todo-tree.filtering.includeHiddenFiles": false,
261262
"todo-tree.filtering.useBuiltInExcludes": "file and search excludes",

__fixtures__/book.interface.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* @module tests/fixtures/Book
44
*/
55

6+
import type { Nullable, Simplify } from '#src/types'
67
import type Author from './author.interface'
78
import type Publisher from './publisher.interface'
89

@@ -23,7 +24,7 @@ interface Book {
2324
/**
2425
* Book publisher.
2526
*/
26-
publisher?: Publisher
27+
publisher?: Nullable<Simplify<Publisher>>
2728

2829
/**
2930
* Book readers.

__fixtures__/ordered-pair.ts

-26
This file was deleted.

__fixtures__/vehicle.ts

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* @file Test Fixtures - Vehicle
3+
* @module tests/fixtures/Vehicle
4+
*/
5+
6+
/**
7+
* Object representing a vehicle.
8+
*/
9+
type Vehicle = {
10+
/**
11+
* Vehicle brand.
12+
*/
13+
make: string
14+
15+
/**
16+
* Vehicle model.
17+
*/
18+
model: string
19+
20+
/**
21+
* Vehicle identification number.
22+
*/
23+
vin: string
24+
25+
/**
26+
* Vehicle model year.
27+
*/
28+
year: number
29+
}
30+
31+
export type { Vehicle as default }

0 commit comments

Comments
 (0)