TypeScript/tests/baselines/reference/bestCommonTypeWithContextualTyping.js
Sheetal Nandi 6ab3adfd43 Modified the emitComment logic to handle emitting leading or trailing spaces depending on flags
Leading comments have trailing separator while trailing comments have leading space
This removes the extra trailing space in the trailing comments
2014-08-15 14:32:08 -07:00

32 lines
1 KiB
JavaScript

//// [bestCommonTypeWithContextualTyping.ts]
interface Contextual {
dummy;
p?: number;
}
interface Ellement {
dummy;
p: any;
}
var e: Ellement;
// All of these should pass. Neither type is a supertype of the other, but the RHS should
// always use Ellement in these examples (not Contextual). Because Ellement is assignable
// to Contextual, no errors.
var arr: Contextual[] = [e]; // Ellement[]
var obj: { [s: string]: Contextual } = { s: e }; // { s: Ellement; [s: string]: Ellement }
var conditional: Contextual = null ? e : e; // Ellement
var contextualOr: Contextual = e || e; // Ellement
//// [bestCommonTypeWithContextualTyping.js]
var e;
// All of these should pass. Neither type is a supertype of the other, but the RHS should
// always use Ellement in these examples (not Contextual). Because Ellement is assignable
// to Contextual, no errors.
var arr = [e]; // Ellement[]
var obj = { s: e }; // { s: Ellement; [s: string]: Ellement }
var conditional = null ? e : e; // Ellement
var contextualOr = e || e; // Ellement