From c3a1152895227d37871b383dd8fa5ad3c7361880 Mon Sep 17 00:00:00 2001 From: Herrington Darkholme Date: Wed, 2 Nov 2016 20:27:53 +0800 Subject: [PATCH] fix #11480, disallow delete operator on readonly property or index signature --- src/compiler/checker.ts | 3 +++ src/compiler/diagnosticMessages.json | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 744d23a3657a1..109e30979a94c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -13486,6 +13486,9 @@ namespace ts { function checkDeleteExpression(node: DeleteExpression): Type { checkExpression(node.expression); + checkReferenceExpression(node.expression, + Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference, + Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property); return booleanType; } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 3b873cf35c04e..f448f848c05b7 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1971,6 +1971,14 @@ "category": "Error", "code": 2697 }, + "The operand of a delete operator must be a property reference": { + "category": "Error", + "code": 2698 + }, + "The operand of a delete operator cannot be a read-only property": { + "category": "Error", + "code": 2699 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error",