Skip to content

Commit bb53aa4

Browse files
Copilotjakebailey
andauthored
Port #61683: Use getNonMissingTypeOfSymbol in compareProperties (#2726)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
1 parent 499fa04 commit bb53aa4

5 files changed

Lines changed: 46 additions & 54 deletions

internal/checker/checker.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27069,7 +27069,7 @@ func (c *Checker) compareProperties(sourceProp *ast.Symbol, targetProp *ast.Symb
2706927069
if c.isReadonlySymbol(sourceProp) != c.isReadonlySymbol(targetProp) {
2707027070
return TernaryFalse
2707127071
}
27072-
return compareTypes(c.getTypeOfSymbol(sourceProp), c.getTypeOfSymbol(targetProp))
27072+
return compareTypes(c.getNonMissingTypeOfSymbol(sourceProp), c.getNonMissingTypeOfSymbol(targetProp))
2707327073
}
2707427074

2707527075
func compareTypesEqual(s *Type, t *Type) Ternary {
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
exactOptionalPropertyTypesIdentical.ts(2,12): error TS2322: Type '<T>() => T extends { a?: string; } ? 0 : 1' is not assignable to type '<T>() => T extends { a?: string | undefined; } ? 0 : 1'.
2+
Type 'T extends { a?: string; } ? 0 : 1' is not assignable to type 'T extends { a?: string | undefined; } ? 0 : 1'.
3+
Type '0 | 1' is not assignable to type 'T extends { a?: string | undefined; } ? 0 : 1'.
4+
Type '0' is not assignable to type 'T extends { a?: string | undefined; } ? 0 : 1'.
5+
6+
7+
==== exactOptionalPropertyTypesIdentical.ts (1 errors) ====
8+
export let a: <T>() => T extends {a?: string} ? 0 : 1 = null!;
9+
export let b: <T>() => T extends {a?: string | undefined} ? 0 : 1 = a;
10+
~
11+
!!! error TS2322: Type '<T>() => T extends { a?: string; } ? 0 : 1' is not assignable to type '<T>() => T extends { a?: string | undefined; } ? 0 : 1'.
12+
!!! error TS2322: Type 'T extends { a?: string; } ? 0 : 1' is not assignable to type 'T extends { a?: string | undefined; } ? 0 : 1'.
13+
!!! error TS2322: Type '0 | 1' is not assignable to type 'T extends { a?: string | undefined; } ? 0 : 1'.
14+
!!! error TS2322: Type '0' is not assignable to type 'T extends { a?: string | undefined; } ? 0 : 1'.
15+

testdata/baselines/reference/submodule/compiler/exactOptionalPropertyTypesIdentical.errors.txt.diff

Lines changed: 0 additions & 19 deletions
This file was deleted.
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+

testdata/baselines/reference/submodule/compiler/multipleBaseInterfaesWithIncompatibleProperties2(exactoptionalpropertytypes=true).errors.txt.diff

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)