Skip to content

Commit da9ce35

Browse files
DunqingBoshen
authored andcommitted
feat(isolated-declarations): support inferring ParenthesizedExpression
1 parent cfd4b76 commit da9ce35

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

crates/oxc_isolated_declarations/src/inferrer.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,15 @@ impl<'a> IsolatedDeclarations<'a> {
5252
self.error(inferred_type_of_class_expression(expr.span));
5353
Some(self.ast.ts_unknown_keyword(SPAN))
5454
}
55+
Expression::ParenthesizedExpression(expr) => {
56+
self.infer_type_from_expression(&expr.expression)
57+
}
5558
Expression::TSNonNullExpression(expr) => {
5659
self.infer_type_from_expression(&expr.expression)
5760
}
5861
Expression::TSSatisfiesExpression(expr) => {
5962
self.infer_type_from_expression(&expr.expression)
6063
}
61-
Expression::TSInstantiationExpression(_expr) => {
62-
unreachable!();
63-
// infer_type_from_expression(ctx, &expr.expression)
64-
}
6564
Expression::TSTypeAssertion(expr) => Some(self.ast.copy(&expr.type_annotation)),
6665
_ => None,
6766
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// ParenthesizedExpression
2+
const n = (0);
3+
const s = ("");
4+
const t = (``);
5+
const b = (true);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
source: crates/oxc_isolated_declarations/tests/mod.rs
3+
input_file: crates/oxc_isolated_declarations/tests/fixtures/infer-expression.ts
4+
---
5+
==================== .D.TS ====================
6+
7+
declare const n: number;
8+
declare const s: string;
9+
declare const t: string;
10+
declare const b: boolean;

0 commit comments

Comments
 (0)