问题描述
{
"results_": [
{
"alternatives_": [
{
"transcript_": "but what if somebody decides to break it be careful that you keep adequate coverage but look for places to save money baby it\u0027s taking longer to get things squared away then the bankers expected hiring the life for one\u0027s company may win her tax aided retirement income the booth just helpful but inadequate new self to saving Rags or hardly tossed on the two naked bones what it discussion Canyon Sue when the title of this type of song is in question there\u0027s no dying or waxing or gassing need a paperweight maybe personalized kNown back Quoc Leigh is leather hard place work on a flat surface and smooth out this simplest kind of separate system uses a single self-contained unit to the old shop outage still Holts a good mechanic is usually a bad boss so fingers would go higher in later years so make beautiful chairs cabinets chest doll houses it\u0027s at","confidence_": 0.6881865,"words_": [
{
"startTime_": {
"seconds_": 0,"nanos_": 0,"memoizedisInitialized": -1,"unkNownFields": {
"fields": {},"fieldsDescending": {}
},"memoizedSize": -1,"memoizedHashCode": 0
},"endTime_": {
"seconds_": 0,"nanos_": 200000000,"word_": "but","confidence_": 0.53119344,"speakerTag_": 0,"unkNownFields": {
"fields": {},"fieldsDescending": {}
},"memoizedHashCode": 0
},......
函数的变形道具(来自redux状态)是嵌套的,如何将mapStatetoProps()
类型应用于它?编译后收到以下错误消息:
HeaderStateMap
此外,我同时设置了Property 'cart' does not exist on type 'HeaderStateMap'. TS2339
,但是如果我将类型更改为object,TypeScript会抱怨user:any
。
不胜感激:)。
Property 'user' does not exist on type '{}'
解决方法
您可以嵌套您的类型:
interface User {
name: string;
};
type HeaderStateMap = {
user: User;
cart: {
hidden: boolean;
};
};
关于您所遇到的错误,我认为您的结构破坏得太深了,假设您在用户对象user.user
中拥有用户,请尝试:
const mapStateToProps = ({ user,cart: { hidden } }:HeaderStateMap) =>