typedoc 0.17.3 → 0.17.7

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 (64) hide show
  1. package/dist/lib/application.js +14 -5
  2. package/dist/lib/application.js.map +1 -1
  3. package/dist/lib/converter/factories/declaration.js +2 -1
  4. package/dist/lib/converter/factories/declaration.js.map +1 -1
  5. package/dist/lib/converter/nodes/module.js +3 -1
  6. package/dist/lib/converter/nodes/module.js.map +1 -1
  7. package/dist/lib/converter/nodes/variable.js.map +1 -1
  8. package/dist/lib/converter/plugins/ImplementsPlugin.js +8 -2
  9. package/dist/lib/converter/plugins/ImplementsPlugin.js.map +1 -1
  10. package/dist/lib/converter/types/anonymous.d.ts +12 -0
  11. package/dist/lib/converter/types/anonymous.js +36 -0
  12. package/dist/lib/converter/types/anonymous.js.map +1 -0
  13. package/dist/lib/converter2/converter.d.ts +16 -0
  14. package/dist/lib/converter2/converter.js +35 -0
  15. package/dist/lib/converter2/converter.js.map +1 -0
  16. package/dist/lib/converter2/index.d.ts +0 -0
  17. package/dist/lib/converter2/index.js +1 -0
  18. package/dist/lib/converter2/index.js.map +1 -0
  19. package/dist/lib/converter2/symbols/enum.d.ts +0 -0
  20. package/dist/lib/converter2/symbols/enum.js +1 -0
  21. package/dist/lib/converter2/symbols/enum.js.map +1 -0
  22. package/dist/lib/models/reflections/abstract.d.ts +3 -1
  23. package/dist/lib/models/reflections/abstract.js +6 -1
  24. package/dist/lib/models/reflections/abstract.js.map +1 -1
  25. package/dist/lib/models/types/object.d.ts +12 -0
  26. package/dist/lib/models/types/object.js +26 -0
  27. package/dist/lib/models/types/object.js.map +1 -0
  28. package/dist/lib/output/plugins/JavascriptIndexPlugin.js +15 -5
  29. package/dist/lib/output/plugins/JavascriptIndexPlugin.js.map +1 -1
  30. package/dist/lib/output/plugins/MarkedLinksPlugin.js +2 -2
  31. package/dist/lib/output/plugins/MarkedLinksPlugin.js.map +1 -1
  32. package/dist/lib/output/plugins/MarkedPlugin.js +4 -1
  33. package/dist/lib/output/plugins/MarkedPlugin.js.map +1 -1
  34. package/dist/lib/utils/index.d.ts +3 -1
  35. package/dist/lib/utils/index.js +0 -2
  36. package/dist/lib/utils/index.js.map +1 -1
  37. package/dist/lib/utils/options/declaration.d.ts +4 -2
  38. package/dist/lib/utils/options/declaration.js +46 -13
  39. package/dist/lib/utils/options/declaration.js.map +1 -1
  40. package/dist/lib/utils/options/options.d.ts +10 -11
  41. package/dist/lib/utils/options/options.js +26 -37
  42. package/dist/lib/utils/options/options.js.map +1 -1
  43. package/dist/lib/utils/options/readers/arguments.js +15 -7
  44. package/dist/lib/utils/options/readers/arguments.js.map +1 -1
  45. package/dist/lib/utils/options/readers/tsconfig.js +15 -9
  46. package/dist/lib/utils/options/readers/tsconfig.js.map +1 -1
  47. package/dist/lib/utils/options/readers/typedoc.js +11 -9
  48. package/dist/lib/utils/options/readers/typedoc.js.map +1 -1
  49. package/dist/lib/utils/options/sources/typescript.d.ts +1 -1
  50. package/dist/lib/utils/options/sources/typescript.js +7 -2
  51. package/dist/lib/utils/options/sources/typescript.js.map +1 -1
  52. package/package.json +15 -12
  53. package/dist/lib/converter/nodes/property-signature.d.ts +0 -8
  54. package/dist/lib/converter/nodes/property-signature.js +0 -34
  55. package/dist/lib/converter/nodes/property-signature.js.map +0 -1
  56. package/dist/lib/converter/nodes/property.d.ts +0 -8
  57. package/dist/lib/converter/nodes/property.js +0 -38
  58. package/dist/lib/converter/nodes/property.js.map +0 -1
  59. package/dist/lib/utils/options/sources/decorator.d.ts +0 -9
  60. package/dist/lib/utils/options/sources/decorator.js +0 -28
  61. package/dist/lib/utils/options/sources/decorator.js.map +0 -1
  62. package/dist/lib/utils/result.d.ts +0 -18
  63. package/dist/lib/utils/result.js +0 -53
  64. package/dist/lib/utils/result.js.map +0 -1
@@ -30,7 +30,13 @@ let Application = Application_1 = class Application extends component_1.Childabl
30
30
  this.plugins = this.addComponent('plugins', index_3.PluginHost);
31
31
  }
32
32
  bootstrap(options = {}) {
33
- this.options.setValues(options);
33
+ for (const [key, val] of Object.entries(options)) {
34
+ try {
35
+ this.options.setValue(key, val);
36
+ }
37
+ catch (_a) {
38
+ }
39
+ }
34
40
  this.options.read(new index_3.Logger());
35
41
  const logger = this.loggerType;
36
42
  if (typeof logger === 'function') {
@@ -43,11 +49,14 @@ let Application = Application_1 = class Application extends component_1.Childabl
43
49
  }
44
50
  this.plugins.load();
45
51
  this.options.reset();
46
- this.options.setValues(options).mapErr(errors => {
47
- for (const error of errors) {
52
+ for (const [key, val] of Object.entries(options)) {
53
+ try {
54
+ this.options.setValue(key, val);
55
+ }
56
+ catch (error) {
48
57
  this.logger.error(error.message);
49
58
  }
50
- });
59
+ }
51
60
  this.options.read(this.logger);
52
61
  return {
53
62
  hasErrors: this.logger.hasErrors(),
@@ -154,7 +163,7 @@ let Application = Application_1 = class Application extends component_1.Childabl
154
163
  ].join(typescript.sys.newLine);
155
164
  }
156
165
  };
157
- Application.VERSION = '0.17.3';
166
+ Application.VERSION = '0.17.7';
158
167
  __decorate([
159
168
  utils_1.BindOption('logger')
160
169
  ], Application.prototype, "loggerType", void 0);
