Merge pull request #15518 from vkurchatkin/empty-property
Allow indexed access to empty property
This commit is contained in:
commit
14f6bf2244
4 changed files with 8 additions and 4 deletions
|
@ -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' }[''];
|
Loading…
Reference in a new issue