mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
parent
804b97c636
commit
8a367d3cc3
9 changed files with 23 additions and 8 deletions
|
@ -150,9 +150,10 @@ pub fn jsr_api_url() -> &'static Url {
|
|||
|
||||
pub fn ts_config_to_transpile_and_emit_options(
|
||||
config: deno_config::TsConfig,
|
||||
) -> (deno_ast::TranspileOptions, deno_ast::EmitOptions) {
|
||||
) -> Result<(deno_ast::TranspileOptions, deno_ast::EmitOptions), AnyError> {
|
||||
let options: deno_config::EmitConfigOptions =
|
||||
serde_json::from_value(config.0).unwrap();
|
||||
serde_json::from_value(config.0)
|
||||
.context("Failed to parse compilerOptions")?;
|
||||
let imports_not_used_as_values =
|
||||
match options.imports_not_used_as_values.as_str() {
|
||||
"preserve" => deno_ast::ImportsNotUsedAsValues::Preserve,
|
||||
|
@ -174,7 +175,7 @@ pub fn ts_config_to_transpile_and_emit_options(
|
|||
} else {
|
||||
SourceMapOption::None
|
||||
};
|
||||
(
|
||||
Ok((
|
||||
deno_ast::TranspileOptions {
|
||||
use_ts_decorators: options.experimental_decorators,
|
||||
use_decorators_proposal: !options.experimental_decorators,
|
||||
|
@ -195,7 +196,7 @@ pub fn ts_config_to_transpile_and_emit_options(
|
|||
keep_comments: false,
|
||||
source_map,
|
||||
},
|
||||
)
|
||||
))
|
||||
}
|
||||
|
||||
/// Indicates how cached source files should be handled.
|
||||
|
|
|
@ -563,7 +563,7 @@ impl CliFactory {
|
|||
let (transpile_options, emit_options) =
|
||||
crate::args::ts_config_to_transpile_and_emit_options(
|
||||
ts_config_result.ts_config,
|
||||
);
|
||||
)?;
|
||||
Ok(Arc::new(Emitter::new(
|
||||
self.emit_cache()?.clone(),
|
||||
self.parsed_source_cache().clone(),
|
||||
|
|
|
@ -147,7 +147,7 @@ fn bundle_module_graph(
|
|||
let (transpile_options, emit_options) =
|
||||
crate::args::ts_config_to_transpile_and_emit_options(
|
||||
ts_config_result.ts_config,
|
||||
);
|
||||
)?;
|
||||
deno_emit::bundle_graph(
|
||||
graph,
|
||||
deno_emit::BundleOptions {
|
||||
|
|
|
@ -76,7 +76,7 @@ pub async fn compile(
|
|||
let (transpile_options, emit_options) =
|
||||
crate::args::ts_config_to_transpile_and_emit_options(
|
||||
ts_config_for_emit.ts_config,
|
||||
);
|
||||
)?;
|
||||
let parser = parsed_source_cache.as_capturing_parser();
|
||||
let eszip = eszip::EszipV2::from_graph(
|
||||
graph,
|
||||
|
|
|
@ -255,7 +255,7 @@ impl ReplSession {
|
|||
let (transpile_options, _) =
|
||||
crate::args::ts_config_to_transpile_and_emit_options(
|
||||
ts_config_for_emit.ts_config,
|
||||
);
|
||||
)?;
|
||||
let experimental_decorators = transpile_options.use_ts_decorators;
|
||||
let mut repl_session = ReplSession {
|
||||
npm_resolver,
|
||||
|
|
5
tests/specs/run/invalid_emit_options/__test__.jsonc
Normal file
5
tests/specs/run/invalid_emit_options/__test__.jsonc
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"args": "run main.ts",
|
||||
"output": "main.out",
|
||||
"exitCode": 1
|
||||
}
|
5
tests/specs/run/invalid_emit_options/deno.json
Normal file
5
tests/specs/run/invalid_emit_options/deno.json
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"jsx": 1234
|
||||
}
|
||||
}
|
4
tests/specs/run/invalid_emit_options/main.out
Normal file
4
tests/specs/run/invalid_emit_options/main.out
Normal file
|
@ -0,0 +1,4 @@
|
|||
error: Failed to parse compilerOptions
|
||||
|
||||
Caused by:
|
||||
invalid type: integer `1234`, expected a string
|
0
tests/specs/run/invalid_emit_options/main.ts
Normal file
0
tests/specs/run/invalid_emit_options/main.ts
Normal file
Loading…
Reference in a new issue