mathjax / mathjax/MathJax-src

Multiple Typescript Errors

Open
#843 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
2.4k
Forks
245
Avg merge
5d 2h
Merged PRs (30d)
2

Description

Hi there,

My project uses typescript, so checks all files for errors - when it reaches this package it returns a few errors. Here is my stack trace for npx tsc --noEmit:

node_modules/mathjax-full/js/core/MmlTree/MmlFactory.d.ts:3:70 - error TS2344: Type 'MmlNodeClass' does not satisfy the constraint 'FactoryNodeClass<MmlNode>'.
  Types of parameters 'factory' and 'factory' are incompatible.
    Type 'Factory<MmlNode, FactoryNodeClass<MmlNode>>' is missing the following properties from type 'MmlFactory': MML, defaultKind, nodeMap, node

3 export declare class MmlFactory extends AbstractNodeFactory<MmlNode, MmlNodeClass> {
                                                                       ~~~~~~~~~~~~

node_modules/mathjax-full/js/core/Tree/WrapperFactory.d.ts:4:123 - error TS2344: Type 'C' does not satisfy the constraint 'FactoryNodeClass<W>'.
  Type 'WrapperClass<N, W>' is not assignable to type 'FactoryNodeClass<W>'.
    Types of parameters 'factory' and 'factory' are incompatible.
      Property 'wrap' is missing in type 'Factory<W, FactoryNodeClass<W>>' but required in type 'WrapperFactory<N, W, WrapperClass<N, W>>'.

4 export interface WrapperFactory<N extends Node, W extends Wrapper<N, W>, C extends WrapperClass<N, W>> extends Factory<W, C> {
                                                                                                                            ~

  node_modules/mathjax-full/js/core/Tree/WrapperFactory.d.ts:5:5
    5     wrap(node: N, ...args: any[]): W;
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    'wrap' is declared here.

node_modules/mathjax-full/js/core/Tree/WrapperFactory.d.ts:7:152 - error TS2344: Type 'C' does not satisfy the constraint 'FactoryNodeClass<W>'.
  Type 'WrapperClass<N, W>' is not assignable to type 'FactoryNodeClass<W>'.
    Types of parameters 'factory' and 'factory' are incompatible.
      Property 'wrap' is missing in type 'Factory<W, FactoryNodeClass<W>>' but required in type 'WrapperFactory<N, W, WrapperClass<N, W>>'.

7 export declare abstract class AbstractWrapperFactory<N extends Node, W extends Wrapper<N, W>, C extends WrapperClass<N, W>> extends AbstractFactory<W, C> implements WrapperFactory<N, W, C> {
                                                                                                                                                         ~

  node_modules/mathjax-full/js/core/Tree/WrapperFactory.d.ts:5:5
    5     wrap(node: N, ...args: any[]): W;
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    'wrap' is declared here.

node_modules/mathjax-full/js/output/common/WrapperFactory.d.ts:6:364 - error TS2344: Type 'C' does not satisfy the constraint 'WrapperClass<MmlNode, W>'.
  Type 'CommonWrapperClass<J, W, C, CC, DD, FD>' is not assignable to type 'WrapperClass<MmlNode, W>'.
    Types of parameters 'factory' and 'factory' are incompatible.
      Type 'WrapperFactory<MmlNode, W, WrapperClass<MmlNode, W>>' is missing the following properties from type 'CommonWrapperFactory<J, W, C, CC, DD, FD>': jax, Wrappers, defaultKind, nodeMap, node

6 export declare class CommonWrapperFactory<J extends CommonOutputJax<any, any, any, W, CommonWrapperFactory<J, W, C, CC, DD, FD>, FD, any>, W extends CommonWrapper<J, W, C, CC, DD, FD>, C extends CommonWrapperClass<J, W, C, CC, DD, FD>, CC extends CharOptions, DD extends DelimiterData, FD extends FontData<CC, any, DD>> extends AbstractWrapperFactory<MmlNode, W, C> {
                                                                                                                                                                                                                                                                                                                                                                             ~


Found 4 errors in 3 files.

Errors  Files
     1  node_modules/mathjax-full/js/core/MmlTree/MmlFactory.d.ts:3
     2  node_modules/mathjax-full/js/core/Tree/WrapperFactory.d.ts:4
     1  node_modules/mathjax-full/js/output/common/WrapperFactory.d.ts:6

Cheers,
Mark

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Run npx tsc --noEmit and review the reported declarations in node_modules/mathjax-full/js/core/MmlTree/MmlFactory.d.ts, node_modules/mathjax-full/js/core/Tree/WrapperFactory.d.ts, and node_modules/mathjax-full/js/output/common/WrapperFactory.d.ts. Determine the TypeScript compatibility issue behind the four errors; done means the package no longer produces these errors under the reported check.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.