Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions src/ts/class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,8 @@ export class Class {
return createIntersectionTypeNode([parentNode, propLiteral]);
} else if (parentNode) {
return parentNode;
} else if (propLiteral.members.length > 0) {
return propLiteral;
} else {
return createTypeLiteralNode([]);
return propLiteral;
}
}

Expand Down Expand Up @@ -245,9 +243,9 @@ export class Class {
createVariableDeclarationList(
[createVariableDeclaration(
this.className(),
/*type=*/undefined,
/*type=*/ undefined,
createObjectLiteral(
enums.map(e => e.toNode()), /*multiLine=*/true))],
enums.map(e => e.toNode()), /*multiLine=*/ true))],
NodeFlags.Const));
}

Expand Down Expand Up @@ -343,7 +341,7 @@ export class BooleanEnum extends Builtin {
createVariableDeclarationList(
[createVariableDeclaration(
this.subject.name,
/*type=*/undefined,
/*type=*/ undefined,
createObjectLiteral(
[
createPropertyAssignment(
Expand Down Expand Up @@ -385,14 +383,14 @@ export class DataTypeUnion extends Builtin {
/**
* Defines a Sort order between Class declarations.
*
* DataTypes come first, by the 'DataType' union itself, followed by all regular
* classes. Within each group, class names are ordered alphabetically in UTF-16
* code units order.
* DataTypes come first, next the 'DataType' union itself, followed by all
* regular classes. Within each group, class names are ordered alphabetically in
* UTF-16 code units order.
*/
export function Sort(a: Class, b: Class): number {
if (a instanceof Builtin && !(a instanceof DataTypeUnion)) {
if (b instanceof Builtin && !(b instanceof DataTypeUnion)) {
return a.subject.name.localeCompare(b.subject.name);
return CompareKeys(a.subject, b.subject);
} else {
return -1;
}
Expand All @@ -401,7 +399,8 @@ export function Sort(a: Class, b: Class): number {
} else if (a instanceof DataTypeUnion) {
return b instanceof DataTypeUnion ? 0 : -1;
} else if (b instanceof DataTypeUnion) {
return a instanceof DataTypeUnion ? 0 : +1;
// If we are here, a is never a DataTypeUnion.
return +1;
} else {
return CompareKeys(a.subject, b.subject);
}
Expand Down
Loading