Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript cannot compile with "strict: true" #2621

Closed
1 task done
BlackGlory opened this issue Jan 30, 2021 · 11 comments
Closed
1 task done

TypeScript cannot compile with "strict: true" #2621

BlackGlory opened this issue Jan 30, 2021 · 11 comments
Labels
Outdate This issue is too old to be resolved

Comments

@BlackGlory
Copy link

  • I have searched the issues of this repository and believe that this is not a duplicate.

Reproduction link

https://repl.it/@BlackGlory/g6

Steps to reproduce

index.ts

import { Graph } from '@antv/g6'

package.json

{
  "scripts": {
    "build": "tsc --project tsconfig.json"
  },
  "dependencies": {
    "@antv/g6": "^4.1.6",
    "typescript": "^4.1.3"
  }
}

tsconfig.json

{
  "compilerOptions": {
    "target": "ES2020"
  , "module": "CommonJS"
  , "strict": true
  }
}
yarn build
Environment Info
g6 4.1.6
System -
Browser -

node_modules/@antv/g6-core/lib/graph/graph.d.ts:199:5 - error TS2416: Property 'updateBehavior' in type 'AbstractGraph' is not assignable to the same property in base type 'IAbstractGraph'.
  Type '(behavior: string, newCfg: object, mode?: string | undefined) => AbstractGraph' is not assignable to type '(behavior: string, newCfg: object, modes: string | string[]) => AbstractGraph'.
    Types of parameters 'mode' and 'modes' are incompatible.
      Type 'string | string[]' is not assignable to type 'string | undefined'.
        Type 'string[]' is not assignable to type 'string'.

199     updateBehavior(behavior: string, newCfg: object, mode?: string): AbstractGraph;
        ~~~~~~~~~~~~~~

node_modules/@antv/g6-core/lib/item/combo.d.ts:11:5 - error TS2416: Property 'getShapeCfg' in type 'Combo' is not assignable to the same property in base type 'ICombo'.
  Type '(model: ComboConfig) => ComboConfig' is not assignable to type '(model: ModelConfig) => ModelConfig'.
    Types of parameters 'model' and 'model' are incompatible.
      Property 'id' is missing in type 'ModelConfig' but required in type 'ComboConfig'.

11     getShapeCfg(model: ComboConfig): ComboConfig;
       ~~~~~~~~~~~

  node_modules/@antv/g6-core/lib/types/index.d.ts:407:5
    407     id: string;
            ~~
    'id' is declared here.

node_modules/@antv/g6-core/lib/item/combo.d.ts:66:5 - error TS2416: Property 'removeNode' in type 'Combo' is not assignable to the same property in base type 'ICombo'.
  Type '(node: INode) => boolean' is not assignable to type '(node: string | INode) => boolean'.
    Types of parameters 'node' and 'node' are incompatible.
      Type 'string | INode' is not assignable to type 'INode'.
        Type 'string' is not assignable to type 'INode'.

66     removeNode(node: INode): boolean;
       ~~~~~~~~~~

node_modules/@antv/g6-core/lib/item/node.d.ts:68:5 - error TS2416: Property 'isOnlyMove' in type 'Node' is not assignable to the same property in base type 'INode'.
  Type '(cfg: NodeConfig) => boolean' is not assignable to type '(cfg: ModelConfig) => boolean'.
    Types of parameters 'cfg' and 'cfg' are incompatible.
      Property 'id' is missing in type 'ModelConfig' but required in type 'NodeConfig'.

68     isOnlyMove(cfg: NodeConfig): boolean;
       ~~~~~~~~~~

  node_modules/@antv/g6-core/lib/types/index.d.ts:339:5
    339     id: string;
            ~~
    'id' is declared here.

