mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
[typer] Infer JSXText as a Primitive
This commit is contained in:
@@ -95,6 +95,7 @@ function generateTypeEquation(
|
||||
const left = assignType(lvalue?.place);
|
||||
|
||||
switch (value.kind) {
|
||||
case "JSXText":
|
||||
case "Primitive": {
|
||||
add(left, { kind: "Primitive" });
|
||||
break;
|
||||
|
||||
@@ -94,13 +94,13 @@ bb2:
|
||||
predecessor blocks: bb6 bb1
|
||||
[33] Const mutate count$66 = read renderedItems$32_@0.length
|
||||
[34] Const mutate $67:TPrimitive = "div"
|
||||
[35] Const mutate $68 = "\n "
|
||||
[35] Const mutate $68:TPrimitive = "\n "
|
||||
[36] Const mutate $69:TPrimitive = "h1"
|
||||
[37] Const mutate $70 = " Items"
|
||||
[38] Const mutate t7$71_@5 = JSX <read $69:TPrimitive>{freeze count$66}{read $70}</read $69:TPrimitive>
|
||||
[39] Const mutate $72 = "\n "
|
||||
[40] Const mutate $73 = "\n "
|
||||
[41] Const mutate t10$74_@6 = JSX <read $67:TPrimitive>{read $68}{read t7$71_@5}{read $72}{freeze renderedItems$32_@0}{read $73}</read $67:TPrimitive>
|
||||
[37] Const mutate $70:TPrimitive = " Items"
|
||||
[38] Const mutate t7$71_@5 = JSX <read $69:TPrimitive>{freeze count$66}{read $70:TPrimitive}</read $69:TPrimitive>
|
||||
[39] Const mutate $72:TPrimitive = "\n "
|
||||
[40] Const mutate $73:TPrimitive = "\n "
|
||||
[41] Const mutate t10$74_@6 = JSX <read $67:TPrimitive>{read $68:TPrimitive}{read t7$71_@5}{read $72:TPrimitive}{freeze renderedItems$32_@0}{read $73:TPrimitive}</read $67:TPrimitive>
|
||||
[42] Return read t10$74_@6
|
||||
```
|
||||
|
||||
@@ -155,16 +155,16 @@ function Component(
|
||||
}
|
||||
[33] Const mutate count$66 = read renderedItems$32_@0.length
|
||||
[34] Const mutate $67:TPrimitive = "div"
|
||||
[35] Const mutate $68 = "\n "
|
||||
[35] Const mutate $68:TPrimitive = "\n "
|
||||
[36] Const mutate $69:TPrimitive = "h1"
|
||||
[37] Const mutate $70 = " Items"
|
||||
[37] Const mutate $70:TPrimitive = " Items"
|
||||
scope @5 [38:39] deps=[freeze count$66] out=[$71_@5] {
|
||||
[38] Const mutate $71_@5 = JSX <read $69:TPrimitive>{freeze count$66}{read $70}</read $69:TPrimitive>
|
||||
[38] Const mutate $71_@5 = JSX <read $69:TPrimitive>{freeze count$66}{read $70:TPrimitive}</read $69:TPrimitive>
|
||||
}
|
||||
[39] Const mutate $72 = "\n "
|
||||
[40] Const mutate $73 = "\n "
|
||||
[39] Const mutate $72:TPrimitive = "\n "
|
||||
[40] Const mutate $73:TPrimitive = "\n "
|
||||
scope @6 [41:42] deps=[read $71_@5, freeze renderedItems$32_@0] out=[$74_@6] {
|
||||
[41] Const mutate $74_@6 = JSX <read $67:TPrimitive>{read $68}{read $71_@5}{read $72}{freeze renderedItems$32_@0}{read $73}</read $67:TPrimitive>
|
||||
[41] Const mutate $74_@6 = JSX <read $67:TPrimitive>{read $68:TPrimitive}{read $71_@5}{read $72:TPrimitive}{freeze renderedItems$32_@0}{read $73:TPrimitive}</read $67:TPrimitive>
|
||||
}
|
||||
return read $74_@6
|
||||
}
|
||||
|
||||
@@ -72,10 +72,10 @@ bb0:
|
||||
[1] Const mutate x$11_@0 = Array []
|
||||
[2] Const mutate y$12_@1 = Call read useFreeze$3:TFunction(freeze x$11_@0)
|
||||
[3] Call mutate foo$5:TFunction(read y$12_@1, read x$11_@0)
|
||||
[4] Const mutate $13 = "\n "
|
||||
[5] Const mutate $14 = "\n "
|
||||
[6] Const mutate $15 = "\n "
|
||||
[7] Const mutate t5$16_@2 = JSX <read Component$0>{read $13}{read x$11_@0}{read $14}{read y$12_@1}{read $15}</read Component$0>
|
||||
[4] Const mutate $13:TPrimitive = "\n "
|
||||
[5] Const mutate $14:TPrimitive = "\n "
|
||||
[6] Const mutate $15:TPrimitive = "\n "
|
||||
[7] Const mutate t5$16_@2 = JSX <read Component$0>{read $13:TPrimitive}{read x$11_@0}{read $14:TPrimitive}{read y$12_@1}{read $15:TPrimitive}</read Component$0>
|
||||
[8] Return read t5$16_@2
|
||||
```
|
||||
|
||||
@@ -92,11 +92,11 @@ function Component(
|
||||
[2] Const mutate y$12_@1 = Call read useFreeze$3:TFunction(freeze x$11_@0)
|
||||
}
|
||||
[3] Call mutate foo$5:TFunction(read y$12_@1, read x$11_@0)
|
||||
[4] Const mutate $13 = "\n "
|
||||
[5] Const mutate $14 = "\n "
|
||||
[6] Const mutate $15 = "\n "
|
||||
[4] Const mutate $13:TPrimitive = "\n "
|
||||
[5] Const mutate $14:TPrimitive = "\n "
|
||||
[6] Const mutate $15:TPrimitive = "\n "
|
||||
scope @2 [7:8] deps=[read x$11_@0, read y$12_@1] out=[$16_@2] {
|
||||
[7] Const mutate $16_@2 = JSX <read Component$0>{read $13}{read x$11_@0}{read $14}{read y$12_@1}{read $15}</read Component$0>
|
||||
[7] Const mutate $16_@2 = JSX <read Component$0>{read $13:TPrimitive}{read x$11_@0}{read $14:TPrimitive}{read y$12_@1}{read $15:TPrimitive}</read Component$0>
|
||||
}
|
||||
return read $16_@2
|
||||
}
|
||||
|
||||
@@ -19,17 +19,17 @@ function Foo(props) {
|
||||
|
||||
```
|
||||
bb0:
|
||||
[1] Const mutate $14 = "\n Hello "
|
||||
[1] Const mutate $14:TPrimitive = "\n Hello "
|
||||
[2] Const mutate $15:TPrimitive = " "
|
||||
[3] Const mutate $16 = "\n "
|
||||
[3] Const mutate $16:TPrimitive = "\n "
|
||||
[4] Const mutate $17:TPrimitive = "div"
|
||||
[5] Const mutate $18 = "\n "
|
||||
[6] Const mutate $19 = "Text"
|
||||
[7] Const mutate t0$20_@0 = JsxFragment [read $19]
|
||||
[8] Const mutate $21 = "\n "
|
||||
[9] Const mutate t2$22_@1 = JSX <read $17:TPrimitive>{read $18}{read t0$20_@0}{read $21}</read $17:TPrimitive>
|
||||
[10] Const mutate $23 = "\n "
|
||||
[11] Const mutate t5$24_@2 = JsxFragment [read $14, read props$13.greeting, read $15:TPrimitive, read $16, read t2$22_@1, read $23]
|
||||
[5] Const mutate $18:TPrimitive = "\n "
|
||||
[6] Const mutate $19:TPrimitive = "Text"
|
||||
[7] Const mutate t0$20_@0 = JsxFragment [read $19:TPrimitive]
|
||||
[8] Const mutate $21:TPrimitive = "\n "
|
||||
[9] Const mutate t2$22_@1 = JSX <read $17:TPrimitive>{read $18:TPrimitive}{read t0$20_@0}{read $21:TPrimitive}</read $17:TPrimitive>
|
||||
[10] Const mutate $23:TPrimitive = "\n "
|
||||
[11] Const mutate t5$24_@2 = JsxFragment [read $14:TPrimitive, read props$13.greeting, read $15:TPrimitive, read $16:TPrimitive, read t2$22_@1, read $23:TPrimitive]
|
||||
[12] Return read t5$24_@2
|
||||
```
|
||||
|
||||
@@ -39,22 +39,22 @@ bb0:
|
||||
function Foo(
|
||||
props,
|
||||
) {
|
||||
[1] Const mutate $14 = "\n Hello "
|
||||
[1] Const mutate $14:TPrimitive = "\n Hello "
|
||||
[2] Const mutate $15:TPrimitive = " "
|
||||
[3] Const mutate $16 = "\n "
|
||||
[3] Const mutate $16:TPrimitive = "\n "
|
||||
[4] Const mutate $17:TPrimitive = "div"
|
||||
[5] Const mutate $18 = "\n "
|
||||
[6] Const mutate $19 = "Text"
|
||||
[5] Const mutate $18:TPrimitive = "\n "
|
||||
[6] Const mutate $19:TPrimitive = "Text"
|
||||
scope @0 [7:8] deps=[] out=[$20_@0] {
|
||||
[7] Const mutate $20_@0 = JsxFragment [read $19]
|
||||
[7] Const mutate $20_@0 = JsxFragment [read $19:TPrimitive]
|
||||
}
|
||||
[8] Const mutate $21 = "\n "
|
||||
[8] Const mutate $21:TPrimitive = "\n "
|
||||
scope @1 [9:10] deps=[read $20_@0] out=[$22_@1] {
|
||||
[9] Const mutate $22_@1 = JSX <read $17:TPrimitive>{read $18}{read $20_@0}{read $21}</read $17:TPrimitive>
|
||||
[9] Const mutate $22_@1 = JSX <read $17:TPrimitive>{read $18:TPrimitive}{read $20_@0}{read $21:TPrimitive}</read $17:TPrimitive>
|
||||
}
|
||||
[10] Const mutate $23 = "\n "
|
||||
[10] Const mutate $23:TPrimitive = "\n "
|
||||
scope @2 [11:12] deps=[read props$13.greeting, read $22_@1] out=[$24_@2] {
|
||||
[11] Const mutate $24_@2 = JsxFragment [read $14, read props$13.greeting, read $15:TPrimitive, read $16, read $22_@1, read $23]
|
||||
[11] Const mutate $24_@2 = JsxFragment [read $14:TPrimitive, read props$13.greeting, read $15:TPrimitive, read $16:TPrimitive, read $22_@1, read $23:TPrimitive]
|
||||
}
|
||||
return read $24_@2
|
||||
}
|
||||
|
||||
@@ -65,10 +65,10 @@ bb4:
|
||||
bb3:
|
||||
predecessor blocks: bb5 bb4
|
||||
[15] Const mutate $25:TPrimitive = "div"
|
||||
[16] Const mutate $26 = "\n "
|
||||
[17] Const mutate $27 = "\n "
|
||||
[18] Const mutate $28 = "\n "
|
||||
[19] Const mutate t13$31_@5 = JSX <read $25:TPrimitive>{read $26}{read y$19_@1}{read $27}{freeze x$30_@2}{read $28}</read $25:TPrimitive>
|
||||
[16] Const mutate $26:TPrimitive = "\n "
|
||||
[17] Const mutate $27:TPrimitive = "\n "
|
||||
[18] Const mutate $28:TPrimitive = "\n "
|
||||
[19] Const mutate t13$31_@5 = JSX <read $25:TPrimitive>{read $26:TPrimitive}{read y$19_@1}{read $27:TPrimitive}{freeze x$30_@2}{read $28:TPrimitive}</read $25:TPrimitive>
|
||||
[20] Return read t13$31_@5
|
||||
```
|
||||
|
||||
@@ -112,11 +112,11 @@ function foo(
|
||||
}
|
||||
}
|
||||
[15] Const mutate $25:TPrimitive = "div"
|
||||
[16] Const mutate $26 = "\n "
|
||||
[17] Const mutate $27 = "\n "
|
||||
[18] Const mutate $28 = "\n "
|
||||
[16] Const mutate $26:TPrimitive = "\n "
|
||||
[17] Const mutate $27:TPrimitive = "\n "
|
||||
[18] Const mutate $28:TPrimitive = "\n "
|
||||
scope @5 [19:20] deps=[read y$19_@1, freeze x$30_@2] out=[$31_@5] {
|
||||
[19] Const mutate $31_@5 = JSX <read $25:TPrimitive>{read $26}{read y$19_@1}{read $27}{freeze x$30_@2}{read $28}</read $25:TPrimitive>
|
||||
[19] Const mutate $31_@5 = JSX <read $25:TPrimitive>{read $26:TPrimitive}{read y$19_@1}{read $27:TPrimitive}{freeze x$30_@2}{read $28:TPrimitive}</read $25:TPrimitive>
|
||||
}
|
||||
return read $31_@5
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user