11import { SourceType } from 'coffee-lex' ;
2+ import SourceToken from 'coffee-lex/dist/SourceToken' ;
23import SourceTokenListIndex from 'coffee-lex/dist/SourceTokenListIndex' ;
34import { Base } from 'decaffeinate-coffeescript/lib/coffee-script/nodes' ;
45import { inspect } from 'util' ;
@@ -43,7 +44,7 @@ export default function getLocation(context: ParseContext, node: Base): NodeLoca
4344 return { line, column, start, end, raw} ;
4445}
4546
46- function firstSemanticTokenAfter ( context : ParseContext , index : number , node : Base ) {
47+ function firstSemanticTokenAfter ( context : ParseContext , index : number , node : Base ) : SourceToken {
4748 let tokenIndex = context . sourceTokens . indexOfTokenMatchingPredicate ( token => {
4849 return (
4950 token . start >= index &&
@@ -54,7 +55,7 @@ function firstSemanticTokenAfter(context: ParseContext, index: number, node: Bas
5455 return tokenFromIndex ( context , tokenIndex , node ) ;
5556}
5657
57- function firstSemanticTokenBefore ( context : ParseContext , index : number , node : Base ) {
58+ function firstSemanticTokenBefore ( context : ParseContext , index : number , node : Base ) : SourceToken {
5859 let tokenIndex = context . sourceTokens . lastIndexOfTokenMatchingPredicate ( token => {
5960 return (
6061 token . end <= index &&
@@ -65,7 +66,7 @@ function firstSemanticTokenBefore(context: ParseContext, index: number, node: Ba
6566 return tokenFromIndex ( context , tokenIndex , node ) ;
6667}
6768
68- function tokenFromIndex ( context : ParseContext , tokenIndex : SourceTokenListIndex | null , node : Base ) {
69+ function tokenFromIndex ( context : ParseContext , tokenIndex : SourceTokenListIndex | null , node : Base ) : SourceToken {
6970 if ( tokenIndex === null ) {
7071 throw new Error ( `unable to find token index for node: ${ inspect ( node ) } ` ) ;
7172 }
0 commit comments