107 cy.getEntityDetailsHeading('topic');
108 cy.get(entityDetailsBackButtonSelector).click();
109 cy.wait('@entitiesRequest').then(({ response }) => {
110 expect(response!.statusCode).to.equal(200);111 });
112 cy.url().should('match', topicPageUrlPattern);
113 });
118 cy.get(entityCreateSaveButtonSelector).should('exist');
119 cy.get(entityCreateCancelButtonSelector).click();
120 cy.wait('@entitiesRequest').then(({ response }) => {
121 expect(response!.statusCode).to.equal(200);122 });
123 cy.url().should('match', topicPageUrlPattern);
124 });
69 cy.get(entityCreateSaveButtonSelector).should('exist');
70 cy.get(entityCreateCancelButtonSelector).click();
71 cy.wait('@entitiesRequest').then(({ response }) => {
72 expect(response!.statusCode).to.equal(200); 73 });
74 cy.url().should('match', topicPageUrlPattern);
75 });
45 cy.visit('/');
46 cy.clickOnEntityMenuItem('topic');
47 cy.wait('@entitiesRequest').then(({ response }) => {
48 if (response!.body.length === 0) { 49 cy.get(entityTableSelector).should('not.exist');
50 } else {
51 cy.get(entityTableSelector).should('exist');
128 cy.getEntityDeleteDialogHeading('topic').should('exist');
129 cy.get(entityConfirmDeleteButtonSelector).click();
130 cy.wait('@deleteEntityRequest').then(({ response }) => {
131 expect(response!.statusCode).to.equal(204);132 });
133 cy.wait('@entitiesRequest').then(({ response }) => {
134 expect(response!.statusCode).to.equal(200);
Type assertion is explicitly telling the compiler that we want to treat the entity as a different type. However, if we add a type assertion for a variable which is automatically inferred with the same type already then it is unnecessary to define the type explicitly.
Using a type assertion that does not change the type of an expression is unnecessary and should be avoided for a cleaner code.
// Types of 'foo' and 'bar' are already inferred as 'number', explicit type assertion in unnecessary
let foo = 3 as number;
let bar = <number>3;
function foobar(x: number): number {
return x!; // Type of 'x' is 'number' and is not 'null' or 'undefined'. Non-null assertion is unnecessary
}
type NewType = number;
let baz = 3 as NewType
let qux = <NewType>3
const foo = [1, 2] as const; // Using 'as const' enforces the array to be readonly
function foobar(x: number | undefined): number {
return x!;
}