Core: fix internal types

This commit is contained in:
Fuma Nama
2026-05-11 23:12:42 +08:00
parent 2569154380
commit 062beab282
6 changed files with 21 additions and 17 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'fumadocs-core': patch
---
fix internal types
@@ -11,7 +11,7 @@ export function transformerFallback(): PageTreeTransformer {
return {
root(root) {
if (shouldIgnore(this)) return root;
const isolatedStorage: ContentStorage = new FileSystem();
const isolatedStorage = new FileSystem() as ContentStorage;
if (addedFiles.size === this.storage.files.size) return root;
for (const file of this.storage.getFiles()) {
+2 -2
View File
@@ -5,8 +5,8 @@ import type { LoaderPlugin } from '../loader';
/**
* a function to generate slugs, return `undefined` to fallback to default generation.
*/
export type SlugFn<S = ContentStorage> = (
file: S extends ContentStorage<infer P, unknown> ? P : never,
export type SlugFn<S extends ContentStorage = ContentStorage> = (
file: S['$inferPage'],
) => string[] | undefined;
/**
+10 -4
View File
@@ -3,9 +3,15 @@ import { slash, splitPath } from '@/source/path';
import type { ResolvedLoaderConfig } from '../loader';
import { isStaticSource, MetaData, PageData, type StaticSource } from '../source';
export type ContentStorage<P = ContentStoragePageFile, M = ContentStorageMetaFile> = FileSystem<
P | M
>;
export type ContentStorage<
P extends ContentStoragePageFile = ContentStoragePageFile,
M extends ContentStorageMetaFile = ContentStorageMetaFile,
> = FileSystem<P | M> & {
/** always `undefined`, for inferring types only */
$inferPage: P;
/** always `undefined`, for inferring types only */
$inferMeta: M;
};
/** @internal */
export interface ContentStorageMetaFile<
@@ -126,7 +132,7 @@ export function createContentStorageBuilder(loaderConfig: ResolvedLoaderConfig)
}
function makeStorage(locale: string | typeof EmptyLang, inherit?: ContentStorage) {
const storage = new FileSystem(inherit);
const storage = new FileSystem(inherit) as ContentStorage;
for (const [storageKey, file] of fileMap.get(locale) ?? []) {
storage.write(storageKey, file);
}
+3 -7
View File
@@ -75,13 +75,9 @@ export async function crawlFrameworkPkgs(
_parentIsFrameworkPkg = false,
hasFrameworkAncestor = false,
) {
const isRoot = parentDepNames.length === 0;
const crawlDevDependencies = isRoot;
const deps = [
...Object.keys(currentPkgJson.dependencies ?? {}),
...(crawlDevDependencies ? Object.keys(currentPkgJson.devDependencies ?? {}) : []),
].filter((dep) => !parentDepNames.includes(dep));
const deps = Object.keys(currentPkgJson.dependencies ?? {}).filter(
(dep) => !parentDepNames.includes(dep),
);
await Promise.all(
deps.map(async (dep) => {
-3
View File
@@ -3471,9 +3471,6 @@ importers:
'@fumadocs/story':
specifier: workspace:*
version: link:../story
'@types/node':
specifier: ^25.6.2
version: 25.6.2
fumadocs-core:
specifier: workspace:*
version: link:../core