weiran-zsd / dts-cli

Zero-config CLI for TypeScript package development
MIT License
439 stars 23 forks source link

allowImportingTsExtensions error when creating/building project #208

Closed Merlin04 closed 7 months ago

Merlin04 commented 7 months ago

Current Behavior

If I run npx dts-cli create hackend-frontend and choose to create a React library, the dts build step at the end of the process (and running that command manually) causes this error:

RollupError: error TS5096: Option 'allowImportingTsExtensions' can only be used when either 'noEmit' or 'emitDeclarationOnly' is set.

I tried setting allowImportingTsExtensions to false in both tsconfigs (library and example) but I still get that error when trying to build.

Your environment

  System:
    OS: Linux 6.6 openSUSE Tumbleweed 20231226
    CPU: (16) x64 12th Gen Intel(R) Core(TM) i7-1260P
    Memory: 21.11 GB / 46.76 GB
    Container: Yes
    Shell: 0.14.1 - /usr/bin/xonsh
  Binaries:
    Node: 21.4.0 - /usr/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.2.4 - /usr/bin/npm
    pnpm: 8.14.0 - /usr/local/bin/pnpm
    bun: 1.0.11 - ~/.bun/bin/bun
    Watchman: 4.9.0 - /usr/bin/watchman
  Browsers:
    Chromium: 119.0.6045.199
  npmPackages:
    dts-cli: ^2.0.3 => 2.0.3 
    typescript: ^5.3.3 => 5.3.3
aladdin-add commented 7 months ago

seems it was added in the new vite-react release, you can just add the config in your tsconfig.json:

  "compilerOptions": {
    "allowImportingTsExtensions": false
  },
aladdin-add commented 7 months ago

it was resolved by adding the config on my macos. can you provide a repro if not, thanks! 🙏

osbornm commented 7 months ago

@aladdin-add turning off that setting generates the following error:

node_modules/@types/react/index.d.ts:32:1
    32 export = React;
       ~~~~~~~~~~~~~~~
    This module is declared with 'export =', and can only be used with a default import when using the 'allowSyntheticDefaultImports' flag.

to repo simply run npx dts-cli create my-lib then try to build my-lib using npm run build

aladdin-add commented 7 months ago

@osbornm I was not able to repro🤔.

I have pushed a new release. please provide a repro if you still encountered it, thanks! 🙏

osbornm commented 7 months ago

@aladdin-add still happens using react-with-storybook option

Screenshot 2024-01-09 at 9 03 24 AM