Skip to content

Commit 72b6a72

Browse files
feat: remove deprecated api (#797)
fixes #767
1 parent 388549f commit 72b6a72

10 files changed

Lines changed: 95 additions & 752 deletions

File tree

src/nodes/typeGuards/compound.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
isDeclarationName,
66
isEntityNameExpression,
77
isJSDocNamespaceBody,
8-
isJsxTagNameExpression,
98
isNamespaceBody,
109
} from "./union";
1110

@@ -134,8 +133,7 @@ export function isJsxTagNamePropertyAccess(
134133
): node is ts.JsxTagNamePropertyAccess {
135134
return (
136135
ts.isPropertyAccessExpression(node) &&
137-
// eslint-disable-next-line @typescript-eslint/no-deprecated -- Keep compatibility with ts < 5
138-
isJsxTagNameExpression(node.expression)
136+
ts.isJsxTagNameExpression(node.expression)
139137
);
140138
}
141139

src/nodes/typeGuards/single.test.ts

Lines changed: 35 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import * as ts from "typescript";
22
import { describe, expect, it } from "vitest";
33

44
import { createNode } from "../../test/utils";
5-
import { isTsVersionAtLeast } from "../../utils";
65
import {
76
isAbstractKeyword,
87
isAccessorKeyword,
@@ -54,16 +53,14 @@ describe("isAbstractKeyword", () => {
5453
});
5554
});
5655

