TypeScript 在索引类型赋值中的类型推断被跳过,

q35jwt9p  于 6个月前  发布在  TypeScript
关注(0)|答案(1)|浏览(56)

类型推断:OOMDict对象的OneOrMany值与其内容和类型推断(oomdict.many不会从OneOrMany缩小到Many)或它们缩小到错误的特定类型(oomdict.one缩小从OneOfMany到Many而不是One)。

实际行为:在一个OOMDict中,值要么不根据其内容和类型推断进行缩小,要么它们缩小到错误的特定类型(oomdict.one缩小从OneOfMany到Many而不是One)。

Playground链接:https://www.typescriptlang.org/play/?ssl=1&ssc=1&pln=56&pc=1#code/PTAECMEMGcEsGNQBcCeAHAptAUKzoB5AOw1AF5QBvUIyAWwwC5RokAnWIgcwG5QBfHrnSkAspCIpyoAIJs2kFAB5iGAHxC8pVQTbjJ01aAA+ofSiHYQyLEk5dQbLAHsANgFc7zoqGcAzZAALbRJdc2QRCBgMABNfH3hvJAwiJBwAN0g2eKZCUL0JKQpqWgZmACJoenKBIWtIJCDYaFA0Z05G71JAmFBIVydIGKlaeWcAd1jQPzZnOjyMMMLkZwWo6CnvUFg00ETUlLSAGj6-ZOznbM5WDCHfAKRgvugNtmS4nQKDLT7wZ3SMNgugA6UqkCjlNANcrYTLZOiFZifcIUADaJXouUq1QEJwxZVA5RggRq-AAunUwAiDD0WqNZpM4jM5gslt9VuEoBs4lsdi19slUjhqShUQAGMmgzHSSHQ7Ai4EItAACgAHuQ1KBVQBKKxgfqubYtSauVzYPU2Vj2RwuDxeHz+IIhRZfKQ-cY7QKcPo+TgxDDqrTYDoYNh+SDwbQEUQAEQQjWoqIA1hgUMxWBxuGSkflzHx+LCsr45jF4wAmJHRuPwRrFQRAkvl4FdUDWFvNUBJogTHxIVbgUiQVmuvqNR4dtodbCgGfSfFYqp0UmUp3POBcIgMVI0LIMzYkaazebI5Z9hYNuilmtl5skKUMGVQpDlITORvXxXLawio2d7vjXt+0HYdwgaJoWknVJp1nNF5wqRdSTxHcCSJaASQECkLUeQcXlgDct0aekJimH9mWPXNTw5QoLyvJAbxFcVJTBR9oRXA1fxNM0sNsa0nGgNxPFgLYPXHHwJG2Ih-UDSJOB2WB+lgAAvUNCwud8kErWN4znHJmDgwkENxUARWYdFkIXHF+CQsEKmJUkyVqLCvRaGB103Q5QFpUAADkCAAFR3MZGVXH5HTfS941vUhLmLCKa0-SQLT+R4+icFg7FNCJMBcloTwMMDxwg9pUhOdxJKwWAFHAVwUBoyKQWYiEnxfC0AFEACV2oIdrmAABVmTA3ikAByMFhtAGJnCwGhnEaANmk6XtImGvKUGG4E2s67q+oG0NUFAUbMXGybpu7ObVQW+IstIYbzHW5UywAZkegBOXVrG81ZYH9IdxkCN1naCZnHcVw4iI8YVjMQoTicBFZO4EDlmB0G4jA1xblYCBgLoS5SA2Ig4Gq0g6GaAcenSIS2Dq+KGIle9wUJZqVw6rqetAVqMYI7Y6DQVwEB2GrPN6cThsKcafgHeBIHcDZQADNA+LgLZHR+YaxXG6WiGGxoB1AWWpjPP0A2ug7VvWza2Z25xBv29XjqmulZvli6sa2NXzeBZUAHYxQAVke96wBkYy8YAWgVjAaymcNYA8NKzwhjaLREwI1zw9yhUPFkJFm4ILnAAArKOkFU2LaMezTq1rKh6zhFgQbYSMq+04pdKocz4Msk4TNAMybIM7uO4H1D0PJRy-Bi5UMcaFMpG9fj3CbjBtSoaCZ3Civk1TByKEX5ft5QClWzAVCkckGp89IE7oG1xpglcNAaaQR6ooZljn1fdTX7ppjpSa1iFpFykFDLMNgOVfj-EBBaWW1ohx+DKjWISPhJ7ZEyPzGIDRkESRuHcVW6BrTYUIFWbSfIMCuD8Ngf08BXBZFIAgogSCtjoO+g0DAypN7xhbjWbUzB0jtBiNgfYbt1IABYdJdD0p3QeS4jK937piLusirLD0UYSOyGFHIsMwckDhYjtSWCAA

bnlyeluc

bnlyeluc1#

我记得我们没有根据初始化器缩小范围的原因,但我现在不记得了。我们应该再次调查一下,看看是否有实际意义。

相关问题