Skip to content

Commit

Permalink
build: remove semver dependency (#587)
Browse files Browse the repository at this point in the history
Co-authored-by: Rebecca Stevens <[email protected]>
  • Loading branch information
fisker and RebeccaStevens authored Nov 26, 2024
1 parent 2b84fdf commit 8cec962
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 14 deletions.
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
"@phenomnomnominal/tsquery": "^6.1.3",
"@release-it/conventional-changelog": "^9.0.0",
"@types/eslint": "^8.56.5",
"@types/semver": "^7.5.8",
"@typescript-eslint/eslint-plugin": "^7.3.1",
"@typescript-eslint/parser": "^8.0.0",
"@typescript/vfs": "^1.5.0",
Expand Down Expand Up @@ -82,7 +81,6 @@
"prettier-plugin-curly": "^0.3.0",
"prettier-plugin-packagejson": "^2.4.7",
"release-it": "^17.0.1",
"semver": "^7.6.2",
"sentences-per-line": "^0.2.1",
"should-semantic-release": "^0.3.0",
"tsup": "^8.0.2",
Expand Down
6 changes: 0 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/types/utilities.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import semver from "semver";
import ts from "typescript";
import { describe, expect, it } from "vitest";

import { createSourceFileAndTypeChecker } from "../test/utils";
import { isTsVersionAtLeast } from "../utils";
import {
isFalsyType,
isPropertyReadonlyInType,
Expand Down Expand Up @@ -133,7 +133,7 @@ describe("symbolHasReadonlyDeclaration", () => {
expect(symbolHasReadonlyDeclaration(symbol, typeChecker)).toBe(expected);
});

if (semver.gte(ts.version, "5.0.0")) {
if (isTsVersionAtLeast(5, 0)) {
it("returns true when the symbol belongs to a property of a nested object literal directly passed into a function that declares the parameter with a const type parameter", () => {
const { sourceFile, typeChecker } = createSourceFileAndTypeChecker(`
declare const fn: <const A>(param: A) => unknown;
Expand Down
8 changes: 4 additions & 4 deletions src/types/utilities.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Code largely based on https://github.com/ajafff/tsutils
// Original license: https://github.com/ajafff/tsutils/blob/26b195358ec36d59f00333115aa3ffd9611ca78b/LICENSE

import semver from "semver";
import ts from "typescript";

import {
Expand All @@ -16,6 +15,7 @@ import {
isInConstContext,
} from "../nodes/utilities";
import { isNumericPropertyName } from "../syntax";
import { isTsVersionAtLeast } from "../utils";
import { getPropertyOfType } from "./getters";
import {
isFalseLiteralType,
Expand Down Expand Up @@ -420,14 +420,14 @@ export function unionTypeParts(type: ts.Type): ts.Type[] {
* ```
*/
export function typeIsLiteral(type: ts.Type): type is ts.LiteralType {
if (semver.lt(ts.version, "5.0.0")) {
if (isTsVersionAtLeast(5, 0)) {
return type.isLiteral();
} else {
return isTypeFlagSet(
type,
ts.TypeFlags.StringLiteral |
ts.TypeFlags.NumberLiteral |
ts.TypeFlags.BigIntLiteral,
);
} else {
return type.isLiteral();
}
}

0 comments on commit 8cec962

Please sign in to comment.