Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: remove semver dependency #587

Merged
merged 4 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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 typeIsLiteral(type: ts.Type): type is ts.LiteralType {
if (semver.lt(ts.version, "5.0.0")) {
if (isTsVersionAtLeast(5, 0)) {
return type.isLiteral();

Check warning on line 424 in src/types/utilities.ts

View check run for this annotation

Codecov / codecov/patch

src/types/utilities.ts#L424

Added line #L424 was not covered by tests
} else {
return isTypeFlagSet(
type,
ts.TypeFlags.StringLiteral |
ts.TypeFlags.NumberLiteral |
ts.TypeFlags.BigIntLiteral,
);
} else {
return type.isLiteral();
}
}
Loading