microsoft / tslint-microsoft-contrib

A set of TSLint rules used on some Microsoft projects.
MIT License
702 stars 198 forks source link

Handle TS exceptions in no-string-based-x rules #860

Closed IllusionMH closed 5 years ago

IllusionMH commented 5 years ago

PR checklist

Overview of change:

This PR does two things:

  1. Defers type check to the moment when potential violation found.
  2. Wraps all calls to typeChecker.getTypeAtLocation in try..catch and restores same behavir when type checker is not available.

This PR doesn't fix root cause of #859 but at least rules won't throw an exception.

Is there anything you'd like reviewers to focus on?

No unit tests for specific case because issue is noticeable in only in Vue. Should I add tests to handle this exceptional case?

IllusionMH commented 5 years ago

Thanks for review!

jwhitmarsh commented 5 years ago

Thank you :)