Add language service tests

This commit is contained in:
Kanchalai Tanglertsampan 2016-11-08 11:07:17 -08:00
parent 2c15eab567
commit 3d19782b1c
32 changed files with 986 additions and 1 deletions

View file

@ -0,0 +1,19 @@
/// <reference path='fourslash.ts' />
//// interface PropsBag {
//// /*first*/propx: number
//// }
//// function foo(arg: PropsBag) {}
//// foo({
//// pr/*p1*/opx: 10
//// })
//// function bar(firstarg: boolean, secondarg: PropsBag) {}
//// bar(true, {
//// pr/*p2*/opx: 10
//// })
verify.goToDefinition({
p1: "first",
p2: "first"
});

View file

@ -0,0 +1,47 @@
/// <reference path='fourslash.ts' />
//@Filename: file.tsx
// @jsx: preserve
// @noLib: true
//// declare module JSX {
//// interface Element { }
//// interface IntrinsicElements {
//// }
//// interface ElementAttributesProperty { props; }
//// }
//// interface OptionPropBag {
//// propx: number
//// propString: "hell"
//// optional?: boolean
//// }
//// declare function Opt(attributes: OptionPropBag): JSX.Element;
//// let opt = <Opt /*1*/ />;
//// let opt1 = <Opt prop/*2*/ />;
//// let opt2 = <Opt propx={100} /*3*/ />;
//// let opt3 = <Opt propx={100} optional /*4*/ />;
//// let opt4 = <Opt wrong /*5*/ />;
goTo.marker("1");
verify.completionListContains('propx');
verify.completionListContains('propString');
verify.completionListContains('optional');
goTo.marker("2");
verify.completionListContains('propx');
verify.completionListContains('propString');
goTo.marker("3");
verify.completionListContains("propString")
verify.completionListContains("optional")
verify.not.completionListContains("propx")
goTo.marker("4");
verify.completionListContains("propString");
verify.not.completionListContains("propx");
verify.not.completionListContains("optional");
goTo.marker("5");
verify.completionListContains('propx');
verify.completionListContains('propString');
verify.completionListContains('optional');

View file

@ -0,0 +1,62 @@
/// <reference path='fourslash.ts' />
//@Filename: file.tsx
// @jsx: preserve
// @noLib: true
//// declare module JSX {
//// interface Element { }
//// interface IntrinsicElements {
//// }
//// interface ElementAttributesProperty { props; }
//// }
//// interface ClickableProps {
//// children?: string;
//// className?: string;
//// }
//// interface ButtonProps extends ClickableProps {
//// onClick(event?: React.MouseEvent<HTMLButtonElement>): void;
//// }
//// interface LinkProps extends ClickableProps {
//// goTo: string;
//// }
//// declare function MainButton(buttonProps: ButtonProps): JSX.Element;
//// declare function MainButton(linkProps: LinkProps): JSX.Element;
//// declare function MainButton(props: ButtonProps | LinkProps): JSX.Element;
//// let opt = <MainButton /*1*/ />;
//// let opt = <MainButton children="chidlren" /*2*/ />;
//// let opt = <MainButton onClick={()=>{}} /*3*/ />;
//// let opt = <MainButton onClick={()=>{}} ignore-prop /*4*/ />;
//// let opt = <MainButton goTo="goTo" /*5*/ />;
//// let opt = <MainButton wrong /*6*/ />;
goTo.marker("1");
verify.completionListContains('children');
verify.completionListContains('className');
verify.completionListContains('onClick');
verify.completionListContains('goTo');
goTo.marker("2");
verify.completionListContains('className');
verify.completionListContains('onClick');
verify.completionListContains('goTo');
goTo.marker("3");
verify.completionListContains('children');
verify.completionListContains('className');
verify.not.completionListContains('goTo');
goTo.marker("4");
verify.completionListContains('children');
verify.completionListContains('className');
goTo.marker("5");
verify.completionListContains('children');
verify.completionListContains('className');
verify.not.completionListContains('onClick');
goTo.marker("6");
verify.completionListContains('children');
verify.completionListContains('className');
verify.completionListContains('onClick');
verify.completionListContains('goTo');

View file

