mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-20 00:59:29 +08:00
Add typings for anchor-js (#23957)
This commit is contained in:
16
types/anchor-js/anchor-js-tests.ts
Normal file
16
types/anchor-js/anchor-js-tests.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
anchors.add();
|
||||
anchors.add('h1');
|
||||
anchors.add().add('h2');
|
||||
|
||||
anchors.remove();
|
||||
anchors.remove('h1');
|
||||
anchors.remove().remove('h2');
|
||||
|
||||
anchors.removeAll();
|
||||
|
||||
const headerAnchors = new AnchorJS();
|
||||
|
||||
const footerAnchors = new AnchorJS({
|
||||
placement: 'right',
|
||||
});
|
||||
footerAnchors.remove('.links');
|
||||
41
types/anchor-js/index.d.ts
vendored
Normal file
41
types/anchor-js/index.d.ts
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
// Type definitions for anchor-js 4.1
|
||||
// Project: https://github.com/bryanbraun/anchorjs
|
||||
// Definitions by: Brian Surowiec <https://github.com/xt0rted>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace anchorjs {
|
||||
interface Anchor {
|
||||
options: AnchorOptions;
|
||||
|
||||
add(selector?: string): Anchor;
|
||||
remove(selector?: string): Anchor;
|
||||
removeAll(): void;
|
||||
}
|
||||
|
||||
type AnchorPlacement = 'left' | 'right';
|
||||
type AnchorVisibility = 'always' | 'hover' | 'touch';
|
||||
|
||||
interface AnchorOptions {
|
||||
arialabel?: string;
|
||||
class?: string;
|
||||
icons?: string;
|
||||
placement?: AnchorPlacement;
|
||||
truncate?: number;
|
||||
visible?: AnchorVisibility;
|
||||
}
|
||||
|
||||
interface AnchorStatic {
|
||||
new(options?: AnchorOptions): Anchor;
|
||||
}
|
||||
}
|
||||
|
||||
declare const anchors: anchorjs.Anchor;
|
||||
declare const AnchorJS: anchorjs.AnchorStatic;
|
||||
|
||||
export = AnchorJS;
|
||||
|
||||
export as namespace AnchorJS;
|
||||
|
||||
declare global {
|
||||
const anchors: anchorjs.Anchor;
|
||||
}
|
||||
23
types/anchor-js/tsconfig.json
Normal file
23
types/anchor-js/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"anchor-js-tests.ts"
|
||||
]
|
||||
}
|
||||
3
types/anchor-js/tslint.json
Normal file
3
types/anchor-js/tslint.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Reference in New Issue
Block a user