error TS2554: Expected 2 arguments, but got 1 in v8
See original GitHub issueπ Bug report
Command (mark with an x)
- [ ] new
- [ ] build
- [x] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc
Description
Just updated to v8 and on ng serve got a lot of TS2554 errors. All on ViewChild decorators. On top of it all, TSlint in VSCode marks all imports from angular related packages as invalid.
π¬ Minimal Reproduction
https://github.com/rip222/viewChild-test-ng8 β>
π₯ Exception or Error
ERROR in src/app/admin/blog-form/blog-form.component.ts(30,4): error TS2554: Expected 2 arguments, but got 1.
src/app/admin/booking-form/booking-form.component.ts(15,4): error TS2554: Expected 2 arguments, but got
1.
src/app/admin/bookings/bookings.component.ts(25,4): error TS2554: Expected 2 arguments, but got 1.
src/app/admin/bookings/bookings.component.ts(26,4): error TS2554: Expected 2 arguments, but got 1.
src/app/admin/fake-bookings/fake-bookings.component.ts(16,4): error TS2554: Expected 2 arguments, but got 1.
src/app/admin/questions/questions.component.ts(18,4): error TS2554: Expected 2 arguments, but got 1.
src/app/admin/questions/questions.component.ts(19,4): error TS2554: Expected 2 arguments, but got 1.
src/app/booking/booking.component.ts(40,4): error TS2554: Expected 2 arguments, but got 1.
src/app/faq/faq.component.ts(19,4): error TS2554: Expected 2 arguments, but got 1.
π Your Environment
Angular CLI: 8.0.0
Node: 10.15.3
OS: linux x64
Angular: 8.0.0
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... platform-server, router, service-worker
Package Version
--------------------------------------------------------------------
@angular-devkit/architect 0.800.0
@angular-devkit/build-angular 0.800.0
@angular-devkit/build-optimizer 0.800.0
@angular-devkit/build-webpack 0.800.0
@angular-devkit/core 8.0.0
@angular-devkit/schematics 8.0.0
@angular/cdk 7.3.7
@angular/fire 5.1.3
@angular/material 7.3.7
@angular/pwa 0.12.4
@ngtools/webpack 8.0.0
@nguniversal/express-engine 7.1.1
@nguniversal/module-map-ngfactory-loader 7.1.1
@schematics/angular 8.0.0
@schematics/update 0.800.0
rxjs 6.5.2
typescript 3.4.5
webpack 4.30.0
Anything else relevant?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:14
- Comments:28 (4 by maintainers)
Top Results From Across the Web
error TS2554: Expected 2 arguments, but got 1 with @ViewChild
After migration to Angular 8 you should declare manually if it's static or not @ViewChild(QuilldEditorComponent, {static: true})Β ...
Read more >How to fix error TS2554: Expected 2 arguments, but got 1.
I had this function running in TypeScript, when I tried to call a base class constructor with "super". constructor( public http: HttpClient, public...
Read more >error ts2554 expected 1-2 arguments but got 3
The error says "Wrong number of arguments; expected 0, got 1". That means the method you are calling is not the one you...
Read more >Angular Archive - TechOverflow
app/my-component/my-component.component.ts:24:4 - error TS2554: Expected 2 arguments, but got 1. 24 @ViewChild(MyOtherComponent) myOtherComponent:Β ...
Read more >Error Ts2554: Expected 1 Arguments, But Got 0. Angular6
Just updated to v8 and on ng serve got a lot of TS2554 errors. TS2554: Expected 2 arguments, but got 1. src/app/booking/booking.component.ts(40,4): 0.800.0Β ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Before:
@ViewChild('foo') foo: ElementRef;After:
// query results available in ngOnInit@ViewChild('foo', {static: true}) foo: ElementRef;OR
// query results available in ngAfterViewInit@ViewChild('foo', {static: false}) foo: ElementRef;More info
in v8 ViewChild syntax changed CHANGELOG says
And I advice to use https://github.com/angular/angular/blob/master/CHANGELOG.md to update
In case of βlot ts errorsβ, I guess you have
fullTemplateTypeCheckin your tsconfig file which is fine and I recommend to add it.Have you SFC ? Is your template inside your .ts file ? If yes I doupt you use some pipe without specify all parameters ? If it is the case you can make parameters of pipe as optional like
Otherwise you can have some hostlistener with no needed second param which was working without
fullTemplateTypeCheck:It should be