From 181f4d59223d0aee1b272908576211433af69a82 Mon Sep 17 00:00:00 2001 From: Sam Baeck <> Date: Mon, 13 Aug 2018 22:23:10 +0200 Subject: [PATCH 1/3] Added typings for react-router-hash-link --- types/react-router-hash-link/index.d.ts | 18 +++++++++++++++ .../react-router-hash-link-tests.ts | 23 +++++++++++++++++++ types/react-router-hash-link/tsconfig.json | 23 +++++++++++++++++++ types/react-router-hash-link/tslint.json | 1 + 4 files changed, 65 insertions(+) create mode 100644 types/react-router-hash-link/index.d.ts create mode 100644 types/react-router-hash-link/react-router-hash-link-tests.ts create mode 100644 types/react-router-hash-link/tsconfig.json create mode 100644 types/react-router-hash-link/tslint.json diff --git a/types/react-router-hash-link/index.d.ts b/types/react-router-hash-link/index.d.ts new file mode 100644 index 0000000000..545a31cc71 --- /dev/null +++ b/types/react-router-hash-link/index.d.ts @@ -0,0 +1,18 @@ +// Type definitions for react-router-hash-link 1.2 +// Project: https://github.com/rafrex/react-router-hash-link (Does not have to be to GitHub, but prefer linking to a source code repository rather than to a project website.) +// Definitions by: Sam Baeck +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import * as React from 'react'; +import { LinkProps, NavLinkProps } from 'react-router-dom'; + +export interface HashLinkProps extends LinkProps { + smooth?: boolean; + scroll?: (element: HTMLElement) => void; +} + +export class HashLink extends React.Component {} + +export interface NavHashLinkProps extends NavLinkProps, HashLinkProps {} + +export class NavHashLink extends React.Component {} diff --git a/types/react-router-hash-link/react-router-hash-link-tests.ts b/types/react-router-hash-link/react-router-hash-link-tests.ts new file mode 100644 index 0000000000..7825bbf6c4 --- /dev/null +++ b/types/react-router-hash-link/react-router-hash-link-tests.ts @@ -0,0 +1,23 @@ +import * as H from 'history'; +import * as React from 'react'; +import { match } from 'react-router'; +import { HashLink, NavHashLink, NavHashLinkProps } from 'react-router-hash-link'; + +interface Props extends NavHashLinkProps { + extraProp: string; +} + +const getIsActive = (extraProp: string) => (match: match, location: H.Location) => !!extraProp; + +export default function (props: Props) { + const {extraProp, ...rest} = props; + const isActive = getIsActive(extraProp); + return ( + +); +} + + + +const acceptRef = (node: HTMLAnchorElement | null) => {}; +; \ No newline at end of file diff --git a/types/react-router-hash-link/tsconfig.json b/types/react-router-hash-link/tsconfig.json new file mode 100644 index 0000000000..71c139a0f0 --- /dev/null +++ b/types/react-router-hash-link/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "jsx": "react", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "react-router-hash-link-tests.ts" + ] +} diff --git a/types/react-router-hash-link/tslint.json b/types/react-router-hash-link/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-router-hash-link/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From e04532a2b1e77c4b9e9276b54313e397e96caae9 Mon Sep 17 00:00:00 2001 From: Sam Baeck <> Date: Mon, 13 Aug 2018 22:30:23 +0200 Subject: [PATCH 2/3] added strictFunctionTypes": true to tsconfig --- types/react-router-hash-link/tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/types/react-router-hash-link/tsconfig.json b/types/react-router-hash-link/tsconfig.json index 71c139a0f0..892d3999e3 100644 --- a/types/react-router-hash-link/tsconfig.json +++ b/types/react-router-hash-link/tsconfig.json @@ -8,6 +8,7 @@ "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, + "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ "../" From d29b89c1a85b0d7379affaab5abdd45aa68effb1 Mon Sep 17 00:00:00 2001 From: Sam Baeck <> Date: Mon, 13 Aug 2018 22:49:28 +0200 Subject: [PATCH 3/3] updated tsconfig, fixed broken tests --- types/react-router-hash-link/index.d.ts | 1 + ...link-tests.ts => react-router-hash-link-tests.tsx} | 11 ++++++----- types/react-router-hash-link/tsconfig.json | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) rename types/react-router-hash-link/{react-router-hash-link-tests.ts => react-router-hash-link-tests.tsx} (72%) diff --git a/types/react-router-hash-link/index.d.ts b/types/react-router-hash-link/index.d.ts index 545a31cc71..9480f1aef0 100644 --- a/types/react-router-hash-link/index.d.ts +++ b/types/react-router-hash-link/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/rafrex/react-router-hash-link (Does not have to be to GitHub, but prefer linking to a source code repository rather than to a project website.) // Definitions by: Sam Baeck // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 import * as React from 'react'; import { LinkProps, NavLinkProps } from 'react-router-dom'; diff --git a/types/react-router-hash-link/react-router-hash-link-tests.ts b/types/react-router-hash-link/react-router-hash-link-tests.tsx similarity index 72% rename from types/react-router-hash-link/react-router-hash-link-tests.ts rename to types/react-router-hash-link/react-router-hash-link-tests.tsx index 7825bbf6c4..4c64a1b5c3 100644 --- a/types/react-router-hash-link/react-router-hash-link-tests.ts +++ b/types/react-router-hash-link/react-router-hash-link-tests.tsx @@ -9,15 +9,16 @@ interface Props extends NavHashLinkProps { const getIsActive = (extraProp: string) => (match: match, location: H.Location) => !!extraProp; -export default function (props: Props) { +export default function(props: Props) { const {extraProp, ...rest} = props; const isActive = getIsActive(extraProp); return ( -); + ); } - +; -const acceptRef = (node: HTMLAnchorElement | null) => {}; -; \ No newline at end of file +const acceptRef = (node: HTMLAnchorElement | null) => { +}; +; diff --git a/types/react-router-hash-link/tsconfig.json b/types/react-router-hash-link/tsconfig.json index 892d3999e3..fc830ac41d 100644 --- a/types/react-router-hash-link/tsconfig.json +++ b/types/react-router-hash-link/tsconfig.json @@ -19,6 +19,6 @@ }, "files": [ "index.d.ts", - "react-router-hash-link-tests.ts" + "react-router-hash-link-tests.tsx" ] }