@ -0,0 +1,16 @@
/// <reference path='fourslash.ts' />
//@Filename: file.tsx
//// declare module JSX {
//// interface Element { }
//// interface IntrinsicElements {
//// [|div|]: {
//// name?: string;
//// isOpen?: boolean;
//// };
//// span: { n: string; };
//// }
//// }
//// var x = <[|div|] />;
verify.rangesReferenceEachOther();

View file

@ -0,0 +1,33 @@
/// <reference path='fourslash.ts' />
//@Filename: file.tsx
// @jsx: preserve
// @noLib: true
//// declare module JSX {
//// interface Element { }
//// interface IntrinsicElements {
//// }
//// interface ElementAttributesProperty { props; }
//// }
//// interface ClickableProps {
//// children?: string;
//// className?: string;
//// }
//// interface ButtonProps extends ClickableProps {
//// [|onClick|](event?: React.MouseEvent<HTMLButtonElement>): void;
//// }
//// interface LinkProps extends ClickableProps {
//// goTo: string;
//// }
//// declare function MainButton(buttonProps: ButtonProps): JSX.Element;
//// declare function MainButton(linkProps: LinkProps): JSX.Element;
//// declare function MainButton(props: ButtonProps | LinkProps): JSX.Element;
//// let opt = <MainButton />;
//// let opt = <MainButton children="chidlren" />;
//// let opt = <MainButton [|onClick|]={()=>{}} />;
//// let opt = <MainButton [|onClick|]={()=>{}} ignore-prop />;
//// let opt = <MainButton goTo="goTo" />;
//// let opt = <MainButton wrong />;
verify.rangesReferenceEachOther();

View file

@ -0,0 +1,29 @@
/// <reference path='fourslash.ts' />
//@Filename: file.tsx
// @jsx: preserve
// @noLib: true
//// declare module JSX {
//// interface Element { }
//// interface IntrinsicElements {
//// }
//// interface ElementAttributesProperty { props; }
//// }
//// interface ClickableProps {
//// children?: string;
//// className?: string;
//// }
//// interface ButtonProps extends ClickableProps {
//// onClick(event?: React.MouseEvent<HTMLButtonElement>): void;
//// }
//// interface LinkProps extends ClickableProps {
//// goTo: string;
//// }
//// declare function MainButton(buttonProps: ButtonProps): JSX.Element;
//// declare function MainButton(linkProps: LinkProps): JSX.Element;
//// declare function MainButton(props: ButtonProps | LinkProps): JSX.Element;
//// let opt = <MainButton [|wrong|] />; // r1
const [r1] = test.ranges();
verify.referencesOf(r1, [r1]);

View file

@ -0,0 +1,16 @@
/// <reference path='fourslash.ts' />
//@Filename: file.tsx
//// declare module JSX {
//// interface Element { }
//// interface IntrinsicElements {
//// div: {
//// [|name|]?: string;
//// isOpen?: boolean;
//// };
//// span: { n: string; };
//// }
//// }
//// var x = <div [|name|]="hello" />;
verify.rangesReferenceEachOther();

View file

@ -0,0 +1,19 @@
/// <reference path='fourslash.ts' />
//@Filename: file.tsx
//// declare module JSX {
//// interface Element { }
//// interface IntrinsicElements {
//// }
//// interface ElementAttributesProperty { props }
//// }
//// class MyClass {
//// props: {
//// [|name|]?: string;
//// size?: number;
//// }
////
////
//// var x = <MyClass [|name|]='hello'/>;
verify.rangesReferenceEachOther();

View file

@ -0,0 +1,19 @@
/// <reference path='fourslash.ts' />
//@Filename: file.tsx
//// declare module JSX {
//// interface Element { }
//// interface IntrinsicElements {
//// }
//// interface ElementAttributesProperty { props }
//// }
//// class [|MyClass|] {
//// props: {
//// name?: string;
//// size?: number;
//// }
////
////
//// var x = <[|MyClass|] name='hello'></[|MyClass|]>;
verify.rangesReferenceEachOther();

View file

@ -0,0 +1,25 @@
/// <reference path='fourslash.ts' />
//@Filename: file.tsx
// @jsx: preserve
// @noLib: true
//// declare module JSX {
//// interface Element { }
//// interface IntrinsicElements {
//// }
//// interface ElementAttributesProperty { props; }
//// }
//// interface OptionPropBag {
//// propx: number
//// propString: string
//// optional?: boolean
//// }
//// declare function [|Opt|](attributes: OptionPropBag): JSX.Element;
//// let opt = <[|Opt|] />;
//// let opt1 = <[|Opt|] propx={100} propString />;
//// let opt2 = <[|Opt|] propx={100} optional/>;
//// let opt3 = <[|Opt|] wrong />;
//// let opt4 = <[|Opt|] propx={100} propString="hi" />;
verify.rangesReferenceEachOther();

