You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.
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;
}
}
The text was updated successfully, but these errors were encountered:
https://circleci.com/gh/palantir/tslint/17859?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link
The text was updated successfully, but these errors were encountered: