summaryrefslogtreecommitdiff
path: root/cli/tsc.rs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2022-05-20 16:40:55 -0400
committerGitHub <noreply@github.com>2022-05-20 16:40:55 -0400
commit1fcecb6789c3f111bc1554766ba9347afcfd02dc (patch)
tree19cd1b121412b992994b2fe4bea0463793d3986e /cli/tsc.rs
parente7c894e8f54ebd2d9fd61c97a265906ac54e2068 (diff)
refactor: upgrade to deno_ast 0.15 (#14680)
Diffstat (limited to 'cli/tsc.rs')
-rw-r--r--cli/tsc.rs18
1 files changed, 9 insertions, 9 deletions
diff --git a/cli/tsc.rs b/cli/tsc.rs
index d629fb80b..a61d7871d 100644
--- a/cli/tsc.rs
+++ b/cli/tsc.rs
@@ -121,7 +121,7 @@ pub fn get_asset(asset: &str) -> Option<&'static str> {
}
fn get_maybe_hash(
- maybe_source: Option<&String>,
+ maybe_source: Option<&str>,
hash_data: &[Vec<u8>],
) -> Option<String> {
if let Some(source) = maybe_source {
@@ -449,18 +449,19 @@ fn op_load(state: &mut OpState, args: Value) -> Result<Value, AnyError> {
.context("Error converting a string module specifier for \"op_load\".")?;
let mut hash: Option<String> = None;
let mut media_type = MediaType::Unknown;
+ let graph_data = state.graph_data.read();
let data = if &v.specifier == "deno:///.tsbuildinfo" {
- state.maybe_tsbuildinfo.clone()
+ state.maybe_tsbuildinfo.as_deref()
// in certain situations we return a "blank" module to tsc and we need to
// handle the request for that module here.
} else if &v.specifier == "deno:///missing_dependency.d.ts" {
hash = Some("1".to_string());
media_type = MediaType::Dts;
- Some("declare const __: any;\nexport = __;\n".to_string())
+ Some("declare const __: any;\nexport = __;\n")
} else if v.specifier.starts_with("asset:///") {
let name = v.specifier.replace("asset:///", "");
- let maybe_source = get_asset(&name).map(String::from);
- hash = get_maybe_hash(maybe_source.as_ref(), &state.hash_data);
+ let maybe_source = get_asset(&name);
+ hash = get_maybe_hash(maybe_source, &state.hash_data);
media_type = MediaType::from(&v.specifier);
maybe_source
} else {
@@ -473,7 +474,6 @@ fn op_load(state: &mut OpState, args: Value) -> Result<Value, AnyError> {
} else {
specifier
};
- let graph_data = state.graph_data.read();
let maybe_source = if let Some(ModuleEntry::Module {
code,
media_type: mt,
@@ -482,12 +482,12 @@ fn op_load(state: &mut OpState, args: Value) -> Result<Value, AnyError> {
graph_data.get(&graph_data.follow_redirect(&specifier))
{
media_type = *mt;
- Some(code.as_ref().clone())
+ Some(code as &str)
} else {
media_type = MediaType::Unknown;
None
};
- hash = get_maybe_hash(maybe_source.as_ref(), &state.hash_data);
+ hash = get_maybe_hash(maybe_source, &state.hash_data);
maybe_source
};
@@ -752,7 +752,7 @@ mod tests {
Some(deno_graph::source::LoadResponse::Module {
specifier: specifier.clone(),
maybe_headers: None,
- content: Arc::new(c),
+ content: c.into(),
})
})
.map_err(|err| err.into());