Merge branch 'master' into fixTypeResolutionInTypeSerialization

This commit is contained in:
Ron Buckton
2015-08-06 15:45:24 -07:00
694 changed files with 15788 additions and 8909 deletions
@@ -0,0 +1,18 @@
// @module: system
// @isolatedModules: true
import alias = require('foo');
import cls = alias.Class;
export import cls2 = alias.Class;
let x = new alias.Class();
let y = new cls();
let z = new cls2();
module M {
export import cls = alias.Class;
let x = new alias.Class();
let y = new cls();
let z = new cls2();
}
@@ -0,0 +1,17 @@
// @module: system
// @isolatedModules: true
import {alias} from "foo";
import cls = alias.Class;
export import cls2 = alias.Class;
let x = new alias.Class();
let y = new cls();
let z = new cls2();
module M {
export import cls = alias.Class;
let x = new alias.Class();
let y = new cls();
let z = new cls2();
}
+7 -5
View File
@@ -1,5 +1,7 @@
var x = {one: 1};
var y: {[index:string]: any};
x = y;
y = x;
var x = { one: 1 };
var y: { [index: string]: any };
var z: { [index: number]: any };
x = y; // Error
y = x; // Ok because index signature type is any
x = z; // Error
z = x; // Ok because index signature type is any
@@ -0,0 +1,18 @@
const enum E { A, B, C }
function foo<T extends number>(x: T) {
var y: number = x; // Ok
}
foo(5);
foo(E.A);
class A { a }
class B { b }
function bar<T extends A | B>(x: T) {
var y: A | B = x; // Ok
}
bar(new A);
bar(new B);
+12
View File
@@ -0,0 +1,12 @@
class C extends null {
constructor() {
super();
return Object.create(null);
}
}
class D extends null {
constructor() {
return Object.create(null);
}
}
@@ -0,0 +1,9 @@
//@module: amd
//@filename: m1.ts
function foo() {}
module foo {
const enum E { X }
}
export = foo
@@ -0,0 +1,9 @@
//@module: amd
//@filename: m1.ts
class foo {}
module foo {
const enum E { X }
}
export = foo
@@ -0,0 +1,9 @@
//@module: amd
//@filename: m1.ts
enum foo { A }
module foo {
const enum E { X }
}
export = foo
@@ -0,0 +1,13 @@
//@module: amd
//@filename: m1.ts
module foo {
const enum E { X }
}
module foo {
var x = 1;
}
export = foo
@@ -0,0 +1,9 @@
//@module: amd
//@filename: m1.ts
//@preserveConstEnums: true
module foo {
const enum E { X }
}
export = foo
@@ -0,0 +1,22 @@
// @comments: false
const enum Foo {
X = 100,
Y = 0.5,
Z = 2.,
A = -1,
B = -1.5,
C = -1.
}
let x0 = Foo.X.toString();
let x1 = Foo["X"].toString();
let y0 = Foo.Y.toString();
let y1 = Foo["Y"].toString();
let z0 = Foo.Z.toString();
let z1 = Foo["Z"].toString();
let a0 = Foo.A.toString();
let a1 = Foo["A"].toString();
let b0 = Foo.B.toString();
let b1 = Foo["B"].toString();
let c0 = Foo.C.toString();
let c1 = Foo["C"].toString();
@@ -0,0 +1,22 @@
// @comments: true
const enum Foo {
X = 100,
Y = 0.5,
Z = 2.,
A = -1,
B = -1.5,
C = -1.
}
let x0 = Foo.X.toString();
let x1 = Foo["X"].toString();
let y0 = Foo.Y.toString();
let y1 = Foo["Y"].toString();
let z0 = Foo.Z.toString();
let z1 = Foo["Z"].toString();
let a0 = Foo.A.toString();
let a1 = Foo["A"].toString();
let b0 = Foo.B.toString();
let b1 = Foo["B"].toString();
let c0 = Foo.C.toString();
let c1 = Foo["C"].toString();
@@ -0,0 +1,17 @@
// @noemithelpers: true
// @experimentaldecorators: true
// @emitdecoratormetadata: true
// @target: es5
declare var decorator: any;
class MyClass {
constructor(test: string, test2: number) {
}
@decorator
doSomething() {
}
}
+17
View File
@@ -0,0 +1,17 @@
// @target: ES5
// @sourcemap: false
// @declaration: false
// @module: commonjs
export default class A
{
constructor ()
{
}
public B()
{
return 42;
}
}
+6
View File
@@ -0,0 +1,6 @@
// @target: ES5
// @sourcemap: false
// @declaration: false
// @module: commonjs
export default 1;
+7
View File
@@ -0,0 +1,7 @@
// @target: ES5
// @sourcemap: false
// @declaration: false
// @module: commonjs
export default "test";
export var __esModule = 1;
+18
View File
@@ -0,0 +1,18 @@
// @target: ES5
// @sourcemap: false
// @declaration: false
// @module: commonjs
export default class A
{
constructor ()
{
}
public B()
{
return 42;
}
}
export var __esModule = 1;
+8
View File
@@ -0,0 +1,8 @@
// @target: ES5
// @sourcemap: false
// @declaration: false
// @module: commonjs
export default function () {
return "test";
}
+7
View File
@@ -0,0 +1,7 @@
// @target: ES5
// @sourcemap: false
// @declaration: false
// @module: commonjs
export default "test";
var __esModule = 1;
+17
View File
@@ -0,0 +1,17 @@
// @target: ES5
// @sourcemap: false
// @declaration: false
// @module: system
export default class A
{
constructor ()
{
}
public B()
{
return 42;
}
}
@@ -3,5 +3,5 @@
(...arg) => 103;
(...arg:number [] = []) => 104;
// Non optional parameter following an optional one
// Uninitialized parameter makes the initialized one required
(arg1 = 1, arg2) => 1;
@@ -0,0 +1,7 @@
declare function f<T>(x: T, y: (p: T) => T, z: (p: T) => T): T;
f("", x => null, x => x.toLowerCase());
// First overload of g should type check just like f
declare function g<T>(x: T, y: (p: T) => T, z: (p: T) => T): T;
declare function g();
g("", x => null, x => x.toLowerCase());
@@ -0,0 +1,17 @@
interface Base {
baseProp;
}
interface Derived extends Base {
toBase(): Base;
}
var derived: Derived;
declare function foo<T>(x: T, func: (p: T) => T): T;
var result = foo(derived, d => d.toBase());
// bar should type check just like foo.
// The same error should be observed in both cases.
declare function bar<T>(x: T, func: (p: T) => T): T;
declare function bar<T>(x: T, func: (p: T) => T): T;
var result = bar(derived, d => d.toBase());
@@ -0,0 +1,17 @@
interface Base {
baseProp;
}
interface Derived extends Base {
toBase?(): Base;
}
var derived: Derived;
declare function foo<T>(x: T, func: (p: T) => T): T;
var result = foo(derived, d => d.toBase());
// bar should type check just like foo.
// result2 should have the same type as result
declare function bar<T>(x: T, func: (p: T) => T): T;
declare function bar<T>(x: T, func: (p: T) => T): T;
var result2 = bar(derived, d => d.toBase());
@@ -0,0 +1,5 @@
function f<T extends { "0": (p1: number) => number }>(p: T): T {
return p;
}
var v = f([x => x]);
@@ -0,0 +1,5 @@
function f<T extends [(p1: number) => number]>(p: T): T {
return p;
}
var v = f([x => x]);
@@ -0,0 +1,5 @@
function f<T extends ((p1: number) => number)[]>(p: T): T {
return p;
}
var v = f([x => x]);
@@ -0,0 +1,5 @@
function f<T extends (p1: number) => number>(p: T): T {
return p;
}
var v = f(x => x);
@@ -0,0 +1,5 @@
function f<T extends { q: (p1: number) => number }>(p: T): T {
return p;
}
var v = f({ q: x => x });
@@ -0,0 +1,88 @@
interface Base {
foo: string|number;
optional?: number;
}
// Derived1 is assignable to, but not a subtype of, Base
class Derived1 implements Base {
foo: string;
}
// Derived2 is a subtype of Base that is not assignable to Derived1
class Derived2 implements Base {
foo: number;
optional: number;
}
class Animal {
move;
}
class Mammal extends Animal { milk; }
class Giraffe extends Mammal { neck; }
function fn1(x: Array<number>|Array<string>|boolean) {
if(x instanceof Array) {
// 1.5: y: Array<number>|Array<string>
// Want: y: Array<number>|Array<string>
let y = x;
}
}
function fn2(x: Base) {
if(x instanceof Derived1) {
// 1.5: y: Base
// Want: y: Derived1
let y = x;
}
}
function fn3(x: Base|Derived1) {
if(x instanceof Derived2) {
// 1.5: y: Derived2
// Want: Derived2
let y = x;
}
}
function fn4(x: Base|Derived2) {
if(x instanceof Derived1) {
// 1.5: y: {}
// Want: Derived1
let y = x;
}
}
function fn5(x: Derived1) {
if(x instanceof Derived2) {
// 1.5: y: Derived1
// Want: ???
let y = x;
}
}
function fn6(x: Animal|Mammal) {
if(x instanceof Giraffe) {
// 1.5: y: Derived1
// Want: ???
let y = x;
}
}
function fn7(x: Array<number>|Array<string>) {
if(x instanceof Array) {
// 1.5: y: Array<number>|Array<string>
// Want: y: Array<number>|Array<string>
let y = x;
}
}
interface Alpha { a }
interface Beta { b }
interface Gamma { c }
class ABC { a; b; c; }
function fn8(x: Alpha|Beta|Gamma) {
if(x instanceof ABC) {
let y = x;
}
}
@@ -3,4 +3,4 @@
// @target: es6
// @filename: file1.ts
export var x;
export var x = 1;
@@ -0,0 +1,14 @@
//@jsx: preserve
//@module: commonjs
//@filename: component.d.ts
declare module "Test" {
export default class Text { }
}
//@filename: consumer.tsx
/// <reference path="component.d.ts" />
import Test from 'Test';
let x = Test; // emit test_1.default
<anything attr={Test} />; // ?
+23
View File
@@ -0,0 +1,23 @@
//@jsx: preserve
//@module: commonjs
//@filename: component.d.ts
declare module JSX {
interface ElementAttributesProperty { props; }
}
declare module React {
class Component<T, U> { }
}
declare module "BaseComponent" {
var base: React.Component<any, {}>;
export = base;
}
//@filename: consumer.tsx
/// <reference path="component.d.ts" />
import BaseComponent = require('BaseComponent');
class TestComponent extends React.Component<any, {}> {
render() {
return <BaseComponent />;
}
}
@@ -30,8 +30,7 @@ class C1 {
public C1M5(C1M5A1:number,C1M5A2:number=0,C1M5A3?:number) { return C1M5A1 + C1M5A2; }
// Negative test
// "Optional parameters may only be followed by other optional parameters"
// Uninitialized parameter makes the initialized one required
public C1M5(C1M5A1:number,C1M5A2:number=0,C1M5A3:number) { return C1M5A1 + C1M5A2; }
}
@@ -0,0 +1,19 @@
function f1(a, b = 0, c) { }
function f2(a, b = 0, c = 0) { }
function f3(a, b = 0, c?) { }
function f4(a, b = 0, ...c) { }
f1(0, 1, 2);
f2(0, 1, 2);
f3(0, 1, 2);
f4(0, 1, 2);
f1(0, 1);
f2(0, 1);
f3(0, 1);
f4(0, 1);
f1(0);
f2(0);
f3(0);
f4(0);
@@ -0,0 +1,7 @@
interface I1 {
method();
}
class C1 implements I1 {
method(a = 0, b) { }
}
@@ -0,0 +1,8 @@
//@declaration: true
interface I1 {
method();
}
class C1 implements I1 {
method(a = 0, b?) { }
}
@@ -0,0 +1,4 @@
//@declaration: true
class C1 {
method(a = 0, b) { }
}
@@ -0,0 +1,2 @@
interface bar { }
let bar: bar;
@@ -0,0 +1,4 @@
interface foo { }
interface bar { }
let bar: bar | foo;
let foo: bar | foo;
@@ -0,0 +1,8 @@
declare module foo {
interface Bar {
}
}
let foo: foo.Bar;
@@ -0,0 +1,8 @@
declare module "punycode" {
interface ucs2 {
decode(string: string): string;
encode(codePoints: number[]): string;
}
export let ucs2: ucs2;
}
@@ -0,0 +1,3 @@
class C { }
type baz = C;
let baz: baz;
+2
View File
@@ -0,0 +1,2 @@
#!/usr/bin/env node
var foo = 'I wish the generated JS to be executed in node';
+2
View File
@@ -0,0 +1,2 @@
var foo = 'Shebang is only allowed on the first line';
#!/usr/bin/env node
+5
View File
@@ -0,0 +1,5 @@
//@target: ES6
var includes: boolean;
includes = "abcde".includes("cd");
includes = "abcde".includes("cd", 2);
@@ -0,0 +1,16 @@
class A {
}
class C {
}
class B extends A {
constructor() {
class D extends C {
constructor() {
super();
}
}
}
}
@@ -0,0 +1,16 @@
class A {
}
class C {
}
class B extends A {
constructor() {
var D = class extends C {
constructor() {
super();
}
}
}
}
@@ -0,0 +1,12 @@
class A {
foo() {
}
}
class B extends A {
constructor() {
var x = {
x: super()
}
}
}
@@ -0,0 +1,9 @@
class Foo extends Bar {
m1() {
return super.m1();
}
static m2() {
return super.m2();
}
}
@@ -0,0 +1,12 @@
// @module: system
// @Filename: foo.ts
export class Foo {
a: string;
}
// @Filename: bar.ts
import {Foo} from './foo';
export class Bar extends Foo {
b: string;
}
@@ -0,0 +1,21 @@
declare var $q: IQService;
interface IQService {
all<T1, T2, T3>(x: [IPromise<T1>, IPromise<T2>, IPromise<T3>]): IPromise<[T1, T2, T3]>;
all<T1, T2>(x: [IPromise<T1>, IPromise<T2>]): IPromise<[T1, T2]>;
all<T1>(x: [IPromise<T1>]): IPromise<[T1]>;
when<T>(t?: T): IPromise<T>;
}
interface IPromise<T> {
then<TResult>(callback: (t: T) => TResult): IPromise<TResult>;
}
// Implicit different types
var a = $q.all([$q.when<string>(), $q.when<number>()]);
// Explicit different types
var b = $q.all<string, number>([$q.when<string>(), $q.when<number>()]);
// Implicit identical types
var c = $q.all([$q.when<string>(), $q.when<string>()]);
+1
View File
@@ -383,6 +383,7 @@ module Underscore {
evaluate?: RegExp;
interpolate?: RegExp;
escape?: RegExp;
variable?: string;
}
export interface Static {
@@ -1,5 +1,5 @@
function f([]) {
var x, y, z;
var x, y, z;
}
@@ -0,0 +1,6 @@
// @target: es5
var a: any;
({} = a);
([] = a);
@@ -0,0 +1,6 @@
// @target: es6
var a: any;
({} = a);
([] = a);
@@ -0,0 +1,7 @@
// @target: es5
var a: any;
let x, y, z, a1, a2, a3;
({} = { x, y, z } = a);
([] = [ a1, a2, a3] = a);
@@ -0,0 +1,7 @@
// @target: es6
var a: any;
let x, y, z, a1, a2, a3;
({} = { x, y, z } = a);
([] = [ a1, a2, a3] = a);
@@ -0,0 +1,6 @@
// @target: es5
var a: any;
({} = {} = a);
([] = [] = a);
@@ -0,0 +1,6 @@
// @target: es6
var a: any;
({} = {} = a);
([] = [] = a);
@@ -0,0 +1,7 @@
// @target: es5
var a: any;
let x, y, z, a1, a2, a3;
({ x, y, z } = {} = a);
([ a1, a2, a3] = [] = a);
@@ -0,0 +1,7 @@
// @target: es6
var a: any;
let x, y, z, a1, a2, a3;
({ x, y, z } = {} = a);
([ a1, a2, a3] = [] = a);
@@ -0,0 +1,31 @@
// @module: commonjs
// @target: ES5
// @filename: m1.ts
export default function Decl() {
return 0;
}
export interface Decl {
p1: number;
p2: number;
}
export namespace Decl {
export var x = 10;
export var y = 20;
interface I {
}
}
// @filename: m2.ts
import Entity from "m1"
Entity();
var x: Entity;
var y: Entity.I;
Entity.x;
Entity.y;
@@ -0,0 +1,26 @@
// @module: commonjs
// @target: ES5
// @filename: m1.ts
export default class Decl {
}
export interface Decl {
p1: number;
p2: number;
}
export namespace Decl {
interface I {
}
}
// @filename: m2.ts
import Entity from "m1"
Entity();
var x: Entity;
var y: Entity.I;
var z = new Entity();
var sum = z.p1 + z.p2
@@ -0,0 +1,26 @@
// @module: commonjs
// @target: ES5
// @filename: m1.ts
export default class Decl {
}
interface Decl {
p1: number;
p2: number;
}
namespace Decl {
interface I {
}
}
// @filename: m2.ts
import Entity from "m1"
Entity();
var x: Entity;
var y: Entity.I;
var z = new Entity();
var sum = z.p1 + z.p2
@@ -0,0 +1,15 @@
// @module: commonjs
// @target: ES5
export default function Foo() {
}
namespace Foo {
export var x;
}
interface Foo {
}
export interface Foo {
}
@@ -0,0 +1,19 @@
// @module: commonjs
// @target: ES5
// @filename: m1.ts
export default class foo {
}
export default function bar() {
}
var x = 10;
export default x;
// @filename: m2.ts
import Entity from "m1"
Entity();
@@ -0,0 +1,16 @@
// @module: commonjs
// @target: ES5
// @filename: m1.ts
export default function foo() {
}
export default function bar() {
}
// @filename: m2.ts
import Entity from "m1"
Entity();
+2
View File
@@ -1,5 +1,7 @@
//@filename: file.tsx
//@jsx: preserve
//@sourceMap: true
declare module JSX {
interface Element { }
interface IntrinsicElements { }
@@ -0,0 +1,17 @@
//@jsx: react
//@module: commonjs
//@filename: modules.d.ts
declare module 'mod' {
var y: any;
export default y;
}
//@filename: app.tsx
import Main from 'mod';
declare var Foo, React;
// Should see mod_1['default'] in emit here
<Foo handler={Main}></Foo>;
// Should see mod_1['default'] in emit here
<Foo {...Main}></Foo>;
@@ -0,0 +1 @@
var [a, b]: [number, any] = [undefined, undefined];
@@ -0,0 +1 @@
function f([a, b]: [number, any]) { }
@@ -0,0 +1 @@
var [a, b] = [0, undefined];
@@ -0,0 +1 @@
function f([a, b] = [0, undefined]) { }
@@ -1,7 +1,8 @@
/// <reference path="fourslash.ts" />
//// /*1*/function parseInt(s/*2*/:string):number;
goTo.marker('2');
edit.deleteAtCaret(':string'.length);
goTo.marker('1');
edit.insert('declare ');
edit.insert('declare ');
@@ -11,7 +11,6 @@
////var a2 = { name: 'bob', age: 18, address: 'springfield' };
////var b2 = { name: 'jim', age: 20, dob: new Date() };
////var /*3*/c2 = [a2, b2];
////var /*4*/c2a = [a2, b2, a1];
////interface I {
//// name: string;
@@ -19,13 +18,13 @@
////}
////var i: I;
////var /*5*/c3 = [a2, b2, i];
////var /*4*/c3 = [i, a];
goTo.marker('1');
verify.quickInfoIs('var c: {\n name: string;\n age: number;\n}[]');
goTo.marker('2');
verify.quickInfoIs('var c1: {\n name: string;\n age: number;\n}[]');
verify.quickInfoIs('var c1: ({\n name: string;\n age: number;\n} | {\n name: string;\n age: number;\n dob: Date;\n})[]');
goTo.marker('3');
verify.quickInfoIs('var c2: ({\n\
@@ -39,8 +38,5 @@ verify.quickInfoIs('var c2: ({\n\
})[]');
goTo.marker('4');
verify.quickInfoIs('var c2a: {\n name: string;\n age: number;\n}[]');
goTo.marker('5');
verify.quickInfoIs('var c3: I[]');
@@ -15,6 +15,6 @@
////x./**/
goTo.marker();
verify.memberListContains("commonProperty", "(property) commonProperty: string | number");
verify.memberListContains("commonProperty", "(property) commonProperty: number | string");
verify.memberListContains("commonFunction", "(method) commonFunction(): number");
verify.memberListCount(2);
@@ -15,6 +15,6 @@
////x.commonProperty./**/
goTo.marker();
verify.memberListContains("toString", "(method) toString(): string");
verify.memberListContains("valueOf", "(method) valueOf(): string | number");
verify.memberListContains("toString", "(property) toString: ((radix?: number) => string) | (() => string)");
verify.memberListContains("valueOf", "(method) valueOf(): number | string");
verify.memberListCount(2);
@@ -16,7 +16,7 @@
//// function func2({ a, b/*parameter2*/
test.markers().forEach((m) => {
test.markers().forEach(m => {
goTo.position(m.position, m.fileName);
verify.completionListIsEmpty();
});
@@ -3,10 +3,10 @@
//// class A {
//// foo: string;
//// }
//// class C extends A {
//// baz: string;
//// class C {
//// foo: string;
//// }
//// var xs /*1*/ = [(x: A) => { return x.foo; }, (x: C) => { return x.baz; }];
//// var xs /*1*/ = [(x: A) => { return x.foo; }, (x: C) => { return x.foo; }];
//// xs.forEach(y => y(new /*2*/A()));
verify.numberOfErrorsInCurrentFile(0);
@@ -24,7 +24,7 @@
////var x4: I = [a, b, c];
////var /*4*/r4 = x4[1];
////var /*5*/x5 = [a, b, c, d];
////var /*5*/x5 = [a, b];
////var /*6*/r5 = x5[1];
// the above code should have a couple errors that will need to be updated with appropriate new (non-error) code and quick info checks
@@ -43,7 +43,21 @@ goTo.marker('4');
verify.quickInfoIs('var r4: C');
goTo.marker('5');
verify.quickInfoIs('var x5: C[]');
verify.quickInfoIs('var x5: ({\n\
name: string;\n\
age: number;\n\
} | {\n\
name: string;\n\
age: number;\n\
dob: Date;\n\
})[]');
goTo.marker('6');
verify.quickInfoIs('var r5: C');
verify.quickInfoIs('var r5: {\n\
name: string;\n\
age: number;\n\
} | {\n\
name: string;\n\
age: number;\n\
dob: Date;\n\
}');
@@ -0,0 +1,19 @@
/// <reference path='fourslash.ts'/>
////interface I {
//// [|property1|]: number;
//// property2: string;
////}
////
////var foo: I;
////var { [|property1|]: prop1 } = foo;
let ranges = test.ranges();
for (let range of ranges) {
goTo.position(range.start);
verify.referencesCountIs(ranges.length);
for (let expectedRange of ranges) {
verify.referencesAtPositionContains(expectedRange);
}
}
@@ -0,0 +1,19 @@
/// <reference path='fourslash.ts'/>
////interface I {
//// [|property1|]: number;
//// property2: string;
////}
////
////var foo: I;
////var { [|property1|]: {} } = foo;
let ranges = test.ranges();
for (let range of ranges) {
goTo.position(range.start);
verify.referencesCountIs(ranges.length);
for (let expectedRange of ranges) {
verify.referencesAtPositionContains(expectedRange);
}
}
@@ -0,0 +1,19 @@
/// <reference path='fourslash.ts'/>
////interface I {
//// [|property1|]: number;
//// property2: string;
////}
////
////var foo: I;
////var [{ [|property1|]: prop1 }, { property1, property2 } ] = [foo, foo];
let ranges = test.ranges();
for (let range of ranges) {
goTo.position(range.start);
verify.referencesCountIs(ranges.length);
for (let expectedRange of ranges) {
verify.referencesAtPositionContains(expectedRange);
}
}
@@ -0,0 +1,23 @@
/// <reference path='fourslash.ts'/>
////interface I {
//// [|property1|]: number;
//// property2: string;
////}
////
////function f({ /**/[|property1|]: p1 }: I,
//// { /*SHOULD_BE_A_REFERENCE*/property1 }: I,
//// { property1: p2 }) {
////
//// return property1 + 1;
////}
// NOTE: In the future, the identifier at
// SHOULD_BE_A_REFERENCE should be in the set of ranges.
goTo.marker();
let ranges = test.ranges();
verify.referencesCountIs(ranges.length);
for (let expectedRange of ranges) {
verify.referencesAtPositionContains(expectedRange);
}
@@ -0,0 +1,13 @@
/// <reference path='fourslash.ts'/>
////interface I {
//// property1: number;
//// property2: string;
////}
////
////function f({ /**/property1: p }, { property1 }) {
//// let x = property1;
////}
goTo.marker();
verify.referencesCountIs(0);
@@ -0,0 +1,30 @@
/// <reference path='fourslash.ts'/>
////interface I {
//// [|property1|]: number;
//// property2: string;
////}
////
////var elems: I[];
////for (let { [|property1|]: p } of elems) {
////}
////for (let { property1 } of elems) {
////}
////for (var { [|property1|]: p1 } of elems) {
////}
////var p2;
////for ({ property1 : p2 } of elems) {
////}
// Note: if this test ever changes, consider updating
// 'quickInfoForObjectBindingElementPropertyName05.ts'
let ranges = test.ranges();
for (let range of ranges) {
goTo.position(range.start);
verify.referencesCountIs(ranges.length);
for (let expectedRange of ranges) {
verify.referencesAtPositionContains(expectedRange);
}
}
@@ -0,0 +1,15 @@
/// <reference path='fourslash.ts'/>
////let p, b;
////
////p, [{ [|a|]: p, b }] = [{ [|a|]: 10, b: true }];
let ranges = test.ranges();
for (let range of ranges) {
goTo.position(range.start);
verify.referencesCountIs(ranges.length);
for (let expectedRange of ranges) {
verify.referencesAtPositionContains(expectedRange);
}
}
@@ -0,0 +1,23 @@
/// <reference path='fourslash.ts'/>
////interface I {
//// /*SHOULD_BE_A_REFERENCE1*/property1: number;
//// property2: string;
////}
////
////function f({ /*SHOULD_BE_A_REFERENCE2*/property1: p1 }: I,
//// { /**/[|property1|] }: I,
//// { property1: p2 }) {
////
//// return [|property1|] + 1;
////}
// NOTE: In the future, the identifiers at
// SHOULD_BE_A_REFERENCE[1/2] should be in the set of ranges.
goTo.marker();
let ranges = test.ranges();
verify.referencesCountIs(ranges.length);
for (let expectedRange of ranges) {
verify.referencesAtPositionContains(expectedRange);
}
@@ -0,0 +1,19 @@
/// <reference path='fourslash.ts'/>
////interface Recursive {
//// [|next|]?: Recursive;
//// value: any;
////}
////
////function f ({ [|next|]: { [|next|]: x} }: Recursive) {
////}
let ranges = test.ranges();
for (let range of ranges) {
goTo.position(range.start);
verify.referencesCountIs(ranges.length);
for (let expectedRange of ranges) {
verify.referencesAtPositionContains(expectedRange);
}
}
@@ -0,0 +1,13 @@
/// <reference path='fourslash.ts'/>
////declare function f<T>(x: T, y: (p: T) => T, z: (p: T) => T): T;
////var /*1*/result = /*2*/f(0, /*3*/x => null, /*4*/x => x.blahblah);
goTo.marker('1');
verify.quickInfoIs('var result: number');
goTo.marker('2');
verify.quickInfoIs('function f<number>(x: number, y: (p: number) => number, z: (p: number) => number): number');
goTo.marker('3');
verify.quickInfoIs('(parameter) x: number');
goTo.marker('4');
verify.quickInfoIs('(parameter) x: number');
@@ -0,0 +1,37 @@
/// <reference path='fourslash.ts'/>
////var x = 1;
////x
/////*1*/.toFixed
////x
/////*2*/.toFixed()
////x
/////*3*/.toFixed()
/////*4*/.length
/////*5*/.toString();
////x
/////*6*/.toFixed
/////*7*/.toString()
/////*8*/.length;
format.document();
goTo.marker('1');
verify.currentLineContentIs(' .toFixed');
goTo.marker('2');
verify.currentLineContentIs(' .toFixed()');
goTo.marker('3');
verify.currentLineContentIs(' .toFixed()');
goTo.marker('4');
verify.currentLineContentIs(' .length');
goTo.marker('5');
verify.currentLineContentIs(' .toString();');
goTo.marker('6');
verify.currentLineContentIs(' .toFixed');
goTo.marker('7');
verify.currentLineContentIs(' .toString()');
goTo.marker('8');
verify.currentLineContentIs(' .length;');
+38 -27
View File
@@ -29,7 +29,34 @@
// type 'fs.' as an alternate way of accessing the top-level objects
// (e.g. 'fs.goTo.eof();')
//---------------------------------------
// For API editors:
// When editting this file, and only while editing this file, enable the reference comments
// and comment out the declarations in this section to get proper type information.
// Undo these changes before compiling/committing/editing any other fourslash tests.
// The test suite will likely crash if you try 'jake runtests' with reference comments enabled.
//
// Explanation:
// We want type-completion while we edit this file, but at compile time/while editting fourslash tests,
// we don't want to include the following reference because we are compiling this file in "--out" mode and don't want to rope
// in the entire codebase into the compilation each fourslash test. Additionally, we don't want to expose the
// src/harness/fourslash.ts API's (or the rest of the compiler) because they are unstable and complicate the
// fourslash testing DSL. Finally, in this case, runtime reflection is (much) faster.
//
// TODO: figure out a better solution to the API exposure problem.
// /// <reference path="../../../built/local/typescriptServices.d.ts"/>
// /// <reference path="../../../src/harness/fourslash.ts"/>
declare var FourSlash;
module ts {
export interface SymbolDisplayPart {
text: string;
kind: string;
}
}
//---------------------------------------------
// Return code used by getEmitOutput function to indicate status of the function
// It is a duplicate of the one in types.ts to expose it to testcases in fourslash
@@ -42,7 +69,6 @@ enum EmitReturnStatus {
}
module FourSlashInterface {
declare var FourSlash;
export interface Marker {
fileName: string;
@@ -201,15 +227,6 @@ module FourSlashInterface {
FourSlash.currentTestState.verifyReferencesAtPositionListContains(range.fileName, range.start, range.end, isWriteAccess);
}
public implementorsCountIs(count: number) {
FourSlash.currentTestState.verifyImplementorsCountIs(count);
}
// Add tests for this.
public currentParameterIsVariable() {
FourSlash.currentTestState.verifyCurrentParameterIsVariable(!this.negative);
}
public signatureHelpPresent() {
FourSlash.currentTestState.verifySignatureHelpPresent(!this.negative);
}
@@ -361,14 +378,11 @@ module FourSlashInterface {
FourSlash.currentTestState.verifyNoMatchingBracePosition(bracePosition);
}
public setVerifyDocComments(val: boolean) {
FourSlash.currentTestState.setVerifyDocComments(val);
}
public getScriptLexicalStructureListCount(count: number) {
FourSlash.currentTestState.verifyGetScriptLexicalStructureListCount(count);
}
// TODO: figure out what to do with the unused arguments.
public getScriptLexicalStructureListContains(
name: string,
kind: string,
@@ -376,13 +390,7 @@ module FourSlashInterface {
parentName?: string,
isAdditionalSpan?: boolean,
markerPosition?: number) {
FourSlash.currentTestState.verifGetScriptLexicalStructureListContains(
name,
kind,
fileName,
parentName,
isAdditionalSpan,
markerPosition);
FourSlash.currentTestState.verifyGetScriptLexicalStructureListContains(name, kind);
}
public navigationItemsListCount(count: number, searchValue: string, matchKind?: string) {
@@ -413,6 +421,14 @@ module FourSlashInterface {
FourSlash.currentTestState.verifyOccurrencesAtPositionListCount(expectedCount);
}
public documentHighlightsAtPositionContains(range: Range, fileNamesToSearch: string[], kind?: string) {
FourSlash.currentTestState.verifyDocumentHighlightsAtPositionListContains(range.fileName, range.start, range.end, fileNamesToSearch, kind);
}
public documentHighlightsAtPositionCount(expectedCount: number, fileNamesToSearch: string[]) {
FourSlash.currentTestState.verifyDocumentHighlightsAtPositionListCount(expectedCount, fileNamesToSearch);
}
public completionEntryDetailIs(entryName: string, text: string, documentation?: string, kind?: string) {
FourSlash.currentTestState.verifyCompletionEntryDetails(entryName, text, documentation, kind);
}
@@ -698,12 +714,7 @@ module fs {
export var format = new FourSlashInterface.format();
export var cancellation = new FourSlashInterface.cancellation();
}
module ts {
export interface SymbolDisplayPart {
text: string;
kind: string;
}
}
function verifyOperationIsCancelled(f) {
FourSlash.verifyOperationIsCancelled(f);
}
+3 -3
View File
@@ -110,7 +110,7 @@ goTo.marker('15');
verify.quickInfoIs('var r4a: Collection<number, any>');
goTo.marker('17');
verify.quickInfoIs('var r5a: Collection<T, V>'); // This is actually due to an error because toFixed does not return a Date
verify.quickInfoIs('var r5a: Collection<number, Date>');
goTo.marker('18');
verify.quickInfoIs('var r5b: Collection<number, Date>');
@@ -122,10 +122,10 @@ goTo.marker('20');
verify.quickInfoIs('var r6b: Collection<Collection<number, number>, Date>');
goTo.marker('21');
verify.quickInfoIs('var r7a: Collection<T, V>'); // This call is an error because y.foo() does not return a string
verify.quickInfoIs('var r7a: Collection<number, string>');
goTo.marker('22');
verify.quickInfoIs('var r7b: Collection<T, V>'); // This call is an error because y.foo() does not return a string
verify.quickInfoIs('var r7b: Collection<number, string>');
goTo.marker('23');
verify.quickInfoIs('var r8a: Collection<number, string>');
@@ -18,9 +18,9 @@
////var /*4*/r4 = _./*41*/all([<any>true], _.identity);
goTo.marker('1');
verify.quickInfoIs('var r: string | number | boolean');
verify.quickInfoIs('var r: boolean | number | string');
goTo.marker('11');
verify.quickInfoIs('(method) Underscore.Static.all<string | number | boolean>(list: (string | number | boolean)[], iterator?: Underscore.Iterator<string | number | boolean, boolean>, context?: any): string | number | boolean');
verify.quickInfoIs('(method) Underscore.Static.all<boolean | number | string>(list: (boolean | number | string)[], iterator?: Underscore.Iterator<boolean | number | string, boolean>, context?: any): boolean | number | string');
goTo.marker('2');
verify.quickInfoIs('var r2: boolean');
@@ -18,9 +18,9 @@
////var /*4*/r4 = _./*41*/all([<any>true], _.identity);
goTo.marker('1');
verify.quickInfoIs('var r: string | number | boolean');
verify.quickInfoIs('var r: boolean | number | string');
goTo.marker('11');
verify.quickInfoIs('(method) Underscore.Static.all<string | number | boolean>(list: (string | number | boolean)[], iterator?: Underscore.Iterator<string | number | boolean, boolean>, context?: any): string | number | boolean');
verify.quickInfoIs('(method) Underscore.Static.all<boolean | number | string>(list: (boolean | number | string)[], iterator?: Underscore.Iterator<boolean | number | string, boolean>, context?: any): boolean | number | string');
goTo.marker('2');
verify.quickInfoIs('var r2: boolean');
@@ -0,0 +1,14 @@
/// <reference path='fourslash.ts'/>
////interface I {
//// /*def*/property1: number;
//// property2: string;
////}
////
////var foo: I;
////var { /*use*/property1: prop1 } = foo;
goTo.marker("use");
verify.definitionLocationExists();
goTo.definition();
verify.caretAtMarker("def");
@@ -19,8 +19,8 @@
goTo.marker("propertyReference");
verify.definitionCountIs(2);
goTo.definition(0);
verify.caretAtMarker("propertyDefinition1");
verify.caretAtMarker("propertyDefinition2");
goTo.marker("propertyReference");
goTo.definition(1);
verify.caretAtMarker("propertyDefinition2");
verify.caretAtMarker("propertyDefinition1");
@@ -0,0 +1,12 @@
/// <reference path='fourslash.ts'/>
////interface I {
//// property1: number;
//// property2: string;
////}
////
////var foo: I;
////var { /**/property1 } = foo;
goTo.marker();
verify.quickInfoIs("var property1: number");
@@ -0,0 +1,12 @@
/// <reference path='fourslash.ts'/>
////interface I {
//// property1: number;
//// property2: string;
////}
////
////var foo: I;
////var { property1: /**/prop1 } = foo;
goTo.marker();
verify.quickInfoIs("var prop1: number");

Some files were not shown because too many files have changed in this diff Show More