merge with master

This commit is contained in:
Arthur Ozga
2015-08-04 18:04:55 -07:00
28 changed files with 413 additions and 112 deletions

View File

@@ -75,28 +75,28 @@ function delint(sourceFile) {
delintNode(sourceFile);
function delintNode(node) {
switch (node.kind) {
case 196 /* ForStatement */:
case 197 /* ForInStatement */:
case 195 /* WhileStatement */:
case 194 /* DoStatement */:
if (node.statement.kind !== 189 /* Block */) {
case 197 /* ForStatement */:
case 198 /* ForInStatement */:
case 196 /* WhileStatement */:
case 195 /* DoStatement */:
if (node.statement.kind !== 190 /* Block */) {
report(node, "A looping statement's contents should be wrapped in a block body.");
}
break;
case 193 /* IfStatement */:
case 194 /* IfStatement */:
var ifStatement = node;
if (ifStatement.thenStatement.kind !== 189 /* Block */) {
if (ifStatement.thenStatement.kind !== 190 /* Block */) {
report(ifStatement.thenStatement, "An if statement's contents should be wrapped in a block body.");
}
if (ifStatement.elseStatement &&
ifStatement.elseStatement.kind !== 189 /* Block */ &&
ifStatement.elseStatement.kind !== 193 /* IfStatement */) {
ifStatement.elseStatement.kind !== 190 /* Block */ &&
ifStatement.elseStatement.kind !== 194 /* IfStatement */) {
report(ifStatement.elseStatement, "An else statement's contents should be wrapped in a block body.");
}
break;
case 178 /* BinaryExpression */:
case 179 /* BinaryExpression */:
var op = node.operatorToken.kind;
if (op === 29 /* EqualsEqualsToken */ || op == 30 /* ExclamationEqualsToken */) {
if (op === 30 /* EqualsEqualsToken */ || op == 31 /* ExclamationEqualsToken */) {
report(node, "Use '===' and '!=='.");
}
break;

View File

@@ -139,14 +139,14 @@ var __extends = (this && this.__extends) || function (d, b) {
//super property access in instance member accessor(get and set) of class with no base type
var NoBase = (function () {
function NoBase() {
this.m = _super.prototype;
this.n = _super.hasOwnProperty.call(this, '');
var a = _super.prototype;
var b = _super.hasOwnProperty.call(this, '');
this.m = _super.prototype.prototype;
this.n = _super.prototype.hasOwnProperty.call(this, '');
var a = _super.prototype.prototype;
var b = _super.prototype.hasOwnProperty.call(this, '');
}
NoBase.prototype.fn = function () {
var a = _super.prototype;
var b = _super.hasOwnProperty.call(this, '');
var a = _super.prototype.prototype;
var b = _super.prototype.hasOwnProperty.call(this, '');
};
//super static property access in static member function of class with no base type
//super static property access in static member accessor(get and set) of class with no base type

View File

@@ -18,7 +18,7 @@ var C = (function () {
function C() {
}
C.prototype.foo = function () {
_super.foo.call(this);
_super.prototype.foo.call(this);
};
return C;
})();
@@ -30,7 +30,7 @@ var M1;
function C() {
}
C.prototype.foo = function () {
_super.foo.call(this);
_super.prototype.foo.call(this);
};
return C;
})();

View File

@@ -10,7 +10,7 @@ var C = (function () {
function C() {
}
C.prototype.M = function () {
_super..call(this, 0);
_super.prototype..call(this, 0);
};
return C;
})();

View File

@@ -18,7 +18,7 @@ var C = (function () {
function C() {
}
C.prototype.foo = function () {
_super.foo = 1;
_super.prototype.foo = 1;
};
return C;
})();
@@ -30,7 +30,7 @@ var M1;
function C() {
}
C.prototype.foo = function () {
_super.foo = 1;
_super.prototype.foo = 1;
};
return C;
})();

View File

@@ -0,0 +1,8 @@
//// [shebang.ts]
#!/usr/bin/env node
var foo = 'I wish the generated JS to be executed in node';
//// [shebang.js]
#!/usr/bin/env node
var foo = 'I wish the generated JS to be executed in node';

View File

@@ -0,0 +1,5 @@
=== tests/cases/compiler/shebang.ts ===
#!/usr/bin/env node
var foo = 'I wish the generated JS to be executed in node';
>foo : Symbol(foo, Decl(shebang.ts, 1, 3))

View File

@@ -0,0 +1,6 @@
=== tests/cases/compiler/shebang.ts ===
#!/usr/bin/env node
var foo = 'I wish the generated JS to be executed in node';
>foo : string
>'I wish the generated JS to be executed in node' : string

View File

@@ -0,0 +1,20 @@
tests/cases/compiler/shebangError.ts(2,1): error TS1127: Invalid character.
tests/cases/compiler/shebangError.ts(2,2): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/compiler/shebangError.ts(2,12): error TS2304: Cannot find name 'env'.
tests/cases/compiler/shebangError.ts(2,16): error TS1005: ';' expected.
tests/cases/compiler/shebangError.ts(2,16): error TS2304: Cannot find name 'node'.
==== tests/cases/compiler/shebangError.ts (5 errors) ====
var foo = 'Shebang is only allowed on the first line';
#!/usr/bin/env node
!!! error TS1127: Invalid character.
~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
~~~
!!! error TS2304: Cannot find name 'env'.
~~~~
!!! error TS1005: ';' expected.
~~~~
!!! error TS2304: Cannot find name 'node'.

View File

@@ -0,0 +1,8 @@
//// [shebangError.ts]
var foo = 'Shebang is only allowed on the first line';
#!/usr/bin/env node
//// [shebangError.js]
var foo = 'Shebang is only allowed on the first line';
!/usr/bin / env;
node;

View File

@@ -79,7 +79,7 @@ var Base2 = (function () {
function Base2() {
}
Base2.prototype.foo = function () {
_super.foo.call(this);
_super.prototype.foo.call(this);
};
return Base2;
})();

View File

@@ -165,7 +165,7 @@ var Base4;
function Sub4E() {
}
Sub4E.prototype.x = function () {
return _super.x.call(this);
return _super.prototype.x.call(this);
};
return Sub4E;
})();

View File

@@ -0,0 +1,15 @@
tests/cases/compiler/superCallWithMissingBaseClass.ts(1,19): error TS2304: Cannot find name 'Bar'.
==== tests/cases/compiler/superCallWithMissingBaseClass.ts (1 errors) ====
class Foo extends Bar {
~~~
!!! error TS2304: Cannot find name 'Bar'.
m1() {
return super.m1();
}
static m2() {
return super.m2();
}
}

View File

@@ -0,0 +1,30 @@
//// [superCallWithMissingBaseClass.ts]
class Foo extends Bar {
m1() {
return super.m1();
}
static m2() {
return super.m2();
}
}
//// [superCallWithMissingBaseClass.js]
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var Foo = (function (_super) {
__extends(Foo, _super);
function Foo() {
_super.apply(this, arguments);
}
Foo.prototype.m1 = function () {
return _super.prototype.m1.call(this);
};
Foo.m2 = function () {
return _super.m2.call(this);
};
return Foo;
})(Bar);

View File

@@ -0,0 +1,55 @@
//// [tests/cases/compiler/systemModuleWithSuperClass.ts] ////
//// [foo.ts]
export class Foo {
a: string;
}
//// [bar.ts]
import {Foo} from './foo';
export class Bar extends Foo {
b: string;
}
//// [foo.js]
System.register([], function(exports_1) {
var Foo;
return {
setters:[],
execute: function() {
Foo = (function () {
function Foo() {
}
return Foo;
})();
exports_1("Foo", Foo);
}
}
});
//// [bar.js]
System.register(['./foo'], function(exports_1) {
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var foo_1;
var Bar;
return {
setters:[
function (_foo_1) {
foo_1 = _foo_1;
}],
execute: function() {
Bar = (function (_super) {
__extends(Bar, _super);
function Bar() {
_super.apply(this, arguments);
}
return Bar;
})(foo_1.Foo);
exports_1("Bar", Bar);
}
}
});

View File

@@ -0,0 +1,20 @@
=== tests/cases/compiler/foo.ts ===
export class Foo {
>Foo : Symbol(Foo, Decl(foo.ts, 0, 0))
a: string;
>a : Symbol(a, Decl(foo.ts, 1, 18))
}
=== tests/cases/compiler/bar.ts ===
import {Foo} from './foo';
>Foo : Symbol(Foo, Decl(bar.ts, 0, 8))
export class Bar extends Foo {
>Bar : Symbol(Bar, Decl(bar.ts, 0, 26))
>Foo : Symbol(Foo, Decl(bar.ts, 0, 8))
b: string;
>b : Symbol(b, Decl(bar.ts, 1, 30))
}

View File

@@ -0,0 +1,20 @@
=== tests/cases/compiler/foo.ts ===
export class Foo {
>Foo : Foo
a: string;
>a : string
}
=== tests/cases/compiler/bar.ts ===
import {Foo} from './foo';
>Foo : typeof Foo
export class Bar extends Foo {
>Bar : Bar
>Foo : Foo
b: string;
>b : string
}

View File

@@ -0,0 +1,2 @@
#!/usr/bin/env node
var foo = 'I wish the generated JS to be executed in node';

View File

@@ -0,0 +1,2 @@
var foo = 'Shebang is only allowed on the first line';
#!/usr/bin/env node

View File

@@ -0,0 +1,9 @@
class Foo extends Bar {
m1() {
return super.m1();
}
static m2() {
return super.m2();
}
}

View File

@@ -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;
}