-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
misc(tsc): reorganize and expose external interfaces #4788
Conversation
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. | ||
*/ | ||
|
||
declare namespace LH.Audit { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
global namespaces are merged, so this adds to the LH
namespace defined in externs.d.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
glad to start getting some structure in our typings! 🎉
*/ | ||
|
||
declare namespace LH.Audit { | ||
export interface ScoringModes { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enum?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it looks like we can't (at least in a d.ts
file). Since enum
defines a type and a value in ts, it expects you to use the value of the enum anywhere the type is expected. So e.g. the values of Audit.SCORING_MODES
would have to be LH.Audit.ScoringModes
(not just 'numeric' and 'binary', even though that's what those are), but those don't exist in JS if the enum is defined here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could be wrong, but I can't make it work. Playground example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you mean you're not a fan of this!?
😆
typings/audit.d.ts
Outdated
// TODO: placeholder typedefs until Details are typed | ||
export interface DetailsRendererDetailsSummary { | ||
wastedMs?: number; | ||
wastedKb?: number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
carryover but this is wastedBytes
:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
I'll let Paul and Patrick take this review, no opinion from my side. |
moves public interfaces of Audit and Gatherer to
audit.d.ts
andgatherer.d.ts
. This fixes the problem that typedefs on a class (e.g.Audit
) are only local and aren't actually exposed on that module when required elsewhere.Also changes the product of
Audit.audit()
toLH.Audit.Product
fromLH.AuditResult
, which allowsLH.AuditFullResult
(which is actually in the LHR) to just beLH.Audit.Result
. Happy to bikeshed on these, though :)Also update to typescript 2.8 (rc) because there's a bug in 2.7 when it wasn't actually checking optional properties when in JS files (not using any new features yet). Can move over to 2.8 when it hits release very soon.