View file

@ -0,0 +1,23 @@
/// <reference path='fourslash.ts' />
/// <reference path='fourslash.ts' />
//@Filename: file.tsx
// @jsx: preserve
// @noLib: true
//// declare module JSX {
//// interface Element { }
//// interface IntrinsicElements {
//// }
//// interface ElementAttributesProperty { props; }
//// }
//// interface OptionPropBag {
//// propx: number
//// propString: string
//// optional?: boolean
//// }
//// declare function Opt(attributes: OptionPropBag): JSX.Element;
//// let opt = <Opt [|wrong|] />; //r1
const [r1] = test.ranges();
verify.referencesOf(r1, [r1]);

View file

@ -0,0 +1,24 @@
/// <reference path='fourslash.ts' />
//@Filename: file.tsx
// @jsx: preserve
// @noLib: true
//// declare module JSX {
//// interface Element { }
//// interface IntrinsicElements {
//// }
//// interface ElementAttributesProperty { props; }
//// }
//// interface OptionPropBag {
//// [|propx|]: number
//// propString: string
//// optional?: boolean
//// }
//// declare function Opt(attributes: OptionPropBag): JSX.Element;
//// let opt = <Opt />;
//// let opt1 = <Opt [|propx|]={100} propString />;
//// let opt2 = <Opt [|propx|]={100} optional/>;
//// let opt3 = <Opt wrong />;
verify.rangesReferenceEachOther();

View file

@ -0,0 +1,33 @@
/// <reference path='fourslash.ts' />
//@Filename: file.tsx
// @jsx: preserve
// @noLib: true
//// declare module JSX {
//// interface Element { }
//// interface IntrinsicElements {
//// }
//// interface ElementAttributesProperty { props; }
//// }
//// interface ClickableProps {
//// children?: string;
//// className?: string;
//// }
//// interface ButtonProps extends ClickableProps {
//// onClick(event?: React.MouseEvent<HTMLButtonElement>): void;
//// }
//// interface LinkProps extends ClickableProps {
//// goTo: string;
//// }
//// declare function [|MainButton|](buttonProps: ButtonProps): JSX.Element;
//// declare function [|MainButton|](linkProps: LinkProps): JSX.Element;
//// declare function [|MainButton|](props: ButtonProps | LinkProps): JSX.Element;
//// let opt = <[|MainButton|] />;
//// let opt = <[|MainButton|] children="chidlren" />;
//// let opt = <[|MainButton|] onClick={()=>{}} />;
//// let opt = <[|MainButton|] onClick={()=>{}} ignore-prop />;
//// let opt = <[|MainButton|] goTo="goTo" />;
//// let opt = <[|MainButton|] wrong />;
verify.rangesReferenceEachOther();

View file

@ -0,0 +1,34 @@
/// <reference path='fourslash.ts' />
//@Filename: file.tsx
// @jsx: preserve
// @noLib: true
//// declare module JSX {
//// interface Element { }
//// interface IntrinsicElements {
//// }
//// interface ElementAttributesProperty { props; }
//// }
//// interface ClickableProps {
//// children?: string;
//// className?: string;
//// }
//// interface ButtonProps extends ClickableProps {
//// onClick(event?: React.MouseEvent<HTMLButtonElement>): void;
//// }
//// interface LinkProps extends ClickableProps {
//// [|goTo|]: string;
//// }
//// declare function MainButton(buttonProps: ButtonProps): JSX.Element;
//// declare function MainButton(linkProps: LinkProps): JSX.Element;
//// declare function MainButton(props: ButtonProps | LinkProps): JSX.Element;
//// let opt = <MainButton />;
//// let opt = <MainButton children="chidlren" />;
//// let opt = <MainButton onClick={()=>{}} />;
//// let opt = <MainButton onClick={()=>{}} ignore-prop />;
//// let opt = <MainButton [|goTo|]="goTo" />;
//// let opt = <MainButton [|goTo|] />;
//// let opt = <MainButton wrong />;
verify.rangesReferenceEachOther();

