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

chore: bumped minimum TypeScript version to 4.3 #207

Merged
merged 5 commits into from
Jun 15, 2023
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
8 changes: 4 additions & 4 deletions .github/actions/protect-main/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ runs:
{ context: "packages" },
{ context: "prettier" },
{ context: "spelling" },
{ context: "test (16.13.0, 4.2.4)" },
{ context: "test (16.13.0, 4.3.5)" },
{ context: "test (16.13.0, 4.4.4)" },
{ context: "test (16.13.0, 4.6.4)" },
{ context: "test (16.13.0, 4.9.5)" },
{ context: "test (16.13.0, latest)" },
{ context: "test (18.x, 4.2.4)" },
{ context: "test (18.x, 4.3.5)" },
{ context: "test (18.x, 4.4.4)" },
{ context: "test (18.x, 4.6.4)" },
{ context: "test (18.x, 4.9.5)" },
{ context: "test (18.x, latest)" },
{ context: "type-check" },
],
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ jobs:
fail-fast: false
matrix:
node_version:
- "16.13.0"
- "18.x"
- "16.13.0"
ts_version:
- "latest"
- "4.4.4"
- "4.9.5"
- "4.6.4"
- "4.3.5"
- "4.2.4"
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/prepare
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ts-api-utils",
"version": "0.1.0",
"version": "0.2.0",
"description": "Utility functions for working with TypeScript's API. Successor to the wonderful tsutils.",
"repository": {
"type": "git",
Expand Down
6 changes: 1 addition & 5 deletions src/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

import ts from "typescript";

import { isTsVersionAtLeast } from "./utils";

/**
* Callback type used for {@link forEachToken}.
*
Expand Down Expand Up @@ -35,11 +33,9 @@ export function forEachToken(
callback: ForEachTokenCallback,
sourceFile: ts.SourceFile = node.getSourceFile()
): void {
const isTS4dot3 = isTsVersionAtLeast(4, 3);

const queue = [];
while (true) {
if (isTS4dot3 && ts.isTokenKind(node.kind)) {
if (ts.isTokenKind(node.kind)) {
callback(node);
} else if (
// eslint-disable-next-line deprecation/deprecation -- need for support of TS < 4.7
Expand Down
25 changes: 11 additions & 14 deletions src/types/getters.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import ts from "typescript";
import { describe, expect, it } from "vitest";

import { createSourceFileAndTypeChecker } from "../test/utils";
import { isTsVersionAtLeast } from "../utils";
import {
getCallSignaturesOfType,
getWellKnownSymbolPropertyOfType,
Expand Down Expand Up @@ -77,25 +76,23 @@ describe("getWellKnownSymbolPropertyOfType", () => {
});
});

if (isTsVersionAtLeast(4, 3)) {
// https://github.com/JoshuaKGoldberg/ts-api-tools/issues/15
it("finds the symbol for an `asyncIterator` property when that property isn't directly on the type", () => {
const { sourceFile, typeChecker } = createSourceFileAndTypeChecker(`
// https://github.com/JoshuaKGoldberg/ts-api-tools/issues/15
it("finds the symbol for an `asyncIterator` property when that property isn't directly on the type", () => {
const { sourceFile, typeChecker } = createSourceFileAndTypeChecker(`
declare const x: Omit<{
[Symbol.asyncIterator](): AsyncIterator<any>;
}, 'z'>
`);

const node = (sourceFile.statements[0] as ts.VariableStatement)
.declarationList.declarations[0].name;
const node = (sourceFile.statements[0] as ts.VariableStatement)
.declarationList.declarations[0].name;

const type = typeChecker.getTypeAtLocation(node);
const type = typeChecker.getTypeAtLocation(node);

expect(
getWellKnownSymbolPropertyOfType(type, "asyncIterator", typeChecker)
).toMatchObject({
name: /^__@asyncIterator/,
});
expect(
getWellKnownSymbolPropertyOfType(type, "asyncIterator", typeChecker)
).toMatchObject({
name: /^__@asyncIterator/,
});
}
});
});
Loading