fix "expect" in tslint

This commit is contained in:
Drew Hays
2017-07-05 12:30:20 -07:00
parent f7bf798553
commit e97722eb0e
3 changed files with 32 additions and 37 deletions

16
types/next/index.d.ts vendored
View File

@@ -2,6 +2,7 @@
// Project: https://github.com/zeit/next.js
// Definitions by: Drew Hays <https://github.com/dru89>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
/// <reference types="node" />
@@ -106,11 +107,13 @@ declare module 'next/link' {
}
declare module 'next/dynamic' {
type ComponentType<T> = React.StatelessComponent<T> | typeof React.Component;
interface DynamicOptions<TCProps, TLProps> {
loading?: React.ComponentType<TLProps>;
loading?: ComponentType<TLProps>;
ssr?: boolean;
modules?(props: TCProps & TLProps): { [key: string]: Promise<React.ComponentType<any>> };
render?(props: TCProps & TLProps, modules: { [key: string]: React.ComponentType<any> }): void;
modules?(props: TCProps & TLProps): { [key: string]: Promise<ComponentType<any>> };
render?(props: TCProps & TLProps, modules: { [key: string]: ComponentType<any> }): void;
}
class SameLoopPromise<T> extends Promise<T> {
@@ -119,11 +122,12 @@ declare module 'next/dynamic' {
setError(value: any): void;
runIfNeeded(): void;
}
export default function<TCProps, TLProps>(componentPromise: Promise<React.ComponentType<TCProps>>, options?: DynamicOptions<TCProps, TLProps>): React.ComponentType<TCProps & TLProps>;
export default function<TCProps, TLProps>(componentPromise: Promise<ComponentType<TCProps>>, options?: DynamicOptions<TCProps, TLProps>): ComponentType<TCProps & TLProps>;
}
declare module 'next/router' {
import * as url from 'url';
type ComponentType<T> = React.StatelessComponent<T> | typeof React.Component;
interface EventChangeOptions {
shallow?: boolean;
@@ -136,7 +140,7 @@ declare module 'next/router' {
ready(cb: RouterCallback): void;
// router properties
readonly components: { [key: string]: { Component: React.ComponentType<any>, err: any } };
readonly components: { [key: string]: { Component: ComponentType<any>, err: any } };
readonly pathname: string;
readonly route: string;
readonly asPath: string;
@@ -147,7 +151,7 @@ declare module 'next/router' {
back(): void;
push(url: string, as?: string, options?: EventChangeOptions): Promise<boolean>;
replace(url: string, as?: string, options?: EventChangeOptions): Promise<boolean>;
prefetch(url: string): Promise<React.ComponentType<any>>;
prefetch(url: string): Promise<ComponentType<any>>;
// router events
onAppUpdated?(nextRoute: string): void;

View File

@@ -24,31 +24,31 @@ server.defineRoutes().then(voidFunc);
server.start().then(voidFunc);
const parsedUrl = url.parse('https://www.example.com');
const req: http.IncomingMessage = null;
const res: http.ServerResponse = null;
const handler = server.getRequestHandler();
handler(req, res);
handler(req, res, parsedUrl).then(voidFunc);
server.run(req, res, parsedUrl).then(voidFunc);
function handle(req: http.IncomingMessage, res: http.ServerResponse) {
handler(req, res);
handler(req, res, parsedUrl).then(voidFunc);
server.run(req, res, parsedUrl).then(voidFunc);
server.render(req, res, '/path/to/resource', null, parsedUrl).then(voidFunc);
server.render(req, res, '/path/to/resource', { key: 'value' }, parsedUrl).then(voidFunc);
server.renderError(new Error(), req, res, '/path/to/resource', { key: 'value' }).then(voidFunc);
server.renderError('this can be an error, too!', req, res, '/path/to/resource', { key: 'value' }).then(voidFunc);
server.render404(req, res, parsedUrl).then(voidFunc);
server.render(req, res, '/path/to/resource', {}, parsedUrl).then(voidFunc);
server.render(req, res, '/path/to/resource', { key: 'value' }, parsedUrl).then(voidFunc);
server.renderError(new Error(), req, res, '/path/to/resource', { key: 'value' }).then(voidFunc);
server.renderError('this can be an error, too!', req, res, '/path/to/resource', { key: 'value' }).then(voidFunc);
server.render404(req, res, parsedUrl).then(voidFunc);
server.renderToHTML(req, res, '/path/to/resource', { foo: 'bar' }).then(x => x.split('\n'));
server.renderErrorToHTML(new Error(), req, res, '/path/to/resource', { foo: 'bar' }).then(x => x.split('\n'));
server.renderToHTML(req, res, '/path/to/resource', { foo: 'bar' }).then(x => x.split('\n'));
server.renderErrorToHTML(new Error(), req, res, '/path/to/resource', { foo: 'bar' }).then(x => x.split('\n'));
server.serveStatic(req, res, '/path/to/thing').then(voidFunc);
server.serveStatic(req, res, '/path/to/thing').then(voidFunc);
let b: boolean;
b = server.isServeableUrl('/path/to/thing');
b = server.isInternalUrl(req);
b = server.handleBuildId('{buildId}', res);
let b: boolean;
b = server.isServeableUrl('/path/to/thing');
b = server.isInternalUrl(req);
b = server.handleBuildId('{buildId}', res);
const s: string = server.readBuildId();
server.getCompilationError('page', req, res).then(err => err.thisIsAnAny);
server.handleBuildHash('filename', 'hash', res);
server.send404(res);
const s: string = server.readBuildId();
server.getCompilationError('page', req, res).then(err => err.thisIsAnAny);
server.handleBuildHash('filename', 'hash', res);
server.send404(res);
}

View File

@@ -4,15 +4,6 @@
// All of the different "export default" lines in the index.d.ts
// appear to be triggering this. Remove this when I know of a way
// to declare a default export across multiple package/subpackages.
"strict-export-declare-modifiers": false,
// This is a pretty generic one to have to ignore, but it's because
// of the following error:
// `JSX element type '<type>' does not have any construct or call signatures.`
// In all cases, the element's type is "React.ComponentType`, which is composed of either:
// - React.StatelessComponent, which has a call signature, or
// - React.ComponentClass, which as a construct signature.
// This seems like it might be a bug.
"expect": false
"strict-export-declare-modifiers": false
}
}