View file

@ -13,8 +13,10 @@
//// }
//// var x = <My/*c*/Class />;
//// var y = <MyClass f/*p*/oo= 'hello' />;
//// var z = <MyCl/*w*/ass wrong= 'hello' />;
verify.goToDefinition({
c: "ct",
p: "pt"
p: "pt",
w: "ct"
});

View file

@ -0,0 +1,31 @@
/// <reference path='fourslash.ts' />
//@Filename: file.tsx
// @jsx: preserve
// @noLib: true
//// declare module JSX {
//// interface Element { }
//// interface IntrinsicElements {
//// }
//// interface ElementAttributesProperty { props; }
//// }
//// interface OptionPropBag {
//// /*pt1*/propx: number
//// propString: "hell"
//// /*pt2*/optional?: boolean
//// }
//// /*opt*/declare function Opt(attributes: OptionPropBag): JSX.Element;
//// let opt = <O/*one*/pt />;
//// let opt1 = <Op/*two*/t pr/*p1*/opx={100} />;
//// let opt2 = <Op/*three*/t propx={100} opt/*p2*/ional />;
//// let opt3 = <Op/*four*/t wr/*p3*/ong />;
verify.goToDefinition({
one: "opt",
two: "opt",
three: "opt",
four: "opt",
p1: "pt1",
p2: "pt2"
});

View file

@ -0,0 +1,40 @@
/// <reference path='fourslash.ts' />
//@Filename: file.tsx
// @jsx: preserve
// @noLib: true
//// declare module JSX {
//// interface Element { }
//// interface IntrinsicElements {
//// }
//// interface ElementAttributesProperty { props; }
//// }
//// interface ClickableProps {
//// children?: string;
//// className?: string;
//// }
//// interface ButtonProps extends ClickableProps {
//// onClick(event?: React.MouseEvent<HTMLButtonElement>): void;
//// }
//// interface LinkProps extends ClickableProps {
//// goTo: string;
//// }
//// /*firstSource*/declare function MainButton(buttonProps: ButtonProps): JSX.Element;
//// /*secondSource*/declare function MainButton(linkProps: LinkProps): JSX.Element;
//// /*thirdSource*/declare function MainButton(props: ButtonProps | LinkProps): JSX.Element;
//// let opt = <Main/*firstTarget*/Button />;
//// let opt = <Main/*secondTarget*/Button children="chidlren" />;
//// let opt = <Main/*thirdTarget*/Button onClick={()=>{}} />;
//// let opt = <Main/*fourthTarget*/Button onClick={()=>{}} ignore-prop />;
//// let opt = <Main/*fivethTarget*/Button goTo="goTo" />;
//// let opt = <Main/*sixthTarget*/Button wrong />;
verify.goToDefinition({
firstTarget: "firstSource",
secondTarget: "firstSource",
thirdTarget: "firstSource",
fourthTarget: "firstSource",
fivethTarget: "secondSource",
sixthTarget: "firstSource"
});

View file

@ -0,0 +1,30 @@
/// <reference path='fourslash.ts' />
//@Filename: file.tsx
// @jsx: preserve
// @noLib: true
//// interface OptionProp {
//// propx: 2
//// }
//// class Opt extends React.Component<OptionProp, {}> {
//// render() {
//// return <div>Hello</div>;
//// }
//// }
//// const obj1: OptionProp = {
//// propx: 2
//// }
//// let y1 = <O/*1*/pt pro/*2*/px={2} />;
//// let y2 = <Opt {...ob/*3*/j1} />;
//// let y2 = <Opt {...obj1} pr/*4*/opx />;
verify.quickInfos({
1: "class Opt",
2: "(JSX attribute) propx: number",
3: "const obj1: OptionProp",
4: "(JSX attribute) propx: true"
});

View file

