mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-09 16:39:46 -05:00
Merge pull request #15518 from vkurchatkin/empty-property
Allow indexed access to empty property
This commit is contained in:
@@ -7257,7 +7257,7 @@ namespace ts {
|
||||
accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ?
|
||||
getPropertyNameForKnownSymbolName((<Identifier>(<PropertyAccessExpression>accessExpression.argumentExpression).name).text) :
|
||||
undefined;
|
||||
if (propName) {
|
||||
if (propName !== undefined) {
|
||||
const prop = getPropertyOfType(objectType, propName);
|
||||
if (prop) {
|
||||
if (accessExpression) {
|
||||
|
||||
@@ -4,4 +4,5 @@ tests/cases/compiler/noImplicitAnyStringIndexerOnObject.ts(1,9): error TS7017: E
|
||||
==== tests/cases/compiler/noImplicitAnyStringIndexerOnObject.ts (1 errors) ====
|
||||
var x = {}["hello"];
|
||||
~~~~~~~~~~~
|
||||
!!! error TS7017: Element implicitly has an 'any' type because type '{}' has no index signature.
|
||||
!!! error TS7017: Element implicitly has an 'any' type because type '{}' has no index signature.
|
||||
var y: string = { '': 'foo' }[''];
|
||||
@@ -1,5 +1,7 @@
|
||||
//// [noImplicitAnyStringIndexerOnObject.ts]
|
||||
var x = {}["hello"];
|
||||
var x = {}["hello"];
|
||||
var y: string = { '': 'foo' }[''];
|
||||
|
||||
//// [noImplicitAnyStringIndexerOnObject.js]
|
||||
var x = {}["hello"];
|
||||
var y = { '': 'foo' }[''];
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// @noimplicitany: true
|
||||
|
||||
var x = {}["hello"];
|
||||
var x = {}["hello"];
|
||||
var y: string = { '': 'foo' }[''];
|
||||
Reference in New Issue
Block a user