error TS2339: Property 'x' does not exist on type 'Y'

前端 未结 6 1204
忘掉有多难
忘掉有多难 2020-12-01 12:02

I don\'t understand why this code generates TypeScript error. (It\'s not the original code and is a bit derived, so please ignore the non-sense in the example):



        
6条回答
  •  爱一瞬间的悲伤
    2020-12-01 12:22

    Starting with TypeScript 2.2 using dot notation to access indexed properties is allowed. You won't get error TS2339 on your example.

    See Dotted property for types with string index signatures in TypeScript 2.2 release note.

提交回复
热议问题