mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 11:35:42 -06:00
Add tests for not depending on base types
This commit is contained in:
parent
3b1c833d67
commit
8bf012b566
38
tests/baselines/reference/classDoesNotDependOnBaseTypes.js
Normal file
38
tests/baselines/reference/classDoesNotDependOnBaseTypes.js
Normal 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);
|
||||
@ -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
|
||||
|
||||
@ -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([""]);
|
||||
}
|
||||
@ -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
|
||||
|
||||
@ -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 { }
|
||||
@ -0,0 +1,8 @@
|
||||
var x: StringTree;
|
||||
if (typeof x !== "string") {
|
||||
x.push("");
|
||||
x.push([""]);
|
||||
}
|
||||
|
||||
type StringTree = string | StringTreeArray;
|
||||
interface StringTreeArray extends Array<StringTree> { }
|
||||
Loading…
x
Reference in New Issue
Block a user