-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't create children prop out of non-semantic JSX children (#55981)
- Loading branch information
Showing
6 changed files
with
144 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
tests/baselines/reference/jsxContainsOnlyTriviaWhiteSpacesNotCountedAsChild.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
//// [tests/cases/compiler/jsxContainsOnlyTriviaWhiteSpacesNotCountedAsChild.tsx] //// | ||
|
||
//// [jsxContainsOnlyTriviaWhiteSpacesNotCountedAsChild.tsx] | ||
namespace JSX { | ||
export interface ElementChildrenAttribute { | ||
children: {}; | ||
} | ||
} | ||
|
||
interface Props { | ||
className?: string | undefined; | ||
} | ||
|
||
function NoticeList(props: Props) { | ||
return null; | ||
} | ||
|
||
<NoticeList className="my-notice-list"> | ||
</NoticeList>; | ||
|
||
<NoticeList className="my-notice-list"> | ||
|
||
</NoticeList>; | ||
|
||
//// [jsxContainsOnlyTriviaWhiteSpacesNotCountedAsChild.jsx] | ||
"use strict"; | ||
function NoticeList(props) { | ||
return null; | ||
} | ||
<NoticeList className="my-notice-list"> | ||
</NoticeList>; | ||
<NoticeList className="my-notice-list"> | ||
|
||
</NoticeList>; |
43 changes: 43 additions & 0 deletions
43
tests/baselines/reference/jsxContainsOnlyTriviaWhiteSpacesNotCountedAsChild.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
//// [tests/cases/compiler/jsxContainsOnlyTriviaWhiteSpacesNotCountedAsChild.tsx] //// | ||
|
||
=== jsxContainsOnlyTriviaWhiteSpacesNotCountedAsChild.tsx === | ||
namespace JSX { | ||
>JSX : Symbol(JSX, Decl(jsxContainsOnlyTriviaWhiteSpacesNotCountedAsChild.tsx, 0, 0)) | ||
|
||
export interface ElementChildrenAttribute { | ||
>ElementChildrenAttribute : Symbol(ElementChildrenAttribute, Decl(jsxContainsOnlyTriviaWhiteSpacesNotCountedAsChild.tsx, 0, 15)) | ||
|
||
children: {}; | ||
>children : Symbol(ElementChildrenAttribute.children, Decl(jsxContainsOnlyTriviaWhiteSpacesNotCountedAsChild.tsx, 1, 45)) | ||
} | ||
} | ||
|
||
interface Props { | ||
>Props : Symbol(Props, Decl(jsxContainsOnlyTriviaWhiteSpacesNotCountedAsChild.tsx, 4, 1)) | ||
|
||
className?: string | undefined; | ||
>className : Symbol(Props.className, Decl(jsxContainsOnlyTriviaWhiteSpacesNotCountedAsChild.tsx, 6, 17)) | ||
} | ||
|
||
function NoticeList(props: Props) { | ||
>NoticeList : Symbol(NoticeList, Decl(jsxContainsOnlyTriviaWhiteSpacesNotCountedAsChild.tsx, 8, 1)) | ||
>props : Symbol(props, Decl(jsxContainsOnlyTriviaWhiteSpacesNotCountedAsChild.tsx, 10, 20)) | ||
>Props : Symbol(Props, Decl(jsxContainsOnlyTriviaWhiteSpacesNotCountedAsChild.tsx, 4, 1)) | ||
|
||
return null; | ||
} | ||
|
||
<NoticeList className="my-notice-list"> | ||
>NoticeList : Symbol(NoticeList, Decl(jsxContainsOnlyTriviaWhiteSpacesNotCountedAsChild.tsx, 8, 1)) | ||
>className : Symbol(className, Decl(jsxContainsOnlyTriviaWhiteSpacesNotCountedAsChild.tsx, 14, 11)) | ||
|
||
</NoticeList>; | ||
>NoticeList : Symbol(NoticeList, Decl(jsxContainsOnlyTriviaWhiteSpacesNotCountedAsChild.tsx, 8, 1)) | ||
|
||
<NoticeList className="my-notice-list"> | ||
>NoticeList : Symbol(NoticeList, Decl(jsxContainsOnlyTriviaWhiteSpacesNotCountedAsChild.tsx, 8, 1)) | ||
>className : Symbol(className, Decl(jsxContainsOnlyTriviaWhiteSpacesNotCountedAsChild.tsx, 17, 11)) | ||
|
||
</NoticeList>; | ||
>NoticeList : Symbol(NoticeList, Decl(jsxContainsOnlyTriviaWhiteSpacesNotCountedAsChild.tsx, 8, 1)) | ||
|
38 changes: 38 additions & 0 deletions
38
tests/baselines/reference/jsxContainsOnlyTriviaWhiteSpacesNotCountedAsChild.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
//// [tests/cases/compiler/jsxContainsOnlyTriviaWhiteSpacesNotCountedAsChild.tsx] //// | ||
|
||
=== jsxContainsOnlyTriviaWhiteSpacesNotCountedAsChild.tsx === | ||
namespace JSX { | ||
export interface ElementChildrenAttribute { | ||
children: {}; | ||
>children : {} | ||
} | ||
} | ||
|
||
interface Props { | ||
className?: string | undefined; | ||
>className : string | undefined | ||
} | ||
|
||
function NoticeList(props: Props) { | ||
>NoticeList : (props: Props) => null | ||
>props : Props | ||
|
||
return null; | ||
} | ||
|
||
<NoticeList className="my-notice-list"> | ||
><NoticeList className="my-notice-list"></NoticeList> : error | ||
>NoticeList : (props: Props) => null | ||
>className : string | ||
|
||
</NoticeList>; | ||
>NoticeList : (props: Props) => null | ||
|
||
<NoticeList className="my-notice-list"> | ||
><NoticeList className="my-notice-list"></NoticeList> : error | ||
>NoticeList : (props: Props) => null | ||
>className : string | ||
|
||
</NoticeList>; | ||
>NoticeList : (props: Props) => null | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
tests/cases/compiler/jsxContainsOnlyTriviaWhiteSpacesNotCountedAsChild.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// @jsx: preserve | ||
// @strict: true | ||
|
||
namespace JSX { | ||
export interface ElementChildrenAttribute { | ||
children: {}; | ||
} | ||
} | ||
|
||
interface Props { | ||
className?: string | undefined; | ||
} | ||
|
||
function NoticeList(props: Props) { | ||
return null; | ||
} | ||
|
||
<NoticeList className="my-notice-list"> | ||
</NoticeList>; | ||
|
||
<NoticeList className="my-notice-list"> | ||
|
||
</NoticeList>; |