haxiomic / dts2hx

Converts TypeScript definition files (d.ts) to haxe externs (.hx) via the TypeScript compiler API
MIT License
131 stars 8 forks source link

Cannot redeclare block-scoped variable 'console' #80

Closed sonygod closed 3 years ago

sonygod commented 3 years ago

dts2hx@0.15.3

npm install @types/wechat-miniprogram

npx dts2hx wechat-miniprogram
haxiomic commented 3 years ago

This is an issue in the externs themselves and I get the same error when I use them: if I make a new file named test.ts that includes the wechat type definitions:

/// <reference types="wechat-miniprogram" />

And then do tsc test.ts, I get

../../.npm-global/lib/node_modules/typescript/lib/lib.dom.d.ts:18958:13 - error TS2451: Cannot redeclare block-scoped variable 'console'.

18958 declare var console: Console;
                  ~~~~~~~

  node_modules/@types/wechat-miniprogram/lib.wx.api.d.ts:18650:15
    18650 declare const console: WechatMiniprogram.Console
                        ~~~~~~~
    'console' was also declared here.

node_modules/@types/wechat-miniprogram/lib.wx.api.d.ts:18650:15 - error TS2451: Cannot redeclare block-scoped variable 'console'.

18650 declare const console: WechatMiniprogram.Console
                    ~~~~~~~

  ../../.npm-global/lib/node_modules/typescript/lib/lib.dom.d.ts:18958:13
    18958 declare var console: Console;
                      ~~~~~~~
    'console' was also declared here.

The good news is the conversion still works just fine and this is more of a warning from the typescript compiler. Nevertheless, if there are special ts config options that will resolve these error messages you can pass them in using --tsconfig

sonygod commented 3 years ago

hi,@haxiomic ,this is only for auto-complete only, you can't run without a Wechat app environment.:)

image

haxiomic commented 3 years ago

The error I posted is a ts compiler-time/autocomplete error (haven’t tested runtime)

sonygod commented 3 years ago

My screenshot show ide auto complete everything is OK use that file

On Fri, 8 Jan 2021, 21:25 George Corney, notifications@github.com wrote:

The error I posted is a ts compiler-time/autocomplete error (haven’t tested runtime)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/haxiomic/dts2hx/issues/80#issuecomment-756754186, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFWWIAFAYCSXFQ3X22H433SY4BTVANCNFSM4VYRY73Q .