@@ -26,11 +26,11 @@ class TokenResultFoundError extends Error {
2626 */
2727const skipTokenMarker = Symbol ( 'Returned to skip visiting a token' ) ;
2828
29- type VisitorFn = ( opts : {
29+ type VisitorFn < T > = ( opts : {
3030 /**
3131 * Call this to return the provided value as the result of treeResultLocator
3232 */
33- returnResult : ( result : any ) => TokenResultFoundError ;
33+ returnResult : ( result : T ) => TokenResultFoundError ;
3434 /**
3535 * Return this to skip visiting any inner tokens
3636 */
@@ -41,12 +41,12 @@ type VisitorFn = (opts: {
4141 token : TokenResult < Token > ;
4242} ) => null | TokenResultFoundError | typeof skipTokenMarker ;
4343
44- type TreeResultLocatorOpts = {
44+ type TreeResultLocatorOpts < T > = {
4545 /**
4646 * The value to return when returnValue was never called and all nodes of the
4747 * search tree were visited.
4848 */
49- noResultValue : any ;
49+ noResultValue : T ;
5050 /**
5151 * The tree to visit
5252 */
@@ -56,7 +56,7 @@ type TreeResultLocatorOpts = {
5656 * visiting. May also indicate that we want to skip any further traversal of
5757 * inner nodes.
5858 */
59- visitorTest : VisitorFn ;
59+ visitorTest : VisitorFn < T > ;
6060} ;
6161
6262/**
@@ -72,7 +72,7 @@ export function treeResultLocator<T>({
7272 tree,
7373 visitorTest,
7474 noResultValue,
75- } : TreeResultLocatorOpts ) : T {
75+ } : TreeResultLocatorOpts < T > ) : T {
7676 const returnResult = ( result : any ) => new TokenResultFoundError ( result ) ;
7777
7878 const nodeVisitor = ( token : TokenResult < Token > | null ) => {
0 commit comments