Skip to content

Commit 1112dae

Browse files
authored
Add extra test for extending multiple bases with incompatible optional property under EOPT (#62574)
1 parent 91b32ac commit 1112dae

6 files changed

+229
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
//// [tests/cases/compiler/multipleBaseInterfaesWithIncompatibleProperties2.ts] ////
2+
3+
=== multipleBaseInterfaesWithIncompatibleProperties2.ts ===
4+
// https://github.com/microsoft/TypeScript/issues/62569
5+
6+
namespace http {
7+
>http : Symbol(http, Decl(multipleBaseInterfaesWithIncompatibleProperties2.ts, 0, 0))
8+
9+
export interface TcpSocketConnectOpts {
10+
>TcpSocketConnectOpts : Symbol(TcpSocketConnectOpts, Decl(multipleBaseInterfaesWithIncompatibleProperties2.ts, 2, 16))
11+
12+
port: number;
13+
>port : Symbol(TcpSocketConnectOpts.port, Decl(multipleBaseInterfaesWithIncompatibleProperties2.ts, 3, 41))
14+
}
15+
16+
export interface AgentOptions extends Partial<TcpSocketConnectOpts> {
17+
>AgentOptions : Symbol(AgentOptions, Decl(multipleBaseInterfaesWithIncompatibleProperties2.ts, 5, 3))
18+
>Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --))
19+
>TcpSocketConnectOpts : Symbol(TcpSocketConnectOpts, Decl(multipleBaseInterfaesWithIncompatibleProperties2.ts, 2, 16))
20+
21+
keepAlive?: boolean | undefined;
22+
>keepAlive : Symbol(AgentOptions.keepAlive, Decl(multipleBaseInterfaesWithIncompatibleProperties2.ts, 7, 71))
23+
}
24+
}
25+
26+
namespace tls {
27+
>tls : Symbol(tls, Decl(multipleBaseInterfaesWithIncompatibleProperties2.ts, 10, 1))
28+
29+
export interface ConnectionOptions {
30+
>ConnectionOptions : Symbol(ConnectionOptions, Decl(multipleBaseInterfaesWithIncompatibleProperties2.ts, 12, 15))
31+
32+
port?: number | undefined;
33+
>port : Symbol(ConnectionOptions.port, Decl(multipleBaseInterfaesWithIncompatibleProperties2.ts, 13, 38))
34+
}
35+
}
36+
37+
interface AgentOptions extends http.AgentOptions, tls.ConnectionOptions { // error under exactOptionalPropertyTypes
38+
>AgentOptions : Symbol(AgentOptions, Decl(multipleBaseInterfaesWithIncompatibleProperties2.ts, 16, 1))
39+
>http.AgentOptions : Symbol(http.AgentOptions, Decl(multipleBaseInterfaesWithIncompatibleProperties2.ts, 5, 3))
40+
>http : Symbol(http, Decl(multipleBaseInterfaesWithIncompatibleProperties2.ts, 0, 0))
41+
>AgentOptions : Symbol(http.AgentOptions, Decl(multipleBaseInterfaesWithIncompatibleProperties2.ts, 5, 3))
42+
>tls.ConnectionOptions : Symbol(tls.ConnectionOptions, Decl(multipleBaseInterfaesWithIncompatibleProperties2.ts, 12, 15))
43+
>tls : Symbol(tls, Decl(multipleBaseInterfaesWithIncompatibleProperties2.ts, 10, 1))
44+
>ConnectionOptions : Symbol(tls.ConnectionOptions, Decl(multipleBaseInterfaesWithIncompatibleProperties2.ts, 12, 15))
45+
46+
maxCachedSessions?: number | undefined;
47+
>maxCachedSessions : Symbol(AgentOptions.maxCachedSessions, Decl(multipleBaseInterfaesWithIncompatibleProperties2.ts, 18, 73))
48+
}
49+
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//// [tests/cases/compiler/multipleBaseInterfaesWithIncompatibleProperties2.ts] ////
2+
3+
=== multipleBaseInterfaesWithIncompatibleProperties2.ts ===
4+
// https://github.com/microsoft/TypeScript/issues/62569
5+
6+
namespace http {
7+
export interface TcpSocketConnectOpts {
8+
port: number;
9+
>port : number
10+
> : ^^^^^^
11+
}
12+
13+
export interface AgentOptions extends Partial<TcpSocketConnectOpts> {
14+
keepAlive?: boolean | undefined;
15+
>keepAlive : boolean | undefined
16+
> : ^^^^^^^^^^^^^^^^^^^
17+
}
18+
}
19+
20+
namespace tls {
21+
export interface ConnectionOptions {
22+
port?: number | undefined;
23+
>port : number | undefined
24+
> : ^^^^^^^^^^^^^^^^^^
25+
}
26+
}
27+
28+
interface AgentOptions extends http.AgentOptions, tls.ConnectionOptions { // error under exactOptionalPropertyTypes
29+
>http : any
30+
> : ^^^
31+
>tls : any
32+
> : ^^^
33+
34+
maxCachedSessions?: number | undefined;
35+
>maxCachedSessions : number | undefined
36+
> : ^^^^^^^^^^^^^^^^^^
37+
}
38+
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
multipleBaseInterfaesWithIncompatibleProperties2.ts(19,11): error TS2320: Interface 'AgentOptions' cannot simultaneously extend types 'AgentOptions' and 'ConnectionOptions'.
2+
Named property 'port' of types 'AgentOptions' and 'ConnectionOptions' are not identical.
3+
4+
5+
==== multipleBaseInterfaesWithIncompatibleProperties2.ts (1 errors) ====
6+
// https://github.com/microsoft/TypeScript/issues/62569
7+
8+
namespace http {
9+
export interface TcpSocketConnectOpts {
10+
port: number;
11+
}
12+
13+
export interface AgentOptions extends Partial<TcpSocketConnectOpts> {
14+
keepAlive?: boolean | undefined;
15+
}
16+
}
17+
18+
namespace tls {
19+
export interface ConnectionOptions {
20+
port?: number | undefined;
21+
}
22+
}
23+
24+
interface AgentOptions extends http.AgentOptions, tls.ConnectionOptions { // error under exactOptionalPropertyTypes
25+
~~~~~~~~~~~~
26+
!!! error TS2320: Interface 'AgentOptions' cannot simultaneously extend types 'AgentOptions' and 'ConnectionOptions'.
27+
!!! error TS2320: Named property 'port' of types 'AgentOptions' and 'ConnectionOptions' are not identical.
28+
maxCachedSessions?: number | undefined;
29+
}
30+
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
//// [tests/cases/compiler/multipleBaseInterfaesWithIncompatibleProperties2.ts] ////
2+
3+
=== multipleBaseInterfaesWithIncompatibleProperties2.ts ===
4+
// https://github.com/microsoft/TypeScript/issues/62569
5+
6+
namespace http {
7+
>http : Symbol(http, Decl(multipleBaseInterfaesWithIncompatibleProperties2.ts, 0, 0))
8+
9+
export interface TcpSocketConnectOpts {
10+
>TcpSocketConnectOpts : Symbol(TcpSocketConnectOpts, Decl(multipleBaseInterfaesWithIncompatibleProperties2.ts, 2, 16))
11+
12+
port: number;
13+
>port : Symbol(TcpSocketConnectOpts.port, Decl(multipleBaseInterfaesWithIncompatibleProperties2.ts, 3, 41))
14+
}
15+
16+
export interface AgentOptions extends Partial<TcpSocketConnectOpts> {
17+
>AgentOptions : Symbol(AgentOptions, Decl(multipleBaseInterfaesWithIncompatibleProperties2.ts, 5, 3))
18+
>Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --))
19+
>TcpSocketConnectOpts : Symbol(TcpSocketConnectOpts, Decl(multipleBaseInterfaesWithIncompatibleProperties2.ts, 2, 16))
20+
21+
keepAlive?: boolean | undefined;
22+
>keepAlive : Symbol(AgentOptions.keepAlive, Decl(multipleBaseInterfaesWithIncompatibleProperties2.ts, 7, 71))
23+
}
24+
}
25+
26+
namespace tls {
27+
>tls : Symbol(tls, Decl(multipleBaseInterfaesWithIncompatibleProperties2.ts, 10, 1))
28+
29+
export interface ConnectionOptions {
30+
>ConnectionOptions : Symbol(ConnectionOptions, Decl(multipleBaseInterfaesWithIncompatibleProperties2.ts, 12, 15))
31+
32+
port?: number | undefined;
33+
>port : Symbol(ConnectionOptions.port, Decl(multipleBaseInterfaesWithIncompatibleProperties2.ts, 13, 38))
34+
}
35+
}
36+
37+
interface AgentOptions extends http.AgentOptions, tls.ConnectionOptions { // error under exactOptionalPropertyTypes
38+
>AgentOptions : Symbol(AgentOptions, Decl(multipleBaseInterfaesWithIncompatibleProperties2.ts, 16, 1))
39+
>http.AgentOptions : Symbol(http.AgentOptions, Decl(multipleBaseInterfaesWithIncompatibleProperties2.ts, 5, 3))
40+
>http : Symbol(http, Decl(multipleBaseInterfaesWithIncompatibleProperties2.ts, 0, 0))
41+
>AgentOptions : Symbol(http.AgentOptions, Decl(multipleBaseInterfaesWithIncompatibleProperties2.ts, 5, 3))
42+
>tls.ConnectionOptions : Symbol(tls.ConnectionOptions, Decl(multipleBaseInterfaesWithIncompatibleProperties2.ts, 12, 15))
43+
>tls : Symbol(tls, Decl(multipleBaseInterfaesWithIncompatibleProperties2.ts, 10, 1))
44+
>ConnectionOptions : Symbol(tls.ConnectionOptions, Decl(multipleBaseInterfaesWithIncompatibleProperties2.ts, 12, 15))
45+
46+
maxCachedSessions?: number | undefined;
47+
>maxCachedSessions : Symbol(AgentOptions.maxCachedSessions, Decl(multipleBaseInterfaesWithIncompatibleProperties2.ts, 18, 73))
48+
}
49+
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//// [tests/cases/compiler/multipleBaseInterfaesWithIncompatibleProperties2.ts] ////
2+
3+
=== multipleBaseInterfaesWithIncompatibleProperties2.ts ===
4+
// https://github.com/microsoft/TypeScript/issues/62569
5+
6+
namespace http {
7+
export interface TcpSocketConnectOpts {
8+
port: number;
9+
>port : number
10+
> : ^^^^^^
11+
}
12+
13+
export interface AgentOptions extends Partial<TcpSocketConnectOpts> {
14+
keepAlive?: boolean | undefined;
15+
>keepAlive : boolean | undefined
16+
> : ^^^^^^^^^^^^^^^^^^^
17+
}
18+
}
19+
20+
namespace tls {
21+
export interface ConnectionOptions {
22+
port?: number | undefined;
23+
>port : number | undefined
24+
> : ^^^^^^^^^^^^^^^^^^
25+
}
26+
}
27+
28+
interface AgentOptions extends http.AgentOptions, tls.ConnectionOptions { // error under exactOptionalPropertyTypes
29+
>http : any
30+
> : ^^^
31+
>tls : any
32+
> : ^^^
33+
34+
maxCachedSessions?: number | undefined;
35+
>maxCachedSessions : number | undefined
36+
> : ^^^^^^^^^^^^^^^^^^
37+
}
38+
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// @strict: true
2+
// @noEmit: true
3+
// @exactOptionalPropertyTypes: true, false
4+
5+
// https://github.com/microsoft/TypeScript/issues/62569
6+
7+
namespace http {
8+
export interface TcpSocketConnectOpts {
9+
port: number;
10+
}
11+
12+
export interface AgentOptions extends Partial<TcpSocketConnectOpts> {
13+
keepAlive?: boolean | undefined;
14+
}
15+
}
16+
17+
namespace tls {
18+
export interface ConnectionOptions {
19+
port?: number | undefined;
20+
}
21+
}
22+
23+
interface AgentOptions extends http.AgentOptions, tls.ConnectionOptions { // error under exactOptionalPropertyTypes
24+
maxCachedSessions?: number | undefined;
25+
}

0 commit comments

Comments
 (0)