Skip to content

Commit ccb8de3

Browse files
authored
fix(typing)!: remove record, rename callback to Callback and TypeOf to TypeOfEnum (#110)
1 parent 35b4ef5 commit ccb8de3

File tree

22 files changed

+90
-115
lines changed

22 files changed

+90
-115
lines changed

.github/deno_bump.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
// deno-lint-ignore-file no-console no-external-import
1+
// deno-lint-ignore-file no-console no-external-import no-import-prefix
22
// Imports
3-
import type { record } from "@libs/typing"
43
import { fromFileUrl, resolve } from "@std/path"
54
import { parseArgs } from "@std/cli"
65
import { assert } from "jsr:@std/assert@^1.0.14"
@@ -18,7 +17,7 @@ console.log(`patching: ${path}`)
1817

1918
// Patch config version
2019
const raw = await Deno.readTextFile(path)
21-
const config = JSONC.parse(raw) as record<string>
20+
const config = JSONC.parse(raw) as Record<PropertyKey, string>
2221
const { version: previous } = config
2322
console.log(`version: ${previous}${version}`)
2423
assert(semver.greaterThan(semver.parse(version), semver.parse(previous)), "expected new version to be greater than previous one")

.github/deno_flags.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// deno-lint-ignore-file no-console
22
// Imports
3-
import type { record } from "@libs/typing"
43
import { parseArgs } from "@std/cli"
54
import { flags } from "@libs/testing/permissions"
65
import * as JSONC from "@std/jsonc"
@@ -12,6 +11,6 @@ if (cwd) {
1211
}
1312

1413
// Resolve config path and parse JSONC
15-
const config = JSONC.parse(await Deno.readTextFile("./deno.jsonc")) as record
14+
const config = JSONC.parse(await Deno.readTextFile("./deno.jsonc")) as Record<PropertyKey, unknown>
1615

1716
console.log(flags(config["test:permissions"] ?? null))

.github/deno_readme.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// deno-lint-ignore-file no-external-import
1+
// deno-lint-ignore-file no-external-import no-import-prefix
22
// Imports
33
import { expandGlob } from "jsr:@std/fs@^1.0.19"
44
import { basename, dirname, fromFileUrl, resolve } from "@std/path"

bundle/ts/publish/mod.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
* @module
44
*/
55
export type { DeepReadonly, Logger } from "@libs/logger"
6-
export type { Arg, record } from "@libs/typing"
6+
export type { Arg } from "@libs/typing"
77
export { type package_output, type packaged, publish as publishNpm, type registry } from "./npm.ts"
88
export { type options as publish_x_options, publish as publishX } from "./x.ts"

bundle/ts/publish/npm.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@
55

66
// Imports
77
import * as JSONC from "@std/jsonc"
8-
import type { Arg, Optional, record } from "@libs/typing"
8+
import type { Arg, Optional } from "@libs/typing"
99
import { assertMatch } from "@std/assert"
1010
import { Logger } from "@libs/logger"
1111
import { bundle } from "../bundle.ts"
1212
import { dirname, resolve, toFileUrl } from "@std/path"
1313
import { command } from "@libs/run/command"
14-
export type { Arg, Logger, record }
14+
export type { Arg, Logger }
1515

1616
/** Transform a `deno.jsonc` file into a `package.json` and bundle exported entrypoints to make package publishable on json. */
1717
export async function packaged(path = "deno.jsonc", { logger: log = new Logger(), scope = undefined as Optional<string>, name = undefined as Optional<string> } = {}): Promise<package_output> {
1818
path = resolve(path)
1919
log.debug(`processing: ${path}`)
20-
const mod = JSONC.parse(await Deno.readTextFile(path)) as record<string> & { exports?: record<string> }
20+
const mod = JSONC.parse(await Deno.readTextFile(path)) as Record<PropertyKey, string> & { exports?: Record<PropertyKey, string> }
2121
// Validate package name
2222
assertMatch(mod.name, /^@[a-z0-9-]+\/[a-z0-9-]+$/)
2323
const [_scope, _name] = mod.name.split("/")
@@ -47,7 +47,7 @@ export async function packaged(path = "deno.jsonc", { logger: log = new Logger()
4747
}
4848

4949
// Copy exports
50-
const exports = {} as record<string>
50+
const exports = {} as Record<PropertyKey, string>
5151
if (mod.exports) {
5252
json.exports = {}
5353
for (const [key, value] of Object.entries(mod.exports) as [string, string][]) {
@@ -114,20 +114,20 @@ export type package_output = {
114114
name: string
115115
version: string
116116
type: "module"
117-
scripts: record<string>
118-
exports?: record<string>
117+
scripts: Record<PropertyKey, string>
118+
exports?: Record<PropertyKey, string>
119119
description?: string
120120
keywords?: string | string[]
121121
license?: string
122122
author?: string
123123
homepage?: string
124124
repository?: string
125125
funding?: string
126-
dependencies: record<string>
127-
devDependencies?: record<string>
126+
dependencies: Record<PropertyKey, string>
127+
devDependencies?: Record<PropertyKey, string>
128128
}
129129
/** Exported entrypoints. */
130-
exports: record<string>
130+
exports: Record<PropertyKey, string>
131131
}
132132

133133
/** Registry configuration. */

bundle/ts/publish/x.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { retry } from "@std/async/retry"
1212
import * as JSONC from "@std/jsonc"
1313
import { expandGlob } from "@std/fs"
1414
import { resolve } from "@std/path"
15-
import type { record } from "@libs/typing"
1615
import { unmap as _unmap } from "../unmap.ts"
1716
export type { Logger }
1817

@@ -234,7 +233,7 @@ export async function publish({ logger: log = new Logger(), token, repository, d
234233
/** Resolve import map. */
235234
async function unmap({ log: logger, map, exclude = [], dryrun }: { log: Logger; map: string; directory?: string; exclude?: string[]; dryrun?: boolean }) {
236235
const root = resolve(".").replaceAll("\\", "/")
237-
const { imports } = JSONC.parse(await Deno.readTextFile(resolve(root, map))) as record<record<string>>
236+
const { imports } = JSONC.parse(await Deno.readTextFile(resolve(root, map))) as Record<PropertyKey, Record<PropertyKey, string>>
238237
exclude.push("node_modules")
239238
logger.log(`processing files in ${root}`)
240239
for await (const { path } of expandGlob("**/*.ts", { root, exclude })) {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// deno-lint-ignore-file no-console no-external-import
1+
// deno-lint-ignore-file no-console no-external-import no-import-prefix
22
// Example module with specifiers
3-
import { red } from "jsr:@std/fmt/colors"
3+
import { red } from "jsr:@std/fmt@1/colors"
44
import { inspect } from "node:util"
55
console.log(red, inspect)
66
console.log("success" as string)

bundle/ts/unmap.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
// Imports
22
import { Logger } from "@libs/logger"
3-
import type { Nullable, record } from "@libs/typing"
4-
export type { record }
3+
import type { Nullable } from "@libs/typing"
54

65
/** Regex for `imports` parsing. */
76
const regex = /^(?<statement>import\s*(?:(?:\s+type)?\s+(?:[^\n]+?|(?:\{[\s\S]*?\}))\s+from\s+)?(?<quote>["']))(?<module>[^\n]+?)\k<quote>/gm
87

98
/** Resolves all imports from file content against an import map. */
10-
export function unmap(content: string, imports: record<string>, { logger: log = new Logger() } = {}): { result: string; resolved: number } {
9+
export function unmap(content: string, imports: Record<PropertyKey, string>, { logger: log = new Logger() } = {}): { result: string; resolved: number } {
1110
let resolved = 0
1211
const directories = Object.keys(imports).filter((module) => module.endsWith("/")) as string[]
1312
const result = content.replace(regex, function (match, statement, quote, module, i) {

bundle/wasm/bundle.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ import { UntarStream } from "@std/tar/untar-stream"
66
import { ensureFile } from "@std/fs"
77
import { basename, dirname, resolve, toFileUrl } from "@std/path"
88
import { Logger } from "@libs/logger"
9-
import type { record } from "@libs/typing"
109
import { command } from "@libs/run/command"
11-
export type { record }
1210

1311
/**
1412
* Build WASM, bundle and minify JavaScript.
@@ -22,7 +20,7 @@ export type { record }
2220
*
2321
* @module
2422
*/
25-
export async function bundle(project: string, { bin = "wasm-pack", autoinstall = false, banner, logger: log = new Logger(), env = {} } = {} as { bin?: string; autoinstall?: boolean; banner?: string; logger?: Logger; env?: record<string> }): Promise<void> {
23+
export async function bundle(project: string, { bin = "wasm-pack", autoinstall = false, banner, logger: log = new Logger(), env = {} } = {} as { bin?: string; autoinstall?: boolean; banner?: string; logger?: Logger; env?: Record<PropertyKey, string> }): Promise<void> {
2624
log = log.with({ project })
2725

2826
// Check that cargo is installed

deno.jsonc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@
5454
],
5555
"nodeModulesDir": "auto",
5656
"imports": {
57-
"@std/cli": "jsr:@std/cli@^1.0.21",
58-
"@std/fmt": "jsr:@std/fmt@1",
59-
"@std/jsonc": "jsr:@std/jsonc@1",
57+
"@std/cli": "jsr:@std/cli@^1.0.22",
58+
"@std/fmt": "jsr:@std/fmt@^1.0.8",
59+
"@std/jsonc": "jsr:@std/jsonc@^1.0.2",
6060
"@std/path": "jsr:@std/path@^1.1.2"
6161
},
6262
"test:permissions": true,

0 commit comments

Comments
 (0)