mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-05 23:37:04 +00:00
[next-nprogress] Add definitions (#35880)
* [next-nprogress] new definitions * [next-nprogress] remove package.json * [next-nprogress] lint * fix(next-nprogress): move generic to returned function * tests(next-nprogress): add test for props infer
This commit is contained in:
committed by
Andrew Casey
parent
937582ebc2
commit
5e79e209ec
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
import { NProgressOptions } from 'nprogress';
|
||||
import * as React from 'react';
|
||||
|
||||
export interface NProgressProps {
|
||||
options?: Partial<NProgressOptions>;
|
||||
color?: string;
|
||||
spinner?: boolean;
|
||||
showAfterMs?: number;
|
||||
}
|
||||
|
||||
export default class NProgress extends React.Component<NProgressProps> {}
|
||||
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
// Type definitions for next-nprogress 1.4
|
||||
// Project: https://github.com/sergiodxa/next-nprogress#readme
|
||||
// Definitions by: Ovyerus <https://github.com/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<NProgressOptions>
|
||||
): <P extends object>(Page: ComponentType<P>) => ComponentType<P>;
|
||||
@@ -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 (
|
||||
<div>
|
||||
<NProgress/>
|
||||
<NProgress
|
||||
color="#29D"
|
||||
options={{ trickleSpeed: 100 }}
|
||||
showAfterMs={250}
|
||||
spinner={false}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
withNProgress()(App);
|
||||
withNProgress(300)(App);
|
||||
withNProgress(300, { trickle: false })(App);
|
||||
|
||||
class AppWithProps extends React.Component<{title: string}> {
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<title>{this.props.title}</title>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// $ExpectType ComponentType<{ title: string; }>
|
||||
withNProgress()(AppWithProps);
|
||||
// $ExpectType ComponentType<{}>
|
||||
withNProgress()(App);
|
||||
@@ -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"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user