Skip to content

Commit 6dec0f5

Browse files
author
Kanchalai Tanglertsampan
committed
Add language service test when element type is a union type
1 parent d0dcee0 commit 6dec0f5

5 files changed

+122
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
//@Filename: file.tsx
4+
// @jsx: preserve
5+
// @noLib: true
6+
7+
//// declare module JSX {
8+
//// interface Element { }
9+
//// interface IntrinsicElements {
10+
//// }
11+
//// interface ElementAttributesProperty { props; }
12+
//// }
13+
//// function SFC1(prop: { x: number }) {
14+
//// return <div>hello </div>;
15+
//// };
16+
//// function SFC2(prop: { x: boolean }) {
17+
//// return <h1>World </h1>;
18+
//// }
19+
//// var SFCComp = SFC1 || SFC2;
20+
//// <SFCComp /**/ />
21+
22+
goTo.marker();
23+
verify.completionListContains("x", "(property) x: number | boolean");
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
//@Filename: file.tsx
4+
// @jsx: preserve
5+
// @noLib: true
6+
7+
//// declare module JSX {
8+
//// interface Element { }
9+
//// interface IntrinsicElements {
10+
//// }
11+
//// interface ElementAttributesProperty { props; }
12+
//// }
13+
//// function SFC1(prop: { x: number }) {
14+
//// return <div>hello </div>;
15+
//// };
16+
17+
//// function SFC2(prop: { x: boolean }) {
18+
//// return <h1>World </h1>;
19+
//// }
20+
21+
//// var [|SFCComp|] = SFC1 || SFC2;
22+
//// <[|SFCComp|] x={ "hi" } />
23+
24+
verify.rangesReferenceEachOther();
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
//@Filename: file.tsx
4+
// @jsx: preserve
5+
// @noLib: true
6+
7+
//// class RC1 extends React.Component<{}, {}> {
8+
//// render() {
9+
//// return null;
10+
//// }
11+
//// }
12+
13+
//// class RC2 extends React.Component<{}, {}> {
14+
//// render() {
15+
//// return null;
16+
//// }
17+
//// private method() { }
18+
//// }
19+
20+
//// var [|RCComp|] = RC1 || RC2;
21+
//// <[|RCComp|] />
22+
23+
verify.rangesReferenceEachOther();
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
//@Filename: file.tsx
4+
// @jsx: preserve
5+
// @noLib: true
6+
7+
//// declare module JSX {
8+
//// interface Element { }
9+
//// interface IntrinsicElements {
10+
//// }
11+
//// interface ElementAttributesProperty { props; }
12+
//// }
13+
//// function /*pt1*/SFC1(prop: { x: number }) {
14+
//// return <div>hello </div>;
15+
//// };
16+
17+
//// function SFC2(prop: { x: boolean }) {
18+
//// return <h1>World </h1>;
19+
//// }
20+
21+
//// var SFCComp = SFC1 || SFC2;
22+
//// <SFC/*one*/Comp x />
23+
24+
verify.goToDefinition({
25+
"one": "pt1"
26+
})
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
//@Filename: file.tsx
4+
// @jsx: preserve
5+
// @noLib: true
6+
7+
//// class RC1 extends React.Component<{}, {}> {
8+
//// render() {
9+
//// return null;
10+
//// }
11+
//// }
12+
13+
//// class RC2 extends React.Component<{}, {}> {
14+
//// render() {
15+
//// return null;
16+
//// }
17+
//// private method() { }
18+
//// }
19+
20+
//// var /*pt1*/RCComp = RC1 || RC2;
21+
22+
//// <RC/*one*/Comp />
23+
24+
verify.goToDefinition({
25+
"one": "pt1"
26+
})

0 commit comments

Comments
 (0)