Skip to content
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

feat: add --no-check option #6456

Merged
merged 11 commits into from Jul 8, 2020
35 changes: 35 additions & 0 deletions cli/flags.rs
Expand Up @@ -106,6 +106,7 @@ pub struct Flags {
pub lock_write: bool,
pub log_level: Option<Level>,
pub net_allowlist: Vec<String>,
pub no_check: bool,
pub no_prompts: bool,
pub no_remote: bool,
pub read_allowlist: Vec<PathBuf>,
Expand Down Expand Up @@ -452,6 +453,7 @@ fn eval_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
fn info_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
ca_file_arg_parse(flags, matches);
unstable_arg_parse(flags, matches);
no_check_arg_parse(flags, matches);

flags.subcommand = DenoSubcommand::Info {
file: matches.value_of("file").map(|f| f.to_string()),
Expand All @@ -463,6 +465,7 @@ fn cache_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
lock_args_parse(flags, matches);
importmap_arg_parse(flags, matches);
config_arg_parse(flags, matches);
no_check_arg_parse(flags, matches);
no_remote_arg_parse(flags, matches);
ca_file_arg_parse(flags, matches);
unstable_arg_parse(flags, matches);
Expand Down Expand Up @@ -491,6 +494,7 @@ fn run_test_args_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
importmap_arg_parse(flags, matches);
config_arg_parse(flags, matches);
v8_flags_arg_parse(flags, matches);
no_check_arg_parse(flags, matches);
no_remote_arg_parse(flags, matches);
permission_args_parse(flags, matches);
ca_file_arg_parse(flags, matches);
Expand Down Expand Up @@ -815,6 +819,7 @@ TypeScript compiler cache: Subdirectory containing TS compiler output.",
)
.arg(Arg::with_name("file").takes_value(true).required(false))
.arg(ca_file_arg())
.arg(no_check_arg())
.arg(unstable_arg())
}

Expand All @@ -826,6 +831,7 @@ fn cache_subcommand<'a, 'b>() -> App<'a, 'b> {
.arg(importmap_arg())
.arg(unstable_arg())
.arg(config_arg())
.arg(no_check_arg())
.arg(no_remote_arg())
.arg(
Arg::with_name("file")
Expand Down Expand Up @@ -1037,6 +1043,7 @@ fn run_test_args<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b> {
.arg(config_arg())
.arg(lock_arg())
.arg(lock_write_arg())
.arg(no_check_arg())
.arg(no_remote_arg())
.arg(v8_flags_arg())
.arg(ca_file_arg())
Expand Down Expand Up @@ -1311,6 +1318,18 @@ fn v8_flags_arg_parse(flags: &mut Flags, matches: &ArgMatches) {
}
}

fn no_check_arg<'a, 'b>() -> Arg<'a, 'b> {
Arg::with_name("no-check")
.long("no-check")
.help("Skip type checking modules")
}

fn no_check_arg_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
if matches.is_present("no-check") {
flags.no_check = true;
}
}

fn no_remote_arg<'a, 'b>() -> Arg<'a, 'b> {
Arg::with_name("no-remote")
.long("no-remote")
Expand Down Expand Up @@ -2415,6 +2434,22 @@ mod tests {
}
*/

#[test]
fn no_check() {
let r =
flags_from_vec_safe(svec!["deno", "run", "--no-check", "script.ts"]);
assert_eq!(
r.unwrap(),
Flags {
subcommand: DenoSubcommand::Run {
script: "script.ts".to_string(),
},
no_check: true,
..Flags::default()
}
);
}

#[test]
fn no_remote() {
let r =
Expand Down
29 changes: 18 additions & 11 deletions cli/global_state.rs
Expand Up @@ -170,17 +170,24 @@ impl GlobalState {
let allow_js = should_allow_js(&module_graph_files);

if should_compile {
self
.ts_compiler
.compile(
self.clone(),
&out,
target_lib,
permissions,
module_graph,
allow_js,
)
.await?;
if self.flags.no_check {
self
.ts_compiler
.transpile(self.clone(), permissions, module_graph)
.await?;
} else {
self
.ts_compiler
.compile(
self.clone(),
&out,
target_lib,
permissions,
module_graph,
allow_js,
)
.await?;
}
}

if let Some(ref lockfile) = self.lockfile {
Expand Down
2 changes: 1 addition & 1 deletion cli/js/buffer.ts
Expand Up @@ -4,7 +4,7 @@
// Copyright 2009 The Go Authors. All rights reserved. BSD license.
// https://github.com/golang/go/blob/master/LICENSE

import { Reader, Writer, ReaderSync, WriterSync } from "./io.ts";
import type { Reader, Writer, ReaderSync, WriterSync } from "./io.ts";
import { assert } from "./util.ts";

// MIN_READ is the minimum ArrayBuffer size passed to a read call by
Expand Down