`linkify-element` 4.0.0-beta.3 missing type for `Options`
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;
One possible fix would be to use something like:
@param {import("linkifyjs").Options} opts
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) => {
Well, "works" might be an overstatement, now that I try to actually use it. I think this might make tsc hang.
Hi @jryans and @Pike, thank you both looking into this! I released v4.0.0-beta.4 some type improvements that should address this.
Thanks for the quick fix! I can confirm the types are now working well for me with 4.0.0-beta.4.