fumadocs-typescript 4.0.9 → 4.0.11

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 +25 -22
  2. package/package.json +8 -8
package/dist/index.js CHANGED
@@ -91,14 +91,13 @@ import path2 from "path";
91
91
 
92
92
  // src/lib/get-simple-form.ts
93
93
  import * as ts from "ts-morph";
94
- function getSimpleForm(type, checker, noUndefined = false) {
94
+ function getSimpleForm(type, checker, noUndefined = false, location) {
95
95
  if (type.isUndefined() && noUndefined) return "";
96
96
  const alias = type.getAliasSymbol();
97
97
  if (alias) {
98
- return alias.getDeclaredType().getText(
99
- void 0,
100
- ts.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope
101
- );
98
+ const args = type.getAliasTypeArguments();
99
+ if (args.length === 0) return alias.getName();
100
+ return `${alias.getName()}<${args.map((arg) => getSimpleForm(arg, checker)).join(", ")}>`;
102
101
  }
103
102
  if (type.isUnion()) {
104
103
  const types = [];
@@ -108,7 +107,7 @@ function getSimpleForm(type, checker, noUndefined = false) {
108
107
  }
109
108
  return types.length > 0 ? (
110
109
  // boolean | null will become true | false | null, need to ensure it's still returned as boolean
111
- types.join(" | ").replace("true | false", "boolean")
110
+ dedupe(types).join(" | ").replace("true | false", "boolean")
112
111
  ) : "never";
113
112
  }
114
113
  if (type.isIntersection()) {
@@ -117,7 +116,7 @@ function getSimpleForm(type, checker, noUndefined = false) {
117
116
  const str = getSimpleForm(t, checker, noUndefined);
118
117
  if (str.length > 0 && str !== "never") types.unshift(str);
119
118
  }
120
- return types.join(" & ");
119
+ return dedupe(types).join(" & ");
121
120
  }
122
121
  if (type.isTuple()) {
123
122
  const elements = type.getTupleElements().map((t) => getSimpleForm(t, checker)).join(", ");
@@ -133,10 +132,21 @@ function getSimpleForm(type, checker, noUndefined = false) {
133
132
  return "object";
134
133
  }
135
134
  return type.getText(
136
- void 0,
135
+ location,
137
136
  ts.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope
138
137
  );
139
138
  }
139
+ function dedupe(arr) {
140
+ const dedupe2 = /* @__PURE__ */ new Set();
141
+ const out = [];
142
+ for (const item of arr) {
143
+ if (!dedupe2.has(item)) {
144
+ out.push(item);
145
+ dedupe2.add(item);
146
+ }
147
+ }
148
+ return out;
149
+ }
140
150
 
141
151
  // src/lib/base.ts
142
152
  function createGenerator(config) {
@@ -211,7 +221,7 @@ function getDocEntry(prop, context) {
211
221
  if (context.type.isClass() && prop.getName().startsWith("#")) {
212
222
  return;
213
223
  }
214
- const subType = program.getTypeChecker().getTypeOfSymbolAtLocation(prop, context.declaration);
224
+ const subType = prop.getTypeAtLocation(context.declaration);
215
225
  const isOptional = prop.isOptional();
216
226
  const tags = prop.getJsDocTags().map(
217
227
  (tag) => ({
@@ -222,7 +232,8 @@ function getDocEntry(prop, context) {
222
232
  let simplifiedType = getSimpleForm(
223
233
  subType,
224
234
  program.getTypeChecker(),
225
- isOptional
235
+ isOptional,
236
+ context.declaration
226
237
  );
227
238
  const remarksTag = tags.find((tag) => tag.name === "remarks");
228
239
  if (remarksTag) {
@@ -237,7 +248,10 @@ function getDocEntry(prop, context) {
237
248
  )
238
249
  ),
239
250
  tags,
240
- type: getFullType(subType),
251
+ type: subType.getText(
252
+ context.declaration,
253
+ ts2.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope | ts2.TypeFormatFlags.NoTruncation
254
+ ),
241
255
  simplifiedType,
242
256
  required: !isOptional,
243
257
  deprecated: tags.some((tag) => tag.name === "deprecated")
@@ -245,17 +259,6 @@ function getDocEntry(prop, context) {
245
259
  transform == null ? void 0 : transform.call(context, entry, subType, prop);
246
260
  return entry;
247
261
  }
248
- function getFullType(type) {
249
- const alias = type.getAliasSymbol();
250
- if (alias) {
251
- return alias.getDeclaredType().getText(void 0, ts2.TypeFormatFlags.NoTruncation);
252
- }
253
- return type.getText(
254
- void 0,
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
257
- );
258
- }
259
262
 
260
263
  // src/lib/mdx.ts
261
264
  import * as path3 from "path";
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "fumadocs-typescript",
3
- "version": "4.0.9",
3
+ "version": "4.0.11",
4
4
  "description": "Typescript Integration for Fumadocs",
5
5
  "keywords": [
6
6
  "NextJs",
7
7
  "fumadocs",
8
8
  "Docs"
9
9
  ],
10
- "homepage": "https://fumadocs.vercel.app",
10
+ "homepage": "https://fumadocs.dev",
11
11
  "repository": "github:fuma-nama/fumadocs",
12
12
  "license": "MIT",
13
13
  "author": "Fuma Nama",
@@ -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.5.2",
46
- "@types/react": "19.1.13",
47
- "@types/react-dom": "19.1.9",
48
- "typescript": "^5.9.2",
45
+ "@types/node": "24.6.2",
46
+ "@types/react": "19.2.0",
47
+ "@types/react-dom": "19.2.0",
48
+ "typescript": "^5.9.3",
49
49
  "unified": "^11.0.5",
50
50
  "eslint-config-custom": "0.0.0",
51
- "fumadocs-core": "15.8.0",
52
- "fumadocs-ui": "15.8.0",
51
+ "fumadocs-core": "15.8.3",
52
+ "fumadocs-ui": "15.8.3",
53
53
  "tsconfig": "0.0.0"
54
54
  },
55
55
  "peerDependencies": {