@ -0,0 +1,55 @@
/// <reference path='fourslash.ts' />
//@Filename: file.tsx
// @jsx: preserve
// @noLib: true
//// export interface ClickableProps {
//// children?: string;
//// className?: string;
//// }
//// export interface ButtonProps extends ClickableProps {
//// onClick(event?: React.MouseEvent<HTMLButtonElement>): void;
//// }
//// export interface LinkProps extends ClickableProps {
//// to: string;
//// }
//// export function MainButton(buttonProps: ButtonProps): JSX.Element;
//// export function MainButton(linkProps: LinkProps): JSX.Element;
//// export function MainButton(props: ButtonProps | LinkProps): JSX.Element {
//// const linkProps = props as LinkProps;
//// if(linkProps.to) {
//// return this._buildMainLink(props);
//// }
//// return this._buildMainButton(props);
//// }
//// function _buildMainButton({ onClick, children, className }: ButtonProps): JSX.Element {
//// return(<button className={className} onClick={onClick}>{ children || 'MAIN BUTTON'}</button>);
//// }
//// declare function buildMainLink({ to, children, className }: LinkProps): JSX.Element;
//// function buildSomeElement1(): JSX.Element {
//// return (
//// <MainB/*1*/utton t/*2*/o='/some/path'>GO</MainButton>
//// );
//// }
//// function buildSomeElement2(): JSX.Element {
//// return (
//// <MainB/*3*/utton onC/*4*/lick={()=>{}}>GO</MainButton>;
//// );
//// }
//// let componenet = <MainButton onClick={()=>{}} ext/*5*/ra-prop>GO</MainButton>;
verify.quickInfos({
1: "function MainButton(linkProps: LinkProps): any (+1 overload)",
2: "(JSX attribute) to: string",
3: "function MainButton(buttonProps: ButtonProps): any (+1 overload)",
4: "(JSX attribute) onClick: () => void",
5: "(JSX attribute) extra-prop: true"
});

View file

@ -0,0 +1,18 @@
/// <reference path='fourslash.ts' />
//@Filename: file.tsx
// @jsx: preserve
// @noLib: true
//// declare function ComponentWithTwoAttributes<K,V>(l: {key1: K, value: V}): JSX.Element;
//// function Baz<T,U>(key1: T, value: U) {
//// let a0 = <ComponentWi/*1*/thTwoAttributes k/*2*/ey1={key1} val/*3*/ue={value} />
//// let a1 = <ComponentWithTwoAttributes {...{key1, value: value}} key="Component" />
//// }
verify.quickInfos({
1: "function ComponentWithTwoAttributes<T, U>(l: {\n key1: T;\n value: U;\n}): any",
2: "(JSX attribute) key1: T",
3: "(JSX attribute) value: U",
});

View file

@ -0,0 +1,19 @@
/// <reference path='fourslash.ts' />
//@Filename: file.tsx
// @jsx: preserve
// @noLib: true
//// declare function ComponentSpecific<U>(l: {prop: U}): JSX.Element;
//// declare function ComponentSpecific1<U>(l: {prop: U, "ignore-prop": number}): JSX.Element;
//// function Bar<T extends {prop: number}>(arg: T) {
//// let a1 = <Compone/*1*/ntSpecific {...arg} ignore-prop="hi" />; // U is number
//// let a2 = <ComponentSpecific1 {...arg} ignore-prop={10} />; // U is number
//// let a3 = <Component/*2*/Specific {...arg} prop="hello" />; // U is "hello"
//// }
verify.quickInfos({
1: "function ComponentSpecific<{}>(l: {\n prop: {};\n}): any",
2: "function ComponentSpecific<{}>(l: {\n prop: {};\n}): any"
});

View file

@ -0,0 +1,29 @@
/// <reference path='fourslash.ts' />
//@Filename: file.tsx
// @jsx: preserve
// @noLib: true
//// declare function OverloadComponent(): JSX.Element;
//// declare function OverloadComponent<U>(attr: {b: U, a?: string, "ignore-prop": boolean}): JSX.Element;
//// declare function OverloadComponent<T, U>(attr: {b: U, a: T}): JSX.Element;
//// function Baz<T extends {b: number}, U extends {a: boolean, b:string}>(arg1: T, arg2: U) {
//// let a0 = <Overloa/*1*/dComponent {...arg1} a="hello" ignore-prop />;
//// let a1 = <Overloa/*2*/dComponent {...arg2} ignore-pro="hello world" />;
//// let a2 = <Overloa/*3*/dComponent {...arg2} />;
//// let a3 = <Overloa/*4*/dComponent {...arg1} ignore-prop />;
//// let a4 = <Overloa/*5*/dComponent />;
//// let a5 = <Overloa/*6*/dComponent {...arg2} ignore-prop="hello" {...arg1} />;
//// let a6 = <Overloa/*7*/dComponent {...arg2} ignore-prop {...arg1} />;
//// }
verify.quickInfos({
1: "function OverloadComponent(): any (+2 overloads)",
2: "function OverloadComponent(): any (+2 overloads)",
3: "function OverloadComponent(): any (+2 overloads)",
4: "function OverloadComponent(): any (+2 overloads)",
5: "function OverloadComponent(): any (+2 overloads)",
6: "function OverloadComponent(): any (+2 overloads)",
7: "function OverloadComponent(): any (+2 overloads)"
});

