Code Monkey home page Code Monkey logo

Comments (5)

jhchen avatar jhchen commented on August 22, 2024

Is this causing issues and if so what? The desire is to overload this function for ScrollBlot's needs for an array of mutations and ScrollBlot only pass context as the only parameter when it calls its superclass's optimize. The Typescript does not complain so I'm not seeing why it would be invalid.

from parchment.

moward avatar moward commented on August 22, 2024

The TypeScript compiler error only appears for me with the option strictNullChecks turned on. Since neither JS nor TS support method overloading, overridden methods need to be typeable as the superclass method type.

I think a simple fix would be switching the order of the arguments on ScrollBlot's optimize. I imagine this might break any consumers of ScrollBlot though.

from parchment.

jhchen avatar jhchen commented on August 22, 2024

A lot of other errors appear if strictNullChecks is turned on. Switching the order also does not get rid of the error as ContainerBlot's signature is only one parameter and ScrollBlot is two. I'm not seeing the practical benefits of this issue. Can you clarify what you are trying to do and how this is getting in the way?

from parchment.

quill-bot avatar quill-bot commented on August 22, 2024

Closing inactive issue.

from parchment.

crysehillmes avatar crysehillmes commented on August 22, 2024

There is an answer in TypeScript function overloading:

You can declare an overloaded function by declaring the function as having a type which has multiple invocation signatures

So, this might work:

optimize: {
  (context: { [key: string]: any }): void;
  (mutations: MutationRecord[], context: { [key: string]: any }): void;
};

from parchment.

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.