Skip to content

Commit 307b09b

Browse files
committed
fix 61547
1 parent 8c62e08 commit 307b09b

6 files changed

+69
-1
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25115,7 +25115,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2511525115
if (isReadonlySymbol(sourceProp) !== isReadonlySymbol(targetProp)) {
2511625116
return Ternary.False;
2511725117
}
25118-
return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp));
25118+
return compareTypes(getNonMissingTypeOfSymbol(sourceProp), getNonMissingTypeOfSymbol(targetProp));
2511925119
}
2512025120

2512125121
function isMatchingSignature(source: Signature, target: Signature, partialMatch: boolean) {
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+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//// [tests/cases/compiler/exactOptionalPropertyTypesIdentical.ts] ////
2+
3+
//// [exactOptionalPropertyTypesIdentical.ts]
4+
export let a: <T>() => T extends {a?: string} ? 0 : 1 = null!;
5+
export let b: <T>() => T extends {a?: string | undefined} ? 0 : 1 = a;
6+
7+
8+
//// [exactOptionalPropertyTypesIdentical.js]
9+
"use strict";
10+
Object.defineProperty(exports, "__esModule", { value: true });
11+
exports.b = exports.a = void 0;
12+
exports.a = null;
13+
exports.b = exports.a;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//// [tests/cases/compiler/exactOptionalPropertyTypesIdentical.ts] ////
2+
3+
=== exactOptionalPropertyTypesIdentical.ts ===
4+
export let a: <T>() => T extends {a?: string} ? 0 : 1 = null!;
5+
>a : Symbol(a, Decl(exactOptionalPropertyTypesIdentical.ts, 0, 10))
6+
>T : Symbol(T, Decl(exactOptionalPropertyTypesIdentical.ts, 0, 15))
7+
>T : Symbol(T, Decl(exactOptionalPropertyTypesIdentical.ts, 0, 15))
8+
>a : Symbol(a, Decl(exactOptionalPropertyTypesIdentical.ts, 0, 34))
9+
10+
export let b: <T>() => T extends {a?: string | undefined} ? 0 : 1 = a;
11+
>b : Symbol(b, Decl(exactOptionalPropertyTypesIdentical.ts, 1, 10))
12+
>T : Symbol(T, Decl(exactOptionalPropertyTypesIdentical.ts, 1, 15))
13+
>T : Symbol(T, Decl(exactOptionalPropertyTypesIdentical.ts, 1, 15))
14+
>a : Symbol(a, Decl(exactOptionalPropertyTypesIdentical.ts, 1, 34))
15+
>a : Symbol(a, Decl(exactOptionalPropertyTypesIdentical.ts, 0, 10))
16+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//// [tests/cases/compiler/exactOptionalPropertyTypesIdentical.ts] ////
2+
3+
=== exactOptionalPropertyTypesIdentical.ts ===
4+
export let a: <T>() => T extends {a?: string} ? 0 : 1 = null!;
5+
>a : <T>() => T extends { a?: string; } ? 0 : 1
6+
> : ^ ^^^^^^^
7+
>a : string | undefined
8+
> : ^^^^^^^^^^^^^^^^^^
9+
>null! : never
10+
> : ^^^^^
11+
12+
export let b: <T>() => T extends {a?: string | undefined} ? 0 : 1 = a;
13+
>b : <T>() => T extends { a?: string | undefined; } ? 0 : 1
14+
> : ^ ^^^^^^^
15+
>a : string | undefined
16+
> : ^^^^^^^^^^^^^^^^^^
17+
>a : <T>() => T extends { a?: string; } ? 0 : 1
18+
> : ^ ^^^^^^^
19+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// @strictNullChecks: true
2+
// @exactOptionalPropertyTypes: true
3+
4+
export let a: <T>() => T extends {a?: string} ? 0 : 1 = null!;
5+
export let b: <T>() => T extends {a?: string | undefined} ? 0 : 1 = a;

0 commit comments

Comments
 (0)