aurelia-ui-toolkits / aurelia-materialize-bridge

Materialize CSS components for Aurelia
http://aurelia-ui-toolkits.github.io/demo-materialize/
MIT License
155 stars 53 forks source link

TS type errors #496

Closed HIRANO-Satoshi closed 6 years ago

HIRANO-Satoshi commented 6 years ago

Hi, I think, since it has been converted to TS, we have the following errors.

[at-loader] Checking finished with 2 errors
[at-loader] ./node_modules/aurelia-materialize-bridge/dist/commonjs/collapsible/collapsible.d.ts:14:104 
    TS2315: Type 'JQuery' is not generic. 

[at-loader] ./node_modules/aurelia-materialize-bridge/dist/commonjs/datepicker/datepicker.d.ts:20:14 
    TS2304: Cannot find name 'DatePickerOptions'. 
MaximBalaganskiy commented 6 years ago

Could be that jQuery and pickadate typings are not in dependencies, I'll check after Easter. Although, all our internal projects compile fine...

On Thu., 29 Mar. 2018, 8:48 pm HIRANO Satoshi, notifications@github.com wrote:

Hi, I think, since it has been converted to TS, we have the following errors.

[at-loader] Checking finished with 2 errors [at-loader] ./node_modules/aurelia-materialize-bridge/dist/commonjs/collapsible/collapsible.d.ts:14:104 TS2315: Type 'JQuery' is not generic.

[at-loader] ./node_modules/aurelia-materialize-bridge/dist/commonjs/datepicker/datepicker.d.ts:20:14 TS2304: Cannot find name 'DatePickerOptions'.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/aurelia-ui-toolkits/aurelia-materialize-bridge/issues/496, or mute the thread https://github.com/notifications/unsubscribe-auth/ADimvAe0tWbf5MsJ0sNQ0htbzM6TnN--ks5tjK36gaJpZM4TADUZ .

MaximBalaganskiy commented 6 years ago

Fixed via https://github.com/aurelia-ui-toolkits/aurelia-materialize-bridge/commit/5f698cef5077b58dd4274f94dc5bab3668b9a76d

HIRANO-Satoshi commented 6 years ago

I tested the new release 0.33.2. Thanks for it.

The DatePickerOptions issue has been gone. But we are still having the jQuery issue.

[at-loader] Checking finished with 1 errors
[at-loader] ./node_modules/aurelia-materialize-bridge/dist/commonjs/collapsible/collapsible.d.ts:14:104 
    TS2315: Type 'JQuery' is not generic. 

The following code in collapsible.ts

    buildCollapsibleOpenCloseCallbackHandler(handler: (element: Element) => {}) {
        return typeof (handler) === "function" ?
            (targetElementJquery: JQuery) => {
                const targetElement = targetElementJquery[0];

                handler(targetElement);
            } : null;
    }

generates the following code in collapsible.d.ts.

    buildCollapsibleOpenCloseCallbackHandler(handler: (element: Element) => {}): (targetElementJquery: JQuery<HTMLElement>) => void;

I have no idea why JQuery is treated as generic and "JQuery" is not "jQuery".

MaximBalaganskiy commented 6 years ago

Could you please check if you have node_modules/@types/jquery folder? I get the same error when I remove mine. That's why I added this dependency.

HIRANO-Satoshi commented 6 years ago

Yes. I have it for sure. I did "rm -rf node_modules; yarn install; yarn upgrade".

HIRANO-Satoshi commented 6 years ago

There is src/materialize.d.ts and JQuery is defined as an interface. It's not generic.

MaximBalaganskiy commented 6 years ago

That's fine. There should be node_modules/@types/jquery. Not sure if yarn downloads that... Please check if it's there.

HIRANO-Satoshi commented 6 years ago

I have node_modules/@types/jquery and its contents.

If you intended to use jQuery rather than JQuery and to use @types/jquery, we need

/// <reference path="../../node_modules/@types/jquery/index.d.ts" /> 

or something like that at somewhere in collapsible.ts, right?

MaximBalaganskiy commented 6 years ago

You need a specific 'node_modules/@types/jQuery' package. Please confirm you have it installed. Also worth checking the demo app source - it's built with webpack and typescript.

On Tue., 3 Apr. 2018, 4:59 pm HIRANO Satoshi, notifications@github.com wrote:

I have node_modules/ and its contents.

If you intended to use jQuery rather than JQuery and to use , we need

///

or something like that at somewhere in collapsible.ts, right?

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/aurelia-ui-toolkits/aurelia-materialize-bridge/issues/496#issuecomment-378148290, or mute the thread https://github.com/notifications/unsubscribe-auth/ADimvP8x4QzvTgMbCvhYj5pe5Ktl0yj4ks5tkx3PgaJpZM4TADUZ .

HIRANO-Satoshi commented 6 years ago

You are right. I had ^2.0 of @types/jquery in my package.json.

Now I updated it to ^3.3.0 and the type error has been disappeared.

Thanks so much!