@ -22,12 +22,14 @@ export default function read_context(parser) {
const code = full _char _code _at ( parser . template , i ) ;
const code = full _char _code _at ( parser . template , i ) ;
if ( isIdentifierStart ( code , true ) ) {
if ( isIdentifierStart ( code , true ) ) {
const name = /** @type {string} */ ( parser . read _identifier ( ) ) ;
const name = /** @type {string} */ ( parser . read _identifier ( ) ) ;
const annotation = read _type _annotation ( parser ) ;
return {
return {
type : 'Identifier' ,
type : 'Identifier' ,
name ,
name ,
start ,
start ,
end : parser . index ,
end : parser . index ,
typeAnnotation : read_type _ annotation( parser )
typeAnnotation : annotation
} ;
} ;
}
}
@ -81,6 +83,10 @@ export default function read_context(parser) {
) . left ;
) . left ;
expression . typeAnnotation = read _type _annotation ( parser ) ;
expression . typeAnnotation = read _type _annotation ( parser ) ;
if ( expression . typeAnnotation ) {
expression . end = expression . typeAnnotation . end ;
}
return expression ;
return expression ;
} catch ( error ) {
} catch ( error ) {
parser . acorn _error ( error ) ;
parser . acorn _error ( error ) ;
@ -92,6 +98,7 @@ export default function read_context(parser) {
* @ returns { any }
* @ returns { any }
* /
* /
function read _type _annotation ( parser ) {
function read _type _annotation ( parser ) {
const index = parser . index ;
parser . allow _whitespace ( ) ;
parser . allow _whitespace ( ) ;
if ( parser . eat ( ':' ) ) {
if ( parser . eat ( ':' ) ) {
@ -103,5 +110,7 @@ function read_type_annotation(parser) {
parser . index = /** @type {number} */ ( expression . end ) ;
parser . index = /** @type {number} */ ( expression . end ) ;
return /** @type {any} */ ( expression ) . typeAnnotation ;
return /** @type {any} */ ( expression ) . typeAnnotation ;
} else {
parser . index = index ;
}
}
}
}