Javascript 未处理的拒绝(TypeError):无法读取属性';呼叫';未定义的

Javascript 未处理的拒绝(TypeError):无法读取属性';呼叫';未定义的,javascript,reactjs,webpack,typeerror,Javascript,Reactjs,Webpack,Typeerror,我读了所有我找到的东西,甚至到了谷歌的第二页。 我删除了node\u模块s和npm安装后。 我一直在说: Unhandled Rejection (TypeError): Cannot read property 'call' of undefined _callee$ C:/src/client/proxy.ts:28 25 | }); 26 | } 27 | > 28 | export async function call<RESULT>(method:

我读了所有我找到的东西,甚至到了谷歌的第二页。 我删除了
node\u模块
s和
npm安装后
。 我一直在说:

Unhandled Rejection (TypeError): Cannot read property 'call' of undefined
_callee$
C:/src/client/proxy.ts:28
  25 |   });
  26 | }
  27 | 
> 28 | export async function call<RESULT>(method: string, ...params: any[]) {
  29 |   return rpc.call<RESULT>(method, ...params);
  30 | }
  31 | 
rpc.ts

import { WindowPostMessageProxy } from '@ont-community/window-post-message-proxy';
import { Rpc } from '../rpc/rpc';

let windowProxy: WindowPostMessageProxy;
let rpc: Rpc;

export function registerClient({
  logMessages = false,
  logWarnings = false
}: {
  logMessages?: boolean;
  logWarnings?: boolean;
}) {
  windowProxy = new WindowPostMessageProxy({
    name: 'page',
    target: 'content-script',
    logMessages,
    suppressWarnings: !logWarnings
  });
  rpc = new Rpc({
    source: 'page',
    destination: 'background',
    logMessages: false,
    postMessage: windowProxy.postMessage.bind(windowProxy, window)
  });
}

export async function call<RESULT>(method: string, ...params: any[]) {
  return rpc.call<RESULT>(method, ...params);
}
import { Caller, Tunnel, TunnelOptions } from './tunnel';

export type MethodType = (...params: any[]) => any;

interface MethodCallType {
  method: string;
  params: any[];
}

export class Rpc {
  private tunnel: Tunnel<MethodCallType>;
  private methods: Map<string, MethodType>;

  constructor(options: TunnelOptions) {
    options.messageHandler = this.messageHandler.bind(this);

    this.tunnel = new Tunnel(options);
    this.methods = new Map();
  }

  call<RESULT = any>(method: string, ...params: any[]) {
    const msg = {
      method,
      params
    };

    return this.tunnel.send<RESULT>(msg);
  }

  register(name: string, method: MethodType) {
    this.methods.set(name, method);
  }

  private messageHandler(msg: MethodCallType, caller: Caller) {
    const method = this.methods.get(msg.method);

    if (method === undefined) {
      throw new Error('Unregistered method call: ' + msg.method);
    }

    return method.call(caller, ...msg.params);
  }
}
从“/Tunnel”导入{Caller,TunnelOptions};
导出类型MethodType=(…参数:any[])=>any;
接口方法调用类型{
方法:字符串;
参数:任何[];
}
导出类Rpc{
私人隧道:隧道;;
私有方法:Map;
建造商(选项:隧道开采){
options.messageHandler=this.messageHandler.bind(this);
this.tunnel=新隧道(选项);
this.methods=newmap();
}
调用(方法:字符串,…参数:任意[]){
常数msg={
方法,,
params
};
返回此.tunnel.send(msg);
}
寄存器(名称:字符串,方法:MethodType){
this.methods.set(名称、方法);
}
私有messageHandler(消息:MethodCallType,调用者:调用者){
const method=this.methods.get(msg.method);
if(方法===未定义){
抛出新错误('未注册的方法调用:'+msg.method);
}
返回method.call(调用者,…msg.params);
}
}

rpc未定义。。。rpc实例在哪里?你能记录proxy.ts的整个文件吗?我用整个proxy.ts编辑file@DarioRega完成!rpc来自节点模块还是自定义模块?如果自定义,请显示代码toorpc未定义。。。rpc实例在哪里?你能记录proxy.ts的整个文件吗?我用整个proxy.ts编辑file@DarioRega完成!rpc来自节点模块还是自定义模块?如果是自定义的,请也显示代码