Skip to content

Commit 7ed2439

Browse files
committed
inline uncheckedindexed
1 parent c3cd7e9 commit 7ed2439

File tree

5 files changed

+27
-11
lines changed

5 files changed

+27
-11
lines changed

packages/toolkit/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,7 @@
107107
"immer": "^10.0.1",
108108
"redux": "5.0.0-alpha.5",
109109
"redux-thunk": "3.0.0-alpha.3",
110-
"reselect": "^4.1.8",
111-
"uncheckedindexed": "^0.0.1"
110+
"reselect": "^4.1.8"
112111
},
113112
"peerDependencies": {
114113
"react": "^16.9.0 || ^17.0.0 || ^18",

packages/toolkit/src/entities/models.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { UncheckedIndexedAccess } from 'uncheckedindexed'
1+
import type { UncheckedIndexedAccess } from '../uncheckedindexed'
22
import type { PayloadAction } from '../createAction'
33
import type { CastAny, Id } from '../tsHelpers'
44

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// inlined from https://github.com/EskiMojo14/uncheckedindexed
2+
// relies on remaining as a TS file, not .d.ts
3+
type IfMaybeUndefined<T, True, False> = [undefined] extends [T] ? True : False
4+
5+
const testAccess = ({} as Record<string, 0>).a
6+
7+
export type IfUncheckedIndexedAccess<True, False> = IfMaybeUndefined<
8+
typeof testAccess,
9+
True,
10+
False
11+
>
12+
13+
export type UncheckedIndexedAccess<T> = IfUncheckedIndexedAccess<
14+
T | undefined,
15+
T
16+
>

packages/toolkit/tsup.config.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,15 @@ export default defineConfig((options) => {
196196
if (format === 'cjs' && name === 'production.min') {
197197
writeCommonJSEntry(outputFolder, prefix)
198198
} else if (generateTypedefs) {
199+
if (folder === '') {
200+
// we need to delete the declaration file and replace it with the original source file
201+
fs.rmSync(path.join(outputFolder, 'uncheckedindexed.d.ts'))
202+
203+
fs.copyFileSync(
204+
'src/uncheckedindexed.ts',
205+
path.join(outputFolder, 'uncheckedindexed.ts')
206+
)
207+
}
199208
// TODO Copy/generate `.d.mts` files?
200209
// const inputTypedefsFile = `${outputFilename}.d.ts`
201210
// const outputTypedefsFile = `${outputFilename}.d.mts`

yarn.lock

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6793,7 +6793,6 @@ __metadata:
67936793
tsup: ^6.7.0
67946794
tsx: ^3.12.2
67956795
typescript: ~4.9
6796-
uncheckedindexed: ^0.0.1
67976796
vitest: ^0.30.1
67986797
yargs: ^15.3.1
67996798
peerDependencies:
@@ -28409,13 +28408,6 @@ fsevents@^1.2.7:
2840928408
languageName: node
2841028409
linkType: hard
2841128410

28412-
"uncheckedindexed@npm:^0.0.1":
28413-
version: 0.0.1
28414-
resolution: "uncheckedindexed@npm:0.0.1"
28415-
checksum: 66cf7c42df36eeb8520de61ed16df0b1506bb40ede645d9c146672799d2392a3ad8c7b54131b07ff764414dcc12bd74eca90c3fdf13f19631181e6198f916075
28416-
languageName: node
28417-
linkType: hard
28418-
2841928411
"unherit@npm:^1.0.4":
2842028412
version: 1.1.3
2842128413
resolution: "unherit@npm:1.1.3"

0 commit comments

Comments
 (0)