Skip to content

Commit

Permalink
refactor(next): improve type safety with Next.js types
Browse files Browse the repository at this point in the history
Replace generic Record<string, unknown> types with proper Next.js types:
- NextConfig for the config object
- WebpackConfigContext for webpack options parameter
  • Loading branch information
ryoppippi committed Feb 4, 2025
1 parent 1818473 commit a088c1c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/unplugin-typia/src/next.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* @module
*/

import type { NextConfig } from 'next';
import type { WebpackConfigContext } from 'next/dist/server/config-shared.js';
import webpack from './webpack.js';
import type { Options } from './core/options.js';

Expand All @@ -28,10 +30,10 @@ import type { Options } from './core/options.js';
* );
* ```
*/
function next(nextConfig: Record<string, unknown> = {}, options: Options): Record<string, unknown> {
function next(nextConfig: NextConfig = {}, options: Options): NextConfig {
return {
...nextConfig,
webpack(config: Record<string, unknown>, webpackOptions: Record<string, unknown>) {
webpack(config: Record<string, unknown>, webpackOptions: WebpackConfigContext) {
if (Array.isArray(config?.plugins)) {
config.plugins.unshift(webpack(options));
}
Expand Down

0 comments on commit a088c1c

Please sign in to comment.