Skip to content

Commit 8d1a989

Browse files
committed
fix: type error
1 parent 406b7e4 commit 8d1a989

File tree

5 files changed

+6
-7
lines changed

5 files changed

+6
-7
lines changed

src/core/server/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import ws from './ws'
1313

1414
export async function createServer(options: Options) {
1515
const { server, launchEditor, passLogs, inspector } = options
16-
const { port, host } = server || { port: 3070, host: '127.0.0.1' }
17-
const _port = Number(port) || 3070
16+
const { port, host } = server!
17+
const _port = Number(port)!
1818
const specifiedEditor = typeof launchEditor === 'object' ? launchEditor.specifiedEditor : undefined
1919
try {
2020
await fetch(`http://${host}:${_port}/health`)

src/core/server/launchEditor.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import type { Options } from './../../types'
21
import { cwd } from 'node:process'
32
import { defineEventHandler, getQuery } from 'h3'
43
import launch from 'launch-editor'

src/core/utils/codegen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export function genConsoleString(genContext: GenContext) {
5353
const { options, originalColumn, originalLine, argType, id, consoleMethod } = genContext
5454
let { argsName } = genContext
5555
const { prefix, suffix, launchEditor, server, highlight } = options
56-
const { port, host } = server || { port: 3070, host: '127.0.0.1' }
56+
const { port, host } = server!
5757
const extendedPathFileNames = typeof highlight === 'object' ? highlight.extendedPathFileNames : []
5858
const _prefix = prefix ? `${prefix}\\n` : ''
5959
const _suffix = suffix ? `\\n${suffix}` : ''

src/core/utils/common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export function printInfo(options: Options, spacing: string = ' ') {
1010
if (typeof options.inspector === 'object' && options.inspector.printUrl === false)
1111
return false
1212

13-
const { port, host } = options.server || { port: 3070, host: '127.0.0.1' }
13+
const { port, host } = options.server!
1414

1515
// eslint-disable-next-line no-console
1616
console.log(` \x1B[32m➜\x1B[39m${spacing}\x1B[1mConsole Inspector\x1B[22m: \x1B[36m\x1B[4mhttp://${host === '127.0.0.1' ? '127.1' : host}:${port}/inspector\x1B[24m\x1B[39m`)

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const unpluginFactory: UnpluginFactory<Options | undefined> = (rawOptions
1717
const options = resolveOptions(rawOptions)
1818

1919
async function detectPort() {
20-
const isAvailable = await checkPort(options.server.port)
20+
const isAvailable = await checkPort(options.server.port!)
2121
if (!isAvailable)
2222
options.server.port = await getRandomPort()
2323
}
@@ -52,7 +52,7 @@ export const unpluginFactory: UnpluginFactory<Options | undefined> = (rawOptions
5252
id = id.slice(1)
5353

5454
if (id === VirtualModules.Init) {
55-
return initVirtualModulesGenerator(options.server.port, env.NODE_ENV === 'production')
55+
return initVirtualModulesGenerator(options.server.port!, env.NODE_ENV === 'production')
5656
}
5757
else if (id === VirtualModules.ThemeDetect) {
5858
return themeDetectVirtualModule(env.NODE_ENV === 'production')

0 commit comments

Comments
 (0)