feat(typescript): support generic JSX element (#4268)
* feat(typescript): support generic JSX element * fix(playground): `buffer is not defined` in `--parser typescript` * chore(deps): update typescript-eslint-parsermaster
parent
643e2a83d6
commit
6a17474e37
|
@ -1845,7 +1845,12 @@ function printPathNoParens(path, options, print, args) {
|
||||||
|
|
||||||
// Don't break self-closing elements with no attributes and no comments
|
// Don't break self-closing elements with no attributes and no comments
|
||||||
if (n.selfClosing && !n.attributes.length && !nameHasComments) {
|
if (n.selfClosing && !n.attributes.length && !nameHasComments) {
|
||||||
return concat(["<", path.call(print, "name"), " />"]);
|
return concat([
|
||||||
|
"<",
|
||||||
|
path.call(print, "name"),
|
||||||
|
path.call(print, "typeParameters"),
|
||||||
|
" />"
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// don't break up opening elements with a single long text attribute
|
// don't break up opening elements with a single long text attribute
|
||||||
|
@ -1871,6 +1876,7 @@ function printPathNoParens(path, options, print, args) {
|
||||||
concat([
|
concat([
|
||||||
"<",
|
"<",
|
||||||
path.call(print, "name"),
|
path.call(print, "name"),
|
||||||
|
path.call(print, "typeParameters"),
|
||||||
" ",
|
" ",
|
||||||
concat(path.map(print, "attributes")),
|
concat(path.map(print, "attributes")),
|
||||||
n.selfClosing ? " />" : ">"
|
n.selfClosing ? " />" : ">"
|
||||||
|
@ -1909,6 +1915,7 @@ function printPathNoParens(path, options, print, args) {
|
||||||
concat([
|
concat([
|
||||||
"<",
|
"<",
|
||||||
path.call(print, "name"),
|
path.call(print, "name"),
|
||||||
|
path.call(print, "typeParameters"),
|
||||||
concat([
|
concat([
|
||||||
indent(
|
indent(
|
||||||
concat(
|
concat(
|
||||||
|
|
|
@ -1,5 +1,20 @@
|
||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
|
exports[`generic-component.tsx 1`] = `
|
||||||
|
const c1 = <MyComponent<number> data={12} />
|
||||||
|
|
||||||
|
const c2 = <MyComponent<number> />
|
||||||
|
|
||||||
|
const c3 = <MyComponent<number> attr="value" />
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
const c1 = <MyComponent<number> data={12} />;
|
||||||
|
|
||||||
|
const c2 = <MyComponent<number> />;
|
||||||
|
|
||||||
|
const c3 = <MyComponent<number> attr="value" />;
|
||||||
|
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`keyword.tsx 1`] = `
|
exports[`keyword.tsx 1`] = `
|
||||||
<try />;
|
<try />;
|
||||||
<object />
|
<object />
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
const c1 = <MyComponent<number> data={12} />
|
||||||
|
|
||||||
|
const c2 = <MyComponent<number> />
|
||||||
|
|
||||||
|
const c3 = <MyComponent<number> attr="value" />
|
Loading…
Reference in New Issue