View file

@ -0,0 +1,40 @@
/// <reference path='fourslash.ts' />
//@Filename: file.tsx
// @jsx: preserve
// @noLib: true
//// declare module JSX {
//// interface Element { }
//// interface IntrinsicElements {
//// }
//// interface ElementAttributesProperty { props; }
//// }
//// interface ClickableProps {
//// children?: string;
//// className?: string;
//// }
//// interface ButtonProps extends ClickableProps {
//// onClick(event?: React.MouseEvent<HTMLButtonElement>): void;
//// }
//// interface LinkProps extends ClickableProps {
//// [|goTo|]: string;
//// }
//// declare function MainButton(buttonProps: ButtonProps): JSX.Element;
//// declare function MainButton(linkProps: LinkProps): JSX.Element;
//// declare function MainButton(props: ButtonProps | LinkProps): JSX.Element;
//// let opt = <MainButton />;
//// let opt = <MainButton children="chidlren" />;
//// let opt = <MainButton onClick={()=>{}} />;
//// let opt = <MainButton onClick={()=>{}} ignore-prop />;
//// let opt = <MainButton [|goTo|]="goTo" />;
//// let opt = <MainButton [|goTo|] />;
//// let opt = <MainButton wrong />;
let ranges = test.ranges();
verify.assertHasRanges(ranges);
for (let range of ranges) {
goTo.position(range.start);
verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false);
}

View file

@ -0,0 +1,39 @@
/// <reference path='fourslash.ts' />
//@Filename: file.tsx
// @jsx: preserve
// @noLib: true
//// declare module JSX {
//// interface Element { }
//// interface IntrinsicElements {
//// }
//// interface ElementAttributesProperty { props; }
//// }
//// interface ClickableProps {
//// children?: string;
//// className?: string;
//// }
//// interface ButtonProps extends ClickableProps {
//// [|onClick|](event?: React.MouseEvent<HTMLButtonElement>): void;
//// }
//// interface LinkProps extends ClickableProps {
//// goTo: string;
//// }
//// declare function MainButton(buttonProps: ButtonProps): JSX.Element;
//// declare function MainButton(linkProps: LinkProps): JSX.Element;
//// declare function MainButton(props: ButtonProps | LinkProps): JSX.Element;
//// let opt = <MainButton />;
//// let opt = <MainButton children="chidlren" />;
//// let opt = <MainButton [|onClick|]={()=>{}} />;
//// let opt = <MainButton [|onClick|]={()=>{}} ignore-prop />;
//// let opt = <MainButton goTo="goTo" />;
//// let opt = <MainButton wrong />;
let ranges = test.ranges();
verify.assertHasRanges(ranges);
for (let range of ranges) {
goTo.position(range.start);
verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false);
}

View file

@ -0,0 +1,39 @@
/// <reference path='fourslash.ts' />
//@Filename: file.tsx
// @jsx: preserve
// @noLib: true
//// declare module JSX {
//// interface Element { }
//// interface IntrinsicElements {
//// }
//// interface ElementAttributesProperty { props; }
//// }
//// interface ClickableProps {
//// children?: string;
//// className?: string;
//// }
//// interface ButtonProps extends ClickableProps {
//// onClick(event?: React.MouseEvent<HTMLButtonElement>): void;
//// }
//// interface LinkProps extends ClickableProps {
//// goTo: string;
//// }
//// declare function MainButton(buttonProps: ButtonProps): JSX.Element;
//// declare function MainButton(linkProps: LinkProps): JSX.Element;
//// declare function MainButton(props: ButtonProps | LinkProps): JSX.Element;
//// let opt = <MainButton />;
//// let opt = <MainButton children="chidlren" />;
//// let opt = <MainButton onClick={()=>{}} />;
//// let opt = <MainButton onClick={()=>{}} ignore-prop />;
//// let opt = <MainButton goTo="goTo" />;
//// let opt = <MainButton [|wrong|] />;
let ranges = test.ranges();
verify.assertHasRanges(ranges);
for (let range of ranges) {
goTo.position(range.start);
verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false);
}

