Skip to content

Commit 7448857

Browse files
committed
fix: 🐛 Fix Config type
1 parent 51a0ac9 commit 7448857

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

src/image.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import React from 'react'
44

55
import type { Manifest } from './cli/types'
66
import formatValidate from './cli/utils/formatValidate'
7-
import getConfig, { ParsedImageInfo } from './utils/getConfig'
7+
import getConfig, { DefaultImageParser } from './utils/getConfig'
88

99
const config = getConfig()
1010

@@ -18,7 +18,7 @@ function hashCode(src: string) {
1818
return `${hash}`
1919
}
2020

21-
const defaultImageParser: (src: string) => ParsedImageInfo = (src: string) => {
21+
const defaultImageParser: DefaultImageParser = (src: string) => {
2222
const path = src.split(/\.([^.]*$)/)[0]
2323
const extension = (src.split(/\.([^.]*$)/)[1] || '').split('?')[0]
2424

src/legacy-image.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import React from 'react'
44

55
import type { Manifest } from './cli/types'
66
import formatValidate from './cli/utils/formatValidate'
7-
import getConfig, { ParsedImageInfo } from './utils/getConfig'
7+
import getConfig, { DefaultImageParser } from './utils/getConfig'
88

99
const config = getConfig()
1010

@@ -18,7 +18,7 @@ function hashCode(src: string) {
1818
return `${hash}`
1919
}
2020

21-
const defaultImageParser: (src: string) => ParsedImageInfo = (src: string) => {
21+
const defaultImageParser: DefaultImageParser = (src: string) => {
2222
const path = src.split(/\.([^.]*$)/)[0]
2323
const extension = (src.split(/\.([^.]*$)/)[1] || '').split('?')[0]
2424

src/utils/getConfig.ts

+7-8
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ import type { AvifOptions, JpegOptions, PngOptions, WebpOptions } from 'sharp'
22

33
import type { AllowedFormat } from '../cli/utils/formatValidate'
44

5-
export type ParsedImageInfo = {
5+
type ParsedImageInfo = {
66
pathWithoutName: string
77
name: string
88
extension: string
99
}
10+
export type DefaultImageParser = (src: string) => ParsedImageInfo
11+
type SourceImageParser = (determinerProps: { src: string; defaultParser: DefaultImageParser }) => ParsedImageInfo
1012

1113
export type Config = {
1214
/**
@@ -28,14 +30,14 @@ export type Config = {
2830
*
2931
* @type {string}
3032
*/
31-
externalImageDir?: string
33+
basePath?: string
3234
/**
3335
* You can customize the directory to output downloaded external images.
3436
* The default is '_next/static/media'
3537
*
3638
* @type {string}
3739
*/
38-
basePath?: string
40+
externalImageDir?: string
3941
/**
4042
* You can customize the generation of file names.
4143
*
@@ -74,12 +76,9 @@ export type Config = {
7476
/**
7577
* Allows you to optionally override the parsed image information before optimized images.
7678
*
77-
* @type {({ src: string, default: (src: string) => object ) }) => object}
79+
* @type {SourceImageParser}
7880
*/
79-
sourceImageParser?: (determinerProps: {
80-
src: string
81-
defaultParser: (src: string) => ParsedImageInfo
82-
}) => ParsedImageInfo
81+
sourceImageParser?: SourceImageParser
8382
}
8483

8584
const getConfig = (): Config => {

0 commit comments

Comments
 (0)