vuepress / vuepress-community

:bulb: Community supported ecosystem for VuePress
https://vuepress-community.netlify.app
MIT License
81 stars 62 forks source link

[Bug Report] use `* as` syntax #39

Closed Mister-Hope closed 4 years ago

Mister-Hope commented 4 years ago

If users is using a tsconfig.json like:

{
  "compilerOptions": {
    "target": "ES6",
    "allowSyntheticDefaultImports": false,
    "esModuleInterop": false,
    "experimentalDecorators": true,
    "types": ["vuepress-types"]
  },
  "include": ["src/.vuepress/enhanceApp.ts"]
}

will cause errors below:

node_modules/vuepress-types/types/markdown.d.ts:1:8 - error TS1259: Module '"Z:/npm/vuepress-theme-hope/node_modules/vuepress-types/node_modules/@types/markdown-it/index"' can only be default-imported using the 'esModuleInterop' flag

1 import MarkdownIt from 'markdown-it'
         ~~~~~~~~~~

  node_modules/vuepress-types/node_modules/@types/markdown-it/index.d.ts:8:1
    8 export = MarkdownIt;
      ~~~~~~~~~~~~~~~~~~~~
    This module is declared with using 'export =', and can only be used with a default import when using the 'esModuleInterop' flag.

node_modules/vuepress-types/types/plugin.d.ts:3:8 - error TS1259: Module '"Z:/npm/vuepress-theme-hope/node_modules/@types/webpack-dev-server/index"' can only be default-imported using the 'esModuleInterop' flag

3 import WebpackDevServer from 'webpack-dev-server'
         ~~~~~~~~~~~~~~~~

  node_modules/@types/webpack-dev-server/index.d.ts:377:1
    377 export = WebpackDevServer;
        ~~~~~~~~~~~~~~~~~~~~~~~~~~
    This module is declared with using 'export =', and can only be used with a default import when using the 'esModuleInterop' flag.

node_modules/vuepress-types/types/plugin.d.ts:4:8 - error TS1259: Module '"Z:/npm/vuepress-theme-hope/node_modules/webpack-chain/types/index"' can only be default-imported using the 'esModuleInterop' flag

4 import Config from 'webpack-chain'
         ~~~~~~

  node_modules/webpack-chain/types/index.d.ts:5:1
    5 export = Config;
      ~~~~~~~~~~~~~~~~
    This module is declared with using 'export =', and can only be used with a default import when using the 'esModuleInterop' flag.

packages/md-enhance/src/markdown-it/footnote.ts:11:28 - error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export.

And that is a critical bug which will cause users build failure if they are using my ts plugins.

Mister-Hope commented 4 years ago

Also, I suggest this line should be removed, because you cannot force every user to turn it on. Deleting it will help better with related issue checking

Mister-Hope commented 4 years ago

There are also some issues with @vuepress/shared-utils declaration files, so my PR fails the CI. I'll open a PR on the vuepress repo first.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.