evgeniy-polyakov / jsfl-support

The plugin for IntelliJ platform that provides support for JSFL API.
Apache License 2.0
9 stars 2 forks source link

Array.forEach type detection #4

Closed jmcscript closed 3 years ago

jmcscript commented 3 years ago

Hello Evgeniy, I hope you are well.

I tend to use a lot of Array.forEach() loops when I know it's a small list and need to inspect every index. So, there is no need to break for example. (In that case, I'd use for i or for in.)

Here's my problem: when I'm using forEach() on known types, the IntelliJ shows T as the type. This issue does not occur with Array.filter().

Is there a way to fix this? It's not a huge problem, but I love the type of validation IntelliJ does with your plugin.

Note: This doesn't occur on all instances of forEach. Running it for fl.documents works fine. Running it for fl.documents,getTimeline().layers does not.

image

image

evgeniy-polyakov commented 3 years ago

It shows the type for me in all cases: image

In your example could you check the type of document variable. It looks like it cannot be inferred properly. Note that there is no global document variable of type Document in JSFL like it is in browsers.

jmcscript commented 3 years ago

I'm so sorry to have bothered you. It's because I was using an imported library and didn't have JSDoc comments to describe the document variable in my custom method. This update seems to resolve it. Although I'm using traditional loops here, the app knows what document is now.

/**

On Tue, Feb 9, 2021 at 11:10 PM Evgeniy Polyakov notifications@github.com wrote:

It shows the type for me in all cases: [image: image] https://user-images.githubusercontent.com/7184003/107467249-41519a00-6b98-11eb-9dd1-3345d2ee9566.png

In your example could you check the type of document variable. It looks like it cannot be inferred properly. Note that there is no global document variable of type Document in JSFL like it is in browsers.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/evgeniy-polyakov/jsfl-support/issues/4#issuecomment-776446313, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJFHQCIDWFFQSFFYMUKVVD3S6IINDANCNFSM4XLBUESA .

-- Thanks,

James McDonald Email: jameschristophermcdonald@gmail.com Mobile Phone: (580) 351-8170

evgeniy-polyakov commented 3 years ago

Ok, I'm closing this