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

[Bug]: typescript errors in 6.0.0-beta10 #9040

Open
7 tasks done
catapop84 opened this issue Jun 20, 2023 · 5 comments
Open
7 tasks done

[Bug]: typescript errors in 6.0.0-beta10 #9040

catapop84 opened this issue Jun 20, 2023 · 5 comments
Labels
types Typescript related

Comments

@catapop84
Copy link

CheckList

  • I agree to follow this project's Code of Conduct
  • I have read and followed the Contributing Guide
  • I have read and followed the Issue Tracker Guide
  • I have searched and referenced existing issues and discussions
  • I am filing a BUG report.
  • I have managed to reproduce the bug after upgrading to the latest version
  • I have created an accurate and minimal reproduction

Version

6.0.0-beta9

In What environments are you experiencing the problem?

No response

Node Version (if applicable)

18.16.0

Link To Reproduction

https://stackblitz.com/edit/stackblitz-starters-bcvgpq?file=src%2Ftest-fabric%2Ftest-fabric.component.ts

Steps To Reproduce

I'm trying to embed fabricjs in an Angular project. This is a new project . I only try to import Canvas :
import {Canvas} from "fabric";

At compilation I'm receiving the following typescript errors:

Error: node_modules/fabric/dist/src/filters/HueRotation.d.ts:14:22 - error TS2417: Class static side 'typeof HueRotation' incorrectly extends base class static side 'typeof ColorMatrix'.
  The types of 'defaults.mainParameter' are incompatible between these types.
    Type 'keyof HueRotation | undefined' is not assignable to type 'keyof ColorMatrix | undefined'.

14 export declare class HueRotation extends ColorMatrix {

and

Error: node_modules/fabric/dist/src/shapes/Image.d.ts:33:22 - error TS2420: Class 'Image<Props, SProps, EventSpec>' incorrectly implements interface 'ImageProps'.
  Property 'crossOrigin' is missing in type 'Image<Props, SProps, EventSpec>' but required in type 'ImageProps'.

33 export declare class Image<Props extends TProps<ImageProps> = Partial<ImageProps>, SProps extends SerializedImageProps = SerializedImageProps, EventSpec extends ObjectEvents = ObjectEvents> extends FabricObject<Props, SProps, EventSpec> implements ImageProps {
                        ~~~~~

  node_modules/fabric/dist/src/shapes/Image.d.ts:15:5
    15     crossOrigin: string | null;
           ~~~~~~~~~~~
    'crossOrigin' is declared here.

My tsconfig.json is the default one when you create a new angular project.

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "forceConsistentCasingInFileNames": true,
    "strict": true,
    "noImplicitOverride": true,
    "noPropertyAccessFromIndexSignature": true,
    "noImplicitReturns": true,
    "noFallthroughCasesInSwitch": true,
    "sourceMap": true,
    "declaration": false,
    "downlevelIteration": true,
    "experimentalDecorators": true,
    "moduleResolution": "node",
    "importHelpers": true,
    "target": "ES2022",
    "module": "ES2022",
    "useDefineForClassFields": false,
    "lib": [
      "ES2022",
      "dom"
    ]
  },
  "angularCompilerOptions": {
    "enableI18nLegacyMessageIdFormat": false,
    "strictInjectionParameters": true,
    "strictInputAccessModifiers": true,
    "strictTemplates": true
  }
}

Expected Behavior

should not receive any of those error

Actual Behavior

receive compilation errors

Error Message & Stack Trace

No response

@ShaMan123 ShaMan123 added the types Typescript related label Jun 20, 2023
@catapop84
Copy link
Author

Some updates to wrong types:

Error: node_modules/fabric/dist/src/shapes/Text/Text.d.ts:194:5 - error TS2416: Property 'path' in type 'Text<Props, SProps, EventSpec>' is not assignable to the same property in base type 'UniqueTextProps'.

and

Error: node_modules/fabric/dist/src/shapes/Textbox.d.ts:184:5 - error TS2416: Property 'toObject' in type 'Textbox' is not assignable to the same property in base type 'IText<ITextProps, SerializedITextProps, ITextEvents>'.

and some duplicate

Error: node_modules/fabric/dist/src/shapes/Path.d.ts:38:17 - error TS2300: Duplicate identifier 'path'.

38     constructor(path: TComplexPathData | string, { path, left, top, ...options }?: Partial<Props>);

@jiayihu
Copy link
Contributor

jiayihu commented Jun 27, 2023

#9014 should fix the toObject issue

@CommanderAlchemy
Copy link

I downloaded the latest "6.0.0-beta15" and also got this issue.


Error: node_modules/fabric/dist/src/filters/HueRotation.d.ts:14:22 - error TS2417: Class static side 'typeof HueRotation' incorrectly extends base class static side 'typeof ColorMatrix'.
  The types of 'defaults.mainParameter' are incompatible between these types.
    Type 'keyof HueRotation | undefined' is not assignable to type 'keyof ColorMatrix | undefined'.

14 export declare class HueRotation extends ColorMatrix {
                        ~~~~~~~~~~~


Error: node_modules/fabric/dist/src/shapes/Path.d.ts:39:17 - error TS2300: Duplicate identifier 'path'.

39     constructor(path: TComplexPathData | string, { path, left, top, ...options }?: Partial<Props>);
                   ~~~~


Error: node_modules/fabric/dist/src/shapes/Path.d.ts:39:52 - error TS2300: Duplicate identifier 'path'.

39     constructor(path: TComplexPathData | string, { path, left, top, ...options }?: Partial<Props>);

@Smrtnyk
Copy link

Smrtnyk commented Nov 24, 2023

same here

@Smrtnyk
Copy link

Smrtnyk commented Nov 29, 2023

I fixed the issue by making sure nothing gets imported from fabric/src
and also skipLibCheck is off on tsconfig

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
types Typescript related
Projects
None yet
Development

No branches or pull requests

5 participants