style: apply strict style rules for this feature

This commit is contained in:
Michel Jonathan Schmitz
2019-06-05 16:29:08 +02:00
parent 843e59811a
commit 23cbc53fef
10 changed files with 90 additions and 67 deletions

View File

@@ -21,7 +21,7 @@ import {join, sep} from 'path';
import {Definition} from 'ts-json-schema-generator';
import {Application, ProjectReflection} from 'typedoc';
import {promisify} from 'util';
import {LightweightType} from './uml/model/LightweightType';
import {LightweightType} from './uml/model/lightweight-type';
export const globPromisified = promisify(glob);
export const mkdirPromisified = promisify(mkdir);
@@ -143,7 +143,7 @@ export interface ExpectableValidationErrors {
*
* @param srcPath Path to get reflection from
*/
export function getProjectReflection(srcPath: PathLike, excludeExternals: boolean = true): ProjectReflection {
export function getProjectReflection(srcPath: PathLike, excludeExternals = true): ProjectReflection {
Logger.info(`Generating project reflection for ${srcPath.toString()}.`);
const tsconfigPath = getTsconfigPath(srcPath.toString());
@@ -254,13 +254,14 @@ export function getFullTypeName(type: LightweightType): string {
}
if (type.isLiteral) {
// literals are a sink
return "'" + fullName + "'";
return `'${fullName}'`;
}
if (type.isUnion && type.specificationTypes.length > 0) {
const tempNames: string[] = [];
for (const easyType of type.specificationTypes) {
tempNames.push(getFullTypeName(easyType));
}
// since unions can't be applied to other types, it is a sink.
return tempNames.join(' | ');
}
@@ -270,11 +271,12 @@ export function getFullTypeName(type: LightweightType): string {
for (const easyType of type.genericsTypes) {
tempNames.push(getFullTypeName(easyType));
}
fullName += '<' + tempNames.join(', ') + '>';
fullName = `${fullName}<${tempNames.join(', ')}>`;
}
// check if type is array
if (type.isArray) {
fullName += '[]';
}
return fullName;
}