Title: isTypeOfExpression is broken · Issue #20875 · microsoft/TypeScript · GitHub
Open Graph Title: isTypeOfExpression is broken · Issue #20875 · microsoft/TypeScript
X Title: isTypeOfExpression is broken · Issue #20875 · microsoft/TypeScript
Description: TypeScript Version: 2.6.2 Code import * as ts from 'typescript' const testTypeOf = ts.createTypeOf(ts.createLiteral("")) const testAwait = ts.createAwait(ts.createLiteral("")) console.log(testTypeOf.kind, testAwait.kind) // 189, 191 cons...
Open Graph Description: TypeScript Version: 2.6.2 Code import * as ts from 'typescript' const testTypeOf = ts.createTypeOf(ts.createLiteral("")) const testAwait = ts.createAwait(ts.createLiteral("")) console.log(testTypeO...
X Description: TypeScript Version: 2.6.2 Code import * as ts from 'typescript' const testTypeOf = ts.createTypeOf(ts.createLiteral("")) const testAwait = ts.createAwait(ts.createLiteral("&q...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/20875
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"isTypeOfExpression is broken","articleBody":"\u003c!-- BUGS: Please use this template. -->\r\n\u003c!-- Please try to reproduce the issue with `typescript@next`. It may have already been fixed. -->\r\n**TypeScript Version:** 2.6.2 \r\n**Code**\r\n```ts\r\nimport * as ts from 'typescript'\r\n\r\nconst testTypeOf = ts.createTypeOf(ts.createLiteral(\"\"))\r\nconst testAwait = ts.createAwait(ts.createLiteral(\"\"))\r\n\r\nconsole.log(testTypeOf.kind, testAwait.kind) // 189, 191\r\n\r\nconsole.log(ts.isTypeOfExpression(testTypeOf)) // Prints false, should be true\r\nconsole.log(ts.isTypeOfExpression(testAwait)) // Prints true, should be false\r\n```\r\n\r\n**Expected behavior:**\r\n`ts.isTypeofExpression` should return `true` (only) for `TypeOfExpression` nodes.\r\n\r\n**Actual behavior:**\r\nIt returns `true` for `AwaitExpression` nodes instead.\r\n\r\n**Reason**\r\nThe nodes both get created correctly (`TypeOfExpression` has kind `189` like it should), but the generated code for `isTypeOfExpression` uses the wrong number for `kind`: (from [`tsc.ts`](https://github.com/Microsoft/TypeScript/blob/release-2.6/lib/tsc.js), starting on line 9132)\r\n```ts\r\n function isTypeOfExpression(node) {\r\n return node.kind === 191;\r\n }\r\n ts.isTypeOfExpression = isTypeOfExpression;\r\n function isVoidExpression(node) {\r\n return node.kind === 190;\r\n }\r\n ts.isVoidExpression = isVoidExpression;\r\n function isAwaitExpression(node) {\r\n return node.kind === 191;\r\n }\r\n ts.isAwaitExpression = isAwaitExpression;\r\n```\r\nNote that some code uses the correct `kind`:\r\n```ts\r\n function createTypeOf(expression) {\r\n var node = createSynthesizedNode(189);\r\n node.expression = ts.parenthesizePrefixOperand(expression);\r\n return node;\r\n }\r\n```\r\nNote that this issue also exists on [master](https://github.com/Microsoft/TypeScript/tree/8118cc76295d5f3a1bb65bd97807d649ee0a5bc9), even though the numbers for `SyntaxKind` enum values have changed.\r\n\r\nI couldn't find where this code gets generated, so I haven't been able to investigate further.","author":{"url":"https://github.com/tehwalris","@type":"Person","name":"tehwalris"},"datePublished":"2017-12-23T14:04:23Z","url":"https://github.com/microsoft/TypeScript/issues/20875"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:71ce9b2a-032c-da19-c83d-0cdd11e6b636 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A344:21AC3F:BBD3C6:F14B21:6B00E79B |
| html-safe-nonce | deabbc0dc1779e8869850c2a8e5e199ee5be8926753e2319b0302a11a5ed5ad8 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMzQ0OjIxQUMzRjpCQkQzQzY6RjE0QjIxOjZCMDBFNzlCIiwidmlzaXRvcl9pZCI6IjY0NDA1OTA4MTY5MzQxNjAyODMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | d7a23d0ff915ea193ebd729af23e427fab7db35eb487b549ae2c3aff4d732627 |
| hovercard-subject-tag | issue:284308104 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/TypeScript/20875/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b3c1a6ca9ae1525ecfbbc28c604109d9a53421a38ffb7f17e727d6f168f3b245/microsoft/TypeScript/issues/20875 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b3c1a6ca9ae1525ecfbbc28c604109d9a53421a38ffb7f17e727d6f168f3b245/microsoft/TypeScript/issues/20875 |
| og:image:alt | TypeScript Version: 2.6.2 Code import * as ts from 'typescript' const testTypeOf = ts.createTypeOf(ts.createLiteral("")) const testAwait = ts.createAwait(ts.createLiteral("")) console.log(testTypeO... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | tehwalris |
| hostname | github.com |
| expected-hostname | github.com |
| None | 27088b6977484d0d3321d9a11c907c6d6637b315cfa359ef7952dbf6292f9b14 |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoft/TypeScript git https://github.com/microsoft/TypeScript.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 20929025 |
| octolytics-dimension-repository_nwo | microsoft/TypeScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 20929025 |
| octolytics-dimension-repository_network_root_nwo | microsoft/TypeScript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 624179fb8b88d26ba5bba08894eb60a1c5a1d93d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width