webhintio / rfcs

🛑 This repository is deprecated!! To request changes, new features, hints, etc. please open an issue in https://github.com/webhintio/hint
1 stars 1 forks source link

Improve initialization of `utils-debugging-protocol-common` #44

Closed antross closed 5 years ago

antross commented 6 years ago

Currently debugging-protocol-connector.ts contains a number of properties which are asynchronously initialized after the CDP connection has been established. As the code is migrated to TypeScript's strict mode, each of these properties is considered potentially uninitialized when read within methods. The spot fix is to override the compiler's assertion for now.

Going forward, this would be better handled by taking all of these late-initialized properties and putting them within a single (initially null) sub-object. This provides a single point at which null-checks can be performed in dependent methods without having to check each property individually. It also allows the TypeScript compiler to understand that this check has taken place.