Add tests for not depending on base types

This commit is contained in:
Jason Freeman 2015-04-16 18:14:25 -07:00
parent 3b1c833d67
commit 8bf012b566
6 changed files with 153 additions and 0 deletions

View File

@ -0,0 +1,38 @@
//// [classDoesNotDependOnBaseTypes.ts]
var x: StringTree;
if (typeof x !== "string") {
x[0] = "";
x[0] = new StringTreeCollection;
}
type StringTree = string | StringTreeCollection;
class StringTreeCollectionBase {
[n: number]: StringTree;
}
class StringTreeCollection extends StringTreeCollectionBase { }
//// [classDoesNotDependOnBaseTypes.js]
var __extends = this.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
};
var x;
if (typeof x !== "string") {
x[0] = "";
x[0] = new StringTreeCollection;
}
var StringTreeCollectionBase = (function () {
function StringTreeCollectionBase() {
}
return StringTreeCollectionBase;
})();
var StringTreeCollection = (function (_super) {
__extends(StringTreeCollection, _super);
function StringTreeCollection() {
_super.apply(this, arguments);
}
return StringTreeCollection;
})(StringTreeCollectionBase);

View File

@ -0,0 +1,43 @@
=== tests/cases/conformance/types/typeAliases/classDoesNotDependOnBaseTypes.ts ===
var x: StringTree;
>x : string | StringTreeCollection
>StringTree : string | StringTreeCollection
if (typeof x !== "string") {
>typeof x !== "string" : boolean
>typeof x : string
>x : string | StringTreeCollection
>"string" : string
x[0] = "";
>x[0] = "" : string
>x[0] : string | StringTreeCollection
>x : StringTreeCollection
>0 : number
>"" : string
x[0] = new StringTreeCollection;
>x[0] = new StringTreeCollection : StringTreeCollection
>x[0] : string | StringTreeCollection
>x : StringTreeCollection
>0 : number
>new StringTreeCollection : StringTreeCollection
>StringTreeCollection : typeof StringTreeCollection
}
type StringTree = string | StringTreeCollection;
>StringTree : string | StringTreeCollection
>StringTreeCollection : StringTreeCollection
class StringTreeCollectionBase {
>StringTreeCollectionBase : StringTreeCollectionBase
[n: number]: StringTree;
>n : number
>StringTree : string | StringTreeCollection
}
class StringTreeCollection extends StringTreeCollectionBase { }
>StringTreeCollection : StringTreeCollection
>StringTreeCollectionBase : StringTreeCollectionBase

View File

@ -0,0 +1,16 @@
//// [interfaceDoesNotDependOnBaseTypes.ts]
var x: StringTree;
if (typeof x !== "string") {
x.push("");
x.push([""]);
}
type StringTree = string | StringTreeArray;
interface StringTreeArray extends Array<StringTree> { }
//// [interfaceDoesNotDependOnBaseTypes.js]
var x;
if (typeof x !== "string") {
x.push("");
x.push([""]);
}

View File

@ -0,0 +1,36 @@
=== tests/cases/conformance/types/typeAliases/interfaceDoesNotDependOnBaseTypes.ts ===
var x: StringTree;
>x : string | StringTreeArray
>StringTree : string | StringTreeArray
if (typeof x !== "string") {
>typeof x !== "string" : boolean
>typeof x : string
>x : string | StringTreeArray
>"string" : string
x.push("");
>x.push("") : number
>x.push : (...items: (string | StringTreeArray)[]) => number
>x : StringTreeArray
>push : (...items: (string | StringTreeArray)[]) => number
>"" : string
x.push([""]);
>x.push([""]) : number
>x.push : (...items: (string | StringTreeArray)[]) => number
>x : StringTreeArray
>push : (...items: (string | StringTreeArray)[]) => number
>[""] : string[]
>"" : string
}
type StringTree = string | StringTreeArray;
>StringTree : string | StringTreeArray
>StringTreeArray : StringTreeArray
interface StringTreeArray extends Array<StringTree> { }
>StringTreeArray : StringTreeArray
>Array : T[]
>StringTree : string | StringTreeArray

View File

@ -0,0 +1,12 @@
var x: StringTree;
if (typeof x !== "string") {
x[0] = "";
x[0] = new StringTreeCollection;
}
type StringTree = string | StringTreeCollection;
class StringTreeCollectionBase {
[n: number]: StringTree;
}
class StringTreeCollection extends StringTreeCollectionBase { }

View File

@ -0,0 +1,8 @@
var x: StringTree;
if (typeof x !== "string") {
x.push("");
x.push([""]);
}
type StringTree = string | StringTreeArray;
interface StringTreeArray extends Array<StringTree> { }