mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-07 00:07:07 +00:00
Merge pull request #33953 from AntoineDoubovetzky/master
create react-scrollable-anchor package
This commit is contained in:
+24
@@ -0,0 +1,24 @@
|
||||
// Type definitions for react-scrollable-anchor 0.6
|
||||
// Project: https://github.com/gabergg/react-scrollable-anchor
|
||||
// Definitions by: Antoine DOUBOVETZKY <https://github.com/AntoineDoubovetzky>
|
||||
// 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<ScrollableAnchorProps> { }
|
||||
export function goToTop(): void;
|
||||
export function configureAnchors(options: ConfigureAnchorsOptions): void;
|
||||
export function goToAnchor(anchorId: string, saveHashUpdate?: boolean): void;
|
||||
export function removeHash(): void;
|
||||
@@ -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
|
||||
<ScrollableAnchor><div>Test</div></ScrollableAnchor>;
|
||||
|
||||
<ScrollableAnchor id="anchorId"><div>Test</div></ScrollableAnchor>;
|
||||
@@ -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"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user