Skip to content

Commit

Permalink
feat(isolated-declarations): support inferring ParenthesizedExpression (
Browse files Browse the repository at this point in the history
  • Loading branch information
Dunqing committed Jun 19, 2024
1 parent 8ce794d commit b38c34d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
7 changes: 3 additions & 4 deletions crates/oxc_isolated_declarations/src/inferrer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,15 @@ impl<'a> IsolatedDeclarations<'a> {
self.error(inferred_type_of_class_expression(expr.span));
Some(self.ast.ts_unknown_keyword(SPAN))
}
Expression::ParenthesizedExpression(expr) => {
self.infer_type_from_expression(&expr.expression)
}
Expression::TSNonNullExpression(expr) => {
self.infer_type_from_expression(&expr.expression)
}
Expression::TSSatisfiesExpression(expr) => {
self.infer_type_from_expression(&expr.expression)
}
Expression::TSInstantiationExpression(_expr) => {
unreachable!();
// infer_type_from_expression(ctx, &expr.expression)
}
Expression::TSTypeAssertion(expr) => Some(self.ast.copy(&expr.type_annotation)),
_ => None,
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// ParenthesizedExpression
const n = (0);
const s = ("");
const t = (``);
const b = (true);
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
source: crates/oxc_isolated_declarations/tests/mod.rs
input_file: crates/oxc_isolated_declarations/tests/fixtures/infer-expression.ts
---
==================== .D.TS ====================

declare const n: number;
declare const s: string;
declare const t: string;
declare const b: boolean;

0 comments on commit b38c34d

Please sign in to comment.