57-
if (isTsVersionAtLeast(4, 9)) {
58-
describe("isAccessorKeyword", () => {
59-
it.each([
60-
[false, ts.factory.createModifier(ts.SyntaxKind.AbstractKeyword)],
61-
[true, ts.factory.createModifier(ts.SyntaxKind.AccessorKeyword)],
62-
])("returns %j when given %s", (expected, code) => {
63-
expect(isAccessorKeyword(createNode(code))).toBe(expected);
64-
});
56+
describe("isAccessorKeyword", () => {
57+
it.each([
58+
[false, ts.factory.createModifier(ts.SyntaxKind.AbstractKeyword)],
59+
[true, ts.factory.createModifier(ts.SyntaxKind.AccessorKeyword)],
60+
])("returns %j when given %s", (expected, code) => {
61+
expect(isAccessorKeyword(createNode(code))).toBe(expected);
6562
});
66-
}
63+
});
6764

6865
describe("isAnyKeyword", () => {
6966
it.each([
@@ -74,16 +71,14 @@ describe("isAnyKeyword", () => {
7471
});
7572
});
7673

77-
if (isTsVersionAtLeast(4, 5)) {
78-
describe("isAssertKeyword", () => {
79-
it.each([
80-
[false, ts.factory.createToken(ts.SyntaxKind.AbstractKeyword)],
81-
[true, ts.factory.createToken(ts.SyntaxKind.AssertKeyword)],
82-
])("returns %j when given %s", (expected, code) => {
83-
expect(isAssertKeyword(createNode(code))).toBe(expected);
84-
});
74+
describe("isAssertKeyword", () => {
75+
it.each([
76+
[false, ts.factory.createToken(ts.SyntaxKind.AbstractKeyword)],
77+
[true, ts.factory.createToken(ts.SyntaxKind.AssertKeyword)],
78+
])("returns %j when given %s", (expected, code) => {
79+
expect(isAssertKeyword(createNode(code))).toBe(expected);
8580
});
86-
}
81+
});
8782

8883
describe("isAsyncKeyword", () => {
8984
it.each([
@@ -202,16 +197,14 @@ describe("isInKeyword", () => {
202197
});
203198
});
204199

205-
if (isTsVersionAtLeast(4, 3)) {
206-
describe("isJSDocText", () => {
207-
it.each([
208-
[false, ts.factory.createToken(ts.SyntaxKind.AbstractKeyword)],
209-
[true, ts.factory.createJSDocText("")],
210-
])("returns %j when given %s", (expected, code) => {
211-
expect(isJSDocText(createNode(code))).toBe(expected);
212-
});
200+
describe("isJSDocText", () => {
201+
it.each([
202+
[false, ts.factory.createToken(ts.SyntaxKind.AbstractKeyword)],
203+
[true, ts.factory.createJSDocText("")],
204+
])("returns %j when given %s", (expected, code) => {
205+
expect(isJSDocText(createNode(code))).toBe(expected);
213206
});
214-
}
207+
});
215208

216209
describe("isNeverKeyword", () => {
217210
it.each([
@@ -258,27 +251,23 @@ describe("isObjectKeyword", () => {
258251
});
259252
});
260253

261-
if (isTsVersionAtLeast(4, 7)) {
262-
describe("isOutKeyword", () => {
263-
it.each([
264-
[false, ts.factory.createToken(ts.SyntaxKind.AbstractKeyword)],
265-
[true, ts.factory.createToken(ts.SyntaxKind.OutKeyword)],
266-
])("returns %j when given %s", (expected, code) => {
267-
expect(isOutKeyword(createNode(code))).toBe(expected);
268-
});
254+
describe("isOutKeyword", () => {
255+
it.each([
256+
[false, ts.factory.createToken(ts.SyntaxKind.AbstractKeyword)],
257+
[true, ts.factory.createToken(ts.SyntaxKind.OutKeyword)],
258+
])("returns %j when given %s", (expected, code) => {
259+
expect(isOutKeyword(createNode(code))).toBe(expected);
269260
});
270-
}
261+
});
271262

272-
if (isTsVersionAtLeast(4, 3)) {
273-
describe("isOverrideKeyword", () => {
274-
it.each([
275-
[false, ts.factory.createToken(ts.SyntaxKind.AbstractKeyword)],
276-
[true, ts.factory.createToken(ts.SyntaxKind.OverrideKeyword)],
277-
])("returns %j when given %s", (expected, code) => {
278-
expect(isOverrideKeyword(createNode(code))).toBe(expected);
279-
});
263+
describe("isOverrideKeyword", () => {
264+
it.each([
265+
[false, ts.factory.createToken(ts.SyntaxKind.AbstractKeyword)],
266+
[true, ts.factory.createToken(ts.SyntaxKind.OverrideKeyword)],
267+
])("returns %j when given %s", (expected, code) => {
268+
expect(isOverrideKeyword(createNode(code))).toBe(expected);
280269
});
281-
}
270+
});
282271

283272
describe("isPrivateKeyword", () => {
284273
it.each([

src/nodes/typeGuards/single.ts

Lines changed: 0 additions & 164 deletions
Original file line numberDiff line numberDiff line change
@@ -170,24 +170,6 @@ export function isAssertKeyword(node: ts.Node): node is ts.AssertKeyword {
170170
return node.kind === ts.SyntaxKind.AssertKeyword;
171171
}
172172

173-
/**
174-
* Test if a node is an `AssertsKeyword`.
175-
* @deprecated With TypeScript v5, in favor of typescript's `isAssertsKeyword`.
176-
* @category Nodes - Type Guards
177-
* @example
178-
* ```ts
179-
* declare const node: ts.Node;
180-
*
181-
* if (isAssertsKeyword(node)) {
182-
* // ...
183-
* }
184-
* ```
185-
* @returns Whether the given node appears to be an `AssertsKeyword`.
186-
*/
187-
export function isAssertsKeyword(node: ts.Node): node is ts.AssertsKeyword {
188-
return node.kind === ts.SyntaxKind.AssertsKeyword;
189-
}
190-
191173
/**
192174
* Test if a node is an `AsyncKeyword`.
193175
* @category Nodes - Type Guards
@@ -205,78 +187,6 @@ export function isAsyncKeyword(node: ts.Node): node is ts.AsyncKeyword {
205187
return node.kind === ts.SyntaxKind.AsyncKeyword;
206188
}
207189

208-
/**
209-
* Test if a node is an `AwaitKeyword`.
210-
* @deprecated With TypeScript v5, in favor of typescript's `isAwaitKeyword`.
211-
* @category Nodes - Type Guards
212-
* @example
213-
* ```ts
214-
* declare const node: ts.Node;
215-
*
216-
* if (isAwaitKeyword(node)) {
217-
* // ...
218-
* }
219-
* ```
220-
* @returns Whether the given node appears to be an `AwaitKeyword`.
221-
*/
222-
export function isAwaitKeyword(node: ts.Node): node is ts.AwaitKeyword {
223-
return node.kind === ts.SyntaxKind.AwaitKeyword;
224-
}
225-
226-
/**
227-
* Test if a node is a {@link BigIntKeyword}.
228-
* @deprecated With TypeScript v5, in favor of typescript's `isBigIntKeyword`.
229-
* @category Nodes - Type Guards
230-
* @example
231-
* ```ts
232-
* declare const node: ts.Node;
233-
*
234-
* if (isBigIntKeyword(node)) {
235-
* // ...
236-
* }
237-
* ```
238-
* @returns Whether the given node appears to be a {@link BigIntKeyword}.
239-
*/
240-
export function isBigIntKeyword(node: ts.Node): node is BigIntKeyword {
241-
return node.kind === ts.SyntaxKind.BigIntKeyword;
242-
}
243-
244-
/**
245-
* Test if a node is a {@link BooleanKeyword}.
246-
* @deprecated With TypeScript v5, in favor of typescript's `isBooleanKeyword`.
247-
* @category Nodes - Type Guards
248-
* @example
249-
* ```ts
250-
* declare const node: ts.Node;
251-
*
252-
* if (isBooleanKeyword(node)) {
253-
* // ...
254-
* }
255-
* ```
256-
* @returns Whether the given node appears to be a {@link BooleanKeyword}.
257-
*/
258-
export function isBooleanKeyword(node: ts.Node): node is BooleanKeyword {
259-
return node.kind === ts.SyntaxKind.BooleanKeyword;
260-
}
261-
262-
/**
263-
* Test if a node is a `ColonToken`.
264-
* @deprecated With TypeScript v5, in favor of typescript's `isColonToken`.
265-
* @category Nodes - Type Guards
266-
* @example
267-
* ```ts
268-
* declare const node: ts.Node;
269-
*
270-
* if (isColonToken(node)) {
271-
* // ...
272-
* }
273-
* ```
274-
* @returns Whether the given node appears to be a `ColonToken`.
275-
*/
276-
export function isColonToken(node: ts.Node): node is ts.ColonToken {
277-
return node.kind === ts.SyntaxKind.ColonToken;
278-
}
279-
280190
/**
281191
* Test if a node is a `ConstKeyword`.
282192
* @category Nodes - Type Guards
@@ -362,26 +272,6 @@ export function isEndOfFileToken(node: ts.Node): node is ts.EndOfFileToken {
362272
return node.kind === ts.SyntaxKind.EndOfFileToken;
363273
}
364274

365-
/**
366-
* Test if a node is an `EqualsGreaterThanToken`.
367-
* @deprecated With TypeScript v5, in favor of typescript's `isEqualsGreaterThanToken`.
368-
* @category Nodes - Type Guards
369-
* @example
370-
* ```ts
371-
* declare const node: ts.Node;
372-
*
373-
* if (isEqualsGreaterThanToken(node)) {
374-
* // ...
375-
* }
376-
* ```
377-
* @returns Whether the given node appears to be an `EqualsGreaterThanToken`.
378-
*/
379-
export function isEqualsGreaterThanToken(
380-
node: ts.Node,
381-
): node is ts.EqualsGreaterThanToken {
382-
return node.kind === ts.SyntaxKind.EqualsGreaterThanToken;
383-
}
384-
385275
/**
386276
* Test if a node is an `EqualsToken`.
387277
* @category Nodes - Type Guards
@@ -399,24 +289,6 @@ export function isEqualsToken(node: ts.Node): node is ts.EqualsToken {
399289
return node.kind === ts.SyntaxKind.EqualsToken;
400290
}
401291

402-
/**
403-
* Test if a node is an `ExclamationToken`.
404-
* @deprecated With TypeScript v5, in favor of typescript's `isExclamationToken`.
405-
* @category Nodes - Type Guards
406-
* @example
407-
* ```ts
408-
* declare const node: ts.Node;
409-
*
410-
* if (isExclamationToken(node)) {
411-
* // ...
412-
* }
413-
* ```
414-
* @returns Whether the given node appears to be an `ExclamationToken`.
415-
*/
416-
export function isExclamationToken(node: ts.Node): node is ts.ExclamationToken {
417-
return node.kind === ts.SyntaxKind.ExclamationToken;
418-
}
419-
420292
/**
421293
* Test if a node is an `ExportKeyword`.
422294
* @category Nodes - Type Guards
@@ -725,42 +597,6 @@ export function isPublicKeyword(node: ts.Node): node is ts.PublicKeyword {
725597
return node.kind === ts.SyntaxKind.PublicKeyword;
726598
}
727599

728-
/**
729-
* Test if a node is a `QuestionDotToken`.
730-
* @deprecated With TypeScript v5, in favor of typescript's `isQuestionDotToken`.
731-
* @category Nodes - Type Guards
732-
* @example
733-
* ```ts
734-
* declare const node: ts.Node;
735-
*
736-
* if (isQuestionDotToken(node)) {
737-
* // ...
738-
* }
739-
* ```
740-
* @returns Whether the given node appears to be a `QuestionDotToken`.
741-
*/
742-
export function isQuestionDotToken(node: ts.Node): node is ts.QuestionDotToken {
743-
return node.kind === ts.SyntaxKind.QuestionDotToken;
744-
}
745-
746-
/**
747-
* Test if a node is a `QuestionToken`.
748-
* @deprecated With TypeScript v5, in favor of typescript's `isQuestionToken`.
749-
* @category Nodes - Type Guards
750-
* @example
751-
* ```ts
752-
* declare const node: ts.Node;
753-
*
754-
* if (isQuestionToken(node)) {
755-
* // ...
756-
* }
757-
* ```
758-
* @returns Whether the given node appears to be a `QuestionToken`.
759-
*/
760-
export function isQuestionToken(node: ts.Node): node is ts.QuestionToken {
761-
return node.kind === ts.SyntaxKind.QuestionToken;
762-
}
763-
764600
/**
765601
* Test if a node is a `ReadonlyKeyword`.
766602
* @category Nodes - Type Guards

src/nodes/typeGuards/union.test.ts

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,9 @@ import * as ts from "typescript";
22
import { describe, expect, it } from "vitest";
33

44
import { createNode } from "../../test/utils";
5-
import { isTsVersionAtLeast } from "../../utils";
65
import {
76
isAccessExpression,
87
isAccessibilityModifier,
9-
isAccessorDeclaration,
10-
isArrayBindingElement,
118
isArrayBindingOrAssignmentPattern,
129
isAssignmentPattern,
1310
isBooleanLiteral,
@@ -37,36 +34,6 @@ describe("isAccessibilityModifier", () => {
3734
});
3835
});
3936

40-
if (isTsVersionAtLeast(4, 9)) {
41-
describe("isAccessorDeclaration", () => {
42-
it.each([
43-
[false, `abc`],
44-
[
45-
true,
46-
ts.factory.createGetAccessorDeclaration(
47-
undefined,
48-
"property",
49-
[],
50-
undefined,
51-
undefined,
52-
),
53-
],
54-
[
55-
true,
56-
ts.factory.createSetAccessorDeclaration(
57-
undefined,
58-
"property",
59-
[],
60-
undefined,
61-
),
62-
],
63-
])("returns %j when given %s", (expected, sourceText) => {
64-
// eslint-disable-next-line @typescript-eslint/no-deprecated
65-
expect(isAccessorDeclaration(createNode(sourceText))).toBe(expected);
66-
});
67-
});
68-
}
69-
7037
describe("isArrayBindingOrAssignmentPattern", () => {
7138
it.each([
7239
[false, `"[a]"`],
@@ -86,8 +53,7 @@ describe("isArrayBindingElement", () => {
8653
[true, ts.factory.createBindingElement(undefined, "property", "name")],
8754
[true, ts.factory.createOmittedExpression()],
8855
])("returns %j when given %s", (expected, sourceText) => {
89-
// eslint-disable-next-line @typescript-eslint/no-deprecated
90-
expect(isArrayBindingElement(createNode(sourceText))).toBe(expected);
56+
expect(ts.isArrayBindingElement(createNode(sourceText))).toBe(expected);
9157
});
9258
});
9359

0 commit comments

Comments
 (0)