8000 test(eslint-plugin): [unified-signatures] add tests for #740 (#1074) · lipis/typescript-eslint@39f654b · GitHub
[go: up one dir, main page]

Skip to content

Commit 39f654b

Browse files
komkanitbradzacher
andcommitted
test(eslint-plugin): [unified-signatures] add tests for typescript-eslint#740 (typescript-eslint#1074)
Co-authored-by: Brad Zacher <brad.zacher@gmail.com>
1 parent 5362561 commit 39f654b

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

packages/eslint-plugin/tests/rules/unified-signatures.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,27 @@ declare module "foo" {
136136
`,
137137
`
138138
export default function(foo: number): string[];
139+
`,
140+
// https://github.com/typescript-eslint/typescript-eslint/issues/740
141+
`
142+
function p(key: string): Promise<string | undefined>
143+
function p(key: string, defaultValue: string): Promise<string>
144+
function p(key: string, defaultValue?: string): Promise<string | undefined>
145+
{
146+
const obj: Record<string, string> = { }
147+
return obj[key] || defaultValue
148+
}
149+
`,
150+
`
151+
interface I {
152+
p<T>(x: T): Promise<T>;
153+
p(x: number): Promise<number>;
154+
}
155+
`,
156+
`
157+
function rest(...xs: number[]): Promise<number[]>;
158+
function rest(xs: number[], y: string): Promise<string>;
159+
async function rest(...args: any[], y?: string): Promise<number[] | string> { return y || args }
139160
`,
140161
],
141162
invalid: [

0 commit comments

Comments
 (0)
0