View file

@ -0,0 +1,39 @@
/// <reference path='fourslash.ts' />
//@Filename: file.tsx
// @jsx: preserve
// @noLib: true
//// declare module JSX {
//// interface Element { }
//// interface IntrinsicElements {
//// }
//// interface ElementAttributesProperty { props; }
//// }
//// interface ClickableProps {
//// children?: string;
//// className?: string;
//// }
//// interface ButtonProps extends ClickableProps {
//// onClick(event?: React.MouseEvent<HTMLButtonElement>): void;
//// }
//// interface LinkProps extends ClickableProps {
//// goTo: string;
//// }
//// declare function MainButton(buttonProps: ButtonProps): JSX.Element;
//// declare function MainButton(linkProps: LinkProps): JSX.Element;
//// declare function MainButton(props: ButtonProps | LinkProps): JSX.Element;
//// let opt = <MainButton />;
//// let opt = <MainButton children="chidlren" />;
//// let opt = <MainButton onClick={()=>{}} />;
//// let opt = <MainButton onClick={()=>{}} [|ignore-prop|] />;
//// let opt = <MainButton goTo="goTo" />;
//// let opt = <MainButton wrong />;
let ranges = test.ranges();
verify.assertHasRanges(ranges);
for (let range of ranges) {
goTo.position(range.start);
verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false);
}

View file

@ -0,0 +1,30 @@
/// <reference path='fourslash.ts' />
//@Filename: file.tsx
// @jsx: preserve
// @noLib: true
//// declare module JSX {
//// interface Element { }
//// interface IntrinsicElements {
//// }
//// interface ElementAttributesProperty { props; }
//// }
//// interface OptionPropBag {
//// propx: number
//// propString: string
//// optional?: boolean
//// }
//// declare function [|Opt|](attributes: OptionPropBag): JSX.Element;
//// let opt = <[|Opt|] />;
//// let opt1 = <[|Opt|] propx={100} propString />;
//// let opt2 = <[|Opt|] propx={100} optional/>;
//// let opt3 = <[|Opt|] wrong />;
//// let opt4 = <[|Opt|] propx={100} propString="hi" />;
let ranges = test.ranges();
verify.assertHasRanges(ranges);
for (let range of ranges) {
goTo.position(range.start);
verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false);
}

View file

@ -0,0 +1,29 @@
/// <reference path='fourslash.ts' />
//@Filename: file.tsx
// @jsx: preserve
// @noLib: true
//// declare module JSX {
//// interface Element { }
//// interface IntrinsicElements {
//// }
//// interface ElementAttributesProperty { props; }
//// }
//// interface OptionPropBag {
//// [|propx|]: number
//// propString: string
//// optional?: boolean
//// }
//// declare function Opt(attributes: OptionPropBag): JSX.Element;
//// let opt = <Opt />;
//// let opt1 = <Opt [|propx|]={100} propString />;
//// let opt2 = <Opt [|propx|]={100} optional/>;
//// let opt3 = <Opt wrong />;
let ranges = test.ranges();
verify.assertHasRanges(ranges);
for (let range of ranges) {
goTo.position(range.start);
verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false);
}

View file

@ -0,0 +1,31 @@
/// <reference path='fourslash.ts' />
/// <reference path='fourslash.ts' />
//@Filename: file.tsx
// @jsx: preserve
// @noLib: true
//// declare module JSX {
//// interface Element { }
//// interface IntrinsicElements {
//// }
//// interface ElementAttributesProperty { props; }
//// }
//// interface OptionPropBag {
//// propx: number
//// propString: string
//// optional?: boolean
//// }
//// declare function Opt(attributes: OptionPropBag): JSX.Element;
//// let opt = <Opt />;
//// let opt1 = <Opt propx={100} propString />;
//// let opt2 = <Opt propx={100} optional/>;
//// let opt3 = <Opt [|wrong|] />;
//// let opt4 = <Opt propx={100} propString="hi" />;
let ranges = test.ranges();
verify.assertHasRanges(ranges);
for (let range of ranges) {
goTo.position(range.start);
verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false);
}