@@ -1 +1 @@
1
- {"version":3,"file":"application.js","sourceRoot":"","sources":["../../src/lib/application.ts"],"names":[],"mappings":";;;;;;;;;AAQA,6BAA6B;AAC7B,yBAAyB;AACzB,yCAAyC;AAEzC,6CAA8C;AAC9C,gDAA6C;AAC7C,mDAA6C;AAC7C,0CAAmD;AACnD,yCAAuG;AACvG,yCAAgD;AAEhD,iDAK2B;AAC3B,mCAA8C;AAkB9C,IAAa,WAAW,mBAAxB,MAAa,WAAY,SAAQ,8BAGhC;IAqDG;QACI,KAAK,CAAC,mCAAuB,CAAC,CAAC;QAE/B,IAAI,CAAC,MAAM,GAAG,IAAI,qBAAa,EAAE,CAAC;QAClC,IAAI,CAAC,OAAO,GAAG,IAAI,eAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACxC,IAAI,CAAC,OAA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AI,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;oBAChC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,KAAK,CAAC,CAAC;gBACtC,CAAC,CAAC,CAAC;aACN;iBAAM,IAAI,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;gBACtC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aACpB;QACL,CAAC;QAED,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YACtB,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;QAClC,CAAC,CAAC,CAAC;QAEH,OAAO,KAAK,CAAC;IACjB,CAAC;IAKD,QAAQ;QACJ,OAAO;YACH,EAAE;YACF,WAAW,aAAW,CAAC,OAAO,EAAE;YAChC,oBAAoB,IAAI,CAAC,oBAAoB,EAAE,SAAS,IAAI,CAAC,iBAAiB,EAAE,EAAE;YAClF,EAAE;SACL,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;CACJ,CAAA;AApOU,mBAAO,GAAG,eAAe,CAAC;AApBjC;IADC,kBAAU,CAAC,QAAQ,CAAC;+CACU;AAG/B;IADC,kBAAU,CAAC,sBAAsB,CAAC;yDACJ;AAG/B;IADC,kBAAU,CAAC,SAAS,CAAC;4CACE;AAGxB;IADC,kBAAU,CAAC,YAAY,CAAC;+CACH;AAGtB;IADC,kBAAU,CAAC,SAAS,CAAC;gDACD;AAGrB;IADC,kBAAU,CAAC,UAAU,CAAC;4CACN;AA5CR,WAAW;IADvB,qBAAS,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;GACtC,WAAW,CAqRvB;AArRY,kCAAW","sourcesContent":["/**\n * The TypeDoc main module and namespace.\n *\n * The [[Application]] class holds the core logic of the cli application. All code related\n * to resolving reflections is stored in [[TypeDoc.Factories]], the actual data models can be found\n * in [[TypeDoc.Models]] and the final rendering is defined in [[TypeDoc.Output]].\n */\n\nimport * as Path from 'path';\nimport * as FS from 'fs';\nimport * as typescript from 'typescript';\n\nimport { Converter } from './converter/index';\nimport { Renderer } from './output/renderer';\nimport { Serializer } from './serialization';\nimport { ProjectReflection } from './models/index';\nimport { Logger, ConsoleLogger, CallbackLogger, PluginHost, writeFile, readFile } from './utils/index';\nimport { createMinimatch } from './utils/paths';\n\nimport {\n AbstractComponent,\n ChildableComponent,\n Component,\n DUMMY_APPLICATION_OWNER\n} from './utils/component';\nimport { Options, BindOption } from './utils';\nimport { TypeDocAndTSOptions } from './utils/options/declaration';\n\n/**\n * The default TypeDoc main application class.\n *\n * This class holds the two main components of TypeDoc, the [[Dispatcher]] and\n * the [[Renderer]]. When running TypeDoc, first the [[Dispatcher]] is invoked which\n * generates a [[ProjectReflection]] from the passed in source files. The\n * [[ProjectReflection]] is a hierarchical model representation of the TypeScript\n * project. Afterwards the model is passed to the [[Renderer]] which uses an instance\n * of [[BaseTheme]] to generate the final documentation.\n *\n * Both the [[Dispatcher]] and the [[Renderer]] are subclasses of the [[EventDispatcher]]\n * and emit a series of events while processing the project. Subscribe to these Events\n * to control the application flow or alter the output.\n */\n@Component({ name: 'application', internal: true })\nexport class Application extends ChildableComponent<\n Application,\n AbstractComponent<Application>\n> {\n /**\n * The converter used to create the declaration reflections.\n */\n converter: Converter;\n\n /**\n * The renderer used to generate the documentation output.\n */\n renderer: Renderer;\n\n /**\n * The serializer used to generate JSON output.\n */\n serializer: Serializer;\n\n /**\n * The logger that should be used to output messages.\n */\n logger: Logger;\n\n options: Options;\n\n plugins: PluginHost;\n\n @BindOption('logger')\n loggerType!: string | Function;\n\n @BindOption('ignoreCompilerErrors')\n ignoreCompilerErrors!: boolean;\n\n @BindOption('exclude')\n exclude!: Array<string>;\n\n @BindOption('inputFiles')\n inputFiles!: string[];\n\n @BindOption('options')\n optionsFile!: string;\n\n @BindOption('tsconfig')\n project!: string;\n\n /**\n * The version number of TypeDoc.\n */\n static VERSION = '{{ VERSION }}';\n\n /**\n * Create a new TypeDoc application instance.\n *\n * @param options An object containing the options that should be used.\n */\n constructor() {\n super(DUMMY_APPLICATION_OWNER);\n\n this.logger = new ConsoleLogger();\n this.options = new Options(this.logger);\n this.options.addDefaultDeclarations();\n this.serializer = new Serializer();\n this.converter = this.addComponent<Converter>('converter', Converter);\n this.renderer = this.addComponent<Renderer>('renderer', Renderer);\n this.plugins = this.addComponent('plugins', PluginHost);\n }\n\n /**\n * Initialize TypeDoc with the given options object.\n *\n * @param options The desired options to set.\n */\n bootstrap(options: Partial<TypeDocAndTSOptions> = {}): { hasErrors: boolean, inputFiles: string[] } {\n this.options.setValues(options); // Ignore result, plugins might declare an option\n this.options.read(new Logger());\n\n const logger = this.loggerType;\n if (typeof logger === 'function') {\n this.logger = new CallbackLogger(<any> logger);\n this.options.setLogger(this.logger);\n } else if (logger === 'none') {\n this.logger = new Logger();\n this.options.setLogger(this.logger);\n }\n\n this.plugins.load();\n\n this.options.reset();\n this.options.setValues(options).mapErr(errors => {\n for (const error of errors) {\n this.logger.error(error.message);\n }\n });\n this.options.read(this.logger);\n\n return {\n hasErrors: this.logger.hasErrors(),\n inputFiles: this.inputFiles\n };\n }\n\n /**\n * Return the application / root component instance.\n */\n get application(): Application {\n return this;\n }\n\n /**\n * Return the path to the TypeScript compiler.\n */\n public getTypeScriptPath(): string {\n return Path.dirname(require.resolve('typescript'));\n }\n\n public getTypeScriptVersion(): string {\n const tsPath = this.getTypeScriptPath();\n const json = JSON.parse(readFile(Path.join(tsPath, '..', 'package.json')));\n return json.version;\n }\n\n /**\n * Run the converter for the given set of files and return the generated reflections.\n *\n * @param src A list of source that should be compiled and converted.\n * @returns An instance of ProjectReflection on success, undefined otherwise.\n */\n public convert(src: string[]): ProjectReflection | undefined {\n this.logger.writeln(\n 'Using TypeScript %s from %s',\n this.getTypeScriptVersion(),\n this.getTypeScriptPath()\n );\n\n const result = this.converter.convert(src);\n if (result.errors && result.errors.length) {\n this.logger.diagnostics(result.errors);\n if (this.ignoreCompilerErrors) {\n this.logger.resetErrors();\n return result.project;\n } else {\n return;\n }\n } else {\n return result.project;\n }\n }\n\n /**\n * @param src A list of source files whose documentation should be generated.\n */\n public generateDocs(src: string[], out: string): boolean;\n\n /**\n * @param project The project the documentation should be generated for.\n */\n public generateDocs(project: ProjectReflection, out: string): boolean;\n\n /**\n * Run the documentation generator for the given set of files.\n *\n * @param out The path the documentation should be written to.\n * @returns TRUE if the documentation could be generated successfully, otherwise FALSE.\n */\n public generateDocs(input: ProjectReflection | string[], out: string): boolean {\n const project = input instanceof ProjectReflection ? input : this.convert(input);\n if (!project) {\n return false;\n }\n\n out = Path.resolve(out);\n this.renderer.render(project, out);\n if (this.logger.hasErrors()) {\n this.logger.error('Documentation could not be generated due to the errors above.');\n } else {\n this.logger.success('Documentation generated at %s', out);\n }\n\n return true;\n }\n\n /**\n * @param src A list of source that should be compiled and converted.\n */\n public generateJson(src: string[], out: string): boolean;\n\n /**\n * @param project The project that should be converted.\n */\n public generateJson(project: ProjectReflection, out: string): boolean;\n\n /**\n * Run the converter for the given set of files and write the reflections to a json file.\n *\n * @param out The path and file name of the target file.\n * @returns TRUE if the json file could be written successfully, otherwise FALSE.\n */\n public generateJson(input: ProjectReflection | string[], out: string): boolean {\n const project = input instanceof ProjectReflection ? input : this.convert(input);\n if (!project) {\n return false;\n }\n\n out = Path.resolve(out);\n const eventData = { outputDirectory: Path.dirname(out), outputFile: Path.basename(out) };\n const ser = this.serializer.projectToObject(project, { begin: eventData, end: eventData });\n writeFile(out, JSON.stringify(ser, null, '\\t'), false);\n this.logger.success('JSON written to %s', out);\n\n return true;\n }\n\n /**\n * Expand a list of input files.\n *\n * Searches for directories in the input files list and replaces them with a\n * listing of all TypeScript files within them. One may use the ```--exclude``` option\n * to filter out files with a pattern.\n *\n * @param inputFiles The list of files that should be expanded.\n * @returns The list of input files with expanded directories.\n */\n public expandInputFiles(inputFiles: string[] = []): string[] {\n const files: string[] = [];\n\n const exclude = this.exclude ? createMinimatch(this.exclude) : [];\n\n function isExcluded(fileName: string): boolean {\n return exclude.some(mm => mm.match(fileName));\n }\n\n const supportedFileRegex = this.options.getCompilerOptions().allowJs ? /\\.[tj]sx?$/ : /\\.tsx?$/;\n function add(file: string, entryPoint: boolean) {\n let stats: FS.Stats;\n try {\n stats = FS.statSync(file);\n } catch {\n // No permission or a symbolic link, do not resolve.\n return;\n }\n const fileIsDir = stats.isDirectory();\n if (fileIsDir && !file.endsWith('/')) {\n file = `${file}/`;\n }\n\n if ((!fileIsDir || !entryPoint) && isExcluded(file.replace(/\\\\/g, '/'))) {\n return;\n }\n\n if (fileIsDir) {\n FS.readdirSync(file).forEach(next => {\n add(Path.join(file, next), false);\n });\n } else if (supportedFileRegex.test(file)) {\n files.push(file);\n }\n }\n\n inputFiles.forEach(file => {\n add(Path.resolve(file), true);\n });\n\n return files;\n }\n\n /**\n * Print the version number.\n */\n toString() {\n return [\n '',\n `TypeDoc ${Application.VERSION}`,\n `Using TypeScript ${this.getTypeScriptVersion()} from ${this.getTypeScriptPath()}`,\n ''\n ].join(typescript.sys.newLine);\n }\n}\n"]}
1
+ {"version":3,"file":"application.js","sourceRoot":"","sources":["../../src/lib/application.ts"],"names":[],"mappings":";;;;;;;;;AAQA,6BAA6B;AAC7B,yBAAyB;AACzB,yCAAyC;AAEzC,6CAA8C;AAC9C,gDAA6C;AAC7C,mDAA6C;AAC7C,0CAAmD;AACnD,yCAAuG;AACvG,yCAAgD;AAEhD,iDAK2B;AAC3B,mCAA8C;AAkB9C,IAAa,WAAW,mBAAxB,MAAa,WAAY,SAAQ,8BAGhC;IAqDG;QACI,KAAK,CAAC,mCAAuB,CAAC,CAAC;QAE/B,IAAI,CAAC,MAAM,GAAG,IAAI,qBAAa,EAAE,CAAC;QAClC,IAAI,CAAC,OAAO,GAAG,IAAI,eAAO,CAAC,IAAI,CAAC,MAAM,CAAC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GrB;IADC,kBAAU,CAAC,UAAU,CAAC;4CACN;AA5CR,WAAW;IADvB,qBAAS,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;GACtC,WAAW,CA6RvB;AA7RY,kCAAW","sourcesContent":["/**\n * The TypeDoc main module and namespace.\n *\n * The [[Application]] class holds the core logic of the cli application. All code related\n * to resolving reflections is stored in [[TypeDoc.Factories]], the actual data models can be found\n * in [[TypeDoc.Models]] and the final rendering is defined in [[TypeDoc.Output]].\n */\n\nimport * as Path from 'path';\nimport * as FS from 'fs';\nimport * as typescript from 'typescript';\n\nimport { Converter } from './converter/index';\nimport { Renderer } from './output/renderer';\nimport { Serializer } from './serialization';\nimport { ProjectReflection } from './models/index';\nimport { Logger, ConsoleLogger, CallbackLogger, PluginHost, writeFile, readFile } from './utils/index';\nimport { createMinimatch } from './utils/paths';\n\nimport {\n AbstractComponent,\n ChildableComponent,\n Component,\n DUMMY_APPLICATION_OWNER\n} from './utils/component';\nimport { Options, BindOption } from './utils';\nimport { TypeDocAndTSOptions, TypeDocOptions } from './utils/options/declaration';\n\n/**\n * The default TypeDoc main application class.\n *\n * This class holds the two main components of TypeDoc, the [[Dispatcher]] and\n * the [[Renderer]]. When running TypeDoc, first the [[Dispatcher]] is invoked which\n * generates a [[ProjectReflection]] from the passed in source files. The\n * [[ProjectReflection]] is a hierarchical model representation of the TypeScript\n * project. Afterwards the model is passed to the [[Renderer]] which uses an instance\n * of [[BaseTheme]] to generate the final documentation.\n *\n * Both the [[Dispatcher]] and the [[Renderer]] are subclasses of the [[EventDispatcher]]\n * and emit a series of events while processing the project. Subscribe to these Events\n * to control the application flow or alter the output.\n */\n@Component({ name: 'application', internal: true })\nexport class Application extends ChildableComponent<\n Application,\n AbstractComponent<Application>\n> {\n /**\n * The converter used to create the declaration reflections.\n */\n converter: Converter;\n\n /**\n * The renderer used to generate the documentation output.\n */\n renderer: Renderer;\n\n /**\n * The serializer used to generate JSON output.\n */\n serializer: Serializer;\n\n /**\n * The logger that should be used to output messages.\n */\n logger: Logger;\n\n options: Options;\n\n plugins: PluginHost;\n\n @BindOption('logger')\n loggerType!: string | Function;\n\n @BindOption('ignoreCompilerErrors')\n ignoreCompilerErrors!: boolean;\n\n @BindOption('exclude')\n exclude!: Array<string>;\n\n @BindOption('inputFiles')\n inputFiles!: string[];\n\n @BindOption('options')\n optionsFile!: string;\n\n @BindOption('tsconfig')\n project!: string;\n\n /**\n * The version number of TypeDoc.\n */\n static VERSION = '{{ VERSION }}';\n\n /**\n * Create a new TypeDoc application instance.\n *\n * @param options An object containing the options that should be used.\n */\n constructor() {\n super(DUMMY_APPLICATION_OWNER);\n\n this.logger = new ConsoleLogger();\n this.options = new Options(this.logger);\n this.options.addDefaultDeclarations();\n this.serializer = new Serializer();\n this.converter = this.addComponent<Converter>('converter', Converter);\n this.renderer = this.addComponent<Renderer>('renderer', Renderer);\n this.plugins = this.addComponent('plugins', PluginHost);\n }\n\n /**\n * Initialize TypeDoc with the given options object.\n *\n * @param options The desired options to set.\n */\n bootstrap(options: Partial<TypeDocAndTSOptions> = {}): { hasErrors: boolean, inputFiles: string[] } {\n for (const [key, val] of Object.entries(options)) {\n try {\n this.options.setValue(key as keyof TypeDocOptions, val);\n } catch {\n // Ignore errors, plugins haven't been loaded yet and may declare an option.\n }\n }\n this.options.read(new Logger());\n\n const logger = this.loggerType;\n if (typeof logger === 'function') {\n this.logger = new CallbackLogger(<any> logger);\n this.options.setLogger(this.logger);\n } else if (logger === 'none') {\n this.logger = new Logger();\n this.options.setLogger(this.logger);\n }\n\n this.plugins.load();\n\n this.options.reset();\n for (const [key, val] of Object.entries(options)) {\n try {\n this.options.setValue(key as keyof TypeDocOptions, val);\n } catch (error) {\n this.logger.error(error.message);\n }\n }\n this.options.read(this.logger);\n\n return {\n hasErrors: this.logger.hasErrors(),\n inputFiles: this.inputFiles\n };\n }\n\n /**\n * Return the application / root component instance.\n */\n get application(): Application {\n return this;\n }\n\n /**\n * Return the path to the TypeScript compiler.\n */\n public getTypeScriptPath(): string {\n return Path.dirname(require.resolve('typescript'));\n }\n\n public getTypeScriptVersion(): string {\n const tsPath = this.getTypeScriptPath();\n const json = JSON.parse(readFile(Path.join(tsPath, '..', 'package.json')));\n return json.version;\n }\n\n /**\n * Run the converter for the given set of files and return the generated reflections.\n *\n * @param src A list of source that should be compiled and converted.\n * @returns An instance of ProjectReflection on success, undefined otherwise.\n */\n public convert(src: string[]): ProjectReflection | undefined {\n this.logger.writeln(\n 'Using TypeScript %s from %s',\n this.getTypeScriptVersion(),\n this.getTypeScriptPath()\n );\n\n const result = this.converter.convert(src);\n if (result.errors && result.errors.length) {\n this.logger.diagnostics(result.errors);\n if (this.ignoreCompilerErrors) {\n this.logger.resetErrors();\n return result.project;\n } else {\n return;\n }\n } else {\n return result.project;\n }\n }\n\n /**\n * @param src A list of source files whose documentation should be generated.\n */\n public generateDocs(src: string[], out: string): boolean;\n\n /**\n * @param project The project the documentation should be generated for.\n */\n public generateDocs(project: ProjectReflection, out: string): boolean;\n\n /**\n * Run the documentation generator for the given set of files.\n *\n * @param out The path the documentation should be written to.\n * @returns TRUE if the documentation could be generated successfully, otherwise FALSE.\n */\n public generateDocs(input: ProjectReflection | string[], out: string): boolean {\n const project = input instanceof ProjectReflection ? input : this.convert(input);\n if (!project) {\n return false;\n }\n\n out = Path.resolve(out);\n this.renderer.render(project, out);\n if (this.logger.hasErrors()) {\n this.logger.error('Documentation could not be generated due to the errors above.');\n } else {\n this.logger.success('Documentation generated at %s', out);\n }\n\n return true;\n }\n\n /**\n * @param src A list of source that should be compiled and converted.\n */\n public generateJson(src: string[], out: string): boolean;\n\n /**\n * @param project The project that should be converted.\n */\n public generateJson(project: ProjectReflection, out: string): boolean;\n\n /**\n * Run the converter for the given set of files and write the reflections to a json file.\n *\n * @param out The path and file name of the target file.\n * @returns TRUE if the json file could be written successfully, otherwise FALSE.\n */\n public generateJson(input: ProjectReflection | string[], out: string): boolean {\n const project = input instanceof ProjectReflection ? input : this.convert(input);\n if (!project) {\n return false;\n }\n\n out = Path.resolve(out);\n const eventData = { outputDirectory: Path.dirname(out), outputFile: Path.basename(out) };\n const ser = this.serializer.projectToObject(project, { begin: eventData, end: eventData });\n writeFile(out, JSON.stringify(ser, null, '\\t'), false);\n this.logger.success('JSON written to %s', out);\n\n return true;\n }\n\n /**\n * Expand a list of input files.\n *\n * Searches for directories in the input files list and replaces them with a\n * listing of all TypeScript files within them. One may use the ```--exclude``` option\n * to filter out files with a pattern.\n *\n * @param inputFiles The list of files that should be expanded.\n * @returns The list of input files with expanded directories.\n */\n public expandInputFiles(inputFiles: string[] = []): string[] {\n const files: string[] = [];\n\n const exclude = this.exclude ? createMinimatch(this.exclude) : [];\n\n function isExcluded(fileName: string): boolean {\n return exclude.some(mm => mm.match(fileName));\n }\n\n const supportedFileRegex = this.options.getCompilerOptions().allowJs ? /\\.[tj]sx?$/ : /\\.tsx?$/;\n function add(file: string, entryPoint: boolean) {\n let stats: FS.Stats;\n try {\n stats = FS.statSync(file);\n } catch {\n // No permission or a symbolic link, do not resolve.\n return;\n }\n const fileIsDir = stats.isDirectory();\n if (fileIsDir && !file.endsWith('/')) {\n file = `${file}/`;\n }\n\n if ((!fileIsDir || !entryPoint) && isExcluded(file.replace(/\\\\/g, '/'))) {\n return;\n }\n\n if (fileIsDir) {\n FS.readdirSync(file).forEach(next => {\n add(Path.join(file, next), false);\n });\n } else if (supportedFileRegex.test(file)) {\n files.push(file);\n }\n }\n\n inputFiles.forEach(file => {\n add(Path.resolve(file), true);\n });\n\n return files;\n }\n\n /**\n * Print the version number.\n */\n toString() {\n return [\n '',\n `TypeDoc ${Application.VERSION}`,\n `Using TypeScript ${this.getTypeScriptVersion()} from ${this.getTypeScriptPath()}`,\n ''\n ].join(typescript.sys.newLine);\n }\n}\n"]}
@@ -36,7 +36,7 @@ function createDeclaration(context, node, kind, name) {
36
36
  if (match) {
37
37
  name = `[Symbol.${match[1]}]`;
38
38
  }
39
- else if (kind & index_1.ReflectionKind.ClassMember && name === '__computed') {
39
+ else if (kind & (index_1.ReflectionKind.ClassMember | index_1.ReflectionKind.VariableOrProperty) && name === '__computed') {
40
40
  const declName = ts.getNameOfDeclaration(node);
41
41
  const symbol = declName && context.checker.getSymbolAtLocation(declName);
42
42
  if (symbol) {
@@ -135,6 +135,7 @@ function setupDeclaration(context, reflection, node) {
135
135
  reflection.setFlag(index_1.ReflectionFlag.Protected, !!(modifiers & ts.ModifierFlags.Protected));
136
136
  reflection.setFlag(index_1.ReflectionFlag.Public, !!(modifiers & ts.ModifierFlags.Public));
137
137
  reflection.setFlag(index_1.ReflectionFlag.Optional, !!(node['questionToken']));
138
+ reflection.setFlag(index_1.ReflectionFlag.Readonly, !!(modifiers & ts.ModifierFlags.Readonly));
138
139
  if (context.isInherit &&
139
140
  (node.parent === context.inheritParent || reflection.flags.isConstructorProperty)) {
140
141
  if (!reflection.inheritedFrom) {
@@ -1 +1 @@
1
- {"version":3,"file":"declaration.js","sourceRoot":"","sources":["../../../../src/lib/converter/factories/declaration.ts"],"names":[],"mappings":";;AAAA,iCAAiC;AAEjC,8CAAgH;AAEhH,4CAAyC;AACzC,6CAA6C;AAC7C,2CAAkD;AAKlD,MAAM,cAAc,GAAG;IACnB,sBAAc,CAAC,KAAK;IACpB,sBAAc,CAAC,SAAS;IACxB,sBAAc,CAAC,SAAS;CAC3B,CAAC;AAKF,MAAM,mBAAmB,GAAG;IACxB,EAAE,CAAC,UAAU,CAAC,gBAAgB;IAC9B,EAAE,CAAC,UAAU,CAAC,eAAe;IAC7B,EAAE,CAAC,UAAU,CAAC,oBAAoB;CACrC,CAAC;AAEF,MAAM,mBAAmB,GAAG,YAAY,CAAC;AAYzC,SAAgB,iBAAiB,CAAC,OAAgB,EAAE,IAAoB,EAAE,IAAoB,EAAE,IAAa;;IACzG,IAAI,CAAC,CAAC,OAAO,CAAC,KAAK,YAAY,2BAAmB,CAAC,EAAE;QACjD,MAAM,IAAI,KAAK,CAAC,g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AK,CAAC,CAAC;QACtF,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACzC,MAAM,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACzD,IAAI,UAAU,GAAG,eAAe,EAAE;YAC9B,UAAU,CAAC,IAAI,GAAG,IAAI,CAAC;SAC1B;KACJ;IAED,IACI,OAAO,CAAC,SAAS;QACjB,CAAC,OAAO,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC;QACnD,CAAC,IAAI,CAAC,MAAM,KAAK,OAAO,CAAC,aAAa,IAAI,UAAU,CAAC,KAAK,CAAC,qBAAqB,CAAC,EACnF;QACE,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE;YACxB,UAAU,CAAC,UAAU,GAAG,+BAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YACxE,UAAU,CAAC,gBAAgB,EAAE,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE;gBAChD,SAAS,CAAC,UAAU,GAAG,+BAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YAC3E,CAAC,CAAC,CAAC;SACN;QACD,OAAO;KACV;IAED,OAAO,UAAU,CAAC;AACtB,CAAC","sourcesContent":["import * as ts from 'typescript';\n\nimport { ContainerReflection, DeclarationReflection, ReflectionFlag, ReflectionKind } from '../../models/index';\nimport { Context } from '../context';\nimport { Converter } from '../converter';\nimport { getRawComment } from './comment.js';\nimport { createReferenceType } from './reference';\n\n/**\n * List of reflection kinds that never should be static.\n */\nconst nonStaticKinds = [\n ReflectionKind.Class,\n ReflectionKind.Interface,\n ReflectionKind.Namespace\n];\n\n/**\n * List of ts kinds leading to none static merge.\n */\nconst nonStaticMergeKinds = [\n ts.SyntaxKind.ClassDeclaration,\n ts.SyntaxKind.ClassExpression,\n ts.SyntaxKind.InterfaceDeclaration\n];\n\nconst builtInSymbolRegExp = /^__@(\\w+)$/;\n\n/**\n * Create a declaration reflection from the given TypeScript node.\n *\n * @param context The context object describing the current state the converter is in. The\n * scope of the context will be the parent of the generated reflection.\n * @param node The TypeScript node that should be converted to a reflection.\n * @param kind The desired kind of the reflection.\n * @param name The desired name of the reflection.\n * @returns The resulting reflection or undefined if an error is encountered.\n */\nexport function createDeclaration(context: Context, node: ts.Declaration, kind: ReflectionKind, name?: string): DeclarationReflection | undefined {\n if (!(context.scope instanceof ContainerReflection)) {\n throw new Error('Expected container reflection.');\n }\n const container = context.scope;\n\n // Ensure we have a name for the reflection\n if (!name) {\n if (node.localSymbol) {\n name = node.localSymbol.name;\n } else if (node.symbol) {\n name = node.symbol.name;\n } else {\n return;\n }\n\n // rename built-in symbols\n const match = builtInSymbolRegExp.exec(name);\n if (match) {\n name = `[Symbol.${match[1]}]`;\n } else if (kind & ReflectionKind.ClassMember && name === '__computed') {\n // rename computed properties\n const declName = ts.getNameOfDeclaration(node);\n const symbol = declName && context.checker.getSymbolAtLocation(declName);\n if (symbol) {\n name = context.checker.symbolToString(symbol, /*enclosingDeclaration*/ undefined, ts.SymbolFlags.ClassMember);\n } else if (declName) {\n name = declName.getText();\n }\n }\n }\n\n const modifiers = ts.getCombinedModifierFlags(node);\n\n let hasComment: boolean = Boolean(getRawComment(node));\n // Test whether the node is exported\n let isExported: boolean;\n if (kind === ReflectionKind.Module || kind === ReflectionKind.Global) {\n isExported = true;\n hasComment = true;\n } else if (container.kind === ReflectionKind.Global) {\n // In file mode, everything is exported.\n isExported = true;\n } else if (container.kindOf([ReflectionKind.Namespace, ReflectionKind.Module])) {\n const symbol = context.getSymbolAtLocation(node);\n if (!symbol) {\n isExported = false;\n } else {\n let parentNode = node.parent;\n while (![ts.SyntaxKind.SourceFile, ts.SyntaxKind.ModuleDeclaration].includes(parentNode.kind)) {\n parentNode = parentNode.parent;\n }\n const parentSymbol = context.getSymbolAtLocation(parentNode);\n if (!parentSymbol) {\n // This is a file with no imports/exports, so everything is\n // global and therefore exported.\n isExported = true;\n } else {\n isExported = !!parentSymbol.exports?.get(symbol.escapedName);\n }\n }\n } else {\n isExported = container.flags.isExported;\n }\n\n if (\n (!isExported && context.converter.excludeNotExported)\n ||\n (context.converter.excludeNotDocumented && kind !== ReflectionKind.EnumMember && !hasComment)\n ) {\n return;\n }\n\n // Test whether the node is private, when inheriting ignore private members\n const isPrivate = !!(modifiers & ts.ModifierFlags.Private);\n if (context.isInherit && isPrivate) {\n return;\n }\n\n // Test whether the node is static, when merging a module to a class make the node static\n let isConstructorProperty = false;\n let isStatic = false;\n if (!nonStaticKinds.includes(kind)) {\n isStatic = !!(modifiers & ts.ModifierFlags.Static);\n if (container.kind === ReflectionKind.Class) {\n if (node.parent && node.parent.kind === ts.SyntaxKind.Constructor) {\n isConstructorProperty = true;\n } else if (!node.parent || !nonStaticMergeKinds.includes(node.parent.kind)) {\n isStatic = true;\n }\n }\n }\n\n // Check if we already have a child of the same kind, with the same name and static flag\n let child: DeclarationReflection | undefined;\n const children = container.children = container.children || [];\n children.forEach((n: DeclarationReflection) => {\n if (n.name === name && n.flags.isStatic === isStatic && canMergeReflectionsByKind(n.kind, kind)) {\n child = n;\n }\n });\n\n if (!child) {\n // Child does not exist, create a new reflection\n child = new DeclarationReflection(name, kind, container);\n child.setFlag(ReflectionFlag.Static, isStatic);\n child.setFlag(ReflectionFlag.Private, isPrivate);\n child.setFlag(ReflectionFlag.ConstructorProperty, isConstructorProperty);\n child.setFlag(ReflectionFlag.Exported, isExported);\n child = setupDeclaration(context, child, node);\n\n if (child) {\n children.push(child);\n context.registerReflection(child, context.getSymbolAtLocation(node) ?? node.symbol);\n }\n } else {\n // Merge the existent reflection with the given node\n child = mergeDeclarations(context, child, node, kind);\n }\n\n // If we have a reflection, trigger the corresponding event\n if (child) {\n context.trigger(Converter.EVENT_CREATE_DECLARATION, child, node);\n }\n\n return child;\n}\n\n/**\n * Setup a newly created declaration reflection.\n *\n * @param context The context object describing the current state the converter is in.\n * @param reflection The newly created blank reflection.\n * @param node The TypeScript node whose properties should be applies to the given reflection.\n * @returns The reflection populated with the values of the given node.\n */\nfunction setupDeclaration(context: Context, reflection: DeclarationReflection, node: ts.Declaration) {\n const modifiers = ts.getCombinedModifierFlags(node);\n\n reflection.setFlag(ReflectionFlag.External, context.isExternal);\n reflection.setFlag(ReflectionFlag.Protected, !!(modifiers & ts.ModifierFlags.Protected));\n reflection.setFlag(ReflectionFlag.Public, !!(modifiers & ts.ModifierFlags.Public));\n reflection.setFlag(ReflectionFlag.Optional, !!(node['questionToken']));\n\n if (\n context.isInherit &&\n (node.parent === context.inheritParent || reflection.flags.isConstructorProperty)\n ) {\n if (!reflection.inheritedFrom) {\n reflection.inheritedFrom = createReferenceType(context, node.symbol, true);\n reflection.getAllSignatures().forEach((signature) => {\n signature.inheritedFrom = createReferenceType(context, node.symbol, true);\n });\n }\n }\n\n return reflection;\n}\n\n// we should not be merging type and value with the same name,\n// because TypeScript has different namespaces for these two categories\nfunction canMergeReflectionsByKind(kind1: ReflectionKind, kind2: ReflectionKind): boolean {\n if (\n (kind1 & ReflectionKind.SomeType && kind2 & ReflectionKind.SomeValue)\n ||\n (kind2 & ReflectionKind.SomeType && kind1 & ReflectionKind.SomeValue)\n ) {\n return false;\n }\n\n return true;\n}\n\n/**\n * Merge the properties of the given TypeScript node with the pre existent reflection.\n *\n * @param context The context object describing the current state the converter is in.\n * @param reflection The pre existent reflection.\n * @param node The TypeScript node whose properties should be merged with the given reflection.\n * @param kind The desired kind of the reflection.\n * @returns The reflection merged with the values of the given node or NULL if the merge is invalid.\n */\nfunction mergeDeclarations(context: Context, reflection: DeclarationReflection, node: ts.Node, kind: ReflectionKind) {\n if (reflection.kind !== kind) {\n const weights = [ReflectionKind.Namespace, ReflectionKind.Enum, ReflectionKind.Class];\n const kindWeight = weights.indexOf(kind);\n const childKindWeight = weights.indexOf(reflection.kind);\n if (kindWeight > childKindWeight) {\n reflection.kind = kind;\n }\n }\n\n if (\n context.isInherit &&\n (context.inherited || []).includes(reflection.name) &&\n (node.parent === context.inheritParent || reflection.flags.isConstructorProperty)\n ) {\n if (!reflection.overwrites) {\n reflection.overwrites = createReferenceType(context, node.symbol, true);\n reflection.getAllSignatures().forEach((signature) => {\n signature.overwrites = createReferenceType(context, node.symbol, true);\n });\n }\n return;\n }\n\n return reflection;\n}\n"]}
1
+ {"version":3,"file":"declaration.js","sourceRoot":"","sources":["../../../../src/lib/converter/factories/declaration.ts"],"names":[],"mappings":";;AAAA,iCAAiC;AAEjC,8CAAgH;AAEhH,4CAAyC;AACzC,6CAA6C;AAC7C,2CAAkD;AAKlD,MAAM,cAAc,GAAG;IACnB,sBAAc,CAAC,KAAK;IACpB,sBAAc,CAAC,SAAS;IACxB,sBAAc,CAAC,SAAS;CAC3B,CAAC;AAKF,MAAM,mBAAmB,GAAG;IACxB,EAAE,CAAC,UAAU,CAAC,gBAAgB;IAC9B,EAAE,CAAC,UAAU,CAAC,eAAe;IAC7B,EAAE,CAAC,UAAU,CAAC,oBAAoB;CACrC,CAAC;AAEF,MAAM,mBAAmB,GAAG,YAAY,CAAC;AAYzC,SAAgB,iBAAiB,CAAC,OAAgB,EAAE,IAAoB,EAAE,IAAoB,EAAE,IAAa;;IACzG,IAAI,CAAC,CAAC,OAAO,CAAC,KAAK,YAAY,2BAAmB,CAAC,EAAE;QACjD,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;KACrD;IACD,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK,CAAC;IAGhC,IAAI,CAAC,IAAI,EAAE;QACP,IAAI,IAAI,CAAC,WAAW,EAAE;YAClB,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;SAChC;aAAM,IAAI,IAAI,CAAC,MAAM,EAAE;YACpB,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;SAC3B;aAAM;YACH,OAAO;SACV;QAGD,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CAAC,CAAC;QACzD,IAAI,UAAU,GAAG,eAAe,EAAE;YAC9B,UAAU,CAAC,IAAI,GAAG,IAAI,CAAC;SAC1B;KACJ;IAED,IACI,OAAO,CAAC,SAAS;QACjB,CAAC,OAAO,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC;QACnD,CAAC,IAAI,CAAC,MAAM,KAAK,OAAO,CAAC,aAAa,IAAI,UAAU,CAAC,KAAK,CAAC,qBAAqB,CAAC,EACnF;QACE,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE;YACxB,UAAU,CAAC,UAAU,GAAG,+BAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YACxE,UAAU,CAAC,gBAAgB,EAAE,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE;gBAChD,SAAS,CAAC,UAAU,GAAG,+BAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YAC3E,CAAC,CAAC,CAAC;SACN;QACD,OAAO;KACV;IAED,OAAO,UAAU,CAAC;AACtB,CAAC","sourcesContent":["import * as ts from 'typescript';\n\nimport { ContainerReflection, DeclarationReflection, ReflectionFlag, ReflectionKind } from '../../models/index';\nimport { Context } from '../context';\nimport { Converter } from '../converter';\nimport { getRawComment } from './comment.js';\nimport { createReferenceType } from './reference';\n\n/**\n * List of reflection kinds that never should be static.\n */\nconst nonStaticKinds = [\n ReflectionKind.Class,\n ReflectionKind.Interface,\n ReflectionKind.Namespace\n];\n\n/**\n * List of ts kinds leading to none static merge.\n */\nconst nonStaticMergeKinds = [\n ts.SyntaxKind.ClassDeclaration,\n ts.SyntaxKind.ClassExpression,\n ts.SyntaxKind.InterfaceDeclaration\n];\n\nconst builtInSymbolRegExp = /^__@(\\w+)$/;\n\n/**\n * Create a declaration reflection from the given TypeScript node.\n *\n * @param context The context object describing the current state the converter is in. The\n * scope of the context will be the parent of the generated reflection.\n * @param node The TypeScript node that should be converted to a reflection.\n * @param kind The desired kind of the reflection.\n * @param name The desired name of the reflection.\n * @returns The resulting reflection or undefined if an error is encountered.\n */\nexport function createDeclaration(context: Context, node: ts.Declaration, kind: ReflectionKind, name?: string): DeclarationReflection | undefined {\n if (!(context.scope instanceof ContainerReflection)) {\n throw new Error('Expected container reflection.');\n }\n const container = context.scope;\n\n // Ensure we have a name for the reflection\n if (!name) {\n if (node.localSymbol) {\n name = node.localSymbol.name;\n } else if (node.symbol) {\n name = node.symbol.name;\n } else {\n return;\n }\n\n // rename built-in symbols\n const match = builtInSymbolRegExp.exec(name);\n if (match) {\n name = `[Symbol.${match[1]}]`;\n } else if (kind & (ReflectionKind.ClassMember | ReflectionKind.VariableOrProperty) && name === '__computed') {\n // rename computed properties\n const declName = ts.getNameOfDeclaration(node);\n const symbol = declName && context.checker.getSymbolAtLocation(declName);\n if (symbol) {\n name = context.checker.symbolToString(symbol, /*enclosingDeclaration*/ undefined, ts.SymbolFlags.ClassMember);\n } else if (declName) {\n name = declName.getText();\n }\n }\n }\n\n const modifiers = ts.getCombinedModifierFlags(node);\n\n let hasComment: boolean = Boolean(getRawComment(node));\n // Test whether the node is exported\n let isExported: boolean;\n if (kind === ReflectionKind.Module || kind === ReflectionKind.Global) {\n isExported = true;\n hasComment = true;\n } else if (container.kind === ReflectionKind.Global) {\n // In file mode, everything is exported.\n isExported = true;\n } else if (container.kindOf([ReflectionKind.Namespace, ReflectionKind.Module])) {\n const symbol = context.getSymbolAtLocation(node);\n if (!symbol) {\n isExported = false;\n } else {\n let parentNode = node.parent;\n while (![ts.SyntaxKind.SourceFile, ts.SyntaxKind.ModuleDeclaration].includes(parentNode.kind)) {\n parentNode = parentNode.parent;\n }\n const parentSymbol = context.getSymbolAtLocation(parentNode);\n if (!parentSymbol) {\n // This is a file with no imports/exports, so everything is\n // global and therefore exported.\n isExported = true;\n } else {\n isExported = !!parentSymbol.exports?.get(symbol.escapedName);\n }\n }\n } else {\n isExported = container.flags.isExported;\n }\n\n if (\n (!isExported && context.converter.excludeNotExported)\n ||\n (context.converter.excludeNotDocumented && kind !== ReflectionKind.EnumMember && !hasComment)\n ) {\n return;\n }\n\n // Test whether the node is private, when inheriting ignore private members\n const isPrivate = !!(modifiers & ts.ModifierFlags.Private);\n if (context.isInherit && isPrivate) {\n return;\n }\n\n // Test whether the node is static, when merging a module to a class make the node static\n let isConstructorProperty = false;\n let isStatic = false;\n if (!nonStaticKinds.includes(kind)) {\n isStatic = !!(modifiers & ts.ModifierFlags.Static);\n if (container.kind === ReflectionKind.Class) {\n if (node.parent && node.parent.kind === ts.SyntaxKind.Constructor) {\n isConstructorProperty = true;\n } else if (!node.parent || !nonStaticMergeKinds.includes(node.parent.kind)) {\n isStatic = true;\n }\n }\n }\n\n // Check if we already have a child of the same kind, with the same name and static flag\n let child: DeclarationReflection | undefined;\n const children = container.children = container.children || [];\n children.forEach((n: DeclarationReflection) => {\n if (n.name === name && n.flags.isStatic === isStatic && canMergeReflectionsByKind(n.kind, kind)) {\n child = n;\n }\n });\n\n if (!child) {\n // Child does not exist, create a new reflection\n child = new DeclarationReflection(name, kind, container);\n child.setFlag(ReflectionFlag.Static, isStatic);\n child.setFlag(ReflectionFlag.Private, isPrivate);\n child.setFlag(ReflectionFlag.ConstructorProperty, isConstructorProperty);\n child.setFlag(ReflectionFlag.Exported, isExported);\n child = setupDeclaration(context, child, node);\n\n if (child) {\n children.push(child);\n context.registerReflection(child, context.getSymbolAtLocation(node) ?? node.symbol);\n }\n } else {\n // Merge the existent reflection with the given node\n child = mergeDeclarations(context, child, node, kind);\n }\n\n // If we have a reflection, trigger the corresponding event\n if (child) {\n context.trigger(Converter.EVENT_CREATE_DECLARATION, child, node);\n }\n\n return child;\n}\n\n/**\n * Setup a newly created declaration reflection.\n *\n * @param context The context object describing the current state the converter is in.\n * @param reflection The newly created blank reflection.\n * @param node The TypeScript node whose properties should be applies to the given reflection.\n * @returns The reflection populated with the values of the given node.\n */\nfunction setupDeclaration(context: Context, reflection: DeclarationReflection, node: ts.Declaration) {\n const modifiers = ts.getCombinedModifierFlags(node);\n\n reflection.setFlag(ReflectionFlag.External, context.isExternal);\n reflection.setFlag(ReflectionFlag.Protected, !!(modifiers & ts.ModifierFlags.Protected));\n reflection.setFlag(ReflectionFlag.Public, !!(modifiers & ts.ModifierFlags.Public));\n reflection.setFlag(ReflectionFlag.Optional, !!(node['questionToken']));\n reflection.setFlag(ReflectionFlag.Readonly, !!(modifiers & ts.ModifierFlags.Readonly));\n\n if (\n context.isInherit &&\n (node.parent === context.inheritParent || reflection.flags.isConstructorProperty)\n ) {\n if (!reflection.inheritedFrom) {\n reflection.inheritedFrom = createReferenceType(context, node.symbol, true);\n reflection.getAllSignatures().forEach((signature) => {\n signature.inheritedFrom = createReferenceType(context, node.symbol, true);\n });\n }\n }\n\n return reflection;\n}\n\n// we should not be merging type and value with the same name,\n// because TypeScript has different namespaces for these two categories\nfunction canMergeReflectionsByKind(kind1: ReflectionKind, kind2: ReflectionKind): boolean {\n if (\n (kind1 & ReflectionKind.SomeType && kind2 & ReflectionKind.SomeValue)\n ||\n (kind2 & ReflectionKind.SomeType && kind1 & ReflectionKind.SomeValue)\n ) {\n return false;\n }\n\n return true;\n}\n\n/**\n * Merge the properties of the given TypeScript node with the pre existent reflection.\n *\n * @param context The context object describing the current state the converter is in.\n * @param reflection The pre existent reflection.\n * @param node The TypeScript node whose properties should be merged with the given reflection.\n * @param kind The desired kind of the reflection.\n * @returns The reflection merged with the values of the given node or NULL if the merge is invalid.\n */\nfunction mergeDeclarations(context: Context, reflection: DeclarationReflection, node: ts.Node, kind: ReflectionKind) {\n if (reflection.kind !== kind) {\n const weights = [ReflectionKind.Namespace, ReflectionKind.Enum, ReflectionKind.Class];\n const kindWeight = weights.indexOf(kind);\n const childKindWeight = weights.indexOf(reflection.kind);\n if (kindWeight > childKindWeight) {\n reflection.kind = kind;\n }\n }\n\n if (\n context.isInherit &&\n (context.inherited || []).includes(reflection.name) &&\n (node.parent === context.inheritParent || reflection.flags.isConstructorProperty)\n ) {\n if (!reflection.overwrites) {\n reflection.overwrites = createReferenceType(context, node.symbol, true);\n reflection.getAllSignatures().forEach((signature) => {\n signature.overwrites = createReferenceType(context, node.symbol, true);\n });\n }\n return;\n }\n\n return reflection;\n}\n"]}
@@ -20,7 +20,9 @@ let ModuleConverter = class ModuleConverter extends components_1.ConverterNodeCo
20
20
  convert(context, node) {
21
21
  const reflection = context.isInherit && context.inheritParent === node
22
22
  ? context.scope
23
- : index_2.createDeclaration(context, node, index_1.ReflectionKind.Namespace);
23
+ : index_2.createDeclaration(context, node, node.name.kind === ts.SyntaxKind.StringLiteral
24
+ ? index_1.ReflectionKind.Module
25
+ : index_1.ReflectionKind.Namespace);
24
26
  context.withScope(reflection, () => {
25
27
  if (node.body) {
26
28
  this.owner.convertNode(context, node.body);
@@ -1 +1 @@
1
- {"version":3,"file":"module.js","sourceRoot":"","sources":["../../../../src/lib/converter/nodes/module.ts"],"names":[],"mappings":";;;;;;;;AAAA,iCAAiC;AAEjC,8CAAuF;AACvF,8CAAuD;AAEvD,8CAAkE;AAGlE,IAAa,eAAe,GAA5B,MAAa,eAAgB,SAAQ,mCAA4C;IAAjF;;QAII,aAAQ,GAAoB;YACxB,EAAE,CAAC,UAAU,CAAC,iBAAiB;SAClC,CAAC;IAoBN,CAAC;IAXG,OAAO,CAAC,OAAgB,EAAE,IAA0B;QAChD,MAAM,UAAU,GAAG,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,aAAa,KAAK,IAAI;YAClE,CAAC,CAAyB,OAAO,CAAC,KAAK;YACvC,CAAC,CAAC,yBAAiB,CAAC,OAAO,EAAE,IAAI,EAAE,sBAAc,CAAC,SAAS,CAAC,CAAC;QACjE,OAAO,CAAC,SAAS,CAAC,UAAU,EAAE,GAAG,EAAE;YAC/B,IAAI,IAAI,CAAC,IAAI,EAAE;gBACX,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;aAC9C;QACL,CAAC,CAAC,CAAC;QACH,OAAO,UAAU,CAAC;IACtB,CAAC;CACJ,CAAA;AA1BY,eAAe;IAD3B,sBAAS,CAAC,EAAC,IAAI,EAAE,aAAa,EAAC,CAAC;GACpB,eAAe,CA0B3B;AA1BY,0CAAe","sourcesContent":["import * as ts from 'typescript';\n\nimport { Reflection, ReflectionKind, DeclarationReflection } from '../../models/index';\nimport { createDeclaration } from '../factories/index';\nimport { Context } from '../context';\nimport { Component, ConverterNodeComponent } from '../components';\n\n@Component({name: 'node:module'})\nexport class ModuleConverter extends ConverterNodeComponent<ts.ModuleDeclaration> {\n /**\n * List of supported TypeScript syntax kinds.\n */\n supports: ts.SyntaxKind[] = [\n ts.SyntaxKind.ModuleDeclaration\n ];\n\n /**\n * Analyze the given module node and create a suitable reflection.\n *\n * @param context The context object describing the current state the converter is in.\n * @param node The module node that should be analyzed.\n * @return The resulting reflection or NULL.\n */\n convert(context: Context, node: ts.ModuleDeclaration): Reflection | undefined {\n const reflection = context.isInherit && context.inheritParent === node\n ? <DeclarationReflection> context.scope\n : createDeclaration(context, node, ReflectionKind.Namespace);\n context.withScope(reflection, () => {\n if (node.body) {\n this.owner.convertNode(context, node.body);\n }\n });\n return reflection;\n }\n}\n"]}
1
+ {"version":3,"file":"module.js","sourceRoot":"","sources":["../../../../src/lib/converter/nodes/module.ts"],"names":[],"mappings":";;;;;;;;AAAA,iCAAiC;AAEjC,8CAAuF;AACvF,8CAAuD;AAEvD,8CAAkE;AAGlE,IAAa,eAAe,GAA5B,MAAa,eAAgB,SAAQ,mCAA4C;IAAjF;;QAII,aAAQ,GAAoB;YACxB,EAAE,CAAC,UAAU,CAAC,iBAAiB;SAClC,CAAC;IAsBN,CAAC;IAbG,OAAO,CAAC,OAAgB,EAAE,IAA0B;QAChD,MAAM,UAAU,GAAG,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,aAAa,KAAK,IAAI;YAClE,CAAC,CAAyB,OAAO,CAAC,KAAK;YACvC,CAAC,CAAC,yBAAiB,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,EAAE,CAAC,UAAU,CAAC,aAAa;gBAC7E,CAAC,CAAC,sBAAc,CAAC,MAAM;gBACvB,CAAC,CAAC,sBAAc,CAAC,SAAS,CAAC,CAAC;QACpC,OAAO,CAAC,SAAS,CAAC,UAAU,EAAE,GAAG,EAAE;YAC/B,IAAI,IAAI,CAAC,IAAI,EAAE;gBACX,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;aAC9C;QACL,CAAC,CAAC,CAAC;QACH,OAAO,UAAU,CAAC;IACtB,CAAC;CACJ,CAAA;AA5BY,eAAe;IAD3B,sBAAS,CAAC,EAAC,IAAI,EAAE,aAAa,EAAC,CAAC;GACpB,eAAe,CA4B3B;AA5BY,0CAAe","sourcesContent":["import * as ts from 'typescript';\n\nimport { Reflection, ReflectionKind, DeclarationReflection } from '../../models/index';\nimport { createDeclaration } from '../factories/index';\nimport { Context } from '../context';\nimport { Component, ConverterNodeComponent } from '../components';\n\n@Component({name: 'node:module'})\nexport class ModuleConverter extends ConverterNodeComponent<ts.ModuleDeclaration> {\n /**\n * List of supported TypeScript syntax kinds.\n */\n supports: ts.SyntaxKind[] = [\n ts.SyntaxKind.ModuleDeclaration\n ];\n\n /**\n * Analyze the given module node and create a suitable reflection.\n *\n * @param context The context object describing the current state the converter is in.\n * @param node The module node that should be analyzed.\n * @return The resulting reflection or NULL.\n */\n convert(context: Context, node: ts.ModuleDeclaration): Reflection | undefined {\n const reflection = context.isInherit && context.inheritParent === node\n ? <DeclarationReflection> context.scope\n : createDeclaration(context, node, node.name.kind === ts.SyntaxKind.StringLiteral\n ? ReflectionKind.Module\n : ReflectionKind.Namespace);\n context.withScope(reflection, () => {\n if (node.body) {\n this.owner.convertNode(context, node.body);\n }\n });\n return reflection;\n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pF;aACJ;YAED,IAAI,QAAS,CAAC,IAAI,KAAK,IAAI,IAAI,QAAS,CAAC,IAAI,KAAK,sBAAc,CAAC,KAAK,EAAE;gBACpE,IAAI,gBAAgB,EAAE;oBAClB,QAAS,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;iBAC/D;qBAAM;oBACH,QAAS,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,EAAG,IAA+B,CAAC,IAAI,EAAE,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC;iBAC5H;aACJ;QACL,CAAC,CAAC,CAAC;QAEH,OAAO,QAAQ,CAAC;IACpB,CAAC;CACJ,CAAA;AA3GY,iBAAiB;IAD7B,sBAAS,CAAC,EAAC,IAAI,EAAE,eAAe,EAAC,CAAC;GACtB,iBAAiB,CA2G7B;AA3GY,8CAAiB","sourcesContent":["import * as ts from 'typescript';\nimport * as _ts from '../../ts-internal';\n\nimport { Reflection, ReflectionFlag, ReflectionKind, IntrinsicType } from '../../models/index';\nimport { createDeclaration, createComment } from '../factories/index';\nimport { Context } from '../context';\nimport { Component, ConverterNodeComponent } from '../components';\nimport { convertDefaultValue } from '../index';\n\ntype VarNodeType = ts.PropertySignature\n | ts.PropertyDeclaration\n | ts.PropertyAssignment\n | ts.ShorthandPropertyAssignment\n | ts.VariableDeclaration\n | ts.ImportEqualsDeclaration\n | ts.BindingElement;\n\n@Component({name: 'node:variable'})\nexport class VariableConverter extends ConverterNodeComponent<ts.VariableDeclaration> {\n /**\n * List of supported TypeScript syntax kinds.\n */\n supports: ts.SyntaxKind[] = [\n ts.SyntaxKind.PropertySignature,\n ts.SyntaxKind.PropertyDeclaration,\n ts.SyntaxKind.PropertyAssignment,\n ts.SyntaxKind.ShorthandPropertyAssignment,\n ts.SyntaxKind.VariableDeclaration,\n ts.SyntaxKind.ImportEqualsDeclaration,\n ts.SyntaxKind.BindingElement\n ];\n\n isSimpleObjectLiteral(objectLiteral: ts.ObjectLiteralExpression): boolean {\n if (!objectLiteral.properties) {\n return true;\n }\n return objectLiteral.properties.length === 0;\n }\n\n /**\n * Analyze the given variable declaration node and create a suitable reflection.\n * TODO: the type of `node` is incorrect, it should be a union of ts.PropertySignature | ts.PropertyDeclaration | ...\n *\n * @param context The context object describing the current state the converter is in.\n * @param node The variable declaration node that should be analyzed.\n * @return The resulting reflection or NULL.\n */\n convert(context: Context, node: VarNodeType): Reflection | undefined {\n const comment = createComment(node);\n if (comment && comment.hasTag('resolve')) {\n const resolveType = context.getTypeAtLocation(node);\n if (resolveType && resolveType.symbol) {\n const resolved = this.owner.convertNode(context, resolveType.symbol.declarations[0]);\n if (resolved && node.symbol) {\n resolved.name = node.symbol.name;\n }\n return resolved;\n }\n }\n\n let name: string | undefined;\n let isBindingPattern: boolean;\n if (ts.isArrayBindingPattern(node.name) || ts.isObjectBindingPattern(node.name)) {\n if (ts.isBindingElement(node) && node.propertyName) {\n name = node.propertyName.getText();\n isBindingPattern = true;\n } else {\n return;\n }\n }\n\n const scope = context.scope;\n const kind = scope.kind & ReflectionKind.ClassOrInterface ? ReflectionKind.Property : ReflectionKind.Variable;\n const variable = createDeclaration(context, node, kind, name);\n\n // The variable can be null if `excludeNotExported` is `true`\n if (variable) {\n switch (kind) {\n case ReflectionKind.Variable:\n if (node.parent.flags & ts.NodeFlags.Const) {\n variable.setFlag(ReflectionFlag.Const, true);\n } else if (node.parent.flags & ts.NodeFlags.Let) {\n variable.setFlag(ReflectionFlag.Let, true);\n }\n break;\n case ReflectionKind.Property:\n if (node.modifiers\n && node.modifiers.some( m => m.kind === ts.SyntaxKind.AbstractKeyword )) {\n variable.setFlag(ReflectionFlag.Abstract, true);\n }\n break;\n }\n }\n\n context.withScope(variable, () => {\n if ('initializer' in node && node.initializer) {\n switch (node.initializer.kind) {\n case ts.SyntaxKind.ArrowFunction:\n case ts.SyntaxKind.FunctionExpression:\n variable!.kind = scope.kind & ReflectionKind.ClassOrInterface ? ReflectionKind.Method : ReflectionKind.Function;\n this.owner.convertNode(context, node.initializer);\n break;\n case ts.SyntaxKind.ObjectLiteralExpression:\n if (!this.isSimpleObjectLiteral(<ts.ObjectLiteralExpression> node.initializer)) {\n variable!.kind = ReflectionKind.ObjectLiteral;\n variable!.type = new IntrinsicType('object');\n this.owner.convertNode(context, node.initializer);\n }\n break;\n default:\n variable!.defaultValue = convertDefaultValue(node as ts.VariableDeclaration);\n }\n }\n\n if (variable!.kind === kind || variable!.kind === ReflectionKind.Event) {\n if (isBindingPattern) {\n variable!.type = this.owner.convertType(context, node.name);\n } else {\n variable!.type = this.owner.convertType(context, (node as ts.VariableDeclaration).type, context.getTypeAtLocation(node));\n }\n }\n });\n\n return variable;\n }\n}\n"]}
1
+ {"version":3,"file":"variable.js","sourceRoot":"","sources":["../../../../src/lib/converter/nodes/variable.ts"],"names":[],"mappings":";;;;;;;;AAAA,iCAAiC;AAGjC,8CAA+F;AAC/F,8CAAsE;AAEtE,8CAAkE;AAClE,oCAA+C;AAW/C,IAAa,iBAAiB,GAA9B,MAAa,iBAAkB,SAAQ,mCAA8C;IAArF;;QAII,aAAQ,GAAoB;YACxB,EAAE,CAAC,UAAU,CAAC,iBAAiB;YAC/B,EAAE,CAAC,UAAU,CAAC,mBAAmB;YACjC,EAAE,CAAC,UAAU,CAAC,kBAAkB;YAChC,EAAE,CAAC,UAAU,CAAC,2BAA2B;YACzC,EAAE,CAAC,UAAU,CAAC,mBAAmB;YACjC,EAAE,CAAC,UAAU,CAAC,uBAAuB;YACrC,EAAE,CAAC,UAAU,CAAC,cAAc;SAC/B,CAAC;IA+FN,CAAC;IA7FG,qBAAqB,CAAC,aAAyC;QAC3D,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE;YAC3B,OAAO,IAAI,CAAC;SACf;QACD,OAAO,aAAa,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,CAAC;IACjD,CAAC;IA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OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;wBAClD,MAAM;oBACV,KAAK,EAAE,CAAC,UAAU,CAAC,uBAAuB;wBACtC,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAA8B,IAAI,CAAC,WAAW,CAAC,EAAE;4BAC5E,QAAS,CAAC,IAAI,GAAG,sBAAc,CAAC,aAAa,CAAC;4BAC9C,QAAS,CAAC,IAAI,GAAG,IAAI,qBAAa,CAAC,QAAQ,CAAC,CAAC;4BAC7C,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;yBACrD;wBACD,MAAM;oBACV;wBACI,QAAS,CAAC,YAAY,GAAG,2BAAmB,CAAC,IAA8B,CAAC,CAAC;iBACpF;aACJ;YAED,IAAI,QAAS,CAAC,IAAI,KAAK,IAAI,IAAI,QAAS,CAAC,IAAI,KAAK,sBAAc,CAAC,KAAK,EAAE;gBACpE,IAAI,gBAAgB,EAAE;oBAClB,QAAS,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;iBAC/D;qBAAM;oBACH,QAAS,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,EAAG,IAA+B,CAAC,IAAI,EAAE,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC;iBAC5H;aACJ;QACL,CAAC,CAAC,CAAC;QAEH,OAAO,QAAQ,CAAC;IACpB,CAAC;CACJ,CAAA;AA3GY,iBAAiB;IAD7B,sBAAS,CAAC,EAAC,IAAI,EAAE,eAAe,EAAC,CAAC;GACtB,iBAAiB,CA2G7B;AA3GY,8CAAiB","sourcesContent":["import * as ts from 'typescript';\nimport * as _ts from '../../ts-internal';\n\nimport { Reflection, ReflectionFlag, ReflectionKind, IntrinsicType } from '../../models/index';\nimport { createDeclaration, createComment } from '../factories/index';\nimport { Context } from '../context';\nimport { Component, ConverterNodeComponent } from '../components';\nimport { convertDefaultValue } from '../index';\n\ntype VarNodeType = ts.PropertySignature\n | ts.PropertyDeclaration\n | ts.PropertyAssignment\n | ts.ShorthandPropertyAssignment\n | ts.VariableDeclaration\n | ts.ImportEqualsDeclaration\n | ts.BindingElement;\n\n@Component({name: 'node:variable'})\nexport class VariableConverter extends ConverterNodeComponent<ts.VariableDeclaration> {\n /**\n * List of supported TypeScript syntax kinds.\n */\n supports: ts.SyntaxKind[] = [\n ts.SyntaxKind.PropertySignature,\n ts.SyntaxKind.PropertyDeclaration,\n ts.SyntaxKind.PropertyAssignment,\n ts.SyntaxKind.ShorthandPropertyAssignment,\n ts.SyntaxKind.VariableDeclaration,\n ts.SyntaxKind.ImportEqualsDeclaration,\n ts.SyntaxKind.BindingElement\n ];\n\n isSimpleObjectLiteral(objectLiteral: ts.ObjectLiteralExpression): boolean {\n if (!objectLiteral.properties) {\n return true;\n }\n return objectLiteral.properties.length === 0;\n }\n\n /**\n * Analyze the given variable declaration node and create a suitable reflection.\n * TODO: the type of `node` is incorrect, it should be a union of ts.PropertySignature | ts.PropertyDeclaration | ...\n *\n * @param context The context object describing the current state the converter is in.\n * @param node The variable declaration node that should be analyzed.\n * @return The resulting reflection or NULL.\n */\n convert(context: Context, node: VarNodeType): Reflection | undefined {\n const comment = createComment(node);\n if (comment && comment.hasTag('resolve')) {\n const resolveType = context.getTypeAtLocation(node);\n if (resolveType && resolveType.symbol) {\n const resolved = this.owner.convertNode(context, resolveType.symbol.declarations[0]);\n if (resolved && node.symbol) {\n resolved.name = node.symbol.name;\n }\n return resolved;\n }\n }\n\n let name: string | undefined;\n let isBindingPattern: boolean;\n if (ts.isArrayBindingPattern(node.name) || ts.isObjectBindingPattern(node.name)) {\n if (ts.isBindingElement(node) && node.propertyName) {\n name = node.propertyName.getText();\n isBindingPattern = true;\n } else {\n return;\n }\n }\n\n const scope = context.scope;\n const kind = scope.kind & ReflectionKind.ClassOrInterface ? ReflectionKind.Property : ReflectionKind.Variable;\n const variable = createDeclaration(context, node, kind, name);\n\n // The variable can be null if `excludeNotExported` is `true`\n if (variable) {\n switch (kind) {\n case ReflectionKind.Variable:\n if (node.parent.flags & ts.NodeFlags.Const) {\n variable.setFlag(ReflectionFlag.Const, true);\n } else if (node.parent.flags & ts.NodeFlags.Let) {\n variable.setFlag(ReflectionFlag.Let, true);\n }\n break;\n case ReflectionKind.Property:\n if (node.modifiers\n && node.modifiers.some( m => m.kind === ts.SyntaxKind.AbstractKeyword)) {\n variable.setFlag(ReflectionFlag.Abstract, true);\n }\n break;\n }\n }\n\n context.withScope(variable, () => {\n if ('initializer' in node && node.initializer) {\n switch (node.initializer.kind) {\n case ts.SyntaxKind.ArrowFunction:\n case ts.SyntaxKind.FunctionExpression:\n variable!.kind = scope.kind & ReflectionKind.ClassOrInterface ? ReflectionKind.Method : ReflectionKind.Function;\n this.owner.convertNode(context, node.initializer);\n break;\n case ts.SyntaxKind.ObjectLiteralExpression:\n if (!this.isSimpleObjectLiteral(<ts.ObjectLiteralExpression> node.initializer)) {\n variable!.kind = ReflectionKind.ObjectLiteral;\n variable!.type = new IntrinsicType('object');\n this.owner.convertNode(context, node.initializer);\n }\n break;\n default:\n variable!.defaultValue = convertDefaultValue(node as ts.VariableDeclaration);\n }\n }\n\n if (variable!.kind === kind || variable!.kind === ReflectionKind.Event) {\n if (isBindingPattern) {\n variable!.type = this.owner.convertType(context, node.name);\n } else {\n variable!.type = this.owner.convertType(context, (node as ts.VariableDeclaration).type, context.getTypeAtLocation(node));\n }\n }\n });\n\n return variable;\n }\n}\n"]}
@@ -10,6 +10,7 @@ const index_1 = require("../../models/reflections/index");
10
10
  const index_2 = require("../../models/types/index");
11
11
  const components_1 = require("../components");
12
12
  const converter_1 = require("../converter");
13
+ const comment_1 = require("../../models/comments/comment");
13
14
  let ImplementsPlugin = class ImplementsPlugin extends components_1.ConverterComponent {
14
15
  initialize() {
15
16
  this.listenTo(this.owner, converter_1.Converter.EVENT_RESOLVE, this.onResolve, -10);
@@ -62,8 +63,13 @@ let ImplementsPlugin = class ImplementsPlugin extends components_1.ConverterComp
62
63
  if (target instanceof index_1.SignatureReflection && target.parameters &&
63
64
  source instanceof index_1.SignatureReflection && source.parameters) {
64
65
  for (let index = 0, count = target.parameters.length; index < count; index++) {
65
- if (target.parameters[index].comment) {
66
- target.parameters[index].comment.copyFrom(source.parameters[index].comment);
66
+ const sourceParameter = source.parameters[index];
67
+ if (sourceParameter && sourceParameter.comment) {
68
+ const targetParameter = target.parameters[index];
69
+ if (!targetParameter.comment) {
70
+ targetParameter.comment = new comment_1.Comment();
71
+ targetParameter.comment.copyFrom(sourceParameter.comment);
72
+ }
67
73
  }
68
74
  }
69
75
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ImplementsPlugin.js","sourceRoot":"","sources":["../../../../src/lib/converter/plugins/ImplementsPlugin.ts"],"names":[],"mappings":";;;;;;;;AAAA,0DAAwH;AACxH,oDAA+D;AAC/D,8CAA8D;AAC9D,4CAAyC;AAQzC,IAAa,gBAAgB,GAA7B,MAAa,gBAAiB,SAAQ,+BAAkB;IAIpD,UAAU;QACN,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,qBAAS,CAAC,aAAa,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,EAAE,CAAC,CAAC;IAC5E,CAAC;IASO,YAAY,CAAC,OAAgB,EAAE,eAAsC,EAAE,mBAA0C;QACrH,IAAI,CAAC,mBAAmB,CAAC,QAAQ,EAAE;YAC/B,OAAO;SACV;QAED,mBAAmB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,eAAsC,EAAE,EAAE;YAC5E,IAAI,CAAC,CAAC,eAAe,YAAY,6BAAqB,CAAC,EAAE;gBACrD,OAAO;aACV;YAED,IAAI,WAA8C,CAAC;YAEnD,IAAI,CAAC,eAAe,CAAC,QAAQ,EAAE;gBAC3B,OAAO;aACV;YAED,KAAK,IAAI,KAAK,GAAG,CAA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CAAC,UAAU,CAAC,MAAM,CAAC,sBAAc,CAAC,SAAS,CAAC,EAAE;oBACrE,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,UAAU,EAA0B,IAAI,CAAC,UAAU,CAAC,CAAC;iBACnF;YACL,CAAC,CAAC,CAAC;SACN;IACL,CAAC;CACJ,CAAA;AA1GY,gBAAgB;IAD5B,sBAAS,CAAC,EAAC,IAAI,EAAE,YAAY,EAAC,CAAC;GACnB,gBAAgB,CA0G5B;AA1GY,4CAAgB","sourcesContent":["import { Reflection, ReflectionKind, DeclarationReflection, SignatureReflection } from '../../models/reflections/index';\nimport { Type, ReferenceType } from '../../models/types/index';\nimport { Component, ConverterComponent } from '../components';\nimport { Converter } from '../converter';\nimport { Context } from '../context';\n\n/**\n * A plugin that detects interface implementations of functions and\n * properties on classes and links them.\n */\n@Component({name: 'implements'})\nexport class ImplementsPlugin extends ConverterComponent {\n /**\n * Create a new ImplementsPlugin instance.\n */\n initialize() {\n this.listenTo(this.owner, Converter.EVENT_RESOLVE, this.onResolve, -10);\n }\n\n /**\n * Mark all members of the given class to be the implementation of the matching interface member.\n *\n * @param context The context object describing the current state the converter is in.\n * @param classReflection The reflection of the classReflection class.\n * @param interfaceReflection The reflection of the interfaceReflection interface.\n */\n private analyzeClass(context: Context, classReflection: DeclarationReflection, interfaceReflection: DeclarationReflection) {\n if (!interfaceReflection.children) {\n return;\n }\n\n interfaceReflection.children.forEach((interfaceMember: DeclarationReflection) => {\n if (!(interfaceMember instanceof DeclarationReflection)) {\n return;\n }\n\n let classMember: DeclarationReflection | undefined;\n\n if (!classReflection.children) {\n return;\n }\n\n for (let index = 0, count = classReflection.children.length; index < count; index++) {\n const child = classReflection.children[index];\n if (child.name !== interfaceMember.name) {\n continue;\n }\n if (child.flags.isStatic !== interfaceMember.flags.isStatic) {\n continue;\n }\n\n classMember = child;\n break;\n }\n\n if (!classMember) {\n return;\n }\n\n const interfaceMemberName = interfaceReflection.name + '.' + interfaceMember.name;\n classMember.implementationOf = new ReferenceType(interfaceMemberName, ReferenceType.SYMBOL_FQN_RESOLVED, interfaceMember);\n this.copyComment(classMember, interfaceMember);\n\n if (interfaceMember.kindOf(ReflectionKind.FunctionOrMethod) && interfaceMember.signatures && classMember.signatures) {\n interfaceMember.signatures.forEach((interfaceSignature: SignatureReflection) => {\n const interfaceParameters = interfaceSignature.getParameterTypes();\n (classMember!.signatures || []).forEach((classSignature: SignatureReflection) => {\n if (Type.isTypeListEqual(interfaceParameters, classSignature.getParameterTypes())) {\n classSignature.implementationOf = new ReferenceType(interfaceMemberName, ReferenceType.SYMBOL_FQN_RESOLVED, interfaceSignature);\n this.copyComment(classSignature, interfaceSignature);\n }\n });\n });\n }\n });\n }\n\n /**\n * Copy the comment of the source reflection to the target reflection.\n *\n * @param target\n * @param source\n */\n private copyComment(target: Reflection, source: Reflection) {\n if (target.comment && source.comment && target.comment.hasTag('inheritdoc')) {\n target.comment.copyFrom(source.comment);\n\n if (target instanceof SignatureReflection && target.parameters &&\n source instanceof SignatureReflection && source.parameters) {\n for (let index = 0, count = target.parameters.length; index < count; index++) {\n if (target.parameters[index].comment) {\n target.parameters[index].comment!.copyFrom(source.parameters[index].comment!);\n }\n }\n }\n }\n }\n\n /**\n * Triggered when the converter resolves a reflection.\n *\n * @param context The context object describing the current state the converter is in.\n * @param reflection The reflection that is currently resolved.\n */\n private onResolve(context: Context, reflection: DeclarationReflection) {\n if (reflection.kindOf(ReflectionKind.Class) && reflection.implementedTypes) {\n reflection.implementedTypes.forEach((type: Type) => {\n if (!(type instanceof ReferenceType)) {\n return;\n }\n\n if (type.reflection && type.reflection.kindOf(ReflectionKind.Interface)) {\n this.analyzeClass(context, reflection, <DeclarationReflection> type.reflection);\n }\n });\n }\n }\n}\n"]}
1
+ {"version":3,"file":"ImplementsPlugin.js","sourceRoot":"","sources":["../../../../src/lib/converter/plugins/ImplementsPlugin.ts"],"names":[],"mappings":";;;;;;;;AAAA,0DAAwH;AACxH,oDAA+D;AAC/D,8C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C,UAAU,CAAC,MAAM,EAAE,KAAK,GAAG,KAAK,EAAE,KAAK,EAAE,EAAE;oBAC1E,MAAM,eAAe,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;oBACjD,IAAI,eAAe,IAAI,eAAe,CAAC,OAAO,EAAE;wBAC5C,MAAM,eAAe,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;wBACjD,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE;4BAC1B,eAAe,CAAC,OAAO,GAAG,IAAI,iBAAO,EAAE,CAAC;4BACxC,eAAe,CAAC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;yBAC7D;qBACJ;iBACJ;aACJ;SACJ;IACL,CAAC;IAQO,SAAS,CAAC,OAAgB,EAAE,UAAiC;QACjE,IAAI,UAAU,CAAC,MAAM,CAAC,sBAAc,CAAC,KAAK,CAAC,IAAI,UAAU,CAAC,gBAAgB,EAAE;YACxE,UAAU,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,IAAU,EAAE,EAAE;gBAC/C,IAAI,CAAC,CAAC,IAAI,YAAY,qBAAa,CAAC,EAAE;oBAClC,OAAO;iBACV;gBAED,IAAI,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,sBAAc,CAAC,SAAS,CAAC,EAAE;oBACrE,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,UAAU,EAA0B,IAAI,CAAC,UAAU,CAAC,CAAC;iBACnF;YACL,CAAC,CAAC,CAAC;SACN;IACL,CAAC;CACJ,CAAA;AA/GY,gBAAgB;IAD5B,sBAAS,CAAC,EAAC,IAAI,EAAE,YAAY,EAAC,CAAC;GACnB,gBAAgB,CA+G5B;AA/GY,4CAAgB","sourcesContent":["import { Reflection, ReflectionKind, DeclarationReflection, SignatureReflection } from '../../models/reflections/index';\nimport { Type, ReferenceType } from '../../models/types/index';\nimport { Component, ConverterComponent } from '../components';\nimport { Converter } from '../converter';\nimport { Context } from '../context';\nimport { Comment } from '../../models/comments/comment';\n\n/**\n * A plugin that detects interface implementations of functions and\n * properties on classes and links them.\n */\n@Component({name: 'implements'})\nexport class ImplementsPlugin extends ConverterComponent {\n /**\n * Create a new ImplementsPlugin instance.\n */\n initialize() {\n this.listenTo(this.owner, Converter.EVENT_RESOLVE, this.onResolve, -10);\n }\n\n /**\n * Mark all members of the given class to be the implementation of the matching interface member.\n *\n * @param context The context object describing the current state the converter is in.\n * @param classReflection The reflection of the classReflection class.\n * @param interfaceReflection The reflection of the interfaceReflection interface.\n */\n private analyzeClass(context: Context, classReflection: DeclarationReflection, interfaceReflection: DeclarationReflection) {\n if (!interfaceReflection.children) {\n return;\n }\n\n interfaceReflection.children.forEach((interfaceMember: DeclarationReflection) => {\n if (!(interfaceMember instanceof DeclarationReflection)) {\n return;\n }\n\n let classMember: DeclarationReflection | undefined;\n\n if (!classReflection.children) {\n return;\n }\n\n for (let index = 0, count = classReflection.children.length; index < count; index++) {\n const child = classReflection.children[index];\n if (child.name !== interfaceMember.name) {\n continue;\n }\n if (child.flags.isStatic !== interfaceMember.flags.isStatic) {\n continue;\n }\n\n classMember = child;\n break;\n }\n\n if (!classMember) {\n return;\n }\n\n const interfaceMemberName = interfaceReflection.name + '.' + interfaceMember.name;\n classMember.implementationOf = new ReferenceType(interfaceMemberName, ReferenceType.SYMBOL_FQN_RESOLVED, interfaceMember);\n this.copyComment(classMember, interfaceMember);\n\n if (interfaceMember.kindOf(ReflectionKind.FunctionOrMethod) && interfaceMember.signatures && classMember.signatures) {\n interfaceMember.signatures.forEach((interfaceSignature: SignatureReflection) => {\n const interfaceParameters = interfaceSignature.getParameterTypes();\n (classMember!.signatures || []).forEach((classSignature: SignatureReflection) => {\n if (Type.isTypeListEqual(interfaceParameters, classSignature.getParameterTypes())) {\n classSignature.implementationOf = new ReferenceType(interfaceMemberName, ReferenceType.SYMBOL_FQN_RESOLVED, interfaceSignature);\n this.copyComment(classSignature, interfaceSignature);\n }\n });\n });\n }\n });\n }\n\n /**\n * Copy the comment of the source reflection to the target reflection.\n *\n * @param target\n * @param source\n */\n private copyComment(target: Reflection, source: Reflection) {\n if (target.comment && source.comment && target.comment.hasTag('inheritdoc')) {\n target.comment.copyFrom(source.comment);\n\n if (target instanceof SignatureReflection && target.parameters &&\n source instanceof SignatureReflection && source.parameters) {\n for (let index = 0, count = target.parameters.length; index < count; index++) {\n const sourceParameter = source.parameters[index];\n if (sourceParameter && sourceParameter.comment) {\n const targetParameter = target.parameters[index];\n if (!targetParameter.comment) {\n targetParameter.comment = new Comment();\n targetParameter.comment.copyFrom(sourceParameter.comment);\n }\n }\n }\n }\n }\n }\n\n /**\n * Triggered when the converter resolves a reflection.\n *\n * @param context The context object describing the current state the converter is in.\n * @param reflection The reflection that is currently resolved.\n */\n private onResolve(context: Context, reflection: DeclarationReflection) {\n if (reflection.kindOf(ReflectionKind.Class) && reflection.implementedTypes) {\n reflection.implementedTypes.forEach((type: Type) => {\n if (!(type instanceof ReferenceType)) {\n return;\n }\n\n if (type.reflection && type.reflection.kindOf(ReflectionKind.Interface)) {\n this.analyzeClass(context, reflection, <DeclarationReflection> type.reflection);\n }\n });\n }\n }\n}\n"]}
@@ -0,0 +1,12 @@
1
+ import * as ts from 'typescript';
2
+ import { ConverterTypeComponent, TypeTypeConverter } from '../components';
3
+ import { Context } from '../context';
4
+ import { Type } from '../../models';
5
+ export declare class ObjectType extends Type {
6
+ readonly type = "object";
7
+ clone(): ObjectType;
8
+ }
9
+ export declare class ConditionalConverter extends ConverterTypeComponent implements TypeTypeConverter<ts.ObjectType> {
10
+ supportsType(context: Context, type: ts.Type): boolean;
11
+ convertType(context: Context, type: ts.ObjectType): ObjectType | undefined;
12
+ }
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ const ts = require("typescript");
10
+ const components_1 = require("../components");
11
+ const models_1 = require("../../models");
12
+ class ObjectType extends models_1.Type {
13
+ constructor() {
14
+ super(...arguments);
15
+ this.type = 'object';
16
+ }
17
+ clone() {
18
+ return new ObjectType;
19
+ }
20
+ }
21
+ exports.ObjectType = ObjectType;
22
+ let ConditionalConverter = class ConditionalConverter extends components_1.ConverterTypeComponent {
23
+ supportsType(context, type) {
24
+ return !!(type.flags & ts.TypeFlags.Object)
25
+ && !!(type.objectFlags & ts.ObjectFlags.Anonymous)
26
+ && !type.symbol;
27
+ }
28
+ convertType(context, type) {
29
+ return new ObjectType;
30
+ }
31
+ };
32
+ ConditionalConverter = __decorate([
33
+ components_1.Component({ name: 'type:anonymous' })
34
+ ], ConditionalConverter);
35
+ exports.ConditionalConverter = ConditionalConverter;
36
+ //# sourceMappingURL=anonymous.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anonymous.js","sourceRoot":"","sources":["../../../../src/lib/converter/types/anonymous.ts"],"names":[],"mappings":";;;;;;;;AAAA,iCAAiC;AAEjC,8CAAqF;AAErF,yCAAoC;AAEpC,MAAa,UAAW,SAAQ,aAAI;IAApC;;QACa,SAAI,GAAG,QAAQ,CAAA;IAK5B,CAAC;IAHG,KAAK;QACD,OAAO,IAAI,UAAU,CAAA;IACzB,CAAC;CACJ;AAND,gCAMC;AAGD,IAAa,oBAAoB,GAAjC,MAAa,oBAAqB,SAAQ,mCAAsB;IAC5D,YAAY,CAAC,OAAgB,EAAE,IAAa;QACxC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC;eACpC,CAAC,CAAC,CAAE,IAAsB,CAAC,WAAW,GAAG,EAAE,CAAC,WAAW,CAAC,SAAS,CAAC;eAClE,CAAC,IAAI,CAAC,MAAM,CAAA;IACvB,CAAC;IAED,WAAW,CAAC,OAAgB,EAAE,IAAmB;QAC7C,OAAO,IAAI,UAAU,CAAA;IACzB,CAAC;CACJ,CAAA;AAVY,oBAAoB;IADhC,sBAAS,CAAC,EAAC,IAAI,EAAE,gBAAgB,EAAC,CAAC;GACvB,oBAAoB,CAUhC;AAVY,oDAAoB","sourcesContent":["import * as ts from 'typescript';\n\nimport { Component, ConverterTypeComponent, TypeTypeConverter } from '../components';\nimport { Context } from '../context';\nimport { Type } from '../../models';\n\nexport class ObjectType extends Type {\n readonly type = 'object'\n\n clone() {\n return new ObjectType\n }\n}\n\n@Component({name: 'type:anonymous'})\nexport class ConditionalConverter extends ConverterTypeComponent implements TypeTypeConverter<ts.ObjectType> {\n supportsType(context: Context, type: ts.Type): boolean {\n return !!(type.flags & ts.TypeFlags.Object)\n && !!((type as ts.ObjectType).objectFlags & ts.ObjectFlags.Anonymous)\n && !type.symbol // No anonymous classes... not sure how to handle them yet.\n }\n\n convertType(context: Context, type: ts.ObjectType): ObjectType | undefined {\n return new ObjectType\n }\n}\n"]}
@@ -0,0 +1,16 @@
1
+ import * as ts from 'typescript';
2
+ export declare class BaseReflection {
3
+ id: number;
4
+ parent?: BaseReflection;
5
+ }
6
+ export declare class EnumReflection extends BaseReflection {
7
+ readonly name: string;
8
+ readonly members: EnumMemberReflection[];
9
+ constructor(name: string, members: EnumMemberReflection[]);
10
+ }
11
+ export declare class EnumMemberReflection extends BaseReflection {
12
+ readonly name: string;
13
+ readonly value: string | number;
14
+ constructor(name: string, value: string | number);
15
+ }
16
+ export declare function convertEnum(symbol: ts.Symbol): EnumReflection | undefined;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const ts = require("typescript");
4
+ let foo = 1;
5
+ class BaseReflection {
6
+ constructor() {
7
+ this.id = foo++;
8
+ }
9
+ }
10
+ exports.BaseReflection = BaseReflection;
11
+ class EnumReflection extends BaseReflection {
12
+ constructor(name, members) {
13
+ super();
14
+ this.name = name;
15
+ this.members = members;
16
+ }
17
+ }
18
+ exports.EnumReflection = EnumReflection;
19
+ class EnumMemberReflection extends BaseReflection {
20
+ constructor(name, value) {
21
+ super();
22
+ this.name = name;
23
+ this.value = value;
24
+ }
25
+ }
26
+ exports.EnumMemberReflection = EnumMemberReflection;
27
+ function convertEnum(symbol) {
28
+ var _a, _b;
29
+ const declarations = (_b = (_a = symbol.getDeclarations()) === null || _a === void 0 ? void 0 : _a.filter(ts.isEnumDeclaration)) !== null && _b !== void 0 ? _b : [];
30
+ if (!declarations.length) {
31
+ return;
32
+ }
33
+ }
34
+ exports.convertEnum = convertEnum;
35
+ //# sourceMappingURL=converter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"converter.js","sourceRoot":"","sources":["../../../src/lib/converter2/converter.ts"],"names":[],"mappings":";;AAAA,iCAAiC;AAEjC,IAAI,GAAG,GAAG,CAAC,CAAA;AAEX,MAAa,cAAc;IAA3B;QACI,OAAE,GAAG,GAAG,EAAE,CAAA;IAEd,CAAC;CAAA;AAHD,wCAGC;AAED,MAAa,cAAe,SAAQ,cAAc;IAC9C,YACa,IAAY,EACZ,OAA+B;QAExC,KAAK,EAAE,CAAC;QAHC,SAAI,GAAJ,IAAI,CAAQ;QACZ,YAAO,GAAP,OAAO,CAAwB;IAG5C,CAAC;CACJ;AAPD,wCAOC;AAED,MAAa,oBAAqB,SAAQ,cAAc;IACpD,YACa,IAAY,EACZ,KAAsB;QAE/B,KAAK,EAAE,CAAC;QAHC,SAAI,GAAJ,IAAI,CAAQ;QACZ,UAAK,GAAL,KAAK,CAAiB;IAGnC,CAAC;CACJ;AAPD,oDAOC;AAED,SAAgB,WAAW,CAAC,MAAiB;;IACzC,MAAM,YAAY,eAAG,MAAM,CAAC,eAAe,EAAE,0CAAE,MAAM,CAAC,EAAE,CAAC,iBAAiB,oCAAK,EAAE,CAAC;IAElF,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE;QACtB,OAAO;KACV;AACL,CAAC;AAND,kCAMC","sourcesContent":["import * as ts from 'typescript';\n\nlet foo = 1\n\nexport class BaseReflection {\n id = foo++\n parent?: BaseReflection\n}\n\nexport class EnumReflection extends BaseReflection {\n constructor(\n readonly name: string,\n readonly members: EnumMemberReflection[]\n ) {\n super();\n }\n}\n\nexport class EnumMemberReflection extends BaseReflection {\n constructor(\n readonly name: string,\n readonly value: string | number\n ) {\n super();\n }\n}\n\nexport function convertEnum(symbol: ts.Symbol): EnumReflection | undefined {\n const declarations = symbol.getDeclarations()?.filter(ts.isEnumDeclaration) ?? [];\n\n if (!declarations.length) {\n return;\n }\n}\n"]}
File without changes
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/converter2/index.ts"],"names":[],"mappings":"","sourcesContent":[""]}
File without changes
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=enum.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enum.js","sourceRoot":"","sources":["../../../../src/lib/converter2/symbols/enum.ts"],"names":[],"mappings":"","sourcesContent":[""]}
@@ -54,7 +54,8 @@ export declare enum ReflectionFlag {
54
54
  ConstructorProperty = 1024,
55
55
  Abstract = 2048,
56
56
  Const = 4096,
57
- Let = 8192
57
+ Let = 8192,
58
+ Readonly = 16384
58
59
  }
59
60
  export declare class ReflectionFlags extends Array<string> {
60
61
  private flags;
@@ -72,6 +73,7 @@ export declare class ReflectionFlags extends Array<string> {
72
73
  get isAbstract(): boolean;
73
74
  get isConst(): boolean;
74
75
  get isLet(): boolean;
76
+ get isReadonly(): boolean;
75
77
  setFlag(flag: ReflectionFlag, set: boolean): void;
76
78
  private setSingleFlag;
77
79
  }
@@ -59,6 +59,7 @@ var ReflectionFlag;
59
59
  ReflectionFlag[ReflectionFlag["Abstract"] = 2048] = "Abstract";
60
60
  ReflectionFlag[ReflectionFlag["Const"] = 4096] = "Const";
61
61
  ReflectionFlag[ReflectionFlag["Let"] = 8192] = "Let";
62
+ ReflectionFlag[ReflectionFlag["Readonly"] = 16384] = "Readonly";
62
63
  })(ReflectionFlag = exports.ReflectionFlag || (exports.ReflectionFlag = {}));
63
64
  const relevantFlags = [
64
65
  ReflectionFlag.Private,
@@ -70,7 +71,8 @@ const relevantFlags = [
70
71
  ReflectionFlag.Rest,
71
72
  ReflectionFlag.Abstract,
72
73
  ReflectionFlag.Let,
73
- ReflectionFlag.Const
74
+ ReflectionFlag.Const,
75
+ ReflectionFlag.Readonly
74
76
  ];
75
77
  class ReflectionFlags extends Array {
76
78
  constructor() {
@@ -119,6 +121,9 @@ class ReflectionFlags extends Array {
119
121
  get isLet() {
120
122
  return this.hasFlag(ReflectionFlag.Let);
121
123
  }
124
+ get isReadonly() {
125
+ return this.hasFlag(ReflectionFlag.Readonly);
126
+ }
122
127
  setFlag(flag, set) {
123
128
  switch (flag) {
124
129
  case ReflectionFlag.Private: