From 307b09b58b4ebe54fe12d1274f077121bd6e8f96 Mon Sep 17 00:00:00 2001 From: Hans Brende Date: Fri, 9 May 2025 16:06:07 -0500 Subject: [PATCH] fix 61547 --- src/compiler/checker.ts | 2 +- ...tOptionalPropertyTypesIdentical.errors.txt | 15 +++++++++++++++ .../exactOptionalPropertyTypesIdentical.js | 13 +++++++++++++ ...xactOptionalPropertyTypesIdentical.symbols | 16 ++++++++++++++++ .../exactOptionalPropertyTypesIdentical.types | 19 +++++++++++++++++++ .../exactOptionalPropertyTypesIdentical.ts | 5 +++++ 6 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/exactOptionalPropertyTypesIdentical.errors.txt create mode 100644 tests/baselines/reference/exactOptionalPropertyTypesIdentical.js create mode 100644 tests/baselines/reference/exactOptionalPropertyTypesIdentical.symbols create mode 100644 tests/baselines/reference/exactOptionalPropertyTypesIdentical.types create mode 100644 tests/cases/compiler/exactOptionalPropertyTypesIdentical.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 073c0d46d7b4e..ee8b72d303487 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -25115,7 +25115,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (isReadonlySymbol(sourceProp) !== isReadonlySymbol(targetProp)) { return Ternary.False; } - return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); + return compareTypes(getNonMissingTypeOfSymbol(sourceProp), getNonMissingTypeOfSymbol(targetProp)); } function isMatchingSignature(source: Signature, target: Signature, partialMatch: boolean) { diff --git a/tests/baselines/reference/exactOptionalPropertyTypesIdentical.errors.txt b/tests/baselines/reference/exactOptionalPropertyTypesIdentical.errors.txt new file mode 100644 index 0000000000000..8ed639135a13f --- /dev/null +++ b/tests/baselines/reference/exactOptionalPropertyTypesIdentical.errors.txt @@ -0,0 +1,15 @@ +exactOptionalPropertyTypesIdentical.ts(2,12): error TS2322: Type '() => T extends { a?: string; } ? 0 : 1' is not assignable to type '() => T extends { a?: string | undefined; } ? 0 : 1'. + Type 'T extends { a?: string; } ? 0 : 1' is not assignable to type 'T extends { a?: string | undefined; } ? 0 : 1'. + Type '0 | 1' is not assignable to type 'T extends { a?: string | undefined; } ? 0 : 1'. + Type '0' is not assignable to type 'T extends { a?: string | undefined; } ? 0 : 1'. + + +==== exactOptionalPropertyTypesIdentical.ts (1 errors) ==== + export let a: () => T extends {a?: string} ? 0 : 1 = null!; + export let b: () => T extends {a?: string | undefined} ? 0 : 1 = a; + ~ +!!! error TS2322: Type '() => T extends { a?: string; } ? 0 : 1' is not assignable to type '() => T extends { a?: string | undefined; } ? 0 : 1'. +!!! error TS2322: Type 'T extends { a?: string; } ? 0 : 1' is not assignable to type 'T extends { a?: string | undefined; } ? 0 : 1'. +!!! error TS2322: Type '0 | 1' is not assignable to type 'T extends { a?: string | undefined; } ? 0 : 1'. +!!! error TS2322: Type '0' is not assignable to type 'T extends { a?: string | undefined; } ? 0 : 1'. + \ No newline at end of file diff --git a/tests/baselines/reference/exactOptionalPropertyTypesIdentical.js b/tests/baselines/reference/exactOptionalPropertyTypesIdentical.js new file mode 100644 index 0000000000000..e3153ce591e35 --- /dev/null +++ b/tests/baselines/reference/exactOptionalPropertyTypesIdentical.js @@ -0,0 +1,13 @@ +//// [tests/cases/compiler/exactOptionalPropertyTypesIdentical.ts] //// + +//// [exactOptionalPropertyTypesIdentical.ts] +export let a: () => T extends {a?: string} ? 0 : 1 = null!; +export let b: () => T extends {a?: string | undefined} ? 0 : 1 = a; + + +//// [exactOptionalPropertyTypesIdentical.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.b = exports.a = void 0; +exports.a = null; +exports.b = exports.a; diff --git a/tests/baselines/reference/exactOptionalPropertyTypesIdentical.symbols b/tests/baselines/reference/exactOptionalPropertyTypesIdentical.symbols new file mode 100644 index 0000000000000..e7bbad247053d --- /dev/null +++ b/tests/baselines/reference/exactOptionalPropertyTypesIdentical.symbols @@ -0,0 +1,16 @@ +//// [tests/cases/compiler/exactOptionalPropertyTypesIdentical.ts] //// + +=== exactOptionalPropertyTypesIdentical.ts === +export let a: () => T extends {a?: string} ? 0 : 1 = null!; +>a : Symbol(a, Decl(exactOptionalPropertyTypesIdentical.ts, 0, 10)) +>T : Symbol(T, Decl(exactOptionalPropertyTypesIdentical.ts, 0, 15)) +>T : Symbol(T, Decl(exactOptionalPropertyTypesIdentical.ts, 0, 15)) +>a : Symbol(a, Decl(exactOptionalPropertyTypesIdentical.ts, 0, 34)) + +export let b: () => T extends {a?: string | undefined} ? 0 : 1 = a; +>b : Symbol(b, Decl(exactOptionalPropertyTypesIdentical.ts, 1, 10)) +>T : Symbol(T, Decl(exactOptionalPropertyTypesIdentical.ts, 1, 15)) +>T : Symbol(T, Decl(exactOptionalPropertyTypesIdentical.ts, 1, 15)) +>a : Symbol(a, Decl(exactOptionalPropertyTypesIdentical.ts, 1, 34)) +>a : Symbol(a, Decl(exactOptionalPropertyTypesIdentical.ts, 0, 10)) + diff --git a/tests/baselines/reference/exactOptionalPropertyTypesIdentical.types b/tests/baselines/reference/exactOptionalPropertyTypesIdentical.types new file mode 100644 index 0000000000000..ff2ea9358fd9b --- /dev/null +++ b/tests/baselines/reference/exactOptionalPropertyTypesIdentical.types @@ -0,0 +1,19 @@ +//// [tests/cases/compiler/exactOptionalPropertyTypesIdentical.ts] //// + +=== exactOptionalPropertyTypesIdentical.ts === +export let a: () => T extends {a?: string} ? 0 : 1 = null!; +>a : () => T extends { a?: string; } ? 0 : 1 +> : ^ ^^^^^^^ +>a : string | undefined +> : ^^^^^^^^^^^^^^^^^^ +>null! : never +> : ^^^^^ + +export let b: () => T extends {a?: string | undefined} ? 0 : 1 = a; +>b : () => T extends { a?: string | undefined; } ? 0 : 1 +> : ^ ^^^^^^^ +>a : string | undefined +> : ^^^^^^^^^^^^^^^^^^ +>a : () => T extends { a?: string; } ? 0 : 1 +> : ^ ^^^^^^^ + diff --git a/tests/cases/compiler/exactOptionalPropertyTypesIdentical.ts b/tests/cases/compiler/exactOptionalPropertyTypesIdentical.ts new file mode 100644 index 0000000000000..3abb2bc66b2c9 --- /dev/null +++ b/tests/cases/compiler/exactOptionalPropertyTypesIdentical.ts @@ -0,0 +1,5 @@ +// @strictNullChecks: true +// @exactOptionalPropertyTypes: true + +export let a: () => T extends {a?: string} ? 0 : 1 = null!; +export let b: () => T extends {a?: string | undefined} ? 0 : 1 = a; pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy