diff options
author | Yiyu Lin <linyiyu1992@gmail.com> | 2023-04-13 09:08:01 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-13 03:08:01 +0200 |
commit | d790ea7d533c3c48b09a2f16f3fef549aa96be78 (patch) | |
tree | b31fc35baf1f634054f52e94626f0399d187b99b /cli/tsc/diagnostics.rs | |
parent | 19c3e4f6dc31fd78e2793d0596d6a9cc3a30580a (diff) |
refactor(cli,ext,ops): cleanup `regex` with `lazy-regex` (#17296)
- bump deps: the newest `lazy-regex` need newer `oncecell` and
`regex`
- reduce `unwrap`
- remove dep `lazy_static`
- make more regex cached
---------
Co-authored-by: Bartek IwaĆczuk <biwanczuk@gmail.com>
Diffstat (limited to 'cli/tsc/diagnostics.rs')
-rw-r--r-- | cli/tsc/diagnostics.rs | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/cli/tsc/diagnostics.rs b/cli/tsc/diagnostics.rs index a865daa9d..1e9819309 100644 --- a/cli/tsc/diagnostics.rs +++ b/cli/tsc/diagnostics.rs @@ -6,6 +6,7 @@ use deno_core::serde::Deserialize; use deno_core::serde::Deserializer; use deno_core::serde::Serialize; use deno_core::serde::Serializer; +use lazy_regex::lazy_regex; use once_cell::sync::Lazy; use regex::Regex; use std::error::Error; @@ -36,13 +37,11 @@ const UNSTABLE_DENO_PROPS: &[&str] = &[ "osUptime", ]; -static MSG_MISSING_PROPERTY_DENO: Lazy<Regex> = Lazy::new(|| { - Regex::new(r#"Property '([^']+)' does not exist on type 'typeof Deno'"#) - .unwrap() -}); +static MSG_MISSING_PROPERTY_DENO: Lazy<Regex> = + lazy_regex!(r#"Property '([^']+)' does not exist on type 'typeof Deno'"#); static MSG_SUGGESTION: Lazy<Regex> = - Lazy::new(|| Regex::new(r#" Did you mean '([^']+)'\?"#).unwrap()); + lazy_regex!(r#" Did you mean '([^']+)'\?"#); /// Potentially convert a "raw" diagnostic message from TSC to something that /// provides a more sensible error message given a Deno runtime context. |