View file

@ -0,0 +1,38 @@
/// <reference path='fourslash.ts' />
//@Filename: file.tsx
// @jsx: preserve
// @noLib: true
//// declare module JSX {
//// interface Element { }
//// interface IntrinsicElements {
//// }
//// interface ElementAttributesProperty { props; }
//// }
//// interface ClickableProps {
//// children?: string;
//// className?: string;
//// }
//// interface ButtonProps extends ClickableProps {
//// onClick(event?: React.MouseEvent<HTMLButtonElement>): void;
//// }
//// interface LinkProps extends ClickableProps {
//// goTo: string;
//// }
//// declare function [|MainButton|](buttonProps: ButtonProps): JSX.Element;
//// declare function [|MainButton|](linkProps: LinkProps): JSX.Element;
//// declare function [|MainButton|](props: ButtonProps | LinkProps): JSX.Element;
//// let opt = <[|MainButton|] />;
//// let opt = <[|MainButton|] children="chidlren" />;
//// let opt = <[|MainButton|] onClick={()=>{}} />;
//// let opt = <[|MainButton|] onClick={()=>{}} ignore-prop />;
//// let opt = <[|MainButton|] goTo="goTo" />;
//// let opt = <[|MainButton|] wrong />;
let ranges = test.ranges();
verify.assertHasRanges(ranges);
for (let range of ranges) {
goTo.position(range.start);
verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false);
}

View file

@ -0,0 +1,35 @@
/// <reference path='fourslash.ts' />
//@Filename: file.tsx
// @jsx: preserve
// @noLib: true
// @libFiles: react.d.ts,lib.d.ts
//// import React = require('react');
//// export interface ClickableProps {
//// children?: string;
//// className?: string;
//// }
//// export interface ButtonProps extends ClickableProps {
//// onClick(event?: React.MouseEvent<HTMLButtonElement>): void;
//// }
//// function _buildMainButton({ onClick, children, className }: ButtonProps): JSX.Element {
//// return(<button className={className} onClick={onClick}>{ children || 'MAIN BUTTON'}</button>);
//// }
//// export function MainButton(props: ButtonProps): JSX.Element {
//// return this._buildMainButton(props);
//// }
//// let e1 = <MainButton/*1*/ /*2*/
goTo.marker("1");
verify.signatureHelpCountIs(1);
verify.currentSignatureHelpIs("MainButton(props: ButtonProps): any");
verify.currentParameterSpanIs("props: ButtonProps");
goTo.marker("2");
verify.signatureHelpCountIs(1);
verify.currentSignatureHelpIs("MainButton(props: ButtonProps): any");
verify.currentParameterSpanIs("props: ButtonProps");

View file

@ -0,0 +1,42 @@
/// <reference path='fourslash.ts' />
//@Filename: file.tsx
// @jsx: preserve
// @noLib: true
// @libFiles: react.d.ts,lib.d.ts
//// import React = require('react');
//// export interface ClickableProps {
//// children?: string;
//// className?: string;
//// }
//// export interface ButtonProps extends ClickableProps {
//// onClick(event?: React.MouseEvent<HTMLButtonElement>): void;
//// }
//// export interface LinkProps extends ClickableProps {
//// goTo(where: "home" | "contact"): void;
//// }
//// function _buildMainButton({ onClick, children, className }: ButtonProps): JSX.Element {
//// return(<button className={className} onClick={onClick}>{ children || 'MAIN BUTTON'}</button>);
//// }
//// export function MainButton(buttonProps: ButtonProps): JSX.Element;
//// export function MainButton(linkProps: LinkProps): JSX.Element;
//// export function MainButton(props: ButtonProps | LinkProps): JSX.Element {
//// return this._buildMainButton(props);
//// }
//// let e1 = <MainButton/*1*/ /*2*/
goTo.marker("1");
// The second overload is chosen because the first doesn't get selected by choose overload as it has incorrect arity
verify.signatureHelpCountIs(2);
verify.currentSignatureHelpIs("MainButton(buttonProps: ButtonProps): any");
verify.currentParameterSpanIs("buttonProps: ButtonProps");
goTo.marker("2");
verify.signatureHelpCountIs(2);
verify.currentSignatureHelpIs("MainButton(buttonProps: ButtonProps): any");
verify.currentParameterSpanIs("buttonProps: ButtonProps");