From 3f90887a6e45510de8f7e858cf4e8bb881d1a1cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Tue, 21 Mar 2023 23:47:35 +0100 Subject: [PATCH] Optimize the transformed output of `JSXSpreadAttribute`s containing an `ObjectLiteralExpression` (#49100) --- src/compiler/transformers/jsx.ts | 79 +++++++++++----- .../tsxEmitSpreadAttribute(target=es2015).js | 43 ++++++++- ...EmitSpreadAttribute(target=es2015).symbols | 66 +++++++++++++ ...sxEmitSpreadAttribute(target=es2015).types | 92 +++++++++++++++++++ .../tsxEmitSpreadAttribute(target=es2018).js | 43 ++++++++- ...EmitSpreadAttribute(target=es2018).symbols | 66 +++++++++++++ ...sxEmitSpreadAttribute(target=es2018).types | 92 +++++++++++++++++++ .../tsxEmitSpreadAttribute(target=esnext).js | 43 ++++++++- ...EmitSpreadAttribute(target=esnext).symbols | 66 +++++++++++++ ...sxEmitSpreadAttribute(target=esnext).types | 92 +++++++++++++++++++ ...ReactEmitSpreadAttribute(target=es2015).js | 43 ++++++++- ...EmitSpreadAttribute(target=es2015).symbols | 76 +++++++++++++++ ...ctEmitSpreadAttribute(target=es2015).types | 92 +++++++++++++++++++ ...ReactEmitSpreadAttribute(target=es2018).js | 43 ++++++++- ...EmitSpreadAttribute(target=es2018).symbols | 76 +++++++++++++++ ...ctEmitSpreadAttribute(target=es2018).types | 92 +++++++++++++++++++ ...ReactEmitSpreadAttribute(target=esnext).js | 43 ++++++++- ...EmitSpreadAttribute(target=esnext).symbols | 76 +++++++++++++++ ...ctEmitSpreadAttribute(target=esnext).types | 92 +++++++++++++++++++ .../conformance/jsx/tsxEmitSpreadAttribute.ts | 22 +++++ .../jsx/tsxReactEmitSpreadAttribute.ts | 22 +++++ 21 files changed, 1319 insertions(+), 40 deletions(-) diff --git a/src/compiler/transformers/jsx.ts b/src/compiler/transformers/jsx.ts index 7efa35b87fc70..89883be33292b 100644 --- a/src/compiler/transformers/jsx.ts +++ b/src/compiler/transformers/jsx.ts @@ -35,8 +35,12 @@ import { isJsxSelfClosingElement, isJsxSpreadAttribute, isLineBreak, + isObjectLiteralExpression, + isPropertyAssignment, isSourceFile, + isSpreadAssignment, isStringDoubleQuoted, + isStringLiteral, isWhiteSpaceSingleLine, JsxAttribute, JsxAttributeValue, @@ -55,6 +59,8 @@ import { mapDefined, Node, NodeFlags, + ObjectLiteralElementLike, + ObjectLiteralExpression, PropertyAssignment, ScriptTarget, setIdentifierGeneratedImportReference, @@ -63,7 +69,6 @@ import { singleOrUndefined, SourceFile, spanMap, - SpreadAssignment, startOnNewLine, Statement, StringLiteral, @@ -243,13 +248,18 @@ export function transformJsx(context: TransformationContext): (x: SourceFile | B } } + function hasProto(obj: ObjectLiteralExpression) { + return obj.properties.some(p => isPropertyAssignment(p) && + (isIdentifier(p.name) && idText(p.name) === "__proto__" || isStringLiteral(p.name) && p.name.text === "__proto__")); + } + /** * The react jsx/jsxs transform falls back to `createElement` when an explicit `key` argument comes after a spread */ function hasKeyAfterPropsSpread(node: JsxOpeningLikeElement) { let spread = false; for (const elem of node.attributes.properties) { - if (isJsxSpreadAttribute(elem)) { + if (isJsxSpreadAttribute(elem) && (!isObjectLiteralExpression(elem.expression) || elem.expression.properties.some(isSpreadAssignment))) { spread = true; } else if (spread && isJsxAttribute(elem) && elem.name.escapedText === "key") { @@ -427,7 +437,10 @@ export function transformJsx(context: TransformationContext): (x: SourceFile | B return element; } - function transformJsxSpreadAttributeToSpreadAssignment(node: JsxSpreadAttribute) { + function transformJsxSpreadAttributeToProps(node: JsxSpreadAttribute) { + if (isObjectLiteralExpression(node.expression) && !hasProto(node.expression)) { + return node.expression.properties; + } return factory.createSpreadAssignment(Debug.checkDefined(visitNode(node.expression, visitor, isExpression))); } @@ -438,8 +451,8 @@ export function transformJsx(context: TransformationContext): (x: SourceFile | B } function transformJsxAttributesToProps(attrs: readonly(JsxSpreadAttribute | JsxAttribute)[], children?: PropertyAssignment) { - const props = flatten(spanMap(attrs, isJsxSpreadAttribute, (attrs, isSpread) => - map(attrs, attr => isSpread ? transformJsxSpreadAttributeToSpreadAssignment(attr as JsxSpreadAttribute) : transformJsxAttributeToObjectLiteralElement(attr as JsxAttribute)))); + const props = flatten(spanMap(attrs, isJsxSpreadAttribute, (attrs, isSpread) => + flatten(map(attrs, attr => isSpread ? transformJsxSpreadAttributeToProps(attr as JsxSpreadAttribute) : transformJsxAttributeToObjectLiteralElement(attr as JsxAttribute))))); if (children) { props.push(children); } @@ -447,30 +460,52 @@ export function transformJsx(context: TransformationContext): (x: SourceFile | B } function transformJsxAttributesToExpression(attrs: readonly(JsxSpreadAttribute | JsxAttribute)[], children?: PropertyAssignment) { - // Map spans of JsxAttribute nodes into object literals and spans - // of JsxSpreadAttribute nodes into expressions. - const expressions = flatten( - spanMap(attrs, isJsxSpreadAttribute, (attrs, isSpread) => isSpread - ? map(attrs as JsxSpreadAttribute[], transformJsxSpreadAttributeToExpression) - : factory.createObjectLiteralExpression(map(attrs as JsxAttribute[], transformJsxAttributeToObjectLiteralElement)) - ) - ); - - if (isJsxSpreadAttribute(attrs[0])) { - // We must always emit at least one object literal before a spread - // argument.factory.createObjectLiteral - expressions.unshift(factory.createObjectLiteralExpression()); + const expressions: Expression[] = []; + let properties: ObjectLiteralElementLike[] = []; + + for (const attr of attrs) { + if (isJsxSpreadAttribute(attr)) { + // as an optimization we try to flatten the first level of spread inline object + // as if its props would be passed as JSX attributes + if (isObjectLiteralExpression(attr.expression) && !hasProto(attr.expression)) { + for (const prop of attr.expression.properties) { + if (isSpreadAssignment(prop)) { + finishObjectLiteralIfNeeded(); + expressions.push(prop.expression); + continue; + } + properties.push(prop); + } + continue; + } + finishObjectLiteralIfNeeded(); + expressions.push(attr.expression); + continue; + } + properties.push(transformJsxAttributeToObjectLiteralElement(attr)); } if (children) { - expressions.push(factory.createObjectLiteralExpression([children])); + properties.push(children); + } + + finishObjectLiteralIfNeeded(); + + if (expressions.length && !isObjectLiteralExpression(expressions[0])) { + // We must always emit at least one object literal before a spread attribute + // as the JSX always factory expects a fresh object, so we need to make a copy here + // we also avoid mutating an external reference by doing this (first expression is used as assign's target) + expressions.unshift(factory.createObjectLiteralExpression()); } return singleOrUndefined(expressions) || emitHelpers().createAssignHelper(expressions); - } - function transformJsxSpreadAttributeToExpression(node: JsxSpreadAttribute) { - return Debug.checkDefined(visitNode(node.expression, visitor, isExpression)); + function finishObjectLiteralIfNeeded() { + if (properties.length) { + expressions.push(factory.createObjectLiteralExpression(properties)); + properties = []; + } + } } function transformJsxAttributeToObjectLiteralElement(node: JsxAttribute) { diff --git a/tests/baselines/reference/tsxEmitSpreadAttribute(target=es2015).js b/tests/baselines/reference/tsxEmitSpreadAttribute(target=es2015).js index fbf2d3ac97c9a..ddc09ef8ef86a 100644 --- a/tests/baselines/reference/tsxEmitSpreadAttribute(target=es2015).js +++ b/tests/baselines/reference/tsxEmitSpreadAttribute(target=es2015).js @@ -24,6 +24,28 @@ export function T5(a: any, b: any, c: any, d: any) { export function T6(a: any, b: any, c: any, d: any) { return
T6
; } + +export function T7(a: any, b: any, c: any, d: any) { + return
T7
; +} + +export function T8(a: any, b: any, c: any, d: any) { + return
T8
; +} + +declare const __proto__: string; + +export function T9(a: any, b: any, c: any, d: any) { + return
T9
; +} + +export function T10(a: any, b: any, c: any, d: any) { + return
T10
; +} + +export function T11(a: any, b: any, c: any, d: any) { + return
T11
; +} //// [test.js] @@ -37,11 +59,26 @@ export function T3(a, b) { return React.createElement("div", Object.assign({}, a, { className: "T3" }, b), "T3"); } export function T4(a, b) { - return React.createElement("div", Object.assign({ className: "T4" }, Object.assign(Object.assign({}, a), b)), "T4"); + return React.createElement("div", Object.assign({ className: "T4" }, a, b), "T4"); } export function T5(a, b, c, d) { - return React.createElement("div", Object.assign({ className: "T5" }, Object.assign(Object.assign(Object.assign({}, a), b), { c, d })), "T5"); + return React.createElement("div", Object.assign({ className: "T5" }, a, b, { c, d }), "T5"); } export function T6(a, b, c, d) { - return React.createElement("div", Object.assign({ className: "T6" }, Object.assign(Object.assign(Object.assign({}, a), b), Object.assign(Object.assign({}, c), d))), "T6"); + return React.createElement("div", Object.assign({ className: "T6" }, a, b, Object.assign(Object.assign({}, c), d)), "T6"); +} +export function T7(a, b, c, d) { + return React.createElement("div", Object.assign({ className: "T7" }, { __proto__: null, dir: 'rtl' }), "T7"); +} +export function T8(a, b, c, d) { + return React.createElement("div", Object.assign({ className: "T8" }, { "__proto__": null }), "T8"); +} +export function T9(a, b, c, d) { + return React.createElement("div", { className: "T9", [__proto__]: null }, "T9"); +} +export function T10(a, b, c, d) { + return React.createElement("div", { className: "T10", ["__proto__"]: null }, "T10"); +} +export function T11(a, b, c, d) { + return React.createElement("div", { className: "T11", __proto__ }, "T11"); } diff --git a/tests/baselines/reference/tsxEmitSpreadAttribute(target=es2015).symbols b/tests/baselines/reference/tsxEmitSpreadAttribute(target=es2015).symbols index 2ef93d2f4315c..a103428f683b8 100644 --- a/tests/baselines/reference/tsxEmitSpreadAttribute(target=es2015).symbols +++ b/tests/baselines/reference/tsxEmitSpreadAttribute(target=es2015).symbols @@ -74,3 +74,69 @@ export function T6(a: any, b: any, c: any, d: any) { >d : Symbol(d, Decl(test.tsx, 22, 42)) } +export function T7(a: any, b: any, c: any, d: any) { +>T7 : Symbol(T7, Decl(test.tsx, 24, 1)) +>a : Symbol(a, Decl(test.tsx, 26, 19)) +>b : Symbol(b, Decl(test.tsx, 26, 26)) +>c : Symbol(c, Decl(test.tsx, 26, 34)) +>d : Symbol(d, Decl(test.tsx, 26, 42)) + + return
T7
; +>className : Symbol(className, Decl(test.tsx, 27, 15)) +>__proto__ : Symbol(__proto__, Decl(test.tsx, 27, 39)) +>dir : Symbol(dir, Decl(test.tsx, 27, 56)) +} + +export function T8(a: any, b: any, c: any, d: any) { +>T8 : Symbol(T8, Decl(test.tsx, 28, 1)) +>a : Symbol(a, Decl(test.tsx, 30, 19)) +>b : Symbol(b, Decl(test.tsx, 30, 26)) +>c : Symbol(c, Decl(test.tsx, 30, 34)) +>d : Symbol(d, Decl(test.tsx, 30, 42)) + + return
T8
; +>className : Symbol(className, Decl(test.tsx, 31, 15)) +>"__proto__" : Symbol("__proto__", Decl(test.tsx, 31, 39)) +} + +declare const __proto__: string; +>__proto__ : Symbol(__proto__, Decl(test.tsx, 34, 13)) + +export function T9(a: any, b: any, c: any, d: any) { +>T9 : Symbol(T9, Decl(test.tsx, 34, 32)) +>a : Symbol(a, Decl(test.tsx, 36, 19)) +>b : Symbol(b, Decl(test.tsx, 36, 26)) +>c : Symbol(c, Decl(test.tsx, 36, 34)) +>d : Symbol(d, Decl(test.tsx, 36, 42)) + + return
T9
; +>className : Symbol(className, Decl(test.tsx, 37, 15)) +>[__proto__] : Symbol([__proto__], Decl(test.tsx, 37, 39)) +>__proto__ : Symbol(__proto__, Decl(test.tsx, 34, 13)) +} + +export function T10(a: any, b: any, c: any, d: any) { +>T10 : Symbol(T10, Decl(test.tsx, 38, 1)) +>a : Symbol(a, Decl(test.tsx, 40, 20)) +>b : Symbol(b, Decl(test.tsx, 40, 27)) +>c : Symbol(c, Decl(test.tsx, 40, 35)) +>d : Symbol(d, Decl(test.tsx, 40, 43)) + + return
T10
; +>className : Symbol(className, Decl(test.tsx, 41, 15)) +>["__proto__"] : Symbol(["__proto__"], Decl(test.tsx, 41, 40)) +>"__proto__" : Symbol(["__proto__"], Decl(test.tsx, 41, 40)) +} + +export function T11(a: any, b: any, c: any, d: any) { +>T11 : Symbol(T11, Decl(test.tsx, 42, 1)) +>a : Symbol(a, Decl(test.tsx, 44, 20)) +>b : Symbol(b, Decl(test.tsx, 44, 27)) +>c : Symbol(c, Decl(test.tsx, 44, 35)) +>d : Symbol(d, Decl(test.tsx, 44, 43)) + + return
T11
; +>className : Symbol(className, Decl(test.tsx, 45, 15)) +>__proto__ : Symbol(__proto__, Decl(test.tsx, 45, 40)) +} + diff --git a/tests/baselines/reference/tsxEmitSpreadAttribute(target=es2015).types b/tests/baselines/reference/tsxEmitSpreadAttribute(target=es2015).types index 101c3fb75a0d8..7e5185ccb8d82 100644 --- a/tests/baselines/reference/tsxEmitSpreadAttribute(target=es2015).types +++ b/tests/baselines/reference/tsxEmitSpreadAttribute(target=es2015).types @@ -103,3 +103,95 @@ export function T6(a: any, b: any, c: any, d: any) { >div : any } +export function T7(a: any, b: any, c: any, d: any) { +>T7 : (a: any, b: any, c: any, d: any) => any +>a : any +>b : any +>c : any +>d : any + + return
T7
; +>
T7
: error +>div : any +>className : string +>"T7" : "T7" +>{ __proto__: null, dir: 'rtl' } : { __proto__: null; dir: string; } +>__proto__ : null +>dir : string +>'rtl' : "rtl" +>div : any +} + +export function T8(a: any, b: any, c: any, d: any) { +>T8 : (a: any, b: any, c: any, d: any) => any +>a : any +>b : any +>c : any +>d : any + + return
T8
; +>
T8
: error +>div : any +>className : string +>"T8" : "T8" +>{ "__proto__": null } : { __proto__: null; } +>"__proto__" : null +>div : any +} + +declare const __proto__: string; +>__proto__ : string + +export function T9(a: any, b: any, c: any, d: any) { +>T9 : (a: any, b: any, c: any, d: any) => any +>a : any +>b : any +>c : any +>d : any + + return
T9
; +>
T9
: error +>div : any +>className : string +>"T9" : "T9" +>{ [__proto__]: null } : { [x: string]: null; } +>[__proto__] : null +>__proto__ : string +>div : any +} + +export function T10(a: any, b: any, c: any, d: any) { +>T10 : (a: any, b: any, c: any, d: any) => any +>a : any +>b : any +>c : any +>d : any + + return
T10
; +>
T10
: error +>div : any +>className : string +>"T10" : "T10" +>{ ["__proto__"]: null } : { __proto__: null; } +>["__proto__"] : null +>"__proto__" : "__proto__" +>div : any +} + +export function T11(a: any, b: any, c: any, d: any) { +>T11 : (a: any, b: any, c: any, d: any) => any +>a : any +>b : any +>c : any +>d : any + + return
T11
; +>
T11
: error +>div : any +>className : string +>"T11" : "T11" +>{ __proto__ } : { __proto__: string; } +>__proto__ : string +>div : any +} + diff --git a/tests/baselines/reference/tsxEmitSpreadAttribute(target=es2018).js b/tests/baselines/reference/tsxEmitSpreadAttribute(target=es2018).js index dcb223449bb22..52dfc243921ae 100644 --- a/tests/baselines/reference/tsxEmitSpreadAttribute(target=es2018).js +++ b/tests/baselines/reference/tsxEmitSpreadAttribute(target=es2018).js @@ -24,6 +24,28 @@ export function T5(a: any, b: any, c: any, d: any) { export function T6(a: any, b: any, c: any, d: any) { return
T6
; } + +export function T7(a: any, b: any, c: any, d: any) { + return
T7
; +} + +export function T8(a: any, b: any, c: any, d: any) { + return
T8
; +} + +declare const __proto__: string; + +export function T9(a: any, b: any, c: any, d: any) { + return
T9
; +} + +export function T10(a: any, b: any, c: any, d: any) { + return
T10
; +} + +export function T11(a: any, b: any, c: any, d: any) { + return
T11
; +} //// [test.js] @@ -37,11 +59,26 @@ export function T3(a, b) { return React.createElement("div", { ...a, className: "T3", ...b }, "T3"); } export function T4(a, b) { - return React.createElement("div", { className: "T4", ...{ ...a, ...b } }, "T4"); + return React.createElement("div", { className: "T4", ...a, ...b }, "T4"); } export function T5(a, b, c, d) { - return React.createElement("div", { className: "T5", ...{ ...a, ...b, ...{ c, d } } }, "T5"); + return React.createElement("div", { className: "T5", ...a, ...b, ...{ c, d } }, "T5"); } export function T6(a, b, c, d) { - return React.createElement("div", { className: "T6", ...{ ...a, ...b, ...{ ...c, ...d } } }, "T6"); + return React.createElement("div", { className: "T6", ...a, ...b, ...{ ...c, ...d } }, "T6"); +} +export function T7(a, b, c, d) { + return React.createElement("div", { className: "T7", ...{ __proto__: null, dir: 'rtl' } }, "T7"); +} +export function T8(a, b, c, d) { + return React.createElement("div", { className: "T8", ...{ "__proto__": null } }, "T8"); +} +export function T9(a, b, c, d) { + return React.createElement("div", { className: "T9", [__proto__]: null }, "T9"); +} +export function T10(a, b, c, d) { + return React.createElement("div", { className: "T10", ["__proto__"]: null }, "T10"); +} +export function T11(a, b, c, d) { + return React.createElement("div", { className: "T11", __proto__ }, "T11"); } diff --git a/tests/baselines/reference/tsxEmitSpreadAttribute(target=es2018).symbols b/tests/baselines/reference/tsxEmitSpreadAttribute(target=es2018).symbols index 2ef93d2f4315c..a103428f683b8 100644 --- a/tests/baselines/reference/tsxEmitSpreadAttribute(target=es2018).symbols +++ b/tests/baselines/reference/tsxEmitSpreadAttribute(target=es2018).symbols @@ -74,3 +74,69 @@ export function T6(a: any, b: any, c: any, d: any) { >d : Symbol(d, Decl(test.tsx, 22, 42)) } +export function T7(a: any, b: any, c: any, d: any) { +>T7 : Symbol(T7, Decl(test.tsx, 24, 1)) +>a : Symbol(a, Decl(test.tsx, 26, 19)) +>b : Symbol(b, Decl(test.tsx, 26, 26)) +>c : Symbol(c, Decl(test.tsx, 26, 34)) +>d : Symbol(d, Decl(test.tsx, 26, 42)) + + return
T7
; +>className : Symbol(className, Decl(test.tsx, 27, 15)) +>__proto__ : Symbol(__proto__, Decl(test.tsx, 27, 39)) +>dir : Symbol(dir, Decl(test.tsx, 27, 56)) +} + +export function T8(a: any, b: any, c: any, d: any) { +>T8 : Symbol(T8, Decl(test.tsx, 28, 1)) +>a : Symbol(a, Decl(test.tsx, 30, 19)) +>b : Symbol(b, Decl(test.tsx, 30, 26)) +>c : Symbol(c, Decl(test.tsx, 30, 34)) +>d : Symbol(d, Decl(test.tsx, 30, 42)) + + return
T8
; +>className : Symbol(className, Decl(test.tsx, 31, 15)) +>"__proto__" : Symbol("__proto__", Decl(test.tsx, 31, 39)) +} + +declare const __proto__: string; +>__proto__ : Symbol(__proto__, Decl(test.tsx, 34, 13)) + +export function T9(a: any, b: any, c: any, d: any) { +>T9 : Symbol(T9, Decl(test.tsx, 34, 32)) +>a : Symbol(a, Decl(test.tsx, 36, 19)) +>b : Symbol(b, Decl(test.tsx, 36, 26)) +>c : Symbol(c, Decl(test.tsx, 36, 34)) +>d : Symbol(d, Decl(test.tsx, 36, 42)) + + return
T9
; +>className : Symbol(className, Decl(test.tsx, 37, 15)) +>[__proto__] : Symbol([__proto__], Decl(test.tsx, 37, 39)) +>__proto__ : Symbol(__proto__, Decl(test.tsx, 34, 13)) +} + +export function T10(a: any, b: any, c: any, d: any) { +>T10 : Symbol(T10, Decl(test.tsx, 38, 1)) +>a : Symbol(a, Decl(test.tsx, 40, 20)) +>b : Symbol(b, Decl(test.tsx, 40, 27)) +>c : Symbol(c, Decl(test.tsx, 40, 35)) +>d : Symbol(d, Decl(test.tsx, 40, 43)) + + return
T10
; +>className : Symbol(className, Decl(test.tsx, 41, 15)) +>["__proto__"] : Symbol(["__proto__"], Decl(test.tsx, 41, 40)) +>"__proto__" : Symbol(["__proto__"], Decl(test.tsx, 41, 40)) +} + +export function T11(a: any, b: any, c: any, d: any) { +>T11 : Symbol(T11, Decl(test.tsx, 42, 1)) +>a : Symbol(a, Decl(test.tsx, 44, 20)) +>b : Symbol(b, Decl(test.tsx, 44, 27)) +>c : Symbol(c, Decl(test.tsx, 44, 35)) +>d : Symbol(d, Decl(test.tsx, 44, 43)) + + return
T11
; +>className : Symbol(className, Decl(test.tsx, 45, 15)) +>__proto__ : Symbol(__proto__, Decl(test.tsx, 45, 40)) +} + diff --git a/tests/baselines/reference/tsxEmitSpreadAttribute(target=es2018).types b/tests/baselines/reference/tsxEmitSpreadAttribute(target=es2018).types index 101c3fb75a0d8..7e5185ccb8d82 100644 --- a/tests/baselines/reference/tsxEmitSpreadAttribute(target=es2018).types +++ b/tests/baselines/reference/tsxEmitSpreadAttribute(target=es2018).types @@ -103,3 +103,95 @@ export function T6(a: any, b: any, c: any, d: any) { >div : any } +export function T7(a: any, b: any, c: any, d: any) { +>T7 : (a: any, b: any, c: any, d: any) => any +>a : any +>b : any +>c : any +>d : any + + return
T7
; +>
T7
: error +>div : any +>className : string +>"T7" : "T7" +>{ __proto__: null, dir: 'rtl' } : { __proto__: null; dir: string; } +>__proto__ : null +>dir : string +>'rtl' : "rtl" +>div : any +} + +export function T8(a: any, b: any, c: any, d: any) { +>T8 : (a: any, b: any, c: any, d: any) => any +>a : any +>b : any +>c : any +>d : any + + return
T8
; +>
T8
: error +>div : any +>className : string +>"T8" : "T8" +>{ "__proto__": null } : { __proto__: null; } +>"__proto__" : null +>div : any +} + +declare const __proto__: string; +>__proto__ : string + +export function T9(a: any, b: any, c: any, d: any) { +>T9 : (a: any, b: any, c: any, d: any) => any +>a : any +>b : any +>c : any +>d : any + + return
T9
; +>
T9
: error +>div : any +>className : string +>"T9" : "T9" +>{ [__proto__]: null } : { [x: string]: null; } +>[__proto__] : null +>__proto__ : string +>div : any +} + +export function T10(a: any, b: any, c: any, d: any) { +>T10 : (a: any, b: any, c: any, d: any) => any +>a : any +>b : any +>c : any +>d : any + + return
T10
; +>
T10
: error +>div : any +>className : string +>"T10" : "T10" +>{ ["__proto__"]: null } : { __proto__: null; } +>["__proto__"] : null +>"__proto__" : "__proto__" +>div : any +} + +export function T11(a: any, b: any, c: any, d: any) { +>T11 : (a: any, b: any, c: any, d: any) => any +>a : any +>b : any +>c : any +>d : any + + return
T11
; +>
T11
: error +>div : any +>className : string +>"T11" : "T11" +>{ __proto__ } : { __proto__: string; } +>__proto__ : string +>div : any +} + diff --git a/tests/baselines/reference/tsxEmitSpreadAttribute(target=esnext).js b/tests/baselines/reference/tsxEmitSpreadAttribute(target=esnext).js index dcb223449bb22..52dfc243921ae 100644 --- a/tests/baselines/reference/tsxEmitSpreadAttribute(target=esnext).js +++ b/tests/baselines/reference/tsxEmitSpreadAttribute(target=esnext).js @@ -24,6 +24,28 @@ export function T5(a: any, b: any, c: any, d: any) { export function T6(a: any, b: any, c: any, d: any) { return
T6
; } + +export function T7(a: any, b: any, c: any, d: any) { + return
T7
; +} + +export function T8(a: any, b: any, c: any, d: any) { + return
T8
; +} + +declare const __proto__: string; + +export function T9(a: any, b: any, c: any, d: any) { + return
T9
; +} + +export function T10(a: any, b: any, c: any, d: any) { + return
T10
; +} + +export function T11(a: any, b: any, c: any, d: any) { + return
T11
; +} //// [test.js] @@ -37,11 +59,26 @@ export function T3(a, b) { return React.createElement("div", { ...a, className: "T3", ...b }, "T3"); } export function T4(a, b) { - return React.createElement("div", { className: "T4", ...{ ...a, ...b } }, "T4"); + return React.createElement("div", { className: "T4", ...a, ...b }, "T4"); } export function T5(a, b, c, d) { - return React.createElement("div", { className: "T5", ...{ ...a, ...b, ...{ c, d } } }, "T5"); + return React.createElement("div", { className: "T5", ...a, ...b, ...{ c, d } }, "T5"); } export function T6(a, b, c, d) { - return React.createElement("div", { className: "T6", ...{ ...a, ...b, ...{ ...c, ...d } } }, "T6"); + return React.createElement("div", { className: "T6", ...a, ...b, ...{ ...c, ...d } }, "T6"); +} +export function T7(a, b, c, d) { + return React.createElement("div", { className: "T7", ...{ __proto__: null, dir: 'rtl' } }, "T7"); +} +export function T8(a, b, c, d) { + return React.createElement("div", { className: "T8", ...{ "__proto__": null } }, "T8"); +} +export function T9(a, b, c, d) { + return React.createElement("div", { className: "T9", [__proto__]: null }, "T9"); +} +export function T10(a, b, c, d) { + return React.createElement("div", { className: "T10", ["__proto__"]: null }, "T10"); +} +export function T11(a, b, c, d) { + return React.createElement("div", { className: "T11", __proto__ }, "T11"); } diff --git a/tests/baselines/reference/tsxEmitSpreadAttribute(target=esnext).symbols b/tests/baselines/reference/tsxEmitSpreadAttribute(target=esnext).symbols index 2ef93d2f4315c..a103428f683b8 100644 --- a/tests/baselines/reference/tsxEmitSpreadAttribute(target=esnext).symbols +++ b/tests/baselines/reference/tsxEmitSpreadAttribute(target=esnext).symbols @@ -74,3 +74,69 @@ export function T6(a: any, b: any, c: any, d: any) { >d : Symbol(d, Decl(test.tsx, 22, 42)) } +export function T7(a: any, b: any, c: any, d: any) { +>T7 : Symbol(T7, Decl(test.tsx, 24, 1)) +>a : Symbol(a, Decl(test.tsx, 26, 19)) +>b : Symbol(b, Decl(test.tsx, 26, 26)) +>c : Symbol(c, Decl(test.tsx, 26, 34)) +>d : Symbol(d, Decl(test.tsx, 26, 42)) + + return
T7
; +>className : Symbol(className, Decl(test.tsx, 27, 15)) +>__proto__ : Symbol(__proto__, Decl(test.tsx, 27, 39)) +>dir : Symbol(dir, Decl(test.tsx, 27, 56)) +} + +export function T8(a: any, b: any, c: any, d: any) { +>T8 : Symbol(T8, Decl(test.tsx, 28, 1)) +>a : Symbol(a, Decl(test.tsx, 30, 19)) +>b : Symbol(b, Decl(test.tsx, 30, 26)) +>c : Symbol(c, Decl(test.tsx, 30, 34)) +>d : Symbol(d, Decl(test.tsx, 30, 42)) + + return
T8
; +>className : Symbol(className, Decl(test.tsx, 31, 15)) +>"__proto__" : Symbol("__proto__", Decl(test.tsx, 31, 39)) +} + +declare const __proto__: string; +>__proto__ : Symbol(__proto__, Decl(test.tsx, 34, 13)) + +export function T9(a: any, b: any, c: any, d: any) { +>T9 : Symbol(T9, Decl(test.tsx, 34, 32)) +>a : Symbol(a, Decl(test.tsx, 36, 19)) +>b : Symbol(b, Decl(test.tsx, 36, 26)) +>c : Symbol(c, Decl(test.tsx, 36, 34)) +>d : Symbol(d, Decl(test.tsx, 36, 42)) + + return
T9
; +>className : Symbol(className, Decl(test.tsx, 37, 15)) +>[__proto__] : Symbol([__proto__], Decl(test.tsx, 37, 39)) +>__proto__ : Symbol(__proto__, Decl(test.tsx, 34, 13)) +} + +export function T10(a: any, b: any, c: any, d: any) { +>T10 : Symbol(T10, Decl(test.tsx, 38, 1)) +>a : Symbol(a, Decl(test.tsx, 40, 20)) +>b : Symbol(b, Decl(test.tsx, 40, 27)) +>c : Symbol(c, Decl(test.tsx, 40, 35)) +>d : Symbol(d, Decl(test.tsx, 40, 43)) + + return
T10
; +>className : Symbol(className, Decl(test.tsx, 41, 15)) +>["__proto__"] : Symbol(["__proto__"], Decl(test.tsx, 41, 40)) +>"__proto__" : Symbol(["__proto__"], Decl(test.tsx, 41, 40)) +} + +export function T11(a: any, b: any, c: any, d: any) { +>T11 : Symbol(T11, Decl(test.tsx, 42, 1)) +>a : Symbol(a, Decl(test.tsx, 44, 20)) +>b : Symbol(b, Decl(test.tsx, 44, 27)) +>c : Symbol(c, Decl(test.tsx, 44, 35)) +>d : Symbol(d, Decl(test.tsx, 44, 43)) + + return
T11
; +>className : Symbol(className, Decl(test.tsx, 45, 15)) +>__proto__ : Symbol(__proto__, Decl(test.tsx, 45, 40)) +} + diff --git a/tests/baselines/reference/tsxEmitSpreadAttribute(target=esnext).types b/tests/baselines/reference/tsxEmitSpreadAttribute(target=esnext).types index 101c3fb75a0d8..7e5185ccb8d82 100644 --- a/tests/baselines/reference/tsxEmitSpreadAttribute(target=esnext).types +++ b/tests/baselines/reference/tsxEmitSpreadAttribute(target=esnext).types @@ -103,3 +103,95 @@ export function T6(a: any, b: any, c: any, d: any) { >div : any } +export function T7(a: any, b: any, c: any, d: any) { +>T7 : (a: any, b: any, c: any, d: any) => any +>a : any +>b : any +>c : any +>d : any + + return
T7
; +>
T7
: error +>div : any +>className : string +>"T7" : "T7" +>{ __proto__: null, dir: 'rtl' } : { __proto__: null; dir: string; } +>__proto__ : null +>dir : string +>'rtl' : "rtl" +>div : any +} + +export function T8(a: any, b: any, c: any, d: any) { +>T8 : (a: any, b: any, c: any, d: any) => any +>a : any +>b : any +>c : any +>d : any + + return
T8
; +>
T8
: error +>div : any +>className : string +>"T8" : "T8" +>{ "__proto__": null } : { __proto__: null; } +>"__proto__" : null +>div : any +} + +declare const __proto__: string; +>__proto__ : string + +export function T9(a: any, b: any, c: any, d: any) { +>T9 : (a: any, b: any, c: any, d: any) => any +>a : any +>b : any +>c : any +>d : any + + return
T9
; +>
T9
: error +>div : any +>className : string +>"T9" : "T9" +>{ [__proto__]: null } : { [x: string]: null; } +>[__proto__] : null +>__proto__ : string +>div : any +} + +export function T10(a: any, b: any, c: any, d: any) { +>T10 : (a: any, b: any, c: any, d: any) => any +>a : any +>b : any +>c : any +>d : any + + return
T10
; +>
T10
: error +>div : any +>className : string +>"T10" : "T10" +>{ ["__proto__"]: null } : { __proto__: null; } +>["__proto__"] : null +>"__proto__" : "__proto__" +>div : any +} + +export function T11(a: any, b: any, c: any, d: any) { +>T11 : (a: any, b: any, c: any, d: any) => any +>a : any +>b : any +>c : any +>d : any + + return
T11
; +>
T11
: error +>div : any +>className : string +>"T11" : "T11" +>{ __proto__ } : { __proto__: string; } +>__proto__ : string +>div : any +} + diff --git a/tests/baselines/reference/tsxReactEmitSpreadAttribute(target=es2015).js b/tests/baselines/reference/tsxReactEmitSpreadAttribute(target=es2015).js index 1e4fbe01c78ba..770b067a07461 100644 --- a/tests/baselines/reference/tsxReactEmitSpreadAttribute(target=es2015).js +++ b/tests/baselines/reference/tsxReactEmitSpreadAttribute(target=es2015).js @@ -28,6 +28,28 @@ export function T6(a: any, b: any, c: any, d: any) { export function T7(a: any, b: any, c: any, d: any) { return
T7
; } + +export function T8(a: any, b: any, c: any, d: any) { + return
T8
; +} + +export function T9(a: any, b: any, c: any, d: any) { + return
T9
; +} + +declare const __proto__: string; + +export function T10(a: any, b: any, c: any, d: any) { + return
T10
; +} + +export function T11(a: any, b: any, c: any, d: any) { + return
T11
; +} + +export function T12(a: any, b: any, c: any, d: any) { + return
T12
; +} //// [test.js] @@ -43,14 +65,29 @@ export function T3(a, b) { return _jsx("div", Object.assign({}, a, { className: "T3" }, b, { children: "T3" })); } export function T4(a, b) { - return _jsx("div", Object.assign({ className: "T4" }, Object.assign(Object.assign({}, a), b), { children: "T4" })); + return _jsx("div", Object.assign({ className: "T4" }, a, b, { children: "T4" })); } export function T5(a, b, c, d) { - return _jsx("div", Object.assign({ className: "T5" }, Object.assign(Object.assign(Object.assign({}, a), b), { c, d }), { children: "T5" })); + return _jsx("div", Object.assign({ className: "T5" }, a, b, { c, d }, { children: "T5" })); } export function T6(a, b, c, d) { - return _jsx("div", Object.assign({ className: "T6" }, Object.assign(Object.assign(Object.assign({}, a), b), Object.assign(Object.assign({}, c), d)), { children: "T6" })); + return _jsx("div", Object.assign({ className: "T6" }, a, b, Object.assign(Object.assign({}, c), d), { children: "T6" })); } export function T7(a, b, c, d) { return _jsx("div", { children: "T7" }); } +export function T8(a, b, c, d) { + return _jsx("div", Object.assign({ className: "T8" }, { __proto__: null, dir: 'rtl' }, { children: "T8" })); +} +export function T9(a, b, c, d) { + return _jsx("div", Object.assign({ className: "T9" }, { "__proto__": null }, { children: "T9" })); +} +export function T10(a, b, c, d) { + return _jsx("div", { className: "T10", [__proto__]: null, children: "T10" }); +} +export function T11(a, b, c, d) { + return _jsx("div", { className: "T11", ["__proto__"]: null, children: "T11" }); +} +export function T12(a, b, c, d) { + return _jsx("div", { className: "T12", __proto__, children: "T12" }); +} diff --git a/tests/baselines/reference/tsxReactEmitSpreadAttribute(target=es2015).symbols b/tests/baselines/reference/tsxReactEmitSpreadAttribute(target=es2015).symbols index 09b030724b8c6..76b5b61edb914 100644 --- a/tests/baselines/reference/tsxReactEmitSpreadAttribute(target=es2015).symbols +++ b/tests/baselines/reference/tsxReactEmitSpreadAttribute(target=es2015).symbols @@ -97,3 +97,79 @@ export function T7(a: any, b: any, c: any, d: any) { >div : Symbol(JSX.IntrinsicElements.div, Decl(react16.d.ts, 2546, 114)) } +export function T8(a: any, b: any, c: any, d: any) { +>T8 : Symbol(T8, Decl(test.tsx, 28, 1)) +>a : Symbol(a, Decl(test.tsx, 30, 19)) +>b : Symbol(b, Decl(test.tsx, 30, 26)) +>c : Symbol(c, Decl(test.tsx, 30, 34)) +>d : Symbol(d, Decl(test.tsx, 30, 42)) + + return
T8
; +>div : Symbol(JSX.IntrinsicElements.div, Decl(react16.d.ts, 2546, 114)) +>className : Symbol(className, Decl(test.tsx, 31, 15)) +>__proto__ : Symbol(__proto__, Decl(test.tsx, 31, 39)) +>dir : Symbol(dir, Decl(test.tsx, 31, 56)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react16.d.ts, 2546, 114)) +} + +export function T9(a: any, b: any, c: any, d: any) { +>T9 : Symbol(T9, Decl(test.tsx, 32, 1)) +>a : Symbol(a, Decl(test.tsx, 34, 19)) +>b : Symbol(b, Decl(test.tsx, 34, 26)) +>c : Symbol(c, Decl(test.tsx, 34, 34)) +>d : Symbol(d, Decl(test.tsx, 34, 42)) + + return
T9
; +>div : Symbol(JSX.IntrinsicElements.div, Decl(react16.d.ts, 2546, 114)) +>className : Symbol(className, Decl(test.tsx, 35, 15)) +>"__proto__" : Symbol("__proto__", Decl(test.tsx, 35, 39)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react16.d.ts, 2546, 114)) +} + +declare const __proto__: string; +>__proto__ : Symbol(__proto__, Decl(test.tsx, 38, 13)) + +export function T10(a: any, b: any, c: any, d: any) { +>T10 : Symbol(T10, Decl(test.tsx, 38, 32)) +>a : Symbol(a, Decl(test.tsx, 40, 20)) +>b : Symbol(b, Decl(test.tsx, 40, 27)) +>c : Symbol(c, Decl(test.tsx, 40, 35)) +>d : Symbol(d, Decl(test.tsx, 40, 43)) + + return
T10
; +>div : Symbol(JSX.IntrinsicElements.div, Decl(react16.d.ts, 2546, 114)) +>className : Symbol(className, Decl(test.tsx, 41, 15)) +>[__proto__] : Symbol([__proto__], Decl(test.tsx, 41, 40)) +>__proto__ : Symbol(__proto__, Decl(test.tsx, 38, 13)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react16.d.ts, 2546, 114)) +} + +export function T11(a: any, b: any, c: any, d: any) { +>T11 : Symbol(T11, Decl(test.tsx, 42, 1)) +>a : Symbol(a, Decl(test.tsx, 44, 20)) +>b : Symbol(b, Decl(test.tsx, 44, 27)) +>c : Symbol(c, Decl(test.tsx, 44, 35)) +>d : Symbol(d, Decl(test.tsx, 44, 43)) + + return
T11
; +>div : Symbol(JSX.IntrinsicElements.div, Decl(react16.d.ts, 2546, 114)) +>className : Symbol(className, Decl(test.tsx, 45, 15)) +>["__proto__"] : Symbol(["__proto__"], Decl(test.tsx, 45, 40)) +>"__proto__" : Symbol(["__proto__"], Decl(test.tsx, 45, 40)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react16.d.ts, 2546, 114)) +} + +export function T12(a: any, b: any, c: any, d: any) { +>T12 : Symbol(T12, Decl(test.tsx, 46, 1)) +>a : Symbol(a, Decl(test.tsx, 48, 20)) +>b : Symbol(b, Decl(test.tsx, 48, 27)) +>c : Symbol(c, Decl(test.tsx, 48, 35)) +>d : Symbol(d, Decl(test.tsx, 48, 43)) + + return
T12
; +>div : Symbol(JSX.IntrinsicElements.div, Decl(react16.d.ts, 2546, 114)) +>className : Symbol(className, Decl(test.tsx, 49, 15)) +>__proto__ : Symbol(__proto__, Decl(test.tsx, 49, 40)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react16.d.ts, 2546, 114)) +} + diff --git a/tests/baselines/reference/tsxReactEmitSpreadAttribute(target=es2015).types b/tests/baselines/reference/tsxReactEmitSpreadAttribute(target=es2015).types index 7fc232939b09b..d8fb30375757c 100644 --- a/tests/baselines/reference/tsxReactEmitSpreadAttribute(target=es2015).types +++ b/tests/baselines/reference/tsxReactEmitSpreadAttribute(target=es2015).types @@ -115,3 +115,95 @@ export function T7(a: any, b: any, c: any, d: any) { >div : any } +export function T8(a: any, b: any, c: any, d: any) { +>T8 : (a: any, b: any, c: any, d: any) => JSX.Element +>a : any +>b : any +>c : any +>d : any + + return
T8
; +>
T8
: JSX.Element +>div : any +>className : string +>"T8" : "T8" +>{ __proto__: null, dir: 'rtl' } : { __proto__: null; dir: string; } +>__proto__ : null +>dir : string +>'rtl' : "rtl" +>div : any +} + +export function T9(a: any, b: any, c: any, d: any) { +>T9 : (a: any, b: any, c: any, d: any) => JSX.Element +>a : any +>b : any +>c : any +>d : any + + return
T9
; +>
T9
: JSX.Element +>div : any +>className : string +>"T9" : "T9" +>{ "__proto__": null } : { __proto__: null; } +>"__proto__" : null +>div : any +} + +declare const __proto__: string; +>__proto__ : string + +export function T10(a: any, b: any, c: any, d: any) { +>T10 : (a: any, b: any, c: any, d: any) => JSX.Element +>a : any +>b : any +>c : any +>d : any + + return
T10
; +>
T10
: JSX.Element +>div : any +>className : string +>"T10" : "T10" +>{ [__proto__]: null } : { [x: string]: null; } +>[__proto__] : null +>__proto__ : string +>div : any +} + +export function T11(a: any, b: any, c: any, d: any) { +>T11 : (a: any, b: any, c: any, d: any) => JSX.Element +>a : any +>b : any +>c : any +>d : any + + return
T11
; +>
T11
: JSX.Element +>div : any +>className : string +>"T11" : "T11" +>{ ["__proto__"]: null } : { __proto__: null; } +>["__proto__"] : null +>"__proto__" : "__proto__" +>div : any +} + +export function T12(a: any, b: any, c: any, d: any) { +>T12 : (a: any, b: any, c: any, d: any) => JSX.Element +>a : any +>b : any +>c : any +>d : any + + return
T12
; +>
T12
: JSX.Element +>div : any +>className : string +>"T12" : "T12" +>{ __proto__ } : { __proto__: string; } +>__proto__ : string +>div : any +} + diff --git a/tests/baselines/reference/tsxReactEmitSpreadAttribute(target=es2018).js b/tests/baselines/reference/tsxReactEmitSpreadAttribute(target=es2018).js index 0aa58a3f27284..2000d1a297356 100644 --- a/tests/baselines/reference/tsxReactEmitSpreadAttribute(target=es2018).js +++ b/tests/baselines/reference/tsxReactEmitSpreadAttribute(target=es2018).js @@ -28,6 +28,28 @@ export function T6(a: any, b: any, c: any, d: any) { export function T7(a: any, b: any, c: any, d: any) { return
T7
; } + +export function T8(a: any, b: any, c: any, d: any) { + return
T8
; +} + +export function T9(a: any, b: any, c: any, d: any) { + return
T9
; +} + +declare const __proto__: string; + +export function T10(a: any, b: any, c: any, d: any) { + return
T10
; +} + +export function T11(a: any, b: any, c: any, d: any) { + return
T11
; +} + +export function T12(a: any, b: any, c: any, d: any) { + return
T12
; +} //// [test.js] @@ -43,14 +65,29 @@ export function T3(a, b) { return _jsx("div", { ...a, className: "T3", ...b, children: "T3" }); } export function T4(a, b) { - return _jsx("div", { className: "T4", ...{ ...a, ...b }, children: "T4" }); + return _jsx("div", { className: "T4", ...a, ...b, children: "T4" }); } export function T5(a, b, c, d) { - return _jsx("div", { className: "T5", ...{ ...a, ...b, ...{ c, d } }, children: "T5" }); + return _jsx("div", { className: "T5", ...a, ...b, ...{ c, d }, children: "T5" }); } export function T6(a, b, c, d) { - return _jsx("div", { className: "T6", ...{ ...a, ...b, ...{ ...c, ...d } }, children: "T6" }); + return _jsx("div", { className: "T6", ...a, ...b, ...{ ...c, ...d }, children: "T6" }); } export function T7(a, b, c, d) { return _jsx("div", { children: "T7" }); } +export function T8(a, b, c, d) { + return _jsx("div", { className: "T8", ...{ __proto__: null, dir: 'rtl' }, children: "T8" }); +} +export function T9(a, b, c, d) { + return _jsx("div", { className: "T9", ...{ "__proto__": null }, children: "T9" }); +} +export function T10(a, b, c, d) { + return _jsx("div", { className: "T10", [__proto__]: null, children: "T10" }); +} +export function T11(a, b, c, d) { + return _jsx("div", { className: "T11", ["__proto__"]: null, children: "T11" }); +} +export function T12(a, b, c, d) { + return _jsx("div", { className: "T12", __proto__, children: "T12" }); +} diff --git a/tests/baselines/reference/tsxReactEmitSpreadAttribute(target=es2018).symbols b/tests/baselines/reference/tsxReactEmitSpreadAttribute(target=es2018).symbols index 09b030724b8c6..76b5b61edb914 100644 --- a/tests/baselines/reference/tsxReactEmitSpreadAttribute(target=es2018).symbols +++ b/tests/baselines/reference/tsxReactEmitSpreadAttribute(target=es2018).symbols @@ -97,3 +97,79 @@ export function T7(a: any, b: any, c: any, d: any) { >div : Symbol(JSX.IntrinsicElements.div, Decl(react16.d.ts, 2546, 114)) } +export function T8(a: any, b: any, c: any, d: any) { +>T8 : Symbol(T8, Decl(test.tsx, 28, 1)) +>a : Symbol(a, Decl(test.tsx, 30, 19)) +>b : Symbol(b, Decl(test.tsx, 30, 26)) +>c : Symbol(c, Decl(test.tsx, 30, 34)) +>d : Symbol(d, Decl(test.tsx, 30, 42)) + + return
T8
; +>div : Symbol(JSX.IntrinsicElements.div, Decl(react16.d.ts, 2546, 114)) +>className : Symbol(className, Decl(test.tsx, 31, 15)) +>__proto__ : Symbol(__proto__, Decl(test.tsx, 31, 39)) +>dir : Symbol(dir, Decl(test.tsx, 31, 56)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react16.d.ts, 2546, 114)) +} + +export function T9(a: any, b: any, c: any, d: any) { +>T9 : Symbol(T9, Decl(test.tsx, 32, 1)) +>a : Symbol(a, Decl(test.tsx, 34, 19)) +>b : Symbol(b, Decl(test.tsx, 34, 26)) +>c : Symbol(c, Decl(test.tsx, 34, 34)) +>d : Symbol(d, Decl(test.tsx, 34, 42)) + + return
T9
; +>div : Symbol(JSX.IntrinsicElements.div, Decl(react16.d.ts, 2546, 114)) +>className : Symbol(className, Decl(test.tsx, 35, 15)) +>"__proto__" : Symbol("__proto__", Decl(test.tsx, 35, 39)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react16.d.ts, 2546, 114)) +} + +declare const __proto__: string; +>__proto__ : Symbol(__proto__, Decl(test.tsx, 38, 13)) + +export function T10(a: any, b: any, c: any, d: any) { +>T10 : Symbol(T10, Decl(test.tsx, 38, 32)) +>a : Symbol(a, Decl(test.tsx, 40, 20)) +>b : Symbol(b, Decl(test.tsx, 40, 27)) +>c : Symbol(c, Decl(test.tsx, 40, 35)) +>d : Symbol(d, Decl(test.tsx, 40, 43)) + + return
T10
; +>div : Symbol(JSX.IntrinsicElements.div, Decl(react16.d.ts, 2546, 114)) +>className : Symbol(className, Decl(test.tsx, 41, 15)) +>[__proto__] : Symbol([__proto__], Decl(test.tsx, 41, 40)) +>__proto__ : Symbol(__proto__, Decl(test.tsx, 38, 13)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react16.d.ts, 2546, 114)) +} + +export function T11(a: any, b: any, c: any, d: any) { +>T11 : Symbol(T11, Decl(test.tsx, 42, 1)) +>a : Symbol(a, Decl(test.tsx, 44, 20)) +>b : Symbol(b, Decl(test.tsx, 44, 27)) +>c : Symbol(c, Decl(test.tsx, 44, 35)) +>d : Symbol(d, Decl(test.tsx, 44, 43)) + + return
T11
; +>div : Symbol(JSX.IntrinsicElements.div, Decl(react16.d.ts, 2546, 114)) +>className : Symbol(className, Decl(test.tsx, 45, 15)) +>["__proto__"] : Symbol(["__proto__"], Decl(test.tsx, 45, 40)) +>"__proto__" : Symbol(["__proto__"], Decl(test.tsx, 45, 40)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react16.d.ts, 2546, 114)) +} + +export function T12(a: any, b: any, c: any, d: any) { +>T12 : Symbol(T12, Decl(test.tsx, 46, 1)) +>a : Symbol(a, Decl(test.tsx, 48, 20)) +>b : Symbol(b, Decl(test.tsx, 48, 27)) +>c : Symbol(c, Decl(test.tsx, 48, 35)) +>d : Symbol(d, Decl(test.tsx, 48, 43)) + + return
T12
; +>div : Symbol(JSX.IntrinsicElements.div, Decl(react16.d.ts, 2546, 114)) +>className : Symbol(className, Decl(test.tsx, 49, 15)) +>__proto__ : Symbol(__proto__, Decl(test.tsx, 49, 40)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react16.d.ts, 2546, 114)) +} + diff --git a/tests/baselines/reference/tsxReactEmitSpreadAttribute(target=es2018).types b/tests/baselines/reference/tsxReactEmitSpreadAttribute(target=es2018).types index 7fc232939b09b..d8fb30375757c 100644 --- a/tests/baselines/reference/tsxReactEmitSpreadAttribute(target=es2018).types +++ b/tests/baselines/reference/tsxReactEmitSpreadAttribute(target=es2018).types @@ -115,3 +115,95 @@ export function T7(a: any, b: any, c: any, d: any) { >div : any } +export function T8(a: any, b: any, c: any, d: any) { +>T8 : (a: any, b: any, c: any, d: any) => JSX.Element +>a : any +>b : any +>c : any +>d : any + + return
T8
; +>
T8
: JSX.Element +>div : any +>className : string +>"T8" : "T8" +>{ __proto__: null, dir: 'rtl' } : { __proto__: null; dir: string; } +>__proto__ : null +>dir : string +>'rtl' : "rtl" +>div : any +} + +export function T9(a: any, b: any, c: any, d: any) { +>T9 : (a: any, b: any, c: any, d: any) => JSX.Element +>a : any +>b : any +>c : any +>d : any + + return
T9
; +>
T9
: JSX.Element +>div : any +>className : string +>"T9" : "T9" +>{ "__proto__": null } : { __proto__: null; } +>"__proto__" : null +>div : any +} + +declare const __proto__: string; +>__proto__ : string + +export function T10(a: any, b: any, c: any, d: any) { +>T10 : (a: any, b: any, c: any, d: any) => JSX.Element +>a : any +>b : any +>c : any +>d : any + + return
T10
; +>
T10
: JSX.Element +>div : any +>className : string +>"T10" : "T10" +>{ [__proto__]: null } : { [x: string]: null; } +>[__proto__] : null +>__proto__ : string +>div : any +} + +export function T11(a: any, b: any, c: any, d: any) { +>T11 : (a: any, b: any, c: any, d: any) => JSX.Element +>a : any +>b : any +>c : any +>d : any + + return
T11
; +>
T11
: JSX.Element +>div : any +>className : string +>"T11" : "T11" +>{ ["__proto__"]: null } : { __proto__: null; } +>["__proto__"] : null +>"__proto__" : "__proto__" +>div : any +} + +export function T12(a: any, b: any, c: any, d: any) { +>T12 : (a: any, b: any, c: any, d: any) => JSX.Element +>a : any +>b : any +>c : any +>d : any + + return
T12
; +>
T12
: JSX.Element +>div : any +>className : string +>"T12" : "T12" +>{ __proto__ } : { __proto__: string; } +>__proto__ : string +>div : any +} + diff --git a/tests/baselines/reference/tsxReactEmitSpreadAttribute(target=esnext).js b/tests/baselines/reference/tsxReactEmitSpreadAttribute(target=esnext).js index 0aa58a3f27284..2000d1a297356 100644 --- a/tests/baselines/reference/tsxReactEmitSpreadAttribute(target=esnext).js +++ b/tests/baselines/reference/tsxReactEmitSpreadAttribute(target=esnext).js @@ -28,6 +28,28 @@ export function T6(a: any, b: any, c: any, d: any) { export function T7(a: any, b: any, c: any, d: any) { return
T7
; } + +export function T8(a: any, b: any, c: any, d: any) { + return
T8
; +} + +export function T9(a: any, b: any, c: any, d: any) { + return
T9
; +} + +declare const __proto__: string; + +export function T10(a: any, b: any, c: any, d: any) { + return
T10
; +} + +export function T11(a: any, b: any, c: any, d: any) { + return
T11
; +} + +export function T12(a: any, b: any, c: any, d: any) { + return
T12
; +} //// [test.js] @@ -43,14 +65,29 @@ export function T3(a, b) { return _jsx("div", { ...a, className: "T3", ...b, children: "T3" }); } export function T4(a, b) { - return _jsx("div", { className: "T4", ...{ ...a, ...b }, children: "T4" }); + return _jsx("div", { className: "T4", ...a, ...b, children: "T4" }); } export function T5(a, b, c, d) { - return _jsx("div", { className: "T5", ...{ ...a, ...b, ...{ c, d } }, children: "T5" }); + return _jsx("div", { className: "T5", ...a, ...b, ...{ c, d }, children: "T5" }); } export function T6(a, b, c, d) { - return _jsx("div", { className: "T6", ...{ ...a, ...b, ...{ ...c, ...d } }, children: "T6" }); + return _jsx("div", { className: "T6", ...a, ...b, ...{ ...c, ...d }, children: "T6" }); } export function T7(a, b, c, d) { return _jsx("div", { children: "T7" }); } +export function T8(a, b, c, d) { + return _jsx("div", { className: "T8", ...{ __proto__: null, dir: 'rtl' }, children: "T8" }); +} +export function T9(a, b, c, d) { + return _jsx("div", { className: "T9", ...{ "__proto__": null }, children: "T9" }); +} +export function T10(a, b, c, d) { + return _jsx("div", { className: "T10", [__proto__]: null, children: "T10" }); +} +export function T11(a, b, c, d) { + return _jsx("div", { className: "T11", ["__proto__"]: null, children: "T11" }); +} +export function T12(a, b, c, d) { + return _jsx("div", { className: "T12", __proto__, children: "T12" }); +} diff --git a/tests/baselines/reference/tsxReactEmitSpreadAttribute(target=esnext).symbols b/tests/baselines/reference/tsxReactEmitSpreadAttribute(target=esnext).symbols index 09b030724b8c6..76b5b61edb914 100644 --- a/tests/baselines/reference/tsxReactEmitSpreadAttribute(target=esnext).symbols +++ b/tests/baselines/reference/tsxReactEmitSpreadAttribute(target=esnext).symbols @@ -97,3 +97,79 @@ export function T7(a: any, b: any, c: any, d: any) { >div : Symbol(JSX.IntrinsicElements.div, Decl(react16.d.ts, 2546, 114)) } +export function T8(a: any, b: any, c: any, d: any) { +>T8 : Symbol(T8, Decl(test.tsx, 28, 1)) +>a : Symbol(a, Decl(test.tsx, 30, 19)) +>b : Symbol(b, Decl(test.tsx, 30, 26)) +>c : Symbol(c, Decl(test.tsx, 30, 34)) +>d : Symbol(d, Decl(test.tsx, 30, 42)) + + return
T8
; +>div : Symbol(JSX.IntrinsicElements.div, Decl(react16.d.ts, 2546, 114)) +>className : Symbol(className, Decl(test.tsx, 31, 15)) +>__proto__ : Symbol(__proto__, Decl(test.tsx, 31, 39)) +>dir : Symbol(dir, Decl(test.tsx, 31, 56)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react16.d.ts, 2546, 114)) +} + +export function T9(a: any, b: any, c: any, d: any) { +>T9 : Symbol(T9, Decl(test.tsx, 32, 1)) +>a : Symbol(a, Decl(test.tsx, 34, 19)) +>b : Symbol(b, Decl(test.tsx, 34, 26)) +>c : Symbol(c, Decl(test.tsx, 34, 34)) +>d : Symbol(d, Decl(test.tsx, 34, 42)) + + return
T9
; +>div : Symbol(JSX.IntrinsicElements.div, Decl(react16.d.ts, 2546, 114)) +>className : Symbol(className, Decl(test.tsx, 35, 15)) +>"__proto__" : Symbol("__proto__", Decl(test.tsx, 35, 39)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react16.d.ts, 2546, 114)) +} + +declare const __proto__: string; +>__proto__ : Symbol(__proto__, Decl(test.tsx, 38, 13)) + +export function T10(a: any, b: any, c: any, d: any) { +>T10 : Symbol(T10, Decl(test.tsx, 38, 32)) +>a : Symbol(a, Decl(test.tsx, 40, 20)) +>b : Symbol(b, Decl(test.tsx, 40, 27)) +>c : Symbol(c, Decl(test.tsx, 40, 35)) +>d : Symbol(d, Decl(test.tsx, 40, 43)) + + return
T10
; +>div : Symbol(JSX.IntrinsicElements.div, Decl(react16.d.ts, 2546, 114)) +>className : Symbol(className, Decl(test.tsx, 41, 15)) +>[__proto__] : Symbol([__proto__], Decl(test.tsx, 41, 40)) +>__proto__ : Symbol(__proto__, Decl(test.tsx, 38, 13)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react16.d.ts, 2546, 114)) +} + +export function T11(a: any, b: any, c: any, d: any) { +>T11 : Symbol(T11, Decl(test.tsx, 42, 1)) +>a : Symbol(a, Decl(test.tsx, 44, 20)) +>b : Symbol(b, Decl(test.tsx, 44, 27)) +>c : Symbol(c, Decl(test.tsx, 44, 35)) +>d : Symbol(d, Decl(test.tsx, 44, 43)) + + return
T11
; +>div : Symbol(JSX.IntrinsicElements.div, Decl(react16.d.ts, 2546, 114)) +>className : Symbol(className, Decl(test.tsx, 45, 15)) +>["__proto__"] : Symbol(["__proto__"], Decl(test.tsx, 45, 40)) +>"__proto__" : Symbol(["__proto__"], Decl(test.tsx, 45, 40)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react16.d.ts, 2546, 114)) +} + +export function T12(a: any, b: any, c: any, d: any) { +>T12 : Symbol(T12, Decl(test.tsx, 46, 1)) +>a : Symbol(a, Decl(test.tsx, 48, 20)) +>b : Symbol(b, Decl(test.tsx, 48, 27)) +>c : Symbol(c, Decl(test.tsx, 48, 35)) +>d : Symbol(d, Decl(test.tsx, 48, 43)) + + return
T12
; +>div : Symbol(JSX.IntrinsicElements.div, Decl(react16.d.ts, 2546, 114)) +>className : Symbol(className, Decl(test.tsx, 49, 15)) +>__proto__ : Symbol(__proto__, Decl(test.tsx, 49, 40)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react16.d.ts, 2546, 114)) +} + diff --git a/tests/baselines/reference/tsxReactEmitSpreadAttribute(target=esnext).types b/tests/baselines/reference/tsxReactEmitSpreadAttribute(target=esnext).types index 7fc232939b09b..d8fb30375757c 100644 --- a/tests/baselines/reference/tsxReactEmitSpreadAttribute(target=esnext).types +++ b/tests/baselines/reference/tsxReactEmitSpreadAttribute(target=esnext).types @@ -115,3 +115,95 @@ export function T7(a: any, b: any, c: any, d: any) { >div : any } +export function T8(a: any, b: any, c: any, d: any) { +>T8 : (a: any, b: any, c: any, d: any) => JSX.Element +>a : any +>b : any +>c : any +>d : any + + return
T8
; +>
T8
: JSX.Element +>div : any +>className : string +>"T8" : "T8" +>{ __proto__: null, dir: 'rtl' } : { __proto__: null; dir: string; } +>__proto__ : null +>dir : string +>'rtl' : "rtl" +>div : any +} + +export function T9(a: any, b: any, c: any, d: any) { +>T9 : (a: any, b: any, c: any, d: any) => JSX.Element +>a : any +>b : any +>c : any +>d : any + + return
T9
; +>
T9
: JSX.Element +>div : any +>className : string +>"T9" : "T9" +>{ "__proto__": null } : { __proto__: null; } +>"__proto__" : null +>div : any +} + +declare const __proto__: string; +>__proto__ : string + +export function T10(a: any, b: any, c: any, d: any) { +>T10 : (a: any, b: any, c: any, d: any) => JSX.Element +>a : any +>b : any +>c : any +>d : any + + return
T10
; +>
T10
: JSX.Element +>div : any +>className : string +>"T10" : "T10" +>{ [__proto__]: null } : { [x: string]: null; } +>[__proto__] : null +>__proto__ : string +>div : any +} + +export function T11(a: any, b: any, c: any, d: any) { +>T11 : (a: any, b: any, c: any, d: any) => JSX.Element +>a : any +>b : any +>c : any +>d : any + + return
T11
; +>
T11
: JSX.Element +>div : any +>className : string +>"T11" : "T11" +>{ ["__proto__"]: null } : { __proto__: null; } +>["__proto__"] : null +>"__proto__" : "__proto__" +>div : any +} + +export function T12(a: any, b: any, c: any, d: any) { +>T12 : (a: any, b: any, c: any, d: any) => JSX.Element +>a : any +>b : any +>c : any +>d : any + + return
T12
; +>
T12
: JSX.Element +>div : any +>className : string +>"T12" : "T12" +>{ __proto__ } : { __proto__: string; } +>__proto__ : string +>div : any +} + diff --git a/tests/cases/conformance/jsx/tsxEmitSpreadAttribute.ts b/tests/cases/conformance/jsx/tsxEmitSpreadAttribute.ts index 4ddebfcb12173..1c5103442a6bb 100644 --- a/tests/cases/conformance/jsx/tsxEmitSpreadAttribute.ts +++ b/tests/cases/conformance/jsx/tsxEmitSpreadAttribute.ts @@ -27,3 +27,25 @@ export function T5(a: any, b: any, c: any, d: any) { export function T6(a: any, b: any, c: any, d: any) { return
T6
; } + +export function T7(a: any, b: any, c: any, d: any) { + return
T7
; +} + +export function T8(a: any, b: any, c: any, d: any) { + return
T8
; +} + +declare const __proto__: string; + +export function T9(a: any, b: any, c: any, d: any) { + return
T9
; +} + +export function T10(a: any, b: any, c: any, d: any) { + return
T10
; +} + +export function T11(a: any, b: any, c: any, d: any) { + return
T11
; +} diff --git a/tests/cases/conformance/jsx/tsxReactEmitSpreadAttribute.ts b/tests/cases/conformance/jsx/tsxReactEmitSpreadAttribute.ts index 2ddc20ae39f2b..87973e4784837 100644 --- a/tests/cases/conformance/jsx/tsxReactEmitSpreadAttribute.ts +++ b/tests/cases/conformance/jsx/tsxReactEmitSpreadAttribute.ts @@ -30,3 +30,25 @@ export function T6(a: any, b: any, c: any, d: any) { export function T7(a: any, b: any, c: any, d: any) { return
T7
; } + +export function T8(a: any, b: any, c: any, d: any) { + return
T8
; +} + +export function T9(a: any, b: any, c: any, d: any) { + return
T9
; +} + +declare const __proto__: string; + +export function T10(a: any, b: any, c: any, d: any) { + return
T10
; +} + +export function T11(a: any, b: any, c: any, d: any) { + return
T11
; +} + +export function T12(a: any, b: any, c: any, d: any) { + return
T12
; +}