diff --git a/types/next-nprogress/component.d.ts b/types/next-nprogress/component.d.ts new file mode 100644 index 0000000000..8c0feabad2 --- /dev/null +++ b/types/next-nprogress/component.d.ts @@ -0,0 +1,11 @@ +import { NProgressOptions } from 'nprogress'; +import * as React from 'react'; + +export interface NProgressProps { + options?: Partial; + color?: string; + spinner?: boolean; + showAfterMs?: number; +} + +export default class NProgress extends React.Component {} diff --git a/types/next-nprogress/index.d.ts b/types/next-nprogress/index.d.ts new file mode 100644 index 0000000000..f4fb77503c --- /dev/null +++ b/types/next-nprogress/index.d.ts @@ -0,0 +1,13 @@ +// Type definitions for next-nprogress 1.4 +// Project: https://github.com/sergiodxa/next-nprogress#readme +// Definitions by: Ovyerus +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import { NProgressOptions } from 'nprogress'; +import { Component, ComponentType } from 'react'; + +export default function withNProgress( + delayMs?: number, + options?: Partial +):

(Page: ComponentType

) => ComponentType

; diff --git a/types/next-nprogress/next-nprogress-tests.tsx b/types/next-nprogress/next-nprogress-tests.tsx new file mode 100644 index 0000000000..1ebdedede3 --- /dev/null +++ b/types/next-nprogress/next-nprogress-tests.tsx @@ -0,0 +1,38 @@ +import * as React from 'react'; +import withNProgress from 'next-nprogress'; +import NProgress from 'next-nprogress/component'; + +class App extends React.Component { + render() { + return ( +

+ + +
+ ); + } +} + +withNProgress()(App); +withNProgress(300)(App); +withNProgress(300, { trickle: false })(App); + +class AppWithProps extends React.Component<{title: string}> { + render() { + return ( +
+ {this.props.title} +
+ ); + } +} + +// $ExpectType ComponentType<{ title: string; }> +withNProgress()(AppWithProps); +// $ExpectType ComponentType<{}> +withNProgress()(App); diff --git a/types/next-nprogress/tsconfig.json b/types/next-nprogress/tsconfig.json new file mode 100644 index 0000000000..2d04e88867 --- /dev/null +++ b/types/next-nprogress/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "jsx": "react" + }, + "files": [ + "index.d.ts", + "component.d.ts", + "next-nprogress-tests.tsx" + ] +} diff --git a/types/next-nprogress/tslint.json b/types/next-nprogress/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/next-nprogress/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }