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

originalKeywordKind has been deprecated #155

Open
pmcelhaney opened this issue Aug 29, 2023 · 1 comment · May be fixed by #156
Open

originalKeywordKind has been deprecated #155

pmcelhaney opened this issue Aug 29, 2023 · 1 comment · May be fixed by #156

Comments

@pmcelhaney
Copy link

Got this error after upgrading to TypeScript 5.2:

DeprecationWarning: 'originalKeywordKind' has been deprecated since v5.0.0 and will no longer be usable after v5.2.0. Use 'identifierToKeywordKind(identifier)' instead.

Looks like a fairly straightforward fix. I'll send a pull request shortly.

@pmcelhaney
Copy link
Author

pmcelhaney commented Sep 5, 2023

Here's a work-around until it's fixed: Install patch-package, add "postinstall": "patch-package" to your npm scripts, and copy this code to a file named ./patches/tsutils+3.21.0.patch.

diff --git a/node_modules/tsutils/util/usage.js b/node_modules/tsutils/util/usage.js
index fa24e64..9818b0a 100644
--- a/node_modules/tsutils/util/usage.js
+++ b/node_modules/tsutils/util/usage.js
@@ -25,7 +25,7 @@ function getUsageDomain(node) {
     const parent = node.parent;
     switch (parent.kind) {
         case ts.SyntaxKind.TypeReference:
-            return node.originalKeywordKind !== ts.SyntaxKind.ConstKeyword ? 2 /* Type */ : undefined;
+            return ts.identifierToKeywordKind(node) !== ts.SyntaxKind.ConstKeyword ? 2 /* Type */ : undefined;
         case ts.SyntaxKind.ExpressionWithTypeArguments:
             return parent.parent.token === ts.SyntaxKind.ImplementsKeyword ||
                 parent.parent.parent.kind === ts.SyntaxKind.InterfaceDeclaration
@@ -116,7 +116,7 @@ function getDeclarationDomain(node) {
         case ts.SyntaxKind.ModuleDeclaration:
             return 1 /* Namespace */;
         case ts.SyntaxKind.Parameter:
-            if (node.parent.parent.kind === ts.SyntaxKind.IndexSignature || node.originalKeywordKind === ts.SyntaxKind.ThisKeyword)
+            if (node.parent.parent.kind === ts.SyntaxKind.IndexSignature || ts.identifierToKeywordKind(node) === ts.SyntaxKind.ThisKeyword)
                 return;
         // falls through
         case ts.SyntaxKind.BindingElement:
@@ -525,7 +525,7 @@ class UsageWalker {
                 case ts.SyntaxKind.Parameter:
                     if (node.parent.kind !== ts.SyntaxKind.IndexSignature &&
                         (node.name.kind !== ts.SyntaxKind.Identifier ||
-                            node.name.originalKeywordKind !== ts.SyntaxKind.ThisKeyword))
+                            ts.identifierToKeywordKind(node.name) !== ts.SyntaxKind.ThisKeyword))
                         this._handleBindingName(node.name, false, false);
                     break;
                 case ts.SyntaxKind.EnumMember:
diff --git a/node_modules/tsutils/util/util.js b/node_modules/tsutils/util/util.js
index 0109fea..81aa517 100644
--- a/node_modules/tsutils/util/util.js
+++ b/node_modules/tsutils/util/util.js
@@ -37,7 +37,7 @@ function isKeywordKind(kind) {
 }
 exports.isKeywordKind = isKeywordKind;
 function isThisParameter(parameter) {
-    return parameter.name.kind === ts.SyntaxKind.Identifier && parameter.name.originalKeywordKind === ts.SyntaxKind.ThisKeyword;
+    return parameter.name.kind === ts.SyntaxKind.Identifier && ts.identifierToKeywordKind(parameter.name) === ts.SyntaxKind.ThisKeyword;
 }
 exports.isThisParameter = isThisParameter;
 function getModifier(node, kind) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant