Socket.io: خطأ ترجمة مطبوعة

تم إنشاؤها على ٦ نوفمبر ٢٠٢٠  ·  7تعليقات  ·  مصدر: socketio/socket.io

اتريد:

  • [x] أبلغ عن خطأ
  • [] طلب ميزة

السلوك الحالي

لدي بعض المشاكل في تجميع الكود الخاص بي من الكتابة المطبوعة إلى جافا سكريبت.
فشل التجميع بسبب خطأ في الكتابة في مساحة الاسم. d.ts و socket.d.ts مساحة الاسم وفئة المقبس يمتد EventEmitter. ومع ذلك ، فإنها تلغي وظيفة "البث" والتوقيع غير متوافق مع وظيفة إرسال EventEmitter.

هل هناك أي طريقة لحلها؟

خطوات إعادة الإنتاج (إذا كان السلوك الحالي خطأ)

يوجد أدناه إعداد tsconfig الخاص بي:

{
    "compileOnSave": true,
    "compilerOptions": {
        "outDir": "./dist",
        "lib": ["es5", "es6"],
        "target": "es3",
        "module": "commonjs",
        "moduleResolution": "node",
        "experimentalDecorators": true,
        "emitDecoratorMetadata": true,
        "allowSyntheticDefaultImports": true,
    },
    "include": ["./src/**/*"],
}

هنا تبعيات المشروع:

"dependencies": {
    "debug": "^3.1.0",
    "koa": "^2.13.0",
    "socket.io": "^3.0.0"
  },
  "devDependencies": {
    "@types/koa": "^2.11.6",
    "@types/node": "^14.14.6",
    "supervisor": "^0.12.0",
    "typescript": "^4.0.5"
  }

عندما أجري: "tsc" ، تلقيت الخطأ التالي:

node_modules/socket.io/dist/namespace.d.ts(89,5): error TS2416: Property 'emit' in type 'Namespace' is not assignable to the same property in base type 'EventEmitter'.
  Type '(ev: string, ...args: any[]) => Namespace' is not assignable to type '(event: string | symbol, ...args: any[]) => boolean'.
    Type 'Namespace' is not assignable to type 'boolean'.
node_modules/socket.io/dist/socket.d.ts(84,5): error TS2416: Property 'emit' in type 'Socket' is not assignable to the same property in base type 'EventEmitter'.
  Type '(ev: string, ...args: any[]) => this' is not assignable to type '(event: string | symbol, ...args: any[]) => boolean'.
    Type 'this' is not assignable to type 'boolean'.
      Type 'Socket' is not assignable to type 'boolean'.

اقامة

  • نظام التشغيل: Windows
  • الإصدار socket.io: 3.0.0
bug

التعليق الأكثر فائدة

هل يمكنك إطلاق هذا الإصدار في أسرع وقت ممكن؟

أو دعونا نستهدف فرع fix/typescript-emit مباشرة!

ال 7 كومينتر

لها نفس المشكلة هنا!

نفس المشكلة.
Debian، socket.io 3.0

شكرًا ، يمكنني بالفعل إعادة إنتاج المشكلة.

يجب إصلاح ذلك من خلال https://github.com/socketio/socket.io/commit/50671d984a81535a6a15c704546ca7465e2ea295.

هل يمكنك إطلاق هذا الإصدار في أسرع وقت ممكن؟

أو دعونا نستهدف فرع fix/typescript-emit مباشرة!

يبدو أن هذا يستحق إصدار 3.0.1.

3.0.1 خارج!

لقد قمت بتحديث مثال TypeScript هنا: https://github.com/socketio/socket.io/tree/master/examples/typescript

شكرا لك!

هل كانت هذه الصفحة مفيدة؟
0 / 5 - 0 التقييمات