mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
[linkifyjs] Add types for some more interfaces (#35573)
* Add type definitions for "linkifyjs/string" * Add type definitions for "linkifyjs/element" * Update linkifyjs/tsconfig * Update types/linkifyjs/tsconfig.json Co-Authored-By: Sean Zhu <interestinglythere@gmail.com> * Remove trailing comman * Explicitly specify LinkifyOptions in test * Link doc in test
This commit is contained in:
parent
23dff03111
commit
4d63b62600
4
types/linkifyjs/element.d.ts
vendored
Normal file
4
types/linkifyjs/element.d.ts
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
import { LinkifyOptions } from "./index";
|
||||
|
||||
export function linkifyElement(element: HTMLElement, options?: LinkifyOptions, doc?: HTMLDocument): HTMLElement;
|
||||
export default linkifyElement;
|
||||
@ -1,6 +1,9 @@
|
||||
import * as React from "react";
|
||||
import linkifyHtml from "linkifyjs/html";
|
||||
import Linkify from "linkifyjs/react";
|
||||
import linkifyStr from "linkifyjs/string";
|
||||
import linkifyElement from "linkifyjs/element";
|
||||
import { LinkifyOptions } from "linkifyjs";
|
||||
|
||||
declare function describe(desc: string, f: () => void): void;
|
||||
|
||||
@ -103,7 +106,7 @@ describe("linkifyjs/html", () => {
|
||||
linkifyHtml(
|
||||
// tslint:disable-next-line:prefer-template
|
||||
'Please ignore <script>var a = {}; a.com = "Hi";</script> \n' +
|
||||
"but do <span>b.ca</span>",
|
||||
"but do <span>b.ca</span>",
|
||||
{
|
||||
ignoreTags: ["script", "style"]
|
||||
}
|
||||
@ -225,3 +228,25 @@ describe("linkifyjs/react", () => {
|
||||
</Linkify>;
|
||||
}
|
||||
});
|
||||
|
||||
describe("linkifyjs/string", () => {
|
||||
/**
|
||||
* The following tests were based on the documentation:
|
||||
* https://soapbox.github.io/linkifyjs/docs/linkify-string.html
|
||||
*/
|
||||
const options: LinkifyOptions = {};
|
||||
const str = '<p>For help with GitHub.com, please email support@github.com</p>';
|
||||
const result1: string = linkifyStr(str, options);
|
||||
const result2: string = linkifyStr(str);
|
||||
});
|
||||
|
||||
describe("linkifyjs/element", () => {
|
||||
/**
|
||||
* The following tests were based on the documentation:
|
||||
* https://soapbox.github.io/linkifyjs/docs/linkify-element.html
|
||||
*/
|
||||
const options: LinkifyOptions = {};
|
||||
const result1: HTMLElement = linkifyElement(document.body, options, document);
|
||||
const result2: HTMLElement = linkifyElement(document.body, options);
|
||||
const result3: HTMLElement = linkifyElement(document.body);
|
||||
});
|
||||
|
||||
4
types/linkifyjs/string.d.ts
vendored
Normal file
4
types/linkifyjs/string.d.ts
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
import { LinkifyOptions } from "./index";
|
||||
|
||||
export function linkifyStr(str: string, options?: LinkifyOptions): string;
|
||||
export default linkifyStr;
|
||||
@ -13,5 +13,12 @@
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"jsx": "preserve"
|
||||
},
|
||||
"files": ["index.d.ts", "html.d.ts", "react.d.ts", "linkifyjs-tests.tsx"]
|
||||
"files": [
|
||||
"element.d.ts",
|
||||
"html.d.ts",
|
||||
"index.d.ts",
|
||||
"linkifyjs-tests.tsx",
|
||||
"react.d.ts",
|
||||
"string.d.ts"
|
||||
]
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user