mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
feat(isolated-declarations): support inferring ParenthesizedExpression (#3769)
This commit is contained in:
parent
8ce794d740
commit
b38c34dfce
3 changed files with 18 additions and 4 deletions
|
|
@ -52,16 +52,15 @@ impl<'a> IsolatedDeclarations<'a> {
|
||||||
self.error(inferred_type_of_class_expression(expr.span));
|
self.error(inferred_type_of_class_expression(expr.span));
|
||||||
Some(self.ast.ts_unknown_keyword(SPAN))
|
Some(self.ast.ts_unknown_keyword(SPAN))
|
||||||
}
|
}
|
||||||
|
Expression::ParenthesizedExpression(expr) => {
|
||||||
|
self.infer_type_from_expression(&expr.expression)
|
||||||
|
}
|
||||||
Expression::TSNonNullExpression(expr) => {
|
Expression::TSNonNullExpression(expr) => {
|
||||||
self.infer_type_from_expression(&expr.expression)
|
self.infer_type_from_expression(&expr.expression)
|
||||||
}
|
}
|
||||||
Expression::TSSatisfiesExpression(expr) => {
|
Expression::TSSatisfiesExpression(expr) => {
|
||||||
self.infer_type_from_expression(&expr.expression)
|
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)),
|
Expression::TSTypeAssertion(expr) => Some(self.ast.copy(&expr.type_annotation)),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
5
crates/oxc_isolated_declarations/tests/fixtures/infer-expression.ts
vendored
Normal file
5
crates/oxc_isolated_declarations/tests/fixtures/infer-expression.ts
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
// ParenthesizedExpression
|
||||||
|
const n = (0);
|
||||||
|
const s = ("");
|
||||||
|
const t = (``);
|
||||||
|
const b = (true);
|
||||||
|
|
@ -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;
|
||||||
Loading…
Reference in a new issue