diff --git a/scripts/rebuild_specs.js b/scripts/rebuild_specs.js index 711618da6..457e1a039 100644 --- a/scripts/rebuild_specs.js +++ b/scripts/rebuild_specs.js @@ -58,29 +58,26 @@ function rebuildConverterTests(dirs) { return; } - return Promise.all( - dirs.map((fullPath) => { - console.log(fullPath); - const src = app.expandInputFiles([fullPath]); - return Promise.all( - conversions.map(([file, before, after]) => { - const out = path.join(fullPath, `${file}.json`); - if (fs.existsSync(out)) { - TypeDoc.resetReflectionID(); - before(); - const result = app.converter.convert(src, program); - const serialized = app.serializer.toObject(result); - - const data = JSON.stringify(serialized, null, " ") - .split(TypeDoc.normalizePath(base)) - .join("%BASE%"); - after(); - return fs.writeFile(out.replace("dist", "src"), data); - } - }) - ); - }) - ); + for (const fullPath of dirs) { + console.log(fullPath); + const src = app.expandInputFiles([fullPath]); + + for (const [file, before, after] of conversions) { + const out = path.join(fullPath, `${file}.json`); + if (fs.existsSync(out)) { + TypeDoc.resetReflectionID(); + before(); + const result = app.converter.convert(src, program); + const serialized = app.serializer.toObject(result); + + const data = JSON.stringify(serialized, null, " ") + .split(TypeDoc.normalizePath(base)) + .join("%BASE%"); + after(); + fs.writeFileSync(out.replace("dist", "src"), data); + } + } + } } async function rebuildRendererTest() { diff --git a/src/lib/converter/types.ts b/src/lib/converter/types.ts index afe975832..ac4320a22 100644 --- a/src/lib/converter/types.ts +++ b/src/lib/converter/types.ts @@ -149,7 +149,9 @@ const arrayConverter: TypeConverter = { }, convertType(context, type) { const params = context.checker.getTypeArguments(type); - assert(params.length === 1); + // This is *almost* always true... except for when this type is in the constraint of a type parameter see GH#1408 + // assert(params.length === 1); + assert(params.length > 0); return new ArrayType(convertType(context, params[0])); }, }; diff --git a/src/test/converter/alias/alias.ts b/src/test/converter/alias/alias.ts index 858e870b8..2ea883479 100644 --- a/src/test/converter/alias/alias.ts +++ b/src/test/converter/alias/alias.ts @@ -61,3 +61,7 @@ export namespace GH1330 { declare const makeProp: (x: T) => HasProp; export const testValue3 = makeProp(1); } + +export namespace GH1408 { + export declare function foo(): T; +} diff --git a/src/test/converter/alias/specs.json b/src/test/converter/alias/specs.json index 9bd97f177..0ba88fda6 100644 --- a/src/test/converter/alias/specs.json +++ b/src/test/converter/alias/specs.json @@ -177,6 +177,60 @@ } ] }, + { + "id": 39, + "name": "GH1408", + "kind": 2, + "kindString": "Namespace", + "flags": {}, + "children": [ + { + "id": 40, + "name": "foo", + "kind": 64, + "kindString": "Function", + "flags": {}, + "signatures": [ + { + "id": 41, + "name": "foo", + "kind": 4096, + "kindString": "Call signature", + "flags": {}, + "typeParameter": [ + { + "id": 42, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": {}, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "unknown" + } + } + } + ], + "type": { + "type": "reference", + "name": "T" + } + } + ] + } + ], + "groups": [ + { + "title": "Functions", + "kind": 64, + "children": [ + 40 + ] + } + ] + }, { "id": 21, "name": "HorribleRecursiveTypeThatShouldNotBeUsedByAnyone", @@ -684,7 +738,8 @@ "title": "Namespaces", "kind": 2, "children": [ - 28 + 28, + 39 ] }, {