You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We'd like to be able to check if an expression, passed as an argument of a call expression, is in a "const context". Checking for as const is fairly trivial as we can just search up the syntax tree, but checking for const type parameters seems impossible without using TypeScript internals.
With code examples:
We can currently check if foo is in a "const context" here fairly trivially:
š Search Terms
const type parameter
ā Viability Checklist
ā Suggestion
Hi from ts-api-utils.
We'd like to be able to check if an expression, passed as an argument of a call expression, is in a "const context". Checking for
as constis fairly trivial as we can just search up the syntax tree, but checking forconst type parametersseems impossible without using TypeScript internals.With code examples:
We can currently check if
foois in a "const context" here fairly trivially:But can't do the same for
fooin this example:Proposal
Ideally, we would like an officially supported way to make such a check.
We currently have a PR in progress that works using ts internals, but we'd prefer not to rely on ts internals.
š Motivating Example
N/A
š» Use Cases
What do you want to use this for?
determining whether a type is readonly
Determine immutability for const type parametersĀ eslint-functional/eslint-plugin-functional#827
What shortcomings exist with current approaches?
There doesn't seem to be anyway official way to do this
What workarounds are you using in the meantime?
Use ts internals