diff --git a/.github/actions/protect-main/action.yml b/.github/actions/protect-main/action.yml index 940238ab..9c67d0d4 100644 --- a/.github/actions/protect-main/action.yml +++ b/.github/actions/protect-main/action.yml @@ -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" }, ], diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 815815d4..015b9a11 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 diff --git a/package.json b/package.json index 7a5890b0..22164185 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/tokens.ts b/src/tokens.ts index 46af58f8..a0d1a5e7 100644 --- a/src/tokens.ts +++ b/src/tokens.ts @@ -5,8 +5,6 @@ import ts from "typescript"; -import { isTsVersionAtLeast } from "./utils"; - /** * Callback type used for {@link forEachToken}. * @@ -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 diff --git a/src/types/getters.test.ts b/src/types/getters.test.ts index a9ce2551..9eff9dfc 100644 --- a/src/types/getters.test.ts +++ b/src/types/getters.test.ts @@ -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, @@ -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; }, '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/, }); - } + }); });