Skip to content
This repository was archived by the owner on Mar 12, 2025. It is now read-only.

Commit 508b2ba

Browse files
authored
feat: Use any for JSX fragments (#973)
**Description:** TypeScript does not validate JSX Fragments properly. **Related issue:** - microsoft/TypeScript#50429
1 parent 5f8ae3f commit 508b2ba

8 files changed

+20
-35
lines changed

crates/stc_ts_file_analyzer/src/analyzer/expr/jsx.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,9 @@ impl Analyzer<'_, '_> {
314314
fn validate(&mut self, e: &RJSXFragment, type_ann: Option<&Type>) -> VResult<Type> {
315315
let children = e.children.validate_with_default(self)?;
316316

317-
self.get_jsx_intrinsic_element(e.span, &"Fragment".into())
317+
// See https://github.com/microsoft/TypeScript/issues/50429
318+
// The TypeScript does not specify the validation rule for JSXFragment.
319+
Ok(Type::any(e.span, Default::default()))
318320
}
319321
}
320322

crates/stc_ts_type_checker/tests/conformance/jsx/checkJsxChildrenProperty14.error-diff.json

+2-12
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,6 @@
77
42
88
]
99
},
10-
"extra_errors": {
11-
"TS2339": 5
12-
},
13-
"extra_error_lines": {
14-
"TS2339": [
15-
24,
16-
25,
17-
26,
18-
39,
19-
42
20-
]
21-
}
10+
"extra_errors": {},
11+
"extra_error_lines": {}
2212
}
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Stats {
22
required_error: 1,
33
matched_error: 0,
4-
extra_error: 5,
4+
extra_error: 0,
55
panic: 0,
66
}

crates/stc_ts_type_checker/tests/conformance/jsx/tsxTypeArgumentsJsxPreserveOutput.error-diff.json

-12
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Stats {
22
required_error: 0,
33
matched_error: 0,
4-
extra_error: 1,
4+
extra_error: 0,
55
panic: 0,
66
}

crates/stc_ts_type_checker/tests/conformance/types/conditional/conditionalTypes1.error-diff.json

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
22
"required_errors": {
33
"TS2322": 6,
4+
"TS2540": 2,
45
"TS2542": 1,
5-
"TS2540": 1,
6+
"TS2339": 1,
67
"TS2403": 1
78
},
89
"required_error_lines": {
@@ -14,11 +15,15 @@
1415
109,
1516
111
1617
],
18+
"TS2540": [
19+
137,
20+
139
21+
],
1722
"TS2542": [
1823
138
1924
],
20-
"TS2540": [
21-
139
25+
"TS2339": [
26+
140
2227
],
2328
"TS2403": [
2429
266
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Stats {
2-
required_error: 9,
3-
matched_error: 11,
2+
required_error: 11,
3+
matched_error: 9,
44
extra_error: 3,
55
panic: 0,
66
}
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Stats {
2-
required_error: 3714,
3-
matched_error: 6320,
4-
extra_error: 757,
2+
required_error: 3716,
3+
matched_error: 6318,
4+
extra_error: 751,
55
panic: 106,
66
}

0 commit comments

Comments
 (0)