From f17d78f8888ca9028f09dca15d672c9fc76c1ebb Mon Sep 17 00:00:00 2001 From: Maxi Gimenez Date: Mon, 25 May 2020 00:44:05 +0200 Subject: [PATCH] chore(next): export/lib/next-server missing types (#13320) --- packages/next/export/index.ts | 2 +- packages/next/lib/recursive-copy.ts | 2 +- packages/next/lib/verifyTypeScriptSetup.ts | 2 +- packages/next/next-server/lib/amp.ts | 4 ++-- packages/next/next-server/lib/dynamic.tsx | 2 +- packages/next/next-server/lib/head.tsx | 2 +- packages/next/next-server/lib/runtime-config.ts | 2 +- packages/next/next-server/lib/side-effect.tsx | 2 +- packages/next/next-server/lib/utils.ts | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/next/export/index.ts b/packages/next/export/index.ts index ab3f18882b..2234000e58 100644 --- a/packages/next/export/index.ts +++ b/packages/next/export/index.ts @@ -90,7 +90,7 @@ export default async function ( options: any, configuration?: any ): Promise { - function log(message: string) { + function log(message: string): void { if (options.silent) { return } diff --git a/packages/next/lib/recursive-copy.ts b/packages/next/lib/recursive-copy.ts index 08e4b045f1..e451d38d26 100644 --- a/packages/next/lib/recursive-copy.ts +++ b/packages/next/lib/recursive-copy.ts @@ -23,7 +23,7 @@ export async function recursiveCopy( const sema = new Sema(concurrency) - async function _copy(item: string) { + async function _copy(item: string): Promise { const target = item.replace(from, to) const stats = await promises.stat(item) diff --git a/packages/next/lib/verifyTypeScriptSetup.ts b/packages/next/lib/verifyTypeScriptSetup.ts index b66c6518b2..76bfbf55ff 100644 --- a/packages/next/lib/verifyTypeScriptSetup.ts +++ b/packages/next/lib/verifyTypeScriptSetup.ts @@ -30,7 +30,7 @@ async function checkDependencies({ }: { dir: string isYarn: boolean -}) { +}): Promise { const requiredPackages = [ { file: 'typescript', pkg: 'typescript' }, { file: '@types/react/index.d.ts', pkg: '@types/react' }, diff --git a/packages/next/next-server/lib/amp.ts b/packages/next/next-server/lib/amp.ts index 052cc6339f..12dbb711fd 100644 --- a/packages/next/next-server/lib/amp.ts +++ b/packages/next/next-server/lib/amp.ts @@ -5,11 +5,11 @@ export function isInAmpMode({ ampFirst = false, hybrid = false, hasQuery = false, -} = {}) { +} = {}): boolean { return ampFirst || (hybrid && hasQuery) } -export function useAmp() { +export function useAmp(): boolean { // Don't assign the context value to a variable to save bytes return isInAmpMode(React.useContext(AmpStateContext)) } diff --git a/packages/next/next-server/lib/dynamic.tsx b/packages/next/next-server/lib/dynamic.tsx index ed8cac994f..3c1a9ebc15 100644 --- a/packages/next/next-server/lib/dynamic.tsx +++ b/packages/next/next-server/lib/dynamic.tsx @@ -52,7 +52,7 @@ export type LoadableComponent

= React.ComponentType

export function noSSR

( LoadableInitializer: LoadableFn

, loadableOptions: LoadableOptions

-) { +): React.ComponentType

{ // Removing webpack and modules means react-loadable won't try preloading delete loadableOptions.webpack delete loadableOptions.modules diff --git a/packages/next/next-server/lib/head.tsx b/packages/next/next-server/lib/head.tsx index d13189cfe9..6f2fdbd51b 100644 --- a/packages/next/next-server/lib/head.tsx +++ b/packages/next/next-server/lib/head.tsx @@ -8,7 +8,7 @@ type WithInAmpMode = { inAmpMode?: boolean } -export function defaultHead(inAmpMode = false) { +export function defaultHead(inAmpMode = false): JSX.Element[] { const head = [] if (!inAmpMode) { head.push() diff --git a/packages/next/next-server/lib/runtime-config.ts b/packages/next/next-server/lib/runtime-config.ts index 095330abb8..b4a48a362d 100644 --- a/packages/next/next-server/lib/runtime-config.ts +++ b/packages/next/next-server/lib/runtime-config.ts @@ -4,6 +4,6 @@ export default () => { return runtimeConfig } -export function setConfig(configValue: any) { +export function setConfig(configValue: any): void { runtimeConfig = configValue } diff --git a/packages/next/next-server/lib/side-effect.tsx b/packages/next/next-server/lib/side-effect.tsx index a68ebdd280..73e16a8fc1 100644 --- a/packages/next/next-server/lib/side-effect.tsx +++ b/packages/next/next-server/lib/side-effect.tsx @@ -17,7 +17,7 @@ export default () => { const mountedInstances: Set = new Set() let state: State - function emitChange(component: React.Component) { + function emitChange(component: React.Component): void { state = component.props.reduceComponentsToState( [...mountedInstances], component.props diff --git a/packages/next/next-server/lib/utils.ts b/packages/next/next-server/lib/utils.ts index c29adc6699..d8ab04aca5 100644 --- a/packages/next/next-server/lib/utils.ts +++ b/packages/next/next-server/lib/utils.ts @@ -347,7 +347,7 @@ export const urlObjectKeys = [ export function formatWithValidation( url: UrlObject, options?: URLFormatOptions -) { +): string { if (process.env.NODE_ENV === 'development') { if (url !== null && typeof url === 'object') { Object.keys(url).forEach((key) => { -- GitLab