Skip to content

Commit d33143c

Browse files
committed
Initial setup
1 parent 368cdfd commit d33143c

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

Diff for: src/compiler/checker.ts

+11-5
Original file line numberDiff line numberDiff line change
@@ -32323,16 +32323,13 @@ namespace ts {
3232332323
if (otherAccessor) {
3232432324
const nodeFlags = getEffectiveModifierFlags(node);
3232532325
const otherFlags = getEffectiveModifierFlags(otherAccessor);
32326-
if ((nodeFlags & ModifierFlags.AccessibilityModifier) !== (otherFlags & ModifierFlags.AccessibilityModifier)) {
32327-
error(node.name, Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility);
32328-
}
3232932326
if ((nodeFlags & ModifierFlags.Abstract) !== (otherFlags & ModifierFlags.Abstract)) {
3233032327
error(node.name, Diagnostics.Accessors_must_both_be_abstract_or_non_abstract);
3233132328
}
3233232329

3233332330
// TypeScript 1.0 spec (April 2014): 4.5
3233432331
// If both accessors include type annotations, the specified types must be identical.
32335-
checkAccessorDeclarationTypesIdentical(node, otherAccessor, getAnnotatedAccessorType, Diagnostics.get_and_set_accessor_must_have_the_same_type);
32332+
checkAccessorDeclarationTypesAssignable(node, otherAccessor, getAnnotatedAccessorType, Diagnostics.get_and_set_accessor_must_have_the_comparable_types);
3233632333
checkAccessorDeclarationTypesIdentical(node, otherAccessor, getThisTypeOfDeclaration, Diagnostics.get_and_set_accessor_must_have_the_same_this_type);
3233732334
}
3233832335
}
@@ -32345,13 +32342,22 @@ namespace ts {
3234532342
}
3234632343

3234732344
function checkAccessorDeclarationTypesIdentical(first: AccessorDeclaration, second: AccessorDeclaration, getAnnotatedType: (a: AccessorDeclaration) => Type | undefined, message: DiagnosticMessage) {
32345+
return checkAccessorDeclarationTypesMatch(first, second, getAnnotatedType, isTypeIdenticalTo, message);
32346+
}
32347+
32348+
function checkAccessorDeclarationTypesAssignable(first: AccessorDeclaration, second: AccessorDeclaration, getAnnotatedType: (a: AccessorDeclaration) => Type | undefined, message: DiagnosticMessage) {
32349+
return checkAccessorDeclarationTypesMatch(first, second, getAnnotatedType, areTypesComparable, message);
32350+
}
32351+
32352+
function checkAccessorDeclarationTypesMatch(first: AccessorDeclaration, second: AccessorDeclaration, getAnnotatedType: (a: AccessorDeclaration) => Type | undefined, match: typeof areTypesComparable, message: DiagnosticMessage) {
3234832353
const firstType = getAnnotatedType(first);
3234932354
const secondType = getAnnotatedType(second);
32350-
if (firstType && secondType && !isTypeIdenticalTo(firstType, secondType)) {
32355+
if (firstType && secondType && !match(firstType, secondType)) {
3235132356
error(first, message);
3235232357
}
3235332358
}
3235432359

32360+
3235532361
function checkMissingDeclaration(node: Node) {
3235632362
checkDecorators(node);
3235732363
}

Diff for: src/compiler/diagnosticMessages.json

+1-5
Original file line numberDiff line numberDiff line change
@@ -1697,11 +1697,7 @@
16971697
"category": "Error",
16981698
"code": 2378
16991699
},
1700-
"Getter and setter accessors do not agree in visibility.": {
1701-
"category": "Error",
1702-
"code": 2379
1703-
},
1704-
"'get' and 'set' accessor must have the same type.": {
1700+
"'get' and 'set' accessor must have comparable types.": {
17051701
"category": "Error",
17061702
"code": 2380
17071703
},

0 commit comments

Comments
 (0)