1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
tests/cases/compiler/uncalledFunctionChecksInConditional2.ts(20,5): error TS2774: This condition will always return true since this function is always defined. Did you mean to call it instead?
tests/cases/compiler/uncalledFunctionChecksInConditional2.ts(30,7): error TS2774: This condition will always return true since this function is always defined. Did you mean to call it instead?
tests/cases/compiler/uncalledFunctionChecksInConditional2.ts(49,5): error TS2774: This condition will always return true since this function is always defined. Did you mean to call it instead?
==== tests/cases/compiler/uncalledFunctionChecksInConditional2.ts (3 errors) ====
{
const perf = window.performance
// Simplified
if (
perf &&
perf.measure &&
perf.clearMarks &&
perf.clearMeasures
) {
perf.measure("");
perf.clearMarks("")
perf.clearMeasures("")
}
// With ||
if (
perf &&
perf.mark &&
perf.measure || !!true
~~~~~~~~~~~~
!!! error TS2774: This condition will always return true since this function is always defined. Did you mean to call it instead?
) {
perf.mark("");
}
// With ??
if (
(
perf &&
perf.mark &&
perf.measure
~~~~~~~~~~~~
!!! error TS2774: This condition will always return true since this function is always defined. Did you mean to call it instead?
) ?? !!true
) {
perf.mark("");
}
};
// Original #49192
declare let inBrowser: boolean;
{
let mark;
let measure;
const perf = inBrowser && window.performance
/* istanbul ignore if */
if (
perf &&
perf.mark &&
perf.measure &&
perf.clearMarks &&
perf.clearMeasures
~~~~~~~~~~~~~~~~~~
!!! error TS2774: This condition will always return true since this function is always defined. Did you mean to call it instead?
) {
mark = (tag) => perf.mark(tag)
measure = (name, startTag, endTag) => {
perf.measure(name, startTag, endTag)
perf.clearMarks(startTag)
perf.clearMarks(endTag)
// perf.clearMeasures(name)
}
}
};
|