TypeScript/tests/baselines/reference/jsdocTypeTagCast.types
Wesley Wigham 5353475fce Always collect type and symbol baselines (#18621)
* Always generate type & symbol baselines

* Accept changed shadowed baselines

* Accept brand new type and symbol baselines

* Allow `getTypeAtLocation` to return undefined in the type writer

* Accept baselines which had missing type information

* Bind container for dynamically names enum members so they may be printed

* Accept type/symbol baselines for enums with computed members

* First pass at reducing typeWriter memory overhead

* Use generators to allow for type and symbol baselines with no cache

* Accept new baselines for tests whose output was fixed by better newline splitting

* Hard cap on number of declarations printed, cache declaration print text

* handle differing newlines better still to handle RWC newlines

* Lower abridging count, accept abridged baselines

* Limit max RWC error output size, limit RWC type and symbol baseline input size

* Move skip logic into type and symbol baseliner to streamline error handling

* Accept removal of empty baselines

* Canonicalize path earlier to handle odd paths in input files

* Do canonicalization earlier still, also ensure parallel perf profiles for different targets do not trample one another

* No need to pathify again
2017-09-22 15:52:04 -07:00

213 lines
5 KiB
Plaintext

=== tests/cases/conformance/jsdoc/a.ts ===
var W: string;
>W : string
=== tests/cases/conformance/jsdoc/b.js ===
// @ts-check
var W = /** @type {string} */(/** @type {*} */ (4));
>W : string
>(/** @type {*} */ (4)) : string
>(4) : any
>4 : 4
var W = /** @type {string} */(4); // Error
>W : string
>(4) : string
>4 : 4
/** @type {*} */
var a;
>a : any
/** @type {string} */
var s;
>s : string
var a = /** @type {*} */("" + 4);
>a : any
>("" + 4) : any
>"" + 4 : string
>"" : ""
>4 : 4
var s = "" + /** @type {*} */(4);
>s : string
>"" + /** @type {*} */(4) : string
>"" : ""
>(4) : any
>4 : 4
class SomeBase {
>SomeBase : SomeBase
constructor() {
this.p = 42;
>this.p = 42 : 42
>this.p : number
>this : this
>p : number
>42 : 42
}
}
class SomeDerived extends SomeBase {
>SomeDerived : SomeDerived
>SomeBase : SomeBase
constructor() {
super();
>super() : void
>super : typeof SomeBase
this.x = 42;
>this.x = 42 : 42
>this.x : number
>this : this
>x : number
>42 : 42
}
}
class SomeOther {
>SomeOther : SomeOther
constructor() {
this.q = 42;
>this.q = 42 : 42
>this.q : number
>this : this
>q : number
>42 : 42
}
}
function SomeFakeClass() {
>SomeFakeClass : () => void
/** @type {string|number} */
this.p = "bar";
>this.p = "bar" : "bar"
>this.p : any
>this : any
>p : any
>"bar" : "bar"
}
// Type assertion should check for assignability in either direction
var someBase = new SomeBase();
>someBase : SomeBase
>new SomeBase() : SomeBase
>SomeBase : typeof SomeBase
var someDerived = new SomeDerived();
>someDerived : SomeDerived
>new SomeDerived() : SomeDerived
>SomeDerived : typeof SomeDerived
var someOther = new SomeOther();
>someOther : SomeOther
>new SomeOther() : SomeOther
>SomeOther : typeof SomeOther
var someFakeClass = new SomeFakeClass();
>someFakeClass : { p: string | number | undefined; }
>new SomeFakeClass() : { p: string | number | undefined; }
>SomeFakeClass : () => void
someBase = /** @type {SomeBase} */(someDerived);
>someBase = /** @type {SomeBase} */(someDerived) : SomeBase
>someBase : SomeBase
>(someDerived) : SomeBase
>someDerived : SomeDerived
someBase = /** @type {SomeBase} */(someBase);
>someBase = /** @type {SomeBase} */(someBase) : SomeBase
>someBase : SomeBase
>(someBase) : SomeBase
>someBase : SomeBase
someBase = /** @type {SomeBase} */(someOther); // Error
>someBase = /** @type {SomeBase} */(someOther) : SomeBase
>someBase : SomeBase
>(someOther) : SomeBase
>someOther : SomeOther
someDerived = /** @type {SomeDerived} */(someDerived);
>someDerived = /** @type {SomeDerived} */(someDerived) : SomeDerived
>someDerived : SomeDerived
>(someDerived) : SomeDerived
>someDerived : SomeDerived
someDerived = /** @type {SomeDerived} */(someBase);
>someDerived = /** @type {SomeDerived} */(someBase) : SomeDerived
>someDerived : SomeDerived
>(someBase) : SomeDerived
>someBase : SomeBase
someDerived = /** @type {SomeDerived} */(someOther); // Error
>someDerived = /** @type {SomeDerived} */(someOther) : SomeDerived
>someDerived : SomeDerived
>(someOther) : SomeDerived
>someOther : SomeOther
someOther = /** @type {SomeOther} */(someDerived); // Error
>someOther = /** @type {SomeOther} */(someDerived) : SomeOther
>someOther : SomeOther
>(someDerived) : SomeOther
>someDerived : SomeDerived
someOther = /** @type {SomeOther} */(someBase); // Error
>someOther = /** @type {SomeOther} */(someBase) : SomeOther
>someOther : SomeOther
>(someBase) : SomeOther
>someBase : SomeBase
someOther = /** @type {SomeOther} */(someOther);
>someOther = /** @type {SomeOther} */(someOther) : SomeOther
>someOther : SomeOther
>(someOther) : SomeOther
>someOther : SomeOther
someFakeClass = someBase;
>someFakeClass = someBase : SomeBase
>someFakeClass : { p: string | number | undefined; }
>someBase : SomeBase
someFakeClass = someDerived;
>someFakeClass = someDerived : SomeDerived
>someFakeClass : { p: string | number | undefined; }
>someDerived : SomeDerived
someBase = someFakeClass; // Error
>someBase = someFakeClass : { p: string | number | undefined; }
>someBase : SomeBase
>someFakeClass : { p: string | number | undefined; }
someBase = /** @type {SomeBase} */(someFakeClass);
>someBase = /** @type {SomeBase} */(someFakeClass) : SomeBase
>someBase : SomeBase
>(someFakeClass) : SomeBase
>someFakeClass : { p: string | number | undefined; }
// Type assertion cannot be a type-predicate type
/** @type {number | string} */
var numOrStr;
>numOrStr : string | number
/** @type {string} */
var str;
>str : string
if(/** @type {numOrStr is string} */(numOrStr === undefined)) { // Error
>(numOrStr === undefined) : string | number
>numOrStr === undefined : boolean
>numOrStr : string | number
>undefined : undefined
str = numOrStr; // Error, no narrowing occurred
>str = numOrStr : string | number
>str : string
>numOrStr : string | number
}