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(cli): update to TypeScript 4.5 #12410

Merged
merged 13 commits into from
Dec 9, 2021
6 changes: 4 additions & 2 deletions .dprint.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
"json": {
"deno": true
},
"includes": ["**/*.{ts,tsx,js,jsx,json,md,toml}"],
"includes": [
"**/*.{ts,tsx,js,jsx,json,md,toml}"
],
"excludes": [
".cargo_home",
".git",
Expand All @@ -36,7 +38,7 @@
"tools/wpt/manifest.json"
],
"plugins": [
"https://plugins.dprint.dev/typescript-0.59.2.wasm",
"https://plugins.dprint.dev/typescript-0.60.0.wasm",
"https://plugins.dprint.dev/json-0.13.2.wasm",
"https://plugins.dprint.dev/markdown-0.11.3.wasm",
"https://plugins.dprint.dev/toml-0.5.3.wasm"
Expand Down
19 changes: 12 additions & 7 deletions cli/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
use deno_core::error::custom_error;
use deno_core::op_sync;
use deno_core::serde::Deserialize;
use deno_core::serde_json;
use deno_core::serde_json::json;
use deno_core::serde_json::Value;
use deno_core::JsRuntime;
Expand Down Expand Up @@ -122,6 +121,7 @@ fn create_compiler_snapshot(
"es2020.string",
"es2020.symbol.wellknown",
"es2021",
"es2021.intl",
"es2021.promise",
"es2021.string",
"es2021.weakref",
Expand Down Expand Up @@ -168,14 +168,19 @@ fn create_compiler_snapshot(
"op_cwd",
op_sync(move |_state, _args: Value, _: ()| Ok(json!("cache:///"))),
);
// As of TypeScript 4.5, it tries to detect the existence of substitute lib
// files, which we currently don't use, so we just return false.
js_runtime.register_op(
"op_exists",
op_sync(move |_state, _args: LoadArgs, _: ()| Ok(json!(false))),
);
// using the same op that is used in `tsc.rs` for loading modules and reading
// files, but a slightly different implementation at build time.
js_runtime.register_op(
"op_load",
op_sync(move |_state, args, _: ()| {
let v: LoadArgs = serde_json::from_value(args)?;
op_sync(move |_state, args: LoadArgs, _: ()| {
// we need a basic file to send to tsc to warm it up.
if v.specifier == build_specifier {
if args.specifier == build_specifier {
Ok(json!({
"data": r#"console.log("hello deno!");"#,
"hash": "1",
Expand All @@ -184,7 +189,7 @@ fn create_compiler_snapshot(
}))
// specifiers come across as `asset:///lib.{lib_name}.d.ts` and we need to
// parse out just the name so we can lookup the asset.
} else if let Some(caps) = re_asset.captures(&v.specifier) {
} else if let Some(caps) = re_asset.captures(&args.specifier) {
if let Some(lib) = caps.get(1).map(|m| m.as_str()) {
// if it comes from an op crate, we were supplied with the path to the
// file.
Expand All @@ -204,13 +209,13 @@ fn create_compiler_snapshot(
} else {
Err(custom_error(
"InvalidSpecifier",
format!("An invalid specifier was requested: {}", v.specifier),
format!("An invalid specifier was requested: {}", args.specifier),
))
}
} else {
Err(custom_error(
"InvalidSpecifier",
format!("An invalid specifier was requested: {}", v.specifier),
format!("An invalid specifier was requested: {}", args.specifier),
))
}
}),
Expand Down
Loading