Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12683,7 +12683,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
// or if we have another early-bound symbol declaration with the same name and
// conflicting flags.
const earlySymbol = earlySymbols && earlySymbols.get(memberName);
if (lateSymbol.flags & getExcludedSymbolFlags(symbolFlags) || earlySymbol) {
// Duplicate property declarations of classes are checked in checkClassForDuplicateDeclarations.
if (!(parent.flags & SymbolFlags.Class) && (lateSymbol.flags & getExcludedSymbolFlags(symbolFlags) || earlySymbol)) {
// If we have an existing early-bound member, combine its declarations so that we can
// report an error at each declaration.
const declarations = earlySymbol ? concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations;
Expand Down Expand Up @@ -38878,7 +38879,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
isStaticMember ? staticNames :
instanceNames;

const memberName = name && getPropertyNameForPropertyNameNode(name);
const memberName = name && getEffectivePropertyNameForPropertyNameNode(name);
if (memberName) {
switch (member.kind) {
case SyntaxKind.GetAccessor:
Expand Down Expand Up @@ -38947,7 +38948,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
const memberNameNode = member.name;
const isStaticMember = isStatic(member);
if (isStaticMember && memberNameNode) {
const memberName = getPropertyNameForPropertyNameNode(memberNameNode);
const memberName = getEffectivePropertyNameForPropertyNameNode(memberNameNode);
switch (memberName) {
case "name":
case "length":
Expand Down
14 changes: 13 additions & 1 deletion tests/baselines/reference/mappedTypeProperties.errors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@ mappedTypeProperties.ts(23,5): error TS7061: A mapped type may not declare prope
mappedTypeProperties.ts(27,5): error TS7061: A mapped type may not declare properties or methods.
mappedTypeProperties.ts(31,5): error TS7061: A mapped type may not declare properties or methods.
mappedTypeProperties.ts(34,5): error TS7061: A mapped type may not declare properties or methods.
mappedTypeProperties.ts(34,6): error TS2304: Cannot find name 'P'.
mappedTypeProperties.ts(34,11): error TS2693: 'PlaceType' only refers to a type, but is being used as a value here.
mappedTypeProperties.ts(37,5): error TS7061: A mapped type may not declare properties or methods.
mappedTypeProperties.ts(37,6): error TS2304: Cannot find name 'P'.
mappedTypeProperties.ts(37,11): error TS2693: 'PlaceType' only refers to a type, but is being used as a value here.
mappedTypeProperties.ts(40,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type.
mappedTypeProperties.ts(40,6): error TS2304: Cannot find name 'P'.
mappedTypeProperties.ts(40,6): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
mappedTypeProperties.ts(40,11): error TS2322: Type 'string' is not assignable to type 'object'.
mappedTypeProperties.ts(40,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.


==== mappedTypeProperties.ts (14 errors) ====
==== mappedTypeProperties.ts (18 errors) ====
export type PlaceType = 'openSky' | 'roofed' | 'garage'
type Before = {
model: 'hour' | 'day';
Expand Down Expand Up @@ -65,11 +69,19 @@ mappedTypeProperties.ts(40,17): error TS2363: The right-hand side of an arithmet
[P in PlaceType]: any
~~~~~~~~~~~~~~~~
!!! error TS7061: A mapped type may not declare properties or methods.
~
!!! error TS2304: Cannot find name 'P'.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those seem to be just noise but maybe it's ok to have them as a side effect of the change.

~~~~~~~~~
!!! error TS2693: 'PlaceType' only refers to a type, but is being used as a value here.
}
const D = class {
[P in PlaceType]: any
~~~~~~~~~~~~~~~~
!!! error TS7061: A mapped type may not declare properties or methods.
~
!!! error TS2304: Cannot find name 'P'.
~~~~~~~~~
!!! error TS2693: 'PlaceType' only refers to a type, but is being used as a value here.
}
const E = class {
[P in 'a' | 'b']: any
Expand Down
Loading