Is there a way to fix this error without having to place an ignore in the file?
Error when running command:
./node_modules/tslint/bin/tslint -p src/tsconfig.json --type-check src/app/app.component.spec.ts
[21, 5]: unused expression, expected an assignment or function call
Test:
let chai = require('chai');
let expect = chai.expect;
import { AppComponent } from './app.component';
import { ComponentFixture, TestBed } from '@angular/core/testing';
describe('AppComponent', function() {
let testAppComponent: AppComponent;
let fixture: ComponentFixture<AppComponent>;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [AppComponent]
});
fixture = TestBed.createComponent(AppComponent);
testAppComponent = fixture.componentInstance;
});
it('should create the correct component', () => {
expect(testAppComponent instanceof AppComponent).to.be.true;
});
});
Did you perhaps mean this:
expect(testAppComponent instanceof AppComponent).toBe(true);
The expression you have there just accesses a bunch of properties, you need some kind of function call for it to actually do anything.
In my case I had a dangling ?
someArray.find(someCheck)?.items.push(someThing)
I just wrote it out as an if
statement:
let ok = someArray.find(someCheck);
if (ok) {
ok.items.push(someThing);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.