mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 02:33:53 -06:00
Allow indexed access to empty property
Fixes: https://github.com/Microsoft/TypeScript/issues/15209
This commit is contained in:
parent
88f9a978dd
commit
d45d289f36
@ -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…
x
Reference in New Issue
Block a user