node_modules/@antv/g6-pc/lib/graph/graph.d.ts:5:22 - error TS2420: Class 'Graph' incorrectly implements interface 'IGraph'.
  Types of property 'updateBehavior' are incompatible.
    Type '(behavior: string, newCfg: object, mode?: string | undefined) => AbstractGraph' is not assignable to type '(behavior: string, newCfg: object, modes: string | string[]) => AbstractGraph'.

5 export default class Graph extends AbstractGraph implements IGraph {
                       ~~~~~

node_modules/@antv/g6-pc/lib/graph/tree-graph.d.ts:4:22 - error TS2420: Class 'TreeGraph' incorrectly implements interface 'ITreeGraph'.
  Types of property 'updateBehavior' are incompatible.
    Type '(behavior: string, newCfg: object, mode?: string | undefined) => AbstractGraph' is not assignable to type '(behavior: string, newCfg: object, modes: string | string[]) => AbstractGraph'.

4 export default class TreeGraph extends Graph implements ITreeGraph {
                       ~~~~~~~~~


Found 6 errors.
@Yanyan-Wang
Copy link
Contributor

Try v4.1.7 pls

@BlackGlory
Copy link
Author

@Yanyan-Wang

v4.1.7

node_modules/@antv/g6-core/lib/index.d.ts:1:23 - error TS2688: Cannot find type definition file for '_gl-matrix@3.3.0@gl-matrix'.

1 /// <reference types="_gl-matrix@3.3.0@gl-matrix" />
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@antv/g6-core/lib/util/index.d.ts:1:23 - error TS2688: Cannot find type definition file for '_gl-matrix@3.3.0@gl-matrix'.

1 /// <reference types="_gl-matrix@3.3.0@gl-matrix" />
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@antv/g6-plugin/node_modules/@antv/g6-core/lib/graph/graph.d.ts:199:5 - error TS2416: Property 'updateBehavior' in type 'AbstractGraph' is not assignable to the same property in base type 'IAbstractGraph'.
  Type '(behavior: string, newCfg: object, mode?: string | undefined) => AbstractGraph' is not assignable to type '(behavior: string, newCfg: object, modes: string | string[]) => AbstractGraph'.
    Types of parameters 'mode' and 'modes' are incompatible.
      Type 'string | string[]' is not assignable to type 'string | undefined'.
        Type 'string[]' is not assignable to type 'string'.

199     updateBehavior(behavior: string, newCfg: object, mode?: string): AbstractGraph;
        ~~~~~~~~~~~~~~

node_modules/@antv/g6-plugin/node_modules/@antv/g6-core/lib/item/combo.d.ts:11:5 - error TS2416: Property 'getShapeCfg' in type 'Combo' is not assignable to the same property in base type 'ICombo'.
  Type '(model: ComboConfig) => ComboConfig' is not assignable to type '(model: ModelConfig) => ModelConfig'.
    Types of parameters 'model' and 'model' are incompatible.
      Property 'id' is missing in type 'ModelConfig' but required in type 'ComboConfig'.

11     getShapeCfg(model: ComboConfig): ComboConfig;
       ~~~~~~~~~~~

  node_modules/@antv/g6-plugin/node_modules/@antv/g6-core/lib/types/index.d.ts:407:5
    407     id: string;
            ~~
    'id' is declared here.

node_modules/@antv/g6-plugin/node_modules/@antv/g6-core/lib/item/combo.d.ts:66:5 - error TS2416: Property 'removeNode' in type 'Combo' is not assignable to the same property in base type 'ICombo'.
  Type '(node: INode) => boolean' is not assignable to type '(node: string | INode) => boolean'.
    Types of parameters 'node' and 'node' are incompatible.
      Type 'string | INode' is not assignable to type 'INode'.
        Type 'string' is not assignable to type 'INode'.

66     removeNode(node: INode): boolean;
       ~~~~~~~~~~

node_modules/@antv/g6-plugin/node_modules/@antv/g6-core/lib/item/node.d.ts:68:5 - error TS2416: Property 'isOnlyMove' in type 'Node' is not assignable to the same property in base type 'INode'.
  Type '(cfg: NodeConfig) => boolean' is not assignable to type '(cfg: ModelConfig) => boolean'.
    Types of parameters 'cfg' and 'cfg' are incompatible.
      Property 'id' is missing in type 'ModelConfig' but required in type 'NodeConfig'.

68     isOnlyMove(cfg: NodeConfig): boolean;
       ~~~~~~~~~~

  node_modules/@antv/g6-plugin/node_modules/@antv/g6-core/lib/types/index.d.ts:339:5
    339     id: string;
            ~~
    'id' is declared here.


Found 6 errors.

@Yanyan-Wang
Copy link
Contributor

What if configuring "skipLibCheck":true to ignore type checking of all declaration files (*.d.ts) for third libraries?

@BlackGlory
Copy link
Author

@Yanyan-Wang That's unacceptable. skipLibCheck is used to shorten compilation time, not to ignore libraries with errors.

@Yanyan-Wang
Copy link
Contributor

getShapeCfg

pls check the version of @antv/core, it looks like that the core is not updated

@BlackGlory
Copy link
Author

@Yanyan-Wang Please upgrade @antv/g6-plugin

+-- @antv/g6@4.1.7
| `-- @antv/g6-pc@0.0.12
|   +-- @ant-design/colors@4.0.5
|   | `-- tinycolor2@1.4.2
|   +-- @antv/algorithm@0.0.7
|   +-- @antv/dom-util@2.0.3
|   | `-- tslib@2.1.0
|   +-- @antv/event-emitter@0.1.2
|   +-- @antv/g-base@0.5.5
|   | +-- @antv/event-emitter@0.1.2 deduped
|   | +-- @antv/g-math@0.1.7 deduped
|   | +-- @antv/matrix-util@3.1.0-beta.2
|   | | +-- @antv/util@2.0.10 deduped
|   | | +-- gl-matrix@3.3.0 deduped
|   | | `-- tslib@1.14.1
|   | +-- @antv/path-util@2.0.9 deduped
|   | +-- @antv/util@2.0.10 deduped
|   | +-- @types/d3-timer@1.0.10
|   | +-- d3-ease@1.0.7
|   | +-- d3-interpolate@1.4.0
|   | | `-- d3-color@1.4.1
|   | +-- d3-timer@1.0.10
|   | +-- detect-browser@5.2.0
|   | `-- tslib@2.1.0 deduped
|   +-- @antv/g-canvas@0.5.6
|   | +-- @antv/g-base@0.5.5 deduped
|   | +-- @antv/g-math@0.1.7 deduped
|   | +-- @antv/matrix-util@3.1.0-beta.2 deduped
|   | +-- @antv/path-util@2.0.9 deduped
|   | +-- @antv/util@2.0.10 deduped
|   | +-- gl-matrix@3.3.0
|   | `-- tslib@2.1.0 deduped
|   +-- @antv/g-math@0.1.7
|   | +-- @antv/util@2.0.10 deduped
|   | `-- gl-matrix@3.3.0 deduped
|   +-- @antv/g-svg@0.5.6
|   | +-- @antv/g-base@0.5.5 deduped
|   | +-- @antv/g-math@0.1.7 deduped
|   | +-- @antv/util@2.0.10 deduped
|   | +-- detect-browser@5.2.0 deduped
|   | `-- tslib@2.1.0 deduped
|   +-- @antv/g-webgpu@0.5.2
|   | +-- @antv/g-webgpu-core@0.5.2
|   | | +-- eventemitter3@4.0.7
|   | | +-- gl-matrix@3.3.0 deduped
|   | | +-- inversify@5.0.5 deduped
|   | | +-- inversify-inject-decorators@3.1.0 deduped
|   | | +-- lodash@4.17.20 deduped
|   | | +-- probe.gl@3.3.0 deduped
|   | | `-- reflect-metadata@0.1.13 deduped
|   | +-- @antv/g-webgpu-engine@0.5.2
|   | | +-- @antv/g-webgpu-core@0.5.2 deduped
|   | | +-- @webgpu/glslang@0.0.15
|   | | +-- @webgpu/types@0.0.31 deduped
|   | | +-- gl-matrix@3.3.0 deduped
|   | | +-- hammerjs@2.0.8 deduped
|   | | +-- inversify@5.0.5 deduped
|   | | +-- inversify-inject-decorators@3.1.0 deduped
|   | | +-- lodash@4.17.20 deduped
|   | | +-- probe.gl@3.3.0 deduped
|   | | +-- reflect-metadata@0.1.13 deduped
|   | | `-- regl@1.7.0
|   | +-- @webgpu/types@0.0.31
|   | +-- gl-matrix@3.3.0 deduped
|   | +-- gl-vec2@1.3.0
|   | +-- hammerjs@2.0.8
|   | +-- inversify@5.0.5
|   | +-- inversify-inject-decorators@3.1.0
|   | +-- lodash@4.17.20
|   | +-- polyline-miter-util@1.0.1
|   | | `-- gl-vec2@1.3.0 deduped
|   | +-- polyline-normals@2.0.2
|   | | `-- polyline-miter-util@1.0.1 deduped
|   | +-- probe.gl@3.3.0
|   | | +-- @babel/runtime@7.12.5
|   | | | `-- regenerator-runtime@0.13.7
|   | | `-- @probe.gl/stats@3.3.0
|   | |   `-- @babel/runtime@7.12.5 deduped
|   | `-- reflect-metadata@0.1.13
|   +-- @antv/g6-core@0.0.9
|   | +-- @antv/algorithm@0.0.7 deduped
|   | +-- @antv/dom-util@2.0.3 deduped
|   | +-- @antv/event-emitter@0.1.2 deduped
|   | +-- @antv/g-base@0.5.5 deduped
|   | +-- @antv/g-math@0.1.7 deduped
|   | +-- @antv/matrix-util@3.1.0-beta.2 deduped
|   | +-- @antv/path-util@2.0.9 deduped
|   | +-- @antv/scale@0.3.7 deduped
|   | +-- @antv/util@2.0.10 deduped
|   | `-- ml-matrix@6.6.0 deduped
|   +-- @antv/g6-element@0.0.8
|   | +-- @antv/g-base@0.5.5 deduped
|   | +-- @antv/g6-core@0.0.9 deduped
|   | `-- @antv/util@2.0.10 deduped
|   +-- @antv/g6-plugin@0.0.8
|   | +-- @antv/dom-util@2.0.3 deduped
|   | +-- @antv/g-base@0.5.5 deduped
|   | +-- @antv/g-canvas@0.5.6 deduped
|   | +-- @antv/g-svg@0.5.6 deduped
|   | +-- @antv/g6-core@0.0.8
|   | | +-- @antv/algorithm@0.0.7 deduped
|   | | +-- @antv/dom-util@2.0.3 deduped
|   | | +-- @antv/event-emitter@0.1.2 deduped
|   | | +-- @antv/g-base@0.5.5 deduped
|   | | +-- @antv/g-math@0.1.7 deduped
|   | | +-- @antv/matrix-util@3.1.0-beta.2
|   | | | +-- @antv/util@2.0.10 deduped
|   | | | +-- gl-matrix@3.3.0 deduped
|   | | | `-- tslib@1.14.1
|   | | +-- @antv/path-util@2.0.9 deduped
|   | | +-- @antv/scale@0.3.7 deduped
|   | | +-- @antv/util@2.0.10 deduped
|   | | `-- ml-matrix@6.6.0 deduped
|   | +-- @antv/matrix-util@3.0.4
|   | | +-- @antv/util@2.0.10 deduped
|   | | +-- gl-matrix@3.3.0 deduped
|   | | `-- tslib@2.1.0 deduped
|   | +-- @antv/scale@0.3.7 deduped
|   | +-- @antv/util@2.0.10 deduped
|   | `-- insert-css@2.0.0 deduped
|   +-- @antv/hierarchy@0.6.6
|   | `-- @antv/util@2.0.10 deduped
|   +-- @antv/layout@0.0.16
|   | +-- @antv/g-webgpu@0.5.2 deduped
|   | +-- d3-force@2.1.1 deduped
|   | +-- dagre@0.8.5 deduped
|   | `-- ml-matrix@6.6.0 deduped
|   +-- @antv/matrix-util@3.0.4
|   | +-- @antv/util@2.0.10 deduped
|   | +-- gl-matrix@3.3.0 deduped
|   | `-- tslib@2.1.0 deduped
|   +-- @antv/path-util@2.0.9
|   | +-- @antv/util@2.0.10 deduped
|   | `-- tslib@2.1.0 deduped
|   +-- @antv/scale@0.3.7
|   | +-- @antv/util@2.0.10 deduped
|   | +-- fecha@4.2.0
|   | `-- tslib@2.1.0 deduped
|   +-- @antv/util@2.0.10
|   | `-- tslib@2.1.0 deduped
|   +-- color@3.1.3
|   | +-- color-convert@1.9.3
|   | | `-- color-name@1.1.3
|   | `-- color-string@1.5.4
|   |   +-- color-name@1.1.4
|   |   `-- simple-swizzle@0.2.2
|   |     `-- is-arrayish@0.3.2
|   +-- d3-force@2.1.1
|   | +-- d3-dispatch@2.0.0
|   | +-- d3-quadtree@2.0.0
|   | `-- d3-timer@2.0.0
|   +-- dagre@0.8.5
|   | +-- graphlib@2.1.8
|   | | `-- lodash@4.17.20 deduped
|   | `-- lodash@4.17.20 deduped
|   +-- insert-css@2.0.0
|   `-- ml-matrix@6.6.0
|     `-- ml-array-rescale@1.3.2
|       +-- is-any-array@0.1.0
|       | `-- rollup@1.32.1
|       |   +-- @types/estree@0.0.46
|       |   +-- @types/node@14.14.22
|       |   `-- acorn@7.4.1
|       +-- ml-array-max@1.2.0
|       | `-- is-any-array@0.1.0 deduped
|       `-- ml-array-min@1.2.0
|         `-- is-any-array@0.1.0 deduped
`-- typescript@4.1.3

@billowstao
Copy link

Add "skipLibCheck": true, to tsconfig.json's compilerOptions can round this problem. But if you don't do that, Angular (version 11), G6 (version 4.25), and TypeScript (version 4.1.5) still have this problem.

Instead of skipping type checking with configuration items, you should fix this.

The error message

Error: node_modules/@antv/g6-core/lib/index.d.ts:1:23 - error TS2688: Cannot find type definition file for '_gl-matrix@3.3.0@gl-matrix'.

1 /// <reference types="_gl-matrix@3.3.0@gl-matrix" />
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~

Error: node_modules/@antv/g6-core/lib/util/index.d.ts:1:23 - error TS2688: Cannot find type definition file for '_gl-matrix@3.3.0@gl-matrix'.

1 /// <reference types="_gl-matrix@3.3.0@gl-matrix" />

@plakyda-codefresh
Copy link

any news about that?
g6 v.4.3.5 still facing this issue

@Lisa1787
Copy link

Lisa1787 commented Mar 23, 2022

Failed to compile.

./node_modules/@antv/g6-core/lib/types/index.d.ts
TypeScript error in ./node_modules/@antv/g6-core/lib/types/index.d.ts(24,37):
Type expected. TS1110

22 | export declare type GraphTimingEvents = 'beforerender' | 'afterrender' | 'beforeadditem' | 'afteradditem' | 'beforeremoveitem' | 'afterremoveitem' | 'beforeupdateitem' | 'afterupdateitem' | 'beforeitemvisibilitychange' | 'afteritemvisibilitychange' | 'beforeitemstatechange' | 'afteritemstatechange' | 'beforeitemrefresh' | 'afteritemrefresh' | 'beforeitemstatesclear' | 'afteritemstatesclear' | 'beforemodechange' | 'aftermodechange' | 'beforelayout' | 'afterlayout' | 'beforegraphrefreshposition' | 'aftergraphrefreshposition' | 'beforegraphrefresh' | 'aftergraphrefresh' | 'beforeanimate' | 'afteranimate' | 'beforecreateedge' | 'aftercreateedge' | 'beforecollapseexpandcombo' | 'aftercollapseexpandcombo' | 'graphstatechange' | 'afteractivaterelations' | 'nodeselectChange' | 'itemcollapsed' | 'tooltipchange' | 'wheelzoom' | 'viewportchange' | 'dragnodeend' | 'stackchange' | 'beforepaint' | 'afterpaint';
23 | declare type MobileInteractionEvent = 'tap' | 'pinchstart' | 'pinmove' | 'panstart' | 'panmove' | 'panend';

24 | export declare type NodeEventType = node:${NodeInteractionEvent};
| ^
25 | export declare type EdgeEventType = edge:${EdgeInteractionEvent};
26 | export declare type ComboEventType = combo:${ComboInteractionEvent};
27 | export declare type CanvasEventType = canvas:${CanvasInteractionEvent};

@supuwoerc
Copy link

Failed to compile.

./node_modules/@antv/g6-core/lib/types/index.d.ts TypeScript error in ./node_modules/@antv/g6-core/lib/types/index.d.ts(24,37): Type expected. TS1110

22 | export declare type GraphTimingEvents = 'beforerender' | 'afterrender' | 'beforeadditem' | 'afteradditem' | 'beforeremoveitem' | 'afterremoveitem' | 'beforeupdateitem' | 'afterupdateitem' | 'beforeitemvisibilitychange' | 'afteritemvisibilitychange' | 'beforeitemstatechange' | 'afteritemstatechange' | 'beforeitemrefresh' | 'afteritemrefresh' | 'beforeitemstatesclear' | 'afteritemstatesclear' | 'beforemodechange' | 'aftermodechange' | 'beforelayout' | 'afterlayout' | 'beforegraphrefreshposition' | 'aftergraphrefreshposition' | 'beforegraphrefresh' | 'aftergraphrefresh' | 'beforeanimate' | 'afteranimate' | 'beforecreateedge' | 'aftercreateedge' | 'beforecollapseexpandcombo' | 'aftercollapseexpandcombo' | 'graphstatechange' | 'afteractivaterelations' | 'nodeselectChange' | 'itemcollapsed' | 'tooltipchange' | 'wheelzoom' | 'viewportchange' | 'dragnodeend' | 'stackchange' | 'beforepaint' | 'afterpaint';
23 | declare type MobileInteractionEvent = 'tap' | 'pinchstart' | 'pinmove' | 'panstart' | 'panmove' | 'panend';

24 | export declare type NodeEventType = node:${NodeInteractionEvent};
| ^
25 | export declare type EdgeEventType = edge:${EdgeInteractionEvent};
26 | export declare type ComboEventType = combo:${ComboInteractionEvent};
27 | export declare type CanvasEventType = canvas:${CanvasInteractionEvent};

我也遇到了这个问题,请问你解决了嘛?

@Aarebecca Aarebecca added the Outdate This issue is too old to be resolved label Dec 8, 2023
Copy link

github-actions bot commented Dec 8, 2023

This issue has been closed because it has been outdate for a long time.
Please open a new issue if you still need help.
这个 issue 已经被关闭,因为 它已经过期很久了
如果你仍然需要帮助,请创建一个新的 issue。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Outdate This issue is too old to be resolved
Projects
None yet
Development

No branches or pull requests

7 participants