-
-
Notifications
You must be signed in to change notification settings - Fork 337
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
fix(types): better declaration files #2914
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
That must have been a PITA to investigate and fix.
Thanks for your effort! 👍🏼
Thanks for the PR. There are still a few issues, at least in my application:
method: Uppercase<'get' | 'post' | 'put' | 'delete' | 'head' | 'options' | 'patch'> | Lowercase<'get' | 'post' | 'put' | 'delete' | 'head' | 'options' | 'patch'>; or method: string | undefined; //same as AjaxSettings.method Otherwise, everything is looking better than the old version... |
Also ... so that we can use: |
For this error I would suggest doing this: rules: Form.RulesSettings & {[key: string]: (value?: any, identifier?: string, module?: any) => boolean}; So we can add custom rule but keep the original prompt: Form.PromptSettings & {[key: string]: string | undefined}; To line number 282 |
Additional commit for fomantic#2914 from @prudho
This is clever ! I tried a lot of stuff to make it work but your solution works great and doesn't break Intellisense 👍 I've pushed another bunch of fixes based on your feedback, many thanks @KiddoV ! @lubber-de yeah, let's wait a few more fixes before merging it. |
@prudho, thanks for the update from the second commit! I - API stateContext: false | string | JQuery<any>; Since I can pass in II - TRANSITION (behavior: 'shake', duration?: string | number): JQuery; III - FORM onSuccess(this: JQuery, event: Event, fields: {[key: string]: any}): void; Since I can use IV - SEARCH Also onSelect(this: JQuery, result: any, response: object): void | Promise<void> | boolean | Promise<boolean>; V - POPUP onShow(this: JQuery): boolean | void; |
Definitely many thanks @KiddoV. All the difficulty here is to set "probable" types to a framework that can accept virtually anything 😄 Your help is very appreciated ! I've implemented your suggested changes, and added a few more by reviewing code and internal uses. |
@prudho Thank you! Your latest commit make my VSCode happy... for now, so I am cool! 😁 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 👍🏼
Description
This is the first round of fixes/improvements for type declarations of Fomantic. Some properties and methods were missing, some were too restrictive.
I've enabled strict type checking on my work project (~500k lines of code and use almost every module of Fomantic). Before the fix I had around 2500 errors during transpilation, 0 after.
I just cannot fix one error, that I circumvent by adding the
//@ts-expect-error
on the line before:For a
Form
, creating a new rule will raise an error in VSCode (that can be safely bypassed).$.fn.form.settings.rules
is typed and Intellisense is working, but adding a new rule to it will trigger an error. Anyway, this is not a blocking issue for merging, since this PR will make a lot more good than bad :)Closes
#2906