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

import by CommonJS dosen't working in typescript environment #90

Closed
vreality64 opened this issue Jan 11, 2018 · 2 comments
Closed

import by CommonJS dosen't working in typescript environment #90

vreality64 opened this issue Jan 11, 2018 · 2 comments
Labels

Comments

@vreality64
Copy link

Description

following code throw runtime error Uncaught TypeError: axes_1.default is not a constructor

import Axes from "@egjs/Axes"

const axes = new Axes(...)

transpiled version references default property, but Axes constructor is axes_1 itself. that means default property is not constructor.

// transpiled version
var axes_1 = __webpack_require__(4);

var axes = new axes_1["default"](...)

Steps to check or reproduce

I changed Axes.d.ts by my self. but not sure it's right.
I can use import * as Axes from "@egjs/axes" with changed definition file;

export = Axes;

export as namespace Axes;

declare class Axes extends Component {
    axis: {
        [key: string]: AxisOption;
    };
    static VERSION: string;
    static PanInput: any;
    static PinchInput: any;
    static WheelInput: any;
    static MoveKeyInput: any;
    static TRANSFORM: string;
    static DIRECTION_NONE: DIRECTION;
    static DIRECTION_LEFT: DIRECTION;
    static DIRECTION_RIGHT: DIRECTION;
    static DIRECTION_UP: DIRECTION;
    static DIRECTION_DOWN: DIRECTION;
    static DIRECTION_HORIZONTAL: DIRECTION;
    static DIRECTION_VERTICAL: DIRECTION;
    static DIRECTION_ALL: DIRECTION;
    options: AxesOption;
    em: EventManager;
    axm: AxisManager;
    itm: InterruptManager;
    am: AnimationManager;
    io: InputObserver;
    private _inputs;
    constructor(axis: {
        [key: string]: AxisOption;
    }, options: AxesOption, startPos?: Axis);
    connect(axes: string[] | string, inputType: IInputType): this;
    disconnect(inputType?: IInputType): this;
    get(axes?: string[]): Axis;
    setTo(pos: Axis, duration?: number): this;
    setBy(pos: Axis, duration?: number): this;
    isBounceArea(axes?: string[]): boolean;
    destroy(): void;
}

declare interface AxesOption {
	easing?: (x: number) => number;
	maximumDuration?: number;
	minimumDuration?: number;
	deceleration?: number;
	interruptable?: boolean;
}

declare namespace Axes {
	export interface AxesOption {
		easing?: (x: number) => number;
		maximumDuration?: number;
		minimumDuration?: number;
		deceleration?: number;
		interruptable?: boolean;
	}
}
@sculove
Copy link
Contributor

sculove commented Jan 11, 2018

ok. I will check it! thanks

@sculove
Copy link
Contributor

sculove commented Jan 12, 2018

sculove added a commit to sculove/egjs-axes that referenced this issue Jan 12, 2018
@sculove sculove mentioned this issue Jan 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants