Skip to content

Commit 0ae9634

Browse files
committed
WIP for 44220
1 parent 5be0d71 commit 0ae9634

File tree

5 files changed

+9
-10
lines changed

5 files changed

+9
-10
lines changed

src/compiler/checker.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7867,7 +7867,10 @@ namespace ts {
78677867
}
78687868
}
78697869
}
7870-
return declarationNameToString(name);
7870+
if (!(isTransientSymbol(symbol) && symbol.checkFlags & ts.CheckFlags.Mapped
7871+
&& isMappedTypeWithKeyofConstraintDeclaration((symbol as MappedSymbol).mappedType))) {
7872+
return declarationNameToString(name);
7873+
}
78717874
}
78727875
if (!declaration) {
78737876
declaration = symbol.declarations[0]; // Declaration may be nameless, but we'll try anyway
@@ -19078,7 +19081,9 @@ namespace ts {
1907819081
if (props.length === 1) {
1907919082
const propName = symbolToString(unmatchedProperty);
1908019083
reportError(Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2, propName, ...getTypeNamesForErrorDisplay(source, target));
19081-
if (length(unmatchedProperty.declarations)) {
19084+
if (length(unmatchedProperty.declarations)
19085+
&& !(isTransientSymbol(unmatchedProperty) && unmatchedProperty.checkFlags & ts.CheckFlags.Mapped
19086+
&& isMappedTypeWithKeyofConstraintDeclaration((unmatchedProperty as MappedSymbol).mappedType))) {
1908219087
associateRelatedInfo(createDiagnosticForNode(unmatchedProperty.declarations![0], Diagnostics._0_is_declared_here, propName));
1908319088
}
1908419089
if (shouldSkipElaboration && errorInfo) {

tests/baselines/reference/mappedTypeErrors.errors.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ tests/cases/conformance/types/mapped/mappedTypeErrors.ts(152,17): error TS2339:
162162
~~~~~~~~
163163
!!! error TS2345: Argument of type '{ x: number; }' is not assignable to parameter of type 'Readonly<{ x: number; y: number; }>'.
164164
!!! error TS2345: Property 'y' is missing in type '{ x: number; }' but required in type 'Readonly<{ x: number; y: number; }>'.
165-
!!! related TS2728 tests/cases/conformance/types/mapped/mappedTypeErrors.ts:75:37: 'y' is declared here.
166165
let x2 = objAndReadonly({ x: 0, y: 0 }, { x: 1, y: 1 });
167166
let x3 = objAndReadonly({ x: 0, y: 0 }, { x: 1, y: 1, z: 1 }); // Error
168167
~~~~

tests/baselines/reference/mappedTypes6.errors.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ tests/cases/conformance/types/mapped/mappedTypes6.ts(120,4): error TS2540: Canno
173173
x2 = { a: 1, b: 1, c: 1 }; // Error
174174
~~
175175
!!! error TS2741: Property 'd' is missing in type '{ a: number; b: number; c: number; }' but required in type 'Required<Foo>'.
176-
!!! related TS2728 tests/cases/conformance/types/mapped/mappedTypes6.ts:82:5: 'd' is declared here.
177176
x2 = { a: 1, b: 1, c: 1, d: 1 };
178177

179178
type Bar = {

tests/baselines/reference/recursiveMappedTypes.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ tests/cases/conformance/types/mapped/recursiveMappedTypes.ts(11,6): error TS2456
66
tests/cases/conformance/types/mapped/recursiveMappedTypes.ts(12,11): error TS2313: Type parameter 'K' has a circular constraint.
77
tests/cases/conformance/types/mapped/recursiveMappedTypes.ts(20,19): error TS2589: Type instantiation is excessively deep and possibly infinite.
88
tests/cases/conformance/types/mapped/recursiveMappedTypes.ts(73,5): error TS2502: '"each"' is referenced directly or indirectly in its own type annotation.
9-
tests/cases/conformance/types/mapped/recursiveMappedTypes.ts(73,13): error TS2615: Type of property '"each"' circularly references itself in mapped type '{ [P in keyof ListWidget]: undefined extends ListWidget[P] ? never : P; }'.
9+
tests/cases/conformance/types/mapped/recursiveMappedTypes.ts(73,13): error TS2615: Type of property 'each' circularly references itself in mapped type '{ [P in keyof ListWidget]: undefined extends ListWidget[P] ? never : P; }'.
1010

1111

1212
==== tests/cases/conformance/types/mapped/recursiveMappedTypes.ts (9 errors) ====
@@ -101,7 +101,7 @@ tests/cases/conformance/types/mapped/recursiveMappedTypes.ts(73,13): error TS261
101101
~~~~~~
102102
!!! error TS2502: '"each"' is referenced directly or indirectly in its own type annotation.
103103
~~~~~~~~~~~~~~~~~
104-
!!! error TS2615: Type of property '"each"' circularly references itself in mapped type '{ [P in keyof ListWidget]: undefined extends ListWidget[P] ? never : P; }'.
104+
!!! error TS2615: Type of property 'each' circularly references itself in mapped type '{ [P in keyof ListWidget]: undefined extends ListWidget[P] ? never : P; }'.
105105
}
106106

107107
type ListChild = Child<ListWidget>

tests/baselines/reference/requiredMappedTypeModifierTrumpsVariance.errors.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,9 @@ tests/cases/compiler/requiredMappedTypeModifierTrumpsVariance.ts(22,6): error TS
2020
A = b; // Should Error
2121
~
2222
!!! error TS2741: Property 'a' is missing in type 'Required<{ b?: 1; x: 1; }>' but required in type 'Required<{ a?: 1; x: 1; }>'.
23-
!!! related TS2728 tests/cases/compiler/requiredMappedTypeModifierTrumpsVariance.ts:1:21: 'a' is declared here.
2423
B = a; // Should Error
2524
~
2625
!!! error TS2741: Property 'b' is missing in type 'Required<{ a?: 1; x: 1; }>' but required in type 'Required<{ b?: 1; x: 1; }>'.
27-
!!! related TS2728 tests/cases/compiler/requiredMappedTypeModifierTrumpsVariance.ts:2:21: 'b' is declared here.
2826

2927
a.b; // Property 'b' does not exist on type 'Required<{ a?: 1; x: 1; }>'.
3028
~
@@ -45,13 +43,11 @@ tests/cases/compiler/requiredMappedTypeModifierTrumpsVariance.ts(22,6): error TS
4543
!!! error TS2322: Type 'Foo<{ b?: 1; x: 1; }>' is not assignable to type 'Foo<{ a?: 1; x: 1; }>'.
4644
!!! error TS2322: Types of property 'a' are incompatible.
4745
!!! error TS2322: Property 'a' is missing in type 'Required<{ b?: 1; x: 1; }>' but required in type 'Required<{ a?: 1; x: 1; }>'.
48-
!!! related TS2728 tests/cases/compiler/requiredMappedTypeModifierTrumpsVariance.ts:14:17: 'a' is declared here.
4946
BB = aa; // Should Error
5047
~~
5148
!!! error TS2322: Type 'Foo<{ a?: 1; x: 1; }>' is not assignable to type 'Foo<{ b?: 1; x: 1; }>'.
5249
!!! error TS2322: Types of property 'a' are incompatible.
5350
!!! error TS2322: Property 'b' is missing in type 'Required<{ a?: 1; x: 1; }>' but required in type 'Required<{ b?: 1; x: 1; }>'.
54-
!!! related TS2728 tests/cases/compiler/requiredMappedTypeModifierTrumpsVariance.ts:15:17: 'b' is declared here.
5551

5652
aa.a.b; // Property 'b' does not exist on type 'Required<{ a?: 1; x: 1; }>'.
5753
~

0 commit comments

Comments
 (0)