Closed moshfeu closed 4 years ago
Hey @moshfeu!
This issue is related to TS compiler.
The compiler expects here a specific string(one of the component's nicknames or selector by type).
If you try to pass any argument that can be changed during runtime(in the above example, you can change foo
to be any an array for example), the compiler can't be sure what would be the value during runtime, and this is the reason why it raised an error.
If we would change the $w
function declaration to accept any string(won't solve your case), we would lose the string value validation(a valid nickname that indeed exists on your page). This feature is much more valuable to our users.
Our recommendation is to assign the selector string to a const
, this way the compiler can run the type checker.
Makes sense. Thanks!
@moshfeu BTW, in the online IDE, we try to hide those error, but we can't control your local IDE :)
True :)
For example
Working
Not working
Throwing