wechaty / getting-started

A Starter Project Template for Wechaty works out-of-the-box
https://gitpod.io/#https://github.com/wechaty/wechaty-getting-started
Apache License 2.0
797 stars 351 forks source link

tsc 编译报错 #189

Closed atorber closed 2 years ago

atorber commented 3 years ago

B000000152192P:wechat-assistant-pro-master luyuchao$ tsc wecom_tool.ts node_modules/wechaty/node_modules/memory-card/dist/src/memory-card.d.ts:82:5 - error TS2416: Property 'set' in type 'MemoryCard' is not assignable to the same property in base type 'AsyncMapLike<any, any>'. Type '<T = any>(name: string, data: T) => Promise' is not assignable to type 'AsyncifyMapFunction<any, any, (key: any, value: any) => Map<any, any>>'. Type 'Promise' is not assignable to type 'Promise<AsyncMapLike<any, any>>'. Type 'this' is not assignable to type 'AsyncMapLike<any, any>'. Type 'MemoryCard' is missing the following properties from type 'AsyncMapLike<any, any>': [Symbol.iterator], [Symbol.toStringTag]

82 set<T = any>(name: string, data: T): Promise;


node_modules/wechaty/node_modules/wechaty-puppet/dist/src/puppet.d.ts:19:8 - error TS1259: Module '"/Users/luyuchao/OneDrive/wxxcc/groupmaster/wechat-assistant-pro-master/node_modules/quick-lru/index"' can only be default-imported using the 'esModuleInterop' flag

19 import QuickLru from 'quick-lru';

node_modules/quick-lru/index.d.ts:97:1 97 export = QuickLRU;


    This module is declared with using 'export =', and can only be used with a default import when using the 'esModuleInterop' flag.

Found 2 errors.
alekye commented 2 years ago
npx tsc examples/ding-dong-bot.ts

FileBox

node_modules/file-box/dist/esm/src/file-box.d.ts:8:13 - error TS1192: Module '"http"' has no default export.

8 import type http from 'http';
              ~~~~

node_modules/file-box/dist/esm/src/file-box.d.ts:13:5 - error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.

13     #private;
       ~~~~~~~~

node_modules/file-box/dist/esm/src/file-box.type.d.ts:2:13 - error TS1192: Module '"http"' has no default export.

2 import type http from 'http';
              ~~~~

MemoryCard

node_modules/memory-card/dist/src/memory-card.d.ts:82:5 - error TS2416: Property 'set' in type 'MemoryCard' is not assignable to the same property in base type 'AsyncMapLike<any, any>'.
  Type '<T = any>(name: string, data: T) => Promise<this>' is not assignable to type 'AsyncifyMapFunction<any, any, (key: any, value: any) => Map<any, any>>'.
    Type 'Promise<this>' is not assignable to type 'Promise<AsyncMapLike<any, any>>'.
      Type 'this' is not assignable to type 'AsyncMapLike<any, any>'.
        Type 'MemoryCard' is missing the following properties from type 'AsyncMapLike<any, any>': [Symbol.iterator], [Symbol.toStringTag]

82     set<T = any>(name: string, data: T): Promise<this>;
       ~~~

Puppet (QuickLRU)

node_modules/wechaty-puppet/dist/esm/src/agents/cache-agent.d.ts:1:8 - error TS1259: Module '"/Users/alekye/Workspace/My2021/NodeProjs/wechaty-starter/node_modules/@alloc/quick-lru/index"' can only be default-imported using the 'esModuleInterop' flag

1 import QuickLru from '@alloc/quick-lru';
         ~~~~~~~~

  node_modules/@alloc/quick-lru/index.d.ts:128:1
    128 export = QuickLRU;
        ~~~~~~~~~~~~~~~~~~
    This module is declared with using 'export =', and can only be used with a default import when using the 'esModuleInterop' flag.

node_modules/wechaty/dist/esm/src/interface/sayable.d.ts:33:70 - error TS2694: Namespace '"/Users/alekye/Workspace/My2021/NodeProjs/wechaty-starter/node_modules/wechaty-puppet/dist/esm/src/mods/impls"' has no exported member 'Puppet'.

33 declare const deliverSayableConversationPuppet: (puppet: PUPPET.impl.Puppet) => (conversationId: string) => (sayableMessage: SayableMessage) => Promise<string | void>;
                                                                        ~~~~~~

node_modules/wechaty/dist/esm/src/wechaty.d.ts:13:45 - error TS2694: Namespace '"/Users/alekye/Workspace/My2021/NodeProjs/wechaty-starter/node_modules/wechaty-puppet/dist/esm/src/mods/impls"' has no exported member 'Puppet'.

13     puppet?: PuppetModuleName | PUPPET.impl.Puppet;
                                               ~~~~~~

node_modules/wechaty/dist/esm/src/wechaty.d.ts:65:37 - error TS2694: Namespace '"/Users/alekye/Workspace/My2021/NodeProjs/wechaty-starter/node_modules/wechaty-puppet/dist/esm/src/mods/impls"' has no exported member 'Puppet'.

65     protected _puppet?: PUPPET.impl.Puppet;
                                       ~~~~~~

node_modules/wechaty/dist/esm/src/wechaty.d.ts:66:31 - error TS2694: Namespace '"/Users/alekye/Workspace/My2021/NodeProjs/wechaty-starter/node_modules/wechaty-puppet/dist/esm/src/mods/impls"' has no exported member 'Puppet'.

66     get puppet(): PUPPET.impl.Puppet;
                                 ~~~~~~

node_modules/wechaty/dist/esm/src/wechaty.d.ts:213:57 - error TS2694: Namespace '"/Users/alekye/Workspace/My2021/NodeProjs/wechaty-starter/node_modules/wechaty-puppet/dist/esm/src/mods/impls"' has no exported member 'Puppet'.

213     protected initPuppetEventBridge(puppet: PUPPET.impl.Puppet): void;
                                                            ~~~~~~

node_modules/wechaty/src/io-peer/json-rpc-peer.d.ts:47:14 - error TS2416: Property 'pipe' in type 'Peer' is not assignable to the same property in base type 'Writable'.
  Type '<T extends Writable>(writable: T) => T' is not assignable to type '<T extends WritableStream>(destination: T, options?: { end?: boolean; }) => T'.
    Types of parameters 'writable' and 'destination' are incompatible.
      Type 'T' is not assignable to type 'Writable'.
        Type 'WritableStream' is missing the following properties from type 'Writable': writableEnded, writableFinished, writableHighWaterMark, writableLength, and 11 more.

47       public pipe<T extends Writable>(writable: T): T
                ~~~~

Found 11 errors.
alekye commented 2 years ago

ding-dong-bot.ts 这个demo可以运行,但是编译报错

huan commented 2 years ago

@alekye run npx tsc --skipLibCheck examples/ding-dong-bot.ts will solve your problem.

alekye commented 2 years ago

@alekye run npx tsc --skipLibCheck examples/ding-dong-bot.ts will solve your problem.

nice, it works, thank u.

huan commented 2 years ago

You are welcome!

huan commented 2 years ago

With the latest code of the Wechaty Getting Start (v1.0.7 for now), it was supported to run npm run build to build the example/ding-dong-bot.ts

huan commented 2 years ago

Close this issue because it's solved:

npx tsc --skipLibCheck examples/ding-dong-bot.ts