feat: use @optolith/helpers package

This commit is contained in:
Lukas Obermann
2024-10-06 12:43:26 +02:00
parent aeea73b713
commit bfbb1075c1
7 changed files with 18 additions and 13 deletions
+12
View File
@@ -9,6 +9,7 @@
"version": "0.10.7",
"license": "MPL-2.0",
"dependencies": {
"@optolith/helpers": "^0.2.1",
"typescript": "^5.2.2"
},
"bin": {
@@ -513,6 +514,12 @@
"url": "https://github.com/chalk/wrap-ansi?sponsor=1"
}
},
"node_modules/@optolith/helpers": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/@optolith/helpers/-/helpers-0.2.1.tgz",
"integrity": "sha512-i2mg5ro2XaY0sFT3vwW+BBuMYVuJpHRMt27X9/sBfXmgY6L16aKG3UXEcP5jjX+/gjH2AM7Uiz6xgtV31/rFLw==",
"license": "MPL-2.0"
},
"node_modules/@pkgjs/parseargs": {
"version": "0.11.0",
"resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz",
@@ -3218,6 +3225,11 @@
}
}
},
"@optolith/helpers": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/@optolith/helpers/-/helpers-0.2.1.tgz",
"integrity": "sha512-i2mg5ro2XaY0sFT3vwW+BBuMYVuJpHRMt27X9/sBfXmgY6L16aKG3UXEcP5jjX+/gjH2AM7Uiz6xgtV31/rFLw=="
},
"@pkgjs/parseargs": {
"version": "0.11.0",
"resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz",
+1
View File
@@ -28,6 +28,7 @@
"author": "Lukas Obermann",
"license": "MPL-2.0",
"dependencies": {
"@optolith/helpers": "^0.2.1",
"typescript": "^5.2.2"
},
"devDependencies": {
+2 -2
View File
@@ -1,3 +1,5 @@
import { isNotNullish } from "@optolith/helpers/nullable"
import { assertExhaustive } from "@optolith/helpers/typeSafety"
import {
ContentNode,
EnumerationNode,
@@ -10,8 +12,6 @@ import {
TypeDefinitionNode,
isExportAssignmentNode,
} from "../ast.js"
import { assertExhaustive } from "../utils/assertExhaustive.js"
import { isNotNullish } from "../utils/nullable.js"
enum ScopeTypeKind {
Default,
+1 -1
View File
@@ -1,3 +1,4 @@
import { assertExhaustive } from "@optolith/helpers/typeSafety"
import { EOL } from "node:os"
import { sep } from "node:path"
import {
@@ -12,7 +13,6 @@ import {
isReferenceNode,
} from "../ast.js"
import { AstTransformer, Renderer } from "../main.js"
import { assertExhaustive } from "../utils/assertExhaustive.js"
import {
getAliasedImportName,
getFullyQualifiedNameAsPath,
+2 -2
View File
@@ -1,3 +1,5 @@
import { isNotNullish } from "@optolith/helpers/nullable"
import { assertExhaustive } from "@optolith/helpers/typeSafety"
import { EOL } from "node:os"
import {
ArrayNode,
@@ -20,8 +22,6 @@ import {
isTokenNode,
} from "../ast.js"
import { AstTransformer, Renderer } from "../main.js"
import { assertExhaustive } from "../utils/assertExhaustive.js"
import { isNotNullish } from "../utils/nullable.js"
import {
getRightmostQualifiedNameSegment,
qualifiedNameToArray,
-6
View File
@@ -1,6 +0,0 @@
export function assertExhaustive(
_x: never,
msg: string = "The switch is not exhaustive."
): never {
throw new Error(msg)
}
-2
View File
@@ -1,2 +0,0 @@
export const isNotNullish = <T>(value: T): value is NonNullable<T> =>
value !== null && value !== undefined