Skip to content

Commit

Permalink
Remove deprecated Enum style.
Browse files Browse the repository at this point in the history
The successor to this enum style has been available since v0.4.4.
  • Loading branch information
Eyas committed Jan 8, 2020
1 parent 2e5b233 commit 6bd1106
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 34 deletions.
31 changes: 1 addition & 30 deletions src/ts/class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {createAsExpression, createIdentifier, createIntersectionTypeNode, createLiteralTypeNode, createModifiersFromModifierFlags, createObjectLiteral, createParenthesizedType, createPropertyAssignment, createStringLiteral, createTypeAliasDeclaration, createTypeLiteralNode, createTypeReferenceNode, createUnionTypeNode, createVariableDeclaration, createVariableDeclarationList, createVariableStatement, DeclarationStatement, ModifierFlags, NodeFlags, Statement, TypeAliasDeclaration, TypeNode, VariableStatement} from 'typescript';
import {createAsExpression, createIntersectionTypeNode, createLiteralTypeNode, createModifiersFromModifierFlags, createObjectLiteral, createParenthesizedType, createPropertyAssignment, createStringLiteral, createTypeAliasDeclaration, createTypeLiteralNode, createTypeReferenceNode, createUnionTypeNode, createVariableDeclaration, createVariableDeclarationList, createVariableStatement, DeclarationStatement, ModifierFlags, NodeFlags, Statement, TypeAliasDeclaration, TypeNode, VariableStatement} from 'typescript';

import {Log} from '../logging';
import {TObject, TPredicate, TSubject} from '../triples/triple';
Expand Down Expand Up @@ -92,9 +92,6 @@ export class Class {
protected baseName() {
return toClassName(this.subject) + 'Base';
}
private enumName() {
return toClassName(this.subject) + 'Enum';
}
private className() {
return toClassName(this.subject);
}
Expand Down Expand Up @@ -252,28 +249,6 @@ export class Class {
NodeFlags.Const));
}

private deprecatedEnumDecl(): Statement[] {
if (this._enums.size === 0) return [];
return [
withComments(
`@deprecated Use ${this.className()} as a variable instead.`,
createVariableStatement(
createModifiersFromModifierFlags(ModifierFlags.Export),
createVariableDeclarationList(
[createVariableDeclaration(
this.enumName(),
/*type=*/undefined, createIdentifier(this.className()))],
NodeFlags.Const))),
withComments(
`@deprecated Use ${this.className()} as a type instead.`,
createTypeAliasDeclaration(
/* decorators = */[],
createModifiersFromModifierFlags(ModifierFlags.Export),
this.enumName(), /*typeParameters=*/[],
createTypeReferenceNode(this.className(), /*typeArgs=*/[])))
];
}

toNode(context: Context, skipDeprecatedProperties: boolean):
readonly Statement[] {
const typeValue: TypeNode = this.totalType(context);
Expand Down Expand Up @@ -302,15 +277,11 @@ export class Class {
// Enum2 = "Enum2" as const,
// ...
// }
// // Deprecated: Old Enum Style Declarations --//
// export const XyzEnum = Xyz;
// export type XyzEnum = Xyz;
// //-------------------------------------------//
return arrayOf<Statement>(
this.baseDecl(skipDeprecatedProperties, context),
declaration,
this.enumDecl(),
...this.deprecatedEnumDecl(),
);
}
}
Expand Down
4 changes: 0 additions & 4 deletions tests/baselines/sorted_enum.ts.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,4 @@ export const Thing = {
c: ("http://schema.org/c" as const),
d: ("http://schema.org/d" as const)
};
/** @deprecated Use Thing as a variable instead. */
export const ThingEnum = Thing;
/** @deprecated Use Thing as a type instead. */
export type ThingEnum = Thing;

0 comments on commit 6bd1106

Please sign in to comment.