mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 03:09:39 -06:00
Don't compare "missing" to undefined in compareProperties under exactOptionalPropertyTypes (#61683)
This commit is contained in:
parent
d4b15eb56d
commit
31a0ead46d
@ -25273,7 +25273,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) {
|
||||
|
||||
@ -0,0 +1,15 @@
|
||||
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'.
|
||||
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>() => T extends {a?: string} ? 0 : 1 = null!;
|
||||
export let b: <T>() => T extends {a?: string | undefined} ? 0 : 1 = a;
|
||||
~
|
||||
!!! error TS2322: Type '<T>() => T extends { a?: string; } ? 0 : 1' is not assignable to type '<T>() => 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'.
|
||||
|
||||
@ -0,0 +1,13 @@
|
||||
//// [tests/cases/compiler/exactOptionalPropertyTypesIdentical.ts] ////
|
||||
|
||||
//// [exactOptionalPropertyTypesIdentical.ts]
|
||||
export let a: <T>() => T extends {a?: string} ? 0 : 1 = null!;
|
||||
export let b: <T>() => 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;
|
||||
@ -0,0 +1,16 @@
|
||||
//// [tests/cases/compiler/exactOptionalPropertyTypesIdentical.ts] ////
|
||||
|
||||
=== exactOptionalPropertyTypesIdentical.ts ===
|
||||
export let a: <T>() => 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>() => 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))
|
||||
|
||||
@ -0,0 +1,19 @@
|
||||
//// [tests/cases/compiler/exactOptionalPropertyTypesIdentical.ts] ////
|
||||
|
||||
=== exactOptionalPropertyTypesIdentical.ts ===
|
||||
export let a: <T>() => T extends {a?: string} ? 0 : 1 = null!;
|
||||
>a : <T>() => T extends { a?: string; } ? 0 : 1
|
||||
> : ^ ^^^^^^^
|
||||
>a : string | undefined
|
||||
> : ^^^^^^^^^^^^^^^^^^
|
||||
>null! : never
|
||||
> : ^^^^^
|
||||
|
||||
export let b: <T>() => T extends {a?: string | undefined} ? 0 : 1 = a;
|
||||
>b : <T>() => T extends { a?: string | undefined; } ? 0 : 1
|
||||
> : ^ ^^^^^^^
|
||||
>a : string | undefined
|
||||
> : ^^^^^^^^^^^^^^^^^^
|
||||
>a : <T>() => T extends { a?: string; } ? 0 : 1
|
||||
> : ^ ^^^^^^^
|
||||
|
||||
@ -0,0 +1,5 @@
|
||||
// @strictNullChecks: true
|
||||
// @exactOptionalPropertyTypes: true
|
||||
|
||||
export let a: <T>() => T extends {a?: string} ? 0 : 1 = null!;
|
||||
export let b: <T>() => T extends {a?: string | undefined} ? 0 : 1 = a;
|
||||
Loading…
x
Reference in New Issue
Block a user