Code Monkey home page Code Monkey logo

Comments (10)

dgreensp avatar dgreensp commented on August 23, 2024 23

The simplest way to fix this issue is to set the compilerOption "esModuleInterop": true in your tsconfig.json.

The modules fast-diff and quill-delta are exported using export = because this is the only way they can be backwards-compatible with CommonJS require statements like const diff = require('fast-diff').

Using Babel, you can then write import diff from 'fast-diff' because of Babel's module interop behavior. TypeScript originally did not have this interop, forcing you to write import diff = require('fast-diff'), but this is ugly, and they changed their mind in 2.7 to be like Babel. They put the new behavior behind a flag because it is breaking, but they "highly recommend" you use the new behavior.

We could change Delta.ts to say import diff =, but the point of TypeScript's change to module interop is that no one should have to type that anymore, so let me know if turning on the new module interop isn't a valid solution for you.

from delta.

fdeguibert avatar fdeguibert commented on August 23, 2024 17

for anyone coming through this problem, i believe the actual solution is not to mess with the compiler options but just to be careful with dependencies versions.
If you use Quill, the default version is a v1.x.
but the default @type/quill version is a v2.x.

juste use a @type/quill v1.x and everything will be all right ;)

from delta.

whyboris avatar whyboris commented on August 23, 2024 7

I'm on Angular 9 with:

"quill": "1.3.7",
"@types/quill": "1.3.10",

Works fine, but when I update @types/quill to version 2.0.3 I get the above-mentioned-error 🤷‍♂️

from delta.

sumitvekariya avatar sumitvekariya commented on August 23, 2024 3

file: node_modules\fast-diff\diff.d.ts (line number 20) export = diff to export default diff
file: node_modules\quill-delta\dist\Delta.d.ts (line number 32) export = Delta; to export default Delta will solve the issue. Working well for me now.

from delta.

wvyeun avatar wvyeun commented on August 23, 2024 2

I have the same error when I try to
yarn add react-quill
I'm using React and Typescript
it seems to be coming from Delta.d.ts
How can I resolve this?

from delta.

whyboris avatar whyboris commented on August 23, 2024 1

I was able to make the error go away by editing the tsconfig.json in two different ways:

  • "esModuleInterop": true,
  • "allowSyntheticDefaultImports": true,

Add either of the above lines inside the "compilerOptions": { ... } to fix ✅

from delta.

boscohyun avatar boscohyun commented on August 23, 2024

import diff from 'fast-diff';
->
import diff = require('fast-diff');

from delta.

dave0688 avatar dave0688 commented on August 23, 2024

@dgreensp What a nice answer, it solved the issue. Thanks :)

from delta.

Olgagr avatar Olgagr commented on August 23, 2024

@dgreensp This is not working for me. I turned on this option, this is my tsconfig.ts file:

  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "module": "esnext",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "allowSyntheticDefaultImports": true,
    "importHelpers": true,
    "esModuleInterop": true,
    "target": "es5",
    "baseUrl": "./src",
    "paths": {
      "@angular/*": ["../node_modules/@angular/*"],
      "app/*": ["app/*"],
      "shared/*": ["app/shared/*"],
      "shared": ["app/shared"],
      "spec-helpers/*": ["app/spec-helpers/*"],
      "spec-helpers": ["app/spec-helpers"],
      "admin_app/*": ["app/admin_app/*"],
      "admin_app": ["app/admin_app"],
      "style_guides_app/*": ["app/style_guides_app/*"],
      "style_guides_app": ["app/style_guides_app"]
    },
    "typeRoots": ["node_modules/@types"],
    "types": ["node", "jasmine", "googlemaps"],
    "lib": ["es2018", "dom"]
  }
}

I still get the error:

node_modules/@types/quill/node_modules/quill-delta/dist/Delta.d.ts:1:8 - error TS1192: Module '"/home/admin/Documents/projects/project-angular/node_modules/@types/quill/node_modules/fast-diff/diff"' has no default export.

My Typescript version is ~3.2.2

from delta.

Hukutus avatar Hukutus commented on August 23, 2024

I'm having the same problem, and esModuleInterop didn't work. Had to remove @types/quill for now because it caused build to fail.

from delta.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.