diff --git a/scripts/rebuild_specs.js b/scripts/rebuild_specs.js index 245941657..c18005f1b 100644 --- a/scripts/rebuild_specs.js +++ b/scripts/rebuild_specs.js @@ -21,7 +21,8 @@ app.bootstrap({ ], name: 'typedoc', excludeExternals: true, - disableSources: true + disableSources: true, + resolveJsonModule: true }); // Note that this uses the test files in dist, not in src, this is important since diff --git a/src/lib/application.ts b/src/lib/application.ts index 3d1c7a31a..925cbcc65 100644 --- a/src/lib/application.ts +++ b/src/lib/application.ts @@ -281,6 +281,7 @@ export class Application extends ChildableComponent< return exclude.some(mm => mm.match(fileName)); } + const includeJson = this.options.getCompilerOptions().resolveJsonModule; const supportedFileRegex = this.options.getCompilerOptions().allowJs ? /\.[tj]sx?$/ : /\.tsx?$/; function add(file: string, entryPoint: boolean) { let stats: FS.Stats; @@ -305,6 +306,8 @@ export class Application extends ChildableComponent< }); } else if (supportedFileRegex.test(file)) { files.push(file); + } else if (includeJson && file.endsWith('.json')) { + files.push(file); } } diff --git a/src/lib/converter/converter.ts b/src/lib/converter/converter.ts index 090dd5044..78e4cb887 100644 --- a/src/lib/converter/converter.ts +++ b/src/lib/converter/converter.ts @@ -250,7 +250,9 @@ export class Converter extends ChildableComponent !path.endsWith('.json')); const program = ts.createProgram(normalizedFiles, this.application.options.getCompilerOptions()); const checker = program.getTypeChecker(); diff --git a/src/test/converter.test.ts b/src/test/converter.test.ts index 08c2e0cbf..a7545273d 100644 --- a/src/test/converter.test.ts +++ b/src/test/converter.test.ts @@ -20,7 +20,8 @@ describe('Converter', function() { name: 'typedoc', ignoreCompilerErrors: true, excludeExternals: true, - disableSources: true + disableSources: true, + resolveJsonModule: true }); const checks: [string, () => void, () => void][] = [ diff --git a/src/test/converter/exports/export.ts b/src/test/converter/exports/export.ts index 9976c553f..8c1e95701 100644 --- a/src/test/converter/exports/export.ts +++ b/src/test/converter/exports/export.ts @@ -11,3 +11,8 @@ function add(x: number, y: number) { // Note that this will show up in the docs, not the default function from mod2. // export * from './mod2' does *not* re-export the default function. export default function (a: number) {} + +import * as x from './test.json'; + +/** @hidden */ +const x2: string = x.issue; diff --git a/src/test/converter/exports/test.json b/src/test/converter/exports/test.json new file mode 100644 index 000000000..8b317d3b4 --- /dev/null +++ b/src/test/converter/exports/test.json @@ -0,0 +1,3 @@ +{ + "issue": "https://github.com/TypeStrong/typedoc/issues/1323" +}