TypeScript/tests/baselines/reference/weakType.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

185 lines
4.2 KiB
Plaintext

=== tests/cases/compiler/weakType.ts ===
interface Settings {
>Settings : Settings
timeout?: number;
>timeout : number
onError?(): void;
>onError : () => void
}
function getDefaultSettings() {
>getDefaultSettings : () => { timeout: number; }
return { timeout: 1000 };
>{ timeout: 1000 } : { timeout: number; }
>timeout : number
>1000 : 1000
}
interface CtorOnly {
>CtorOnly : CtorOnly
new(s: string): { timeout: 1000 }
>s : string
>timeout : 1000
}
function doSomething(settings: Settings) { /* ... */ }
>doSomething : (settings: Settings) => void
>settings : Settings
>Settings : Settings
// forgot to call `getDefaultSettings`
doSomething(getDefaultSettings);
>doSomething(getDefaultSettings) : void
>doSomething : (settings: Settings) => void
>getDefaultSettings : () => { timeout: number; }
doSomething(() => ({ timeout: 1000 }));
>doSomething(() => ({ timeout: 1000 })) : void
>doSomething : (settings: Settings) => void
>() => ({ timeout: 1000 }) : () => { timeout: number; }
>({ timeout: 1000 }) : { timeout: number; }
>{ timeout: 1000 } : { timeout: number; }
>timeout : number
>1000 : 1000
doSomething(null as CtorOnly);
>doSomething(null as CtorOnly) : void
>doSomething : (settings: Settings) => void
>null as CtorOnly : CtorOnly
>null : null
>CtorOnly : CtorOnly
doSomething(12);
>doSomething(12) : void
>doSomething : (settings: Settings) => void
>12 : 12
doSomething('completely wrong');
>doSomething('completely wrong') : void
>doSomething : (settings: Settings) => void
>'completely wrong' : "completely wrong"
doSomething(false);
>doSomething(false) : void
>doSomething : (settings: Settings) => void
>false : false
// this is an oddly popular way of defining settings
// this example is from services/textChanges.ts
type ConfigurableStart = { useStart?: boolean }
>ConfigurableStart : ConfigurableStart
>useStart : boolean
type ConfigurableEnd = { useEnd?: boolean }
>ConfigurableEnd : ConfigurableEnd
>useEnd : boolean
type ConfigurableStartEnd = ConfigurableStart & ConfigurableEnd
>ConfigurableStartEnd : ConfigurableStartEnd
>ConfigurableStart : ConfigurableStart
>ConfigurableEnd : ConfigurableEnd
interface InsertOptions {
>InsertOptions : InsertOptions
prefix?: string
>prefix : string
suffix?: string
>suffix : string
}
type ChangeOptions = ConfigurableStartEnd & InsertOptions;
>ChangeOptions : ChangeOptions
>ConfigurableStartEnd : ConfigurableStartEnd
>InsertOptions : InsertOptions
function del(options: ConfigurableStartEnd = {},
>del : (options?: ConfigurableStartEnd, error?: { error?: number; }) => void
>options : ConfigurableStartEnd
>ConfigurableStartEnd : ConfigurableStartEnd
>{} : {}
error: { error?: number } = {}) {
>error : { error?: number; }
>error : number
>{} : {}
let changes: ChangeOptions[];
>changes : ChangeOptions[]
>ChangeOptions : ChangeOptions
changes.push(options);
>changes.push(options) : number
>changes.push : (...items: ChangeOptions[]) => number
>changes : ChangeOptions[]
>push : (...items: ChangeOptions[]) => number
>options : ConfigurableStartEnd
changes.push(error);
>changes.push(error) : number
>changes.push : (...items: ChangeOptions[]) => number
>changes : ChangeOptions[]
>push : (...items: ChangeOptions[]) => number
>error : { error?: number; }
}
class K {
>K : K
constructor(s: string) { }
>s : string
}
// Ctor isn't a weak type because it has a construct signature
interface Ctor {
>Ctor : Ctor
new (s: string): K
>s : string
>K : K
n?: number
>n : number
}
let ctor: Ctor = K
>ctor : Ctor
>Ctor : Ctor
>K : typeof K
type Spoiler = { nope?: string }
>Spoiler : Spoiler
>nope : string
type Weak = {
>Weak : Weak
a?: number
>a : number
properties?: {
>properties : { b?: number; }
b?: number
>b : number
}
}
declare let unknown: {
>unknown : { properties: { wrong: string; }; }
properties: {
>properties : { wrong: string; }
wrong: string
>wrong : string
}
}
let weak: Weak & Spoiler = unknown
>weak : Weak & Spoiler
>Weak : Weak
>Spoiler : Spoiler
>unknown : { properties: { wrong: string; }; }