Open okadurin opened 6 months ago
The fix here that you could have used is:
getReferences(token.original.value, dictionary.unfilteredTokens);
The tokens
property is the tokens object after it's been filtered, same for allTokens
, that's filtered, and just a flattened version of it.
There's also a property unfilteredTokens
which is the tokens object without it being filtered, and you can use the flattenTokens
utility if you want it in flat array structure similar to allTokens (maybe we should add an unfilteredAllTokens
prop for ease of use)
I definitely agree that should be documented, perhaps someone would like to contribute this?
Thank you a lot! I will use your solution
Here is a proposal for the documentation update for
getReferences
(it is not actual documentation but the description of the topic that could be explained more detailed). Inv4
getReferences
throws the error if it cannot find a reference definition in the given dictionary. Inv3
as a fallback it was fetching the value from theinclude
array.Consider the following configuration after migrating to
v4
fromv3
:And then there is a formatter defined as follows:
This code is going to fail when calling
getReferences
and when thesource
array does not contain one of references definition which is defined in theinclude
array. Inv3
that was not an issue sincegetReferences
was fetching the value from theinclude
array as a fallback. The new code appoach in v4 for the case above would be removingtoken.isSource
filter from the file configuration and move it into theregisterFormat
as follows:Not sure though how much of a value this kind of information will bring to other customers. Hence feel free to close the issue if you think it is too specific and does not target the majority of users.