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
First of all thank you for this awesome package. It really helps me a lot.
Brief explanation of proposal
In this code,
interfaceParams{a: number;b: number;}functionX({
a,
b,}: Params){constx={ a, b }}X({a: 1,b: 2})X({a: 2,b: 3})
we cannot determine what's the value of x without specifying where X is called, bacause a and b are not deterministic(honestly not only determinstic but also never can hold any value in this lexical scope) before the function is invoked.
However I feel like it is quite useful if we can tell ts-evaluator like "Use 1 as a fallback value of parameter a", then we can predict the value of x, which is actually not accurate, but still we can treat the value like "So x in here is an object with two number property".
Why I ran into this kind of needs
I'm making a web app analyzer, which generate url flow a user can take. Guess this:
And this flow is not deterministic, as web app can have various state and under the state the destination url can be changed. See the second line which has userId in the path. It is not important what the exact value of user id is, just using any string or number is fine enough.
So in this context allowing fallback value for BindingElement (or perhaps more several other nodes, which contains the same problem) is useful, I think.
Or, it would be better to provide API to intercept default behavior of evaluating some kind of node, similar to libraries like html-parser? Maybe this is more proper solution cause allowing strange value to evaluate some node would cause unpredictable problem 🤔
The text was updated successfully, but these errors were encountered:
First of all thank you for this awesome package. It really helps me a lot.
Brief explanation of proposal
In this code,
we cannot determine what's the value of
x
without specifying where X is called, bacausea
andb
are not deterministic(honestly not only determinstic but also never can hold any value in this lexical scope) before the function is invoked.However I feel like it is quite useful if we can tell ts-evaluator like "Use 1 as a fallback value of parameter a", then we can predict the value of x, which is actually not accurate, but still we can treat the value like "So x in here is an object with two number property".
Why I ran into this kind of needs
I'm making a web app analyzer, which generate url flow a user can take. Guess this:
And this flow is not deterministic, as web app can have various state and under the state the destination url can be changed. See the second line which has
userId
in the path. It is not important what the exact value of user id is, just using any string or number is fine enough.So in this context allowing fallback value for BindingElement (or perhaps more several other nodes, which contains the same problem) is useful, I think.
Or, it would be better to provide API to intercept default behavior of evaluating some kind of node, similar to libraries like html-parser? Maybe this is more proper solution cause allowing strange value to evaluate some node would cause unpredictable problem 🤔
The text was updated successfully, but these errors were encountered: