1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -05:00

fix(cli/module_graph): Set useDefineForClassFields to true (#9774)

Fixes #9773
This commit is contained in:
Nayeem Rahman 2021-03-14 22:19:27 +00:00 committed by GitHub
parent 7286eea75c
commit c4709834b3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 18 additions and 0 deletions

View file

@ -314,6 +314,7 @@ impl Inner {
"noEmit": true, "noEmit": true,
"strict": true, "strict": true,
"target": "esnext", "target": "esnext",
"useDefineForClassFields": true,
})); }));
let (maybe_config, maybe_root_uri) = { let (maybe_config, maybe_root_uri) = {
let config = &self.config; let config = &self.config;

View file

@ -809,6 +809,7 @@ impl Graph {
"strict": true, "strict": true,
"target": "esnext", "target": "esnext",
"tsBuildInfoFile": "deno:///.tsbuildinfo", "tsBuildInfoFile": "deno:///.tsbuildinfo",
"useDefineForClassFields": true,
})); }));
if options.emit { if options.emit {
config.merge(&json!({ config.merge(&json!({
@ -954,6 +955,7 @@ impl Graph {
"module": "esnext", "module": "esnext",
"strict": true, "strict": true,
"target": "esnext", "target": "esnext",
"useDefineForClassFields": true,
})); }));
let opts = match options.bundle_type { let opts = match options.bundle_type {
BundleType::Esm | BundleType::Iife => json!({ BundleType::Esm | BundleType::Iife => json!({

View file

@ -0,0 +1,4 @@
class A {
b = this.a;
constructor(public a: unknown) {}
}

View file

@ -0,0 +1,4 @@
[WILDCARD]error: TS2729 [ERROR]: Property 'a' is used before its initialization.
b = this.a;
^
[WILDCARD]

View file

@ -2841,6 +2841,12 @@ console.log("finish");
output: "087_no_check_imports_not_used_as_values.ts.out", output: "087_no_check_imports_not_used_as_values.ts.out",
}); });
itest!(_088_use_define_for_class_fields {
args: "run 088_use_define_for_class_fields.ts",
output: "088_use_define_for_class_fields.ts.out",
exit_code: 1,
});
itest!(js_import_detect { itest!(js_import_detect {
args: "run --quiet --reload js_import_detect.ts", args: "run --quiet --reload js_import_detect.ts",
output: "js_import_detect.ts.out", output: "js_import_detect.ts.out",

View file

@ -130,6 +130,7 @@ pub const IGNORED_RUNTIME_COMPILER_OPTIONS: &[&str] = &[
"traceResolution", "traceResolution",
"tsBuildInfoFile", "tsBuildInfoFile",
"typeRoots", "typeRoots",
"useDefineForClassFields",
"version", "version",
"watch", "watch",
]; ];