Skip to content

Commit

Permalink
Merge pull request #44 from relative-ci/fix-types
Browse files Browse the repository at this point in the history
fix types
  • Loading branch information
vio authored Jan 11, 2025
2 parents 4c78577 + 0f923cc commit 011c9bd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export type ChunkStats = Omit<OutputChunk, 'code' | 'modules'> & {
modules: Record<string, ModuleStats>;
};

export type Stats = OutputBundle;
export type Stats = Record<string, AssetStats | ChunkStats>;

export type StatsOptions = {
/**
Expand Down Expand Up @@ -49,7 +49,7 @@ export default function extractRollupStats(bundle: OutputBundle, options: StatsO

// Skip asset source if options source is false
if (!source) {
assetStats = omit(assetStats, 'source');
assetStats = omit(assetStats, ['source']);
}

output[bundleEntryFilepath] = assetStats;
Expand All @@ -62,7 +62,7 @@ export default function extractRollupStats(bundle: OutputBundle, options: StatsO

// Skip chunk source if options source is false
if (!source) {
chunkStats = omit(chunkStats, 'code');
chunkStats = omit(chunkStats, ['code']);
}

// Extract chunk modules stats
Expand All @@ -78,7 +78,7 @@ export default function extractRollupStats(bundle: OutputBundle, options: StatsO

// Skip module source if options source is false
if (!source) {
moduleStats = omit(moduleStats, 'code');
moduleStats = omit(moduleStats, ['code']);
}

chunkModulesStats[bundleModuleFilepath] = moduleStats;
Expand Down
15 changes: 8 additions & 7 deletions src/utils/omit.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
export function omit(
data: { [key: string]: unknown },
keys: Array<string>
): { [key: string]: unknown } {
const result = {};
export function omit<D extends object, K extends keyof D>(
data: D,
keys: K[],
): Omit<D, K> {
const result = {} as D;
const objectKeys = Object.keys(data) as Array<K>;

Object.entries(data).forEach(([key, value]) => {
objectKeys.forEach((key) => {
if (!keys.includes(key)) {
result[key] = value;
result[key] = data[key];
}
});

Expand Down

0 comments on commit 011c9bd

Please sign in to comment.