This repository has been archived by the owner on Mar 25, 2021. It is now read-only.
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.
CI testNext failures with typescript@3.7.0-dev.20190928 #4863
Closed
Description
test/rules/return-undefined/default/test.ts.lint: Failed!
Expected (from .lint file)
Actual (from TSLint)
class Promise<T> {
then(): Promise<T>;
}
function valueWrong(): number | undefined {
return;
~~~~~~~ [Value-returning function should use `return undefined;`, not just `return;`.]
}
function valueRight(): number | undefined {
return undefined;
}
function voidWrong(): void {
return undefined;
~~~~~~~~~~~~~~~~~ [`void` function should use `return;`, not `return undefined;`.]
}
function voidRight(): void {
return;
}
// Infers type from context.
[].forEach(() => {
return undefined;
~~~~~~~~~~~~~~~~~ [`void` function should use `return;`, not `return undefined;`.]
});
[].map<number | undefined>(() => {
return;
~~~~~~~ [Value-returning function should use `return undefined;`, not just `return;`.]
});
type Cb = () => void;
declare function badContextualType(cb: Cb | Cb[]): void;
// Uses typeAtLocation instead of contextual type.
badContextualType(() => {
if (1 === 2) return 1;
else return;
~~~~~~~ [Value-returning function should use `return undefined;`, not just `return;`.]
});
// Allow anything in callback taking 'any'.
function takesAnyCb(cb: () => any): void;
takesAnyCb(() => { return; });
takesAnyCb(() => { return undefined; });
takesAnyCb(() => {
if (1 === 2) return;
else return 1;
});
takesAnyCb(() => {
if (1 === 2) return;
else return undefined;
});
takesAnyCb((): void => {
if (1 === 2) return;
else return undefined;
~~~~~~~~~~~~~~~~~ [`void` function should use `return;`, not `return undefined;`.]
});
async function promiseVoid(): Promise<void> {
if (1 === 2) return;
- ~~~~~~~ [Value-returning function should use `return undefined;`, not just `return;`.]
else return undefined;
+ ~~~~~~~~~~~~~~~~~ [`void` function should use `return;`, not `return undefined;`.]
}
async function promiseValue(): Promise<number | undefined> {
if (1 === 2) return 1;
else return;
~~~~~~~ [Value-returning function should use `return undefined;`, not just `return;`.]
}
declare function test(cb: () => Promise<void> | void): void;
test(async () => {
if (1 === 2) return;
- ~~~~~~~ [Value-returning function should use `return undefined;`, not just `return;`.]
else return undefined;
+ ~~~~~~~~~~~~~~~~~ [`void` function should use `return;`, not `return undefined;`.]
});
function * generator(returnNothing: boolean) {
if (returnNothing) return;
yield 1;
return yield * [2, 3];
}
class ClassWithGeneratorMethod {
* generatorMethod(returnNothing: boolean) {
if (returnNothing) return;
yield 1;
}
}