mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 20:32:10 +00:00
fix(ast): support TSIndexSignature.readonly (#2579)
[playground](https://oxc-project.github.io/oxc/playground/?code=3YCAAIDKgICAgICAgIC0GwpuZs97oWDqPM4xvCuoRB73mPOSrYb%2BTQEZf3b8RF0G%2B60jF5tYXUE9Me2%2FmMqVEwVy%2FiBIlyIMX6PqBpqsSmIXTJcsRqi4f3%2Bj6ICA)
This commit is contained in:
parent
8bb1084863
commit
637cd1dea4
3 changed files with 13 additions and 2 deletions
|
|
@ -582,6 +582,7 @@ pub struct TSIndexSignature<'a> {
|
|||
pub span: Span,
|
||||
pub parameters: Vec<'a, Box<'a, TSIndexSignatureName<'a>>>,
|
||||
pub type_annotation: Box<'a, TSTypeAnnotation<'a>>,
|
||||
pub readonly: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Hash)]
|
||||
|
|
|
|||
|
|
@ -1365,11 +1365,13 @@ impl<'a> AstBuilder<'a> {
|
|||
span: Span,
|
||||
parameters: Vec<'a, Box<'a, TSIndexSignatureName<'a>>>,
|
||||
type_annotation: Box<'a, TSTypeAnnotation<'a>>,
|
||||
readonly: bool,
|
||||
) -> TSSignature<'a> {
|
||||
TSSignature::TSIndexSignature(self.alloc(TSIndexSignature {
|
||||
span,
|
||||
parameters,
|
||||
type_annotation,
|
||||
readonly,
|
||||
}))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1077,8 +1077,11 @@ impl<'a> ParserImpl<'a> {
|
|||
|
||||
pub(crate) fn parse_ts_index_signature_member(&mut self) -> Result<TSSignature<'a>> {
|
||||
let span = self.start_span();
|
||||
let mut readonly = false;
|
||||
while self.is_nth_at_modifier(0, false) {
|
||||
if !self.eat(Kind::Readonly) {
|
||||
if self.eat(Kind::Readonly) {
|
||||
readonly = true;
|
||||
} else {
|
||||
return Err(self.unexpected());
|
||||
}
|
||||
}
|
||||
|
|
@ -1093,7 +1096,12 @@ impl<'a> ParserImpl<'a> {
|
|||
if let Some(type_annotation) = type_annotation {
|
||||
self.bump(Kind::Comma);
|
||||
self.bump(Kind::Semicolon);
|
||||
Ok(self.ast.ts_index_signature(self.end_span(span), parameters, type_annotation))
|
||||
Ok(self.ast.ts_index_signature(
|
||||
self.end_span(span),
|
||||
parameters,
|
||||
type_annotation,
|
||||
readonly,
|
||||
))
|
||||
} else {
|
||||
Err(self.unexpected())
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue