8000 refactor(nitro,nuxt,schema,vite): provide explicit return types · nuxt/nuxt@2564002 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2564002

Browse files
committed
refactor(nitro,nuxt,schema,vite): provide explicit return types
1 parent ec2239c commit 2564002

File tree

22 files changed

+46
-36
lines changed

22 files changed

+46
-36
lines changed

eslint.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export default createConfigForNuxt({
2424
// Ignores have to be a separate object to be treated as global ignores
2525
// Don't add other attributes to this object
2626
ignores: [
27+
'.goff/**',
2728
'packages/schema/schema/**',
2829
'packages/nuxt/src/app/components/welcome.vue',
2930
'packages/nuxt/src/app/components/error-*.vue',

packages/kit/src/ignore.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import ignore from 'ignore'
33
import { join, relative, resolve } from 'pathe'
44
import { tryUseNuxt } from './context'
55
import { getLayerDirectories } from './layers'
6-
import type { Nuxt } from 'nuxt/schema'
6+
import type { Nuxt } from '@nuxt/schema'
77

88
export function createIsIgnored (nuxt: Nuxt | null | undefined = tryUseNuxt()): (pathname: string, stats?: unknown) => boolean {
99
return (pathname, stats) => isIgnored(pathname, stats, nuxt)

packages/nitro-server/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const logLevelMapReverse = {
3535

3636
const NODE_MODULES_RE = /(?<=\/)node_modules\/(.+)$/
3737
const PNPM_NODE_MODULES_RE = /\.pnpm\/.+\/node_modules\/(.+)$/
38-
export async function bundle (nuxt: Nuxt & { _nitro?: Nitro }) {
38+
export async function bundle (nuxt: Nuxt & { _nitro?: Nitro }): Promise<void> {
3939
// Resolve config
4040
const layerDirs = getLayerDirectories(nuxt)
4141
const excludePaths: string[] = []

packages/nuxt/src/app/compat/capi.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
export * from 'vue'
22

3-
export const install = () => {}
3+
export const install = (): void => {}
44

5-
export function set (target: any, key: string | number | symbol, val: any) {
5+
export function set<T> (target: any, key: string | number | symbol, val: T): T {
66
if (Array.isArray(target)) {
77
target.length = Math.max(target.length, key as number)
88
target.splice(key as number, 1, val)
@@ -12,7 +12,7 @@ export function set (target: any, key: string | number | symbol, val: any) {
1212
return val
1313
}
1414

15-
export function del (target: any, key: string | number | symbol) {
15+
export function del (target: any, key: string | number | symbol): void {
1616
if (Array.isArray(target)) {
1717
target.splice(key as number, 1)
1818
return

packages/nuxt/src/app/compat/interval.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { createError } from '../composables/error'
22

33
const intervalError = '[nuxt] `setInterval` should not be used on the server. Consider wrapping it with an `onNuxtReady`, `onBeforeMount` or `onMounted` lifecycle hook, or ensure you only call it in the browser by checking `import.meta.client`.'
44

5-
export const setInterval = import.meta.client
5+
export const setInterval: typeof globalThis.setInterval = import.meta.client
66
? globalThis.setInterval
7-
: () => {
7+
: (() => {
88
if (import.meta.dev) {
99
throw createError({
1010
statusCode: 500,
@@ -13,4 +13,4 @@ export const setInterval = import.meta.client
1313
}
1414

1515
console.error(intervalError)
16-
}
16+
}) as any

packages/nuxt/src/app/components/nuxt-stubs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createError } from '../composables/error'
22

3-
function renderStubMessage (name: string) {
3+
function renderStubMessage (name: string): never {
44
throw createError({
55
fatal: true,
66
statusCode: 500,

packages/nuxt/src/app/config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export function useAppConfig (): AppConfig {
6464
return nuxtApp._appConfig
6565
}
6666

67-
export function _replaceAppConfig (newConfig: AppConfig) {
67+
export function _replaceAppConfig (newConfig: AppConfig): void {
6868
const appConfig = useAppConfig()
6969

7070
deepAssign(appConfig, newConfig)
@@ -76,7 +76,7 @@ export function _replaceAppConfig (newConfig: AppConfig) {
7676
*
7777
* Will preserve existing properties.
7878
*/
79-
export function updateAppConfig (appConfig: DeepPartial<AppConfig>) {
79+
export function updateAppConfig (appConfig: DeepPartial<AppConfig>): void {
8080
const _appConfig = useAppConfig()
8181
deepAssign(_appConfig, appConfig)
8282
}

packages/nuxt/src/app/entry-spa.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export default () => {}
1+
export default (): void => {}

packages/nuxt/src/app/entry.async.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import type { CreateOptions } from './nuxt'
1+
import type { Entry } from './entry'
22

3-
const entry = import.meta.server
4-
? (ctx?: CreateOptions['ssrContext']) => import('#app/entry').then(m => m.default(ctx))
3+
const entry: Entry | (() => Promise<Entry>) = import.meta.server
4+
? ctx => import('#app/entry').then(m => m.default(ctx))
55
: () => import('#app/entry').then(m => m.default)
66

77
if (import.meta.client) {

packages/nuxt/src/app/entry.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import '#build/fetch.mjs'
88
import '#build/global-polyfills.mjs'
99

1010
import { applyPlugins, createNuxtApp } from './nuxt'
11-
import type { CreateOptions } from './nuxt'
11+
import type { CreateOptions, NuxtSSRContext } from './nuxt'
1212

1313
import { createError } from './composables/error'
1414

@@ -21,7 +21,9 @@ import RootComponent from '#build/root-component.mjs'
2121
// @ts-expect-error virtual file
2222
import { appId, appSpaLoaderAttrs, multiApp, spaLoadingTemplateOutside, vueAppRootContainer } from '#build/nuxt.config.mjs'
2323

24-
let entry: (ssrContext?: CreateOptions['ssrContext']) => Promise<App<Element>>
24+
export type Entry = (ssrContext?: NuxtSSRContext) => Promise<App<Element>>
25+
26+
let entry: Entry
2527

2628
if (import.meta.server) {
2729
entry = async function createNuxtAppServer (ssrContext: CreateOptions['ssrContext']) {
@@ -106,4 +108,4 @@ if (import.meta.client) {
106108
})
107109
}
108110

109-
export default (ssrContext?: CreateOptions['ssrContext']) => entry(ssrContext)
111+
export default (ssrContext => entry(ssrContext)) as Entry

0 commit comments

Comments
 (0)
0