Skip to content

Commit

Permalink
test(eslint-plugin): [unified-signatures] add tests for #740 (#1074)
Browse files Browse the repository at this point in the history
Co-authored-by: Brad Zacher <brad.zacher@gmail.com>
  • Loading branch information
komkanit and bradzacher committed Dec 3, 2019
1 parent 5362561 commit 39f654b
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions packages/eslint-plugin/tests/rules/unified-signatures.test.ts
Expand Up @@ -136,6 +136,27 @@ declare module "foo" {
`,
`
export default function(foo: number): string[];
`,
// https://github.com/typescript-eslint/typescript-eslint/issues/740
`
function p(key: string): Promise<string | undefined>
function p(key: string, defaultValue: string): Promise<string>
function p(key: string, defaultValue?: string): Promise<string | undefined>
{
const obj: Record<string, string> = { }
return obj[key] || defaultValue
}
`,
`
interface I {
p<T>(x: T): Promise<T>;
p(x: number): Promise<number>;
}
`,
`
function rest(...xs: number[]): Promise<number[]>;
function rest(xs: number[], y: string): Promise<string>;
async function rest(...args: any[], y?: string): Promise<number[] | string> { return y || args }
`,
],
invalid: [
Expand Down

0 comments on commit 39f654b

Please sign in to comment.