Nokta notasyonu ile bir dict özelliğine erişmeye çalışmak, Türleri şikayet eder. dil belirtimi, 4.10, devletler:typescript: 'dictionary' türünde nokta notasyonu ile erişim özelliği
interface MapStringToFunction {
[index: string]: Function;
}
var dict: MapStringToFunction = {};
dict.say =() => 'hi';
dict.say();
MapStringToFunction bir acı endeksi imzası vardır ve say
String türünün, bu nedenle izin verilmelidir:
ObjExpr [ IndexExpr]
... if ObjExpr ’s apparent type has a string index signature and IndexExpr is of type Any, the String or Number primitive type, or an enum type, the property access is of the type of that index signature.
kullanıyorum? Ama belli değil. Hatam nedir ve kodu nasıl değiştirebilirim, böylece nokta notasyonu ile dict yazabilir ve özelliklerine erişebilirim?
. Cevabı okuduktan sonra bile, nokta gösterimi ile arayüzlerin özelliklerine referans verebilmemiz gerektiğini hissediyorum. – Jopela