@@ -14,17 +14,16 @@ import { locator } from '../../../state.js';
14
14
15
15
/**
16
16
* @param {import('../index.js').Parser } parser
17
- * @param {boolean } [optional_allowed]
18
17
* @returns {import('estree').Pattern }
19
18
*/
20
- export default function read_pattern ( parser , optional_allowed = false ) {
19
+ export default function read_pattern ( parser ) {
21
20
const start = parser . index ;
22
21
let i = parser . index ;
23
22
24
23
const code = full_char_code_at ( parser . template , i ) ;
25
24
if ( isIdentifierStart ( code , true ) ) {
26
25
const name = /** @type {string } */ ( parser . read_identifier ( ) ) ;
27
- const annotation = read_type_annotation ( parser , optional_allowed ) ;
26
+ const annotation = read_type_annotation ( parser ) ;
28
27
29
28
return {
30
29
type : 'Identifier' ,
@@ -84,7 +83,7 @@ export default function read_pattern(parser, optional_allowed = false) {
84
83
parse_expression_at ( `${ space_with_newline } (${ pattern_string } = 1)` , parser . ts , start - 1 )
85
84
) . left ;
86
85
87
- expression . typeAnnotation = read_type_annotation ( parser , optional_allowed ) ;
86
+ expression . typeAnnotation = read_type_annotation ( parser ) ;
88
87
if ( expression . typeAnnotation ) {
89
88
expression . end = expression . typeAnnotation . end ;
90
89
}
@@ -97,19 +96,12 @@ export default function read_pattern(parser, optional_allowed = false) {
97
96
98
97
/**
99
98
* @param {import('../index.js').Parser } parser
100
- * @param {boolean } [optional_allowed]
101
99
* @returns {any }
102
100
*/
103
- function read_type_annotation ( parser , optional_allowed = false ) {
101
+ function read_type_annotation ( parser ) {
104
102
const start = parser . index ;
105
103
parser . allow_whitespace ( ) ;
106
104
107
- if ( optional_allowed && parser . eat ( '?' ) ) {
108
- // Acorn-TS puts the optional info as a property on the surrounding node.
109
- // We spare the work here because it doesn't matter for us anywhere else.
110
- parser . allow_whitespace ( ) ;
111
- }
112
-
113
105
if ( ! parser . eat ( ':' ) ) {
114
106
parser . index = start ;
115
107
return undefined ;
0 commit comments