Her zaman - --IImplicitAny bayrağı ile Typescript derlemek. Tip kontrolümün olabildiğince sıkı olmasını istediğim için bu mantıklı.
Benim sorunum şu kod ile hatayı alıyorum Index signature of object type implicitly has an 'any' type:
interface ISomeObject {
firstKey: string;
secondKey: string;
thirdKey: string;
}
let someObject: ISomeObject = {
firstKey: 'firstValue',
secondKey: 'secondValue',
thirdKey: 'thirdValue'
};
let key: string = 'secondKey';
let secondValue: string = someObject[key];
Dikkat edilmesi gereken önemli nokta, anahtar değişkenin uygulamada başka bir yerden gelmesi ve nesnedeki anahtarlardan herhangi biri olabilmesidir.
Açıkça tarafından tür döküm denedim:
let secondValue: string = <string>someObject[key];
Yoksa benim senaryom mümkün değil --noImplicitAnymi?