diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0e28b571..32d3242f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -55,7 +55,7 @@ jobs: fail-fast: false matrix: python-version: ["3.12"] - typedoc-version: ["0.25", "0.26"] + typedoc-version: ["0.25", "0.26", "0.27"] name: Python ${{ matrix.python-version}} + typedoc ${{ matrix.typedoc-version }} steps: diff --git a/noxfile.py b/noxfile.py index 2abf80a6..6d057f5a 100644 --- a/noxfile.py +++ b/noxfile.py @@ -26,7 +26,7 @@ def tests(session: Session) -> None: @nox.session(python=["3.12"]) -@nox.parametrize("typedoc", ["0.25", "0.26"]) +@nox.parametrize("typedoc", ["0.25", "0.26", "0.27"]) def test_typedoc(session: Session, typedoc: str) -> None: # Install python dependencies session.install("-r", "requirements_dev.txt") diff --git a/sphinx_js/js/convertType.ts b/sphinx_js/js/convertType.ts index 3ad424c2..7f89c244 100644 --- a/sphinx_js/js/convertType.ts +++ b/sphinx_js/js/convertType.ts @@ -215,7 +215,10 @@ class TypeConverter implements TypeVisitor { // up so in this case we index on file name and reference name. // Another place where we incorrectly handle merged declarations - const src = refl.sources![0]; + const src = type.reflection?.sources?.[0]; + if (!src) { + return undefined; + } const newTarget = this.symbolToType.get( `${src.fullFileName}:${refl.name}`, ); @@ -299,18 +302,17 @@ class TypeConverter implements TypeVisitor { } reference(type: ReferenceType): Type { + // if we got a reflection use that. It's not all that clear how to deal + // with type arguments here though... + const res = this.convertPrivateReferenceToReflection(type); + if (res) { + return res; + } if (type.isIntentionallyBroken()) { // If it's intentionally broken, don't add an xref. It's probably a type // parameter. return this.addTypeArguments(type, [type.name]); } else { - // if we got a reflection use that. It's not all that clear how to deal - // with type arguments here though... - const res = this.convertPrivateReferenceToReflection(type); - // else use convertReferenceToXRef - if (res) { - return res; - } return this.convertReferenceToXRef(type); } } diff --git a/tests/test.ts b/tests/test.ts index 17c87769..407c0838 100644 --- a/tests/test.ts +++ b/tests/test.ts @@ -33,7 +33,7 @@ suite("types.ts", async () => { function getObject(name: string): TopLevelIR { const obj = map.get(name); assert(obj); - return obj!; + return obj; } suite("basic", async () => { for (const [obj_name, type_name] of [ @@ -100,4 +100,14 @@ suite("types.ts", async () => { }, ]); }); + await test("private_type_alias_1", () => { + const obj = getObject("typeIsPrivateTypeAlias1"); + assert.strictEqual(obj.kind, "attribute"); + assert.deepStrictEqual(joinType(obj.type), "{ a: number; b: string; }"); + }); + await test("private_type_alias_2", () => { + const obj = getObject("typeIsPrivateTypeAlias2"); + assert.strictEqual(obj.kind, "attribute"); + assert.deepStrictEqual(joinType(obj.type), "{ a: number; b: string; }"); + }); });