pixi-ease icon indicating copy to clipboard operation
pixi-ease copied to clipboard

erros while compiling

Open sreenadh09 opened this issue 5 years ago • 5 comments

Here is the error from the console

ERROR in node_modules/pixi-ease/@types/index.d.ts:63:5 - error TS2416: Property 'on' in type 'Ease' is not assignable to the same property in base type 'EventEmitter<string | symbol, any>'.
  Type '(event: "complete" | "each", fn: (ease: Ease) => void, context?: any) => this' is not assignable to type '<T extends string | symbol>(event: T, fn: (...args: any[]) => void, context?: any) => this'.
    Types of parameters 'event' and 'event' are incompatible.
      Type 'T' is not assignable to type '"complete" | "each"'.
        Type 'string | symbol' is not assignable to type '"complete" | "each"'.
          Type 'string' is not assignable to type '"complete" | "each"'.
            Type 'T' is not assignable to type '"each"'.
              Type 'string | symbol' is not assignable to type '"each"'.
                Type 'string' is not assignable to type '"each"'.

63     on(event: 'each' | 'complete', fn: (ease: Ease) => void, context?: any): this

Using latest version of pixi-ease, angular 9. Are there any types to be installed for this error to go away? Thanks

sreenadh09 avatar Aug 06 '20 07:08 sreenadh09

Types are defined in pixi-ease, but I haven't updated them in a while (I don't usually use typescript, so I'm not great at keeping it updated). If you submit a PR with the updated types, I can review and publish it. Alternatively, you can also cut-and-paste the index file here and I can create it if you don't want to go through the PR process.

davidfig avatar Aug 10 '20 23:08 davidfig

Maybe consider to remove typings if they are not kept consistent with the actual code by people who commit the changes. You can actually tell the typescript compiler to allow to use pure javascript (everything will be any type then).

Right now, I am fixing this for you guy this time <3

uahic avatar Nov 12 '20 18:11 uahic

import * as PIXI from 'pixi.js'
import { EventEmitter } from 'eventemitter3'

interface EaseOptions {
    duration?: number
    ease?: string | Function
    useRaf?: boolean
    ticker?: PIXI.Ticker
    maxFrame?: number
}

interface EaseParams {
    x?: number
    y?: number
    position?: PIXI.DisplayObject | PIXI.Point
    width?: number
    height?: number
    scale?: number
    scaleX?: number
    scaleY?: number
    alpha?: number
    rotation?: number
    face?: PIXI.DisplayObject | PIXI.Point
    skew?: number
    skewX?: number
    skewY?: number
    tint?: number | number[]
    blend?: number | number[]
    shake?: number
    [generic: string]: any
}

interface AddOptions {
    duration?: number
    ease?: string | Function
    repeat?: boolean | number
    reverse?: boolean
    wait?: number
    removeExisting?: boolean
}

export let ease: Ease

export declare class Ease extends EventEmitter {
    duration: number
    ease: string | Function

    constructor(options: EaseOptions)

    destroy(): void
    add(element: PIXI.DisplayObject | PIXI.DisplayObject[], params: EaseParams, options: AddOptions): Easing
    target(element: PIXI.DisplayObject, target: PIXI.DisplayObject | PIXI.DisplayObject[], speed: number, options: AddOptions): Easing;
    face(element: PIXI.DisplayObject, target: PIXI.DisplayObject | PIXI.DisplayObject[], speed: number, options: AddOptions): Easing;
    removeEase(element: PIXI.DisplayObject, param?: string | string[]): void
    removeAll(): void
    update(elapsed: number): void
    get count(): number;
    countElements(): number
    countRunning(): number
}

export declare class Easing extends EventEmitter {
    static shortestAngle(start: number, finish: number): number
    remove(element?: PIXI.DisplayObject, params?: string | string[]): void

    constructor(element: PIXI.DisplayObject | PIXI.DisplayObject[], params: EaseParams, options: EaseOptions)

    addParam(element: PIXI.DisplayObject, entry: string, param: any): void
    updateOne(ease: Ease, entry: string): void
    updatePoint(ease: Ease, entry: string): void
    updatePosition(ease: Ease): void
    updateCoord(ease: Ease, name: string, coord: any): void
    updateTint(ease: Ease, colors: number[]): void
    updateBlend(ease: Ease, colors: number[]): void
    updateShake(ease: Ease): void
    complete(ease: Ease): void
    reverse(ease: Ease): void
    repeat(ease: Ease): void
    update(elapsed: number): void
    count(): number
}

uahic avatar Nov 12 '20 18:11 uahic

@davidfig I'd like to ask you if you could have a look on the previously posted type-definitions if they are OK and merge them. Thank you :)

uahic avatar Nov 26 '20 16:11 uahic

Published as v3.0.6

davidfig avatar Nov 26 '20 23:11 davidfig