fumadocs-typescript 4.0.8 → 4.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +29 -23
  2. package/package.json +7 -7
package/dist/index.js CHANGED
@@ -94,8 +94,11 @@ import * as ts from "ts-morph";
94
94
  function getSimpleForm(type, checker, noUndefined = false) {
95
95
  if (type.isUndefined() && noUndefined) return "";
96
96
  const alias = type.getAliasSymbol();
97
- if (alias && type.getAliasTypeArguments().length === 0) {
98
- return alias.getEscapedName();
97
+ if (alias) {
98
+ return alias.getDeclaredType().getText(
99
+ void 0,
100
+ ts.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope
101
+ );
99
102
  }
100
103
  if (type.isUnion()) {
101
104
  const types = [];
@@ -131,7 +134,7 @@ function getSimpleForm(type, checker, noUndefined = false) {
131
134
  }
132
135
  return type.getText(
133
136
  void 0,
134
- ts.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope | ts.TypeFormatFlags.InTypeAlias
137
+ ts.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope
135
138
  );
136
139
  }
137
140
 
@@ -141,7 +144,7 @@ function createGenerator(config) {
141
144
  const options = config instanceof Project2 ? {
142
145
  project: config
143
146
  } : config;
144
- const cacheType = (_a = options == null ? void 0 : options.cache) != null ? _a : "fs";
147
+ const cacheType = (_a = options == null ? void 0 : options.cache) != null ? _a : process.env.NODE_ENV !== "development" ? "fs" : false;
145
148
  const cache = cacheType === "fs" ? createCache() : null;
146
149
  let instance;
147
150
  function getProject() {
@@ -203,7 +206,7 @@ function generate(program, name, declaration, { allowInternal = false, transform
203
206
  };
204
207
  }
205
208
  function getDocEntry(prop, context) {
206
- var _a, _b;
209
+ var _a;
207
210
  const { transform, program } = context;
208
211
  if (context.type.isClass() && prop.getName().startsWith("#")) {
209
212
  return;
@@ -216,10 +219,15 @@ function getDocEntry(prop, context) {
216
219
  text: ts2.displayPartsToString(tag.getText())
217
220
  })
218
221
  );
219
- let type = getFullType(subType);
220
- for (const tag of tags) {
221
- if (tag.name !== "remarks") continue;
222
- type = (_b = (_a = new RegExp("^`(?<name>.+)`").exec(tag.text)) == null ? void 0 : _a[1]) != null ? _b : type;
222
+ let simplifiedType = getSimpleForm(
223
+ subType,
224
+ program.getTypeChecker(),
225
+ isOptional
226
+ );
227
+ const remarksTag = tags.find((tag) => tag.name === "remarks");
228
+ if (remarksTag) {
229
+ const match = (_a = new RegExp("^`(?<name>.+)`").exec(remarksTag.text)) == null ? void 0 : _a[1];
230
+ if (match) simplifiedType = match;
223
231
  }
224
232
  const entry = {
225
233
  name: prop.getName(),
@@ -229,12 +237,8 @@ function getDocEntry(prop, context) {
229
237
  )
230
238
  ),
231
239
  tags,
232
- type,
233
- simplifiedType: getSimpleForm(
234
- subType,
235
- program.getTypeChecker(),
236
- isOptional
237
- ),
240
+ type: getFullType(subType),
241
+ simplifiedType,
238
242
  required: !isOptional,
239
243
  deprecated: tags.some((tag) => tag.name === "deprecated")
240
244
  };
@@ -242,15 +246,15 @@ function getDocEntry(prop, context) {
242
246
  return entry;
243
247
  }
244
248
  function getFullType(type) {
245
- var _a, _b;
246
- let typeName = type.getText(
249
+ const alias = type.getAliasSymbol();
250
+ if (alias) {
251
+ return alias.getDeclaredType().getText(void 0, ts2.TypeFormatFlags.NoTruncation);
252
+ }
253
+ return type.getText(
247
254
  void 0,
248
- ts2.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope | ts2.TypeFormatFlags.NoTruncation | ts2.TypeFormatFlags.InTypeAlias
255
+ ts2.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope | ts2.TypeFormatFlags.NoTruncation | // we use `InTypeAlias` to force TypeScript to extend generic types like `ExtractParams<T>` into more detailed forms like `T extends string? ExtractParamsFromString<T> : never`.
256
+ ts2.TypeFormatFlags.InTypeAlias
249
257
  );
250
- if (type.getAliasSymbol() && type.getAliasTypeArguments().length === 0) {
251
- typeName = (_b = (_a = type.getAliasSymbol()) == null ? void 0 : _a.getEscapedName()) != null ? _b : typeName;
252
- }
253
- return typeName;
254
258
  }
255
259
 
256
260
  // src/lib/mdx.ts
@@ -266,9 +270,11 @@ ${doc.description}
266
270
 
267
271
  <div className="flex flex-row items-center gap-4">
268
272
  <code className="text-sm">${c.name}</code>
269
- <code className="text-fd-muted-foreground">{${JSON.stringify(c.type)}}</code>
273
+ <code className="text-fd-muted-foreground">{${JSON.stringify(c.simplifiedType)}}</code>
270
274
  </div>
271
275
 
276
+ Full Type: <code className="text-fd-muted-foreground">{${JSON.stringify(c.type)}}</code>
277
+
272
278
  ${c.description || "No Description"}
273
279
 
274
280
  ${c.tags.map((tag) => `- ${tag.name}:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-typescript",
3
- "version": "4.0.8",
3
+ "version": "4.0.9",
4
4
  "description": "Typescript Integration for Fumadocs",
5
5
  "keywords": [
6
6
  "NextJs",
@@ -33,8 +33,8 @@
33
33
  "hast-util-to-jsx-runtime": "^2.3.6",
34
34
  "remark": "^15.0.1",
35
35
  "remark-rehype": "^11.1.2",
36
- "tinyglobby": "^0.2.14",
37
- "ts-morph": "^26.0.0",
36
+ "tinyglobby": "^0.2.15",
37
+ "ts-morph": "^27.0.0",
38
38
  "unist-util-visit": "^5.0.0"
39
39
  },
40
40
  "devDependencies": {
@@ -42,14 +42,14 @@
42
42
  "@types/estree": "^1.0.8",
43
43
  "@types/hast": "^3.0.4",
44
44
  "@types/mdast": "^4.0.3",
45
- "@types/node": "24.3.1",
46
- "@types/react": "19.1.12",
45
+ "@types/node": "24.5.2",
46
+ "@types/react": "19.1.13",
47
47
  "@types/react-dom": "19.1.9",
48
48
  "typescript": "^5.9.2",
49
49
  "unified": "^11.0.5",
50
50
  "eslint-config-custom": "0.0.0",
51
- "fumadocs-core": "15.7.10",
52
- "fumadocs-ui": "15.7.10",
51
+ "fumadocs-core": "15.8.0",
52
+ "fumadocs-ui": "15.8.0",
53
53
  "tsconfig": "0.0.0"
54
54
  },
55
55
  "peerDependencies": {