Title: getSyntacticModifierFlags return value affected by getEffectiveModifierFlags · Issue #42189 · microsoft/TypeScript · GitHub
Open Graph Title: getSyntacticModifierFlags return value affected by getEffectiveModifierFlags · Issue #42189 · microsoft/TypeScript
X Title: getSyntacticModifierFlags return value affected by getEffectiveModifierFlags · Issue #42189 · microsoft/TypeScript
Description: Bug Report I don't know if this already causes a user-facing bug, but it might in the future. 🔎 Search Terms syntactic effective modifierflags 🕗 Version & Regression Information The API was introduced in #38403 by Ron Buckton (@rbuckton)...
Open Graph Description: Bug Report I don't know if this already causes a user-facing bug, but it might in the future. 🔎 Search Terms syntactic effective modifierflags 🕗 Version & Regression Information The API was introdu...
X Description: Bug Report I don't know if this already causes a user-facing bug, but it might in the future. 🔎 Search Terms syntactic effective modifierflags 🕗 Version & Regression Information The API was...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/42189
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"getSyntacticModifierFlags return value affected by getEffectiveModifierFlags","articleBody":"# Bug Report\r\n\r\nI don't know if this already causes a user-facing bug, but it might in the future.\r\n\r\n### 🔎 Search Terms\r\n\r\nsyntactic effective modifierflags\r\n\r\n### 🕗 Version & Regression Information\r\n\r\nThe API was introduced in #38403 by @rbuckton on 12th May 2020, I don't know which TS version that is\r\n\r\n### 💻 Code\r\n\r\n\u003c!-- Please post the relevant code sample here as well-->\r\n```ts\r\nclass C {\r\n /** @private */\r\n prop = 1;\r\n}\r\n```\r\n\r\nThe code snippets below assume that `node: ts.PropertyDeclaration` of property `prop`\r\n\r\n### 🙁 Actual behavior\r\n\r\nNote: I'm not talking about user code using compiler API as these APIs are not public. I'm talking about the compiler implementation itself.\r\n\r\nIf the above code is a TS file:\r\n\r\n* call `ts.getSyntacticModifierFlags(node)`, return `ts.ModifierFlags.None` (expected)\r\n* call `ts.getEffectiveModifierFlags(node)`, return `ts.ModifierFlags.None` (expected)\r\n* call `ts.getSyntacticModifierFlags(node)` again, returns `ts.ModifierFlags.None` (expected)\r\n\r\nIf the above code is a JS file:\r\n\r\n* call `ts.getSyntacticModifierFlags(node)`, return `ts.ModifierFlags.None` (expected)\r\n* call `ts.getEffectiveModifierFlags(node)`, return `ts.ModifierFlags.Private` (expected)\r\n* call `ts.getSyntacticModifierFlags(node)` again, returns `ts.ModifierFlags.Private` (**not** expected)\r\n\r\n(see https://runkit.com/ajafff/5ff204e2ac3559001a1407f7)\r\n\r\nThis is because both use the same property to cache the result. `getEffectiveModifierFlags` adds modifiers from JSDoc to the cached result. Calling `getSyntacticModifierFlags` afterwards cannot remove the modifiers from JSDoc, so it simply returns them too.\r\n\r\n### 🙂 Expected behavior\r\n\r\nLooking at the description of #38403, the intended use of `getSyntacticModifierFlags` is: \"get me the syntactic modifiers and **don't** include those from JSDoc\". Calling `getEffectiveModifierFlags` should not have a side-effect on `getSyntacticModifierFlags`.\r\n\r\nAlso there's `getEffectiveModifierFlagsAlwaysIncludeJSDoc` introduced in #38523 by @Kingwl. This affects TS files, making the original change in #38403 useless depending on execution order: \r\n* call `ts.getSyntacticModifierFlags(node)`, return `ts.ModifierFlags.None` (expected)\r\n* call `ts.getEffectiveModifierFlags(node)`, return `ts.ModifierFlags.None` (expected)\r\n* call `getEffectiveModifierFlagsAlwaysIncludeJSDoc`, return `ts.ModifierFlags.Private` (expected)\r\n* call `ts.getSyntacticModifierFlags(node)` again, returns `ts.ModifierFlags.Private` (**not** expected)\r\n* call `ts.getEffectiveModifierFlags(node)` again, returns `ts.ModifierFlags.Private` (**not** expected)\r\n","author":{"url":"https://github.com/ajafff","@type":"Person","name":"ajafff"},"datePublished":"2021-01-03T18:02:19Z","url":"https://github.com/microsoft/TypeScript/issues/42189"}
| 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:3a33407c-6c63-70fc-66ef-a1f003afedd7 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C47A:842EC:7BA38F:A6F656:6B00DF5F |
| html-safe-nonce | b89bf1e38a6f8260fd853446ab33710602c0e88b6d9b0c20d688e751a09e4e2f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNDdBOjg0MkVDOjdCQTM4RjpBNkY2NTY6NkIwMERGNUYiLCJ2aXNpdG9yX2lkIjoiMTg2NDY2MTQ0MDYyODA1NTkwMyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 36215fe9b14a7a8dc0b7854778065a95c31237d2ad511a78c90b6b9953e58e98 |
| hovercard-subject-tag | issue:777687452 |
| 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/42189/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9ea07d3f9d69034b36880c6e97034550d9584dfff8da76acfaf263d95c857197/microsoft/TypeScript/issues/42189 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9ea07d3f9d69034b36880c6e97034550d9584dfff8da76acfaf263d95c857197/microsoft/TypeScript/issues/42189 |
| og:image:alt | Bug Report I don't know if this already causes a user-facing bug, but it might in the future. 🔎 Search Terms syntactic effective modifierflags 🕗 Version & Regression Information The API was introdu... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ajafff |
| hostname | github.com |
| expected-hostname | github.com |
| None | 043c3f30fbcbe2c6c8e729e10cbbbc90c406546f9fbbb67c648d38f6b7d16daf |
| 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 | 5425dc24e8bd8d6fca9641a12afc984825a43875 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width