Typescript: Same type referenced multiple times in param doesnt throw error

Created on 7 Sep 2019  ·  1Comment  ·  Source: microsoft/TypeScript


TypeScript Version: 3.6.2


Search Terms:

Code

type A = {first: string};
type B = {second: string};


function test(props: A&B &A) {
}

Expected behavior:

Should throw error cause A is used multiple times in type definition of props

Actual behavior:
No error is thrown

Playground Link:

http://www.typescriptlang.org/play/#code/C4TwDgpgBAglC8UDeAzAlgJwM7AFxRwzQDsBzAXwG4AoUSKAIQWSwgGMB7YgE30JIo1q1FAFdibYGi5RgEHAAowGDmCz4YAMiaaYASmTDyQA

Related Issues:

Most helpful comment

Intersection is idempotent, so flagging an error here would be incorrect.

If anything, this would be more suitable as a lint rule, IMO.

>All comments

Intersection is idempotent, so flagging an error here would be incorrect.

If anything, this would be more suitable as a lint rule, IMO.

Was this page helpful?
0 / 5 - 0 ratings