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

linkify-element 4.0.0-beta.3 missing type for Options #376

Closed
jryans opened this issue Jan 31, 2022 · 5 comments · Fixed by #354
Closed

linkify-element 4.0.0-beta.3 missing type for Options #376

jryans opened this issue Jan 31, 2022 · 5 comments · Fixed by #354
Assignees
Milestone

Comments

@jryans
Copy link

jryans commented Jan 31, 2022

When using linkify-element 4.0.0-beta.3, it seems the bundled type definitions in the package don't provide a type for the Options arg of linkifyElementHelper:

node_modules/linkify-element/index.d.ts:24:67 - error TS2304: Cannot find name 'Options'.

24 declare function linkifyElementHelper(element: HTMLElement, opts: Options, doc: Document): HTMLElement;
@jryans
Copy link
Author

jryans commented Jan 31, 2022

One possible fix would be to use something like:

@param {import("linkifyjs").Options} opts

@nfrasser nfrasser self-assigned this Jan 31, 2022
@nfrasser nfrasser added this to the 4.0 milestone Jan 31, 2022
@nfrasser nfrasser added the types label Jan 31, 2022
@Pike
Copy link

Pike commented Feb 1, 2022

I tried this locally, and this works for me:

diff --git a/packages/linkify-react/src/linkify-react.js b/packages/linkify-react/src/linkify-react.js
index 86af2ca..dba32cd 100644
--- a/packages/linkify-react/src/linkify-react.js
+++ b/packages/linkify-react/src/linkify-react.js
@@ -77,10 +77,14 @@ function linkifyReactElement(element, opts, elementId = 0) {
        return React.cloneElement(element, newProps, children);
 }

+/**
+ * @typedef { import("linkifyjs").Options } Options
+ */
+
 /**
  * @template P
  * @template {string | React.JSXElementConstructor<P>} T
- * @param {P & { as?: T, tagName?: T, tagName?: T, options?: any, children?: React.ReactNode}} props
+ * @param {P & { as?: T, tagName?: T, tagName?: T, options?: Options, children?: React.ReactNode}} props
  * @returns {React.ReactElement<P, T>}
  */
 const Linkify = (props) => {

@Pike
Copy link

Pike commented Feb 1, 2022

Well, "works" might be an overstatement, now that I try to actually use it. I think this might make tsc hang.

@nfrasser
Copy link
Owner

nfrasser commented Feb 4, 2022

Hi @jryans and @Pike, thank you both looking into this! I released v4.0.0-beta.4 some type improvements that should address this.

@nfrasser nfrasser mentioned this issue Feb 4, 2022
@jryans
Copy link
Author

jryans commented Feb 4, 2022

Thanks for the quick fix! I can confirm the types are now working well for me with 4.0.0-beta.4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants