diff --git a/types/react-scrollable-anchor/index.d.ts b/types/react-scrollable-anchor/index.d.ts new file mode 100644 index 0000000000..ea495dd0f7 --- /dev/null +++ b/types/react-scrollable-anchor/index.d.ts @@ -0,0 +1,24 @@ +// Type definitions for react-scrollable-anchor 0.6 +// Project: https://github.com/gabergg/react-scrollable-anchor +// Definitions by: Antoine DOUBOVETZKY +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import * as React from 'react'; + +export interface ScrollableAnchorProps { + id: string; + children?: React.ReactNode; +} + +export interface ConfigureAnchorsOptions { + offset?: number; + scrollDuration?: number; + keepLastAnchorHash?: boolean; +} + +export default class ScrollableAnchor extends React.Component { } +export function goToTop(): void; +export function configureAnchors(options: ConfigureAnchorsOptions): void; +export function goToAnchor(anchorId: string, saveHashUpdate?: boolean): void; +export function removeHash(): void; diff --git a/types/react-scrollable-anchor/react-scrollable-anchor-tests.tsx b/types/react-scrollable-anchor/react-scrollable-anchor-tests.tsx new file mode 100644 index 0000000000..984a01f741 --- /dev/null +++ b/types/react-scrollable-anchor/react-scrollable-anchor-tests.tsx @@ -0,0 +1,47 @@ +import * as React from 'react'; +import ScrollableAnchor, { goToAnchor, goToTop, removeHash, configureAnchors } from "react-scrollable-anchor"; + +/* + * goToAnchor + */ +// $ExpectType void +goToAnchor("one"); +// $ExpectError +goToAnchor(1); + +/* + * goToTop + */ +// $ExpectType void +goToTop(); +// $ExpectError +goToTop(1); + +/* + * removeHash + */ +// $ExpectType void +removeHash(); +// $ExpectError +removeHash(1); + +/* + * configureAnchors + */ +// $ExpectType void +configureAnchors({ offset: 500, scrollDuration: 1000, keepLastAnchorHash: true }); +// $ExpectError +configureAnchors(); +// $ExpectError +configureAnchors({ wrongKey: 1 }); +// $ExpectError +configureAnchors({ offset: 'string' }); +// $ExpectError +configureAnchors({ scrollDuration: 'string' }); +// $ExpectError +configureAnchors({ keepLastAnchorHash: 3 }); + +// $ExpectError +
Test
; + +
Test
; diff --git a/types/react-scrollable-anchor/tsconfig.json b/types/react-scrollable-anchor/tsconfig.json new file mode 100644 index 0000000000..198bad7412 --- /dev/null +++ b/types/react-scrollable-anchor/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "jsx": "react", + "noImplicitAny": true, + "strictFunctionTypes": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "react-scrollable-anchor-tests.tsx" + ] +} diff --git a/types/react-scrollable-anchor/tslint.json b/types/react-scrollable-anchor/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-scrollable-anchor/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }