@@ -72,7 +72,7 @@ class Parser {
7272 if ( this . _state === 'complete' ) {
7373 throw new Error ( 'Cannot add a new token to a completed Parser' )
7474 }
75- const state = states [ this . _state ]
75+ const state = states [ this . _state ] !
7676 const startExpr = this . _exprStr
7777 this . _exprStr += token . raw
7878 if ( state . subHandler ) {
@@ -91,9 +91,9 @@ class Parser {
9191 }
9292 }
9393 } else if ( token . type === 'semicolon' && this . _stopMap [ token . type ] ) {
94- return this . _stopMap [ token . type ]
94+ return this . _stopMap [ token . type ] !
9595 } else if ( state . tokenTypes ?. [ token . type ] ) {
96- const typeOpts = state . tokenTypes [ token . type ]
96+ const typeOpts = state . tokenTypes [ token . type ] !
9797 let handleFunc = (
9898 handlers as Record <
9999 string ,
@@ -110,7 +110,7 @@ class Parser {
110110 this . _state = typeOpts . toState
111111 }
112112 } else if ( this . _stopMap [ token . type ] ) {
113- return this . _stopMap [ token . type ]
113+ return this . _stopMap [ token . type ] !
114114 } else {
115115 throw new Error (
116116 `Token ${ token . raw } (${ token . type } ) unexpected in expression: ${ this . _exprStr } `
@@ -138,7 +138,7 @@ class Parser {
138138 * the expression, indicating that the expression is incomplete
139139 */
140140 complete ( ) {
141- if ( this . _cursor && ! states [ this . _state ] . completable ) {
141+ if ( this . _cursor && ! states [ this . _state ] ! . completable ) {
142142 throw new Error ( `Unexpected end of expression: ${ this . _exprStr } ` )
143143 }
144144 if ( this . _subParser ) {
@@ -175,7 +175,7 @@ class Parser {
175175 * @private
176176 */
177177 _endSubExpression ( ) {
178- states [ this . _state ] . subHandler ! . call ( this , this . _subParser ! . complete ( ) )
178+ states [ this . _state ] ! . subHandler ! . call ( this , this . _subParser ! . complete ( ) )
179179 this . _subParser = undefined
180180 }
181181
@@ -232,12 +232,12 @@ class Parser {
232232 * @private
233233 */
234234 _startSubExpression ( exprStr ?: string ) {
235- let endStates = states [ this . _state ] . endStates
235+ let endStates = states [ this . _state ] ! . endStates
236236 if ( ! endStates ) {
237237 this . _parentStop = true
238238 endStates = this . _stopMap
239239 }
240- if ( states [ this . _state ] . completable && ! endStates . semicolon ) {
240+ if ( states [ this . _state ] ! . completable && ! endStates . semicolon ) {
241241 endStates = { ...endStates , semicolon : '_semicolon' }
242242 }
243243 this . _subParser = new Parser ( this . _grammar , this . _lexer , exprStr , endStates )
0 commit comments