Skip to content

Commit

Permalink
Fix: panic from parse().unwrap()
Browse files Browse the repository at this point in the history
  • Loading branch information
sunrabbit123 committed Aug 19, 2023
1 parent d5a01ed commit 4d64d1c
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions crates/stc_ts_file_analyzer/src/analyzer/generic/inference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -624,16 +624,24 @@ impl Analyzer<'_, '_> {
}

if r.is_num() {
return Type::Lit(LitType {
span,
lit: RTsLit::Number(RNumber {
span,
value: src.parse().unwrap(),
raw: None,
}),
metadata: Default::default(),
tracker: Default::default(),
});
match src.parse() {
Ok(v) => {
return Type::Lit(LitType {
span,
lit: RTsLit::Number(RNumber { span, value: v, raw: None }),
metadata: Default::default(),
tracker: Default::default(),
})
}
Err(..) => {
return Type::Keyword(KeywordType {
span,
kind: TsKeywordTypeKind::TsNumberKeyword,
metadata: Default::default(),
tracker: Default::default(),
})
}
}
}

if l.is_enum_type() || l.is_enum_variant() {
Expand Down

0 comments on commit 4d64d1c

Please sign in to comment.