From b9c8b6be03bd9da1711ffbcc9db0835069de4e55 Mon Sep 17 00:00:00 2001 From: Jesse Jafa Date: Mon, 12 Jun 2023 16:32:11 +0300 Subject: [PATCH 01/40] fix: Allow `"false" | "true"` for a bool in template literal types (#1047) --- .../src/analyzer/assign/mod.rs | 2 - .../src/analyzer/assign/tpl.rs | 46 ++++++++++++++++++- ...mplateLiteralTypesPatterns.error-diff.json | 3 +- ...plateLiteralTypesPatterns.stats.rust-debug | 4 +- .../tests/tsc-stats.rust-debug | 4 +- 5 files changed, 49 insertions(+), 10 deletions(-) diff --git a/crates/stc_ts_file_analyzer/src/analyzer/assign/mod.rs b/crates/stc_ts_file_analyzer/src/analyzer/assign/mod.rs index 888bb721c0..81f4436dea 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/assign/mod.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/assign/mod.rs @@ -551,7 +551,6 @@ impl Analyzer<'_, '_> { }, )? .into_owned(); - return Ok(Cow::Owned(ty)); } _ => {} @@ -580,7 +579,6 @@ impl Analyzer<'_, '_> { let _stack = stack::track(opts.span)?; data.dejavu.push((left.clone(), right.clone())); - let res = self.assign_without_wrapping(data, left, right, opts).with_context(|| { // let l = force_dump_type_as_string(left); diff --git a/crates/stc_ts_file_analyzer/src/analyzer/assign/tpl.rs b/crates/stc_ts_file_analyzer/src/analyzer/assign/tpl.rs index bc02f629a3..46025c68de 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/assign/tpl.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/assign/tpl.rs @@ -2,7 +2,7 @@ use stc_ts_ast_rnode::RTsLit; use stc_ts_errors::{debug::force_dump_type_as_string, ErrorKind}; -use stc_ts_types::{IntrinsicKind, LitType, StringMapping, TplType, Type}; +use stc_ts_types::{IntrinsicKind, KeywordType, LitType, StringMapping, TplType, Type}; use stc_utils::dev_span; use swc_common::{Span, TypeEq}; use swc_ecma_ast::TsKeywordTypeKind; @@ -76,7 +76,49 @@ impl Analyzer<'_, '_> { // TODO: Check for `source` match &*value.value { - "true" | "false" | "null" | "undefined" => return Ok(true), + "false" | "true" => { + if let Type::Keyword(KeywordType { + kind: TsKeywordTypeKind::TsBooleanKeyword, + .. + }) = &target.normalize() + { + return Ok(true); + } + if let Type::Union(u) = &target.normalize() { + if u.types.iter().any(|x| x.is_bool()) { + return Ok(true); + } + } + } + "null" => { + if let Type::Keyword(KeywordType { + kind: TsKeywordTypeKind::TsNullKeyword, + .. + }) = &target.normalize() + { + return Ok(true); + } + if let Type::Union(u) = &target.normalize() { + if u.types.iter().any(|x| x.is_null()) { + return Ok(true); + } + } + } + "undefined" => { + if let Type::Keyword(KeywordType { + kind: TsKeywordTypeKind::TsUndefinedKeyword, + .. + }) = &target.normalize() + { + return Ok(true); + } + + if let Type::Union(u) = &target.normalize() { + if u.types.iter().any(|x| x.is_undefined()) { + return Ok(true); + } + } + } _ => {} } diff --git a/crates/stc_ts_type_checker/tests/conformance/types/literal/templateLiteralTypesPatterns.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/types/literal/templateLiteralTypesPatterns.error-diff.json index 3cac5ec3ca..0c61d21003 100644 --- a/crates/stc_ts_type_checker/tests/conformance/types/literal/templateLiteralTypesPatterns.error-diff.json +++ b/crates/stc_ts_type_checker/tests/conformance/types/literal/templateLiteralTypesPatterns.error-diff.json @@ -1,10 +1,9 @@ { "required_errors": { - "TS2345": 2 + "TS2345": 1 }, "required_error_lines": { "TS2345": [ - 37, 105 ] }, diff --git a/crates/stc_ts_type_checker/tests/conformance/types/literal/templateLiteralTypesPatterns.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/types/literal/templateLiteralTypesPatterns.stats.rust-debug index 9ef6511d90..35362d0605 100644 --- a/crates/stc_ts_type_checker/tests/conformance/types/literal/templateLiteralTypesPatterns.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/types/literal/templateLiteralTypesPatterns.stats.rust-debug @@ -1,6 +1,6 @@ Stats { - required_error: 2, - matched_error: 55, + required_error: 1, + matched_error: 56, extra_error: 1, panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug index 3237e92857..e72573e2b1 100644 --- a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug @@ -1,6 +1,6 @@ Stats { - required_error: 3535, - matched_error: 6500, + required_error: 3534, + matched_error: 6501, extra_error: 771, panic: 74, } \ No newline at end of file From 7e9d57f421143a932390e31b245805bb0f8ebe94 Mon Sep 17 00:00:00 2001 From: Togami <62130798+togami2864@users.noreply.github.com> Date: Wed, 14 Jun 2023 12:02:53 +0900 Subject: [PATCH 02/40] feat: Support `noUncheckedIndexedAccess` (#1020) --- crates/stc_ts_env/src/lib.rs | 2 + .../src/analyzer/expr/mod.rs | 17 +++++++++ crates/stc_ts_testing/src/conformance.rs | 3 ++ .../noUncheckedIndexedAccess.error-diff.json | 37 +++++++------------ .../noUncheckedIndexedAccess.stats.rust-debug | 6 +-- .../tests/tsc-stats.rust-debug | 4 +- 6 files changed, 41 insertions(+), 28 deletions(-) diff --git a/crates/stc_ts_env/src/lib.rs b/crates/stc_ts_env/src/lib.rs index 523a22b64e..ca5196fb7c 100644 --- a/crates/stc_ts_env/src/lib.rs +++ b/crates/stc_ts_env/src/lib.rs @@ -196,6 +196,7 @@ pub struct Rule { pub allow_unused_labels: bool, pub no_fallthrough_cases_in_switch: bool, pub no_implicit_returns: bool, + pub no_unchecked_indexed_access: bool, pub suppress_excess_property_errors: bool, pub suppress_implicit_any_index_errors: bool, pub no_strict_generic_checks: bool, @@ -222,6 +223,7 @@ impl From<&CompilerOptions> for Rule { allow_unused_labels: v.allow_unused_labels.unwrap_or_default(), no_fallthrough_cases_in_switch: v.no_fallthrough_cases_in_switch.unwrap_or_default(), no_implicit_returns: v.no_implicit_returns.unwrap_or_default(), + no_unchecked_indexed_access: false, suppress_excess_property_errors: v.suppress_excess_property_errors.unwrap_or_default(), suppress_implicit_any_index_errors: v.suppress_implicit_any_index_errors.unwrap_or_default(), no_strict_generic_checks: v.no_strict_generic_checks.unwrap_or_default(), diff --git a/crates/stc_ts_file_analyzer/src/analyzer/expr/mod.rs b/crates/stc_ts_file_analyzer/src/analyzer/expr/mod.rs index e61b3fbce4..a3ab044822 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/expr/mod.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/expr/mod.rs @@ -4355,6 +4355,23 @@ impl Analyzer<'_, '_> { if should_be_optional && include_optional_chaining_undefined { Ok(ty.union_with_undefined(span)) } else { + if self.rule().no_unchecked_indexed_access { + let indexed_access = match obj_ty.normalize() { + Type::IndexedAccessType(_) | Type::Array(_) => true, + Type::TypeLit(ty) => ty.members.iter().any(|t| matches!(t, TypeElement::Index(ty))), + _ => false, + }; + + let field_is_symbol = match &prop { + Key::Computed(key) => key.ty.is_symbol_like(), + _ => false, + }; + + if !field_is_symbol && indexed_access { + return Ok(ty.union_with_undefined(span)); + } + } + if !self.config.is_builtin { debug_assert_ne!(ty.span(), DUMMY_SP); } diff --git a/crates/stc_ts_testing/src/conformance.rs b/crates/stc_ts_testing/src/conformance.rs index 438f806785..de8111f23f 100644 --- a/crates/stc_ts_testing/src/conformance.rs +++ b/crates/stc_ts_testing/src/conformance.rs @@ -190,6 +190,9 @@ pub fn parse_conformance_test(file_name: &Path) -> Result> { } else if s.starts_with("noImplicitReturns:") { let v = s["noImplicitReturns:".len()..].trim().parse().unwrap(); rule.no_implicit_returns = v; + } else if s.starts_with("noUncheckedIndexedAccess:") { + let v = s["noUncheckedIndexedAccess:".len()..].trim().parse().unwrap(); + rule.no_unchecked_indexed_access = v; } else if s.starts_with("declaration") { } else if s.starts_with("stripInternal:") { // TODO(kdy1): Handle diff --git a/crates/stc_ts_type_checker/tests/conformance/pedantic/noUncheckedIndexedAccess.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/pedantic/noUncheckedIndexedAccess.error-diff.json index 8816dfb544..e32cc04e8c 100644 --- a/crates/stc_ts_type_checker/tests/conformance/pedantic/noUncheckedIndexedAccess.error-diff.json +++ b/crates/stc_ts_type_checker/tests/conformance/pedantic/noUncheckedIndexedAccess.error-diff.json @@ -1,38 +1,29 @@ { "required_errors": { "TS2344": 1, - "TS2322": 23 + "TS2322": 8 }, "required_error_lines": { "TS2344": [ 6 ], "TS2322": [ - 15, - 16, - 17, - 18, - 19, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 49, - 50, - 51, - 52, - 53, + 41, + 42, + 43, + 44, 58, - 66, 82, 93, - 102 + 101 ] }, - "extra_errors": {}, - "extra_error_lines": {} + "extra_errors": { + "TS2322": 1 + }, + "extra_error_lines": { + "TS2322": [ + 99 + ] + } } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/pedantic/noUncheckedIndexedAccess.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/pedantic/noUncheckedIndexedAccess.stats.rust-debug index 765d7d64d0..520165a61d 100644 --- a/crates/stc_ts_type_checker/tests/conformance/pedantic/noUncheckedIndexedAccess.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/pedantic/noUncheckedIndexedAccess.stats.rust-debug @@ -1,6 +1,6 @@ Stats { - required_error: 24, - matched_error: 7, - extra_error: 0, + required_error: 9, + matched_error: 22, + extra_error: 1, panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug index e72573e2b1..992227ddc9 100644 --- a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug @@ -1,6 +1,6 @@ Stats { - required_error: 3534, - matched_error: 6501, + required_error: 3519, + matched_error: 6516, extra_error: 771, panic: 74, } \ No newline at end of file From 0b12a85b6eee5ea599ac19da7a1d38bb44e9c6e1 Mon Sep 17 00:00:00 2001 From: Jesse Jafa Date: Mon, 19 Jun 2023 04:58:54 +0300 Subject: [PATCH 03/40] fix: Consider a template literal with no types as a string (#1049) --- .../stc_ts_file_analyzer/src/analyzer/assign/tpl.rs | 12 ++++++++++++ .../tests/pass-only/assign/tpl/1.ts | 12 ++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 crates/stc_ts_file_analyzer/tests/pass-only/assign/tpl/1.ts diff --git a/crates/stc_ts_file_analyzer/src/analyzer/assign/tpl.rs b/crates/stc_ts_file_analyzer/src/analyzer/assign/tpl.rs index 46025c68de..c067241822 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/assign/tpl.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/assign/tpl.rs @@ -134,9 +134,21 @@ impl Analyzer<'_, '_> { } Type::Tpl(source) => { + if source.quasis.len() == 1 && source.types.is_empty() { + let ty = Type::Lit(LitType { + span, + lit: RTsLit::Str(source.quasis[0].clone().value.into()), + metadata: Default::default(), + tracker: Default::default(), + }); + + return self.is_valid_type_for_tpl_lit_placeholder(span, &ty, target); + } + if source.quasis.len() == 2 && source.quasis[0].value == "" && source.quasis[1].value == "" { // TODO(kdy1): Return `Ok(self.is_type_assignable_to(span, &source.types[0], // target))` instead + if self.is_type_assignable_to(span, &source.types[0], target) { return Ok(true); } diff --git a/crates/stc_ts_file_analyzer/tests/pass-only/assign/tpl/1.ts b/crates/stc_ts_file_analyzer/tests/pass-only/assign/tpl/1.ts new file mode 100644 index 0000000000..4fb4534218 --- /dev/null +++ b/crates/stc_ts_file_analyzer/tests/pass-only/assign/tpl/1.ts @@ -0,0 +1,12 @@ +function f1(a: `100`) { + let x: `${number}`; + x = `${a}`; +} +function f2(a: `true`) { + let x: `${boolean}`; + x = `${a}`; +} +function f3(a: `false`) { + let x: `${boolean}`; + x = `${a}`; +} From 693cf5a891c5580542811b906616f0c15d0dd0fc Mon Sep 17 00:00:00 2001 From: Jesse Jafa Date: Mon, 19 Jun 2023 09:46:23 +0300 Subject: [PATCH 04/40] fix: Parse numeric strings in template literals as a bigint (#1050) --- .../src/analyzer/tsc_helper.rs | 14 +++++++++++++- .../templateLiteralTypesPatterns.error-diff.json | 10 ++-------- .../templateLiteralTypesPatterns.stats.rust-debug | 4 ++-- .../stc_ts_type_checker/tests/tsc-stats.rust-debug | 4 ++-- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/crates/stc_ts_file_analyzer/src/analyzer/tsc_helper.rs b/crates/stc_ts_file_analyzer/src/analyzer/tsc_helper.rs index 2585afe6c2..c01ccd9693 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/tsc_helper.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/tsc_helper.rs @@ -72,7 +72,19 @@ impl Analyzer<'_, '_> { } else if s.starts_with("0b") || s.starts_with("0B") { BigInt::parse_bytes(s[2..].as_bytes(), 2) } else { - s.parse::().ok() + let unsigned_literal = s.strip_prefix('-').unwrap_or(s); + + // numeric string starting with more than one 0 are incorrect + if unsigned_literal.starts_with("00") { + None + } + // BigInt strings only accepts numbers + // 1000n or 1_000n are both considered invalid + else if unsigned_literal.chars().all(|c| c.is_ascii_digit()) { + s.parse::().ok() + } else { + None + } }; if let Some(v) = v { !round_trip_only || v.to_string() == s diff --git a/crates/stc_ts_type_checker/tests/conformance/types/literal/templateLiteralTypesPatterns.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/types/literal/templateLiteralTypesPatterns.error-diff.json index 0c61d21003..5b90eaff2b 100644 --- a/crates/stc_ts_type_checker/tests/conformance/types/literal/templateLiteralTypesPatterns.error-diff.json +++ b/crates/stc_ts_type_checker/tests/conformance/types/literal/templateLiteralTypesPatterns.error-diff.json @@ -1,12 +1,6 @@ { - "required_errors": { - "TS2345": 1 - }, - "required_error_lines": { - "TS2345": [ - 105 - ] - }, + "required_errors": {}, + "required_error_lines": {}, "extra_errors": { "TS2339": 1 }, diff --git a/crates/stc_ts_type_checker/tests/conformance/types/literal/templateLiteralTypesPatterns.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/types/literal/templateLiteralTypesPatterns.stats.rust-debug index 35362d0605..1a1a52a6c1 100644 --- a/crates/stc_ts_type_checker/tests/conformance/types/literal/templateLiteralTypesPatterns.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/types/literal/templateLiteralTypesPatterns.stats.rust-debug @@ -1,6 +1,6 @@ Stats { - required_error: 1, - matched_error: 56, + required_error: 0, + matched_error: 57, extra_error: 1, panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug index 992227ddc9..16216098c2 100644 --- a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug @@ -1,6 +1,6 @@ Stats { - required_error: 3519, - matched_error: 6516, + required_error: 3518, + matched_error: 6517, extra_error: 771, panic: 74, } \ No newline at end of file From 31db61a7e92759df26c65d3e0d8b5c68627bf9ac Mon Sep 17 00:00:00 2001 From: padorang684 <80400772+padorang684@users.noreply.github.com> Date: Mon, 3 Jul 2023 15:08:11 +1000 Subject: [PATCH 05/40] fix: Improve logic for the order of statement evaluation (#1052) --- crates/stc_ts_ordering/src/calc.rs | 4 +++- .../conformance/types/rest/objectRest.error-diff.json | 11 ++--------- .../types/rest/objectRest.stats.rust-debug | 2 +- crates/stc_ts_type_checker/tests/tsc-stats.rust-debug | 2 +- 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/crates/stc_ts_ordering/src/calc.rs b/crates/stc_ts_ordering/src/calc.rs index 1a6b9527cc..597341ca2d 100644 --- a/crates/stc_ts_ordering/src/calc.rs +++ b/crates/stc_ts_ordering/src/calc.rs @@ -49,7 +49,9 @@ where let deps = self.declared_by.get(used); if let Some(deps) = deps { - buf.extend(deps.iter()); + if let Some(min) = deps.iter().min() { + buf.push(*min) + } } } diff --git a/crates/stc_ts_type_checker/tests/conformance/types/rest/objectRest.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/types/rest/objectRest.error-diff.json index 8fa0b736df..9ecbb9fde6 100644 --- a/crates/stc_ts_type_checker/tests/conformance/types/rest/objectRest.error-diff.json +++ b/crates/stc_ts_type_checker/tests/conformance/types/rest/objectRest.error-diff.json @@ -18,13 +18,6 @@ 45 ] }, - "extra_errors": { - "TS2304": 2 - }, - "extra_error_lines": { - "TS2304": [ - 44, - 44 - ] - } + "extra_errors": {}, + "extra_error_lines": {} } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/types/rest/objectRest.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/types/rest/objectRest.stats.rust-debug index c4de7b3acb..e1dc08a8cb 100644 --- a/crates/stc_ts_type_checker/tests/conformance/types/rest/objectRest.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/types/rest/objectRest.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 6, matched_error: 0, - extra_error: 2, + extra_error: 0, panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug index 16216098c2..9ba60c1e6e 100644 --- a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 3518, matched_error: 6517, - extra_error: 771, + extra_error: 769, panic: 74, } \ No newline at end of file From dcacac1a8ebcd39b9b749b55d2e4ee4951ce5139 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=98=A4=EB=B3=91=EC=A7=84?= <64676070+sunrabbit123@users.noreply.github.com> Date: Mon, 7 Aug 2023 20:39:19 +0900 Subject: [PATCH 06/40] feat: Validate inferred generic types (#1053) --- .../src/analyzer/generic/expander.rs | 7 ++--- .../src/analyzer/generic/mod.rs | 31 ++++++++++++++++++- .../overloadResolution.error-diff.json | 4 --- .../overloadResolution.stats.rust-debug | 4 +-- ...loadResolutionConstructors.error-diff.json | 4 --- ...oadResolutionConstructors.stats.rust-debug | 4 +-- ...ntInferenceWithConstraints.error-diff.json | 8 ----- ...tInferenceWithConstraints.stats.rust-debug | 4 +-- .../conditionalTypes1.error-diff.json | 6 ++-- .../mapped/mappedTypeErrors.error-diff.json | 4 +-- .../mapped/mappedTypeErrors.stats.rust-debug | 4 +-- .../nonPrimitiveInGeneric.error-diff.json | 14 --------- .../nonPrimitiveInGeneric.stats.rust-debug | 4 +-- .../nonPrimitiveStrictNull.error-diff.json | 8 +---- .../nonPrimitiveStrictNull.stats.rust-debug | 4 +-- .../genericRestParameters1.error-diff.json | 4 --- .../genericRestParameters1.stats.rust-debug | 4 +-- ...ircularTypeofWithVarOrFunc.error-diff.json | 13 +++++--- .../tests/tsc-stats.rust-debug | 4 +-- 19 files changed, 61 insertions(+), 74 deletions(-) delete mode 100644 crates/stc_ts_type_checker/tests/conformance/types/nonPrimitive/nonPrimitiveInGeneric.error-diff.json diff --git a/crates/stc_ts_file_analyzer/src/analyzer/generic/expander.rs b/crates/stc_ts_file_analyzer/src/analyzer/generic/expander.rs index 1ed5bc8ba2..6502f93401 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/generic/expander.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/generic/expander.rs @@ -6,7 +6,7 @@ use stc_ts_generics::{ ExpandGenericOpts, }; use stc_ts_type_ops::Fix; -use stc_ts_types::{Id, Interface, KeywordType, Readonly, TypeElement, TypeParam, TypeParamDecl, TypeParamInstantiation}; +use stc_ts_types::{Id, Index, Interface, KeywordType, Readonly, TypeElement, TypeParam, TypeParamDecl, TypeParamInstantiation}; use stc_utils::{cache::Freeze, dev_span, ext::SpanExt}; use swc_common::{Span, Spanned, TypeEq}; use swc_ecma_ast::*; @@ -241,10 +241,7 @@ impl Analyzer<'_, '_> { return self.extends(span, child, &parent, opts); } - _ => {} - } - - match parent { + Type::Index(Index { ty, .. }) if ty.is_any() && child.is_index() => return Some(true), Type::Keyword(KeywordType { kind: TsKeywordTypeKind::TsNullKeyword, .. diff --git a/crates/stc_ts_file_analyzer/src/analyzer/generic/mod.rs b/crates/stc_ts_file_analyzer/src/analyzer/generic/mod.rs index c2191f369e..17c9398108 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/generic/mod.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/generic/mod.rs @@ -6,7 +6,7 @@ use rnode::{Fold, FoldWith, VisitMut, VisitMutWith, VisitWith}; use stc_ts_ast_rnode::{RBindingIdent, RIdent, RNumber, RPat, RTsEntityName, RTsLit}; use stc_ts_errors::{ debug::{dump_type_as_string, force_dump_type_as_string, print_backtrace, print_type}, - DebugExt, + DebugExt, ErrorKind, }; use stc_ts_generics::{ expander::InferTypeResult, @@ -128,6 +128,11 @@ impl Analyzer<'_, '_> { if let Some(base) = base { for (param, type_param) in base.params.iter().zip(type_params) { info!("User provided `{:?} = {:?}`", type_param.name, param.clone()); + + if self.validate_generic_argument(span, param, type_param) { + break; + } + inferred.type_params.insert( type_param.name.clone(), InferenceInfo { @@ -2376,6 +2381,30 @@ impl Analyzer<'_, '_> { Ok(()) } + + /// ```ts + /// type A = 1; + /// A; + /// ``` + fn validate_generic_argument(&mut self, span: Span, param: &Type, type_param: &TypeParam) -> bool { + if let Some(tp) = &type_param.constraint { + if !param.span().is_dummy() && !param.is_type_param() { + if matches!(self.extends(span, param, tp, Default::default()), Some(false)) { + self.storage.report( + ErrorKind::NotSatisfyConstraint { + span: param.span(), + left: tp.clone(), + right: Box::new(param.clone()), + } + .into(), + ); + return true; + } + } + } + + false + } } fn array_elem_type(t: &Type) -> Option<&Type> { diff --git a/crates/stc_ts_type_checker/tests/conformance/expressions/functionCalls/overloadResolution.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/expressions/functionCalls/overloadResolution.error-diff.json index 7b21137702..1f9b4d34fc 100644 --- a/crates/stc_ts_type_checker/tests/conformance/expressions/functionCalls/overloadResolution.error-diff.json +++ b/crates/stc_ts_type_checker/tests/conformance/expressions/functionCalls/overloadResolution.error-diff.json @@ -1,12 +1,8 @@ { "required_errors": { - "TS2344": 1, "TS2339": 1 }, "required_error_lines": { - "TS2344": [ - 81 - ], "TS2339": [ 91 ] diff --git a/crates/stc_ts_type_checker/tests/conformance/expressions/functionCalls/overloadResolution.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/expressions/functionCalls/overloadResolution.stats.rust-debug index 13ac66ffd7..4074730ba8 100644 --- a/crates/stc_ts_type_checker/tests/conformance/expressions/functionCalls/overloadResolution.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/expressions/functionCalls/overloadResolution.stats.rust-debug @@ -1,6 +1,6 @@ Stats { - required_error: 2, - matched_error: 8, + required_error: 1, + matched_error: 9, extra_error: 0, panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/expressions/functionCalls/overloadResolutionConstructors.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/expressions/functionCalls/overloadResolutionConstructors.error-diff.json index 87273b3f0a..07a5c81c04 100644 --- a/crates/stc_ts_type_checker/tests/conformance/expressions/functionCalls/overloadResolutionConstructors.error-diff.json +++ b/crates/stc_ts_type_checker/tests/conformance/expressions/functionCalls/overloadResolutionConstructors.error-diff.json @@ -1,12 +1,8 @@ { "required_errors": { - "TS2344": 1, "TS2339": 1 }, "required_error_lines": { - "TS2344": [ - 88 - ], "TS2339": [ 100 ] diff --git a/crates/stc_ts_type_checker/tests/conformance/expressions/functionCalls/overloadResolutionConstructors.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/expressions/functionCalls/overloadResolutionConstructors.stats.rust-debug index 13ac66ffd7..4074730ba8 100644 --- a/crates/stc_ts_type_checker/tests/conformance/expressions/functionCalls/overloadResolutionConstructors.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/expressions/functionCalls/overloadResolutionConstructors.stats.rust-debug @@ -1,6 +1,6 @@ Stats { - required_error: 2, - matched_error: 8, + required_error: 1, + matched_error: 9, extra_error: 0, panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.error-diff.json index fca0f71b2b..ae93ce38eb 100644 --- a/crates/stc_ts_type_checker/tests/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.error-diff.json +++ b/crates/stc_ts_type_checker/tests/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.error-diff.json @@ -1,18 +1,10 @@ { "required_errors": { - "TS2344": 5, "TS2322": 1, "TS2403": 1, "TS2345": 1 }, "required_error_lines": { - "TS2344": [ - 11, - 16, - 17, - 35, - 49 - ], "TS2322": [ 33 ], diff --git a/crates/stc_ts_type_checker/tests/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.stats.rust-debug index 66cf8a0936..c6c8a39c7a 100644 --- a/crates/stc_ts_type_checker/tests/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.stats.rust-debug @@ -1,6 +1,6 @@ Stats { - required_error: 8, - matched_error: 7, + required_error: 3, + matched_error: 12, extra_error: 2, panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/types/conditional/conditionalTypes1.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/types/conditional/conditionalTypes1.error-diff.json index d1504430e1..539bf5b803 100644 --- a/crates/stc_ts_type_checker/tests/conformance/types/conditional/conditionalTypes1.error-diff.json +++ b/crates/stc_ts_type_checker/tests/conformance/types/conditional/conditionalTypes1.error-diff.json @@ -31,14 +31,14 @@ }, "extra_errors": { "TS2322": 1, - "TS0": 1 + "TS2344": 1 }, "extra_error_lines": { "TS2322": [ 21 ], - "TS0": [ - 323 + "TS2344": [ + 317 ] } } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/types/mapped/mappedTypeErrors.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/types/mapped/mappedTypeErrors.error-diff.json index 60c8f90643..57b15f4e3d 100644 --- a/crates/stc_ts_type_checker/tests/conformance/types/mapped/mappedTypeErrors.error-diff.json +++ b/crates/stc_ts_type_checker/tests/conformance/types/mapped/mappedTypeErrors.error-diff.json @@ -2,7 +2,7 @@ "required_errors": { "TS2313": 1, "TS2322": 4, - "TS2344": 7, + "TS2344": 5, "TS2403": 4, "TS2345": 4, "TS2536": 1, @@ -19,11 +19,9 @@ 139 ], "TS2344": [ - 25, 28, 29, 31, - 33, 36, 40 ], diff --git a/crates/stc_ts_type_checker/tests/conformance/types/mapped/mappedTypeErrors.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/types/mapped/mappedTypeErrors.stats.rust-debug index 3dcce7e65b..0333ddafe9 100644 --- a/crates/stc_ts_type_checker/tests/conformance/types/mapped/mappedTypeErrors.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/types/mapped/mappedTypeErrors.stats.rust-debug @@ -1,6 +1,6 @@ Stats { - required_error: 23, - matched_error: 4, + required_error: 21, + matched_error: 6, extra_error: 16, panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/types/nonPrimitive/nonPrimitiveInGeneric.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/types/nonPrimitive/nonPrimitiveInGeneric.error-diff.json deleted file mode 100644 index 140e78e888..0000000000 --- a/crates/stc_ts_type_checker/tests/conformance/types/nonPrimitive/nonPrimitiveInGeneric.error-diff.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "required_errors": { - "TS2344": 3 - }, - "required_error_lines": { - "TS2344": [ - 26, - 27, - 35 - ] - }, - "extra_errors": {}, - "extra_error_lines": {} -} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/types/nonPrimitive/nonPrimitiveInGeneric.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/types/nonPrimitive/nonPrimitiveInGeneric.stats.rust-debug index 990eab48bc..2733dbe65c 100644 --- a/crates/stc_ts_type_checker/tests/conformance/types/nonPrimitive/nonPrimitiveInGeneric.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/types/nonPrimitive/nonPrimitiveInGeneric.stats.rust-debug @@ -1,6 +1,6 @@ Stats { - required_error: 3, - matched_error: 5, + required_error: 0, + matched_error: 8, extra_error: 0, panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/types/nonPrimitive/nonPrimitiveStrictNull.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/types/nonPrimitive/nonPrimitiveStrictNull.error-diff.json index 9719e8367f..be19e16974 100644 --- a/crates/stc_ts_type_checker/tests/conformance/types/nonPrimitive/nonPrimitiveStrictNull.error-diff.json +++ b/crates/stc_ts_type_checker/tests/conformance/types/nonPrimitive/nonPrimitiveStrictNull.error-diff.json @@ -4,8 +4,7 @@ "TS2339": 1, "TS2531": 3, "TS2532": 3, - "TS2533": 1, - "TS2344": 3 + "TS2533": 1 }, "required_error_lines": { "TS2454": [ @@ -26,11 +25,6 @@ ], "TS2533": [ 34 - ], - "TS2344": [ - 53, - 54, - 55 ] }, "extra_errors": {}, diff --git a/crates/stc_ts_type_checker/tests/conformance/types/nonPrimitive/nonPrimitiveStrictNull.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/types/nonPrimitive/nonPrimitiveStrictNull.stats.rust-debug index 53a400fda3..0eab5e3d3e 100644 --- a/crates/stc_ts_type_checker/tests/conformance/types/nonPrimitive/nonPrimitiveStrictNull.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/types/nonPrimitive/nonPrimitiveStrictNull.stats.rust-debug @@ -1,6 +1,6 @@ Stats { - required_error: 12, - matched_error: 6, + required_error: 9, + matched_error: 9, extra_error: 0, panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/types/rest/genericRestParameters1.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/types/rest/genericRestParameters1.error-diff.json index 5c01e090e2..4400a4b18d 100644 --- a/crates/stc_ts_type_checker/tests/conformance/types/rest/genericRestParameters1.error-diff.json +++ b/crates/stc_ts_type_checker/tests/conformance/types/rest/genericRestParameters1.error-diff.json @@ -1,12 +1,8 @@ { "required_errors": { - "TS2344": 1, "TS2322": 1 }, "required_error_lines": { - "TS2344": [ - 138 - ], "TS2322": [ 167 ] diff --git a/crates/stc_ts_type_checker/tests/conformance/types/rest/genericRestParameters1.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/types/rest/genericRestParameters1.stats.rust-debug index e47bce7f3c..a5c3750ce9 100644 --- a/crates/stc_ts_type_checker/tests/conformance/types/rest/genericRestParameters1.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/types/rest/genericRestParameters1.stats.rust-debug @@ -1,6 +1,6 @@ Stats { - required_error: 2, - matched_error: 0, + required_error: 1, + matched_error: 1, extra_error: 1, panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarOrFunc.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarOrFunc.error-diff.json index 66fcb3c563..438aeb2ede 100644 --- a/crates/stc_ts_type_checker/tests/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarOrFunc.error-diff.json +++ b/crates/stc_ts_type_checker/tests/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarOrFunc.error-diff.json @@ -23,21 +23,24 @@ ] }, "extra_errors": { - "TS2304": 5, - "TS2322": 3 + "TS2304": 3, + "TS2322": 3, + "TS2344": 2 }, "extra_error_lines": { "TS2304": [ 1, 5, - 9, - 18, - 25 + 9 ], "TS2322": [ 7, 20, 26 + ], + "TS2344": [ + 18, + 25 ] } } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug index 9ba60c1e6e..b72223af99 100644 --- a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug @@ -1,6 +1,6 @@ Stats { - required_error: 3518, - matched_error: 6517, + required_error: 3502, + matched_error: 6533, extra_error: 769, panic: 74, } \ No newline at end of file From 865e977d19d9b5d10bc6b3f4e87d47c2ec102179 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Tue, 8 Aug 2023 05:47:08 +0900 Subject: [PATCH 07/40] chore(ci): Enable publish action for more branches (#1057) --- .github/workflows/publish.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 58059eb60c..f289d24cb8 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -18,7 +18,7 @@ on: jobs: build: - if: ${{ startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/ci' }} + if: ${{ startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/heads/ci') }} strategy: fail-fast: false matrix: @@ -187,7 +187,7 @@ jobs: stc* if-no-files-found: error test-macOS-windows-binding: - if: ${{ startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/ci' }} + if: ${{ startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/heads/ci') }} name: Test bindings on ${{ matrix.settings.target }} - node@${{ matrix.node }} needs: - build @@ -229,7 +229,7 @@ jobs: - name: Test bindings run: yarn test test-linux-x64-gnu-binding: - if: ${{ startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/ci' }} + if: ${{ startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/heads/ci') }} name: Test bindings on Linux-x64-gnu - node@${{ matrix.node }} needs: - build @@ -268,7 +268,7 @@ jobs: - name: Test bindings run: docker run --rm -v $(pwd):/stc -w /stc node:${{ matrix.node }}-slim env yarn test test-linux-x64-musl-binding: - if: ${{ startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/ci' }} + if: ${{ startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/heads/ci') }} name: Test bindings on x86_64-unknown-linux-musl - node@${{ matrix.node }} needs: - build @@ -307,7 +307,7 @@ jobs: - name: Test bindings run: docker run --rm -v $(pwd):/stc -w /stc node:${{ matrix.node }}-alpine env DISABLE_PLUGIN_E2E_TESTS=true yarn test test-linux-aarch64-musl-binding: - if: ${{ startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/ci' }} + if: ${{ startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/heads/ci') }} name: Test bindings on aarch64-unknown-linux-musl - node@${{ matrix.node }} needs: - build @@ -341,7 +341,7 @@ jobs: set -e apk add nodejs npm yarn test-linux-arm-gnueabihf-binding: - if: ${{ startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/ci' }} + if: ${{ startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/heads/ci') }} name: Test bindings on armv7-unknown-linux-gnueabihf - node@${{ matrix.node }} needs: - build @@ -453,7 +453,7 @@ jobs: NPM_TOKEN: ${{ secrets.NPM_TOKEN }} publish-wasm: - if: ${{ startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/ci' }} + if: ${{ startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/heads/ci') }} name: Publisg Wasm for ${{ matrix.target }} # needs: From 81792e8e9dcfd95c4e3e0b98001a8ec47e0af27c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=98=A4=EB=B3=91=EC=A7=84?= <64676070+sunrabbit123@users.noreply.github.com> Date: Wed, 9 Aug 2023 05:14:54 -0700 Subject: [PATCH 08/40] test: Add a test to the pass list (#1058) --- crates/stc_ts_type_checker/tests/conformance.pass.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/stc_ts_type_checker/tests/conformance.pass.txt b/crates/stc_ts_type_checker/tests/conformance.pass.txt index b3042bffa6..b3f30d3722 100644 --- a/crates/stc_ts_type_checker/tests/conformance.pass.txt +++ b/crates/stc_ts_type_checker/tests/conformance.pass.txt @@ -2427,6 +2427,7 @@ types/nonPrimitive/nonPrimitiveAndTypeVariables.ts types/nonPrimitive/nonPrimitiveAsProperty.ts types/nonPrimitive/nonPrimitiveAssignError.ts types/nonPrimitive/nonPrimitiveInFunction.ts +types/nonPrimitive/nonPrimitiveInGeneric.ts types/nonPrimitive/nonPrimitiveIndexingWithForIn.ts types/nonPrimitive/nonPrimitiveIndexingWithForInNoImplicitAny.ts types/nonPrimitive/nonPrimitiveRhsSideOfInExpression.ts From 9fe5d4312cc67dfe34268b0191b2c1b6b3d64ca9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=98=A4=EB=B3=91=EC=A7=84?= <64676070+sunrabbit123@users.noreply.github.com> Date: Wed, 9 Aug 2023 06:54:28 -0700 Subject: [PATCH 09/40] feat: Implement `keyof this` (#1059) **Description:** implement `keyof this` ```ts // @strict: true // @declaration: true type OldDiff = ( & { [P in T]: P; } & { [P in U]: never; } & { [x: string]: never; } )[T]; interface A { a: 'a'; } interface B1 extends A { b: 'b'; c: OldDiff; } type c1 = B1['c']; // 'c' | 'b' ``` --- .../src/analyzer/types/keyof.rs | 6 ++++++ .../src/analyzer/types/mod.rs | 14 ++++++++------ .../types/conditional/conditionalTypes1/4.ts | 16 ++++++++++++++++ .../conditionalTypes1.error-diff.json | 6 +----- .../conditionalTypes1.stats.rust-debug | 2 +- .../tests/tsc-stats.rust-debug | 2 +- 6 files changed, 33 insertions(+), 13 deletions(-) create mode 100644 crates/stc_ts_file_analyzer/tests/pass-only/conformance/types/conditional/conditionalTypes1/4.ts diff --git a/crates/stc_ts_file_analyzer/src/analyzer/types/keyof.rs b/crates/stc_ts_file_analyzer/src/analyzer/types/keyof.rs index 63bfd0336a..dd37d5205c 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/types/keyof.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/types/keyof.rs @@ -297,6 +297,12 @@ impl Analyzer<'_, '_> { .context("tried to get keys of Array (builtin)"); } + Type::This(this) => { + if let Some(ty) = self.scope.this().map(Cow::into_owned) { + return self.keyof(this.span, &ty); + } + } + Type::Interface(..) | Type::Enum(..) => { let ty = self .convert_type_to_type_lit(span, ty.freezed(), Default::default())? diff --git a/crates/stc_ts_file_analyzer/src/analyzer/types/mod.rs b/crates/stc_ts_file_analyzer/src/analyzer/types/mod.rs index 244a0ef204..90dba21dcf 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/types/mod.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/types/mod.rs @@ -578,12 +578,14 @@ impl Analyzer<'_, '_> { return Ok(ty); } - let ty = self - .normalize(span, Cow::Owned(prop_ty), opts) - .context("tried to normalize the type of property")? - .into_owned(); - - return Ok(Cow::Owned(ty)); + let prev_this = self.scope.this.take(); + self.scope.this = Some(*obj_ty); + let result = { + self.normalize(span, Cow::Owned(prop_ty), opts) + .context("tried to normalize the type of property") + }; + self.scope.this = prev_this; + return result; } // TODO(kdy1): diff --git a/crates/stc_ts_file_analyzer/tests/pass-only/conformance/types/conditional/conditionalTypes1/4.ts b/crates/stc_ts_file_analyzer/tests/pass-only/conformance/types/conditional/conditionalTypes1/4.ts new file mode 100644 index 0000000000..2d008c3e54 --- /dev/null +++ b/crates/stc_ts_file_analyzer/tests/pass-only/conformance/types/conditional/conditionalTypes1/4.ts @@ -0,0 +1,16 @@ +// @strict: true +// @declaration: true + +type OldDiff = ( + & { [P in T]: P; } + & { [P in U]: never; } + & { [x: string]: never; } +)[T]; +interface A { + a: 'a'; +} +interface B1 extends A { + b: 'b'; + c: OldDiff; +} +type c1 = B1['c']; // 'c' | 'b' \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/types/conditional/conditionalTypes1.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/types/conditional/conditionalTypes1.error-diff.json index 539bf5b803..b9748d69af 100644 --- a/crates/stc_ts_type_checker/tests/conformance/types/conditional/conditionalTypes1.error-diff.json +++ b/crates/stc_ts_type_checker/tests/conformance/types/conditional/conditionalTypes1.error-diff.json @@ -30,15 +30,11 @@ ] }, "extra_errors": { - "TS2322": 1, - "TS2344": 1 + "TS2322": 1 }, "extra_error_lines": { "TS2322": [ 21 - ], - "TS2344": [ - 317 ] } } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/types/conditional/conditionalTypes1.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/types/conditional/conditionalTypes1.stats.rust-debug index d84650c75c..5821a9121b 100644 --- a/crates/stc_ts_type_checker/tests/conformance/types/conditional/conditionalTypes1.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/types/conditional/conditionalTypes1.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 11, matched_error: 9, - extra_error: 2, + extra_error: 1, panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug index b72223af99..c1f1543a3a 100644 --- a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 3502, matched_error: 6533, - extra_error: 769, + extra_error: 768, panic: 74, } \ No newline at end of file From 9d957b449ee6f0b4902c2a1bad5d15caf66c51ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=98=A4=EB=B3=91=EC=A7=84?= <64676070+sunrabbit123@users.noreply.github.com> Date: Wed, 9 Aug 2023 08:00:24 -0700 Subject: [PATCH 10/40] feat: Implement `keyof` for enums (#1061) **Description:** ```ts // @strictNullChecks: true // @declaration: true enum E { A, B, C }; type K15 = keyof E; // "toString" | "toFixed" | "toExponential" | ... ``` --- .../src/analyzer/types/keyof.rs | 41 ++++++++++++++++++- .../tests/pass-only/types/keyof/1.ts | 6 +++ .../keyofAndIndexedAccess.error-diff.json | 11 +++-- .../keyofAndIndexedAccess.stats.rust-debug | 2 +- .../tests/tsc-stats.rust-debug | 2 +- 5 files changed, 53 insertions(+), 9 deletions(-) create mode 100644 crates/stc_ts_file_analyzer/tests/pass-only/types/keyof/1.ts diff --git a/crates/stc_ts_file_analyzer/src/analyzer/types/keyof.rs b/crates/stc_ts_file_analyzer/src/analyzer/types/keyof.rs index dd37d5205c..c8d610e165 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/types/keyof.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/types/keyof.rs @@ -380,7 +380,46 @@ impl Analyzer<'_, '_> { return Ok(ty.clone()); } } - + Type::EnumVariant(e) => { + if matches!(e.name, None) && (e.def.has_num || e.def.has_str) { + return self.keyof( + span, + &if e.def.has_num && e.def.has_str { + Type::new_intersection( + span, + [ + Type::Keyword(KeywordType { + span, + kind: TsKeywordTypeKind::TsStringKeyword, + metadata: Default::default(), + tracker: Default::default(), + }), + Type::Keyword(KeywordType { + span, + kind: TsKeywordTypeKind::TsNumberKeyword, + metadata: Default::default(), + tracker: Default::default(), + }), + ], + ) + } else if e.def.has_num { + Type::Keyword(KeywordType { + span, + kind: TsKeywordTypeKind::TsNumberKeyword, + metadata: Default::default(), + tracker: Default::default(), + }) + } else { + Type::Keyword(KeywordType { + span, + kind: TsKeywordTypeKind::TsStringKeyword, + metadata: Default::default(), + tracker: Default::default(), + }) + }, + ); + } + } _ => {} } diff --git a/crates/stc_ts_file_analyzer/tests/pass-only/types/keyof/1.ts b/crates/stc_ts_file_analyzer/tests/pass-only/types/keyof/1.ts new file mode 100644 index 0000000000..24bb24b6a4 --- /dev/null +++ b/crates/stc_ts_file_analyzer/tests/pass-only/types/keyof/1.ts @@ -0,0 +1,6 @@ +// @strictNullChecks: true +// @declaration: true + +enum E { A, B, C }; + +type K15 = keyof E; // "toString" | "toFixed" | "toExponential" | ... diff --git a/crates/stc_ts_type_checker/tests/conformance/types/keyof/keyofAndIndexedAccess.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/types/keyof/keyofAndIndexedAccess.error-diff.json index 0b24f28a5f..ff6a3adda9 100644 --- a/crates/stc_ts_type_checker/tests/conformance/types/keyof/keyofAndIndexedAccess.error-diff.json +++ b/crates/stc_ts_type_checker/tests/conformance/types/keyof/keyofAndIndexedAccess.error-diff.json @@ -2,16 +2,12 @@ "required_errors": {}, "required_error_lines": {}, "extra_errors": { - "TS0": 2, "TS2345": 8, "TS2339": 2, - "TS2322": 12 + "TS2322": 12, + "TS0": 1 }, "extra_error_lines": { - "TS0": [ - 44, - 523 - ], "TS2345": [ 96, 132, @@ -39,6 +35,9 @@ 640, 645, 658 + ], + "TS0": [ + 523 ] } } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/types/keyof/keyofAndIndexedAccess.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/types/keyof/keyofAndIndexedAccess.stats.rust-debug index d04e6d347e..c1d16af4c5 100644 --- a/crates/stc_ts_type_checker/tests/conformance/types/keyof/keyofAndIndexedAccess.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/types/keyof/keyofAndIndexedAccess.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 5, - extra_error: 24, + extra_error: 23, panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug index c1f1543a3a..9956d0d163 100644 --- a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 3502, matched_error: 6533, - extra_error: 768, + extra_error: 767, panic: 74, } \ No newline at end of file From 0130bbe856f2582d5f50b3241bf72afe46ea6b22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=98=A4=EB=B3=91=EC=A7=84?= <64676070+sunrabbit123@users.noreply.github.com> Date: Wed, 9 Aug 2023 20:28:47 -0700 Subject: [PATCH 11/40] feat: Implement `this` types in method parameters (#1062) **Description:** ```ts // @strictNullChecks: true // @declaration: true class A { props: T & { foo: string }; } class B extends A<{ x: number}> { f(p: this["props"]) { p.x; } } ``` --- .../stc_ts_file_analyzer/src/analyzer/expr/mod.rs | 8 +++++++- .../tests/pass-only/types/keyof/2.ts | 13 +++++++++++++ .../keyof/keyofAndIndexedAccess.error-diff.json | 6 +----- .../keyof/keyofAndIndexedAccess.stats.rust-debug | 2 +- .../stc_ts_type_checker/tests/tsc-stats.rust-debug | 2 +- 5 files changed, 23 insertions(+), 8 deletions(-) create mode 100644 crates/stc_ts_file_analyzer/tests/pass-only/types/keyof/2.ts diff --git a/crates/stc_ts_file_analyzer/src/analyzer/expr/mod.rs b/crates/stc_ts_file_analyzer/src/analyzer/expr/mod.rs index a3ab044822..84c11c35de 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/expr/mod.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/expr/mod.rs @@ -1550,7 +1550,6 @@ impl Analyzer<'_, '_> { }, _ => {} } - return Err(ErrorKind::Unimplemented { span, msg: format!("access_property_inner: global_this: {:?}", prop), @@ -3053,6 +3052,13 @@ impl Analyzer<'_, '_> { // TODO return Ok(Type::any(span, Default::default())); } + Some(ScopeKind::Method { is_static: false }) => { + if let Some(Some(parent)) = scope.map(|s| s.parent()) { + if let Some(this) = parent.this().map(|v| v.into_owned()).or(parent.get_super_class(false)) { + return self.access_property(span, &this, prop, type_mode, id_ctx, opts); + } + } + } None => { // Global this return Ok(Type::any(span, Default::default())); diff --git a/crates/stc_ts_file_analyzer/tests/pass-only/types/keyof/2.ts b/crates/stc_ts_file_analyzer/tests/pass-only/types/keyof/2.ts new file mode 100644 index 0000000000..1e89d4ff89 --- /dev/null +++ b/crates/stc_ts_file_analyzer/tests/pass-only/types/keyof/2.ts @@ -0,0 +1,13 @@ +// @strictNullChecks: true +// @declaration: true + + +class A { + props: T & { foo: string }; +} + +class B extends A<{ x: number}> { + f(p: this["props"]) { + p.x; + } +} diff --git a/crates/stc_ts_type_checker/tests/conformance/types/keyof/keyofAndIndexedAccess.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/types/keyof/keyofAndIndexedAccess.error-diff.json index ff6a3adda9..724ce11a8a 100644 --- a/crates/stc_ts_type_checker/tests/conformance/types/keyof/keyofAndIndexedAccess.error-diff.json +++ b/crates/stc_ts_type_checker/tests/conformance/types/keyof/keyofAndIndexedAccess.error-diff.json @@ -4,8 +4,7 @@ "extra_errors": { "TS2345": 8, "TS2339": 2, - "TS2322": 12, - "TS0": 1 + "TS2322": 12 }, "extra_error_lines": { "TS2345": [ @@ -35,9 +34,6 @@ 640, 645, 658 - ], - "TS0": [ - 523 ] } } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/types/keyof/keyofAndIndexedAccess.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/types/keyof/keyofAndIndexedAccess.stats.rust-debug index c1d16af4c5..4f0736a120 100644 --- a/crates/stc_ts_type_checker/tests/conformance/types/keyof/keyofAndIndexedAccess.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/types/keyof/keyofAndIndexedAccess.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 5, - extra_error: 23, + extra_error: 22, panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug index 9956d0d163..7501a54aa7 100644 --- a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 3502, matched_error: 6533, - extra_error: 767, + extra_error: 766, panic: 74, } \ No newline at end of file From e6e4c6320d5ad6965ff53600ea9eab275cdf38b3 Mon Sep 17 00:00:00 2001 From: Togami <62130798+togami2864@users.noreply.github.com> Date: Sun, 13 Aug 2023 22:20:43 +0900 Subject: [PATCH 12/40] test: Handle `.` in conformance test resolver (#1064) --- crates/stc_ts_errors/src/lib.rs | 2 ++ .../tests/conformance.pass.txt | 1 + .../exportSpellingSuggestion.error-diff.json | 4 ++-- .../importFromDot.stats.rust-debug | 6 +++--- .../tests/tsc-stats.rust-debug | 6 +++--- crates/stc_ts_type_checker/tests/tsc.rs | 20 +++++++++++++++++++ 6 files changed, 31 insertions(+), 8 deletions(-) diff --git a/crates/stc_ts_errors/src/lib.rs b/crates/stc_ts_errors/src/lib.rs index e5b486955a..7bdf5ff2c4 100644 --- a/crates/stc_ts_errors/src/lib.rs +++ b/crates/stc_ts_errors/src/lib.rs @@ -2201,6 +2201,8 @@ impl ErrorKind { ErrorKind::RestParamMustBeLast { .. } => 1014, + ErrorKind::ImportFailed { .. } => 2305, + _ => 0, } } diff --git a/crates/stc_ts_type_checker/tests/conformance.pass.txt b/crates/stc_ts_type_checker/tests/conformance.pass.txt index b3f30d3722..7620551fec 100644 --- a/crates/stc_ts_type_checker/tests/conformance.pass.txt +++ b/crates/stc_ts_type_checker/tests/conformance.pass.txt @@ -1808,6 +1808,7 @@ jsdoc/parseThrowsTag.ts jsdoc/seeTag1.ts jsdoc/seeTag2.ts jsx/tsxEmitSpreadAttribute.ts +moduleResolution/importFromDot.ts moduleResolution/packageJsonImportsExportsOptionCompat.ts nonjsExtensions/declarationFileForJsonImport.ts override/override10.ts diff --git a/crates/stc_ts_type_checker/tests/conformance/es6/modules/exportSpellingSuggestion.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/es6/modules/exportSpellingSuggestion.error-diff.json index db75f7c375..2dfa3bc74e 100644 --- a/crates/stc_ts_type_checker/tests/conformance/es6/modules/exportSpellingSuggestion.error-diff.json +++ b/crates/stc_ts_type_checker/tests/conformance/es6/modules/exportSpellingSuggestion.error-diff.json @@ -8,10 +8,10 @@ ] }, "extra_errors": { - "TS0": 1 + "TS2305": 1 }, "extra_error_lines": { - "TS0": [ + "TS2305": [ 1 ] } diff --git a/crates/stc_ts_type_checker/tests/conformance/moduleResolution/importFromDot.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/moduleResolution/importFromDot.stats.rust-debug index f79107e8ee..f3e39f53bd 100644 --- a/crates/stc_ts_type_checker/tests/conformance/moduleResolution/importFromDot.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/moduleResolution/importFromDot.stats.rust-debug @@ -1,6 +1,6 @@ Stats { - required_error: 1, - matched_error: 0, + required_error: 0, + matched_error: 1, extra_error: 0, - panic: 1, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug index 7501a54aa7..8cf4fbce6a 100644 --- a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug @@ -1,6 +1,6 @@ Stats { - required_error: 3502, - matched_error: 6533, + required_error: 3501, + matched_error: 6534, extra_error: 766, - panic: 74, + panic: 73, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/tsc.rs b/crates/stc_ts_type_checker/tests/tsc.rs index ea9b51b98b..5666522e23 100644 --- a/crates/stc_ts_type_checker/tests/tsc.rs +++ b/crates/stc_ts_type_checker/tests/tsc.rs @@ -606,6 +606,26 @@ impl Resolve for TestFileSystem { return Ok(FileName::Real(filename.into())); } + if module_specifier == "." { + let path = PathBuf::from(base.to_string()); + match path.parent() { + Some(cur_dir) => { + for (name, _) in self.files.iter() { + if format!("{}/index.ts", cur_dir.display()) == *name || format!("{}/index.tsx", cur_dir.display()) == *name { + return Ok(FileName::Real(name.into())); + } + } + } + None => { + for (name, _) in self.files.iter() { + if "index.ts" == *name || "index.tsx" == *name { + return Ok(FileName::Real(name.into())); + } + } + } + } + } + todo!("resolve: current = {:?}; target ={:?}", base, module_specifier); } } From 92191dc1e10504d00cb08edb9a155123885b8841 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=98=A4=EB=B3=91=EC=A7=84?= <64676070+sunrabbit123@users.noreply.github.com> Date: Sun, 13 Aug 2023 22:54:53 +0900 Subject: [PATCH 13/40] feat: Support more `keyof` for `IndexedAccessType`s (#1065) **Description:** ```ts function f90(x1: S2[keyof S2], x2: T[keyof S2], x3: S2[K]) { x1 = x2; x1 = x3; x2 = x1; x2 = x3; x3 = x1; x3 = x2; x1.length; x2.length; x3.length; } ``` --- .../src/analyzer/types/keyof.rs | 5 +- .../src/analyzer/types/mod.rs | 67 ++++++++++++++----- .../tests/tsc/types/nonPrimitive/.1.ts | 9 +++ .../keyofAndIndexedAccess.error-diff.json | 11 +-- .../keyofAndIndexedAccess.stats.rust-debug | 2 +- ...onstraintOfIndexAccessType.error-diff.json | 5 +- ...nstraintOfIndexAccessType.stats.rust-debug | 4 +- .../tests/tsc-stats.rust-debug | 7 +- 8 files changed, 77 insertions(+), 33 deletions(-) create mode 100644 crates/stc_ts_file_analyzer/tests/tsc/types/nonPrimitive/.1.ts diff --git a/crates/stc_ts_file_analyzer/src/analyzer/types/keyof.rs b/crates/stc_ts_file_analyzer/src/analyzer/types/keyof.rs index c8d610e165..b1892bac52 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/types/keyof.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/types/keyof.rs @@ -5,8 +5,8 @@ use stc_ts_ast_rnode::{RIdent, RNumber, RStr, RTsEntityName, RTsLit}; use stc_ts_errors::{debug::force_dump_type_as_string, DebugExt, ErrorKind}; use stc_ts_type_ops::{is_str_lit_or_union, Fix}; use stc_ts_types::{ - Class, ClassMember, ClassProperty, Index, KeywordType, KeywordTypeMetadata, LitType, Method, MethodSignature, PropertySignature, Ref, - Type, TypeElement, Union, + Class, ClassMember, ClassProperty, Index, KeywordType, KeywordTypeMetadata, LitType, Method, MethodSignature, PropertySignature, + Readonly, Ref, Type, TypeElement, Union, }; use stc_utils::{cache::Freeze, ext::TypeVecExt, stack, try_cache}; use swc_atoms::js_word; @@ -67,6 +67,7 @@ impl Analyzer<'_, '_> { } match ty.normalize() { + Type::Readonly(Readonly { ty, .. }) => return self.keyof(span, ty), Type::Lit(ty) => { return self .keyof( diff --git a/crates/stc_ts_file_analyzer/src/analyzer/types/mod.rs b/crates/stc_ts_file_analyzer/src/analyzer/types/mod.rs index 90dba21dcf..119bbe5f6e 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/types/mod.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/types/mod.rs @@ -555,23 +555,56 @@ impl Analyzer<'_, '_> { disallow_unknown_object_property: true, ..self.ctx }; - let prop_ty = self.with_ctx(ctx).access_property( - actual_span, - &obj_ty, - &Key::Computed(ComputedKey { - span: actual_span, - expr: Box::new(RExpr::Invalid(RInvalid { span: actual_span })), - ty: index_ty.clone(), - }), - TypeOfMode::RValue, - IdCtx::Type, - AccessPropertyOpts { - disallow_creating_indexed_type_from_ty_els: true, - disallow_inexact: true, - do_not_use_any_for_object: true, - ..Default::default() - }, - ); + let prop_ty = { + let type_mode = if ctx.in_fn_with_return_type { + TypeOfMode::LValue + } else { + TypeOfMode::RValue + }; + + let mut result = self.with_ctx(ctx).access_property( + actual_span, + &obj_ty, + &Key::Computed(ComputedKey { + span: actual_span, + expr: Box::new(RExpr::Invalid(RInvalid { span: actual_span })), + ty: index_ty.clone(), + }), + type_mode, + IdCtx::Type, + AccessPropertyOpts { + disallow_creating_indexed_type_from_ty_els: true, + disallow_inexact: true, + do_not_use_any_for_object: true, + ..Default::default() + }, + ); + + if result.is_err() { + if let Type::Param(TypeParam { constraint: Some(ty), .. }) = index_ty.normalize() { + let prop = self.normalize(span, Cow::Borrowed(ty), opts)?.into_owned(); + result = self.with_ctx(ctx).access_property( + actual_span, + &obj_ty, + &Key::Computed(ComputedKey { + span: actual_span, + expr: Box::new(RExpr::Invalid(RInvalid { span: actual_span })), + ty: Box::new(prop), + }), + type_mode, + IdCtx::Type, + AccessPropertyOpts { + disallow_creating_indexed_type_from_ty_els: true, + disallow_inexact: true, + do_not_use_any_for_object: true, + ..Default::default() + }, + ); + } + } + + result + }; if let Ok(prop_ty) = prop_ty { if ty.type_eq(&prop_ty) { diff --git a/crates/stc_ts_file_analyzer/tests/tsc/types/nonPrimitive/.1.ts b/crates/stc_ts_file_analyzer/tests/tsc/types/nonPrimitive/.1.ts new file mode 100644 index 0000000000..37063f079b --- /dev/null +++ b/crates/stc_ts_file_analyzer/tests/tsc/types/nonPrimitive/.1.ts @@ -0,0 +1,9 @@ +// @strict: true + + +function l(s: string, tp: T[P]): void { + tp = s; +} +function m(s: string, tp: T[P]): void { + tp = s; +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/types/keyof/keyofAndIndexedAccess.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/types/keyof/keyofAndIndexedAccess.error-diff.json index 724ce11a8a..62061f3494 100644 --- a/crates/stc_ts_type_checker/tests/conformance/types/keyof/keyofAndIndexedAccess.error-diff.json +++ b/crates/stc_ts_type_checker/tests/conformance/types/keyof/keyofAndIndexedAccess.error-diff.json @@ -4,7 +4,8 @@ "extra_errors": { "TS2345": 8, "TS2339": 2, - "TS2322": 12 + "TS0": 2, + "TS2322": 8 }, "extra_error_lines": { "TS2345": [ @@ -21,11 +22,11 @@ 147, 152 ], + "TS0": [ + 286, + 338 + ], "TS2322": [ - 307, - 309, - 310, - 311, 326, 327, 328, diff --git a/crates/stc_ts_type_checker/tests/conformance/types/keyof/keyofAndIndexedAccess.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/types/keyof/keyofAndIndexedAccess.stats.rust-debug index 4f0736a120..93c216b79c 100644 --- a/crates/stc_ts_type_checker/tests/conformance/types/keyof/keyofAndIndexedAccess.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/types/keyof/keyofAndIndexedAccess.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 5, - extra_error: 22, + extra_error: 20, panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.error-diff.json index 3e392f20b1..f8c3529e5f 100644 --- a/crates/stc_ts_type_checker/tests/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.error-diff.json +++ b/crates/stc_ts_type_checker/tests/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.error-diff.json @@ -1,10 +1,11 @@ { "required_errors": { - "TS2322": 1 + "TS2322": 2 }, "required_error_lines": { "TS2322": [ - 22 + 25, + 28 ] }, "extra_errors": {}, diff --git a/crates/stc_ts_type_checker/tests/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.stats.rust-debug index 4074730ba8..13ac66ffd7 100644 --- a/crates/stc_ts_type_checker/tests/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.stats.rust-debug @@ -1,6 +1,6 @@ Stats { - required_error: 1, - matched_error: 9, + required_error: 2, + matched_error: 8, extra_error: 0, panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug index 8cf4fbce6a..9a3b700764 100644 --- a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug @@ -1,6 +1,5 @@ Stats { - required_error: 3501, - matched_error: 6534, - extra_error: 766, - panic: 73, + required_error: 3502, + matched_error: 6533, + extra_error: 764, } \ No newline at end of file From f78187b937c25de240b7196b9b8cae6bc9a059fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=98=A4=EB=B3=91=EC=A7=84?= <64676070+sunrabbit123@users.noreply.github.com> Date: Mon, 14 Aug 2023 18:46:49 +0900 Subject: [PATCH 14/40] refactor: Create `Type::get_any_key_type` (#1066) --- .../src/analyzer/expr/bin.rs | 27 +-------- .../src/analyzer/types/keyof.rs | 56 +------------------ crates/stc_ts_types/src/lib.rs | 29 ++++++++++ 3 files changed, 32 insertions(+), 80 deletions(-) diff --git a/crates/stc_ts_file_analyzer/src/analyzer/expr/bin.rs b/crates/stc_ts_file_analyzer/src/analyzer/expr/bin.rs index 02141109d8..38ac67de83 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/expr/bin.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/expr/bin.rs @@ -2091,32 +2091,7 @@ impl Analyzer<'_, '_> { ty => { if let Err(err) = self.assign_with_opts( &mut Default::default(), - &Type::Union(Union { - span, - types: vec![ - Type::Keyword(KeywordType { - span, - kind: TsKeywordTypeKind::TsStringKeyword, - metadata: Default::default(), - tracker: Default::default(), - }), - Type::Keyword(KeywordType { - span, - kind: TsKeywordTypeKind::TsNumberKeyword, - metadata: Default::default(), - tracker: Default::default(), - }), - Type::Keyword(KeywordType { - span, - kind: TsKeywordTypeKind::TsSymbolKeyword, - metadata: Default::default(), - tracker: Default::default(), - }), - ], - metadata: Default::default(), - tracker: Default::default(), - }) - .freezed(), + &Type::get_any_key_type(span), ty, AssignOpts { span: ls, diff --git a/crates/stc_ts_file_analyzer/src/analyzer/types/keyof.rs b/crates/stc_ts_file_analyzer/src/analyzer/types/keyof.rs index b1892bac52..e74754749f 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/types/keyof.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/types/keyof.rs @@ -6,7 +6,7 @@ use stc_ts_errors::{debug::force_dump_type_as_string, DebugExt, ErrorKind}; use stc_ts_type_ops::{is_str_lit_or_union, Fix}; use stc_ts_types::{ Class, ClassMember, ClassProperty, Index, KeywordType, KeywordTypeMetadata, LitType, Method, MethodSignature, PropertySignature, - Readonly, Ref, Type, TypeElement, Union, + Readonly, Ref, Type, TypeElement, }; use stc_utils::{cache::Freeze, ext::TypeVecExt, stack, try_cache}; use swc_atoms::js_word; @@ -90,32 +90,7 @@ impl Analyzer<'_, '_> { .context("tried applying `keyof` to a literal by delegating to keyword type handler") } Type::Keyword(KeywordType { kind, .. }) => match kind { - TsKeywordTypeKind::TsAnyKeyword => { - let string = Type::Keyword(KeywordType { - span, - kind: TsKeywordTypeKind::TsStringKeyword, - metadata: Default::default(), - tracker: Default::default(), - }); - let number = Type::Keyword(KeywordType { - span, - kind: TsKeywordTypeKind::TsNumberKeyword, - metadata: Default::default(), - tracker: Default::default(), - }); - let symbol = Type::Keyword(KeywordType { - span, - kind: TsKeywordTypeKind::TsSymbolKeyword, - metadata: Default::default(), - tracker: Default::default(), - }); - return Ok(Type::Union(Union { - span, - types: vec![string, number, symbol], - metadata: Default::default(), - tracker: Default::default(), - })); - } + TsKeywordTypeKind::TsAnyKeyword | TsKeywordTypeKind::TsNeverKeyword => return Ok(Type::get_any_key_type(span)), TsKeywordTypeKind::TsVoidKeyword | TsKeywordTypeKind::TsUndefinedKeyword | TsKeywordTypeKind::TsNullKeyword @@ -157,33 +132,6 @@ impl Analyzer<'_, '_> { TsKeywordTypeKind::TsBigIntKeyword => {} TsKeywordTypeKind::TsSymbolKeyword => {} - TsKeywordTypeKind::TsNeverKeyword => { - return Ok(Type::Union(Union { - span, - types: vec![ - Type::Keyword(KeywordType { - span, - kind: TsKeywordTypeKind::TsStringKeyword, - metadata: Default::default(), - tracker: Default::default(), - }), - Type::Keyword(KeywordType { - span, - kind: TsKeywordTypeKind::TsNumberKeyword, - metadata: Default::default(), - tracker: Default::default(), - }), - Type::Keyword(KeywordType { - span, - kind: TsKeywordTypeKind::TsSymbolKeyword, - metadata: Default::default(), - tracker: Default::default(), - }), - ], - metadata: Default::default(), - tracker: Default::default(), - })) - } TsKeywordTypeKind::TsIntrinsicKeyword => {} }, diff --git a/crates/stc_ts_types/src/lib.rs b/crates/stc_ts_types/src/lib.rs index 9a4f8bf369..dd622bf37e 100644 --- a/crates/stc_ts_types/src/lib.rs +++ b/crates/stc_ts_types/src/lib.rs @@ -1900,6 +1900,35 @@ impl Type { _ => None, } } + + pub fn get_any_key_type(span: Span) -> Type { + let string = Type::Keyword(KeywordType { + span, + kind: TsKeywordTypeKind::TsStringKeyword, + metadata: Default::default(), + tracker: Default::default(), + }); + let number = Type::Keyword(KeywordType { + span, + kind: TsKeywordTypeKind::TsNumberKeyword, + metadata: Default::default(), + tracker: Default::default(), + }); + let symbol = Type::Keyword(KeywordType { + span, + kind: TsKeywordTypeKind::TsSymbolKeyword, + metadata: Default::default(), + tracker: Default::default(), + }); + + Type::Union(Union { + span, + types: vec![string, number, symbol], + metadata: Default::default(), + tracker: Default::default(), + }) + .freezed() + } } impl Type { From a04f4b13f2afe89f435f6af5cbfe6f1bb0cf89fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=98=A4=EB=B3=91=EC=A7=84?= <64676070+sunrabbit123@users.noreply.github.com> Date: Tue, 15 Aug 2023 14:34:32 +0900 Subject: [PATCH 15/40] test: Update `conformance` test error message format (#1068) --- crates/stc_ts_file_analyzer/tests/base.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/stc_ts_file_analyzer/tests/base.rs b/crates/stc_ts_file_analyzer/tests/base.rs index 86f633a8ba..05da201bdd 100644 --- a/crates/stc_ts_file_analyzer/tests/base.rs +++ b/crates/stc_ts_file_analyzer/tests/base.rs @@ -191,7 +191,7 @@ fn compare(input: PathBuf) { } let stderr = run_test(input, false, false).unwrap(); - panic!("Wanted {:?}\n{}", expected, stderr) + panic!("\nWanted {:?}\nBut, We got {:?}\n\n{}", expected, actual, stderr) } fn invoke_tsc(input: &Path) -> Vec { From d5a01edccca9cf31d577e7cdb530651e501ddc13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=98=A4=EB=B3=91=EC=A7=84?= <64676070+sunrabbit123@users.noreply.github.com> Date: Fri, 18 Aug 2023 05:02:14 +0900 Subject: [PATCH 16/40] test: Support more directives in file analyzer testing system (#1069) **Description:** When comparing TSC to error, we took the error results from ACTUAL. In actual, the rules for each file were not applied properly, As a result, tests like strictNullCheck didn't work correctly. To fix this, we unified the env import code within the tests. --- crates/stc_ts_file_analyzer/tests/base.rs | 38 ++++--------------- .../tests/tsc/rule/strictNullCheck.ts | 5 +++ .../tsc/rule/strictNullCheck.tsc-errors.json | 8 ++++ .../withUnionConstraint/{.1.ts => 1.ts} | 0 .../withUnionConstraint/1.tsc-errors.json | 8 ++++ .../tests/tsc-stats.rust-debug | 1 + 6 files changed, 29 insertions(+), 31 deletions(-) create mode 100644 crates/stc_ts_file_analyzer/tests/tsc/rule/strictNullCheck.ts create mode 100644 crates/stc_ts_file_analyzer/tests/tsc/rule/strictNullCheck.tsc-errors.json rename crates/stc_ts_file_analyzer/tests/tsc/types/intersection/withUnionConstraint/{.1.ts => 1.ts} (100%) create mode 100644 crates/stc_ts_file_analyzer/tests/tsc/types/intersection/withUnionConstraint/1.tsc-errors.json diff --git a/crates/stc_ts_file_analyzer/tests/base.rs b/crates/stc_ts_file_analyzer/tests/base.rs index 05da201bdd..264551732c 100644 --- a/crates/stc_ts_file_analyzer/tests/base.rs +++ b/crates/stc_ts_file_analyzer/tests/base.rs @@ -13,7 +13,7 @@ use rnode::{NodeIdGenerator, RNode, VisitWith}; use stc_testing::logger; use stc_ts_ast_rnode::RModule; use stc_ts_builtin_types::Lib; -use stc_ts_env::{Env, ModuleConfig, Rule}; +use stc_ts_env::Env; use stc_ts_errors::{debug::debugger::Debugger, ErrorKind}; use stc_ts_file_analyzer::{ analyzer::{Analyzer, NoopLoader}, @@ -41,8 +41,9 @@ struct StcError { code: usize, } -fn get_env() -> Env { - let mut libs = vec![]; +fn get_env_from_path(path: &Path, mut libs: Vec) -> Env { + let case = parse_conformance_test(path).unwrap().into_iter().next().unwrap(); + libs.extend(&case.libs); let ls = &[ "es2022.full", "es2021.full", @@ -59,15 +60,7 @@ fn get_env() -> Env { libs.sort(); libs.dedup(); - Env::simple( - Rule { - strict_function_types: true, - ..Default::default() - }, - EsVersion::latest(), - ModuleConfig::None, - &libs, - ) + Env::simple(case.rule, case.target, case.module_config, &libs) } fn validate(input: &Path) -> Vec { @@ -78,7 +71,7 @@ fn validate(input: &Path) -> Vec { let fm = cm.load_file(input).unwrap(); - let env = get_env(); + let env = get_env_from_path(input, vec![]); let generator = module_id::ModuleIdGenerator::default(); let path = Arc::new(FileName::Real(input.to_path_buf())); @@ -240,8 +233,6 @@ fn run_test(file_name: PathBuf, want_error: bool, disable_logging: bool) -> Opti let filename = file_name.display().to_string(); println!("{}", filename); - let case = parse_conformance_test(&file_name).unwrap().into_iter().next().unwrap(); - let result = testing::Tester::new() .print_errors(|cm, handler| -> Result<(), _> { let _tracing = if disable_logging { @@ -252,22 +243,7 @@ fn run_test(file_name: PathBuf, want_error: bool, disable_logging: bool) -> Opti let handler = Arc::new(handler); let fm = cm.load_file(&file_name).unwrap(); - let mut libs = vec![]; - let ls = &[ - "es2020.full", - "es2019.full", - "es2018.full", - "es2017.full", - "es2016.full", - "es2015.full", - ]; - for s in ls { - libs.extend(Lib::load(s)) - } - libs.sort(); - libs.dedup(); - - let env = Env::simple(case.rule, case.target, case.module_config, &libs); + let env = get_env_from_path(&file_name, vec![]); let stable_env = env.shared().clone(); let generator = module_id::ModuleIdGenerator::default(); let path = Arc::new(FileName::Real(file_name.clone())); diff --git a/crates/stc_ts_file_analyzer/tests/tsc/rule/strictNullCheck.ts b/crates/stc_ts_file_analyzer/tests/tsc/rule/strictNullCheck.ts new file mode 100644 index 0000000000..ca1da46a9b --- /dev/null +++ b/crates/stc_ts_file_analyzer/tests/tsc/rule/strictNullCheck.ts @@ -0,0 +1,5 @@ +// @strictNullChecks: true +// @declaration: true + +declare let a : string; +a = "a" as string | undefined; \ No newline at end of file diff --git a/crates/stc_ts_file_analyzer/tests/tsc/rule/strictNullCheck.tsc-errors.json b/crates/stc_ts_file_analyzer/tests/tsc/rule/strictNullCheck.tsc-errors.json new file mode 100644 index 0000000000..86cc3b9c18 --- /dev/null +++ b/crates/stc_ts_file_analyzer/tests/tsc/rule/strictNullCheck.tsc-errors.json @@ -0,0 +1,8 @@ +[ + { + "file": "tests/tsc/rule/strictNullCheck.ts", + "line": 5, + "col": 1, + "code": 2322 + } +] \ No newline at end of file diff --git a/crates/stc_ts_file_analyzer/tests/tsc/types/intersection/withUnionConstraint/.1.ts b/crates/stc_ts_file_analyzer/tests/tsc/types/intersection/withUnionConstraint/1.ts similarity index 100% rename from crates/stc_ts_file_analyzer/tests/tsc/types/intersection/withUnionConstraint/.1.ts rename to crates/stc_ts_file_analyzer/tests/tsc/types/intersection/withUnionConstraint/1.ts diff --git a/crates/stc_ts_file_analyzer/tests/tsc/types/intersection/withUnionConstraint/1.tsc-errors.json b/crates/stc_ts_file_analyzer/tests/tsc/types/intersection/withUnionConstraint/1.tsc-errors.json new file mode 100644 index 0000000000..94fd52114e --- /dev/null +++ b/crates/stc_ts_file_analyzer/tests/tsc/types/intersection/withUnionConstraint/1.tsc-errors.json @@ -0,0 +1,8 @@ +[ + { + "file": "tests/tsc/types/intersection/withUnionConstraint/1.ts", + "line": 4, + "col": 9, + "code": 2322 + } +] \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug index 9a3b700764..02553a0cb6 100644 --- a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug @@ -2,4 +2,5 @@ Stats { required_error: 3502, matched_error: 6533, extra_error: 764, + panic: 73, } \ No newline at end of file From 96ad01d46cd8920d08479e357d9e8da56e6e98da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=98=A4=EB=B3=91=EC=A7=84?= <64676070+sunrabbit123@users.noreply.github.com> Date: Sun, 20 Aug 2023 12:16:17 +0900 Subject: [PATCH 17/40] feat: Support accessing nom primitive constraint of an empty object (#1072) **Description:** ```ts function l(s: string, tp: T[P]): void { tp = s; } ``` --- crates/stc_ts_file_analyzer/src/analyzer/expr/mod.rs | 3 +++ .../nonPrimitiveConstraintOfIndexAccessType.error-diff.json | 3 +-- .../nonPrimitiveConstraintOfIndexAccessType.stats.rust-debug | 4 ++-- crates/stc_ts_type_checker/tests/tsc-stats.rust-debug | 4 ++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/crates/stc_ts_file_analyzer/src/analyzer/expr/mod.rs b/crates/stc_ts_file_analyzer/src/analyzer/expr/mod.rs index 84c11c35de..0e81cc3ecc 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/expr/mod.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/expr/mod.rs @@ -2513,6 +2513,9 @@ impl Analyzer<'_, '_> { } if type_mode == TypeOfMode::LValue { + if prop.ty().is_type_param() && members.is_empty() { + return Ok(Type::never(span, Default::default())); + } return Ok(Type::any(span, Default::default())); } diff --git a/crates/stc_ts_type_checker/tests/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.error-diff.json index f8c3529e5f..b6be05c17d 100644 --- a/crates/stc_ts_type_checker/tests/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.error-diff.json +++ b/crates/stc_ts_type_checker/tests/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.error-diff.json @@ -1,10 +1,9 @@ { "required_errors": { - "TS2322": 2 + "TS2322": 1 }, "required_error_lines": { "TS2322": [ - 25, 28 ] }, diff --git a/crates/stc_ts_type_checker/tests/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.stats.rust-debug index 13ac66ffd7..4074730ba8 100644 --- a/crates/stc_ts_type_checker/tests/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.stats.rust-debug @@ -1,6 +1,6 @@ Stats { - required_error: 2, - matched_error: 8, + required_error: 1, + matched_error: 9, extra_error: 0, panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug index 02553a0cb6..57039bc151 100644 --- a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug @@ -1,6 +1,6 @@ Stats { - required_error: 3502, - matched_error: 6533, + required_error: 3501, + matched_error: 6534, extra_error: 764, panic: 73, } \ No newline at end of file From 277b967403b38526a373f5aed05c0320f744feb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=98=A4=EB=B3=91=EC=A7=84?= <64676070+sunrabbit123@users.noreply.github.com> Date: Sun, 20 Aug 2023 12:27:29 +0900 Subject: [PATCH 18/40] fix: Fix panic from `parse().unwrap()` at generic inference (#1070) **Description:** ```rs if r.is_num() { match src.parse() { Ok(v) => { return Type::Lit(LitType { span, lit: RTsLit::Number(RNumber { span, value: v, raw: None }), metadata: Default::default(), tracker: Default::default(), }) } Err(..) => { return Type::Keyword(KeywordType { span, kind: TsKeywordTypeKind::TsNumberKeyword, metadata: Default::default(), tracker: Default::default(), }) } } } ``` --- .../src/analyzer/generic/inference.rs | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/crates/stc_ts_file_analyzer/src/analyzer/generic/inference.rs b/crates/stc_ts_file_analyzer/src/analyzer/generic/inference.rs index 3aca4dcd45..f09cc6a88d 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/generic/inference.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/generic/inference.rs @@ -533,6 +533,7 @@ impl Analyzer<'_, '_> { // variable whose constraint includes one of the // allowed template literal placeholder types, infer from a // literal type corresponding to the constraint. + // ref: https://github.com/microsoft/TypeScript/blob/b5557271a51704e0469dd86974335a4775a68ffd/src/compiler/checker.ts#L25342 if source.is_str_lit() && (target.is_type_param() || target.is_infer()) { if let Type::Infer(InferType { type_param: @@ -624,16 +625,24 @@ impl Analyzer<'_, '_> { } if r.is_num() { - return Type::Lit(LitType { - span, - lit: RTsLit::Number(RNumber { - span, - value: src.parse().unwrap(), - raw: None, - }), - metadata: Default::default(), - tracker: Default::default(), - }); + match src.parse() { + Ok(v) => { + return Type::Lit(LitType { + span, + lit: RTsLit::Number(RNumber { span, value: v, raw: None }), + metadata: Default::default(), + tracker: Default::default(), + }) + } + Err(..) => { + return Type::Keyword(KeywordType { + span, + kind: TsKeywordTypeKind::TsNumberKeyword, + metadata: Default::default(), + tracker: Default::default(), + }) + } + } } if l.is_enum_type() || l.is_enum_variant() { From 57e0f3fae1089a7ee6119637ec4e4c3da3fc10f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=98=A4=EB=B3=91=EC=A7=84?= <64676070+sunrabbit123@users.noreply.github.com> Date: Sun, 20 Aug 2023 21:20:29 +0900 Subject: [PATCH 19/40] feat: Implement `assign` about indexed access types (#1071) **Description:** ```ts type A = 1 | 2; function f(a: T): A & T { return a; } // Shouldn't error ``` --- .../src/analyzer/assign/mod.rs | 82 ++++++++++++++++++- .../tests/conformance.pass.txt | 1 + ...UnionConstraintDistributed.error-diff.json | 12 --- ...nionConstraintDistributed.stats.rust-debug | 2 +- .../tests/tsc-stats.rust-debug | 2 +- 5 files changed, 81 insertions(+), 18 deletions(-) delete mode 100644 crates/stc_ts_type_checker/tests/conformance/jsdoc/typeParameterExtendsUnionConstraintDistributed.error-diff.json diff --git a/crates/stc_ts_file_analyzer/src/analyzer/assign/mod.rs b/crates/stc_ts_file_analyzer/src/analyzer/assign/mod.rs index 81f4436dea..88e05ecec3 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/assign/mod.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/assign/mod.rs @@ -6,9 +6,9 @@ use stc_ts_errors::{ DebugExt, ErrorKind, }; use stc_ts_types::{ - Array, Conditional, EnumVariant, Index, Instance, Interface, Intersection, IntrinsicKind, Key, KeywordType, LitType, Mapped, - PropertySignature, QueryExpr, QueryType, Readonly, Ref, StringMapping, ThisType, Tuple, TupleElement, Type, TypeElement, TypeLit, - TypeParam, + Array, Conditional, EnumVariant, Index, IndexedAccessType, Instance, Interface, Intersection, IntrinsicKind, Key, KeywordType, LitType, + Mapped, PropertySignature, QueryExpr, QueryType, Readonly, Ref, StringMapping, ThisType, Tuple, TupleElement, Type, TypeElement, + TypeLit, TypeParam, }; use stc_utils::{cache::Freeze, dev_span, ext::SpanExt, stack}; use swc_atoms::js_word; @@ -521,12 +521,72 @@ impl Analyzer<'_, '_> { } } - match ty { + match ty.normalize() { Type::EnumVariant(e @ EnumVariant { name: Some(..), .. }) => { if opts.ignore_enum_variant_name { return Ok(Cow::Owned(Type::EnumVariant(EnumVariant { name: None, ..e.clone() }))); } } + Type::IndexedAccessType(IndexedAccessType { + obj_type: + obj @ box Type::Param(TypeParam { + span: p_span, + name, + constraint, + .. + }), + index_type: + box Type::Index(Index { + ty: + box Type::Param(TypeParam { + constraint: None, + default: None, + name: rhs_param_name, + .. + }), + .. + }), + .. + }) if name.eq(rhs_param_name) => { + let create_index_accessed_type = |ty: Box, obj| { + Type::IndexedAccessType(IndexedAccessType { + span, + readonly: false, + obj_type: obj, + index_type: ty, + metadata: Default::default(), + tracker: Default::default(), + }) + }; + + let gen_keyword_type = |kind| { + Type::Keyword(KeywordType { + span, + kind, + metadata: Default::default(), + tracker: Default::default(), + }) + }; + + return Ok(Cow::Owned(Type::new_union( + span, + [ + create_index_accessed_type( + Box::new(gen_keyword_type(TsKeywordTypeKind::TsStringKeyword)), + Box::new(*obj.clone()), + ), + create_index_accessed_type( + Box::new(gen_keyword_type(TsKeywordTypeKind::TsNumberKeyword)), + Box::new(*obj.clone()), + ), + create_index_accessed_type( + Box::new(gen_keyword_type(TsKeywordTypeKind::TsSymbolKeyword)), + Box::new(*obj.clone()), + ), + ], + ))); + } + Type::Conditional(..) | Type::IndexedAccessType(..) | Type::Alias(..) @@ -1965,10 +2025,23 @@ impl Analyzer<'_, '_> { if results.iter().any(Result::is_ok) { return Ok(()); } + + if let Type::Param(TypeParam { + constraint: Some(box c), .. + }) = rhs + { + if let Ok(result) = self.normalize(Some(span), Cow::Borrowed(c), Default::default()) { + return self + .assign_with_opts(data, to, result.normalize(), opts) + .context("tried to assign a type_param at union"); + } + } + let normalized = lu.types.iter().any(|ty| match ty.normalize() { Type::TypeLit(ty) => ty.metadata.normalized, _ => false, }); + let errors = results.into_iter().map(Result::unwrap_err).collect(); let should_use_single_error = normalized || lu.types.iter().all(|ty| { @@ -1984,6 +2057,7 @@ impl Analyzer<'_, '_> { || ty.is_type_param() || ty.is_class() || ty.is_class_def() + || ty.is_indexed_access_type() }); if should_use_single_error { diff --git a/crates/stc_ts_type_checker/tests/conformance.pass.txt b/crates/stc_ts_type_checker/tests/conformance.pass.txt index 7620551fec..2e71241343 100644 --- a/crates/stc_ts_type_checker/tests/conformance.pass.txt +++ b/crates/stc_ts_type_checker/tests/conformance.pass.txt @@ -1807,6 +1807,7 @@ jsdoc/parseLinkTag.ts jsdoc/parseThrowsTag.ts jsdoc/seeTag1.ts jsdoc/seeTag2.ts +jsdoc/typeParameterExtendsUnionConstraintDistributed.ts jsx/tsxEmitSpreadAttribute.ts moduleResolution/importFromDot.ts moduleResolution/packageJsonImportsExportsOptionCompat.ts diff --git a/crates/stc_ts_type_checker/tests/conformance/jsdoc/typeParameterExtendsUnionConstraintDistributed.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/jsdoc/typeParameterExtendsUnionConstraintDistributed.error-diff.json deleted file mode 100644 index 9514d9dda2..0000000000 --- a/crates/stc_ts_type_checker/tests/conformance/jsdoc/typeParameterExtendsUnionConstraintDistributed.error-diff.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "required_errors": {}, - "required_error_lines": {}, - "extra_errors": { - "TS2322": 1 - }, - "extra_error_lines": { - "TS2322": [ - 2 - ] - } -} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsdoc/typeParameterExtendsUnionConstraintDistributed.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/jsdoc/typeParameterExtendsUnionConstraintDistributed.stats.rust-debug index 0498397634..c086b5ab15 100644 --- a/crates/stc_ts_type_checker/tests/conformance/jsdoc/typeParameterExtendsUnionConstraintDistributed.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/jsdoc/typeParameterExtendsUnionConstraintDistributed.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 1, + extra_error: 0, panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug index 57039bc151..3c1c168ad2 100644 --- a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 3501, matched_error: 6534, - extra_error: 764, + extra_error: 763, panic: 73, } \ No newline at end of file From f46b724f597e181200807f229f543a1ec0b9606c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=98=A4=EB=B3=91=EC=A7=84?= <64676070+sunrabbit123@users.noreply.github.com> Date: Thu, 24 Aug 2023 10:57:06 +0900 Subject: [PATCH 20/40] feat: Union the type of an optional property of a mapped type with `undefined` (#1073) **Description:** ```ts function f10(x: T, y: Partial, k: keyof T) { x[k] = y[k]; // Error y[k] = x[k]; } ``` --- .../src/analyzer/expr/mod.rs | 137 ++++++++++-------- .../mappedTypeRelationships.error-diff.json | 3 +- .../mappedTypeRelationships.stats.rust-debug | 4 +- .../tests/tsc-stats.rust-debug | 4 +- 4 files changed, 79 insertions(+), 69 deletions(-) diff --git a/crates/stc_ts_file_analyzer/src/analyzer/expr/mod.rs b/crates/stc_ts_file_analyzer/src/analyzer/expr/mod.rs index 0e81cc3ecc..9c883879fa 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/expr/mod.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/expr/mod.rs @@ -3129,81 +3129,92 @@ impl Analyzer<'_, '_> { // If type of prop is equal to the type of index signature, it's // index access. - match constraint.as_ref().map(Type::normalize) { - Some(Type::Index(Index { - ty: box Type::Array(..), .. - })) => { - if let Ok(obj) = self.env.get_global_type(span, &js_word!("Array")) { - return self.access_property(span, &obj, prop, type_mode, id_ctx, opts); + let result = (|obj| { + match constraint.as_ref().map(Type::normalize) { + Some(Type::Index(Index { + ty: box Type::Array(..), .. + })) => { + if let Ok(obj) = self.env.get_global_type(span, &js_word!("Array")) { + return self.access_property(span, &obj, prop, type_mode, id_ctx, opts); + } } - } - Some(index @ Type::Keyword(..)) | Some(index @ Type::Param(..)) => { - // { - // [P in string]: number; - // }; - if let Ok(()) = self.assign(span, &mut Default::default(), index, &prop.ty()) { - // We handle `Partial` at here. - let ty = m.ty.clone().map(|v| *v).unwrap_or_else(|| Type::any(span, Default::default())); - - let ty = match m.optional { - Some(TruePlusMinus::Plus) | Some(TruePlusMinus::True) => ty.union_with_undefined(span), - Some(TruePlusMinus::Minus) => self.apply_type_facts_to_type(TypeFacts::NEUndefined | TypeFacts::NENull, ty), - _ => ty, - }; - return Ok(ty); + Some(index @ Type::Keyword(..)) | Some(index @ Type::Param(..)) => { + // { + // [P in string]: number; + // }; + if let Ok(()) = self.assign(span, &mut Default::default(), index, &prop.ty()) { + // We handle `Partial` at here. + let ty = m.ty.clone().map(|v| *v).unwrap_or_else(|| Type::any(span, Default::default())); + + let ty = match m.optional { + Some(TruePlusMinus::Plus) | Some(TruePlusMinus::True) => ty.union_with_undefined(span), + Some(TruePlusMinus::Minus) => { + self.apply_type_facts_to_type(TypeFacts::NEUndefined | TypeFacts::NENull, ty) + } + _ => ty, + }; + return Ok(ty); + } } - } - - _ => {} - } - let expanded = self - .expand_mapped(span, m) - .context("tried to expand a mapped type to access property")?; - - if let Some(obj) = &expanded { - return self.access_property(span, obj, prop, type_mode, id_ctx, opts); - } + _ => {} + } - if let Some(Type::Index(Index { ty, .. })) = constraint.as_ref().map(Type::normalize) { - // Check if we can index the object with given key. - if let Ok(index_type) = self.keyof(span, ty) { - if let Ok(()) = self.assign_with_opts( - &mut Default::default(), - &index_type, - &prop.ty(), - AssignOpts { - span, - ..Default::default() - }, - ) { - let mut result_ty = m.ty.clone().map(|v| *v).unwrap_or_else(|| Type::any(span, Default::default())); + if let Some(obj) = self + .expand_mapped(span, m) + .context("tried to expand a mapped type to access property")? + { + return self.access_property(span, &obj, prop, type_mode, id_ctx, opts); + } - replace_type( - &mut result_ty, - |ty| match ty.normalize() { - Type::Param(ty) => ty.name == m.type_param.name, - _ => false, + if let Some(Type::Index(Index { ty, .. })) = constraint.as_ref().map(Type::normalize) { + // Check if we can index the object with given key. + if let Ok(index_type) = self.keyof(span, ty) { + if let Ok(()) = self.assign_with_opts( + &mut Default::default(), + &index_type, + &prop.ty(), + AssignOpts { + span, + ..Default::default() }, - |_| Some(index_type.clone()), - ); + ) { + let mut result_ty = m.ty.clone().map(|v| *v).unwrap_or_else(|| Type::any(span, Default::default())); + + replace_type( + &mut result_ty, + |ty| match ty.normalize() { + Type::Param(ty) => ty.name == m.type_param.name, + _ => false, + }, + |_| Some(index_type.clone()), + ); - return Ok(result_ty); + return Ok(result_ty); + } } } - } - warn!("Creating an indexed access type with mapped type as the object"); + warn!("Creating an indexed access type with mapped type as the object"); - return Ok(Type::IndexedAccessType(IndexedAccessType { - span, - readonly: false, - obj_type: Box::new(obj), - index_type: Box::new(prop.ty().into_owned()), - metadata: Default::default(), - tracker: Default::default(), - })); + return Ok(Type::IndexedAccessType(IndexedAccessType { + span, + readonly: false, + obj_type: Box::new(obj), + index_type: Box::new(prop.ty().into_owned()), + metadata: Default::default(), + tracker: Default::default(), + })); + })(obj.clone()) + .map(|v| { + if let Some(TruePlusMinus::True) = m.optional { + Type::new_union(span, vec![v, Type::undefined(span, Default::default())]) + } else { + v + } + }); + return result; } Type::Ref(r) => { diff --git a/crates/stc_ts_type_checker/tests/conformance/types/mapped/mappedTypeRelationships.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/types/mapped/mappedTypeRelationships.error-diff.json index c6be1b65fe..e0ebb4a483 100644 --- a/crates/stc_ts_type_checker/tests/conformance/types/mapped/mappedTypeRelationships.error-diff.json +++ b/crates/stc_ts_type_checker/tests/conformance/types/mapped/mappedTypeRelationships.error-diff.json @@ -1,6 +1,6 @@ { "required_errors": { - "TS2322": 13, + "TS2322": 12, "TS2536": 4, "TS2542": 4 }, @@ -8,7 +8,6 @@ "TS2322": [ 14, 19, - 33, 75, 81, 91, diff --git a/crates/stc_ts_type_checker/tests/conformance/types/mapped/mappedTypeRelationships.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/types/mapped/mappedTypeRelationships.stats.rust-debug index eda07fe781..4e774fdd28 100644 --- a/crates/stc_ts_type_checker/tests/conformance/types/mapped/mappedTypeRelationships.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/types/mapped/mappedTypeRelationships.stats.rust-debug @@ -1,6 +1,6 @@ Stats { - required_error: 21, - matched_error: 7, + required_error: 20, + matched_error: 8, extra_error: 5, panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug index 3c1c168ad2..8ce4c1a1a4 100644 --- a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug @@ -1,6 +1,6 @@ Stats { - required_error: 3501, - matched_error: 6534, + required_error: 3500, + matched_error: 6535, extra_error: 763, panic: 73, } \ No newline at end of file From a354f079198ba7c95ee488963ba6f54d1ac922c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=98=A4=EB=B3=91=EC=A7=84?= <64676070+sunrabbit123@users.noreply.github.com> Date: Fri, 1 Sep 2023 18:09:32 +0900 Subject: [PATCH 21/40] feat: Implement property access about non-primitive constraints of IAT (#1067) **Description:** ```ts function l(s: string, tp: T[P]): void { tp = s; } function m(s: string, tp: T[P]): void { tp = s; } function f(s: string, tp: T[P]): void { tp = s; } ``` --- crates/stc_ts_errors/src/lib.rs | 10 ++ .../src/analyzer/assign/mod.rs | 35 +++++++ .../src/analyzer/expr/mod.rs | 92 +++++++++++++++++-- .../src/analyzer/types/keyof.rs | 7 +- .../src/analyzer/types/mod.rs | 7 ++ .../tests/pass-only/types/keyof/3.ts | 19 ++++ .../tests/pass-only/types/mapped/.1.ts | 6 ++ .../tests/tsc/types/mapped/1.ts | 23 +++++ .../tests/tsc/types/mapped/1.tsc-errors.json | 14 +++ .../tests/tsc/types/mapped/2.ts | 7 ++ .../tests/tsc/types/mapped/2.tsc-errors.json | 14 +++ .../tsc/types/nonPrimitive/{.1.ts => 1.ts} | 5 +- .../tsc/types/nonPrimitive/1.tsc-errors.json | 20 ++++ .../tests/conformance.pass.txt | 1 + .../mappedTypeRelationships.error-diff.json | 28 ++---- .../mappedTypeRelationships.stats.rust-debug | 6 +- ...onstraintOfIndexAccessType.error-diff.json | 12 --- ...nstraintOfIndexAccessType.stats.rust-debug | 4 +- .../tests/tsc-stats.rust-debug | 6 +- 19 files changed, 268 insertions(+), 48 deletions(-) create mode 100644 crates/stc_ts_file_analyzer/tests/pass-only/types/keyof/3.ts create mode 100644 crates/stc_ts_file_analyzer/tests/pass-only/types/mapped/.1.ts create mode 100644 crates/stc_ts_file_analyzer/tests/tsc/types/mapped/1.ts create mode 100644 crates/stc_ts_file_analyzer/tests/tsc/types/mapped/1.tsc-errors.json create mode 100644 crates/stc_ts_file_analyzer/tests/tsc/types/mapped/2.ts create mode 100644 crates/stc_ts_file_analyzer/tests/tsc/types/mapped/2.tsc-errors.json rename crates/stc_ts_file_analyzer/tests/tsc/types/nonPrimitive/{.1.ts => 1.ts} (68%) create mode 100644 crates/stc_ts_file_analyzer/tests/tsc/types/nonPrimitive/1.tsc-errors.json delete mode 100644 crates/stc_ts_type_checker/tests/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.error-diff.json diff --git a/crates/stc_ts_errors/src/lib.rs b/crates/stc_ts_errors/src/lib.rs index 7bdf5ff2c4..9d8087a4d2 100644 --- a/crates/stc_ts_errors/src/lib.rs +++ b/crates/stc_ts_errors/src/lib.rs @@ -1589,6 +1589,11 @@ pub enum ErrorKind { RestParamMustBeLast { span: Span, }, + + // TS2536 + CannotBeUsedToIndexType { + span: Span, + }, } #[cfg(target_pointer_width = "64")] @@ -2203,6 +2208,7 @@ impl ErrorKind { ErrorKind::ImportFailed { .. } => 2305, + ErrorKind::CannotBeUsedToIndexType { .. } => 2536, _ => 0, } } @@ -2236,6 +2242,10 @@ impl ErrorKind { matches!(self, Self::NoSuchType { .. } | Self::NoSuchTypeButVarExists { .. }) } + pub fn is_cannot_be_used_index_ty(&self) -> bool { + self.code() == 2536 + } + #[cold] pub fn flatten(vec: Vec) -> Vec { let mut buf = Vec::with_capacity(vec.len()); diff --git a/crates/stc_ts_file_analyzer/src/analyzer/assign/mod.rs b/crates/stc_ts_file_analyzer/src/analyzer/assign/mod.rs index 88e05ecec3..965cdac254 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/assign/mod.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/assign/mod.rs @@ -1179,6 +1179,41 @@ impl Analyzer<'_, '_> { return Ok(()); } + // function f3(x: T, y: U, k: keyof T) { + // x[k] = y[k]; + // } + ( + Type::IndexedAccessType(IndexedAccessType { + obj_type: box Type::Param(TypeParam { name: lhs_name, .. }), + index_type: lhs_idx, + .. + }), + Type::IndexedAccessType(IndexedAccessType { + obj_type: + box Type::Param(TypeParam { + constraint: Some(box Type::Param(TypeParam { name: rhs_name, .. })), + .. + }), + index_type: rhs_idx, + .. + }), + ) if lhs_name.eq(rhs_name) && lhs_idx.is_index() && rhs_idx.is_index() => { + if matches!(( + lhs_idx.as_index().map(|ty| ty.ty.normalize()), + rhs_idx.as_index().map(|ty| ty.ty.normalize()), + ), ( + Some(Type::Param(TypeParam { + name: lhs_ty_param_name, .. + })), + Some(Type::Param(TypeParam { + name: rhs_ty_param_name, .. + })), + ) if lhs_ty_param_name.eq(rhs_ty_param_name)) + { + return Ok(()); + } + } + _ => {} } diff --git a/crates/stc_ts_file_analyzer/src/analyzer/expr/mod.rs b/crates/stc_ts_file_analyzer/src/analyzer/expr/mod.rs index 9c883879fa..ef72faaba3 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/expr/mod.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/expr/mod.rs @@ -2174,14 +2174,93 @@ impl Analyzer<'_, '_> { .. }) => { { - // Check for `T extends { a: { x: any } }` - if let Some(constraint) = constraint { - let ctx = Ctx { - ignore_errors: true, - ..self.ctx + let validate_type_param = |name: &Id| { + match prop.ty().normalize() { + Type::Param(TypeParam { constraint: Some(ty), .. }) => { + if let Type::Index(Index { + ty: box Type::Param(TypeParam { name: constraint_name, .. }), + .. + }) = ty.normalize() + { + if !name.eq(constraint_name) { + return Err(ErrorKind::CannotBeUsedToIndexType { span }.into()); + } + } + } + + Type::Index(Index { + ty: box Type::Param(TypeParam { name: constraint_name, .. }), + .. + }) if !name.eq(constraint_name) => return Err(ErrorKind::CannotBeUsedToIndexType { span }.into()), + _ => {} + } + Ok(()) + }; + + if let Some(ty) = constraint { + if let Type::Param(TypeParam { name: constraint_name, .. }) = ty.normalize() { + match validate_type_param(name) { + Ok(..) => {} + Err(err) => validate_type_param(constraint_name)?, + }; + } + } else { + match validate_type_param(name) { + Ok(..) => {} + Err(err) => return Err(err), }; + } + } + + // Check for `T extends { a: { x: any } }` + if let Some(constraint) = constraint { + let ctx = Ctx { + ignore_errors: true, + ..self.ctx + }; + + let accessible = matches!( + constraint.normalize(), + Type::Keyword(KeywordType { + kind: TsKeywordTypeKind::TsObjectKeyword, + .. + }) + ) || if let Type::Param(TypeParam { + constraint: Some(ty), + name: origin_name, + .. + }) = prop.ty().normalize() + { + if name.eq(origin_name) { + true + } else { + if let Type::Index(Index { + ty: box Type::Param(TypeParam { name: constraint_name, .. }), + .. + }) = ty.normalize() + { + !name.eq(constraint_name) + } else { + true + } + } + } else { + true + }; + + if accessible { if let Ok(ty) = self.with_ctx(ctx).access_property(span, constraint, prop, type_mode, id_ctx, opts) { - return Ok(ty); + if let Type::IndexedAccessType(IndexedAccessType { + obj_type: box Type::Param(TypeParam { name: constraint_name, .. }), + .. + }) = ty.normalize() + { + if name.eq(constraint_name) { + return Ok(ty); + } + } else { + return Ok(ty); + } } } } @@ -2220,7 +2299,6 @@ impl Analyzer<'_, '_> { } warn!("Creating an indexed access type with type parameter as the object"); - return Ok(Type::IndexedAccessType(IndexedAccessType { span, readonly: false, diff --git a/crates/stc_ts_file_analyzer/src/analyzer/types/keyof.rs b/crates/stc_ts_file_analyzer/src/analyzer/types/keyof.rs index e74754749f..d43a378a89 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/types/keyof.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/types/keyof.rs @@ -6,7 +6,7 @@ use stc_ts_errors::{debug::force_dump_type_as_string, DebugExt, ErrorKind}; use stc_ts_type_ops::{is_str_lit_or_union, Fix}; use stc_ts_types::{ Class, ClassMember, ClassProperty, Index, KeywordType, KeywordTypeMetadata, LitType, Method, MethodSignature, PropertySignature, - Readonly, Ref, Type, TypeElement, + Readonly, Ref, Type, TypeElement, TypeParam, }; use stc_utils::{cache::Freeze, ext::TypeVecExt, stack, try_cache}; use swc_atoms::js_word; @@ -313,7 +313,10 @@ impl Analyzer<'_, '_> { return Ok(Type::new_union(span, key_types)); } - Type::Param(..) => { + Type::Param(TypeParam { constraint, .. }) => { + // if let Some(box c) = constraint { + // return self.keyof(span, c); + // } return Ok(Type::Index(Index { span, ty: Box::new(ty.into_owned()), diff --git a/crates/stc_ts_file_analyzer/src/analyzer/types/mod.rs b/crates/stc_ts_file_analyzer/src/analyzer/types/mod.rs index 119bbe5f6e..851ec77592 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/types/mod.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/types/mod.rs @@ -581,6 +581,13 @@ impl Analyzer<'_, '_> { ); if result.is_err() { + match result { + Err(err) if err.is_cannot_be_used_index_ty() => { + return Err(err); + } + _ => (), + } + if let Type::Param(TypeParam { constraint: Some(ty), .. }) = index_ty.normalize() { let prop = self.normalize(span, Cow::Borrowed(ty), opts)?.into_owned(); result = self.with_ctx(ctx).access_property( diff --git a/crates/stc_ts_file_analyzer/tests/pass-only/types/keyof/3.ts b/crates/stc_ts_file_analyzer/tests/pass-only/types/keyof/3.ts new file mode 100644 index 0000000000..968518c5d3 --- /dev/null +++ b/crates/stc_ts_file_analyzer/tests/pass-only/types/keyof/3.ts @@ -0,0 +1,19 @@ +// @strictNullChecks: true +// @declaration: true + +class Shape { + name: string; + width: number; + height: number; + visible: boolean; +} + +function getProperty(obj: T, key: K) { + return obj[key]; +} + +function f33(shape: S, key: K) { + let name = getProperty(shape, "name"); + let prop = getProperty(shape, key); + return prop; +} \ No newline at end of file diff --git a/crates/stc_ts_file_analyzer/tests/pass-only/types/mapped/.1.ts b/crates/stc_ts_file_analyzer/tests/pass-only/types/mapped/.1.ts new file mode 100644 index 0000000000..0a612c6dee --- /dev/null +++ b/crates/stc_ts_file_analyzer/tests/pass-only/types/mapped/.1.ts @@ -0,0 +1,6 @@ +// @strictNullChecks: true +// @declaration: true + +function f4(x: T, y: U, k: K) { + x[k] = y[k]; +} diff --git a/crates/stc_ts_file_analyzer/tests/tsc/types/mapped/1.ts b/crates/stc_ts_file_analyzer/tests/tsc/types/mapped/1.ts new file mode 100644 index 0000000000..6d6531b87c --- /dev/null +++ b/crates/stc_ts_file_analyzer/tests/tsc/types/mapped/1.ts @@ -0,0 +1,23 @@ +// @strictNullChecks: true +// @declaration: true + +function f1(x: T, k: keyof T) { + return x[k]; +} + +function f2(x: T, k: K) { + return x[k]; +} + +function f3(x: T, y: U, k: keyof T) { + x[k] = y[k]; +} + +function f10(x: T, y: Partial, k: keyof T) { + y[k] = x[k]; +} + +function f12(x: T, y: Partial, k: keyof T) { + x[k] = y[k]; // Error + y[k] = x[k]; // Error +} diff --git a/crates/stc_ts_file_analyzer/tests/tsc/types/mapped/1.tsc-errors.json b/crates/stc_ts_file_analyzer/tests/tsc/types/mapped/1.tsc-errors.json new file mode 100644 index 0000000000..0622117749 --- /dev/null +++ b/crates/stc_ts_file_analyzer/tests/tsc/types/mapped/1.tsc-errors.json @@ -0,0 +1,14 @@ +[ + { + "file": "tests/tsc/types/mapped/1.ts", + "line": 21, + "col": 5, + "code": 2322 + }, + { + "file": "tests/tsc/types/mapped/1.ts", + "line": 22, + "col": 5, + "code": 2322 + } +] \ No newline at end of file diff --git a/crates/stc_ts_file_analyzer/tests/tsc/types/mapped/2.ts b/crates/stc_ts_file_analyzer/tests/tsc/types/mapped/2.ts new file mode 100644 index 0000000000..df29528d6d --- /dev/null +++ b/crates/stc_ts_file_analyzer/tests/tsc/types/mapped/2.ts @@ -0,0 +1,7 @@ +// @strictNullChecks: true +// @declaration: true + +function f6(x: T, y: U, k: K) { + x[k] = y[k]; // Error + y[k] = x[k]; // Error +} diff --git a/crates/stc_ts_file_analyzer/tests/tsc/types/mapped/2.tsc-errors.json b/crates/stc_ts_file_analyzer/tests/tsc/types/mapped/2.tsc-errors.json new file mode 100644 index 0000000000..27c9cfd682 --- /dev/null +++ b/crates/stc_ts_file_analyzer/tests/tsc/types/mapped/2.tsc-errors.json @@ -0,0 +1,14 @@ +[ + { + "file": "tests/tsc/types/mapped/2.ts", + "line": 5, + "col": 5, + "code": 2536 + }, + { + "file": "tests/tsc/types/mapped/2.ts", + "line": 6, + "col": 12, + "code": 2536 + } +] \ No newline at end of file diff --git a/crates/stc_ts_file_analyzer/tests/tsc/types/nonPrimitive/.1.ts b/crates/stc_ts_file_analyzer/tests/tsc/types/nonPrimitive/1.ts similarity index 68% rename from crates/stc_ts_file_analyzer/tests/tsc/types/nonPrimitive/.1.ts rename to crates/stc_ts_file_analyzer/tests/tsc/types/nonPrimitive/1.ts index 37063f079b..3bae34a150 100644 --- a/crates/stc_ts_file_analyzer/tests/tsc/types/nonPrimitive/.1.ts +++ b/crates/stc_ts_file_analyzer/tests/tsc/types/nonPrimitive/1.ts @@ -6,4 +6,7 @@ function l(s: string, tp: T[P]): void { } function m(s: string, tp: T[P]): void { tp = s; -} \ No newline at end of file +} +function f(s: string, tp: T[P]): void { + tp = s; +} diff --git a/crates/stc_ts_file_analyzer/tests/tsc/types/nonPrimitive/1.tsc-errors.json b/crates/stc_ts_file_analyzer/tests/tsc/types/nonPrimitive/1.tsc-errors.json new file mode 100644 index 0000000000..a05a87d41a --- /dev/null +++ b/crates/stc_ts_file_analyzer/tests/tsc/types/nonPrimitive/1.tsc-errors.json @@ -0,0 +1,20 @@ +[ + { + "file": "tests/tsc/types/nonPrimitive/1.ts", + "line": 5, + "col": 5, + "code": 2322 + }, + { + "file": "tests/tsc/types/nonPrimitive/1.ts", + "line": 8, + "col": 5, + "code": 2322 + }, + { + "file": "tests/tsc/types/nonPrimitive/1.ts", + "line": 11, + "col": 5, + "code": 2322 + } +] \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance.pass.txt b/crates/stc_ts_type_checker/tests/conformance.pass.txt index 2e71241343..58892e1825 100644 --- a/crates/stc_ts_type_checker/tests/conformance.pass.txt +++ b/crates/stc_ts_type_checker/tests/conformance.pass.txt @@ -2428,6 +2428,7 @@ types/nonPrimitive/nonPrimitiveAndEmptyObject.ts types/nonPrimitive/nonPrimitiveAndTypeVariables.ts types/nonPrimitive/nonPrimitiveAsProperty.ts types/nonPrimitive/nonPrimitiveAssignError.ts +types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.ts types/nonPrimitive/nonPrimitiveInFunction.ts types/nonPrimitive/nonPrimitiveInGeneric.ts types/nonPrimitive/nonPrimitiveIndexingWithForIn.ts diff --git a/crates/stc_ts_type_checker/tests/conformance/types/mapped/mappedTypeRelationships.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/types/mapped/mappedTypeRelationships.error-diff.json index e0ebb4a483..c9599c2010 100644 --- a/crates/stc_ts_type_checker/tests/conformance/types/mapped/mappedTypeRelationships.error-diff.json +++ b/crates/stc_ts_type_checker/tests/conformance/types/mapped/mappedTypeRelationships.error-diff.json @@ -1,13 +1,16 @@ { "required_errors": { - "TS2322": 12, - "TS2536": 4, - "TS2542": 4 + "TS2542": 4, + "TS2322": 10 }, "required_error_lines": { + "TS2542": [ + 54, + 59, + 64, + 69 + ], "TS2322": [ - 14, - 19, 75, 81, 91, @@ -18,25 +21,14 @@ 161, 166, 171 - ], - "TS2536": [ - 23, - 24, - 28, - 29 - ], - "TS2542": [ - 54, - 59, - 64, - 69 ] }, "extra_errors": { - "TS2322": 5 + "TS2322": 6 }, "extra_error_lines": { "TS2322": [ + 18, 39, 58, 59, diff --git a/crates/stc_ts_type_checker/tests/conformance/types/mapped/mappedTypeRelationships.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/types/mapped/mappedTypeRelationships.stats.rust-debug index 4e774fdd28..7739abdef4 100644 --- a/crates/stc_ts_type_checker/tests/conformance/types/mapped/mappedTypeRelationships.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/types/mapped/mappedTypeRelationships.stats.rust-debug @@ -1,6 +1,6 @@ Stats { - required_error: 20, - matched_error: 8, - extra_error: 5, + required_error: 14, + matched_error: 14, + extra_error: 6, panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.error-diff.json deleted file mode 100644 index b6be05c17d..0000000000 --- a/crates/stc_ts_type_checker/tests/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.error-diff.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "required_errors": { - "TS2322": 1 - }, - "required_error_lines": { - "TS2322": [ - 28 - ] - }, - "extra_errors": {}, - "extra_error_lines": {} -} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.stats.rust-debug index 4074730ba8..5fd5d2127d 100644 --- a/crates/stc_ts_type_checker/tests/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/types/nonPrimitive/nonPrimitiveConstraintOfIndexAccessType.stats.rust-debug @@ -1,6 +1,6 @@ Stats { - required_error: 1, - matched_error: 9, + required_error: 0, + matched_error: 10, extra_error: 0, panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug index 8ce4c1a1a4..26769c1753 100644 --- a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug @@ -1,6 +1,6 @@ Stats { - required_error: 3500, - matched_error: 6535, - extra_error: 763, + required_error: 3493, + matched_error: 6542, + extra_error: 764, panic: 73, } \ No newline at end of file From 1ae919e56b68074e5f551c5fdf18c2bde9a8475a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=98=A4=EB=B3=91=EC=A7=84?= <64676070+sunrabbit123@users.noreply.github.com> Date: Sat, 9 Sep 2023 12:40:32 +0900 Subject: [PATCH 22/40] refactor: Reduce unused code (#1078) --- .../src/analyzer/expr/bin.rs | 91 +++++++------------ 1 file changed, 32 insertions(+), 59 deletions(-) diff --git a/crates/stc_ts_file_analyzer/src/analyzer/expr/bin.rs b/crates/stc_ts_file_analyzer/src/analyzer/expr/bin.rs index 38ac67de83..0c4c305dd1 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/expr/bin.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/expr/bin.rs @@ -345,12 +345,7 @@ impl Analyzer<'_, '_> { } _ => None, }) { - let ty = ty.clone().freezed(); - if is_eq { - self.add_deep_type_fact(span, name, ty, true); - } else { - self.add_deep_type_fact(span, name, ty, false); - } + self.add_deep_type_fact(span, name, ty.clone().freezed(), is_eq); } self.add_type_facts_for_opt_chains(span, left, right, <, &rt) @@ -388,12 +383,12 @@ impl Analyzer<'_, '_> { let mut is_loose_comparison_with_null_or_undefined = false; match op { op!("==") | op!("!=") => { - if r.is_null() | r.is_undefined() { + if r.is_null_or_undefined() { is_loose_comparison_with_null_or_undefined = true; let eq = TypeFacts::EQUndefinedOrNull | TypeFacts::EQNull | TypeFacts::EQUndefined; let neq = TypeFacts::NEUndefinedOrNull | TypeFacts::NENull | TypeFacts::NEUndefined; - if op == op!("==") { + if is_eq { *self.cur_facts.true_facts.facts.entry(name.clone()).or_default() |= eq; *self.cur_facts.false_facts.facts.entry(name.clone()).or_default() |= neq; } else { @@ -402,42 +397,31 @@ impl Analyzer<'_, '_> { } } } - op!("===") => { - if r.is_null() { - let eq = TypeFacts::EQNull; - let neq = TypeFacts::NENull; - - if op == op!("===") { - *self.cur_facts.true_facts.facts.entry(name.clone()).or_default() |= eq; - *self.cur_facts.false_facts.facts.entry(name.clone()).or_default() |= neq; - } else { - *self.cur_facts.true_facts.facts.entry(name.clone()).or_default() |= neq; - *self.cur_facts.false_facts.facts.entry(name.clone()).or_default() |= eq; - } - } else if r.is_undefined() { - let eq = TypeFacts::EQUndefined; - let neq = TypeFacts::NEUndefined; - - if op == op!("===") { - *self.cur_facts.true_facts.facts.entry(name.clone()).or_default() |= eq; - *self.cur_facts.false_facts.facts.entry(name.clone()).or_default() |= neq; - } else { - *self.cur_facts.true_facts.facts.entry(name.clone()).or_default() |= neq; - *self.cur_facts.false_facts.facts.entry(name.clone()).or_default() |= eq; - } - } + op!("===") if r.is_null() => { + *self.cur_facts.true_facts.facts.entry(name.clone()).or_default() |= TypeFacts::EQNull; + *self.cur_facts.false_facts.facts.entry(name.clone()).or_default() |= TypeFacts::NENull; + } + op!("===") if r.is_undefined() => { + *self.cur_facts.true_facts.facts.entry(name.clone()).or_default() |= TypeFacts::EQUndefined; + *self.cur_facts.false_facts.facts.entry(name.clone()).or_default() |= TypeFacts::NEUndefined; } _ => (), } - let additional_target = if lt.metadata().destructure_key.0 > 0 { - let origin_ty = self.find_destructor(lt.metadata().destructure_key); - if let Some(ty) = origin_ty { - let ty = ty.into_owned(); - self.get_additional_exclude_target(span, ty, &r, name.clone(), is_loose_comparison_with_null_or_undefined) - } else { - Default::default() + + let additional_target = 'target: { + let key = lt.metadata().destructure_key; + if key.0 > 0 { + if let Some(ty) = self.find_destructor(key) { + break 'target self.get_additional_exclude_target( + span, + ty.into_owned(), + &r, + name.clone(), + is_loose_comparison_with_null_or_undefined, + ); + } } - } else { + Default::default() }; @@ -482,17 +466,9 @@ impl Analyzer<'_, '_> { .entry(name.clone()) .or_default() .extend(exclude_types); - for (name, exclude_type) in additional_target.iter() { - self.cur_facts - .false_facts - .excludes - .entry(name.clone()) - .or_default() - .extend(exclude_type.clone()); - } } - r = if let Type::Param(TypeParam { + if let Type::Param(TypeParam { span: param_span, constraint: Some(param), name: param_name, @@ -502,7 +478,7 @@ impl Analyzer<'_, '_> { }) = c.left.1.normalize() { if param.is_unknown() || param.is_any() { - Type::Param(TypeParam { + r = Type::Param(TypeParam { span: *param_span, constraint: Some(Box::new(Type::Keyword(KeywordType { span: *param_span, @@ -515,18 +491,15 @@ impl Analyzer<'_, '_> { metadata: *metadata, tracker: Default::default(), }) - } else { - r } - } else { - r }; + self.add_deep_type_fact(span, name, r, is_eq); - for (name, exclude_type) in additional_target.iter() { - for exclude in exclude_type.iter() { - self.add_deep_type_fact(span, name.clone(), exclude.clone(), is_eq); - } - } + additional_target.iter().for_each(|(name, exclude_type)| { + exclude_type + .iter() + .for_each(|exclude| self.add_deep_type_fact(span, name.clone(), exclude.clone(), is_eq)); + }); } } } From 637a99c41c5c51308ea5144a7889d7e848179853 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=98=A4=EB=B3=91=EC=A7=84?= <64676070+sunrabbit123@users.noreply.github.com> Date: Sat, 9 Sep 2023 12:51:36 +0900 Subject: [PATCH 23/40] refactor: Remove duplicate code (#1080) --- .../src/analyzer/expr/bin.rs | 82 ++++++++----------- 1 file changed, 35 insertions(+), 47 deletions(-) diff --git a/crates/stc_ts_file_analyzer/src/analyzer/expr/bin.rs b/crates/stc_ts_file_analyzer/src/analyzer/expr/bin.rs index 0c4c305dd1..42b980d736 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/expr/bin.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/expr/bin.rs @@ -1020,56 +1020,49 @@ impl Analyzer<'_, '_> { // A type guard of the form typeof x === s and typeof x !== s, // where s is a string literal with any value but 'string', 'number' or // 'boolean' + let default_extends_type = vec![ + Type::Keyword(KeywordType { + span, + kind: TsKeywordTypeKind::TsStringKeyword, + metadata: Default::default(), + tracker: Default::default(), + }), + Type::Keyword(KeywordType { + span, + kind: TsKeywordTypeKind::TsBooleanKeyword, + metadata: Default::default(), + tracker: Default::default(), + }), + Type::Keyword(KeywordType { + span, + kind: TsKeywordTypeKind::TsNumberKeyword, + metadata: Default::default(), + tracker: Default::default(), + }), + ]; + let name = Name::try_from(&**arg).unwrap(); if is_eq { // - typeof x === s // removes the primitive types string, number, and boolean from // the type of x in true facts. - self.cur_facts.true_facts.excludes.entry(name).or_default().extend(vec![ - Type::Keyword(KeywordType { - span, - kind: TsKeywordTypeKind::TsStringKeyword, - metadata: Default::default(), - tracker: Default::default(), - }), - Type::Keyword(KeywordType { - span, - kind: TsKeywordTypeKind::TsBooleanKeyword, - metadata: Default::default(), - tracker: Default::default(), - }), - Type::Keyword(KeywordType { - span, - kind: TsKeywordTypeKind::TsNumberKeyword, - metadata: Default::default(), - tracker: Default::default(), - }), - ]); + self.cur_facts + .true_facts + .excludes + .entry(name) + .or_default() + .extend(default_extends_type); } else { // - typeof x !== s // removes the primitive types string, number, and boolean from // the type of x in false facts. - self.cur_facts.false_facts.excludes.entry(name).or_default().extend(vec![ - Type::Keyword(KeywordType { - span, - kind: TsKeywordTypeKind::TsStringKeyword, - metadata: Default::default(), - tracker: Default::default(), - }), - Type::Keyword(KeywordType { - span, - kind: TsKeywordTypeKind::TsBooleanKeyword, - metadata: Default::default(), - tracker: Default::default(), - }), - Type::Keyword(KeywordType { - span, - kind: TsKeywordTypeKind::TsNumberKeyword, - metadata: Default::default(), - tracker: Default::default(), - }), - ]); + self.cur_facts + .false_facts + .excludes + .entry(name) + .or_default() + .extend(default_extends_type); } None } @@ -1192,9 +1185,6 @@ impl Analyzer<'_, '_> { } fn can_compare_with_eq(&mut self, span: Span, disc_ty: &Type, case_ty: &Type) -> VResult { - let disc_ty = disc_ty.normalize(); - let case_ty = case_ty.normalize(); - if disc_ty.type_eq(case_ty) { return Ok(true); } @@ -1203,10 +1193,8 @@ impl Analyzer<'_, '_> { return Ok(false); } - if self.ctx.in_switch_case_test { - if disc_ty.is_intersection() { - return Ok(true); - } + if self.ctx.in_switch_case_test && disc_ty.is_intersection() { + return Ok(true); } self.has_overlap( From 90f7c040c49ea49cca0fc44d2fb54f168797418b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=98=A4=EB=B3=91=EC=A7=84?= <64676070+sunrabbit123@users.noreply.github.com> Date: Sun, 10 Sep 2023 16:43:49 +0900 Subject: [PATCH 24/40] feat: Implement error emission about existing file (#1076) **Related issue:** - Part of #705 --- .../tests/conformance.pass.txt | 1 + ...uleResolutionWithExtensions.error-diff.json | 12 ++++++++++++ ...leResolutionWithExtensions.stats.rust-debug | 4 ++-- .../relativePathMustResolve.stats.rust-debug | 6 +++--- ...lativePathToDeclarationFile.error-diff.json | 14 ++++++++++++++ ...ativePathToDeclarationFile.stats.rust-debug | 4 ++-- .../allowImportingTsExtensions.error-diff.json | 12 ++++++++++++ ...allowImportingTsExtensions.stats.rust-debug | 4 ++-- ...mlFileWithinDeclarationFile.error-diff.json | 13 +++++++++++++ ...lFileWithinDeclarationFile.stats.rust-debug | 4 ++-- ...eclarationFileForHtmlImport.error-diff.json | 12 ++++++++++++ ...clarationFileForHtmlImport.stats.rust-debug | 4 ++-- .../importTypeLocalMissing.error-diff.json | 18 ++++++++++++++++++ .../importTypeLocalMissing.stats.rust-debug | 8 ++++---- .../tests/tsc-stats.rust-debug | 8 ++++---- crates/stc_ts_type_checker/tests/tsc.rs | 4 ++-- 16 files changed, 105 insertions(+), 23 deletions(-) create mode 100644 crates/stc_ts_type_checker/tests/conformance/externalModules/moduleResolutionWithExtensions.error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/externalModules/relativePathToDeclarationFile.error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/moduleResolution/allowImportingTsExtensions.error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/nonjsExtensions/declarationFileForHtmlFileWithinDeclarationFile.error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/nonjsExtensions/declarationFileForHtmlImport.error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/types/import/importTypeLocalMissing.error-diff.json diff --git a/crates/stc_ts_type_checker/tests/conformance.pass.txt b/crates/stc_ts_type_checker/tests/conformance.pass.txt index 58892e1825..70a0fba1ff 100644 --- a/crates/stc_ts_type_checker/tests/conformance.pass.txt +++ b/crates/stc_ts_type_checker/tests/conformance.pass.txt @@ -1699,6 +1699,7 @@ externalModules/multipleExportDefault6.ts externalModules/nameDelimitedBySlashes.ts externalModules/nameWithFileExtension.ts externalModules/reexportClassDefinition.ts +externalModules/relativePathMustResolve.ts externalModules/topLevelAwait.3.ts externalModules/topLevelFileModule.ts externalModules/topLevelFileModuleMissing.ts diff --git a/crates/stc_ts_type_checker/tests/conformance/externalModules/moduleResolutionWithExtensions.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/externalModules/moduleResolutionWithExtensions.error-diff.json new file mode 100644 index 0000000000..dba7272865 --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/externalModules/moduleResolutionWithExtensions.error-diff.json @@ -0,0 +1,12 @@ +{ + "required_errors": {}, + "required_error_lines": {}, + "extra_errors": { + "TS2307": 1 + }, + "extra_error_lines": { + "TS2307": [ + 1 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/externalModules/moduleResolutionWithExtensions.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/externalModules/moduleResolutionWithExtensions.stats.rust-debug index 27ba984132..0498397634 100644 --- a/crates/stc_ts_type_checker/tests/conformance/externalModules/moduleResolutionWithExtensions.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/externalModules/moduleResolutionWithExtensions.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 0, - panic: 1, + extra_error: 1, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/externalModules/relativePathMustResolve.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/externalModules/relativePathMustResolve.stats.rust-debug index f79107e8ee..f3e39f53bd 100644 --- a/crates/stc_ts_type_checker/tests/conformance/externalModules/relativePathMustResolve.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/externalModules/relativePathMustResolve.stats.rust-debug @@ -1,6 +1,6 @@ Stats { - required_error: 1, - matched_error: 0, + required_error: 0, + matched_error: 1, extra_error: 0, - panic: 1, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/externalModules/relativePathToDeclarationFile.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/externalModules/relativePathToDeclarationFile.error-diff.json new file mode 100644 index 0000000000..6ba22cb597 --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/externalModules/relativePathToDeclarationFile.error-diff.json @@ -0,0 +1,14 @@ +{ + "required_errors": {}, + "required_error_lines": {}, + "extra_errors": { + "TS2307": 3 + }, + "extra_error_lines": { + "TS2307": [ + 1, + 2, + 3 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/externalModules/relativePathToDeclarationFile.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/externalModules/relativePathToDeclarationFile.stats.rust-debug index 27ba984132..7d12ad5c64 100644 --- a/crates/stc_ts_type_checker/tests/conformance/externalModules/relativePathToDeclarationFile.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/externalModules/relativePathToDeclarationFile.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 0, - panic: 1, + extra_error: 3, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/moduleResolution/allowImportingTsExtensions.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/moduleResolution/allowImportingTsExtensions.error-diff.json new file mode 100644 index 0000000000..dba7272865 --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/moduleResolution/allowImportingTsExtensions.error-diff.json @@ -0,0 +1,12 @@ +{ + "required_errors": {}, + "required_error_lines": {}, + "extra_errors": { + "TS2307": 1 + }, + "extra_error_lines": { + "TS2307": [ + 1 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/moduleResolution/allowImportingTsExtensions.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/moduleResolution/allowImportingTsExtensions.stats.rust-debug index 27ba984132..0498397634 100644 --- a/crates/stc_ts_type_checker/tests/conformance/moduleResolution/allowImportingTsExtensions.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/moduleResolution/allowImportingTsExtensions.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 0, - panic: 1, + extra_error: 1, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/nonjsExtensions/declarationFileForHtmlFileWithinDeclarationFile.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/nonjsExtensions/declarationFileForHtmlFileWithinDeclarationFile.error-diff.json new file mode 100644 index 0000000000..c2d072b17f --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/nonjsExtensions/declarationFileForHtmlFileWithinDeclarationFile.error-diff.json @@ -0,0 +1,13 @@ +{ + "required_errors": {}, + "required_error_lines": {}, + "extra_errors": { + "TS2307": 2 + }, + "extra_error_lines": { + "TS2307": [ + 1, + 1 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/nonjsExtensions/declarationFileForHtmlFileWithinDeclarationFile.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/nonjsExtensions/declarationFileForHtmlFileWithinDeclarationFile.stats.rust-debug index 27ba984132..d45524b098 100644 --- a/crates/stc_ts_type_checker/tests/conformance/nonjsExtensions/declarationFileForHtmlFileWithinDeclarationFile.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/nonjsExtensions/declarationFileForHtmlFileWithinDeclarationFile.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 0, - panic: 1, + extra_error: 2, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/nonjsExtensions/declarationFileForHtmlImport.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/nonjsExtensions/declarationFileForHtmlImport.error-diff.json new file mode 100644 index 0000000000..dba7272865 --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/nonjsExtensions/declarationFileForHtmlImport.error-diff.json @@ -0,0 +1,12 @@ +{ + "required_errors": {}, + "required_error_lines": {}, + "extra_errors": { + "TS2307": 1 + }, + "extra_error_lines": { + "TS2307": [ + 1 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/nonjsExtensions/declarationFileForHtmlImport.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/nonjsExtensions/declarationFileForHtmlImport.stats.rust-debug index 27ba984132..0498397634 100644 --- a/crates/stc_ts_type_checker/tests/conformance/nonjsExtensions/declarationFileForHtmlImport.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/nonjsExtensions/declarationFileForHtmlImport.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 0, - panic: 1, + extra_error: 1, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeLocalMissing.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeLocalMissing.error-diff.json new file mode 100644 index 0000000000..77be6774be --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeLocalMissing.error-diff.json @@ -0,0 +1,18 @@ +{ + "required_errors": { + "TS2694": 1 + }, + "required_error_lines": { + "TS2694": [ + 3 + ] + }, + "extra_errors": { + "TS0": 1 + }, + "extra_error_lines": { + "TS0": [ + 16 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeLocalMissing.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeLocalMissing.stats.rust-debug index 9a5e5f9eba..c28efdd8e5 100644 --- a/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeLocalMissing.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeLocalMissing.stats.rust-debug @@ -1,6 +1,6 @@ Stats { - required_error: 4, - matched_error: 0, - extra_error: 0, - panic: 1, + required_error: 1, + matched_error: 3, + extra_error: 1, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug index 26769c1753..dd1f1169c0 100644 --- a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug @@ -1,6 +1,6 @@ Stats { - required_error: 3493, - matched_error: 6542, - extra_error: 764, - panic: 73, + required_error: 3489, + matched_error: 6546, + extra_error: 773, + panic: 66, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/tsc.rs b/crates/stc_ts_type_checker/tests/tsc.rs index 5666522e23..8dae2f3ea5 100644 --- a/crates/stc_ts_type_checker/tests/tsc.rs +++ b/crates/stc_ts_type_checker/tests/tsc.rs @@ -16,7 +16,7 @@ use std::{ sync::Arc, }; -use anyhow::{Context, Error}; +use anyhow::{bail, Context, Error}; use indexmap::IndexMap; use once_cell::sync::Lazy; use parking_lot::Mutex; @@ -662,7 +662,7 @@ impl LoadFile for TestFileSystem { } } - todo!("load_file: {:?} ", filename); + bail!("not found module"); } } From 13696aebda0ec727b2e885be46b7da03847d76a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=98=A4=EB=B3=91=EC=A7=84?= <64676070+sunrabbit123@users.noreply.github.com> Date: Sun, 10 Sep 2023 17:03:19 +0900 Subject: [PATCH 25/40] refactor: Use `Type::xx` as constructor for readability (#1079) --- .../src/analyzer/assign/mod.rs | 7 +-- .../src/analyzer/assign/type_el.rs | 10 +--- .../src/analyzer/class/mod.rs | 7 +-- .../src/analyzer/expr/array.rs | 7 +-- .../src/analyzer/expr/bin.rs | 56 ++----------------- .../src/analyzer/expr/mod.rs | 51 +++-------------- .../src/analyzer/props.rs | 9 ++- .../src/analyzer/stmt/return_type.rs | 10 ++-- .../src/analyzer/types/mod.rs | 21 +------ .../stc_ts_file_analyzer/src/ty/type_facts.rs | 22 ++------ .../src/union_normalization.rs | 11 +--- crates/stc_ts_types/src/lib.rs | 13 +++++ 12 files changed, 50 insertions(+), 174 deletions(-) diff --git a/crates/stc_ts_file_analyzer/src/analyzer/assign/mod.rs b/crates/stc_ts_file_analyzer/src/analyzer/assign/mod.rs index 965cdac254..f921ceca3b 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/assign/mod.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/assign/mod.rs @@ -270,14 +270,11 @@ impl Analyzer<'_, '_> { let mut skip_check_null_or_undefined_of_rhs = false; match op { op!("*=") | op!("**=") | op!("/=") | op!("%=") | op!("-=") => { - if let Type::Keyword(KeywordType { - kind: TsKeywordTypeKind::TsUndefinedKeyword | TsKeywordTypeKind::TsNullKeyword, - .. - }) = rhs - { + if rhs.is_null_or_undefined() { if op == op!("**=") { skip_check_null_or_undefined_of_rhs = true; } + if op != op!("**=") && !self.rule().strict_null_checks && (l.is_num() || l.is_enum_variant()) { skip_check_null_or_undefined_of_rhs = true; } else { diff --git a/crates/stc_ts_file_analyzer/src/analyzer/assign/type_el.rs b/crates/stc_ts_file_analyzer/src/analyzer/assign/type_el.rs index f9c29af448..8638417187 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/assign/type_el.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/assign/type_el.rs @@ -1413,15 +1413,7 @@ impl Analyzer<'_, '_> { l_index_ret_ty, &Type::new_union( span, - vec![ - *r_prop_ty.clone(), - Type::Keyword(KeywordType { - span, - kind: TsKeywordTypeKind::TsUndefinedKeyword, - metadata: Default::default(), - tracker: Default::default(), - }), - ], + vec![*r_prop_ty.clone(), Type::undefined(span, Default::default())], ), opts, ) diff --git a/crates/stc_ts_file_analyzer/src/analyzer/class/mod.rs b/crates/stc_ts_file_analyzer/src/analyzer/class/mod.rs index d4c8517fbd..51e315d364 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/class/mod.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/class/mod.rs @@ -80,12 +80,7 @@ impl Analyzer<'_, '_> { .assign_with_opts( &mut Default::default(), ty, - &Type::Keyword(KeywordType { - span, - kind: TsKeywordTypeKind::TsUndefinedKeyword, - metadata: Default::default(), - tracker: Default::default(), - }), + &Type::undefined(span, Default::default()), AssignOpts { span, ..Default::default() diff --git a/crates/stc_ts_file_analyzer/src/analyzer/expr/array.rs b/crates/stc_ts_file_analyzer/src/analyzer/expr/array.rs index 53d4585e3f..c7c2332a62 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/expr/array.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/expr/array.rs @@ -299,12 +299,7 @@ impl Analyzer<'_, '_> { if !errors.is_empty() { if can_use_undefined && errors.len() != u.types.len() { - types.push(Type::Keyword(KeywordType { - span, - kind: TsKeywordTypeKind::TsUndefinedKeyword, - metadata: Default::default(), - tracker: Default::default(), - })); + types.push(Type::undefined(span, Default::default())); types.dedup_type(); return Ok(Cow::Owned(Type::new_union(span, types))); } diff --git a/crates/stc_ts_file_analyzer/src/analyzer/expr/bin.rs b/crates/stc_ts_file_analyzer/src/analyzer/expr/bin.rs index 42b980d736..ed7f2357ec 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/expr/bin.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/expr/bin.rs @@ -426,20 +426,7 @@ impl Analyzer<'_, '_> { }; let exclude_types = if is_loose_comparison_with_null_or_undefined { - vec![ - Type::Keyword(KeywordType { - span, - kind: TsKeywordTypeKind::TsNullKeyword, - metadata: Default::default(), - tracker: Default::default(), - }), - Type::Keyword(KeywordType { - span, - kind: TsKeywordTypeKind::TsUndefinedKeyword, - metadata: Default::default(), - tracker: Default::default(), - }), - ] + Type::null_and_undefined(span, Default::default()) } else { exclude.freezed() }; @@ -1874,16 +1861,7 @@ impl Analyzer<'_, '_> { let actual = name.slice_to(name.len() - 1); if has_undefined && candidates.is_empty() { - return Ok(( - actual, - Type::Keyword(KeywordType { - span: u.span, - kind: TsKeywordTypeKind::TsUndefinedKeyword, - metadata: Default::default(), - tracker: Default::default(), - }), - excluded.freezed(), - )); + return Ok((actual, Type::undefined(span, Default::default()), excluded.freezed())); } let ty = Type::new_union(span, candidates).freezed(); return Ok((actual, ty, excluded.freezed())); @@ -2280,20 +2258,7 @@ impl Analyzer<'_, '_> { temp_vec.clone() } else { if is_loose_comparison { - vec![ - Type::Keyword(KeywordType { - span, - kind: TsKeywordTypeKind::TsNullKeyword, - metadata: Default::default(), - tracker: Default::default(), - }), - Type::Keyword(KeywordType { - span, - kind: TsKeywordTypeKind::TsUndefinedKeyword, - metadata: Default::default(), - tracker: Default::default(), - }), - ] + Type::null_and_undefined(span, Default::default()) } else { vec![] } @@ -2344,20 +2309,7 @@ impl Analyzer<'_, '_> { temp_vec.clone() } else { if is_loose_comparison { - vec![ - Type::Keyword(KeywordType { - span, - kind: TsKeywordTypeKind::TsNullKeyword, - metadata: Default::default(), - tracker: Default::default(), - }), - Type::Keyword(KeywordType { - span, - kind: TsKeywordTypeKind::TsUndefinedKeyword, - metadata: Default::default(), - tracker: Default::default(), - }), - ] + Type::null_and_undefined(span, Default::default()) } else { vec![] } diff --git a/crates/stc_ts_file_analyzer/src/analyzer/expr/mod.rs b/crates/stc_ts_file_analyzer/src/analyzer/expr/mod.rs index ef72faaba3..cdf9095880 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/expr/mod.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/expr/mod.rs @@ -2612,12 +2612,7 @@ impl Analyzer<'_, '_> { } if !opts.disallow_inexact && metadata.inexact { - return Ok(Type::Keyword(KeywordType { - span, - kind: TsKeywordTypeKind::TsUndefinedKeyword, - metadata: Default::default(), - tracker: Default::default(), - })); + return Ok(Type::undefined(span, Default::default())); } return Err(ErrorKind::NoSuchProperty { @@ -2720,12 +2715,7 @@ impl Analyzer<'_, '_> { } else { if !errors.is_empty() { if is_all_tuple && errors.len() != types.len() { - result_types.push(Type::Keyword(KeywordType { - span, - kind: TsKeywordTypeKind::TsUndefinedKeyword, - metadata: Default::default(), - tracker: Default::default(), - })); + result_types.push(Type::undefined(span, Default::default())); result_types.dedup_type(); let ty = Type::new_union(span, result_types); ty.assert_valid(); @@ -2828,13 +2818,9 @@ impl Analyzer<'_, '_> { if v as usize >= elems.len() { if opts.use_undefined_for_tuple_index_error { - return Ok(Type::Keyword(KeywordType { - span, - kind: TsKeywordTypeKind::TsUndefinedKeyword, - metadata: Default::default(), - tracker: Default::default(), - })); + return Ok(Type::undefined(span, Default::default())); } + if opts.use_last_element_for_tuple_on_out_of_bound { return Ok(*elems.last().unwrap().ty.clone()); } @@ -2848,12 +2834,7 @@ impl Analyzer<'_, '_> { } .context("returning undefined because it's l-value context"), ); - return Ok(Type::Keyword(KeywordType { - span, - kind: TsKeywordTypeKind::TsUndefinedKeyword, - metadata: Default::default(), - tracker: Default::default(), - })); + return Ok(Type::undefined(span, Default::default())); } return Err(ErrorKind::TupleIndexError { @@ -4783,13 +4764,9 @@ impl Analyzer<'_, '_> { type_ann: Option<&Type>, ) -> VResult { if i.sym == js_word!("undefined") { - return Ok(Type::Keyword(KeywordType { - span: i.span.with_ctxt(SyntaxContext::empty()), - kind: TsKeywordTypeKind::TsUndefinedKeyword, - metadata: Default::default(), - tracker: Default::default(), - })); + return Ok(Type::undefined(i.span.with_ctxt(SyntaxContext::empty()), Default::default())); } + let ty = self.type_of_var(i, mode, type_args)?; if self.ctx.should_store_truthy_for_access && mode == TypeOfMode::RValue { // `i` is truthy @@ -4840,20 +4817,10 @@ impl Analyzer<'_, '_> { RLit::Null(RNull { span }) => { if self.ctx.in_export_default_expr { // TODO(kdy1): strict mode - return Ok(Type::Keyword(KeywordType { - span: *span, - kind: TsKeywordTypeKind::TsAnyKeyword, - metadata: Default::default(), - tracker: Default::default(), - })); + return Ok(Type::any(*span, Default::default())); } - Ok(Type::Keyword(KeywordType { - span: *span, - kind: TsKeywordTypeKind::TsNullKeyword, - metadata: Default::default(), - tracker: Default::default(), - })) + Ok(Type::null(*span, Default::default())) } RLit::Regex(v) => Ok(Type::Ref(Ref { span: v.span, diff --git a/crates/stc_ts_file_analyzer/src/analyzer/props.rs b/crates/stc_ts_file_analyzer/src/analyzer/props.rs index 148e77e819..1e60d6fc26 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/props.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/props.rs @@ -300,11 +300,10 @@ impl Analyzer<'_, '_> { false } - Type::Union(u) => u.types.iter().all(|ty| { - ty.is_kwd(TsKeywordTypeKind::TsNullKeyword) - || ty.is_kwd(TsKeywordTypeKind::TsUndefinedKeyword) - || self.is_type_valid_for_computed_key(span, ty) - }), + Type::Union(u) => u + .types + .iter() + .all(|ty| ty.is_null_or_undefined() || self.is_type_valid_for_computed_key(span, ty)), _ => false, } diff --git a/crates/stc_ts_file_analyzer/src/analyzer/stmt/return_type.rs b/crates/stc_ts_file_analyzer/src/analyzer/stmt/return_type.rs index 7c25c765e0..bf50e4418e 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/stmt/return_type.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/stmt/return_type.rs @@ -563,12 +563,10 @@ impl Analyzer<'_, '_> { self.scope.return_values.yield_types.push(item_ty); } else { - self.scope.return_values.yield_types.push(Type::Keyword(KeywordType { - span: e.span, - kind: TsKeywordTypeKind::TsUndefinedKeyword, - metadata: Default::default(), - tracker: Default::default(), - })); + self.scope + .return_values + .yield_types + .push(Type::undefined(e.span, Default::default())); } Ok(Type::any(e.span, Default::default())) diff --git a/crates/stc_ts_file_analyzer/src/analyzer/types/mod.rs b/crates/stc_ts_file_analyzer/src/analyzer/types/mod.rs index 851ec77592..0e41f2fc70 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/types/mod.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/types/mod.rs @@ -929,12 +929,7 @@ impl Analyzer<'_, '_> { if sum >= 2 { if sum == 2 && is_undefined && is_void { - return Ok(Some(Type::Keyword(KeywordType { - span, - kind: TsKeywordTypeKind::TsUndefinedKeyword, - metadata: KeywordTypeMetadata { ..Default::default() }, - tracker: Default::default(), - }))); + return Ok(Some(Type::undefined(span, Default::default()))); } return never!(); } @@ -2498,18 +2493,8 @@ impl Analyzer<'_, '_> { } let mut unknown = vec![ - Type::Keyword(KeywordType { - span: *span, - kind: TsKeywordTypeKind::TsNullKeyword, - metadata: Default::default(), - tracker: Default::default(), - }), - Type::Keyword(KeywordType { - span: *span, - kind: TsKeywordTypeKind::TsUndefinedKeyword, - metadata: Default::default(), - tracker: Default::default(), - }), + Type::null(*span, Default::default()), + Type::undefined(*span, Default::default()), Type::TypeLit(TypeLit { span: *span, members: vec![], diff --git a/crates/stc_ts_file_analyzer/src/ty/type_facts.rs b/crates/stc_ts_file_analyzer/src/ty/type_facts.rs index b64aeaebf4..e9c29ddeae 100644 --- a/crates/stc_ts_file_analyzer/src/ty/type_facts.rs +++ b/crates/stc_ts_file_analyzer/src/ty/type_facts.rs @@ -127,18 +127,13 @@ impl Analyzer<'_, '_> { Type::new_union_without_dedup( span, vec![ + Type::null(span, Default::default()), Type::Keyword(KeywordType { kind: TsKeywordTypeKind::TsObjectKeyword, metadata: Default::default(), span, tracker: Default::default(), }), - Type::Keyword(KeywordType { - kind: TsKeywordTypeKind::TsNullKeyword, - metadata: Default::default(), - span, - tracker: Default::default(), - }), ], ), ], @@ -467,25 +462,18 @@ impl Fold for TypeFactsHandler<'_, '_, '_> { // typeof x === 'object' // => x = {} | null if ty.is_unknown() && self.facts.contains(TypeFacts::TypeofEQObject) { - ty = Type::Union(Union { + ty = Type::new_union( span, - types: vec![ + vec![ Type::Keyword(KeywordType { span, kind: TsKeywordTypeKind::TsObjectKeyword, metadata: Default::default(), tracker: Default::default(), }), - Type::Keyword(KeywordType { - span, - kind: TsKeywordTypeKind::TsNullKeyword, - metadata: Default::default(), - tracker: Default::default(), - }), + Type::null(span, Default::default()), ], - metadata: Default::default(), - tracker: Default::default(), - }) + ) .freezed(); } diff --git a/crates/stc_ts_type_ops/src/union_normalization.rs b/crates/stc_ts_type_ops/src/union_normalization.rs index 083894c56e..fc560680d2 100644 --- a/crates/stc_ts_type_ops/src/union_normalization.rs +++ b/crates/stc_ts_type_ops/src/union_normalization.rs @@ -6,8 +6,8 @@ use rustc_hash::FxHashMap; use stc_ts_ast_rnode::{RBindingIdent, RIdent, RPat}; use stc_ts_generics::type_param::replacer::TypeParamReplacer; use stc_ts_types::{ - CallSignature, FnParam, Function, FunctionMetadata, Key, KeywordType, PropertySignature, Type, TypeElement, TypeLit, TypeLitMetadata, - TypeParamDecl, Union, + CallSignature, FnParam, Function, FunctionMetadata, Key, PropertySignature, Type, TypeElement, TypeLit, TypeLitMetadata, TypeParamDecl, + Union, }; use stc_utils::{cache::Freeze, dev_span, ext::TypeVecExt}; use swc_atoms::JsWord; @@ -357,12 +357,7 @@ impl ObjectUnionNormalizer { }, optional: true, params: Default::default(), - type_ann: Some(Box::new(Type::Keyword(KeywordType { - span: DUMMY_SP, - kind: TsKeywordTypeKind::TsUndefinedKeyword, - metadata: Default::default(), - tracker: Default::default(), - }))), + type_ann: Some(Box::new(Type::undefined(DUMMY_SP, Default::default()))), type_params: Default::default(), metadata: Default::default(), accessor: Default::default(), diff --git a/crates/stc_ts_types/src/lib.rs b/crates/stc_ts_types/src/lib.rs index dd622bf37e..58ab82b75c 100644 --- a/crates/stc_ts_types/src/lib.rs +++ b/crates/stc_ts_types/src/lib.rs @@ -1991,6 +1991,19 @@ impl Type { }) } + pub fn null_and_undefined(span: Span, metadata: KeywordTypeMetadata) -> Vec { + vec![Self::null(span, metadata), Self::undefined(span, metadata)] + } + + pub fn null(span: Span, metadata: KeywordTypeMetadata) -> Self { + Type::Keyword(KeywordType { + span, + kind: TsKeywordTypeKind::TsNullKeyword, + metadata, + tracker: Default::default(), + }) + } + pub fn undefined(span: Span, metadata: KeywordTypeMetadata) -> Self { Type::Keyword(KeywordType { span, From c5a9d98136fc9e27d5e27fb8648c56e04873a17c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=98=A4=EB=B3=91=EC=A7=84?= <64676070+sunrabbit123@users.noreply.github.com> Date: Mon, 11 Sep 2023 17:19:48 +0900 Subject: [PATCH 26/40] feat: Improve optional chaining validation (#1084) --- .../src/analyzer/expr/bin.rs | 56 ++++++++++++++++--- .../src/analyzer/types/mod.rs | 4 ++ .../tests/tsc/conformance/controlflow/1.ts | 25 +++++++++ .../conformance/controlflow/1.tsc-errors.json | 1 + .../controlFlowOptionalChain.error-diff.json | 13 ++--- .../controlFlowOptionalChain.stats.rust-debug | 6 +- .../tests/tsc-stats.rust-debug | 6 +- 7 files changed, 89 insertions(+), 22 deletions(-) create mode 100644 crates/stc_ts_file_analyzer/tests/tsc/conformance/controlflow/1.ts create mode 100644 crates/stc_ts_file_analyzer/tests/tsc/conformance/controlflow/1.tsc-errors.json diff --git a/crates/stc_ts_file_analyzer/src/analyzer/expr/bin.rs b/crates/stc_ts_file_analyzer/src/analyzer/expr/bin.rs index ed7f2357ec..0c56004e98 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/expr/bin.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/expr/bin.rs @@ -6,8 +6,8 @@ use std::{ use fxhash::FxHashMap; use stc_ts_ast_rnode::{ - RBinExpr, RBindingIdent, RComputedPropName, RExpr, RIdent, RLit, RMemberExpr, RMemberProp, ROptChainBase, ROptChainExpr, RPat, - RPatOrExpr, RStr, RTpl, RTsEntityName, RTsLit, RUnaryExpr, + RBinExpr, RBindingIdent, RCallExpr, RCallee, RComputedPropName, RExpr, RIdent, RLit, RMemberExpr, RMemberProp, ROptChainBase, + ROptChainExpr, RPat, RPatOrExpr, RStr, RTpl, RTsEntityName, RTsLit, RUnaryExpr, }; use stc_ts_errors::{DebugExt, ErrorKind, Errors}; use stc_ts_file_analyzer_macros::extra_validator; @@ -300,7 +300,7 @@ impl Analyzer<'_, '_> { match op { op!("===") | op!("!==") | op!("==") | op!("!=") => { let is_eq = op == op!("===") || op == op!("=="); - + let is_strict = op == op!("===") || op == op!("!=="); self.add_type_facts_for_typeof(span, left, right, is_eq, <, &rt) .report(&mut self.storage); @@ -348,7 +348,7 @@ impl Analyzer<'_, '_> { self.add_deep_type_fact(span, name, ty.clone().freezed(), is_eq); } - self.add_type_facts_for_opt_chains(span, left, right, <, &rt) + self.add_type_facts_for_opt_chains(span, left, right, <, &rt, is_eq, is_strict) .report(&mut self.storage); if let Some((l, r_ty)) = c.take_if_any_matches(|(l, _), (_, r_ty)| match (l, r_ty) { @@ -1104,7 +1104,16 @@ impl Analyzer<'_, '_> { /// /// The condition in the if statement above will be `true` if `f.geometry` /// is `undefined`. - fn add_type_facts_for_opt_chains(&mut self, span: Span, l: &RExpr, r: &RExpr, lt: &Type, rt: &Type) -> VResult<()> { + fn add_type_facts_for_opt_chains( + &mut self, + span: Span, + l: &RExpr, + r: &RExpr, + lt: &Type, + rt: &Type, + is_eq: bool, + is_strict: bool, + ) -> VResult<()> { /// Convert expression to names. /// /// This may return multiple names if there are optional chaining @@ -1121,6 +1130,23 @@ impl Analyzer<'_, '_> { names } + RExpr::Call(RCallExpr { + callee: RCallee::Expr(c), .. + }) => { + let mut names = non_undefined_names(c); + names.extend(e.try_into().ok()); + + names + } + + RExpr::Ident(..) => { + let mut names: Vec = vec![]; + + names.extend(e.try_into().ok()); + + names + } + RExpr::Member(e) => { let mut names = non_undefined_names(&e.obj); @@ -1161,8 +1187,24 @@ impl Analyzer<'_, '_> { } }) { if !self.can_be_undefined(span, r_ty, false)? { - for name in names { - self.cur_facts.false_facts.facts.insert(name.clone(), TypeFacts::NEUndefined); + if !is_eq { + for name in names { + self.cur_facts.false_facts.facts.insert(name.clone(), TypeFacts::NEUndefined); + } + } else if is_strict { + for name in names { + self.cur_facts.true_facts.facts.insert(name.clone(), TypeFacts::NEUndefined); + } + } + } else if r_ty.is_undefined() && !is_eq { + if is_strict { + for name in names { + self.cur_facts.true_facts.facts.insert(name.clone(), TypeFacts::NEUndefined); + } + } else { + for name in names { + self.cur_facts.true_facts.facts.insert(name.clone(), TypeFacts::NEUndefinedOrNull); + } } } } diff --git a/crates/stc_ts_file_analyzer/src/analyzer/types/mod.rs b/crates/stc_ts_file_analyzer/src/analyzer/types/mod.rs index 0e41f2fc70..0f8725d124 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/types/mod.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/types/mod.rs @@ -1443,6 +1443,10 @@ impl Analyzer<'_, '_> { return Ok(false); } + if ty.is_unknown() { + return Ok(true); + } + if include_null { if ty.is_null() { return Ok(true); diff --git a/crates/stc_ts_file_analyzer/tests/tsc/conformance/controlflow/1.ts b/crates/stc_ts_file_analyzer/tests/tsc/conformance/controlflow/1.ts new file mode 100644 index 0000000000..eba4054bef --- /dev/null +++ b/crates/stc_ts_file_analyzer/tests/tsc/conformance/controlflow/1.ts @@ -0,0 +1,25 @@ +// @strict: true +// @allowUnreachableCode: false + +type Thing = { foo: string | number, bar(): number, baz: object }; + +function f13(o: Thing | undefined) { + if (o?.foo !== undefined) { + o.foo; + } + if (o?.["foo"] !== undefined) { + o["foo"]; + } + if (o?.bar() !== undefined) { + o.bar; + } + if (o?.foo != undefined) { + o.foo; + } + if (o?.["foo"] != undefined) { + o["foo"]; + } + if (o?.bar() != undefined) { + o.bar; + } +} \ No newline at end of file diff --git a/crates/stc_ts_file_analyzer/tests/tsc/conformance/controlflow/1.tsc-errors.json b/crates/stc_ts_file_analyzer/tests/tsc/conformance/controlflow/1.tsc-errors.json new file mode 100644 index 0000000000..0637a088a0 --- /dev/null +++ b/crates/stc_ts_file_analyzer/tests/tsc/conformance/controlflow/1.tsc-errors.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/controlFlow/controlFlowOptionalChain.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/controlFlow/controlFlowOptionalChain.error-diff.json index 44f8d788b2..d2d60ad743 100644 --- a/crates/stc_ts_type_checker/tests/conformance/controlFlow/controlFlowOptionalChain.error-diff.json +++ b/crates/stc_ts_type_checker/tests/conformance/controlFlow/controlFlowOptionalChain.error-diff.json @@ -2,7 +2,7 @@ "required_errors": { "TS2454": 4, "TS2722": 2, - "TS2532": 16 + "TS2532": 18 }, "required_error_lines": { "TS2454": [ @@ -25,6 +25,8 @@ 223, 241, 244, + 370, + 382, 421, 424, 433, @@ -36,7 +38,7 @@ }, "extra_errors": { "TS2339": 3, - "TS2532": 14, + "TS2532": 7, "TS2531": 6, "TS7027": 2 }, @@ -47,15 +49,8 @@ 86 ], "TS2532": [ - 175, 184, - 238, - 253, - 256, - 259, - 268, 289, - 367, 394, 476, 480, diff --git a/crates/stc_ts_type_checker/tests/conformance/controlFlow/controlFlowOptionalChain.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/controlFlow/controlFlowOptionalChain.stats.rust-debug index abedd8d310..38b724370e 100644 --- a/crates/stc_ts_type_checker/tests/conformance/controlFlow/controlFlowOptionalChain.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/controlFlow/controlFlowOptionalChain.stats.rust-debug @@ -1,6 +1,6 @@ Stats { - required_error: 22, - matched_error: 39, - extra_error: 25, + required_error: 24, + matched_error: 37, + extra_error: 18, panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug index dd1f1169c0..0ce0fc0712 100644 --- a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug @@ -1,6 +1,6 @@ Stats { - required_error: 3489, - matched_error: 6546, - extra_error: 773, + required_error: 3491, + matched_error: 6544, + extra_error: 766, panic: 66, } \ No newline at end of file From 804a0beef80180d41d7b66aa055a52671867c40f Mon Sep 17 00:00:00 2001 From: AcrylicShrimp Date: Mon, 11 Sep 2023 18:58:06 +0900 Subject: [PATCH 27/40] refactor: Collect use of `std::time::Instant` into dedicated timer module (#1085) --- Cargo.lock | 1 + crates/stc/src/main.rs | 39 +++------ .../src/analyzer/expr/array.rs | 9 +-- .../src/analyzer/expr/mod.rs | 13 ++- .../src/analyzer/expr/object.rs | 10 +-- .../src/analyzer/generic/mod.rs | 12 +-- .../src/analyzer/scope/mod.rs | 10 +-- .../src/analyzer/stmt/mod.rs | 10 +-- crates/stc_ts_file_analyzer/src/env.rs | 6 +- crates/stc_ts_type_checker/src/lib.rs | 31 +++---- crates/stc_ts_type_checker/src/typings.rs | 7 +- crates/stc_utils/Cargo.toml | 1 + crates/stc_utils/src/lib.rs | 1 + crates/stc_utils/src/perf_timer.rs | 81 +++++++++++++++++++ 14 files changed, 141 insertions(+), 90 deletions(-) create mode 100644 crates/stc_utils/src/perf_timer.rs diff --git a/Cargo.lock b/Cargo.lock index 2a146059b2..cfc9616618 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2736,6 +2736,7 @@ name = "stc_utils" version = "0.1.0" dependencies = [ "ahash 0.7.6", + "log", "once_cell", "rustc-hash", "scoped-tls", diff --git a/crates/stc/src/main.rs b/crates/stc/src/main.rs index add3056b02..0c026628d4 100644 --- a/crates/stc/src/main.rs +++ b/crates/stc/src/main.rs @@ -1,6 +1,6 @@ extern crate swc_node_base; -use std::{path::PathBuf, sync::Arc, time::Instant}; +use std::{path::PathBuf, sync::Arc}; use anyhow::Error; use clap::Parser; @@ -13,6 +13,7 @@ use stc_ts_type_checker::{ loader::{DefaultFileLoader, ModuleLoader}, Checker, }; +use stc_utils::perf_timer::PerfTimer; use swc_common::{ errors::{ColorConfig, EmitterWriter, Handler}, FileName, Globals, SourceMap, GLOBALS, @@ -33,7 +34,7 @@ enum Command { #[tokio::main] async fn main() -> Result<(), Error> { - let start = Instant::now(); + let timer = PerfTimer::log_info(); env_logger::init(); @@ -57,18 +58,14 @@ async fn main() -> Result<(), Error> { rayon::ThreadPoolBuilder::new().build_global().unwrap(); - { - let end = Instant::now(); - - log::info!("Initialization took {:?}", end - start); - } + timer.log("Initialization"); let globals = Arc::::default(); match command { Command::Test(cmd) => { let libs = { - let start = Instant::now(); + let timer = PerfTimer::log_info(); let mut libs = match cmd.libs { Some(libs) => libs.iter().flat_map(|s| Lib::load(s)).collect::>(), @@ -77,9 +74,7 @@ async fn main() -> Result<(), Error> { libs.sort(); libs.dedup(); - let end = Instant::now(); - - log::info!("Loading builtin libraries took {:?}", end - start); + timer.log("Loading builtin libraries"); libs }; @@ -91,7 +86,7 @@ async fn main() -> Result<(), Error> { let path = PathBuf::from(cmd.file); { - let start = Instant::now(); + let timer = PerfTimer::log_info(); let checker = Checker::new( cm.clone(), @@ -103,14 +98,11 @@ async fn main() -> Result<(), Error> { checker.load_typings(&path, None, cmd.types.as_deref()); - let end = Instant::now(); - - log::info!("Loading typing libraries took {:?}", end - start); + timer.log("Loading typing libraries"); } let mut errors = vec![]; - let start = Instant::now(); GLOBALS.set(&globals, || { let mut checker = Checker::new( cm.clone(), @@ -125,21 +117,18 @@ async fn main() -> Result<(), Error> { errors.extend(checker.take_errors()); }); - let end = Instant::now(); - - log::info!("Checking took {:?}", end - start); + timer.log("Checking"); { - let start = Instant::now(); + let timer = PerfTimer::log_info(); + for err in &errors { err.emit(&handler); } - let end = Instant::now(); - log::info!("Found {} errors", errors.len()); - log::info!("Error reporting took {:?}", end - start); + timer.log("Error reporting"); } } Command::Lsp(cmd) => { @@ -147,9 +136,7 @@ async fn main() -> Result<(), Error> { } } - let end = Instant::now(); - - log::info!("Done in {:?}", end - start); + timer.log("Done"); Ok(()) } diff --git a/crates/stc_ts_file_analyzer/src/analyzer/expr/array.rs b/crates/stc_ts_file_analyzer/src/analyzer/expr/array.rs index c7c2332a62..7f83f205c1 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/expr/array.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/expr/array.rs @@ -1,4 +1,4 @@ -use std::{borrow::Cow, time::Instant}; +use std::borrow::Cow; use itertools::Itertools; use stc_ts_ast_rnode::{RArrayLit, RExpr, RExprOrSpread, RInvalid, RNumber, RTsLit}; @@ -15,6 +15,7 @@ use stc_utils::{ cache::Freeze, dev_span, ext::{SpanExt, TypeVecExt}, + perf_timer::PerfTimer, }; use swc_atoms::js_word; use swc_common::{Span, Spanned, SyntaxContext}; @@ -588,12 +589,10 @@ impl Analyzer<'_, '_> { } pub(crate) fn get_iterator<'a>(&mut self, span: Span, ty: Cow<'a, Type>, opts: GetIteratorOpts) -> VResult> { - let start = Instant::now(); + let timer = PerfTimer::noop(); let iterator = self.get_iterator_inner(span, ty, opts).context("tried to get iterator"); - let end = Instant::now(); - - debug!(kind = "perf", op = "get_iterator", "get_iterator (time = {:?}", end - start); + debug!(kind = "perf", op = "get_iterator", "get_iterator (time = {:?}", timer.elapsed()); let iterator = iterator?; diff --git a/crates/stc_ts_file_analyzer/src/analyzer/expr/mod.rs b/crates/stc_ts_file_analyzer/src/analyzer/expr/mod.rs index cdf9095880..0e93f2e255 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/expr/mod.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/expr/mod.rs @@ -2,7 +2,7 @@ use std::{ borrow::Cow, collections::HashMap, convert::{TryFrom, TryInto}, - time::{Duration, Instant}, + time::Duration, }; use optional_chaining::is_obj_opt_chaining; @@ -27,7 +27,7 @@ use stc_ts_types::{ PropertySignature, QueryExpr, QueryType, QueryTypeMetadata, Readonly, StaticThis, ThisType, TplElem, TplType, TplTypeMetadata, TypeParamInstantiation, }; -use stc_utils::{cache::Freeze, dev_span, ext::TypeVecExt, panic_ctx, stack}; +use stc_utils::{cache::Freeze, dev_span, ext::TypeVecExt, panic_ctx, perf_timer::PerfTimer, stack}; use swc_atoms::js_word; use swc_common::{SourceMapper, Span, Spanned, SyntaxContext, TypeEq, DUMMY_SP}; use swc_ecma_ast::{op, EsVersion, TruePlusMinus, TsKeywordTypeKind, VarDeclKind}; @@ -1229,7 +1229,7 @@ impl Analyzer<'_, '_> { let span = span.with_ctxt(SyntaxContext::empty()); - let start = Instant::now(); + let timer = PerfTimer::noop(); obj.assert_valid(); // Try some easier assignments. @@ -1353,17 +1353,16 @@ impl Analyzer<'_, '_> { ) }) } - let end = Instant::now(); - let dur = end - start; - if dur >= Duration::from_micros(100) { + let elapsed = timer.elapsed(); + if elapsed >= Duration::from_micros(100) { let line_col = self.line_col(span); debug!( kind = "perf", op = "access_property", "({}) access_property: (time = {:?})", line_col, - end - start + elapsed ); } diff --git a/crates/stc_ts_file_analyzer/src/analyzer/expr/object.rs b/crates/stc_ts_file_analyzer/src/analyzer/expr/object.rs index 22e84097bc..eb88459bd5 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/expr/object.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/expr/object.rs @@ -1,4 +1,4 @@ -use std::{borrow::Cow, time::Instant}; +use std::borrow::Cow; use rnode::VisitMutWith; use stc_ts_ast_rnode::{RObjectLit, RPropOrSpread, RSpreadElement}; @@ -6,7 +6,7 @@ use stc_ts_errors::{DebugExt, ErrorKind}; use stc_ts_file_analyzer_macros::validator; use stc_ts_type_ops::{union_normalization::ObjectUnionNormalizer, Fix}; use stc_ts_types::{Accessor, Key, MethodSignature, PropertySignature, Type, TypeElement, TypeLit, TypeParam, Union, UnionMetadata}; -use stc_utils::{cache::Freeze, dev_span}; +use stc_utils::{cache::Freeze, dev_span, perf_timer::PerfTimer}; use swc_common::{Span, Spanned, SyntaxContext, TypeEq}; use swc_ecma_ast::TsKeywordTypeKind; use tracing::debug; @@ -60,12 +60,10 @@ impl Analyzer<'_, '_> { pub(super) fn normalize_union(&mut self, ty: &mut Type, preserve_specified: bool) { let _tracing = dev_span!("normalize_union"); - let start = Instant::now(); + let timer = PerfTimer::noop(); ty.visit_mut_with(&mut ObjectUnionNormalizer { preserve_specified }); - let end = Instant::now(); - - debug!("Normalized unions (time = {:?})", end - start); + debug!("Normalized unions (time = {:?})", timer.elapsed()); } pub(crate) fn validate_type_literals(&mut self, ty: &Type, is_type_ann: bool) { diff --git a/crates/stc_ts_file_analyzer/src/analyzer/generic/mod.rs b/crates/stc_ts_file_analyzer/src/analyzer/generic/mod.rs index 17c9398108..3e4309432e 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/generic/mod.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/generic/mod.rs @@ -1,4 +1,4 @@ -use std::{borrow::Cow, cmp::min, collections::hash_map::Entry, mem::take, time::Instant}; +use std::{borrow::Cow, cmp::min, collections::hash_map::Entry, mem::take}; use fxhash::{FxHashMap, FxHashSet}; use itertools::{EitherOrBoth, Itertools}; @@ -21,7 +21,9 @@ use stc_ts_types::{ use stc_ts_utils::MapWithMut; use stc_utils::{ cache::{Freeze, ALLOW_DEEP_CLONE}, - dev_span, stack, + dev_span, + perf_timer::PerfTimer, + stack, }; use swc_atoms::js_word; use swc_common::{EqIgnoreSpan, Span, Spanned, SyntaxContext, TypeEq, DUMMY_SP}; @@ -114,7 +116,7 @@ impl Analyzer<'_, '_> { type_params.iter().map(|p| format!("{}, ", p.name)).collect::() ); - let start = Instant::now(); + let timer = PerfTimer::noop(); let mut inferred = InferData::default(); @@ -357,9 +359,7 @@ impl Analyzer<'_, '_> { let map = self.finalize_inference(span, type_params, inferred); - let end = Instant::now(); - - warn!("infer_arg_types is finished. (time = {:?})", end - start); + warn!("infer_arg_types is finished. (time = {:?})", timer.elapsed()); Ok(map) } diff --git a/crates/stc_ts_file_analyzer/src/analyzer/scope/mod.rs b/crates/stc_ts_file_analyzer/src/analyzer/scope/mod.rs index cfeadbe21f..0b62af2660 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/scope/mod.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/scope/mod.rs @@ -5,7 +5,6 @@ use std::{ iter, mem::{replace, take}, slice, - time::Instant, }; use fxhash::{FxHashMap, FxHashSet}; @@ -26,7 +25,9 @@ use stc_ts_types::{ }; use stc_utils::{ cache::{AssertCloneCheap, Freeze, ALLOW_DEEP_CLONE}, - dev_span, stack, + dev_span, + perf_timer::PerfTimer, + stack, }; use swc_atoms::js_word; use swc_common::{util::move_map::MoveMap, Span, Spanned, SyntaxContext, TypeEq, DUMMY_SP}; @@ -2707,9 +2708,8 @@ impl Fold for Expander<'_, '_, '_> { _ => {} } let before = dump_type_as_string(&ty); - let start = Instant::now(); + let timer = PerfTimer::noop(); let expanded = self.expand_type(ty).fixed(); - let end = Instant::now(); if !self.analyzer.config.is_builtin { expanded.assert_valid(); @@ -2717,7 +2717,7 @@ impl Fold for Expander<'_, '_, '_> { debug!( "[expander (time = {:?})]: {} => {}", - end - start, + timer.elapsed(), before, dump_type_as_string(&expanded) ); diff --git a/crates/stc_ts_file_analyzer/src/analyzer/stmt/mod.rs b/crates/stc_ts_file_analyzer/src/analyzer/stmt/mod.rs index ac744d1587..2c4102d221 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/stmt/mod.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/stmt/mod.rs @@ -1,10 +1,8 @@ -use std::time::Instant; - use rnode::VisitWith; use stc_ts_ast_rnode::{RBlockStmt, RBool, RDecl, RExpr, RExprStmt, RForStmt, RModuleItem, RStmt, RTsExprWithTypeArgs, RTsLit, RWithStmt}; use stc_ts_errors::{DebugExt, ErrorKind}; use stc_ts_types::{LitType, Type}; -use stc_utils::{dev_span, stack}; +use stc_utils::{dev_span, perf_timer::PerfTimer, stack}; use swc_common::{Spanned, DUMMY_SP}; use swc_ecma_utils::Value::Known; use tracing::{trace, warn}; @@ -42,7 +40,7 @@ impl Analyzer<'_, '_> { let _tracing = dev_span!("Stmt", line_col = &*line_col); warn!("Statement start"); - let start = Instant::now(); + let timer = PerfTimer::noop(); if self.rule().always_strict && !self.rule().allow_unreachable_code && self.ctx.in_unreachable { if !matches!(s, RStmt::Decl(RDecl::TsInterface(..) | RDecl::TsTypeAlias(..))) { @@ -57,14 +55,12 @@ impl Analyzer<'_, '_> { self.scope.return_values.in_conditional = old_in_conditional; - let end = Instant::now(); - warn!( kind = "perf", op = "validate (Stmt)", "({}): Statement validation done. (time = {:?}", line_col, - end - start + timer.elapsed() ); Ok(()) diff --git a/crates/stc_ts_file_analyzer/src/env.rs b/crates/stc_ts_file_analyzer/src/env.rs index 32eb86b2dd..5eeb37889f 100644 --- a/crates/stc_ts_file_analyzer/src/env.rs +++ b/crates/stc_ts_file_analyzer/src/env.rs @@ -1,4 +1,4 @@ -use std::{collections::hash_map::Entry, error::Error, path::Path, sync::Arc, time::Instant}; +use std::{collections::hash_map::Entry, error::Error, path::Path, sync::Arc}; use dashmap::DashMap; use once_cell::sync::{Lazy, OnceCell}; @@ -110,8 +110,6 @@ pub trait BuiltInGen: Sized { { info!("Merging builtin"); - let start = Instant::now(); - let mut types = FxHashMap::default(); let mut vars = FxHashMap::default(); let mut storage = Builtin::default(); @@ -283,8 +281,6 @@ pub trait BuiltInGen: Sized { ty.freeze(); } - let dur = Instant::now() - start; - Self::new(vars, types) } } diff --git a/crates/stc_ts_type_checker/src/lib.rs b/crates/stc_ts_type_checker/src/lib.rs index 0adc5455a4..d9f056171d 100644 --- a/crates/stc_ts_type_checker/src/lib.rs +++ b/crates/stc_ts_type_checker/src/lib.rs @@ -1,6 +1,6 @@ //! Full type checker with dependency support. -use std::{mem::take, sync::Arc, time::Instant}; +use std::{mem::take, sync::Arc}; use dashmap::{DashMap, DashSet, SharedValue}; use fxhash::{FxBuildHasher, FxHashMap}; @@ -15,7 +15,7 @@ use stc_ts_errors::{debug::debugger::Debugger, Error}; use stc_ts_file_analyzer::{analyzer::Analyzer, loader::Load, validator::ValidateWith, ModuleTypeData, VResult}; use stc_ts_storage::{ErrorStore, File, Group, Single}; use stc_ts_types::{ModuleId, Type}; -use stc_utils::{cache::Freeze, early_error}; +use stc_utils::{cache::Freeze, early_error, perf_timer::PerfTimer}; use swc_atoms::JsWord; use swc_common::{errors::Handler, FileName, SourceMap, Spanned, DUMMY_SP}; use swc_ecma_ast::Module; @@ -89,19 +89,16 @@ impl Checker { /// After calling this method, you can get errors using `.take_errors()` pub fn check(&self, entry: Arc) -> ModuleId { - let start = Instant::now(); + let timer = PerfTimer::tracing_debug(); let modules = self.module_loader.load_module(&entry, true).expect("failed to load entry"); - let end = Instant::now(); - log::debug!("Loading of `{}` and dependencies took {:?}", entry, end - start); - - let start = Instant::now(); + timer.log(&format!("Loading of `{}` and dependencies", entry)); + let timer = PerfTimer::tracing_debug(); self.analyze_module(None, entry.clone()); - let end = Instant::now(); - log::debug!("Analysis of `{}` and dependencies took {:?}", entry, end - start); + timer.log(&format!("Analysis of `{}` and dependencies", entry)); modules.entry.id } @@ -236,7 +233,7 @@ impl Checker { } { - let start = Instant::now(); + let timer = PerfTimer::noop(); let mut did_work = false; let v = self.module_types.read().get(&id).cloned().unwrap(); // We now wait for dependency without holding lock @@ -248,9 +245,8 @@ impl Checker { }) .clone(); - let dur = Instant::now() - start; if !did_work { - log::warn!("Waited for {}: {:?}", path, dur); + log::warn!("Waited for {}: {:?}", path, timer.elapsed()); } res @@ -258,7 +254,7 @@ impl Checker { } fn analyze_non_circular_module(&self, module_id: ModuleId, path: Arc) -> Type { - let start = Instant::now(); + let timer = PerfTimer::log_trace(); let is_dts = match &*path { FileName::Real(path) => path.to_string_lossy().ends_with(".d.ts"), @@ -287,7 +283,7 @@ impl Checker { }; let mut mutations; { - let start = Instant::now(); + let timer = PerfTimer::log_debug(); let mut a = Analyzer::root( self.env.clone(), self.cm.clone(), @@ -299,9 +295,7 @@ impl Checker { module.visit_with(&mut a); - let end = Instant::now(); - let dur = end - start; - log::debug!("[Timing] Analysis of {} took {:?}", path, dur); + timer.log(&format!("[Timing] Analysis of {}", path)); mutations = a.mutations.unwrap(); } @@ -336,8 +330,7 @@ impl Checker { self.dts_modules.insert(module_id, module); - let dur = Instant::now() - start; - log::trace!("[Timing] Full analysis of {} took {:?}", path, dur); + timer.log(&format!("[Timing] Full analysis of {}", path)); type_info } diff --git a/crates/stc_ts_type_checker/src/typings.rs b/crates/stc_ts_type_checker/src/typings.rs index 7a37a3f648..1d036e6f4e 100644 --- a/crates/stc_ts_type_checker/src/typings.rs +++ b/crates/stc_ts_type_checker/src/typings.rs @@ -2,11 +2,11 @@ use std::{ fs::read_dir, path::{Path, PathBuf}, sync::Arc, - time::Instant, }; use rayon::prelude::*; use stc_ts_module_loader::resolvers::node::NodeResolver; +use stc_utils::perf_timer::PerfTimer; use swc_common::FileName; use crate::Checker; @@ -23,12 +23,11 @@ impl Checker { if let Ok(entry) = result { let entry = Arc::new(FileName::Real(entry)); - let start = Instant::now(); + let timer = PerfTimer::log_debug(); self.analyze_module(None, entry); - let end = Instant::now(); - log::debug!("Loading typings at `{}` took {:?}", dir.display(), end - start); + timer.log(&format!("Loading typings at `{}`", dir.display())); } } diff --git a/crates/stc_utils/Cargo.toml b/crates/stc_utils/Cargo.toml index 55e8aab869..b2d311be79 100644 --- a/crates/stc_utils/Cargo.toml +++ b/crates/stc_utils/Cargo.toml @@ -9,6 +9,7 @@ version = "0.1.0" [dependencies] ahash = "0.7.2" +log = "0.4.14" once_cell = "1" rustc-hash = "1.1.0" scoped-tls = "1.0.0" diff --git a/crates/stc_utils/src/lib.rs b/crates/stc_utils/src/lib.rs index 3406c6d6ae..d8436846c0 100644 --- a/crates/stc_utils/src/lib.rs +++ b/crates/stc_utils/src/lib.rs @@ -18,6 +18,7 @@ pub mod cache; pub mod error; pub mod ext; pub mod panic_context; +pub mod perf_timer; pub mod stack; pub type ABuilderHasher = ahash::RandomState; diff --git a/crates/stc_utils/src/perf_timer.rs b/crates/stc_utils/src/perf_timer.rs new file mode 100644 index 0000000000..d518033c31 --- /dev/null +++ b/crates/stc_utils/src/perf_timer.rs @@ -0,0 +1,81 @@ +use std::time::{Duration, Instant}; + +pub struct PerfTimer<'l> { + pub start: Instant, + pub logger: &'l dyn Fn(&str, Duration), +} + +impl<'l> PerfTimer<'l> { + pub fn with_logger(logger: &'l dyn Fn(&str, Duration)) -> Self { + Self { + start: Instant::now(), + logger, + } + } + + pub fn noop() -> Self { + Self::with_logger(&|_, _| {}) + } + + pub fn log_trace() -> Self { + Self::with_logger(&loggers::log_trace) + } + + pub fn log_debug() -> Self { + Self::with_logger(&loggers::log_debug) + } + + pub fn log_info() -> Self { + Self::with_logger(&loggers::log_info) + } + + pub fn log_warn() -> Self { + Self::with_logger(&loggers::log_warn) + } + + pub fn tracing_debug() -> Self { + Self::with_logger(&loggers::tracing_debug) + } + + pub fn tracing_warn() -> Self { + Self::with_logger(&loggers::tracing_warn) + } +} + +impl<'l> PerfTimer<'l> { + pub fn elapsed(&self) -> Duration { + self.start.elapsed() + } + + pub fn log(&self, scope: &str) { + (self.logger)(scope, self.start.elapsed()) + } +} + +mod loggers { + use std::time::Duration; + + pub fn log_trace(scope: &str, duration: Duration) { + log::trace!("{} took {:?}", scope, duration); + } + + pub fn log_debug(scope: &str, duration: Duration) { + log::debug!("{} took {:?}", scope, duration); + } + + pub fn log_info(scope: &str, duration: Duration) { + log::info!("{} took {:?}", scope, duration); + } + + pub fn log_warn(scope: &str, duration: Duration) { + log::warn!("{} took {:?}", scope, duration); + } + + pub fn tracing_debug(scope: &str, duration: Duration) { + tracing::debug!("{} took {:?}", scope, duration); + } + + pub fn tracing_warn(scope: &str, duration: Duration) { + tracing::warn!("{} took {:?}", scope, duration); + } +} From 7c45da4fa4a1ba5c38bcf1fede18d8d718cadb17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=98=A4=EB=B3=91=EC=A7=84?= <64676070+sunrabbit123@users.noreply.github.com> Date: Thu, 14 Sep 2023 10:24:50 +0900 Subject: [PATCH 28/40] fix: Resolve panic about module not found with `es5` (#1088) --- .../src/analyzer/expr/call_new.rs | 7 +++++++ .../nameWithRelativePaths.error-diff.json | 12 ++++++++++++ .../nameWithRelativePaths.stats.rust-debug | 4 ++-- .../RegressionTests/parser509534.error-diff.json | 12 ++++++++++++ .../RegressionTests/parser509534.stats.rust-debug | 8 ++++---- .../stc_ts_type_checker/tests/tsc-stats.rust-debug | 8 ++++---- crates/stc_ts_type_checker/tests/tsc.rs | 2 +- 7 files changed, 42 insertions(+), 11 deletions(-) create mode 100644 crates/stc_ts_type_checker/tests/conformance/externalModules/nameWithRelativePaths.error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/RegressionTests/parser509534.error-diff.json diff --git a/crates/stc_ts_file_analyzer/src/analyzer/expr/call_new.rs b/crates/stc_ts_file_analyzer/src/analyzer/expr/call_new.rs index dc1be12f10..0aacaa2b03 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/expr/call_new.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/expr/call_new.rs @@ -349,6 +349,13 @@ impl Analyzer<'_, '_> { // }) // .into()); // } + if self.env.target().eq(&swc_ecma_ast::EsVersion::Es5) { + Err(ErrorKind::NoSuchType { + span: i.span(), + name: i.into(), + })? + } + Err(ErrorKind::UndefinedSymbol { sym: i.into(), span: i.span(), diff --git a/crates/stc_ts_type_checker/tests/conformance/externalModules/nameWithRelativePaths.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/externalModules/nameWithRelativePaths.error-diff.json new file mode 100644 index 0000000000..dba7272865 --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/externalModules/nameWithRelativePaths.error-diff.json @@ -0,0 +1,12 @@ +{ + "required_errors": {}, + "required_error_lines": {}, + "extra_errors": { + "TS2307": 1 + }, + "extra_error_lines": { + "TS2307": [ + 1 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/externalModules/nameWithRelativePaths.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/externalModules/nameWithRelativePaths.stats.rust-debug index 27ba984132..0498397634 100644 --- a/crates/stc_ts_type_checker/tests/conformance/externalModules/nameWithRelativePaths.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/externalModules/nameWithRelativePaths.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 0, - panic: 1, + extra_error: 1, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/RegressionTests/parser509534.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/RegressionTests/parser509534.error-diff.json new file mode 100644 index 0000000000..7c6e505964 --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/RegressionTests/parser509534.error-diff.json @@ -0,0 +1,12 @@ +{ + "required_errors": {}, + "required_error_lines": {}, + "extra_errors": { + "TS2307": 1 + }, + "extra_error_lines": { + "TS2307": [ + 2 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/RegressionTests/parser509534.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/RegressionTests/parser509534.stats.rust-debug index a233b6cb56..06369d85a8 100644 --- a/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/RegressionTests/parser509534.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/RegressionTests/parser509534.stats.rust-debug @@ -1,6 +1,6 @@ Stats { - required_error: 2, - matched_error: 0, - extra_error: 0, - panic: 1, + required_error: 0, + matched_error: 2, + extra_error: 1, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug index 0ce0fc0712..a1d8fe123f 100644 --- a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug @@ -1,6 +1,6 @@ Stats { - required_error: 3491, - matched_error: 6544, - extra_error: 766, - panic: 66, + required_error: 3489, + matched_error: 6546, + extra_error: 768, + panic: 64, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/tsc.rs b/crates/stc_ts_type_checker/tests/tsc.rs index 8dae2f3ea5..c51aef94e6 100644 --- a/crates/stc_ts_type_checker/tests/tsc.rs +++ b/crates/stc_ts_type_checker/tests/tsc.rs @@ -626,7 +626,7 @@ impl Resolve for TestFileSystem { } } - todo!("resolve: current = {:?}; target ={:?}", base, module_specifier); + bail!("resolve: current = {:?}; target ={:?}", base, module_specifier); } } From f390577bcea611fa67d4763998a024ae8d6d7117 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=98=A4=EB=B3=91=EC=A7=84?= <64676070+sunrabbit123@users.noreply.github.com> Date: Thu, 14 Sep 2023 11:45:29 +0900 Subject: [PATCH 29/40] fix: Fix parsing of numeric literals like `0x9E` (#1087) **Description:** ```ts type TBigInt2 = "0x10" extends `${infer N extends bigint}` ? N : never; // bigint (not round-trippable) type TBigInt3 = "0o10" extends `${infer N extends bigint}` ? N : never; // bigint (not round-trippable) type TBigInt4 = "0b10" extends `${infer N extends bigint}` ? N : never; // bigint (not round-trippable) ``` --- .../src/analyzer/generic/inference.rs | 32 +++++++++++++------ .../tests/conformance.pass.txt | 1 + .../templateLiteralTypes4.error-diff.json | 18 ----------- .../templateLiteralTypes4.stats.rust-debug | 6 ++-- .../tests/tsc-stats.rust-debug | 6 ++-- 5 files changed, 29 insertions(+), 34 deletions(-) delete mode 100644 crates/stc_ts_type_checker/tests/conformance/types/literal/templateLiteralTypes4.error-diff.json diff --git a/crates/stc_ts_file_analyzer/src/analyzer/generic/inference.rs b/crates/stc_ts_file_analyzer/src/analyzer/generic/inference.rs index f09cc6a88d..ed0aea16cc 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/generic/inference.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/generic/inference.rs @@ -684,16 +684,28 @@ impl Analyzer<'_, '_> { } if r.is_bigint() { - return Type::Lit(LitType { - span, - lit: RTsLit::BigInt(RBigInt { - span, - value: Box::new(src.parse().unwrap()), - raw: None, - }), - metadata: Default::default(), - tracker: Default::default(), - }); + match src.parse() { + Ok(v) => { + return Type::Lit(LitType { + span, + lit: RTsLit::BigInt(RBigInt { + span, + value: Box::new(v), + raw: None, + }), + metadata: Default::default(), + tracker: Default::default(), + }) + } + Err(..) => { + return Type::Keyword(KeywordType { + span, + kind: TsKeywordTypeKind::TsBigIntKeyword, + metadata: Default::default(), + tracker: Default::default(), + }) + } + } } if l.is_bigint_lit() { diff --git a/crates/stc_ts_type_checker/tests/conformance.pass.txt b/crates/stc_ts_type_checker/tests/conformance.pass.txt index 70a0fba1ff..9927353d12 100644 --- a/crates/stc_ts_type_checker/tests/conformance.pass.txt +++ b/crates/stc_ts_type_checker/tests/conformance.pass.txt @@ -2375,6 +2375,7 @@ types/literal/stringLiteralsWithSwitchStatements03.ts types/literal/stringLiteralsWithSwitchStatements04.ts types/literal/stringLiteralsWithTypeAssertions01.ts types/literal/templateLiteralTypes2.ts +types/literal/templateLiteralTypes4.ts types/literal/templateLiteralTypesPatternsPrefixSuffixAssignability.ts types/localTypes/localTypes1.ts types/localTypes/localTypes2.ts diff --git a/crates/stc_ts_type_checker/tests/conformance/types/literal/templateLiteralTypes4.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/types/literal/templateLiteralTypes4.error-diff.json deleted file mode 100644 index 959811441e..0000000000 --- a/crates/stc_ts_type_checker/tests/conformance/types/literal/templateLiteralTypes4.error-diff.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "required_errors": { - "TS2345": 1 - }, - "required_error_lines": { - "TS2345": [ - 289 - ] - }, - "extra_errors": { - "TS0": 1 - }, - "extra_error_lines": { - "TS0": [ - 271 - ] - } -} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/types/literal/templateLiteralTypes4.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/types/literal/templateLiteralTypes4.stats.rust-debug index a233b6cb56..780225267c 100644 --- a/crates/stc_ts_type_checker/tests/conformance/types/literal/templateLiteralTypes4.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/types/literal/templateLiteralTypes4.stats.rust-debug @@ -1,6 +1,6 @@ Stats { - required_error: 2, - matched_error: 0, + required_error: 0, + matched_error: 2, extra_error: 0, - panic: 1, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug index a1d8fe123f..a8892c675c 100644 --- a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug @@ -1,6 +1,6 @@ Stats { - required_error: 3489, - matched_error: 6546, + required_error: 3487, + matched_error: 6548, extra_error: 768, - panic: 64, + panic: 63, } \ No newline at end of file From 8ac1d0dd8ce710c61dd454bb3208f9bcf62d97e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=98=A4=EB=B3=91=EC=A7=84?= <64676070+sunrabbit123@users.noreply.github.com> Date: Mon, 18 Sep 2023 21:37:37 +0900 Subject: [PATCH 30/40] feat: Resolve `panic!` cause by `import.meta` (#1089) **Description:** ```ts declare global { interface ImportMeta {foo?: () => void} }; if (import.meta.foo) { import.meta.foo(); } ``` --- crates/stc_ts_file_analyzer/src/analyzer/expr/meta_prop.rs | 7 ++++++- crates/stc_ts_type_checker/tests/conformance.pass.txt | 3 +++ .../importMetaNarrowing(module=es2020).stats.rust-debug | 2 +- .../importMetaNarrowing(module=esnext).stats.rust-debug | 2 +- .../importMetaNarrowing(module=system).stats.rust-debug | 2 +- crates/stc_ts_type_checker/tests/tsc-stats.rust-debug | 2 +- 6 files changed, 13 insertions(+), 5 deletions(-) diff --git a/crates/stc_ts_file_analyzer/src/analyzer/expr/meta_prop.rs b/crates/stc_ts_file_analyzer/src/analyzer/expr/meta_prop.rs index dd9a07adc8..3f2f810162 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/expr/meta_prop.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/expr/meta_prop.rs @@ -19,7 +19,12 @@ impl Analyzer<'_, '_> { Ok(Type::any(e.span, Default::default())) } - _ => { + MetaPropKind::ImportMeta => { + if let Ok(mut ty) = self.env.get_global_type(e.span(), &"ImportMeta".into()) { + ty.reposition(e.span()); + return Ok(ty); + } + todo!("Unsupported meta property {:?}", e) } } diff --git a/crates/stc_ts_type_checker/tests/conformance.pass.txt b/crates/stc_ts_type_checker/tests/conformance.pass.txt index 9927353d12..baf950f3a1 100644 --- a/crates/stc_ts_type_checker/tests/conformance.pass.txt +++ b/crates/stc_ts_type_checker/tests/conformance.pass.txt @@ -475,6 +475,7 @@ es2018/es2018IntlAPIs.ts es2018/usePromiseFinally.ts es2018/useRegexpGroups.ts es2019/globalThisTypeIndexAccess.ts +es2019/importMeta/importMetaNarrowing.ts es2020/bigintMissingES2019.ts es2020/bigintMissingES2020.ts es2020/bigintMissingESNext.ts @@ -1018,6 +1019,7 @@ es6/templates/taggedTemplateStringsPlainCharactersThatArePartsOfEscapes01.ts es6/templates/taggedTemplateStringsPlainCharactersThatArePartsOfEscapes01_ES6.ts es6/templates/taggedTemplateStringsPlainCharactersThatArePartsOfEscapes02.ts es6/templates/taggedTemplateStringsPlainCharactersThatArePartsOfEscapes02_ES6.ts +es6/templates/taggedTemplateStringsPldirectives/ts-expect-error-nocheck.ts es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts es6/templates/taggedTemplateStringsWithIncompatibleTypedTagsES6.ts es6/templates/taggedTemplateStringsWithManyCallAndMemberExpressions.ts @@ -1148,6 +1150,7 @@ es6/templates/templateStringWithEmbeddedObjectLiteral.ts es6/templates/templateStringWithEmbeddedObjectLiteralES6.ts es6/templates/templateStringWithEmbeddedTemplateString.ts es6/templates/templateStringWithEmbeddedTemplateStringES6.ts +es6/templates/templateStringWithEmbeddedTypdirectives/ts-expect-error-nocheck.ts es6/templates/templateStringWithEmbeddedTypeAssertionOnAddition.ts es6/templates/templateStringWithEmbeddedTypeAssertionOnAdditionES6.ts es6/templates/templateStringWithEmbeddedTypeOfOperator.ts diff --git a/crates/stc_ts_type_checker/tests/conformance/es2019/importMeta/importMetaNarrowing(module=es2020).stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/es2019/importMeta/importMetaNarrowing(module=es2020).stats.rust-debug index 27ba984132..c086b5ab15 100644 --- a/crates/stc_ts_type_checker/tests/conformance/es2019/importMeta/importMetaNarrowing(module=es2020).stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/es2019/importMeta/importMetaNarrowing(module=es2020).stats.rust-debug @@ -2,5 +2,5 @@ Stats { required_error: 0, matched_error: 0, extra_error: 0, - panic: 1, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/es2019/importMeta/importMetaNarrowing(module=esnext).stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/es2019/importMeta/importMetaNarrowing(module=esnext).stats.rust-debug index 27ba984132..c086b5ab15 100644 --- a/crates/stc_ts_type_checker/tests/conformance/es2019/importMeta/importMetaNarrowing(module=esnext).stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/es2019/importMeta/importMetaNarrowing(module=esnext).stats.rust-debug @@ -2,5 +2,5 @@ Stats { required_error: 0, matched_error: 0, extra_error: 0, - panic: 1, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/es2019/importMeta/importMetaNarrowing(module=system).stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/es2019/importMeta/importMetaNarrowing(module=system).stats.rust-debug index 27ba984132..c086b5ab15 100644 --- a/crates/stc_ts_type_checker/tests/conformance/es2019/importMeta/importMetaNarrowing(module=system).stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/es2019/importMeta/importMetaNarrowing(module=system).stats.rust-debug @@ -2,5 +2,5 @@ Stats { required_error: 0, matched_error: 0, extra_error: 0, - panic: 1, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug index a8892c675c..436c94ebb2 100644 --- a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug @@ -2,5 +2,5 @@ Stats { required_error: 3487, matched_error: 6548, extra_error: 768, - panic: 63, + panic: 60, } \ No newline at end of file From cf8baebfe087e9fc377871754100d9f2b7f86929 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=98=A4=EB=B3=91=EC=A7=84?= <64676070+sunrabbit123@users.noreply.github.com> Date: Sat, 23 Sep 2023 07:39:53 +0900 Subject: [PATCH 31/40] feat: Remove panic when `main_source` contains reference comment (#1086) **Description:** ```rs let main_src = Arc::new(fs::read_to_string(file_name).unwrap()); // Postpone multi-file tests. if main_src.contains(" ``` **Deep Dive** this code wrote #487 I'm guessing it was used as a pass-through because it was a test case that was too much for the code to handle at the time. And I don't think it matters if you delete that code now. --- .../tests/conformance.pass.txt | 1 + ...mbientDeclarationsExternal.error-diff.json | 13 + ...bientDeclarationsExternal.stats.rust-debug | 4 +- ...mbientDeclarationsPatterns.error-diff.json | 14 + ...bientDeclarationsPatterns.stats.rust-debug | 4 +- .../ambientShorthand_merging.error-diff.json | 12 + .../ambientShorthand_merging.stats.rust-debug | 4 +- .../topLevelAmbientModule.error-diff.json | 12 + .../topLevelAmbientModule.stats.rust-debug | 4 +- ...elModuleDeclarationAndFile.error-diff.json | 18 + ...lModuleDeclarationAndFile.stats.rust-debug | 4 +- .../umd-augmentation-1.error-diff.json | 24 ++ .../umd-augmentation-1.stats.rust-debug | 4 +- .../umd-augmentation-2.error-diff.json | 22 ++ .../umd-augmentation-2.stats.rust-debug | 4 +- .../umd-augmentation-3.error-diff.json | 24 ++ .../umd-augmentation-3.stats.rust-debug | 4 +- .../umd-augmentation-4.error-diff.json | 22 ++ .../umd-augmentation-4.stats.rust-debug | 4 +- .../externalModules/umd1.error-diff.json | 16 + .../externalModules/umd1.stats.rust-debug | 4 +- .../externalModules/umd6.error-diff.json | 12 + .../externalModules/umd6.stats.rust-debug | 4 +- .../externalModules/umd7.error-diff.json | 12 + .../externalModules/umd7.stats.rust-debug | 4 +- .../externalModules/umd8.error-diff.json | 23 ++ .../externalModules/umd8.stats.rust-debug | 4 +- .../externalModules/umd9.error-diff.json | 12 + .../externalModules/umd9.stats.rust-debug | 4 +- ...kJsxChildrenCanBeTupleType.error-diff.json | 19 + ...JsxChildrenCanBeTupleType.stats.rust-debug | 4 +- ...tleSkipContextSensitiveBug.error-diff.json | 17 + ...leSkipContextSensitiveBug.stats.rust-debug | 4 +- ...xtualTypeInferredCorrectly.error-diff.json | 21 ++ ...tualTypeInferredCorrectly.stats.rust-debug | 4 +- ...tlyMarkAliasAsReferences1.stats.rust-debug | 2 +- ...tlyMarkAliasAsReferences2.stats.rust-debug | 2 +- ...ctlyMarkAliasAsReferences3.error-diff.json | 12 + ...tlyMarkAliasAsReferences3.stats.rust-debug | 2 +- ...tlyMarkAliasAsReferences4.stats.rust-debug | 2 +- ...ormChildren(jsx=react-jsx).error-diff.json | 16 + ...rmChildren(jsx=react-jsx).stats.rust-debug | 4 +- ...Children(jsx=react-jsxdev).error-diff.json | 16 + ...hildren(jsx=react-jsxdev).stats.rust-debug | 4 +- ...mportPragma(jsx=react-jsx).error-diff.json | 19 + ...portPragma(jsx=react-jsx).stats.rust-debug | 8 +- ...rtPragma(jsx=react-jsxdev).error-diff.json | 19 + ...tPragma(jsx=react-jsxdev).stats.rust-debug | 8 +- ...formKeyProp(jsx=react-jsx).error-diff.json | 17 + ...ormKeyProp(jsx=react-jsx).stats.rust-debug | 4 +- ...mKeyProp(jsx=react-jsxdev).error-diff.json | 17 + ...KeyProp(jsx=react-jsxdev).stats.rust-debug | 4 +- ...mportPragma(jsx=react-jsx).error-diff.json | 26 ++ ...portPragma(jsx=react-jsx).stats.rust-debug | 4 +- ...rtPragma(jsx=react-jsxdev).error-diff.json | 26 ++ ...tPragma(jsx=react-jsxdev).stats.rust-debug | 4 +- ...losingChild(jsx=react-jsx).error-diff.json | 23 ++ ...osingChild(jsx=react-jsx).stats.rust-debug | 4 +- ...ingChild(jsx=react-jsxdev).error-diff.json | 23 ++ ...ngChild(jsx=react-jsxdev).stats.rust-debug | 4 +- ...itutesNames(jsx=react-jsx).error-diff.json | 16 + ...tutesNames(jsx=react-jsx).stats.rust-debug | 4 +- ...tesNames(jsx=react-jsxdev).error-diff.json | 16 + ...esNames(jsx=react-jsxdev).stats.rust-debug | 4 +- ...mesFragment(jsx=react-jsx).error-diff.json | 17 + ...esFragment(jsx=react-jsx).stats.rust-debug | 4 +- ...Fragment(jsx=react-jsxdev).error-diff.json | 17 + ...ragment(jsx=react-jsxdev).stats.rust-debug | 4 +- .../tsxElementResolution17.error-diff.json | 13 + .../tsxElementResolution17.stats.rust-debug | 4 +- ...xReactEmit8(jsx=react-jsx).error-diff.json | 17 + ...ReactEmit8(jsx=react-jsx).stats.rust-debug | 4 +- ...actEmit8(jsx=react-jsxdev).error-diff.json | 17 + ...ctEmit8(jsx=react-jsxdev).stats.rust-debug | 4 +- ...adAttribute(target=es2015).error-diff.json | 12 + ...dAttribute(target=es2015).stats.rust-debug | 4 +- ...adAttribute(target=es2018).error-diff.json | 12 + ...dAttribute(target=es2018).stats.rust-debug | 4 +- ...adAttribute(target=esnext).error-diff.json | 12 + ...dAttribute(target=esnext).stats.rust-debug | 4 +- .../RealWorld/parserindenter.error-diff.json | 83 +++++ .../RealWorld/parserindenter.stats.rust-debug | 8 +- .../parserRealSource1.error-diff.json | 12 + .../parserRealSource1.stats.rust-debug | 2 +- .../parserRealSource12.error-diff.json | 31 ++ .../parserRealSource12.stats.rust-debug | 8 +- .../parserRealSource13.error-diff.json | 22 ++ .../parserRealSource13.stats.rust-debug | 8 +- .../parserRealSource14.error-diff.json | 327 ++++++++++++++++++ .../parserRealSource14.stats.rust-debug | 8 +- .../parserRealSource2.error-diff.json | 12 + .../parserRealSource2.stats.rust-debug | 2 +- .../parserRealSource3.error-diff.json | 12 + .../parserRealSource3.stats.rust-debug | 2 +- .../parserRealSource5.error-diff.json | 18 + .../parserRealSource5.stats.rust-debug | 8 +- .../parserRealSource6.error-diff.json | 38 ++ .../parserRealSource6.stats.rust-debug | 8 +- .../parserRealSource8.error-diff.json | 43 +++ .../parserRealSource8.stats.rust-debug | 8 +- ...urceFileMergeWithFunction.stats.rust-debug | 2 +- .../ecmascript5/scannertest1.error-diff.json | 26 ++ .../ecmascript5/scannertest1.stats.rust-debug | 8 +- ...traExpressionInferencesJsx.error-diff.json | 30 ++ ...raExpressionInferencesJsx.stats.rust-debug | 4 +- .../tests/tsc-stats.rust-debug | 8 +- crates/stc_ts_type_checker/tests/tsc.rs | 6 - 107 files changed, 1435 insertions(+), 130 deletions(-) create mode 100644 crates/stc_ts_type_checker/tests/conformance/ambient/ambientDeclarationsExternal.error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/ambient/ambientDeclarationsPatterns.error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/ambient/ambientShorthand_merging.error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/externalModules/topLevelAmbientModule.error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/externalModules/topLevelModuleDeclarationAndFile.error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/externalModules/umd-augmentation-1.error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/externalModules/umd-augmentation-2.error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/externalModules/umd-augmentation-3.error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/externalModules/umd-augmentation-4.error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/externalModules/umd1.error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/externalModules/umd6.error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/externalModules/umd7.error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/externalModules/umd8.error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/externalModules/umd9.error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/jsx/checkJsxChildrenCanBeTupleType.error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/jsx/checkJsxSubtleSkipContextSensitiveBug.error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/jsx/checkJsxUnionSFXContextualTypeInferredCorrectly.error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/jsx/correctlyMarkAliasAsReferences3.error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformChildren(jsx=react-jsx).error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformChildren(jsx=react-jsxdev).error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsx).error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsxdev).error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformKeyProp(jsx=react-jsx).error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformKeyProp(jsx=react-jsxdev).error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformKeyPropCustomImportPragma(jsx=react-jsx).error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformKeyPropCustomImportPragma(jsx=react-jsxdev).error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformNestedSelfClosingChild(jsx=react-jsx).error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformNestedSelfClosingChild(jsx=react-jsxdev).error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformSubstitutesNames(jsx=react-jsx).error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformSubstitutesNames(jsx=react-jsxdev).error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformSubstitutesNamesFragment(jsx=react-jsx).error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformSubstitutesNamesFragment(jsx=react-jsxdev).error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/jsx/tsxElementResolution17.error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/jsx/tsxReactEmit8(jsx=react-jsx).error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/jsx/tsxReactEmit8(jsx=react-jsxdev).error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/jsx/tsxReactEmitSpreadAttribute(target=es2015).error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/jsx/tsxReactEmitSpreadAttribute(target=es2018).error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/jsx/tsxReactEmitSpreadAttribute(target=esnext).error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/RealWorld/parserindenter.error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource1.error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource12.error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource13.error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource14.error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource2.error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource3.error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource5.error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource6.error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource8.error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/scanner/ecmascript5/scannertest1.error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/types/typeRelationships/typeInference/intraExpressionInferencesJsx.error-diff.json diff --git a/crates/stc_ts_type_checker/tests/conformance.pass.txt b/crates/stc_ts_type_checker/tests/conformance.pass.txt index baf950f3a1..03eb15c6a1 100644 --- a/crates/stc_ts_type_checker/tests/conformance.pass.txt +++ b/crates/stc_ts_type_checker/tests/conformance.pass.txt @@ -2204,6 +2204,7 @@ salsa/constructorNameInObjectLiteralAccessor.ts salsa/inferringClassMembersFromAssignments8.ts salsa/mixedPropertyElementAccessAssignmentDeclaration.ts salsa/propertyAssignmentUseParentType3.ts +salsa/sourceFileMergeWithFunction.ts salsa/typeFromPropertyAssignment30.ts salsa/typeFromPropertyAssignment38.ts scanner/ecmascript3/scannerES3NumericLiteral1.ts diff --git a/crates/stc_ts_type_checker/tests/conformance/ambient/ambientDeclarationsExternal.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/ambient/ambientDeclarationsExternal.error-diff.json new file mode 100644 index 0000000000..5a14a7d1c2 --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/ambient/ambientDeclarationsExternal.error-diff.json @@ -0,0 +1,13 @@ +{ + "required_errors": {}, + "required_error_lines": {}, + "extra_errors": { + "TS2307": 2 + }, + "extra_error_lines": { + "TS2307": [ + 2, + 6 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/ambient/ambientDeclarationsExternal.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/ambient/ambientDeclarationsExternal.stats.rust-debug index 27ba984132..d45524b098 100644 --- a/crates/stc_ts_type_checker/tests/conformance/ambient/ambientDeclarationsExternal.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/ambient/ambientDeclarationsExternal.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 0, - panic: 1, + extra_error: 2, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/ambient/ambientDeclarationsPatterns.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/ambient/ambientDeclarationsPatterns.error-diff.json new file mode 100644 index 0000000000..1a8e26ac72 --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/ambient/ambientDeclarationsPatterns.error-diff.json @@ -0,0 +1,14 @@ +{ + "required_errors": {}, + "required_error_lines": {}, + "extra_errors": { + "TS2307": 3 + }, + "extra_error_lines": { + "TS2307": [ + 2, + 5, + 9 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/ambient/ambientDeclarationsPatterns.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/ambient/ambientDeclarationsPatterns.stats.rust-debug index 27ba984132..7d12ad5c64 100644 --- a/crates/stc_ts_type_checker/tests/conformance/ambient/ambientDeclarationsPatterns.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/ambient/ambientDeclarationsPatterns.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 0, - panic: 1, + extra_error: 3, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/ambient/ambientShorthand_merging.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/ambient/ambientShorthand_merging.error-diff.json new file mode 100644 index 0000000000..af26ba78f9 --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/ambient/ambientShorthand_merging.error-diff.json @@ -0,0 +1,12 @@ +{ + "required_errors": {}, + "required_error_lines": {}, + "extra_errors": { + "TS2305": 1 + }, + "extra_error_lines": { + "TS2305": [ + 3 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/ambient/ambientShorthand_merging.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/ambient/ambientShorthand_merging.stats.rust-debug index 27ba984132..0498397634 100644 --- a/crates/stc_ts_type_checker/tests/conformance/ambient/ambientShorthand_merging.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/ambient/ambientShorthand_merging.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 0, - panic: 1, + extra_error: 1, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/externalModules/topLevelAmbientModule.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/externalModules/topLevelAmbientModule.error-diff.json new file mode 100644 index 0000000000..7c6e505964 --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/externalModules/topLevelAmbientModule.error-diff.json @@ -0,0 +1,12 @@ +{ + "required_errors": {}, + "required_error_lines": {}, + "extra_errors": { + "TS2307": 1 + }, + "extra_error_lines": { + "TS2307": [ + 2 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/externalModules/topLevelAmbientModule.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/externalModules/topLevelAmbientModule.stats.rust-debug index 27ba984132..0498397634 100644 --- a/crates/stc_ts_type_checker/tests/conformance/externalModules/topLevelAmbientModule.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/externalModules/topLevelAmbientModule.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 0, - panic: 1, + extra_error: 1, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/externalModules/topLevelModuleDeclarationAndFile.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/externalModules/topLevelModuleDeclarationAndFile.error-diff.json new file mode 100644 index 0000000000..122f8e79d9 --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/externalModules/topLevelModuleDeclarationAndFile.error-diff.json @@ -0,0 +1,18 @@ +{ + "required_errors": { + "TS2339": 1 + }, + "required_error_lines": { + "TS2339": [ + 3 + ] + }, + "extra_errors": { + "TS2307": 1 + }, + "extra_error_lines": { + "TS2307": [ + 2 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/externalModules/topLevelModuleDeclarationAndFile.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/externalModules/topLevelModuleDeclarationAndFile.stats.rust-debug index f79107e8ee..c0ac063550 100644 --- a/crates/stc_ts_type_checker/tests/conformance/externalModules/topLevelModuleDeclarationAndFile.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/externalModules/topLevelModuleDeclarationAndFile.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 1, matched_error: 0, - extra_error: 0, - panic: 1, + extra_error: 1, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/externalModules/umd-augmentation-1.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/externalModules/umd-augmentation-1.error-diff.json new file mode 100644 index 0000000000..8a2cb68b66 --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/externalModules/umd-augmentation-1.error-diff.json @@ -0,0 +1,24 @@ +{ + "required_errors": {}, + "required_error_lines": {}, + "extra_errors": { + "TS2349": 1, + "TS2339": 1, + "TS2307": 1, + "TS2503": 1 + }, + "extra_error_lines": { + "TS2349": [ + 3 + ], + "TS2339": [ + 4 + ], + "TS2307": [ + 1 + ], + "TS2503": [ + 6 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/externalModules/umd-augmentation-1.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/externalModules/umd-augmentation-1.stats.rust-debug index 27ba984132..f8c5b3550b 100644 --- a/crates/stc_ts_type_checker/tests/conformance/externalModules/umd-augmentation-1.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/externalModules/umd-augmentation-1.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 0, - panic: 1, + extra_error: 4, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/externalModules/umd-augmentation-2.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/externalModules/umd-augmentation-2.error-diff.json new file mode 100644 index 0000000000..beae868b30 --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/externalModules/umd-augmentation-2.error-diff.json @@ -0,0 +1,22 @@ +{ + "required_errors": {}, + "required_error_lines": {}, + "extra_errors": { + "TS2304": 2, + "TS2503": 2, + "TS2307": 1 + }, + "extra_error_lines": { + "TS2304": [ + 3, + 4 + ], + "TS2503": [ + 5, + 6 + ], + "TS2307": [ + 1 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/externalModules/umd-augmentation-2.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/externalModules/umd-augmentation-2.stats.rust-debug index 27ba984132..98e482c2a5 100644 --- a/crates/stc_ts_type_checker/tests/conformance/externalModules/umd-augmentation-2.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/externalModules/umd-augmentation-2.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 0, - panic: 1, + extra_error: 5, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/externalModules/umd-augmentation-3.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/externalModules/umd-augmentation-3.error-diff.json new file mode 100644 index 0000000000..8a2cb68b66 --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/externalModules/umd-augmentation-3.error-diff.json @@ -0,0 +1,24 @@ +{ + "required_errors": {}, + "required_error_lines": {}, + "extra_errors": { + "TS2349": 1, + "TS2339": 1, + "TS2307": 1, + "TS2503": 1 + }, + "extra_error_lines": { + "TS2349": [ + 3 + ], + "TS2339": [ + 4 + ], + "TS2307": [ + 1 + ], + "TS2503": [ + 6 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/externalModules/umd-augmentation-3.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/externalModules/umd-augmentation-3.stats.rust-debug index 27ba984132..f8c5b3550b 100644 --- a/crates/stc_ts_type_checker/tests/conformance/externalModules/umd-augmentation-3.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/externalModules/umd-augmentation-3.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 0, - panic: 1, + extra_error: 4, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/externalModules/umd-augmentation-4.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/externalModules/umd-augmentation-4.error-diff.json new file mode 100644 index 0000000000..beae868b30 --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/externalModules/umd-augmentation-4.error-diff.json @@ -0,0 +1,22 @@ +{ + "required_errors": {}, + "required_error_lines": {}, + "extra_errors": { + "TS2304": 2, + "TS2503": 2, + "TS2307": 1 + }, + "extra_error_lines": { + "TS2304": [ + 3, + 4 + ], + "TS2503": [ + 5, + 6 + ], + "TS2307": [ + 1 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/externalModules/umd-augmentation-4.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/externalModules/umd-augmentation-4.stats.rust-debug index 27ba984132..98e482c2a5 100644 --- a/crates/stc_ts_type_checker/tests/conformance/externalModules/umd-augmentation-4.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/externalModules/umd-augmentation-4.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 0, - panic: 1, + extra_error: 5, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/externalModules/umd1.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/externalModules/umd1.error-diff.json new file mode 100644 index 0000000000..180debabaa --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/externalModules/umd1.error-diff.json @@ -0,0 +1,16 @@ +{ + "required_errors": {}, + "required_error_lines": {}, + "extra_errors": { + "TS2304": 1, + "TS2503": 1 + }, + "extra_error_lines": { + "TS2304": [ + 2 + ], + "TS2503": [ + 3 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/externalModules/umd1.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/externalModules/umd1.stats.rust-debug index 27ba984132..d45524b098 100644 --- a/crates/stc_ts_type_checker/tests/conformance/externalModules/umd1.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/externalModules/umd1.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 0, - panic: 1, + extra_error: 2, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/externalModules/umd6.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/externalModules/umd6.error-diff.json new file mode 100644 index 0000000000..5eb268d1d4 --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/externalModules/umd6.error-diff.json @@ -0,0 +1,12 @@ +{ + "required_errors": {}, + "required_error_lines": {}, + "extra_errors": { + "TS2304": 1 + }, + "extra_error_lines": { + "TS2304": [ + 2 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/externalModules/umd6.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/externalModules/umd6.stats.rust-debug index 27ba984132..0498397634 100644 --- a/crates/stc_ts_type_checker/tests/conformance/externalModules/umd6.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/externalModules/umd6.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 0, - panic: 1, + extra_error: 1, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/externalModules/umd7.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/externalModules/umd7.error-diff.json new file mode 100644 index 0000000000..5eb268d1d4 --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/externalModules/umd7.error-diff.json @@ -0,0 +1,12 @@ +{ + "required_errors": {}, + "required_error_lines": {}, + "extra_errors": { + "TS2304": 1 + }, + "extra_error_lines": { + "TS2304": [ + 2 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/externalModules/umd7.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/externalModules/umd7.stats.rust-debug index 27ba984132..0498397634 100644 --- a/crates/stc_ts_type_checker/tests/conformance/externalModules/umd7.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/externalModules/umd7.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 0, - panic: 1, + extra_error: 1, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/externalModules/umd8.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/externalModules/umd8.error-diff.json new file mode 100644 index 0000000000..1d6e222fd7 --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/externalModules/umd8.error-diff.json @@ -0,0 +1,23 @@ +{ + "required_errors": { + "TS2686": 1 + }, + "required_error_lines": { + "TS2686": [ + 7 + ] + }, + "extra_errors": { + "TS2304": 2, + "TS2503": 1 + }, + "extra_error_lines": { + "TS2304": [ + 4, + 7 + ], + "TS2503": [ + 6 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/externalModules/umd8.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/externalModules/umd8.stats.rust-debug index f79107e8ee..efea2c0329 100644 --- a/crates/stc_ts_type_checker/tests/conformance/externalModules/umd8.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/externalModules/umd8.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 1, matched_error: 0, - extra_error: 0, - panic: 1, + extra_error: 3, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/externalModules/umd9.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/externalModules/umd9.error-diff.json new file mode 100644 index 0000000000..5eb268d1d4 --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/externalModules/umd9.error-diff.json @@ -0,0 +1,12 @@ +{ + "required_errors": {}, + "required_error_lines": {}, + "extra_errors": { + "TS2304": 1 + }, + "extra_error_lines": { + "TS2304": [ + 2 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/externalModules/umd9.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/externalModules/umd9.stats.rust-debug index 27ba984132..0498397634 100644 --- a/crates/stc_ts_type_checker/tests/conformance/externalModules/umd9.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/externalModules/umd9.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 0, - panic: 1, + extra_error: 1, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/checkJsxChildrenCanBeTupleType.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/jsx/checkJsxChildrenCanBeTupleType.error-diff.json new file mode 100644 index 0000000000..187106871f --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/checkJsxChildrenCanBeTupleType.error-diff.json @@ -0,0 +1,19 @@ +{ + "required_errors": { + "TS2769": 1 + }, + "required_error_lines": { + "TS2769": [ + 20 + ] + }, + "extra_errors": { + "TS2307": 2 + }, + "extra_error_lines": { + "TS2307": [ + 6, + 6 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/checkJsxChildrenCanBeTupleType.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/jsx/checkJsxChildrenCanBeTupleType.stats.rust-debug index f79107e8ee..d3ac857022 100644 --- a/crates/stc_ts_type_checker/tests/conformance/jsx/checkJsxChildrenCanBeTupleType.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/checkJsxChildrenCanBeTupleType.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 1, matched_error: 0, - extra_error: 0, - panic: 1, + extra_error: 2, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/checkJsxSubtleSkipContextSensitiveBug.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/jsx/checkJsxSubtleSkipContextSensitiveBug.error-diff.json new file mode 100644 index 0000000000..543ad32e8c --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/checkJsxSubtleSkipContextSensitiveBug.error-diff.json @@ -0,0 +1,17 @@ +{ + "required_errors": {}, + "required_error_lines": {}, + "extra_errors": { + "TS2307": 2, + "TS7005": 1 + }, + "extra_error_lines": { + "TS2307": [ + 6, + 6 + ], + "TS7005": [ + 26 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/checkJsxSubtleSkipContextSensitiveBug.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/jsx/checkJsxSubtleSkipContextSensitiveBug.stats.rust-debug index 27ba984132..7d12ad5c64 100644 --- a/crates/stc_ts_type_checker/tests/conformance/jsx/checkJsxSubtleSkipContextSensitiveBug.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/checkJsxSubtleSkipContextSensitiveBug.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 0, - panic: 1, + extra_error: 3, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/checkJsxUnionSFXContextualTypeInferredCorrectly.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/jsx/checkJsxUnionSFXContextualTypeInferredCorrectly.error-diff.json new file mode 100644 index 0000000000..c29f438208 --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/checkJsxUnionSFXContextualTypeInferredCorrectly.error-diff.json @@ -0,0 +1,21 @@ +{ + "required_errors": {}, + "required_error_lines": {}, + "extra_errors": { + "TS2307": 2, + "TS7010": 1, + "TS7005": 1 + }, + "extra_error_lines": { + "TS2307": [ + 6, + 6 + ], + "TS7010": [ + 20 + ], + "TS7005": [ + 30 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/checkJsxUnionSFXContextualTypeInferredCorrectly.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/jsx/checkJsxUnionSFXContextualTypeInferredCorrectly.stats.rust-debug index 27ba984132..f8c5b3550b 100644 --- a/crates/stc_ts_type_checker/tests/conformance/jsx/checkJsxUnionSFXContextualTypeInferredCorrectly.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/checkJsxUnionSFXContextualTypeInferredCorrectly.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 0, - panic: 1, + extra_error: 4, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/correctlyMarkAliasAsReferences1.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/jsx/correctlyMarkAliasAsReferences1.stats.rust-debug index 27ba984132..c086b5ab15 100644 --- a/crates/stc_ts_type_checker/tests/conformance/jsx/correctlyMarkAliasAsReferences1.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/correctlyMarkAliasAsReferences1.stats.rust-debug @@ -2,5 +2,5 @@ Stats { required_error: 0, matched_error: 0, extra_error: 0, - panic: 1, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/correctlyMarkAliasAsReferences2.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/jsx/correctlyMarkAliasAsReferences2.stats.rust-debug index 27ba984132..c086b5ab15 100644 --- a/crates/stc_ts_type_checker/tests/conformance/jsx/correctlyMarkAliasAsReferences2.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/correctlyMarkAliasAsReferences2.stats.rust-debug @@ -2,5 +2,5 @@ Stats { required_error: 0, matched_error: 0, extra_error: 0, - panic: 1, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/correctlyMarkAliasAsReferences3.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/jsx/correctlyMarkAliasAsReferences3.error-diff.json new file mode 100644 index 0000000000..1bcd412e53 --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/correctlyMarkAliasAsReferences3.error-diff.json @@ -0,0 +1,12 @@ +{ + "required_errors": { + "TS2698": 1 + }, + "required_error_lines": { + "TS2698": [ + 6 + ] + }, + "extra_errors": {}, + "extra_error_lines": {} +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/correctlyMarkAliasAsReferences3.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/jsx/correctlyMarkAliasAsReferences3.stats.rust-debug index f79107e8ee..4af5bf17ec 100644 --- a/crates/stc_ts_type_checker/tests/conformance/jsx/correctlyMarkAliasAsReferences3.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/correctlyMarkAliasAsReferences3.stats.rust-debug @@ -2,5 +2,5 @@ Stats { required_error: 1, matched_error: 0, extra_error: 0, - panic: 1, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/correctlyMarkAliasAsReferences4.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/jsx/correctlyMarkAliasAsReferences4.stats.rust-debug index 27ba984132..c086b5ab15 100644 --- a/crates/stc_ts_type_checker/tests/conformance/jsx/correctlyMarkAliasAsReferences4.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/correctlyMarkAliasAsReferences4.stats.rust-debug @@ -2,5 +2,5 @@ Stats { required_error: 0, matched_error: 0, extra_error: 0, - panic: 1, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformChildren(jsx=react-jsx).error-diff.json b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformChildren(jsx=react-jsx).error-diff.json new file mode 100644 index 0000000000..7d36c3a8e2 --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformChildren(jsx=react-jsx).error-diff.json @@ -0,0 +1,16 @@ +{ + "required_errors": {}, + "required_error_lines": {}, + "extra_errors": { + "TS2307": 1, + "TS7005": 1 + }, + "extra_error_lines": { + "TS2307": [ + 5 + ], + "TS7005": [ + 5 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformChildren(jsx=react-jsx).stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformChildren(jsx=react-jsx).stats.rust-debug index 27ba984132..d45524b098 100644 --- a/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformChildren(jsx=react-jsx).stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformChildren(jsx=react-jsx).stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 0, - panic: 1, + extra_error: 2, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformChildren(jsx=react-jsxdev).error-diff.json b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformChildren(jsx=react-jsxdev).error-diff.json new file mode 100644 index 0000000000..7d36c3a8e2 --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformChildren(jsx=react-jsxdev).error-diff.json @@ -0,0 +1,16 @@ +{ + "required_errors": {}, + "required_error_lines": {}, + "extra_errors": { + "TS2307": 1, + "TS7005": 1 + }, + "extra_error_lines": { + "TS2307": [ + 5 + ], + "TS7005": [ + 5 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformChildren(jsx=react-jsxdev).stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformChildren(jsx=react-jsxdev).stats.rust-debug index 27ba984132..d45524b098 100644 --- a/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformChildren(jsx=react-jsxdev).stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformChildren(jsx=react-jsxdev).stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 0, - panic: 1, + extra_error: 2, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsx).error-diff.json b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsx).error-diff.json new file mode 100644 index 0000000000..9653145007 --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsx).error-diff.json @@ -0,0 +1,19 @@ +{ + "required_errors": {}, + "required_error_lines": {}, + "extra_errors": { + "TS7005": 4, + "TS2307": 1 + }, + "extra_error_lines": { + "TS7005": [ + 4, + 6, + 5, + 7 + ], + "TS2307": [ + 3 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsx).stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsx).stats.rust-debug index f79107e8ee..99011f3272 100644 --- a/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsx).stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsx).stats.rust-debug @@ -1,6 +1,6 @@ Stats { - required_error: 1, - matched_error: 0, - extra_error: 0, - panic: 1, + required_error: 0, + matched_error: 1, + extra_error: 5, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsxdev).error-diff.json b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsxdev).error-diff.json new file mode 100644 index 0000000000..9653145007 --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsxdev).error-diff.json @@ -0,0 +1,19 @@ +{ + "required_errors": {}, + "required_error_lines": {}, + "extra_errors": { + "TS7005": 4, + "TS2307": 1 + }, + "extra_error_lines": { + "TS7005": [ + 4, + 6, + 5, + 7 + ], + "TS2307": [ + 3 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsxdev).stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsxdev).stats.rust-debug index f79107e8ee..99011f3272 100644 --- a/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsxdev).stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsxdev).stats.rust-debug @@ -1,6 +1,6 @@ Stats { - required_error: 1, - matched_error: 0, - extra_error: 0, - panic: 1, + required_error: 0, + matched_error: 1, + extra_error: 5, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformKeyProp(jsx=react-jsx).error-diff.json b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformKeyProp(jsx=react-jsx).error-diff.json new file mode 100644 index 0000000000..89cc5dbfaa --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformKeyProp(jsx=react-jsx).error-diff.json @@ -0,0 +1,17 @@ +{ + "required_errors": {}, + "required_error_lines": {}, + "extra_errors": { + "TS2307": 1, + "TS7005": 2 + }, + "extra_error_lines": { + "TS2307": [ + 5 + ], + "TS7005": [ + 6, + 7 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformKeyProp(jsx=react-jsx).stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformKeyProp(jsx=react-jsx).stats.rust-debug index 27ba984132..7d12ad5c64 100644 --- a/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformKeyProp(jsx=react-jsx).stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformKeyProp(jsx=react-jsx).stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 0, - panic: 1, + extra_error: 3, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformKeyProp(jsx=react-jsxdev).error-diff.json b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformKeyProp(jsx=react-jsxdev).error-diff.json new file mode 100644 index 0000000000..89cc5dbfaa --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformKeyProp(jsx=react-jsxdev).error-diff.json @@ -0,0 +1,17 @@ +{ + "required_errors": {}, + "required_error_lines": {}, + "extra_errors": { + "TS2307": 1, + "TS7005": 2 + }, + "extra_error_lines": { + "TS2307": [ + 5 + ], + "TS7005": [ + 6, + 7 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformKeyProp(jsx=react-jsxdev).stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformKeyProp(jsx=react-jsxdev).stats.rust-debug index 27ba984132..7d12ad5c64 100644 --- a/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformKeyProp(jsx=react-jsxdev).stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformKeyProp(jsx=react-jsxdev).stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 0, - panic: 1, + extra_error: 3, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformKeyPropCustomImportPragma(jsx=react-jsx).error-diff.json b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformKeyPropCustomImportPragma(jsx=react-jsx).error-diff.json new file mode 100644 index 0000000000..ce59ccb9b4 --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformKeyPropCustomImportPragma(jsx=react-jsx).error-diff.json @@ -0,0 +1,26 @@ +{ + "required_errors": { + "TS2307": 1 + }, + "required_error_lines": { + "TS2307": [ + 4 + ] + }, + "extra_errors": { + "TS2307": 2, + "TS7005": 4 + }, + "extra_error_lines": { + "TS2307": [ + 3, + 3 + ], + "TS7005": [ + 4, + 5, + 5, + 6 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformKeyPropCustomImportPragma(jsx=react-jsx).stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformKeyPropCustomImportPragma(jsx=react-jsx).stats.rust-debug index f79107e8ee..6c9e6f8a3c 100644 --- a/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformKeyPropCustomImportPragma(jsx=react-jsx).stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformKeyPropCustomImportPragma(jsx=react-jsx).stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 1, matched_error: 0, - extra_error: 0, - panic: 1, + extra_error: 6, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformKeyPropCustomImportPragma(jsx=react-jsxdev).error-diff.json b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformKeyPropCustomImportPragma(jsx=react-jsxdev).error-diff.json new file mode 100644 index 0000000000..ce59ccb9b4 --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformKeyPropCustomImportPragma(jsx=react-jsxdev).error-diff.json @@ -0,0 +1,26 @@ +{ + "required_errors": { + "TS2307": 1 + }, + "required_error_lines": { + "TS2307": [ + 4 + ] + }, + "extra_errors": { + "TS2307": 2, + "TS7005": 4 + }, + "extra_error_lines": { + "TS2307": [ + 3, + 3 + ], + "TS7005": [ + 4, + 5, + 5, + 6 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformKeyPropCustomImportPragma(jsx=react-jsxdev).stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformKeyPropCustomImportPragma(jsx=react-jsxdev).stats.rust-debug index f79107e8ee..6c9e6f8a3c 100644 --- a/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformKeyPropCustomImportPragma(jsx=react-jsxdev).stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformKeyPropCustomImportPragma(jsx=react-jsxdev).stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 1, matched_error: 0, - extra_error: 0, - panic: 1, + extra_error: 6, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformNestedSelfClosingChild(jsx=react-jsx).error-diff.json b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformNestedSelfClosingChild(jsx=react-jsx).error-diff.json new file mode 100644 index 0000000000..7381c16eaf --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformNestedSelfClosingChild(jsx=react-jsx).error-diff.json @@ -0,0 +1,23 @@ +{ + "required_errors": {}, + "required_error_lines": {}, + "extra_errors": { + "TS2307": 2, + "TS7005": 7 + }, + "extra_error_lines": { + "TS2307": [ + 5, + 5 + ], + "TS7005": [ + 8, + 9, + 14, + 15, + 16, + 21, + 22 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformNestedSelfClosingChild(jsx=react-jsx).stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformNestedSelfClosingChild(jsx=react-jsx).stats.rust-debug index 27ba984132..48117d2c81 100644 --- a/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformNestedSelfClosingChild(jsx=react-jsx).stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformNestedSelfClosingChild(jsx=react-jsx).stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 0, - panic: 1, + extra_error: 9, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformNestedSelfClosingChild(jsx=react-jsxdev).error-diff.json b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformNestedSelfClosingChild(jsx=react-jsxdev).error-diff.json new file mode 100644 index 0000000000..7381c16eaf --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformNestedSelfClosingChild(jsx=react-jsxdev).error-diff.json @@ -0,0 +1,23 @@ +{ + "required_errors": {}, + "required_error_lines": {}, + "extra_errors": { + "TS2307": 2, + "TS7005": 7 + }, + "extra_error_lines": { + "TS2307": [ + 5, + 5 + ], + "TS7005": [ + 8, + 9, + 14, + 15, + 16, + 21, + 22 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformNestedSelfClosingChild(jsx=react-jsxdev).stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformNestedSelfClosingChild(jsx=react-jsxdev).stats.rust-debug index 27ba984132..48117d2c81 100644 --- a/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformNestedSelfClosingChild(jsx=react-jsxdev).stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformNestedSelfClosingChild(jsx=react-jsxdev).stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 0, - panic: 1, + extra_error: 9, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformSubstitutesNames(jsx=react-jsx).error-diff.json b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformSubstitutesNames(jsx=react-jsx).error-diff.json new file mode 100644 index 0000000000..7d36c3a8e2 --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformSubstitutesNames(jsx=react-jsx).error-diff.json @@ -0,0 +1,16 @@ +{ + "required_errors": {}, + "required_error_lines": {}, + "extra_errors": { + "TS2307": 1, + "TS7005": 1 + }, + "extra_error_lines": { + "TS2307": [ + 5 + ], + "TS7005": [ + 5 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformSubstitutesNames(jsx=react-jsx).stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformSubstitutesNames(jsx=react-jsx).stats.rust-debug index 27ba984132..d45524b098 100644 --- a/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformSubstitutesNames(jsx=react-jsx).stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformSubstitutesNames(jsx=react-jsx).stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 0, - panic: 1, + extra_error: 2, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformSubstitutesNames(jsx=react-jsxdev).error-diff.json b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformSubstitutesNames(jsx=react-jsxdev).error-diff.json new file mode 100644 index 0000000000..7d36c3a8e2 --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformSubstitutesNames(jsx=react-jsxdev).error-diff.json @@ -0,0 +1,16 @@ +{ + "required_errors": {}, + "required_error_lines": {}, + "extra_errors": { + "TS2307": 1, + "TS7005": 1 + }, + "extra_error_lines": { + "TS2307": [ + 5 + ], + "TS7005": [ + 5 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformSubstitutesNames(jsx=react-jsxdev).stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformSubstitutesNames(jsx=react-jsxdev).stats.rust-debug index 27ba984132..d45524b098 100644 --- a/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformSubstitutesNames(jsx=react-jsxdev).stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformSubstitutesNames(jsx=react-jsxdev).stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 0, - panic: 1, + extra_error: 2, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformSubstitutesNamesFragment(jsx=react-jsx).error-diff.json b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformSubstitutesNamesFragment(jsx=react-jsx).error-diff.json new file mode 100644 index 0000000000..c7e622144f --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformSubstitutesNamesFragment(jsx=react-jsx).error-diff.json @@ -0,0 +1,17 @@ +{ + "required_errors": {}, + "required_error_lines": {}, + "extra_errors": { + "TS2307": 1, + "TS7005": 2 + }, + "extra_error_lines": { + "TS2307": [ + 5 + ], + "TS7005": [ + 6, + 8 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformSubstitutesNamesFragment(jsx=react-jsx).stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformSubstitutesNamesFragment(jsx=react-jsx).stats.rust-debug index 27ba984132..7d12ad5c64 100644 --- a/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformSubstitutesNamesFragment(jsx=react-jsx).stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformSubstitutesNamesFragment(jsx=react-jsx).stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 0, - panic: 1, + extra_error: 3, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformSubstitutesNamesFragment(jsx=react-jsxdev).error-diff.json b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformSubstitutesNamesFragment(jsx=react-jsxdev).error-diff.json new file mode 100644 index 0000000000..c7e622144f --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformSubstitutesNamesFragment(jsx=react-jsxdev).error-diff.json @@ -0,0 +1,17 @@ +{ + "required_errors": {}, + "required_error_lines": {}, + "extra_errors": { + "TS2307": 1, + "TS7005": 2 + }, + "extra_error_lines": { + "TS2307": [ + 5 + ], + "TS7005": [ + 6, + 8 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformSubstitutesNamesFragment(jsx=react-jsxdev).stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformSubstitutesNamesFragment(jsx=react-jsxdev).stats.rust-debug index 27ba984132..7d12ad5c64 100644 --- a/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformSubstitutesNamesFragment(jsx=react-jsxdev).stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/jsxs/jsxJsxsCjsTransformSubstitutesNamesFragment(jsx=react-jsxdev).stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 0, - panic: 1, + extra_error: 3, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/tsxElementResolution17.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/jsx/tsxElementResolution17.error-diff.json new file mode 100644 index 0000000000..94fd503a18 --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/tsxElementResolution17.error-diff.json @@ -0,0 +1,13 @@ +{ + "required_errors": {}, + "required_error_lines": {}, + "extra_errors": { + "TS2307": 2 + }, + "extra_error_lines": { + "TS2307": [ + 3, + 4 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/tsxElementResolution17.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/jsx/tsxElementResolution17.stats.rust-debug index 27ba984132..d45524b098 100644 --- a/crates/stc_ts_type_checker/tests/conformance/jsx/tsxElementResolution17.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/tsxElementResolution17.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 0, - panic: 1, + extra_error: 2, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/tsxReactEmit8(jsx=react-jsx).error-diff.json b/crates/stc_ts_type_checker/tests/conformance/jsx/tsxReactEmit8(jsx=react-jsx).error-diff.json new file mode 100644 index 0000000000..ec894ef590 --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/tsxReactEmit8(jsx=react-jsx).error-diff.json @@ -0,0 +1,17 @@ +{ + "required_errors": {}, + "required_error_lines": {}, + "extra_errors": { + "TS2307": 1, + "TS7005": 2 + }, + "extra_error_lines": { + "TS2307": [ + 5 + ], + "TS7005": [ + 5, + 6 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/tsxReactEmit8(jsx=react-jsx).stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/jsx/tsxReactEmit8(jsx=react-jsx).stats.rust-debug index 27ba984132..7d12ad5c64 100644 --- a/crates/stc_ts_type_checker/tests/conformance/jsx/tsxReactEmit8(jsx=react-jsx).stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/tsxReactEmit8(jsx=react-jsx).stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 0, - panic: 1, + extra_error: 3, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/tsxReactEmit8(jsx=react-jsxdev).error-diff.json b/crates/stc_ts_type_checker/tests/conformance/jsx/tsxReactEmit8(jsx=react-jsxdev).error-diff.json new file mode 100644 index 0000000000..ec894ef590 --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/tsxReactEmit8(jsx=react-jsxdev).error-diff.json @@ -0,0 +1,17 @@ +{ + "required_errors": {}, + "required_error_lines": {}, + "extra_errors": { + "TS2307": 1, + "TS7005": 2 + }, + "extra_error_lines": { + "TS2307": [ + 5 + ], + "TS7005": [ + 5, + 6 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/tsxReactEmit8(jsx=react-jsxdev).stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/jsx/tsxReactEmit8(jsx=react-jsxdev).stats.rust-debug index 27ba984132..7d12ad5c64 100644 --- a/crates/stc_ts_type_checker/tests/conformance/jsx/tsxReactEmit8(jsx=react-jsxdev).stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/tsxReactEmit8(jsx=react-jsxdev).stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 0, - panic: 1, + extra_error: 3, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/tsxReactEmitSpreadAttribute(target=es2015).error-diff.json b/crates/stc_ts_type_checker/tests/conformance/jsx/tsxReactEmitSpreadAttribute(target=es2015).error-diff.json new file mode 100644 index 0000000000..5bbdac3469 --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/tsxReactEmitSpreadAttribute(target=es2015).error-diff.json @@ -0,0 +1,12 @@ +{ + "required_errors": {}, + "required_error_lines": {}, + "extra_errors": { + "TS2307": 1 + }, + "extra_error_lines": { + "TS2307": [ + 3 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/tsxReactEmitSpreadAttribute(target=es2015).stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/jsx/tsxReactEmitSpreadAttribute(target=es2015).stats.rust-debug index 27ba984132..0498397634 100644 --- a/crates/stc_ts_type_checker/tests/conformance/jsx/tsxReactEmitSpreadAttribute(target=es2015).stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/tsxReactEmitSpreadAttribute(target=es2015).stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 0, - panic: 1, + extra_error: 1, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/tsxReactEmitSpreadAttribute(target=es2018).error-diff.json b/crates/stc_ts_type_checker/tests/conformance/jsx/tsxReactEmitSpreadAttribute(target=es2018).error-diff.json new file mode 100644 index 0000000000..5bbdac3469 --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/tsxReactEmitSpreadAttribute(target=es2018).error-diff.json @@ -0,0 +1,12 @@ +{ + "required_errors": {}, + "required_error_lines": {}, + "extra_errors": { + "TS2307": 1 + }, + "extra_error_lines": { + "TS2307": [ + 3 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/tsxReactEmitSpreadAttribute(target=es2018).stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/jsx/tsxReactEmitSpreadAttribute(target=es2018).stats.rust-debug index 27ba984132..0498397634 100644 --- a/crates/stc_ts_type_checker/tests/conformance/jsx/tsxReactEmitSpreadAttribute(target=es2018).stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/tsxReactEmitSpreadAttribute(target=es2018).stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 0, - panic: 1, + extra_error: 1, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/tsxReactEmitSpreadAttribute(target=esnext).error-diff.json b/crates/stc_ts_type_checker/tests/conformance/jsx/tsxReactEmitSpreadAttribute(target=esnext).error-diff.json new file mode 100644 index 0000000000..5bbdac3469 --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/tsxReactEmitSpreadAttribute(target=esnext).error-diff.json @@ -0,0 +1,12 @@ +{ + "required_errors": {}, + "required_error_lines": {}, + "extra_errors": { + "TS2307": 1 + }, + "extra_error_lines": { + "TS2307": [ + 3 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/tsxReactEmitSpreadAttribute(target=esnext).stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/jsx/tsxReactEmitSpreadAttribute(target=esnext).stats.rust-debug index 27ba984132..0498397634 100644 --- a/crates/stc_ts_type_checker/tests/conformance/jsx/tsxReactEmitSpreadAttribute(target=esnext).stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/tsxReactEmitSpreadAttribute(target=esnext).stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 0, - panic: 1, + extra_error: 1, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/RealWorld/parserindenter.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/RealWorld/parserindenter.error-diff.json new file mode 100644 index 0000000000..1af12b2cfc --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/RealWorld/parserindenter.error-diff.json @@ -0,0 +1,83 @@ +{ + "required_errors": { + "TS6053": 1, + "TS2662": 1, + "TS2304": 28 + }, + "required_error_lines": { + "TS6053": [ + 16 + ], + "TS2662": [ + 183 + ], + "TS2304": [ + 215, + 216, + 220, + 222, + 222, + 227, + 228, + 235, + 238, + 311, + 312, + 313, + 314, + 315, + 316, + 317, + 318, + 319, + 320, + 321, + 324, + 331, + 331, + 718, + 721, + 722, + 725, + 726 + ] + }, + "extra_errors": { + "TS2339": 27, + "TS2304": 1 + }, + "extra_error_lines": { + "TS2339": [ + 42, + 43, + 81, + 89, + 94, + 118, + 126, + 133, + 135, + 141, + 162, + 168, + 171, + 297, + 301, + 397, + 410, + 411, + 446, + 450, + 585, + 587, + 608, + 611, + 636, + 637, + 706 + ], + "TS2304": [ + 183 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/RealWorld/parserindenter.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/RealWorld/parserindenter.stats.rust-debug index f83275a35b..873fc2bc52 100644 --- a/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/RealWorld/parserindenter.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/RealWorld/parserindenter.stats.rust-debug @@ -1,6 +1,6 @@ Stats { - required_error: 128, - matched_error: 0, - extra_error: 0, - panic: 1, + required_error: 30, + matched_error: 98, + extra_error: 28, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource1.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource1.error-diff.json new file mode 100644 index 0000000000..aa1c2c6f87 --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource1.error-diff.json @@ -0,0 +1,12 @@ +{ + "required_errors": { + "TS6053": 1 + }, + "required_error_lines": { + "TS6053": [ + 4 + ] + }, + "extra_errors": {}, + "extra_error_lines": {} +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource1.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource1.stats.rust-debug index f79107e8ee..4af5bf17ec 100644 --- a/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource1.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource1.stats.rust-debug @@ -2,5 +2,5 @@ Stats { required_error: 1, matched_error: 0, extra_error: 0, - panic: 1, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource12.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource12.error-diff.json new file mode 100644 index 0000000000..2309e9d7e2 --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource12.error-diff.json @@ -0,0 +1,31 @@ +{ + "required_errors": { + "TS6053": 1 + }, + "required_error_lines": { + "TS6053": [ + 4 + ] + }, + "extra_errors": { + "TS2345": 2, + "TS2339": 9 + }, + "extra_error_lines": { + "TS2345": [ + 42, + 58 + ], + "TS2339": [ + 55, + 74, + 82, + 236, + 237, + 262, + 264, + 265, + 278 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource12.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource12.stats.rust-debug index 2ac1cb0fa3..ea8af630c8 100644 --- a/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource12.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource12.stats.rust-debug @@ -1,6 +1,6 @@ Stats { - required_error: 209, - matched_error: 0, - extra_error: 0, - panic: 1, + required_error: 1, + matched_error: 208, + extra_error: 11, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource13.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource13.error-diff.json new file mode 100644 index 0000000000..9b5159705a --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource13.error-diff.json @@ -0,0 +1,22 @@ +{ + "required_errors": { + "TS6053": 1, + "TS2339": 1 + }, + "required_error_lines": { + "TS6053": [ + 4 + ], + "TS2339": [ + 128 + ] + }, + "extra_errors": { + "TS2304": 1 + }, + "extra_error_lines": { + "TS2304": [ + 119 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource13.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource13.stats.rust-debug index f7b6605b10..400b628896 100644 --- a/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource13.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource13.stats.rust-debug @@ -1,6 +1,6 @@ Stats { - required_error: 116, - matched_error: 0, - extra_error: 0, - panic: 1, + required_error: 2, + matched_error: 114, + extra_error: 1, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource14.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource14.error-diff.json new file mode 100644 index 0000000000..cfdd5ff673 --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource14.error-diff.json @@ -0,0 +1,327 @@ +{ + "required_errors": { + "TS6053": 1, + "TS2694": 72, + "TS2339": 84 + }, + "required_error_lines": { + "TS6053": [ + 4 + ], + "TS2694": [ + 24, + 38, + 48, + 68, + 75, + 79, + 86, + 96, + 105, + 114, + 123, + 132, + 141, + 176, + 177, + 178, + 192, + 199, + 200, + 206, + 212, + 218, + 224, + 230, + 236, + 242, + 248, + 254, + 260, + 266, + 272, + 278, + 284, + 290, + 296, + 303, + 310, + 311, + 318, + 329, + 330, + 338, + 347, + 354, + 360, + 366, + 378, + 384, + 394, + 401, + 408, + 415, + 422, + 428, + 432, + 462, + 463, + 478, + 478, + 533, + 535, + 535, + 535, + 535, + 558, + 558, + 559, + 559, + 559, + 565, + 565, + 565 + ], + "TS2339": [ + 70, + 94, + 95, + 103, + 104, + 112, + 113, + 121, + 122, + 130, + 131, + 139, + 140, + 148, + 149, + 156, + 157, + 164, + 165, + 172, + 173, + 174, + 175, + 185, + 186, + 191, + 192, + 192, + 197, + 198, + 200, + 200, + 205, + 211, + 217, + 223, + 229, + 235, + 241, + 247, + 253, + 259, + 265, + 271, + 277, + 283, + 289, + 295, + 301, + 302, + 308, + 309, + 316, + 317, + 327, + 328, + 335, + 336, + 337, + 343, + 344, + 345, + 346, + 352, + 353, + 359, + 365, + 371, + 377, + 383, + 393, + 399, + 400, + 406, + 407, + 413, + 414, + 420, + 421, + 427, + 490, + 525, + 551, + 572 + ] + }, + "extra_errors": { + "TS2339": 2, + "TS2322": 1, + "TS2363": 1, + "TS2362": 135 + }, + "extra_error_lines": { + "TS2339": [ + 40, + 322 + ], + "TS2322": [ + 52 + ], + "TS2363": [ + 79 + ], + "TS2362": [ + 148, + 149, + 156, + 157, + 164, + 165, + 172, + 173, + 174, + 175, + 176, + 177, + 177, + 178, + 178, + 185, + 186, + 197, + 198, + 199, + 199, + 200, + 205, + 206, + 206, + 211, + 212, + 212, + 217, + 218, + 218, + 223, + 224, + 224, + 229, + 230, + 230, + 235, + 236, + 236, + 241, + 242, + 242, + 247, + 248, + 248, + 253, + 254, + 254, + 259, + 260, + 260, + 265, + 266, + 266, + 271, + 272, + 272, + 277, + 278, + 278, + 283, + 284, + 284, + 289, + 290, + 290, + 295, + 296, + 296, + 301, + 302, + 303, + 303, + 308, + 309, + 310, + 310, + 311, + 311, + 316, + 317, + 318, + 318, + 327, + 328, + 329, + 329, + 330, + 335, + 336, + 337, + 338, + 338, + 343, + 344, + 345, + 346, + 347, + 347, + 352, + 353, + 354, + 354, + 359, + 360, + 360, + 365, + 366, + 366, + 371, + 377, + 378, + 378, + 383, + 384, + 384, + 399, + 400, + 401, + 401, + 406, + 407, + 408, + 408, + 413, + 414, + 415, + 415, + 420, + 421, + 422, + 422, + 427, + 428 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource14.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource14.stats.rust-debug index f59be2b356..6b9b61b035 100644 --- a/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource14.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource14.stats.rust-debug @@ -1,6 +1,6 @@ Stats { - required_error: 160, - matched_error: 0, - extra_error: 0, - panic: 1, + required_error: 157, + matched_error: 3, + extra_error: 139, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource2.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource2.error-diff.json new file mode 100644 index 0000000000..aa1c2c6f87 --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource2.error-diff.json @@ -0,0 +1,12 @@ +{ + "required_errors": { + "TS6053": 1 + }, + "required_error_lines": { + "TS6053": [ + 4 + ] + }, + "extra_errors": {}, + "extra_error_lines": {} +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource2.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource2.stats.rust-debug index f79107e8ee..4af5bf17ec 100644 --- a/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource2.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource2.stats.rust-debug @@ -2,5 +2,5 @@ Stats { required_error: 1, matched_error: 0, extra_error: 0, - panic: 1, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource3.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource3.error-diff.json new file mode 100644 index 0000000000..aa1c2c6f87 --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource3.error-diff.json @@ -0,0 +1,12 @@ +{ + "required_errors": { + "TS6053": 1 + }, + "required_error_lines": { + "TS6053": [ + 4 + ] + }, + "extra_errors": {}, + "extra_error_lines": {} +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource3.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource3.stats.rust-debug index f79107e8ee..4af5bf17ec 100644 --- a/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource3.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource3.stats.rust-debug @@ -2,5 +2,5 @@ Stats { required_error: 1, matched_error: 0, extra_error: 0, - panic: 1, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource5.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource5.error-diff.json new file mode 100644 index 0000000000..43eab19d65 --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource5.error-diff.json @@ -0,0 +1,18 @@ +{ + "required_errors": { + "TS6053": 1 + }, + "required_error_lines": { + "TS6053": [ + 4 + ] + }, + "extra_errors": { + "TS2304": 1 + }, + "extra_error_lines": { + "TS2304": [ + 14 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource5.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource5.stats.rust-debug index 8c5fd24c0e..2ee9dfaf47 100644 --- a/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource5.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource5.stats.rust-debug @@ -1,6 +1,6 @@ Stats { - required_error: 9, - matched_error: 0, - extra_error: 0, - panic: 1, + required_error: 1, + matched_error: 8, + extra_error: 1, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource6.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource6.error-diff.json new file mode 100644 index 0000000000..b0374356ca --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource6.error-diff.json @@ -0,0 +1,38 @@ +{ + "required_errors": { + "TS6053": 1, + "TS2339": 2, + "TS2304": 12 + }, + "required_error_lines": { + "TS6053": [ + 4 + ], + "TS2339": [ + 73, + 215 + ], + "TS2304": [ + 127, + 134, + 139, + 142, + 143, + 156, + 157, + 164, + 171, + 172, + 179, + 179 + ] + }, + "extra_errors": { + "TS2339": 1 + }, + "extra_error_lines": { + "TS2339": [ + 70 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource6.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource6.stats.rust-debug index 23ff677607..d684f915e0 100644 --- a/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource6.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource6.stats.rust-debug @@ -1,6 +1,6 @@ Stats { - required_error: 60, - matched_error: 0, - extra_error: 0, - panic: 1, + required_error: 15, + matched_error: 45, + extra_error: 1, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource8.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource8.error-diff.json new file mode 100644 index 0000000000..a6a2810f05 --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource8.error-diff.json @@ -0,0 +1,43 @@ +{ + "required_errors": { + "TS6053": 1, + "TS2339": 1 + }, + "required_error_lines": { + "TS6053": [ + 4 + ], + "TS2339": [ + 170 + ] + }, + "extra_errors": { + "TS2339": 22 + }, + "extra_error_lines": { + "TS2339": [ + 226, + 228, + 258, + 271, + 275, + 319, + 324, + 337, + 339, + 340, + 341, + 343, + 350, + 354, + 354, + 355, + 357, + 369, + 372, + 372, + 373, + 373 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource8.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource8.stats.rust-debug index 80874da50f..cf7e9c96cc 100644 --- a/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource8.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/parser/ecmascript5/parserRealSource8.stats.rust-debug @@ -1,6 +1,6 @@ Stats { - required_error: 130, - matched_error: 0, - extra_error: 0, - panic: 1, + required_error: 2, + matched_error: 128, + extra_error: 22, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/salsa/sourceFileMergeWithFunction.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/salsa/sourceFileMergeWithFunction.stats.rust-debug index 27ba984132..c086b5ab15 100644 --- a/crates/stc_ts_type_checker/tests/conformance/salsa/sourceFileMergeWithFunction.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/salsa/sourceFileMergeWithFunction.stats.rust-debug @@ -2,5 +2,5 @@ Stats { required_error: 0, matched_error: 0, extra_error: 0, - panic: 1, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/scanner/ecmascript5/scannertest1.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/scanner/ecmascript5/scannertest1.error-diff.json new file mode 100644 index 0000000000..2b314d348a --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/scanner/ecmascript5/scannertest1.error-diff.json @@ -0,0 +1,26 @@ +{ + "required_errors": { + "TS6053": 1, + "TS2662": 3 + }, + "required_error_lines": { + "TS6053": [ + 1 + ], + "TS2662": [ + 9, + 15, + 16 + ] + }, + "extra_errors": { + "TS2304": 3 + }, + "extra_error_lines": { + "TS2304": [ + 9, + 15, + 16 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/scanner/ecmascript5/scannertest1.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/scanner/ecmascript5/scannertest1.stats.rust-debug index 4c1e44601d..d70dda7ddd 100644 --- a/crates/stc_ts_type_checker/tests/conformance/scanner/ecmascript5/scannertest1.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/scanner/ecmascript5/scannertest1.stats.rust-debug @@ -1,6 +1,6 @@ Stats { - required_error: 16, - matched_error: 0, - extra_error: 0, - panic: 1, + required_error: 4, + matched_error: 12, + extra_error: 3, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/types/typeRelationships/typeInference/intraExpressionInferencesJsx.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/types/typeRelationships/typeInference/intraExpressionInferencesJsx.error-diff.json new file mode 100644 index 0000000000..4a5e33d920 --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/types/typeRelationships/typeInference/intraExpressionInferencesJsx.error-diff.json @@ -0,0 +1,30 @@ +{ + "required_errors": {}, + "required_error_lines": {}, + "extra_errors": { + "TS2307": 1, + "TS2322": 6, + "TS7010": 1, + "TS7005": 2 + }, + "extra_error_lines": { + "TS2307": [ + 9 + ], + "TS2322": [ + 41, + 53, + 70, + 99, + 104, + 109 + ], + "TS7010": [ + 95 + ], + "TS7005": [ + 110, + 111 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/types/typeRelationships/typeInference/intraExpressionInferencesJsx.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/types/typeRelationships/typeInference/intraExpressionInferencesJsx.stats.rust-debug index 27ba984132..8b929ae3fd 100644 --- a/crates/stc_ts_type_checker/tests/conformance/types/typeRelationships/typeInference/intraExpressionInferencesJsx.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/types/typeRelationships/typeInference/intraExpressionInferencesJsx.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 0, - panic: 1, + extra_error: 10, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug index 436c94ebb2..1d562f009c 100644 --- a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug @@ -1,6 +1,6 @@ Stats { - required_error: 3487, - matched_error: 6548, - extra_error: 768, - panic: 60, + required_error: 2869, + matched_error: 7166, + extra_error: 1098, + panic: 6, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/tsc.rs b/crates/stc_ts_type_checker/tests/tsc.rs index c51aef94e6..b67662be5a 100644 --- a/crates/stc_ts_type_checker/tests/tsc.rs +++ b/crates/stc_ts_type_checker/tests/tsc.rs @@ -300,12 +300,6 @@ fn do_test(file_name: &Path, spec: TestSpec, use_target: bool) -> Result<(), Std }, }; - let main_src = Arc::new(fs::read_to_string(file_name).unwrap()); - // Postpone multi-file tests. - if main_src.contains(" Date: Sat, 23 Sep 2023 07:48:56 +0900 Subject: [PATCH 32/40] refactor: Split `analyzer/types/mod.rs` (#1091) --- .../src/analyzer/types/intersection.rs | 447 +++++++++++++++++ .../src/analyzer/types/mod.rs | 452 +----------------- 2 files changed, 449 insertions(+), 450 deletions(-) create mode 100644 crates/stc_ts_file_analyzer/src/analyzer/types/intersection.rs diff --git a/crates/stc_ts_file_analyzer/src/analyzer/types/intersection.rs b/crates/stc_ts_file_analyzer/src/analyzer/types/intersection.rs new file mode 100644 index 0000000000..ff695fe5e5 --- /dev/null +++ b/crates/stc_ts_file_analyzer/src/analyzer/types/intersection.rs @@ -0,0 +1,447 @@ +use std::borrow::Cow; + +use stc_arc_cow::ArcCow; +use stc_ts_ast_rnode::{RIdent, RTsEnumMemberId, RTsLit}; +use stc_ts_errors::DebugExt; +use stc_ts_types::{ + Conditional, Enum, EnumVariant, Intersection, KeywordType, KeywordTypeMetadata, LitType, Type, TypeElement, TypeLit, TypeParam, Union, +}; +use stc_utils::{cache::Freeze, ext::TypeVecExt}; +use swc_atoms::JsWord; +use swc_common::{Span, TypeEq}; +use swc_ecma_ast::TsKeywordTypeKind; + +use super::NormalizeTypeOpts; +use crate::{analyzer::Analyzer, VResult}; + +macro_rules! never { + ($span:ident) => {{ + Ok(Some(Type::never($span, Default::default()))) + }}; +} + +impl Analyzer<'_, '_> { + pub(crate) fn normalize_intersection_types(&mut self, span: Span, types: &[Type], opts: NormalizeTypeOpts) -> VResult> { + let mut normalized_types = vec![]; + // set normalize all + for el in types.iter() { + if let Ok(res) = self.normalize( + Some(span), + Cow::Borrowed(el), + NormalizeTypeOpts { + preserve_global_this: true, + ..opts + }, + ) { + let result = res.into_owned(); + + match &result.normalize() { + Type::Keyword(KeywordType { + kind: TsKeywordTypeKind::TsUnknownKeyword, + .. + }) => {} + Type::Intersection(Intersection { types, .. }) => { + for ty in types { + normalized_types.push(ty.to_owned()); + } + } + _ => { + normalized_types.push(result); + } + } + } + } + + normalized_types.dedup_type(); + normalized_types.freeze(); + + if normalized_types.len() == 1 { + if let Some(ty) = normalized_types.pop() { + return Ok(Some(ty)); + } + } + // has never; return never + if normalized_types.iter().any(|ty| ty.is_never()) { + return never!(span); + } + // has any, return any + if normalized_types.iter().any(|ty| ty.is_any()) { + return Ok(Some(Type::Keyword(KeywordType { + span, + kind: TsKeywordTypeKind::TsAnyKeyword, + metadata: KeywordTypeMetadata { ..Default::default() }, + tracker: Default::default(), + }))); + } + + let is_symbol = normalized_types.iter().any(|ty| ty.is_symbol()); + let is_str = normalized_types.iter().any(|ty| ty.is_str()); + let is_num = normalized_types.iter().any(|ty| ty.is_num()); + let is_bool = normalized_types.iter().any(|ty| ty.is_bool()); + let is_null = normalized_types.iter().any(|ty| ty.is_null()); + let is_undefined = normalized_types.iter().any(|ty| ty.is_undefined()); + let is_void = normalized_types.iter().any(|ty| ty.is_kwd(TsKeywordTypeKind::TsVoidKeyword)); + let is_object = normalized_types.iter().any(|ty| ty.is_kwd(TsKeywordTypeKind::TsObjectKeyword)); + let is_function = normalized_types.iter().any(|ty| ty.is_fn_type()); + let is_type_lit = normalized_types.iter().any(|ty| ty.is_type_lit()); + + if (is_null || is_undefined) && is_type_lit { + return never!(span); + } + + let sum = u32::from(is_symbol) + + u32::from(is_str) + + u32::from(is_num) + + u32::from(is_bool) + + u32::from(is_null) + + u32::from(is_undefined) + + u32::from(is_void) + + u32::from(is_object) + + u32::from(is_function); + + if sum >= 2 { + if sum == 2 && is_undefined && is_void { + return Ok(Some(Type::undefined(span, Default::default()))); + } + return never!(span); + } + + if normalized_types.len() == 2 { + let (a, b) = (&normalized_types[0], &normalized_types[1]); + if ((a.is_str_lit() && b.is_str_lit()) || (a.is_num_lit() && b.is_num_lit()) || (a.is_bool_lit() && b.is_bool_lit())) + && !a.type_eq(b) + { + return never!(span); + } + if let (Type::Conditional(c), other) | (other, Type::Conditional(c)) = (a.normalize(), b.normalize()) { + return Ok(Some( + Type::Conditional(Conditional { + span, + check_type: c.check_type.clone(), + extends_type: c.extends_type.clone(), + true_type: Box::new(Type::new_intersection(span, vec![*(c.true_type).clone(), other.clone()])), + false_type: Box::new(Type::new_intersection(span, vec![*(c.false_type.clone()), other.clone()])), + metadata: c.metadata, + tracker: c.tracker, + }) + .freezed(), + )); + } + } + + let enum_variant_iter = normalized_types.iter().filter(|&t| t.is_enum_variant()).collect::>(); + let enum_variant_len = enum_variant_iter.len(); + + if enum_variant_len > 0 { + if normalized_types.iter().any(|ty| matches!(ty.normalize(), Type::Lit(..))) { + return never!(span); + } + if let Some(first_enum) = enum_variant_iter.first() { + let mut enum_temp = first_enum.normalize(); + for elem in enum_variant_iter.into_iter() { + if let Type::EnumVariant(el) = elem.normalize() { + if let Type::EnumVariant(en) = enum_temp { + if let Type::EnumVariant(EnumVariant { name: None, .. }) = enum_temp { + enum_temp = elem; + continue; + } + + if en.def.id != el.def.id { + return never!(span); + } + + // eq two argument enum_name + if let Ok(el_lit) = self.expand_enum_variant(elem.clone()) { + if let Ok(etl) = self.expand_enum_variant(enum_temp.clone()) { + if !etl.type_eq(&el_lit) { + return never!(span); + } + } + } + } + } + } + } + + #[inline] + fn enum_variant(span: Span, def: ArcCow, name: JsWord) -> Type { + Type::EnumVariant(EnumVariant { + span, + def, + name: Some(name), + metadata: Default::default(), + tracker: Default::default(), + }) + } + for elem in normalized_types.iter() { + if let Type::EnumVariant(ref ev) = elem.normalize() { + match &ev.name { + Some(variant_name) => { + // enumVariant is enumMember + if enum_variant_len >= 2 { + let mut en = ev.clone(); + en.name = None; + return Ok(Some(Type::EnumVariant(en).freezed())); + } + + if let Ok(Type::Lit(LitType { .. })) = self.expand_enum_variant(elem.clone()) { + return Ok(Some(elem.clone().freezed())); + } + } + None => { + // enumVariant is Enum + let mut str_lits = vec![]; + let mut num_lits = vec![]; + + ev.def.members.iter().for_each(|v| { + let key = match &v.id { + RTsEnumMemberId::Ident(i) => i.clone(), + RTsEnumMemberId::Str(s) => RIdent::new(s.value.clone(), s.span), + }; + match &*v.val { + Type::Lit(LitType { lit: RTsLit::Str(v), .. }) => { + str_lits.push(enum_variant(v.span, ev.def.cheap_clone(), key.sym)) + } + Type::Lit(LitType { + lit: RTsLit::Number(v), .. + }) => num_lits.push(enum_variant(v.span, ev.def.cheap_clone(), key.sym)), + _ => {} + } + }); + + if str_lits.is_empty() && is_str { + return never!(span); + } + if num_lits.is_empty() && is_num { + return never!(span); + } + if str_lits.is_empty() && is_num || num_lits.is_empty() && is_str { + return Ok(Some(elem.clone().freezed())); + } + + let mut ty = Type::new_union( + span, + if is_str { + str_lits + } else if is_num { + num_lits + } else { + return never!(span); + }, + ); + + ty.reposition(ev.def.span); + return Ok(Some(ty).freezed()); + } + } + } + } + } + + { + let mut property_types = vec![]; + + for elem in types.iter() { + let elem = self + .normalize( + Some(span), + Cow::Borrowed(elem), + NormalizeTypeOpts { + preserve_global_this: true, + ..opts + }, + ) + .context("failed to normalize types while intersecting properties")? + .freezed() + .into_owned() + .freezed(); + + if let Type::TypeLit(TypeLit { members, .. }) = elem.normalize_instance() { + if let Some(ty) = self.normalize_intersection_of_type_elements(span, members, &mut property_types, opts)? { + return Ok(Some(ty)); + } + } + } + } + + self.flat_intersection_type(span, normalized_types) + } + + fn flat_intersection_type(&mut self, span: Span, mut normalized_types: Vec) -> VResult> { + let normalized_len = normalized_types.len(); + normalized_types.freeze(); + + let mut type_iter = normalized_types.clone().into_iter(); + let mut acc_type = type_iter + .next() + .unwrap_or_else(|| { + Type::Keyword(KeywordType { + span, + kind: TsKeywordTypeKind::TsNeverKeyword, + metadata: KeywordTypeMetadata { ..Default::default() }, + tracker: Default::default(), + }) + }) + .freezed(); + + for elem in type_iter { + let mut new_types = vec![]; + match (acc_type.normalize(), elem.normalize()) { + ( + another @ Type::Param(TypeParam { + constraint: + Some(box Type::Keyword(KeywordType { + kind: TsKeywordTypeKind::TsUnknownKeyword, + .. + })), + .. + }), + other, + ) + | ( + other, + another @ Type::Param(TypeParam { + constraint: + Some(box Type::Keyword(KeywordType { + kind: TsKeywordTypeKind::TsUnknownKeyword, + .. + })), + .. + }), + ) => { + new_types.push(Type::new_intersection(span, [other.clone(), another.clone()]).freezed()); + } + + ( + Type::Param(TypeParam { + constraint: Some(other), .. + }), + Type::Param(TypeParam { + constraint: Some(another), .. + }), + ) => { + if let Some(tp) = + self.normalize_intersection_types(span, &[*other.to_owned(), *another.to_owned()], Default::default())? + { + new_types.push(tp); + } + } + + ( + Type::Param(TypeParam { + constraint: Some(another), .. + }), + other, + ) + | ( + other, + Type::Param(TypeParam { + constraint: Some(another), .. + }), + ) => { + if let Some(tp) = + self.normalize_intersection_types(span, &[other.to_owned(), *another.to_owned()], Default::default())? + { + // We should preserve `T & {}` + if match other.normalize() { + Type::TypeLit(ty) => ty.members.is_empty(), + _ => false, + } && tp.is_interface() + { + new_types.push(acc_type.clone()); + new_types.push(elem.clone()); + } else { + new_types.push(tp); + } + } + } + (Type::Union(Union { types: a_types, .. }), Type::Union(Union { types: b_types, .. })) => { + for a_ty in a_types { + for b_ty in b_types { + if let Some(tp) = + self.normalize_intersection_types(span, &[a_ty.to_owned(), b_ty.to_owned()], Default::default())? + { + new_types.push(tp); + } + } + } + } + (Type::Union(Union { types, .. }), other) | (other, Type::Union(Union { types, .. })) => { + for ty in types { + if let Some(tp) = self.normalize_intersection_types(span, &[ty.to_owned(), other.to_owned()], Default::default())? { + new_types.push(tp); + } + } + } + (Type::Intersection(Intersection { types, .. }), other) | (other, Type::Intersection(Intersection { types, .. })) => { + let mut temp_vec = vec![]; + temp_vec.append(&mut types.to_owned()); + temp_vec.push(other.to_owned()); + + acc_type = Type::new_intersection(span, temp_vec).freezed(); + continue; + } + + (other, another) => { + acc_type = Type::new_intersection(span, vec![other.to_owned(), another.to_owned()]).freezed(); + continue; + } + }; + + new_types.retain(|ty| !ty.is_never()); + + acc_type = match new_types.len() { + 0 => return never!(span), + 1 => { + if let Some(ty) = new_types.pop() { + ty + } else { + return never!(span); + } + } + _ => Type::new_union(span, new_types).freezed(), + }; + } + + if matches!(acc_type.normalize(), Type::Union(Union { types: u_types, .. }) if normalized_len < u_types.len()) { + return Ok(Some(Type::new_intersection(span, normalized_types).freezed())); + } + + Ok(Some(acc_type)) + } + + fn normalize_intersection_of_type_elements( + &mut self, + span: Span, + elements: &[TypeElement], + property_types: &mut Vec, + opts: NormalizeTypeOpts, + ) -> VResult> { + // Intersect property types + 'outer: for e in elements.iter() { + if let TypeElement::Property(p) = e { + for prev in property_types.iter_mut() { + if let TypeElement::Property(prev) = prev { + if prev.key.type_eq(&p.key) { + let prev_type = prev.type_ann.clone().map(|v| *v).unwrap_or(Type::any(span, Default::default())); + let other = p.type_ann.clone().map(|v| *v).unwrap_or(Type::any(span, Default::default())); + + if let Some(new) = self.normalize_intersection_types(span, &[prev_type, other], opts)? { + if new.is_never() { + return never!(span); + } + + prev.type_ann = Some(Box::new(new)); + continue 'outer; + } + } + } + } + } + + property_types.push(e.clone()); + } + + Ok(None) + } +} diff --git a/crates/stc_ts_file_analyzer/src/analyzer/types/mod.rs b/crates/stc_ts_file_analyzer/src/analyzer/types/mod.rs index 0f8725d124..5340973504 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/types/mod.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/types/mod.rs @@ -3,7 +3,7 @@ use std::{borrow::Cow, fmt::Debug}; use fxhash::FxHashMap; use itertools::Itertools; use rnode::{NodeId, VisitWith}; -use stc_ts_ast_rnode::{RBindingIdent, RExpr, RIdent, RInvalid, RNumber, RPat, RStr, RTsEntityName, RTsEnumMemberId, RTsLit}; +use stc_ts_ast_rnode::{RBindingIdent, RExpr, RIdent, RInvalid, RNumber, RPat, RStr, RTsEntityName, RTsLit}; use stc_ts_base_type_ops::{ bindings::{collect_bindings, BindingCollector, KnownTypeVisitor}, is_str_lit_or_union, @@ -42,6 +42,7 @@ use crate::{ mod conditional; mod index_signature; +mod intersection; mod keyof; mod mapped; mod narrowing; @@ -839,455 +840,6 @@ impl Analyzer<'_, '_> { } } - pub(crate) fn normalize_intersection_types(&mut self, span: Span, types: &[Type], opts: NormalizeTypeOpts) -> VResult> { - macro_rules! never { - () => {{ - Ok(Some(Type::Keyword(KeywordType { - span, - kind: TsKeywordTypeKind::TsNeverKeyword, - metadata: KeywordTypeMetadata { ..Default::default() }, - tracker: Default::default(), - }))) - }}; - } - let mut normalized_types = vec![]; - // set normalize all - for el in types.iter() { - if let Ok(res) = self.normalize( - Some(span), - Cow::Borrowed(el), - NormalizeTypeOpts { - preserve_global_this: true, - ..opts - }, - ) { - let result = res.into_owned(); - - match &result.normalize() { - Type::Keyword(KeywordType { - kind: TsKeywordTypeKind::TsUnknownKeyword, - .. - }) => {} - Type::Intersection(Intersection { types, .. }) => { - for ty in types { - normalized_types.push(ty.to_owned()); - } - } - _ => { - normalized_types.push(result); - } - } - } - } - - normalized_types.dedup_type(); - - if normalized_types.len() == 1 { - if let Some(ty) = normalized_types.pop() { - return Ok(Some(ty)); - } - } - // has never; return never - if normalized_types.iter().any(|ty| ty.is_never()) { - return never!(); - } - // has any, return any - if normalized_types.iter().any(|ty| ty.is_any()) { - return Ok(Some(Type::Keyword(KeywordType { - span, - kind: TsKeywordTypeKind::TsAnyKeyword, - metadata: KeywordTypeMetadata { ..Default::default() }, - tracker: Default::default(), - }))); - } - - let is_lit = normalized_types.iter().any(|ty| ty.is_lit()); - let is_symbol = normalized_types.iter().any(|ty| ty.is_symbol()); - let is_str = normalized_types.iter().any(|ty| ty.is_str()); - let is_num = normalized_types.iter().any(|ty| ty.is_num()); - let is_bool = normalized_types.iter().any(|ty| ty.is_bool()); - let is_null = normalized_types.iter().any(|ty| ty.is_null()); - let is_undefined = normalized_types.iter().any(|ty| ty.is_undefined()); - let is_void = normalized_types.iter().any(|ty| ty.is_kwd(TsKeywordTypeKind::TsVoidKeyword)); - let is_object = normalized_types.iter().any(|ty| ty.is_kwd(TsKeywordTypeKind::TsObjectKeyword)); - let is_function = normalized_types.iter().any(|ty| ty.is_fn_type()); - let is_type_lit = normalized_types.iter().any(|ty| ty.is_type_lit()); - - if (is_null || is_undefined) && is_type_lit { - return never!(); - } - - let sum = u32::from(is_symbol) - + u32::from(is_str) - + u32::from(is_num) - + u32::from(is_bool) - + u32::from(is_null) - + u32::from(is_undefined) - + u32::from(is_void) - + u32::from(is_object) - + u32::from(is_function); - - if sum >= 2 { - if sum == 2 && is_undefined && is_void { - return Ok(Some(Type::undefined(span, Default::default()))); - } - return never!(); - } - - if normalized_types.len() == 2 { - let (a, b) = (&normalized_types[0], &normalized_types[1]); - if ((a.is_str_lit() && b.is_str_lit()) || (a.is_num_lit() && b.is_num_lit()) || (a.is_bool_lit() && b.is_bool_lit())) - && !a.type_eq(b) - { - return never!(); - } - if let (Type::Conditional(c), other) | (other, Type::Conditional(c)) = (a, b) { - return Ok(Some( - Type::Conditional(Conditional { - span, - check_type: c.check_type.clone(), - extends_type: c.extends_type.clone(), - true_type: Box::new(Type::new_intersection(span, vec![*(c.true_type).clone(), other.clone()])), - false_type: Box::new(Type::new_intersection(span, vec![*(c.false_type.clone()), other.clone()])), - metadata: c.metadata, - tracker: c.tracker, - }) - .freezed(), - )); - } - } - - let enum_variant_iter = normalized_types.iter().filter(|&t| t.is_enum_variant()).collect::>(); - let enum_variant_len = enum_variant_iter.len(); - - if enum_variant_len > 0 { - if normalized_types.iter().any(|ty| matches!(ty, Type::Lit(..))) { - return never!(); - } - if let Some(first_enum) = enum_variant_iter.first() { - let mut enum_temp = first_enum.normalize(); - for elem in enum_variant_iter.into_iter() { - if let Type::EnumVariant(el) = elem.normalize() { - if let Type::EnumVariant(en) = enum_temp { - if let Type::EnumVariant(EnumVariant { name: None, .. }) = enum_temp { - enum_temp = elem; - continue; - } else if en.def.id != el.def.id { - return never!(); - } else { - // eq two argument enum_name - if let Ok(el_lit) = self.expand_enum_variant(elem.clone()) { - if let Ok(etl) = self.expand_enum_variant(enum_temp.clone()) { - if !etl.type_eq(&el_lit) { - return never!(); - } - } - } - } - } - } - } - } - for elem in normalized_types.iter() { - if let Type::EnumVariant(ref ev) = elem.normalize() { - if let Some(variant_name) = &ev.name { - // enumVariant is enumMember - if enum_variant_len > 1 { - let mut en = ev.clone(); - en.name = None; - return Ok(Some(Type::EnumVariant(en).freezed())); - } - if let Ok(Type::Lit(LitType { .. })) = self.expand_enum_variant(elem.clone()) { - return Ok(Some(elem.clone().freezed())); - } - } else { - // enumVariant is Enum - - let mut str_lits = vec![]; - let mut num_lits = vec![]; - for v in ev.def.members.iter() { - let key = match &v.id { - RTsEnumMemberId::Ident(i) => i.clone(), - RTsEnumMemberId::Str(s) => RIdent::new(s.value.clone(), s.span), - }; - match &*v.val { - Type::Lit(LitType { lit: RTsLit::Str(v), .. }) => str_lits.push(Type::EnumVariant(EnumVariant { - span: v.span, - def: ev.def.cheap_clone(), - name: Some(key.sym), - metadata: Default::default(), - tracker: Default::default(), - })), - Type::Lit(LitType { - lit: RTsLit::Number(v), .. - }) => num_lits.push(Type::EnumVariant(EnumVariant { - span: v.span, - def: ev.def.cheap_clone(), - name: Some(key.sym), - metadata: Default::default(), - tracker: Default::default(), - })), - _ => {} - } - } - - if str_lits.is_empty() && is_str { - return never!(); - } - if num_lits.is_empty() && is_num { - return never!(); - } - if str_lits.is_empty() && is_num || num_lits.is_empty() && is_str { - return Ok(Some(elem.clone().freezed())); - } - - let mut ty = Type::new_union( - span, - if is_str { - str_lits - } else if is_num { - num_lits - } else { - return never!(); - }, - ); - - ty.reposition(ev.def.span); - return Ok(Some(ty).freezed()); - } - } - } - } - - let mut property_types = vec![]; - - for elem in types.iter() { - let elem = self - .normalize( - Some(span), - Cow::Borrowed(elem), - NormalizeTypeOpts { - preserve_global_this: true, - ..opts - }, - ) - .context("failed to normalize types while intersecting properties")? - .freezed() - .into_owned() - .freezed(); - - if let Type::TypeLit(elem_tl) = elem.normalize_instance() { - if let Some(ty) = self.normalize_intersection_of_type_elements(span, &elem_tl.members, &mut property_types, opts)? { - return Ok(Some(ty)); - } - } - } - - { - let normalized_len = normalized_types.len(); - normalized_types.freeze(); - let mut type_iter = normalized_types.clone().into_iter(); - let mut acc_type = type_iter - .next() - .unwrap_or_else(|| { - Type::Keyword(KeywordType { - span, - kind: TsKeywordTypeKind::TsNeverKeyword, - metadata: KeywordTypeMetadata { ..Default::default() }, - tracker: Default::default(), - }) - }) - .freezed(); - - for elem in type_iter { - let mut new_types = vec![]; - match (acc_type.normalize(), elem.normalize()) { - ( - another @ Type::Param(TypeParam { - constraint: - Some(box Type::Keyword(KeywordType { - kind: TsKeywordTypeKind::TsUnknownKeyword, - .. - })), - .. - }), - other, - ) - | ( - other, - another @ Type::Param(TypeParam { - constraint: - Some(box Type::Keyword(KeywordType { - kind: TsKeywordTypeKind::TsUnknownKeyword, - .. - })), - .. - }), - ) => { - new_types.push(Type::new_intersection(span, [other.clone(), another.clone()]).freezed()); - } - - ( - Type::Param(TypeParam { - constraint: Some(other), .. - }), - Type::Param(TypeParam { - constraint: Some(another), .. - }), - ) => { - let result = - self.normalize_intersection_types(span, &[*other.to_owned(), *another.to_owned()], Default::default())?; - if let Some(tp) = result { - new_types.push(tp); - } - } - ( - Type::Param(TypeParam { - constraint: Some(another), .. - }), - other, - ) - | ( - other, - Type::Param(TypeParam { - constraint: Some(another), .. - }), - ) => { - let result = - self.normalize_intersection_types(span, &[other.to_owned(), *another.to_owned()], Default::default())?; - if let Some(tp) = result { - // We should preserve `T & {}` - - if match other.normalize() { - Type::TypeLit(ty) => ty.members.is_empty(), - _ => false, - } && tp.is_interface() - { - new_types.push(acc_type.clone()); - new_types.push(elem.clone()); - } else { - new_types.push(tp); - } - } - } - (Type::Union(Union { types: a_types, .. }), Type::Union(Union { types: b_types, .. })) => { - for a_ty in a_types { - for b_ty in b_types { - let result = - self.normalize_intersection_types(span, &[a_ty.to_owned(), b_ty.to_owned()], Default::default())?; - if let Some(tp) = result { - new_types.push(tp); - } - } - } - } - (Type::Union(Union { types, .. }), other) | (other, Type::Union(Union { types, .. })) => { - for ty in types { - let result = self.normalize_intersection_types(span, &[ty.to_owned(), other.to_owned()], Default::default())?; - if let Some(tp) = result { - new_types.push(tp); - } - } - } - (Type::Intersection(Intersection { types, .. }), other) | (other, Type::Intersection(Intersection { types, .. })) => { - let mut temp_vec = vec![]; - temp_vec.append(&mut types.to_owned()); - temp_vec.push(other.to_owned()); - - acc_type = Type::new_intersection(span, temp_vec).freezed(); - continue; - } - (other, another) => { - acc_type = Type::new_intersection(span, vec![other.to_owned(), another.to_owned()]).freezed(); - continue; - } - }; - - new_types.retain(|ty| !ty.is_never()); - acc_type = if new_types.is_empty() { - return never!(); - } else if new_types.len() == 1 { - if let Some(ty) = new_types.pop() { - ty - } else { - return never!(); - } - } else { - Type::new_union(span, new_types).freezed() - } - } - if let Type::Union(Union { types: u_types, .. }) = acc_type.normalize() { - if normalized_len < u_types.len() { - return Ok(Some( - Type::Intersection(Intersection { - span, - types: normalized_types, - metadata: Default::default(), - tracker: Default::default(), - }) - .freezed(), - )); - } - } - Ok(Some(acc_type)) - } - } - - fn normalize_intersection_of_type_elements( - &mut self, - span: Span, - elements: &[TypeElement], - property_types: &mut Vec, - opts: NormalizeTypeOpts, - ) -> VResult> { - macro_rules! never { - () => {{ - Ok(Some(Type::Keyword(KeywordType { - span, - kind: TsKeywordTypeKind::TsNeverKeyword, - metadata: KeywordTypeMetadata { ..Default::default() }, - tracker: Default::default(), - }))) - }}; - } - - // Intersect property types - 'outer: for e in elements.iter() { - if let TypeElement::Property(p) = e { - for prev in property_types.iter_mut() { - if let TypeElement::Property(prev) = prev { - if prev.key.type_eq(&p.key) { - let prev_type = prev - .type_ann - .clone() - .map(|v| *v) - .unwrap_or_else(|| Type::any(span, KeywordTypeMetadata { ..Default::default() })); - let other = p - .type_ann - .clone() - .map(|v| *v) - .unwrap_or_else(|| Type::any(span, KeywordTypeMetadata { ..Default::default() })); - - let new = self.normalize_intersection_types(span, &[prev_type, other], opts)?; - - if let Some(new) = new { - if new.is_never() { - return never!(); - } - prev.type_ann = Some(Box::new(new)); - continue 'outer; - } - } - } - } - } - - property_types.push(e.clone()); - } - - Ok(None) - } - // This is part of normalization. fn instantiate_for_normalization(&mut self, span: Option, ty: &Type, opts: NormalizeTypeOpts) -> VResult { let _tracing = if cfg!(debug_assertions) { From 174627d58d3cb2d201dfc90ddc84166d70683d7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=98=A4=EB=B3=91=EC=A7=84?= <64676070+sunrabbit123@users.noreply.github.com> Date: Mon, 2 Oct 2023 12:16:49 +0900 Subject: [PATCH 33/40] fix: Freeze the return value of `access_property` (#1094) --- .../src/analyzer/expr/mod.rs | 2 + ...checkJsxChildrenProperty16.error-diff.json | 24 ++++++++++++ ...heckJsxChildrenProperty16.stats.rust-debug | 4 +- ...toryDeclarationsLocalTypes.error-diff.json | 37 +++++++++++++++++++ ...oryDeclarationsLocalTypes.stats.rust-debug | 4 +- .../tests/tsc-stats.rust-debug | 4 +- 6 files changed, 69 insertions(+), 6 deletions(-) create mode 100644 crates/stc_ts_type_checker/tests/conformance/jsx/checkJsxChildrenProperty16.error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/jsx/inline/inlineJsxFactoryDeclarationsLocalTypes.error-diff.json diff --git a/crates/stc_ts_file_analyzer/src/analyzer/expr/mod.rs b/crates/stc_ts_file_analyzer/src/analyzer/expr/mod.rs index 0e93f2e255..4c30da014b 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/expr/mod.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/expr/mod.rs @@ -1381,6 +1381,8 @@ impl Analyzer<'_, '_> { ty.reposition(span); } + ty.freeze(); + Ok(ty) } diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/checkJsxChildrenProperty16.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/jsx/checkJsxChildrenProperty16.error-diff.json new file mode 100644 index 0000000000..63fdeaa49b --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/checkJsxChildrenProperty16.error-diff.json @@ -0,0 +1,24 @@ +{ + "required_errors": {}, + "required_error_lines": {}, + "extra_errors": { + "TS2307": 2, + "TS2503": 1, + "TS7005": 4 + }, + "extra_error_lines": { + "TS2307": [ + 9, + 9 + ], + "TS2503": [ + 18 + ], + "TS7005": [ + 23, + 24, + 26, + 27 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/checkJsxChildrenProperty16.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/jsx/checkJsxChildrenProperty16.stats.rust-debug index 27ba984132..776a9ce8bf 100644 --- a/crates/stc_ts_type_checker/tests/conformance/jsx/checkJsxChildrenProperty16.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/checkJsxChildrenProperty16.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 0, - panic: 1, + extra_error: 7, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/inline/inlineJsxFactoryDeclarationsLocalTypes.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/jsx/inline/inlineJsxFactoryDeclarationsLocalTypes.error-diff.json new file mode 100644 index 0000000000..d8ebfd5c7f --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/inline/inlineJsxFactoryDeclarationsLocalTypes.error-diff.json @@ -0,0 +1,37 @@ +{ + "required_errors": { + "TS2609": 1, + "TS2532": 1, + "TS2322": 5, + "TS2786": 3 + }, + "required_error_lines": { + "TS2609": [ + 4 + ], + "TS2532": [ + 4 + ], + "TS2322": [ + 5, + 21, + 21, + 24, + 24 + ], + "TS2786": [ + 21, + 21, + 21 + ] + }, + "extra_errors": { + "TS2420": 2 + }, + "extra_error_lines": { + "TS2420": [ + 6, + 6 + ] + } +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/jsx/inline/inlineJsxFactoryDeclarationsLocalTypes.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/jsx/inline/inlineJsxFactoryDeclarationsLocalTypes.stats.rust-debug index 283109c18e..9f05f46950 100644 --- a/crates/stc_ts_type_checker/tests/conformance/jsx/inline/inlineJsxFactoryDeclarationsLocalTypes.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/jsx/inline/inlineJsxFactoryDeclarationsLocalTypes.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 10, matched_error: 0, - extra_error: 0, - panic: 1, + extra_error: 2, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug index 1d562f009c..546781f2ef 100644 --- a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 2869, matched_error: 7166, - extra_error: 1098, - panic: 6, + extra_error: 1107, + panic: 4, } \ No newline at end of file From 796da7dc81438ef92737a4317c4c70bae296f81c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=98=A4=EB=B3=91=EC=A7=84?= <64676070+sunrabbit123@users.noreply.github.com> Date: Mon, 2 Oct 2023 15:14:09 +0900 Subject: [PATCH 34/40] feat: Resolve private names and property signatures (#1093) --- crates/stc_ts_errors/src/lib.rs | 8 +++ .../src/analyzer/convert/mod.rs | 62 ++++++++++++------- .../tests/conformance.pass.txt | 1 + ...eNameAndPropertySignature.stats.rust-debug | 6 +- .../tests/tsc-stats.rust-debug | 6 +- 5 files changed, 55 insertions(+), 28 deletions(-) diff --git a/crates/stc_ts_errors/src/lib.rs b/crates/stc_ts_errors/src/lib.rs index 9d8087a4d2..538f8cb25a 100644 --- a/crates/stc_ts_errors/src/lib.rs +++ b/crates/stc_ts_errors/src/lib.rs @@ -1594,6 +1594,11 @@ pub enum ErrorKind { CannotBeUsedToIndexType { span: Span, }, + + // TS18016 + PrivateIdentifiersAreNotAllowedOutsideClassBodies { + span: Span, + }, } #[cfg(target_pointer_width = "64")] @@ -2209,6 +2214,9 @@ impl ErrorKind { ErrorKind::ImportFailed { .. } => 2305, ErrorKind::CannotBeUsedToIndexType { .. } => 2536, + + ErrorKind::PrivateIdentifiersAreNotAllowedOutsideClassBodies { .. } => 18016, + _ => 0, } } diff --git a/crates/stc_ts_file_analyzer/src/analyzer/convert/mod.rs b/crates/stc_ts_file_analyzer/src/analyzer/convert/mod.rs index db0b0ca084..ad67a63839 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/convert/mod.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/convert/mod.rs @@ -1219,31 +1219,49 @@ impl Analyzer<'_, '_> { let mut prev_keys: Vec> = vec![]; for elem in elems { - if let TypeElement::Property(PropertySignature { - accessor: - Accessor { - getter: false, - setter: false, - .. - }, - .. - }) = elem - { - if let Some(key) = elem.key() { - let key = key.normalize(); - let key_ty = key.ty(); - - if key_ty.is_symbol() { - continue; + match elem { + TypeElement::Method(MethodSignature { .. }) => { + if let Some(key) = elem.key() { + if key.is_private() && !self.ctx.in_class_member { + self.storage + .report(ErrorKind::PrivateIdentifiersAreNotAllowedOutsideClassBodies { span: key.span() }.into()); + continue; + } } - if let Some(prev) = prev_keys.iter().find(|prev_key| key.type_eq(prev_key)) { - self.storage - .report(ErrorKind::DuplicateNameWithoutName { span: prev.span() }.into()); - self.storage.report(ErrorKind::DuplicateNameWithoutName { span: key.span() }.into()); - } else { - prev_keys.push(key); + } + TypeElement::Property(PropertySignature { + accessor: + Accessor { + getter: false, + setter: false, + .. + }, + .. + }) => { + if let Some(key) = elem.key() { + if key.is_private() && !self.ctx.in_class_member { + self.storage + .report(ErrorKind::PrivateIdentifiersAreNotAllowedOutsideClassBodies { span: key.span() }.into()); + continue; + } + // if key.ty() call PrivateKey, cause unimplemented panic + + let key = key.normalize(); + let key_ty = key.ty(); + + if key_ty.is_symbol() { + continue; + } + if let Some(prev) = prev_keys.iter().find(|prev_key| key.type_eq(prev_key)) { + self.storage + .report(ErrorKind::DuplicateNameWithoutName { span: prev.span() }.into()); + self.storage.report(ErrorKind::DuplicateNameWithoutName { span: key.span() }.into()); + } else { + prev_keys.push(key); + } } } + _ => {} } } } diff --git a/crates/stc_ts_type_checker/tests/conformance.pass.txt b/crates/stc_ts_type_checker/tests/conformance.pass.txt index 03eb15c6a1..e438f4eba6 100644 --- a/crates/stc_ts_type_checker/tests/conformance.pass.txt +++ b/crates/stc_ts_type_checker/tests/conformance.pass.txt @@ -242,6 +242,7 @@ classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers9.ts classes/members/instanceAndStaticMembers/typeOfThisInstanceMemberNarrowedWithLoopAntecedent.ts classes/members/privateNames/privateNameAccessorsCallExpression.ts classes/members/privateNames/privateNameAmbientNoImplicitAny.ts +classes/members/privateNames/privateNameAndPropertySignature.ts classes/members/privateNames/privateNameAndStaticInitializer.ts classes/members/privateNames/privateNameClassExpressionLoop.ts classes/members/privateNames/privateNameComputedPropertyName1.ts diff --git a/crates/stc_ts_type_checker/tests/conformance/classes/members/privateNames/privateNameAndPropertySignature.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/classes/members/privateNames/privateNameAndPropertySignature.stats.rust-debug index 8c5fd24c0e..64de089899 100644 --- a/crates/stc_ts_type_checker/tests/conformance/classes/members/privateNames/privateNameAndPropertySignature.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/classes/members/privateNames/privateNameAndPropertySignature.stats.rust-debug @@ -1,6 +1,6 @@ Stats { - required_error: 9, - matched_error: 0, + required_error: 0, + matched_error: 9, extra_error: 0, - panic: 1, + panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug index 546781f2ef..83979399ee 100644 --- a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug @@ -1,6 +1,6 @@ Stats { - required_error: 2869, - matched_error: 7166, + required_error: 2860, + matched_error: 7175, extra_error: 1107, - panic: 4, + panic: 3, } \ No newline at end of file From 105ff10bc9919857f1c18a30547a2d46ac2dfdbe Mon Sep 17 00:00:00 2001 From: Simon Buchan Date: Thu, 5 Oct 2023 14:46:18 +1300 Subject: [PATCH 35/40] chore: Update rust-toolchain to `nightly-2023-10-04` (#1095) --- Cargo.lock | 4 ++-- Cargo.toml | 1 + crates/stc_ts_builtin_macro/src/lib.rs | 10 +++++----- crates/stc_ts_errors/src/lib.rs | 2 +- .../src/analyzer/assign/function.rs | 4 +--- crates/stc_ts_file_analyzer/src/analyzer/assign/tpl.rs | 1 + .../stc_ts_file_analyzer/src/analyzer/expr/call_new.rs | 3 ++- .../stc_ts_file_analyzer/src/analyzer/function/mod.rs | 6 +----- .../src/analyzer/generic/inference.rs | 10 +++++----- .../stc_ts_file_analyzer/src/analyzer/generic/mod.rs | 5 +---- .../stc_ts_file_analyzer/src/analyzer/relation/mod.rs | 1 + .../stc_ts_file_analyzer/src/analyzer/types/keyof.rs | 2 +- crates/stc_ts_file_analyzer/src/type_facts.rs | 10 +++++----- crates/stc_ts_file_analyzer/src/util/graph.rs | 4 ++-- crates/stc_ts_type_checker/tests/tsc.rs | 1 - rust-toolchain | 2 +- 16 files changed, 30 insertions(+), 36 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cfc9616618..f349ba0326 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1678,9 +1678,9 @@ checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" [[package]] name = "proc-macro2" -version = "1.0.59" +version = "1.0.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6aeca18b86b413c660b781aa319e4e2648a3e6f9eadc9b47e9038e6fe9f3451b" +checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328" dependencies = [ "unicode-ident", ] diff --git a/Cargo.toml b/Cargo.toml index ebc5582bac..c6651ed34e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,6 @@ [workspace] members = ["crates/stc", "crates/binding_wasm"] +resolver = "2" [profile.release] lto = "off" diff --git a/crates/stc_ts_builtin_macro/src/lib.rs b/crates/stc_ts_builtin_macro/src/lib.rs index f931ce8dad..c1aaf002be 100644 --- a/crates/stc_ts_builtin_macro/src/lib.rs +++ b/crates/stc_ts_builtin_macro/src/lib.rs @@ -5,12 +5,12 @@ #[macro_use] extern crate pmutil; -use std::{collections::HashMap, fs::read_dir, path::Path, sync::Arc}; +use std::{collections::HashMap, env, fs::read_dir, path::Path}; use inflector::Inflector; use pmutil::Quote; use proc_macro2::Span; -use swc_common::{comments::SingleThreadedComments, FilePathMapping, SourceMap}; +use swc_common::{comments::SingleThreadedComments, sync::Lrc, FilePathMapping, SourceMap}; use swc_ecma_parser::{lexer::Lexer, Parser, StringInput, Syntax, TsConfig}; use swc_macros_common::{call_site, print}; use syn::{punctuated::Punctuated, Token}; @@ -18,7 +18,7 @@ use syn::{punctuated::Punctuated, Token}; #[proc_macro] pub fn builtin(_: proc_macro::TokenStream) -> proc_macro::TokenStream { swc_common::GLOBALS.set(&swc_common::Globals::new(), || { - let cm = Arc::new(SourceMap::new(FilePathMapping::empty())); + let cm = Lrc::new(SourceMap::new(FilePathMapping::empty())); let mut deps = HashMap::>::default(); @@ -37,11 +37,11 @@ pub fn builtin(_: proc_macro::TokenStream) -> proc_macro::TokenStream { let mut contents = HashMap::::default(); - let dir_str = ::std::env::var("CARGO_MANIFEST_DIR").expect("failed to read CARGO_MANIFEST_DIR"); + let dir_str = env::var("CARGO_MANIFEST_DIR").expect("failed to read CARGO_MANIFEST_DIR"); let dir = Path::new(&dir_str).join("lib"); let mut tokens = q(); - let mut files = read_dir(&dir) + let mut files = read_dir(dir) .expect("failed to read $CARGO_MANIFEST_DIR/lib") .filter_map(|entry| { let entry = entry.expect("failed to read file of directory"); diff --git a/crates/stc_ts_errors/src/lib.rs b/crates/stc_ts_errors/src/lib.rs index 538f8cb25a..6a649da3ad 100644 --- a/crates/stc_ts_errors/src/lib.rs +++ b/crates/stc_ts_errors/src/lib.rs @@ -62,7 +62,7 @@ impl From for Error { impl Error { #[track_caller] pub fn context(self, context: impl Display) -> Error { - return self.context_impl(Location::caller(), context); + self.context_impl(Location::caller(), context) } #[cfg_attr(not(debug_assertions), inline(always))] diff --git a/crates/stc_ts_file_analyzer/src/analyzer/assign/function.rs b/crates/stc_ts_file_analyzer/src/analyzer/assign/function.rs index fe0285e131..f988aaae3c 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/assign/function.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/assign/function.rs @@ -903,9 +903,7 @@ impl Analyzer<'_, '_> { let l = li.next(); let r = ri.next(); - let (Some(l), Some(r)) = (l, r) else { - break - }; + let (Some(l), Some(r)) = (l, r) else { break }; // TODO(kdy1): What should we do? if opts.allow_assignment_to_param { diff --git a/crates/stc_ts_file_analyzer/src/analyzer/assign/tpl.rs b/crates/stc_ts_file_analyzer/src/analyzer/assign/tpl.rs index c067241822..014d41ec24 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/assign/tpl.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/assign/tpl.rs @@ -27,6 +27,7 @@ impl Analyzer<'_, '_> { /// orders. /// /// After splitting, we can check if each element is assignable. + #[allow(clippy::needless_pass_by_ref_mut)] pub(crate) fn assign_to_tpl(&mut self, data: &mut AssignData, l: &TplType, r_ty: &Type, opts: AssignOpts) -> VResult<()> { let span = opts.span; let r_ty = r_ty.normalize(); diff --git a/crates/stc_ts_file_analyzer/src/analyzer/expr/call_new.rs b/crates/stc_ts_file_analyzer/src/analyzer/expr/call_new.rs index 0aacaa2b03..ba57f513ef 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/expr/call_new.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/expr/call_new.rs @@ -527,8 +527,8 @@ impl Analyzer<'_, '_> { let types = u .types .iter() - .cloned() .filter(|callee| !matches!(callee.normalize(), Type::Module(..) | Type::Namespace(..))) + .cloned() .collect::>(); match types.len() { @@ -3458,6 +3458,7 @@ impl Analyzer<'_, '_> { /// /// should make type of `subscriber` `SafeSubscriber`, not `Subscriber`. /// I (kdy1) don't know why. + #[allow(clippy::needless_pass_by_ref_mut)] fn add_call_facts(&mut self, params: &[FnParam], args: &[RExprOrSpread], ret_ty: &mut Type) { if !self.ctx.in_cond { return; diff --git a/crates/stc_ts_file_analyzer/src/analyzer/function/mod.rs b/crates/stc_ts_file_analyzer/src/analyzer/function/mod.rs index 7f215f3a10..74b845aee3 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/function/mod.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/function/mod.rs @@ -348,11 +348,7 @@ impl Analyzer<'_, '_> { // true, // // Allow overriding // true, - // ) { - // Ok(()) => {} - // Err(err) => { - // self.storage.report(err); - // } + // ) { Ok(()) => {} Err(err) => { self.storage.report(err); } // } // } diff --git a/crates/stc_ts_file_analyzer/src/analyzer/generic/inference.rs b/crates/stc_ts_file_analyzer/src/analyzer/generic/inference.rs index ed0aea16cc..2e3d7f63ac 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/generic/inference.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/generic/inference.rs @@ -116,8 +116,8 @@ pub(crate) struct InferTypeOpts { } bitflags! { + #[derive(Default)] pub struct InferencePriority: i32 { - const None = 0; /// Naked type variable in union or intersection type const NakedTypeVariable = 1 << 0; /// Speculative tuple inference @@ -153,10 +153,10 @@ bitflags! { } } -impl Default for InferencePriority { - fn default() -> Self { - Self::None - } +impl InferencePriority { + // Defining outside bitflags! to avoid clippy::bad_bit_mask lint in generated + // code. + pub const None: Self = Self::empty(); } impl Analyzer<'_, '_> { diff --git a/crates/stc_ts_file_analyzer/src/analyzer/generic/mod.rs b/crates/stc_ts_file_analyzer/src/analyzer/generic/mod.rs index 3e4309432e..41e306ac24 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/generic/mod.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/generic/mod.rs @@ -111,10 +111,7 @@ impl Analyzer<'_, '_> { #[cfg(debug_assertions)] let _tracing = dev_span!("infer_arg_types"); - warn!( - "infer_arg_types: {:?}", - type_params.iter().map(|p| format!("{}, ", p.name)).collect::() - ); + warn!("infer_arg_types: {:?}", type_params.iter().map(|p| &p.name).join(", ")); let timer = PerfTimer::noop(); diff --git a/crates/stc_ts_file_analyzer/src/analyzer/relation/mod.rs b/crates/stc_ts_file_analyzer/src/analyzer/relation/mod.rs index 9e4dd333f6..59bb61bf45 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/relation/mod.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/relation/mod.rs @@ -25,6 +25,7 @@ impl Analyzer<'_, '_> { self.is_type_related_to_inner(&mut data, source, target, relation) } + #[allow(clippy::needless_pass_by_ref_mut)] fn is_type_related_to_inner(&mut self, data: &mut IsRelatedData, source: &Type, target: &Type, relation: Relation) -> bool { if source.type_eq(target) { return true; diff --git a/crates/stc_ts_file_analyzer/src/analyzer/types/keyof.rs b/crates/stc_ts_file_analyzer/src/analyzer/types/keyof.rs index d43a378a89..2c60f0e9e7 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/types/keyof.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/types/keyof.rs @@ -333,7 +333,7 @@ impl Analyzer<'_, '_> { } } Type::EnumVariant(e) => { - if matches!(e.name, None) && (e.def.has_num || e.def.has_str) { + if e.name.is_none() && (e.def.has_num || e.def.has_str) { return self.keyof( span, &if e.def.has_num && e.def.has_str { diff --git a/crates/stc_ts_file_analyzer/src/type_facts.rs b/crates/stc_ts_file_analyzer/src/type_facts.rs index 1b36415de9..0fed6457cb 100644 --- a/crates/stc_ts_file_analyzer/src/type_facts.rs +++ b/crates/stc_ts_file_analyzer/src/type_facts.rs @@ -3,15 +3,15 @@ use bitflags::bitflags; use swc_common::add_bitflags; -impl Default for TypeFacts { - fn default() -> Self { - Self::None - } +impl TypeFacts { + // Defining outside bitflags! to avoid clippy::bad_bit_mask lint in generated + // code. + pub const None: Self = Self::empty(); } bitflags! { + #[derive(Default)] pub struct TypeFacts: u32 { - const None = 0; /// typeof x === "string" const TypeofEQString = 1 << 0; /// typeof x === "number" diff --git a/crates/stc_ts_file_analyzer/src/util/graph.rs b/crates/stc_ts_file_analyzer/src/util/graph.rs index c504ffcd57..b31924109e 100644 --- a/crates/stc_ts_file_analyzer/src/util/graph.rs +++ b/crates/stc_ts_file_analyzer/src/util/graph.rs @@ -41,7 +41,7 @@ pub(crate) struct NodeId(usize, PhantomData); impl Clone for NodeId { fn clone(&self) -> Self { - NodeId(self.0, self.1) + *self } } @@ -57,7 +57,7 @@ impl Eq for NodeId {} impl PartialOrd for NodeId { fn partial_cmp(&self, other: &Self) -> Option { - self.0.partial_cmp(&other.0) + Some(self.cmp(other)) } } diff --git a/crates/stc_ts_type_checker/tests/tsc.rs b/crates/stc_ts_type_checker/tests/tsc.rs index b67662be5a..e5fa2221ee 100644 --- a/crates/stc_ts_type_checker/tests/tsc.rs +++ b/crates/stc_ts_type_checker/tests/tsc.rs @@ -312,7 +312,6 @@ fn do_test(file_name: &Path, spec: TestSpec, use_target: bool) -> Result<(), Std if is_file_similar(err.file.as_deref(), Some(last)) { // If this is the last file, we have to shift the errors. err.line += err_shift_n; - } else { } } else { // If sub files is empty, it means that it's a single-file test, and diff --git a/rust-toolchain b/rust-toolchain index 79183b3f54..a4a1687774 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2023-05-25 \ No newline at end of file +nightly-2023-10-04 \ No newline at end of file From bec48cea793b2056f1335da9f2a76d1f988417da Mon Sep 17 00:00:00 2001 From: AcrylicShrimp Date: Fri, 6 Oct 2023 15:01:15 +0900 Subject: [PATCH 36/40] feat: Add wasm support for playground (#1082) **Description:** This PR implements checker behaviors for `wasm` binding. By supporting wasm, implementing playground will become very easy. I also implemented PoC of playground and it works well. I'll contribute on that when this PR is ready and merged. Due to the constraints of wasm, there is a few APIs that should not be used. Below is the list. - `std::time::Instant` - `mimalloc_rust` from `swc_node_base` - All file-system related APIs. We dropped some code to avoid use of the APIs, and this PR contains those changes. I marked this PR as draft; we have to manage them somehow before merge it. **Related issue:** - #300 - #1021 --- Cargo.lock | 149 +++++++++---------------- crates/binding_wasm/Cargo.toml | 12 ++ crates/binding_wasm/src/lib.rs | 145 +++++++++++++++++++++++- crates/stc/Cargo.toml | 1 - crates/stc/src/main.rs | 2 - crates/stc_ts_file_analyzer/src/env.rs | 1 + crates/stc_utils/Cargo.toml | 1 - crates/stc_utils/src/lib.rs | 3 - cspell.json | 3 +- 9 files changed, 209 insertions(+), 108 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f349ba0326..eb8becddc5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -183,7 +183,7 @@ checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.31", ] [[package]] @@ -254,6 +254,20 @@ dependencies = [ [[package]] name = "binding_wasm" version = "0.1.0" +dependencies = [ + "anyhow", + "serde", + "serde-wasm-bindgen", + "stc_ts_env", + "stc_ts_errors", + "stc_ts_file_analyzer", + "stc_ts_type_checker", + "swc_common", + "swc_ecma_ast", + "swc_ecma_loader", + "swc_ecma_parser", + "wasm-bindgen", +] [[package]] name = "bitflags" @@ -361,7 +375,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.31", ] [[package]] @@ -506,12 +520,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "cty" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35" - [[package]] name = "darling" version = "0.13.4" @@ -693,12 +701,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "fs_extra" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" - [[package]] name = "fuchsia-cprng" version = "0.1.1" @@ -761,7 +763,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.31", ] [[package]] @@ -1295,26 +1297,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "mimalloc-rust" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5eb726c8298efb4010b2c46d8050e4be36cf807b9d9e98cb112f830914fc9bbe" -dependencies = [ - "cty", - "mimalloc-rust-sys", -] - -[[package]] -name = "mimalloc-rust-sys" -version = "1.7.9-source" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6413e13241a9809f291568133eca6694572cf528c1a6175502d090adce5dd5db" -dependencies = [ - "cc", - "cty", -] - [[package]] name = "miniz_oxide" version = "0.6.2" @@ -1596,7 +1578,7 @@ checksum = "39407670928234ebc5e6e580247dd567ad73a3578460c5990f9503df207e8f07" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.31", ] [[package]] @@ -2007,29 +1989,40 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.163" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2113ab51b87a539ae008b5c6c02dc020ffa39afd2d83cffcb3f4eb2722cebec2" +checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" dependencies = [ "serde_derive", ] +[[package]] +name = "serde-wasm-bindgen" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3b143e2833c57ab9ad3ea280d21fd34e285a42837aeb0ee301f4f41890fa00e" +dependencies = [ + "js-sys", + "serde", + "wasm-bindgen", +] + [[package]] name = "serde_derive" -version = "1.0.163" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c805777e3930c8883389c602315a24224bcc738b63905ef87cd1420353ea93e" +checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.31", ] [[package]] name = "serde_json" -version = "1.0.96" +version = "1.0.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" +checksum = "693151e1ac27563d6dbcec9dee9fbd5da8539b20fa14ad3752b2e6d363ace360" dependencies = [ "itoa", "ryu", @@ -2044,7 +2037,7 @@ checksum = "bcec881020c684085e55a25f7fd888954d56609ef363479dc5a1305eb0d40cab" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.31", ] [[package]] @@ -2173,7 +2166,6 @@ dependencies = [ "swc_common", "swc_ecma_ast", "swc_ecma_parser", - "swc_node_base", "tokio", "tracing", "tracing-subscriber 0.2.25", @@ -2741,7 +2733,6 @@ dependencies = [ "rustc-hash", "scoped-tls", "swc_common", - "swc_node_base", "tracing", ] @@ -3099,16 +3090,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "swc_node_base" -version = "0.5.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6065892f97ac3f42280d0f3eadc351aeff552e8de4d459604bcd9c56eb799ade" -dependencies = [ - "mimalloc-rust", - "tikv-jemallocator", -] - [[package]] name = "swc_visit" version = "0.5.6" @@ -3146,9 +3127,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.18" +version = "2.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32d41677bcbe24c20c52e7c70b0d8db04134c5d1066bf98662e2871ad200ea3e" +checksum = "718fa2415bcb8d8bd775917a1bf12a7931b6dfa890753378538118181e0cb398" dependencies = [ "proc-macro2", "quote", @@ -3248,7 +3229,7 @@ checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.31", ] [[package]] @@ -3283,27 +3264,6 @@ dependencies = [ "threadpool", ] -[[package]] -name = "tikv-jemalloc-sys" -version = "0.4.3+5.2.1-patched.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1792ccb507d955b46af42c123ea8863668fae24d03721e40cad6a41773dbb49" -dependencies = [ - "cc", - "fs_extra", - "libc", -] - -[[package]] -name = "tikv-jemallocator" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5b7bcecfafe4998587d636f9ae9d55eb9d0499877b88757767c346875067098" -dependencies = [ - "libc", - "tikv-jemalloc-sys", -] - [[package]] name = "tiny-keccak" version = "2.0.2" @@ -3353,7 +3313,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.31", ] [[package]] @@ -3450,7 +3410,7 @@ checksum = "0f57e3ca2a01450b1a921183a9c9cbfda207fd822cef4ccb00a65402cbba7a74" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.31", ] [[package]] @@ -3663,34 +3623,35 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.86" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bba0e8cb82ba49ff4e229459ff22a191bbe9a1cb3a341610c9c33efc27ddf73" +checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" dependencies = [ "cfg-if 1.0.0", + "serde", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.86" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19b04bc93f9d6bdee709f6bd2118f57dd6679cf1176a1af464fca3ab0d66d8fb" +checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.31", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.86" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14d6b024f1a526bb0234f52840389927257beb670610081360e5a03c5df9c258" +checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3698,22 +3659,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.86" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e128beba882dd1eb6200e1dc92ae6c5dbaa4311aa7bb211ca035779e5efc39f8" +checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.31", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.86" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed9d5b4305409d1fc9482fee2d7f9bcbf24b3972bf59817ef757e23982242a93" +checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" [[package]] name = "winapi" diff --git a/crates/binding_wasm/Cargo.toml b/crates/binding_wasm/Cargo.toml index c1aad7e3bd..0a8c6835e1 100644 --- a/crates/binding_wasm/Cargo.toml +++ b/crates/binding_wasm/Cargo.toml @@ -8,3 +8,15 @@ edition = "2021" crate-type = ["cdylib", "rlib"] [dependencies] +anyhow = "1" +serde = { version = "1.0", features = ["derive"] } +serde-wasm-bindgen = "0.5" +wasm-bindgen = { version = "0.2.87", features = ["serde"] } +stc_ts_env = { path = "../stc_ts_env" } +stc_ts_errors = { path = "../stc_ts_errors" } +stc_ts_file_analyzer = { path = "../stc_ts_file_analyzer" } +stc_ts_type_checker = { path = "../stc_ts_type_checker" } +swc_common = { version = "0.29.37", features = ["tty-emitter"] } +swc_ecma_ast = "0.100.2" +swc_ecma_loader = "0.41.39" +swc_ecma_parser = "0.130.5" diff --git a/crates/binding_wasm/src/lib.rs b/crates/binding_wasm/src/lib.rs index 7d12d9af81..66a2832861 100644 --- a/crates/binding_wasm/src/lib.rs +++ b/crates/binding_wasm/src/lib.rs @@ -1,14 +1,147 @@ -pub fn add(left: usize, right: usize) -> usize { - left + right +use std::{ + path::PathBuf, + str::FromStr, + sync::{Arc, Mutex}, +}; + +use anyhow::{anyhow, Result}; +use serde::{Deserialize, Serialize}; +use stc_ts_env::{BuiltIn, Env, ModuleConfig, Rule, StableEnv}; +use stc_ts_type_checker::{ + loader::{LoadFile, ModuleLoader}, + Checker, +}; +use swc_common::{ + errors::{EmitterWriter, Handler}, + FileName, Globals, SourceFile, SourceMap, GLOBALS, +}; +use swc_ecma_ast::EsVersion; +use swc_ecma_loader::resolve::Resolve; +use swc_ecma_parser::Syntax; + +const ENTRY_FILENAME: &str = "binding-wasm-entry-module"; + +#[cfg(target_arch = "wasm32")] +type Out = wasm_bindgen::JsValue; +#[cfg(not(target_arch = "wasm32"))] +type Out = CheckAndAnnotateOutput; + +#[cfg_attr(target_arch = "wasm32", wasm_bindgen::prelude::wasm_bindgen)] +pub fn check_and_annotate_types(src: &str) -> Out { + let globals = Arc::::default(); + let cm = Arc::new(SourceMap::default()); + let buf = Arc::new(Mutex::new(Vec::new())); + let env = GLOBALS.set(&globals, || { + Env::new( + StableEnv::new(), + Rule { ..Default::default() }, + EsVersion::latest(), + ModuleConfig::None, + Arc::new(BuiltIn::default()), + ) + }); + let emitter = Box::new(EmitterWriter::new( + Box::new(PassThroughWriter { buf: buf.clone() }), + Some(cm.clone()), + false, + false, + )); + let handler = { Arc::new(Handler::with_emitter(true, false, emitter)) }; + let (types, errors) = GLOBALS.set(&globals, || { + let loader = SingleEntryLoader::new(cm.as_ref(), src); + let mut checker = Checker::new( + cm.clone(), + handler.clone(), + env.clone(), + None, + Box::new(ModuleLoader::new(cm, env, VoidResolver, loader)), + ); + + let entry_module = checker.check(Arc::new(FileName::Real(PathBuf::from_str(ENTRY_FILENAME).unwrap()))); + let types = checker.get_types(entry_module); + + (types, checker.take_errors()) + }); + let _types = types.map(|types| format!("{:?}", types)).unwrap_or_else(|| "".to_owned()); + + for err in &errors { + err.emit(&handler); + } + + let out = CheckAndAnnotateOutput { + error: String::from_utf8_lossy(&buf.lock().unwrap()).into_owned(), + }; + + #[cfg(target_arch = "wasm32")] + { + serde_wasm_bindgen::to_value(&out).unwrap() + } + + #[cfg(not(target_arch = "wasm32"))] + { + out + } +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct CheckAndAnnotateOutput { + error: String, +} + +pub struct PassThroughWriter { + pub buf: Arc>>, +} + +impl std::io::Write for PassThroughWriter { + fn write(&mut self, buf: &[u8]) -> std::io::Result { + self.buf.lock().unwrap().write(buf) + } + + fn flush(&mut self) -> std::io::Result<()> { + self.buf.lock().unwrap().flush() + } +} + +pub struct VoidResolver; + +impl Resolve for VoidResolver { + fn resolve(&self, base: &FileName, _module_specifier: &str) -> std::result::Result { + if base != &FileName::Real(PathBuf::from_str(ENTRY_FILENAME).unwrap()) { + return Err(anyhow!("you cannot load any module")); + } + + Ok(base.clone()) + } +} + +pub struct SingleEntryLoader { + src: Arc, +} + +impl SingleEntryLoader { + pub fn new(source_map: &SourceMap, source: impl Into) -> Self { + Self { + src: source_map.new_source_file(FileName::Real(PathBuf::from_str(ENTRY_FILENAME).unwrap()), source.into()), + } + } +} + +impl LoadFile for SingleEntryLoader { + fn load_file(&self, _cm: &Arc, filename: &Arc) -> Result<(Arc, Syntax)> { + if filename.as_ref() != &FileName::Real(PathBuf::from_str(ENTRY_FILENAME).unwrap()) { + return Err(anyhow!("you cannot load any file")); + } + + Ok((self.src.clone(), Syntax::Typescript(Default::default()))) + } } #[cfg(test)] -mod tests { +mod test { use super::*; #[test] - fn it_works() { - let result = add(2, 2); - assert_eq!(result, 4); + fn it_should_be_called() { + println!("Error: {:#?}", check_and_annotate_types("export const a: string = 1;")); } } diff --git a/crates/stc/Cargo.toml b/crates/stc/Cargo.toml index 79bcc61f63..e5ce3264c0 100644 --- a/crates/stc/Cargo.toml +++ b/crates/stc/Cargo.toml @@ -28,7 +28,6 @@ stc_utils = { path = "../stc_utils" } swc_common = { version = "0.29.37", features = ["tty-emitter"] } swc_ecma_ast = "0.100.2" swc_ecma_parser = "0.130.5" -swc_node_base = "0.5.8" tokio = { version = "1.7.1", features = ["rt-multi-thread", "macros"] } tracing = { version = "0.1.37", features = ["release_max_level_off"] } tracing-subscriber = { version = "0.2.19", features = ["env-filter"] } diff --git a/crates/stc/src/main.rs b/crates/stc/src/main.rs index 0c026628d4..ee566792ed 100644 --- a/crates/stc/src/main.rs +++ b/crates/stc/src/main.rs @@ -1,5 +1,3 @@ -extern crate swc_node_base; - use std::{path::PathBuf, sync::Arc}; use anyhow::Error; diff --git a/crates/stc_ts_file_analyzer/src/env.rs b/crates/stc_ts_file_analyzer/src/env.rs index 5eeb37889f..4f42befd17 100644 --- a/crates/stc_ts_file_analyzer/src/env.rs +++ b/crates/stc_ts_file_analyzer/src/env.rs @@ -1,5 +1,6 @@ use std::{collections::hash_map::Entry, error::Error, path::Path, sync::Arc}; +// use std::time::Instant; use dashmap::DashMap; use once_cell::sync::{Lazy, OnceCell}; use rnode::{NodeIdGenerator, RNode, VisitWith}; diff --git a/crates/stc_utils/Cargo.toml b/crates/stc_utils/Cargo.toml index b2d311be79..2c5f013ac1 100644 --- a/crates/stc_utils/Cargo.toml +++ b/crates/stc_utils/Cargo.toml @@ -14,5 +14,4 @@ once_cell = "1" rustc-hash = "1.1.0" scoped-tls = "1.0.0" swc_common = { version = "0.29.37", features = ["concurrent", "tty-emitter"] } -swc_node_base = "0.5.8" tracing = "0.1.37" diff --git a/crates/stc_utils/src/lib.rs b/crates/stc_utils/src/lib.rs index d8436846c0..4f3c6d818d 100644 --- a/crates/stc_utils/src/lib.rs +++ b/crates/stc_utils/src/lib.rs @@ -1,8 +1,5 @@ #![feature(never_type)] -/// Use good memory allocator. -extern crate swc_node_base; - use std::{ collections::{HashMap, HashSet}, env, fmt, diff --git a/cspell.json b/cspell.json index 0b9c4d6769..72dd8d7e69 100644 --- a/cspell.json +++ b/cspell.json @@ -3,6 +3,7 @@ "ahash", "arity", "autocrlf", + "bindgen", "bitflags", "bitor", "bivariant", @@ -125,4 +126,4 @@ "scripts/npm", "**/stc_ts_testing/src/conformance.rs" ] -} \ No newline at end of file +} From 9e4c9b300e5e37311472d722b1c933a7ee4280dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=98=A4=EB=B3=91=EC=A7=84?= <64676070+sunrabbit123@users.noreply.github.com> Date: Wed, 11 Oct 2023 09:48:18 +0900 Subject: [PATCH 37/40] fix: Handle `module-not-found` error occurred while preparing module (#1098) --- .../stc_ts_file_analyzer/src/analyzer/import.rs | 11 +++++++++-- .../tests/conformance.pass.txt | 15 ++++++++++++++- ...ntOfExportNamespaceWithDefault.error-diff.json | 12 ------------ ...tOfExportNamespaceWithDefault.stats.rust-debug | 2 +- .../library-reference-1.error-diff.json | 12 ------------ .../library-reference-1.stats.rust-debug | 2 +- .../library-reference-3.error-diff.json | 12 ------------ .../library-reference-3.stats.rust-debug | 2 +- .../library-reference-4.error-diff.json | 14 -------------- .../library-reference-4.stats.rust-debug | 2 +- .../library-reference-5.error-diff.json | 12 ++---------- .../library-reference-5.stats.rust-debug | 2 +- .../library-reference-7.error-diff.json | 12 ------------ .../library-reference-7.stats.rust-debug | 2 +- .../library-reference-8.error-diff.json | 14 -------------- .../library-reference-8.stats.rust-debug | 2 +- ...rary-reference-scoped-packages.error-diff.json | 12 ------------ ...ary-reference-scoped-packages.stats.rust-debug | 2 +- .../import/importTypeAmbient.error-diff.json | 6 ------ .../import/importTypeAmbient.stats.rust-debug | 2 +- .../importTypeAmbientMissing.error-diff.json | 12 ++++++++++++ .../importTypeAmbientMissing.stats.rust-debug | 4 ++-- .../tests/tsc-stats.rust-debug | 6 +++--- 23 files changed, 51 insertions(+), 121 deletions(-) delete mode 100644 crates/stc_ts_type_checker/tests/conformance/externalModules/exportAssignmentOfExportNamespaceWithDefault.error-diff.json delete mode 100644 crates/stc_ts_type_checker/tests/conformance/references/library-reference-1.error-diff.json delete mode 100644 crates/stc_ts_type_checker/tests/conformance/references/library-reference-3.error-diff.json delete mode 100644 crates/stc_ts_type_checker/tests/conformance/references/library-reference-4.error-diff.json delete mode 100644 crates/stc_ts_type_checker/tests/conformance/references/library-reference-7.error-diff.json delete mode 100644 crates/stc_ts_type_checker/tests/conformance/references/library-reference-8.error-diff.json delete mode 100644 crates/stc_ts_type_checker/tests/conformance/references/library-reference-scoped-packages.error-diff.json create mode 100644 crates/stc_ts_type_checker/tests/conformance/types/import/importTypeAmbientMissing.error-diff.json diff --git a/crates/stc_ts_file_analyzer/src/analyzer/import.rs b/crates/stc_ts_file_analyzer/src/analyzer/import.rs index 4053cad760..c6bbb8be67 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/import.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/import.rs @@ -79,6 +79,11 @@ impl Analyzer<'_, '_> { if self.config.is_builtin { return; } + + #[inline] + fn is_relative_path(path: &str) -> bool { + path.starts_with("./") || path.starts_with("../") + } // We first load non-circular imports. let imports = ImportFinder::find_imports(&self.comments, module_spans, &self.storage, items); @@ -86,12 +91,14 @@ impl Analyzer<'_, '_> { let mut normal_imports = vec![]; for (ctxt, import) in imports { let span = import.span; - let base = self.storage.path(ctxt); let dep_id = self.loader.module_id(&base, &import.src); let dep_id = match dep_id { Some(v) => v, - None => { + _ if !is_relative_path(&import.src) => { + continue; + } + _ => { self.storage.report(ErrorKind::ModuleNotFound { span }.into()); continue; } diff --git a/crates/stc_ts_type_checker/tests/conformance.pass.txt b/crates/stc_ts_type_checker/tests/conformance.pass.txt index e438f4eba6..3b62640fe9 100644 --- a/crates/stc_ts_type_checker/tests/conformance.pass.txt +++ b/crates/stc_ts_type_checker/tests/conformance.pass.txt @@ -1016,10 +1016,14 @@ es6/spread/iteratorSpreadInCall2.ts es6/spread/iteratorSpreadInCall3.ts es6/spread/iteratorSpreadInCall4.ts es6/spread/iteratorSpreadInCall5.ts +es6/tedirectives/ts-expect-error-nocheck.ts +es6/templates/taggedTemplateStrindirectives/ts-expect-error-nocheck.ts es6/templates/taggedTemplateStringsPlainCharactersThatArePartsOfEscapes01.ts es6/templates/taggedTemplateStringsPlainCharactersThatArePartsOfEscapes01_ES6.ts es6/templates/taggedTemplateStringsPlainCharactersThatArePartsOfEscapes02.ts es6/templates/taggedTemplateStringsPlainCharactersThatArePartsOfEscapes02_ES6.ts +es6/templates/taggedTemplateStringsPlainCharactersThatArePartsOfEscapes02_ES6.tsdirectives/ts-expect-error-nocheck.ts +es6/templates/taggedTemplateStringsPlainCharactersThatArePartsOfEscapes02directives/ts-expect-error-nocheck.ts es6/templates/taggedTemplateStringsPldirectives/ts-expect-error-nocheck.ts es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts es6/templates/taggedTemplateStringsWithIncompatibleTypedTagsES6.ts @@ -1123,6 +1127,8 @@ es6/templates/templateStringWhitespaceEscapes2_ES6.ts es6/templates/templateStringWithBackslashEscapes01.ts es6/templates/templateStringWithBackslashEscapes01_ES6.ts es6/templates/templateStringWithCommentsInArrowFunction.ts +es6/templates/templateStringWithE +es6/templates/templateStringWithEdirectives/ts-expect-error-nocheck.ts es6/templates/templateStringWithEmbeddedAddition.ts es6/templates/templateStringWithEmbeddedAdditionES6.ts es6/templates/templateStringWithEmbeddedArray.ts @@ -1163,6 +1169,7 @@ es6/templates/templateStringWithEmptyLiteralPortions.ts es6/templates/templateStringWithEmptyLiteralPortionsES6.ts es6/templates/templateStringWithOpenCommentInStringPortion.ts es6/templates/templateStringWithOpenCommentInStringPortionES6.ts +es6/templates/templateStringWithPdirectives/ts-expect-error-nocheck.ts es6/templates/templateStringWithPropertyAccess.ts es6/templates/templateStringWithPropertyAccessES6.ts es6/templates/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts @@ -1683,6 +1690,7 @@ externalModules/exportAssignImportedIdentifier.ts externalModules/exportAssignTypes.ts externalModules/exportAssignmentAndDeclaration.ts externalModules/exportAssignmentGenericType.ts +externalModules/exportAssignmentOfExportNamespaceWithDefault.ts externalModules/exportAssignmentTopLevelIdentifier.ts externalModules/exportClassNameWithObjectAMD.ts externalModules/exportClassNameWithObjectCommonJS.ts @@ -2199,8 +2207,14 @@ parser/ecmascript6/Symbols/parserSymbolProperty6.ts parser/ecmascript6/Symbols/parserSymbolProperty7.ts parser/ecmascript6/Symbols/parserSymbolProperty8.ts parser/ecmascript6/Symbols/parserSymbolProperty9.ts +references/library-reference-1.ts references/library-reference-14.ts +references/library-reference-3.ts +references/library-reference-4.ts references/library-reference-6.ts +references/library-reference-7.ts +references/library-reference-8.ts +references/library-reference-scoped-packages.ts salsa/constructorNameInObjectLiteralAccessor.ts salsa/inferringClassMembersFromAssignments8.ts salsa/mixedPropertyElementAccessAssignmentDeclaration.ts @@ -2327,7 +2341,6 @@ types/contextualTypes/partiallyAnnotatedFunction/partiallyAnnotatedFunctionWitou types/forAwait/types.forAwait.es2018.1.ts types/forAwait/types.forAwait.es2018.2.ts types/forAwait/types.forAwait.es2018.3.ts -types/import/importTypeAmbientMissing.ts types/import/importTypeAmdBundleRewrite.ts types/intersection/contextualIntersectionType.ts types/intersection/intersectionMemberOfUnionNarrowsCorrectly.ts diff --git a/crates/stc_ts_type_checker/tests/conformance/externalModules/exportAssignmentOfExportNamespaceWithDefault.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/externalModules/exportAssignmentOfExportNamespaceWithDefault.error-diff.json deleted file mode 100644 index e38ae59eac..0000000000 --- a/crates/stc_ts_type_checker/tests/conformance/externalModules/exportAssignmentOfExportNamespaceWithDefault.error-diff.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "required_errors": {}, - "required_error_lines": {}, - "extra_errors": { - "TS2307": 1 - }, - "extra_error_lines": { - "TS2307": [ - 11 - ] - } -} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/externalModules/exportAssignmentOfExportNamespaceWithDefault.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/externalModules/exportAssignmentOfExportNamespaceWithDefault.stats.rust-debug index 0498397634..c086b5ab15 100644 --- a/crates/stc_ts_type_checker/tests/conformance/externalModules/exportAssignmentOfExportNamespaceWithDefault.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/externalModules/exportAssignmentOfExportNamespaceWithDefault.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 1, + extra_error: 0, panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-1.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/references/library-reference-1.error-diff.json deleted file mode 100644 index 7c6e505964..0000000000 --- a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-1.error-diff.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "required_errors": {}, - "required_error_lines": {}, - "extra_errors": { - "TS2307": 1 - }, - "extra_error_lines": { - "TS2307": [ - 2 - ] - } -} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-1.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/references/library-reference-1.stats.rust-debug index 0498397634..c086b5ab15 100644 --- a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-1.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/references/library-reference-1.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 1, + extra_error: 0, panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-3.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/references/library-reference-3.error-diff.json deleted file mode 100644 index 7c6e505964..0000000000 --- a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-3.error-diff.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "required_errors": {}, - "required_error_lines": {}, - "extra_errors": { - "TS2307": 1 - }, - "extra_error_lines": { - "TS2307": [ - 2 - ] - } -} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-3.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/references/library-reference-3.stats.rust-debug index 0498397634..c086b5ab15 100644 --- a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-3.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/references/library-reference-3.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 1, + extra_error: 0, panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-4.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/references/library-reference-4.error-diff.json deleted file mode 100644 index 70141c5123..0000000000 --- a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-4.error-diff.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "required_errors": {}, - "required_error_lines": {}, - "extra_errors": { - "TS2307": 3 - }, - "extra_error_lines": { - "TS2307": [ - 2, - 4, - 1 - ] - } -} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-4.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/references/library-reference-4.stats.rust-debug index 7d12ad5c64..c086b5ab15 100644 --- a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-4.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/references/library-reference-4.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 3, + extra_error: 0, panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-5.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/references/library-reference-5.error-diff.json index 3a1b51456c..d96d78547f 100644 --- a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-5.error-diff.json +++ b/crates/stc_ts_type_checker/tests/conformance/references/library-reference-5.error-diff.json @@ -7,14 +7,6 @@ 1 ] }, - "extra_errors": { - "TS2307": 3 - }, - "extra_error_lines": { - "TS2307": [ - 2, - 4, - 1 - ] - } + "extra_errors": {}, + "extra_error_lines": {} } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-5.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/references/library-reference-5.stats.rust-debug index efea2c0329..4af5bf17ec 100644 --- a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-5.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/references/library-reference-5.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 1, matched_error: 0, - extra_error: 3, + extra_error: 0, panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-7.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/references/library-reference-7.error-diff.json deleted file mode 100644 index 7c6e505964..0000000000 --- a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-7.error-diff.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "required_errors": {}, - "required_error_lines": {}, - "extra_errors": { - "TS2307": 1 - }, - "extra_error_lines": { - "TS2307": [ - 2 - ] - } -} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-7.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/references/library-reference-7.stats.rust-debug index 0498397634..c086b5ab15 100644 --- a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-7.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/references/library-reference-7.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 1, + extra_error: 0, panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-8.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/references/library-reference-8.error-diff.json deleted file mode 100644 index 9df5d88278..0000000000 --- a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-8.error-diff.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "required_errors": {}, - "required_error_lines": {}, - "extra_errors": { - "TS2307": 3 - }, - "extra_error_lines": { - "TS2307": [ - 3, - 4, - 2 - ] - } -} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-8.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/references/library-reference-8.stats.rust-debug index 7d12ad5c64..c086b5ab15 100644 --- a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-8.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/references/library-reference-8.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 3, + extra_error: 0, panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-scoped-packages.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/references/library-reference-scoped-packages.error-diff.json deleted file mode 100644 index dba7272865..0000000000 --- a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-scoped-packages.error-diff.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "required_errors": {}, - "required_error_lines": {}, - "extra_errors": { - "TS2307": 1 - }, - "extra_error_lines": { - "TS2307": [ - 1 - ] - } -} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-scoped-packages.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/references/library-reference-scoped-packages.stats.rust-debug index 0498397634..c086b5ab15 100644 --- a/crates/stc_ts_type_checker/tests/conformance/references/library-reference-scoped-packages.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/references/library-reference-scoped-packages.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 1, + extra_error: 0, panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeAmbient.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeAmbient.error-diff.json index 03d5257c1e..d8db441db2 100644 --- a/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeAmbient.error-diff.json +++ b/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeAmbient.error-diff.json @@ -2,15 +2,9 @@ "required_errors": {}, "required_error_lines": {}, "extra_errors": { - "TS2307": 3, "TS0": 1 }, "extra_error_lines": { - "TS2307": [ - 10, - 33, - 40 - ], "TS0": [ 28 ] diff --git a/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeAmbient.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeAmbient.stats.rust-debug index f8c5b3550b..0498397634 100644 --- a/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeAmbient.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeAmbient.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 4, + extra_error: 1, panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeAmbientMissing.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeAmbientMissing.error-diff.json new file mode 100644 index 0000000000..5e7c93b207 --- /dev/null +++ b/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeAmbientMissing.error-diff.json @@ -0,0 +1,12 @@ +{ + "required_errors": { + "TS2307": 1 + }, + "required_error_lines": { + "TS2307": [ + 10 + ] + }, + "extra_errors": {}, + "extra_error_lines": {} +} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeAmbientMissing.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeAmbientMissing.stats.rust-debug index f3e39f53bd..4af5bf17ec 100644 --- a/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeAmbientMissing.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeAmbientMissing.stats.rust-debug @@ -1,6 +1,6 @@ Stats { - required_error: 0, - matched_error: 1, + required_error: 1, + matched_error: 0, extra_error: 0, panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug index 83979399ee..3bad9ce15d 100644 --- a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug @@ -1,6 +1,6 @@ Stats { - required_error: 2860, - matched_error: 7175, - extra_error: 1107, + required_error: 2861, + matched_error: 7174, + extra_error: 1090, panic: 3, } \ No newline at end of file From b81ae80cefcddacd814660d64111c3fb326b139e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=98=A4=EB=B3=91=EC=A7=84?= <64676070+sunrabbit123@users.noreply.github.com> Date: Mon, 16 Oct 2023 13:55:52 +0900 Subject: [PATCH 38/40] fix: Import local type from module and namespace (#1099) **Description:** ```ts declare module "foo2" { namespace Bar { interface I { a: string; b: number; } } namespace Baz { interface J { a: number; b: string; } } class Bar { item: Bar.I; constructor(input: Baz.J); } } let y: import("foo2").Bar.I = { a: "", b: 0 }; ``` --- .../src/analyzer/expr/mod.rs | 22 +++-- .../src/analyzer/scope/mod.rs | 84 +++++++++++-------- .../tests/conformance.pass.txt | 3 + ...tedInterfacesOfTheSameName.error-diff.json | 7 +- ...portedModulesOfTheSameName.error-diff.json | 7 +- .../import/importTypeAmbient.error-diff.json | 12 --- .../import/importTypeAmbient.stats.rust-debug | 2 +- .../importTypeGenericTypes.error-diff.json | 12 --- .../importTypeGenericTypes.stats.rust-debug | 2 +- .../import/importTypeLocal.error-diff.json | 12 --- .../import/importTypeLocal.stats.rust-debug | 2 +- .../importTypeLocalMissing.error-diff.json | 10 +-- .../importTypeLocalMissing.stats.rust-debug | 2 +- .../tests/tsc-stats.rust-debug | 2 +- 14 files changed, 84 insertions(+), 95 deletions(-) delete mode 100644 crates/stc_ts_type_checker/tests/conformance/types/import/importTypeAmbient.error-diff.json delete mode 100644 crates/stc_ts_type_checker/tests/conformance/types/import/importTypeGenericTypes.error-diff.json delete mode 100644 crates/stc_ts_type_checker/tests/conformance/types/import/importTypeLocal.error-diff.json diff --git a/crates/stc_ts_file_analyzer/src/analyzer/expr/mod.rs b/crates/stc_ts_file_analyzer/src/analyzer/expr/mod.rs index 4c30da014b..448af7913f 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/expr/mod.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/expr/mod.rs @@ -3035,9 +3035,9 @@ impl Analyzer<'_, '_> { } Type::Module(ty::Module { name, ref exports, .. }) => { - match id_ctx { - IdCtx::Type => { - if let Key::Normal { sym, .. } = prop { + if let Key::Normal { sym, .. } = prop { + match id_ctx { + IdCtx::Type => { if let Some(types) = exports.types.get(sym).cloned() { if types.len() == 1 { return Ok(types.into_iter().next().unwrap()); @@ -3053,16 +3053,22 @@ impl Analyzer<'_, '_> { if let Some(vars) = exports.vars.get(sym).cloned() { return Ok(vars); } + + for (id, tys) in exports.private_types.iter() { + if *id.sym() != *sym { + continue; + } + + if let Some(ty) = tys.iter().find(|ty| ty.is_module() || ty.is_interface()) { + return Ok(ty.clone()); + } + } } - } - IdCtx::Var => { - if let Key::Normal { sym, .. } = prop { + IdCtx::Var => { if let Some(item) = exports.vars.get(sym) { return Ok(item.clone()); } - } - if let Key::Normal { sym, .. } = prop { if let Some(types) = exports.types.get(sym) { for ty in types.iter() { if ty.is_module() || ty.is_interface() { diff --git a/crates/stc_ts_file_analyzer/src/analyzer/scope/mod.rs b/crates/stc_ts_file_analyzer/src/analyzer/scope/mod.rs index 0b62af2660..b1c36e9bbe 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/scope/mod.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/scope/mod.rs @@ -1220,6 +1220,12 @@ impl Analyzer<'_, '_> { } } + self.find_local_type_without_this(name) + } + + fn find_local_type_without_this(&self, name: &Id) -> Option> { + let _tracing = dev_span!("find_local_type_without_this", name = tracing::field::debug(name)); + if cfg!(debug_assertions) { debug!("({}) Scope.find_type(`{}`)", self.scope.depth(), name); } @@ -2064,6 +2070,7 @@ impl Expander<'_, '_, '_> { type_args: Option<&TypeParamInstantiation>, was_top_level: bool, trying_primitive_expansion: bool, + ignore_this: bool, ) -> VResult> { macro_rules! verify { ($ty:expr) => {{ @@ -2080,26 +2087,20 @@ impl Expander<'_, '_, '_> { match type_name { RTsEntityName::Ident(ref i) => { - if let Some(class) = &self.analyzer.scope.get_this_class_name() { - if *class == *i { - return Ok(Some(Type::This(ThisType { - span, - metadata: Default::default(), - tracker: Default::default(), - }))); - } - } - if i.sym == js_word!("void") { - return Ok(Some(Type::any(span, Default::default()))); - } - info!("Info: {}{:?}", i.sym, i.span.ctxt); if !trying_primitive_expansion && self.dejavu.contains(&i.into()) { error!("Dejavu: {}{:?}", &i.sym, i.span.ctxt); return Ok(None); } - if let Some(types) = self.analyzer.find_type(&i.into())? { + let tys = if ignore_this { + self.analyzer.find_local_type_without_this(&i.into()) + } else { + None + } + .map_or_else(|| self.analyzer.find_type(&i.into()), |res| Ok(Some(res)))?; + + if let Some(types) = tys { info!("expand: expanding `{}` using analyzer: {}", Id::from(i), types.clone().count()); let mut stored_ref = None; @@ -2247,6 +2248,11 @@ impl Expander<'_, '_, '_> { Type::Mapped(m) => {} + Type::Namespace(..) => { + return Ok(Some(t.into_owned())); + } + + Type::StaticThis(..) => stored_ref = Some(t), _ => stored_ref = Some(t), } } @@ -2258,7 +2264,7 @@ impl Expander<'_, '_, '_> { } } - if i.sym == *"undefined" || i.sym == *"null" { + if i.sym == *"undefined" || i.sym == *"null" || i.sym == *"void" { return Ok(Some(Type::any(span, Default::default()))); } @@ -2269,26 +2275,29 @@ impl Expander<'_, '_, '_> { // // let a: StringEnum.Foo = x; RTsEntityName::TsQualifiedName(box RTsQualifiedName { left, ref right, .. }) => { - let left = self.expand_ts_entity_name(span, left, None, was_top_level, trying_primitive_expansion)?; - - if let Some(left) = &left { - let ty = self + let prop = Key::Normal { + span, + sym: right.sym.clone(), + }; + if let Some(ty) = self.expand_ts_entity_name(span, left, None, was_top_level, trying_primitive_expansion, false)? { + match self .analyzer - .access_property( - span, - left, - &Key::Normal { - span, - sym: right.sym.clone(), - }, - TypeOfMode::RValue, - IdCtx::Type, - Default::default(), - ) + .access_property(span, &ty, &prop, TypeOfMode::RValue, IdCtx::Type, Default::default()) .context("tried to access property as a part of type expansion") - .report(&mut self.analyzer.storage) - .unwrap_or_else(|| Type::any(span, Default::default())); - return Ok(Some(ty)); + { + Ok(t) => return Ok(Some(t)), + err => { + if let Some(left) = + self.expand_ts_entity_name(span, left, None, was_top_level, trying_primitive_expansion, true)? + { + return Ok(self + .analyzer + .access_property(span, &left, &prop, TypeOfMode::RValue, IdCtx::Type, Default::default()) + .context("tried to access property as a part of type expansion(retry without this type)") + .report(&mut self.analyzer.storage)); + } + } + }; } } } @@ -2313,7 +2322,14 @@ impl Expander<'_, '_, '_> { return Ok(None); } - let mut ty = self.expand_ts_entity_name(span, &type_name, type_args.as_deref(), was_top_level, trying_primitive_expansion)?; + let mut ty = self.expand_ts_entity_name( + span, + &type_name, + type_args.as_deref(), + was_top_level, + trying_primitive_expansion, + false, + )?; if let Some(ty) = &mut ty { ty.reposition(r_span); diff --git a/crates/stc_ts_type_checker/tests/conformance.pass.txt b/crates/stc_ts_type_checker/tests/conformance.pass.txt index 3b62640fe9..e13517914a 100644 --- a/crates/stc_ts_type_checker/tests/conformance.pass.txt +++ b/crates/stc_ts_type_checker/tests/conformance.pass.txt @@ -2341,7 +2341,10 @@ types/contextualTypes/partiallyAnnotatedFunction/partiallyAnnotatedFunctionWitou types/forAwait/types.forAwait.es2018.1.ts types/forAwait/types.forAwait.es2018.2.ts types/forAwait/types.forAwait.es2018.3.ts +types/import/importTypeAmbient.ts types/import/importTypeAmdBundleRewrite.ts +types/import/importTypeGenericTypes.ts +types/import/importTypeLocal.ts types/intersection/contextualIntersectionType.ts types/intersection/intersectionMemberOfUnionNarrowsCorrectly.ts types/intersection/intersectionNarrowing.ts diff --git a/crates/stc_ts_type_checker/tests/conformance/internalModules/DeclarationMerging/TwoInternalModulesThatMergeEachWithExportedAndNonExportedInterfacesOfTheSameName.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/internalModules/DeclarationMerging/TwoInternalModulesThatMergeEachWithExportedAndNonExportedInterfacesOfTheSameName.error-diff.json index fc72f54093..1830759d9e 100644 --- a/crates/stc_ts_type_checker/tests/conformance/internalModules/DeclarationMerging/TwoInternalModulesThatMergeEachWithExportedAndNonExportedInterfacesOfTheSameName.error-diff.json +++ b/crates/stc_ts_type_checker/tests/conformance/internalModules/DeclarationMerging/TwoInternalModulesThatMergeEachWithExportedAndNonExportedInterfacesOfTheSameName.error-diff.json @@ -2,11 +2,14 @@ "required_errors": {}, "required_error_lines": {}, "extra_errors": { - "TS2339": 2 + "TS2403": 1, + "TS2339": 1 }, "extra_error_lines": { + "TS2403": [ + 17 + ], "TS2339": [ - 17, 36 ] } diff --git a/crates/stc_ts_type_checker/tests/conformance/internalModules/DeclarationMerging/TwoInternalModulesThatMergeEachWithExportedModulesOfTheSameName.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/internalModules/DeclarationMerging/TwoInternalModulesThatMergeEachWithExportedModulesOfTheSameName.error-diff.json index 47483375cd..519155a71f 100644 --- a/crates/stc_ts_type_checker/tests/conformance/internalModules/DeclarationMerging/TwoInternalModulesThatMergeEachWithExportedModulesOfTheSameName.error-diff.json +++ b/crates/stc_ts_type_checker/tests/conformance/internalModules/DeclarationMerging/TwoInternalModulesThatMergeEachWithExportedModulesOfTheSameName.error-diff.json @@ -2,11 +2,14 @@ "required_errors": {}, "required_error_lines": {}, "extra_errors": { - "TS2339": 2 + "TS2339": 1, + "TS2403": 1 }, "extra_error_lines": { "TS2339": [ - 13, + 13 + ], + "TS2403": [ 33 ] } diff --git a/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeAmbient.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeAmbient.error-diff.json deleted file mode 100644 index d8db441db2..0000000000 --- a/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeAmbient.error-diff.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "required_errors": {}, - "required_error_lines": {}, - "extra_errors": { - "TS0": 1 - }, - "extra_error_lines": { - "TS0": [ - 28 - ] - } -} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeAmbient.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeAmbient.stats.rust-debug index 0498397634..c086b5ab15 100644 --- a/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeAmbient.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeAmbient.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 1, + extra_error: 0, panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeGenericTypes.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeGenericTypes.error-diff.json deleted file mode 100644 index 27fcd6e0ee..0000000000 --- a/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeGenericTypes.error-diff.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "required_errors": {}, - "required_error_lines": {}, - "extra_errors": { - "TS0": 1 - }, - "extra_error_lines": { - "TS0": [ - 18 - ] - } -} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeGenericTypes.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeGenericTypes.stats.rust-debug index 0498397634..c086b5ab15 100644 --- a/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeGenericTypes.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeGenericTypes.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 1, + extra_error: 0, panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeLocal.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeLocal.error-diff.json deleted file mode 100644 index 1dc2bc9b4c..0000000000 --- a/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeLocal.error-diff.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "required_errors": {}, - "required_error_lines": {}, - "extra_errors": { - "TS0": 1 - }, - "extra_error_lines": { - "TS0": [ - 16 - ] - } -} \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeLocal.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeLocal.stats.rust-debug index 0498397634..c086b5ab15 100644 --- a/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeLocal.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeLocal.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 0, matched_error: 0, - extra_error: 1, + extra_error: 0, panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeLocalMissing.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeLocalMissing.error-diff.json index 77be6774be..e8ffa5f5f8 100644 --- a/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeLocalMissing.error-diff.json +++ b/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeLocalMissing.error-diff.json @@ -7,12 +7,6 @@ 3 ] }, - "extra_errors": { - "TS0": 1 - }, - "extra_error_lines": { - "TS0": [ - 16 - ] - } + "extra_errors": {}, + "extra_error_lines": {} } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeLocalMissing.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeLocalMissing.stats.rust-debug index c28efdd8e5..8a4b298eee 100644 --- a/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeLocalMissing.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/types/import/importTypeLocalMissing.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 1, matched_error: 3, - extra_error: 1, + extra_error: 0, panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug index 3bad9ce15d..d972a81e03 100644 --- a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 2861, matched_error: 7174, - extra_error: 1090, + extra_error: 1086, panic: 3, } \ No newline at end of file From fa1547038db4caa39543843b314c8ebdf1a7b815 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=98=A4=EB=B3=91=EC=A7=84?= <64676070+sunrabbit123@users.noreply.github.com> Date: Tue, 14 Nov 2023 22:44:48 +0900 Subject: [PATCH 39/40] feat: Remove extra error at `interfaceExtendsObjectIntersectionErrors` (#1103) **Description:** ```ts interface I31 extends T { x: string } ``` I have a concern. The following functions cause duplicate error handling due to duplicate function calls. ```rs #[validator] impl Analyzer<'_, '_> { fn validate(&mut self, d: &RTsInterfaceDecl) -> VResult { let ty = self.with_child(ScopeKind::Flow, Default::default(), |child: &mut Analyzer| -> VResult<_> { match &*d.id.sym { "any" | "void" | "never" | "unknown" | "string" | "number" | "bigint" | "boolean" | "null" | "undefined" | "symbol" => { child.storage.report(ErrorKind::InvalidInterfaceName { span: d.id.span }.into()); } _ => {} } let mut ty = Interface { span: d.span, name: d.id.clone().into(), type_params: try_opt!(d.type_params.validate_with(&mut *child).map(|v| v.map(Box::new))), extends: d.extends.validate_with(child)?.freezed(), body: d.body.validate_with(child)?, metadata: Default::default(), tracker: Default::default(), }; child.prevent_expansion(&mut ty.body); ty.body.freeze(); child.resolve_parent_interfaces(&d.extends, true); child.report_error_for_conflicting_parents(d.id.span, &ty.extends); child.report_error_for_wrong_interface_inheritance(d.id.span, &ty.body, &ty.extends); let ty = Type::Interface(ty).freezed(); Ok(ty) })?; // TODO(kdy1): Recover self.register_type(d.id.clone().into(), ty.clone()); Ok(ty) } } ``` `child.resolve_parent_interfaces` and `child.report_error_for_wrong_interface_inheritance` call `report_error_for_unresolved_type` this fn cause `ErrorKind::TypeNotFound` This PR only clogs the hole. If there seems to be a need for fundamental improvement, please open up the issue --- .../src/analyzer/convert/interface.rs | 5 +++++ .../tsc/types/interface/interfaceDeclaration/1.ts | 3 +++ .../interface/interfaceDeclaration/1.tsc-errors.json | 8 ++++++++ ...faceExtendsObjectIntersectionErrors.error-diff.json | 10 ++-------- ...aceExtendsObjectIntersectionErrors.stats.rust-debug | 2 +- crates/stc_ts_type_checker/tests/tsc-stats.rust-debug | 2 +- 6 files changed, 20 insertions(+), 10 deletions(-) create mode 100644 crates/stc_ts_file_analyzer/tests/tsc/types/interface/interfaceDeclaration/1.ts create mode 100644 crates/stc_ts_file_analyzer/tests/tsc/types/interface/interfaceDeclaration/1.tsc-errors.json diff --git a/crates/stc_ts_file_analyzer/src/analyzer/convert/interface.rs b/crates/stc_ts_file_analyzer/src/analyzer/convert/interface.rs index ed8e0c9efb..92d623f69f 100644 --- a/crates/stc_ts_file_analyzer/src/analyzer/convert/interface.rs +++ b/crates/stc_ts_file_analyzer/src/analyzer/convert/interface.rs @@ -62,6 +62,11 @@ impl Analyzer<'_, '_> { }; if let Err(err) = res { + if err.code() == 2304 { + // TypeNotFound + return; + } + self.storage.report( ErrorKind::InvalidInterfaceInheritance { span, diff --git a/crates/stc_ts_file_analyzer/tests/tsc/types/interface/interfaceDeclaration/1.ts b/crates/stc_ts_file_analyzer/tests/tsc/types/interface/interfaceDeclaration/1.ts new file mode 100644 index 0000000000..f10e0e701d --- /dev/null +++ b/crates/stc_ts_file_analyzer/tests/tsc/types/interface/interfaceDeclaration/1.ts @@ -0,0 +1,3 @@ +// @strictNullChecks: true + +interface I31 extends T { x: string } \ No newline at end of file diff --git a/crates/stc_ts_file_analyzer/tests/tsc/types/interface/interfaceDeclaration/1.tsc-errors.json b/crates/stc_ts_file_analyzer/tests/tsc/types/interface/interfaceDeclaration/1.tsc-errors.json new file mode 100644 index 0000000000..217c06d3af --- /dev/null +++ b/crates/stc_ts_file_analyzer/tests/tsc/types/interface/interfaceDeclaration/1.tsc-errors.json @@ -0,0 +1,8 @@ +[ + { + "file": "tests/tsc/types/interface/interfaceDeclaration/1.ts", + "line": 3, + "col": 26, + "code": 2312 + } +] \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.error-diff.json b/crates/stc_ts_type_checker/tests/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.error-diff.json index 05f62357e2..14c1b95d3e 100644 --- a/crates/stc_ts_type_checker/tests/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.error-diff.json +++ b/crates/stc_ts_type_checker/tests/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.error-diff.json @@ -32,12 +32,6 @@ 48 ] }, - "extra_errors": { - "TS2430": 1 - }, - "extra_error_lines": { - "TS2430": [ - 49 - ] - } + "extra_errors": {}, + "extra_error_lines": {} } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.stats.rust-debug b/crates/stc_ts_type_checker/tests/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.stats.rust-debug index ddae7c5fd4..da171bb9dd 100644 --- a/crates/stc_ts_type_checker/tests/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 14, matched_error: 9, - extra_error: 1, + extra_error: 0, panic: 0, } \ No newline at end of file diff --git a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug index d972a81e03..61d4808634 100644 --- a/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug +++ b/crates/stc_ts_type_checker/tests/tsc-stats.rust-debug @@ -1,6 +1,6 @@ Stats { required_error: 2861, matched_error: 7174, - extra_error: 1086, + extra_error: 1085, panic: 3, } \ No newline at end of file From 34abe15fab75bd28122be339d739980cd2312d49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=98=A4=EB=B3=91=EC=A7=84?= <64676070+sunrabbit123@users.noreply.github.com> Date: Fri, 17 Nov 2023 09:59:45 +0900 Subject: [PATCH 40/40] chore: Update TypeScript from `v4.3.5` to `v5.1.3` (#1105) --- crates/stc_ts_builtin_types/lib/README.md | 24 +- .../stc_ts_builtin_types/lib/decorators.d.ts | 207 +- .../lib/decorators.legacy.d.ts | 2 +- .../lib/dom.generated.d.ts | 16042 ++++++++++++---- .../lib/dom.iterable.generated.d.ts | 127 +- .../lib/es2015.collection.d.ts | 2 +- .../stc_ts_builtin_types/lib/es2015.core.d.ts | 4 +- .../lib/es2015.symbol.wellknown.d.ts | 24 +- .../lib/es2020.bigint.d.ts | 8 +- .../stc_ts_builtin_types/lib/es2020.intl.d.ts | 8 + .../stc_ts_builtin_types/lib/es2022.intl.d.ts | 9 + crates/stc_ts_builtin_types/lib/es5.d.ts | 97 +- .../lib/esnext.promise.d.ts | 23 - .../lib/esnext.string.d.ts | 15 - .../lib/esnext.weakref.d.ts | 55 - .../lib/webworker.generated.d.ts | 6837 +++++-- .../lib/webworker.iterable.generated.d.ts | 101 +- crates/stc_ts_builtin_types/src/lib.rs | 3 - crates/stc_ts_testing/src/conformance.rs | 6 +- .../tests/conformance.pass.txt | 1 + .../es2022/es2022IntlAPIs.error-diff.json | 12 - .../es2022/es2022IntlAPIs.stats.rust-debug | 2 +- .../tests/tsc-stats.rust-debug | 2 +- package.json | 2 +- yarn.lock | 8 +- 25 files changed, 18140 insertions(+), 5481 deletions(-) delete mode 100644 crates/stc_ts_builtin_types/lib/esnext.promise.d.ts delete mode 100644 crates/stc_ts_builtin_types/lib/esnext.string.d.ts delete mode 100644 crates/stc_ts_builtin_types/lib/esnext.weakref.d.ts delete mode 100644 crates/stc_ts_type_checker/tests/conformance/es2022/es2022IntlAPIs.error-diff.json diff --git a/crates/stc_ts_builtin_types/lib/README.md b/crates/stc_ts_builtin_types/lib/README.md index 5a771d000f..8dc708fd91 100644 --- a/crates/stc_ts_builtin_types/lib/README.md +++ b/crates/stc_ts_builtin_types/lib/README.md @@ -1,8 +1,26 @@ # Read this! -The files within this directory are used to generate `lib.d.ts` and `lib.es6.d.ts`. +The files within this directory are copied and deployed with TypeScript as the set of APIs available as a part of the JavaScript language. + +There are three main domains of APIs in `src/lib`: + + - **ECMAScript language features** - e.g. JavaScript APIs like functions on Array etc which are documented in [ECMA-262](https://tc39.es/ecma262/) + - **DOM APIs** - e.g. APIs which are available in web browsers + - **Intl APIs** - e.g. APIs scoped to `Intl` which are documented in [ECMA-402](https://www.ecma-international.org/publications-and-standards/standards/ecma-402/) + +## How do we figure out when to add something? + +TypeScript has a rule-of-thumb to only add something when it has got far enough through the standards process that it is more or less confirmed. For JavaScript APIs and language features, that means the proposal is at stage 3 or later. + +You can find the source of truth for modern language features and Intl APIs in these completed proposal lists: + + - [JavaScript](https://github.com/tc39/proposals/blob/master/finished-proposals.md) + - [Intl](https://github.com/tc39/proposals/blob/master/ecma402/finished-proposals.md) + +For the DOM APIs, which are a bit more free-form, we have asked that APIs are available un-prefixed/flagged in at least 2 browser _engines_ (i.e. not just 2 chromium browsers.) ## Generated files -Any files ending in `.generated.d.ts` aren't meant to be edited by hand. -If you need to make changes to such files, make a change to the input files for [**our library generator**](https://github.com/Microsoft/TSJS-lib-generator). \ No newline at end of file +The DOM files ending in `.generated.d.ts` aren't meant to be edited by hand. + +If you need to make changes to such files, make a change to the input files for [**our library generator**](https://github.com/microsoft/TypeScript-DOM-lib-generator). diff --git a/crates/stc_ts_builtin_types/lib/decorators.d.ts b/crates/stc_ts_builtin_types/lib/decorators.d.ts index 6fb8de5271..dae39ffed3 100644 --- a/crates/stc_ts_builtin_types/lib/decorators.d.ts +++ b/crates/stc_ts_builtin_types/lib/decorators.d.ts @@ -1,5 +1,5 @@ /** - * The decorator context types provided to class member decorators. + * The decorator context types provided to class element decorators. */ type ClassMemberDecoratorContext = | ClassMethodDecoratorContext @@ -60,34 +60,37 @@ interface ClassMethodDecoratorContext< This = unknown, Value extends (this: This, ...args: any) => any = (this: This, ...args: any) => any, > { - /** The kind of class member that was decorated. */ + /** The kind of class element that was decorated. */ readonly kind: "method"; - /** The name of the decorated class member. */ + /** The name of the decorated class element. */ readonly name: string | symbol; - /** A value indicating whether the class member is a static (`true`) or instance (`false`) member. */ + /** A value indicating whether the class element is a static (`true`) or instance (`false`) element. */ readonly static: boolean; - /** A value indicating whether the class member has a private name. */ + /** A value indicating whether the class element has a private name. */ readonly private: boolean; - // NOTE: Disabled, pending the outcome of https://github.com/tc39/proposal-decorators/issues/494 - // /** An object that can be used to access the current value of the class member at runtime. */ - // readonly access: { - // /** - // * Gets the current value of the method from the provided receiver. - // * - // * @example - // * let fn = context.access.get.call(instance); - // */ - // get(this: This): Value; - // }; + /** An object that can be used to access the current value of the class element at runtime. */ + readonly access: { + /** + * Determines whether an object has a property with the same name as the decorated element. + */ + has(object: This): boolean; + /** + * Gets the current value of the method from the provided object. + * + * @example + * let fn = context.access.get(instance); + */ + get(object: This): Value; + }; /** * Adds a callback to be invoked either before static initializers are run (when - * decorating a `static` member), or before instance initializers are run (when - * decorating a non-`static` member). + * decorating a `static` element), or before instance initializers are run (when + * decorating a non-`static` element). * * @example * ```ts @@ -121,34 +124,37 @@ interface ClassGetterDecoratorContext< This = unknown, Value = unknown, > { - /** The kind of class member that was decorated. */ + /** The kind of class element that was decorated. */ readonly kind: "getter"; - /** The name of the decorated class member. */ + /** The name of the decorated class element. */ readonly name: string | symbol; - /** A value indicating whether the class member is a static (`true`) or instance (`false`) member. */ + /** A value indicating whether the class element is a static (`true`) or instance (`false`) element. */ readonly static: boolean; - /** A value indicating whether the class member has a private name. */ + /** A value indicating whether the class element has a private name. */ readonly private: boolean; - // NOTE: Disabled, pending the outcome of https://github.com/tc39/proposal-decorators/issues/494 - // /** An object that can be used to access the current value of the class member at runtime. */ - // readonly access: { - // /** - // * Invokes the getter on the provided receiver. - // * - // * @example - // * let value = context.access.get.call(instance); - // */ - // get(this: This): Value; - // }; + /** An object that can be used to access the current value of the class element at runtime. */ + readonly access: { + /** + * Determines whether an object has a property with the same name as the decorated element. + */ + has(object: This): boolean; + /** + * Invokes the getter on the provided object. + * + * @example + * let value = context.access.get(instance); + */ + get(object: This): Value; + }; /** * Adds a callback to be invoked either before static initializers are run (when - * decorating a `static` member), or before instance initializers are run (when - * decorating a non-`static` member). + * decorating a `static` element), or before instance initializers are run (when + * decorating a non-`static` element). */ addInitializer(initializer: (this: This) => void): void; } @@ -163,34 +169,37 @@ interface ClassSetterDecoratorContext< This = unknown, Value = unknown, > { - /** The kind of class member that was decorated. */ + /** The kind of class element that was decorated. */ readonly kind: "setter"; - /** The name of the decorated class member. */ + /** The name of the decorated class element. */ readonly name: string | symbol; - /** A value indicating whether the class member is a static (`true`) or instance (`false`) member. */ + /** A value indicating whether the class element is a static (`true`) or instance (`false`) element. */ readonly static: boolean; - /** A value indicating whether the class member has a private name. */ + /** A value indicating whether the class element has a private name. */ readonly private: boolean; - // NOTE: Disabled, pending the outcome of https://github.com/tc39/proposal-decorators/issues/494 - /** An object that can be used to access the current value of the class member at runtime. */ - // readonly access: { - // /** - // * Invokes the setter on the provided receiver. - // * - // * @example - // * context.access.set.call(instance, value); - // */ - // set(this: This, value: Value): void; - // }; + /** An object that can be used to access the current value of the class element at runtime. */ + readonly access: { + /** + * Determines whether an object has a property with the same name as the decorated element. + */ + has(object: This): boolean; + /** + * Invokes the setter on the provided object. + * + * @example + * context.access.set(instance, value); + */ + set(object: This, value: Value): void; + }; /** * Adds a callback to be invoked either before static initializers are run (when - * decorating a `static` member), or before instance initializers are run (when - * decorating a non-`static` member). + * decorating a `static` element), or before instance initializers are run (when + * decorating a non-`static` element). */ addInitializer(initializer: (this: This) => void): void; } @@ -205,42 +214,46 @@ interface ClassAccessorDecoratorContext< This = unknown, Value = unknown, > { - /** The kind of class member that was decorated. */ + /** The kind of class element that was decorated. */ readonly kind: "accessor"; - /** The name of the decorated class member. */ + /** The name of the decorated class element. */ readonly name: string | symbol; - /** A value indicating whether the class member is a static (`true`) or instance (`false`) member. */ + /** A value indicating whether the class element is a static (`true`) or instance (`false`) element. */ readonly static: boolean; - /** A value indicating whether the class member has a private name. */ + /** A value indicating whether the class element has a private name. */ readonly private: boolean; - // NOTE: Disabled, pending the outcome of https://github.com/tc39/proposal-decorators/issues/494 - // /** An object that can be used to access the current value of the class member at runtime. */ - // readonly access: { - // /** - // * Invokes the getter on the provided receiver. - // * - // * @example - // * let value = context.access.get.call(instance); - // */ - // get(this: This): Value; - - // /** - // * Invokes the setter on the provided receiver. - // * - // * @example - // * context.access.set.call(instance, value); - // */ - // set(this: This, value: Value): void; - // }; + /** An object that can be used to access the current value of the class element at runtime. */ + readonly access: { + /** + * Determines whether an object has a property with the same name as the decorated element. + */ + has(object: This): boolean; + + /** + * Invokes the getter on the provided object. + * + * @example + * let value = context.access.get(instance); + */ + get(object: This): Value; + + /** + * Invokes the setter on the provided object. + * + * @example + * context.access.set(instance, value); + */ + set(object: This, value: Value): void; + }; /** * Adds a callback to be invoked either before static initializers are run (when - * decorating a `static` member), or before instance initializers are run (when - * decorating a non-`static` member). + * decorating a `static` element), or before instance initializers are run (when + * decorating a non-`static` element). */ addInitializer(initializer: (this: This) => void): void; } @@ -302,36 +315,40 @@ interface ClassFieldDecoratorContext< This = unknown, Value = unknown, > { - /** The kind of class member that was decorated. */ + /** The kind of class element that was decorated. */ readonly kind: "field"; - /** The name of the decorated class member. */ + /** The name of the decorated class element. */ readonly name: string | symbol; - /** A value indicating whether the class member is a static (`true`) or instance (`false`) member. */ + /** A value indicating whether the class element is a static (`true`) or instance (`false`) element. */ readonly static: boolean; - /** A value indicating whether the class member has a private name. */ + /** A value indicating whether the class element has a private name. */ readonly private: boolean; - // NOTE: Disabled, pending the outcome of https://github.com/tc39/proposal-decorators/issues/494 - // /** An object that can be used to access the current value of the class member at runtime. */ - // readonly access: { - // /** - // * Gets the value of the field on the provided receiver. - // */ - // get(this: This): Value; + /** An object that can be used to access the current value of the class element at runtime. */ + readonly access: { + /** + * Determines whether an object has a property with the same name as the decorated element. + */ + has(object: This): boolean; - // /** - // * Sets the value of the field on the provided receiver. - // */ - // set(this: This, value: Value): void; - // }; + /** + * Gets the value of the field on the provided object. + */ + get(object: This): Value; + + /** + * Sets the value of the field on the provided object. + */ + set(object: This, value: Value): void; + }; /** * Adds a callback to be invoked either before static initializers are run (when - * decorating a `static` member), or before instance initializers are run (when - * decorating a non-`static` member). + * decorating a `static` element), or before instance initializers are run (when + * decorating a non-`static` element). */ addInitializer(initializer: (this: This) => void): void; } diff --git a/crates/stc_ts_builtin_types/lib/decorators.legacy.d.ts b/crates/stc_ts_builtin_types/lib/decorators.legacy.d.ts index aeb4032138..c9ecc94f55 100644 --- a/crates/stc_ts_builtin_types/lib/decorators.legacy.d.ts +++ b/crates/stc_ts_builtin_types/lib/decorators.legacy.d.ts @@ -1,4 +1,4 @@ declare type ClassDecorator = (target: TFunction) => TFunction | void; declare type PropertyDecorator = (target: Object, propertyKey: string | symbol) => void; declare type MethodDecorator = (target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor | void; -declare type ParameterDecorator = (target: Object, propertyKey: string | symbol, parameterIndex: number) => void; +declare type ParameterDecorator = (target: Object, propertyKey: string | symbol | undefined, parameterIndex: number) => void; diff --git a/crates/stc_ts_builtin_types/lib/dom.generated.d.ts b/crates/stc_ts_builtin_types/lib/dom.generated.d.ts index 7a106f0314..0535ea6e70 100644 --- a/crates/stc_ts_builtin_types/lib/dom.generated.d.ts +++ b/crates/stc_ts_builtin_types/lib/dom.generated.d.ts @@ -133,6 +133,10 @@ interface AuthenticatorSelectionCriteria { userVerification?: UserVerificationRequirement; } +interface AvcEncoderConfig { + format?: AvcBitstreamFormat; +} + interface BiquadFilterOptions extends AudioNodeOptions { Q?: number; detune?: number; @@ -151,6 +155,21 @@ interface BlobPropertyBag { type?: string; } +interface CSSMatrixComponentOptions { + is2D?: boolean; +} + +interface CSSNumericType { + angle?: number; + flex?: number; + frequency?: number; + length?: number; + percent?: number; + percentHint?: CSSNumericBaseType; + resolution?: number; + time?: number; +} + interface CSSStyleSheetInit { baseURL?: string; disabled?: boolean; @@ -178,6 +197,11 @@ interface ChannelSplitterOptions extends AudioNodeOptions { numberOfOutputs?: number; } +interface CheckVisibilityOptions { + checkOpacity?: boolean; + checkVisibilityCSS?: boolean; +} + interface ClientQueryOptions { includeUncontrolled?: boolean; type?: ClientTypes; @@ -401,7 +425,7 @@ interface EcdsaParams extends Algorithm { interface EffectTiming { delay?: number; direction?: PlaybackDirection; - duration?: number | string; + duration?: number | CSSNumericValue | string; easing?: string; endDelay?: number; fill?: FillMode; @@ -418,6 +442,17 @@ interface ElementDefinitionOptions { extends?: string; } +interface EncodedVideoChunkInit { + data: BufferSource; + duration?: number; + timestamp: number; + type: EncodedVideoChunkType; +} + +interface EncodedVideoChunkMetadata { + decoderConfig?: VideoDecoderConfig; +} + interface ErrorEventInit extends EventInit { colno?: number; error?: any; @@ -461,6 +496,10 @@ interface FilePropertyBag extends BlobPropertyBag { lastModified?: number; } +interface FileSystemCreateWritableOptions { + keepExistingData?: boolean; +} + interface FileSystemFlags { create?: boolean; exclusive?: boolean; @@ -487,8 +526,11 @@ interface FocusOptions { } interface FontFaceDescriptors { - display?: string; + ascentOverride?: string; + descentOverride?: string; + display?: FontDisplay; featureSettings?: string; + lineGapOverride?: string; stretch?: string; style?: string; unicodeRange?: string; @@ -512,6 +554,13 @@ interface GainOptions extends AudioNodeOptions { gain?: number; } +interface GamepadEffectParameters { + duration?: number; + startDelay?: number; + strongMagnitude?: number; + weakMagnitude?: number; +} + interface GamepadEventInit extends EventInit { gamepad: Gamepad; } @@ -604,6 +653,11 @@ interface ImageDataSettings { colorSpace?: PredefinedColorSpace; } +interface ImageEncodeOptions { + quality?: number; + type?: string; +} + interface ImportMeta { url: string; } @@ -704,6 +758,19 @@ interface LockOptions { steal?: boolean; } +interface MIDIConnectionEventInit extends EventInit { + port?: MIDIPort; +} + +interface MIDIMessageEventInit extends EventInit { + data?: Uint8Array; +} + +interface MIDIOptions { + software?: boolean; + sysex?: boolean; +} + interface MediaCapabilitiesDecodingInfo extends MediaCapabilitiesInfo { configuration?: MediaDecodingConfiguration; } @@ -818,7 +885,6 @@ interface MediaTrackCapabilities { aspectRatio?: DoubleRange; autoGainControl?: boolean[]; channelCount?: ULongRange; - cursor?: string[]; deviceId?: string; displaySurface?: string; echoCancellation?: boolean[]; @@ -826,10 +892,7 @@ interface MediaTrackCapabilities { frameRate?: DoubleRange; groupId?: string; height?: ULongRange; - latency?: DoubleRange; - logicalSurface?: boolean; noiseSuppression?: boolean[]; - resizeMode?: string[]; sampleRate?: ULongRange; sampleSize?: ULongRange; width?: ULongRange; @@ -840,16 +903,15 @@ interface MediaTrackConstraintSet { autoGainControl?: ConstrainBoolean; channelCount?: ConstrainULong; deviceId?: ConstrainDOMString; + displaySurface?: ConstrainDOMString; echoCancellation?: ConstrainBoolean; facingMode?: ConstrainDOMString; frameRate?: ConstrainDouble; groupId?: ConstrainDOMString; height?: ConstrainULong; - latency?: ConstrainDouble; noiseSuppression?: ConstrainBoolean; sampleRate?: ConstrainULong; sampleSize?: ConstrainULong; - suppressLocalAudioPlayback?: ConstrainBoolean; width?: ConstrainULong; } @@ -860,14 +922,15 @@ interface MediaTrackConstraints extends MediaTrackConstraintSet { interface MediaTrackSettings { aspectRatio?: number; autoGainControl?: boolean; + channelCount?: number; deviceId?: string; + displaySurface?: string; echoCancellation?: boolean; facingMode?: string; frameRate?: number; groupId?: string; height?: number; noiseSuppression?: boolean; - restrictOwnAudio?: boolean; sampleRate?: number; sampleSize?: number; width?: number; @@ -876,7 +939,9 @@ interface MediaTrackSettings { interface MediaTrackSupportedConstraints { aspectRatio?: boolean; autoGainControl?: boolean; + channelCount?: boolean; deviceId?: boolean; + displaySurface?: boolean; echoCancellation?: boolean; facingMode?: boolean; frameRate?: boolean; @@ -885,7 +950,6 @@ interface MediaTrackSupportedConstraints { noiseSuppression?: boolean; sampleRate?: boolean; sampleSize?: boolean; - suppressLocalAudioPlayback?: boolean; width?: boolean; } @@ -1100,6 +1164,11 @@ interface PictureInPictureEventInit extends EventInit { pictureInPictureWindow: PictureInPictureWindow; } +interface PlaneLayout { + offset: number; + stride: number; +} + interface PointerEventInit extends MouseEventInit { coalescedEvents?: PointerEvent[]; height?: number; @@ -1136,6 +1205,13 @@ interface PromiseRejectionEventInit extends EventInit { reason?: any; } +interface PropertyDefinition { + inherits: boolean; + initialValue?: string; + name: string; + syntax?: string; +} + interface PropertyIndexedKeyframes { composite?: CompositeOperationOrAuto | CompositeOperationOrAuto[]; easing?: string | string[]; @@ -1287,6 +1363,11 @@ interface RTCIceCandidateInit { usernameFragment?: string | null; } +interface RTCIceCandidatePair { + local?: RTCIceCandidate; + remote?: RTCIceCandidate; +} + interface RTCIceCandidatePairStats extends RTCStats { availableIncomingBitrate?: number; availableOutgoingBitrate?: number; @@ -1420,19 +1501,18 @@ interface RTCRtpCapabilities { headerExtensions: RTCRtpHeaderExtensionCapability[]; } -interface RTCRtpCodecCapability { +interface RTCRtpCodec { channels?: number; clockRate: number; mimeType: string; sdpFmtpLine?: string; } -interface RTCRtpCodecParameters { - channels?: number; - clockRate: number; - mimeType: string; +interface RTCRtpCodecCapability extends RTCRtpCodec { +} + +interface RTCRtpCodecParameters extends RTCRtpCodec { payloadType: number; - sdpFmtpLine?: string; } interface RTCRtpCodingParameters { @@ -1456,7 +1536,7 @@ interface RTCRtpEncodingParameters extends RTCRtpCodingParameters { } interface RTCRtpHeaderExtensionCapability { - uri?: string; + uri: string; } interface RTCRtpHeaderExtensionParameters { @@ -1566,6 +1646,11 @@ interface RegistrationOptions { updateViaCache?: ServiceWorkerUpdateViaCache; } +interface ReportingObserverOptions { + buffered?: boolean; + types?: string[]; +} + interface RequestInit { /** A BodyInit object or null to set request's body. */ body?: BodyInit | null; @@ -1889,6 +1974,71 @@ interface VideoConfiguration { width: number; } +interface VideoDecoderConfig { + codec: string; + codedHeight?: number; + codedWidth?: number; + colorSpace?: VideoColorSpaceInit; + description?: BufferSource; + displayAspectHeight?: number; + displayAspectWidth?: number; + hardwareAcceleration?: HardwareAcceleration; + optimizeForLatency?: boolean; +} + +interface VideoDecoderInit { + error: WebCodecsErrorCallback; + output: VideoFrameOutputCallback; +} + +interface VideoDecoderSupport { + config?: VideoDecoderConfig; + supported?: boolean; +} + +interface VideoEncoderConfig { + alpha?: AlphaOption; + avc?: AvcEncoderConfig; + bitrate?: number; + bitrateMode?: VideoEncoderBitrateMode; + codec: string; + displayHeight?: number; + displayWidth?: number; + framerate?: number; + hardwareAcceleration?: HardwareAcceleration; + height: number; + latencyMode?: LatencyMode; + scalabilityMode?: string; + width: number; +} + +interface VideoEncoderEncodeOptions { + keyFrame?: boolean; +} + +interface VideoEncoderInit { + error: WebCodecsErrorCallback; + output: EncodedVideoChunkOutputCallback; +} + +interface VideoEncoderSupport { + config?: VideoEncoderConfig; + supported?: boolean; +} + +interface VideoFrameBufferInit { + codedHeight: number; + codedWidth: number; + colorSpace?: VideoColorSpaceInit; + displayHeight?: number; + displayWidth?: number; + duration?: number; + format: VideoPixelFormat; + layout?: PlaneLayout[]; + timestamp: number; + visibleRect?: DOMRectInit; +} + interface VideoFrameCallbackMetadata { captureTime?: DOMHighResTimeStamp; expectedDisplayTime: DOMHighResTimeStamp; @@ -1902,6 +2052,20 @@ interface VideoFrameCallbackMetadata { width: number; } +interface VideoFrameCopyToOptions { + layout?: PlaneLayout[]; + rect?: DOMRectInit; +} + +interface VideoFrameInit { + alpha?: AlphaOption; + displayHeight?: number; + displayWidth?: number; + duration?: number; + timestamp?: number; + visibleRect?: DOMRectInit; +} + interface WaveShaperOptions extends AudioNodeOptions { curve?: number[] | Float32Array; oversample?: OverSampleType; @@ -1944,85 +2108,145 @@ interface WorkletOptions { credentials?: RequestCredentials; } +interface WriteParams { + data?: BufferSource | Blob | string | null; + position?: number | null; + size?: number | null; + type: WriteCommandType; +} + type NodeFilter = ((node: Node) => number) | { acceptNode(node: Node): number; }; declare var NodeFilter: { - readonly FILTER_ACCEPT: number; - readonly FILTER_REJECT: number; - readonly FILTER_SKIP: number; - readonly SHOW_ALL: number; - readonly SHOW_ATTRIBUTE: number; - readonly SHOW_CDATA_SECTION: number; - readonly SHOW_COMMENT: number; - readonly SHOW_DOCUMENT: number; - readonly SHOW_DOCUMENT_FRAGMENT: number; - readonly SHOW_DOCUMENT_TYPE: number; - readonly SHOW_ELEMENT: number; - readonly SHOW_ENTITY: number; - readonly SHOW_ENTITY_REFERENCE: number; - readonly SHOW_NOTATION: number; - readonly SHOW_PROCESSING_INSTRUCTION: number; - readonly SHOW_TEXT: number; + readonly FILTER_ACCEPT: 1; + readonly FILTER_REJECT: 2; + readonly FILTER_SKIP: 3; + readonly SHOW_ALL: 0xFFFFFFFF; + readonly SHOW_ELEMENT: 0x1; + readonly SHOW_ATTRIBUTE: 0x2; + readonly SHOW_TEXT: 0x4; + readonly SHOW_CDATA_SECTION: 0x8; + readonly SHOW_ENTITY_REFERENCE: 0x10; + readonly SHOW_ENTITY: 0x20; + readonly SHOW_PROCESSING_INSTRUCTION: 0x40; + readonly SHOW_COMMENT: 0x80; + readonly SHOW_DOCUMENT: 0x100; + readonly SHOW_DOCUMENT_TYPE: 0x200; + readonly SHOW_DOCUMENT_FRAGMENT: 0x400; + readonly SHOW_NOTATION: 0x800; }; type XPathNSResolver = ((prefix: string | null) => string | null) | { lookupNamespaceURI(prefix: string | null): string | null; }; -/** The ANGLE_instanced_arrays extension is part of the WebGL API and allows to draw the same object, or groups of similar objects multiple times, if they share the same vertex data, primitive count and type. */ +/** + * The ANGLE_instanced_arrays extension is part of the WebGL API and allows to draw the same object, or groups of similar objects multiple times, if they share the same vertex data, primitive count and type. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ANGLE_instanced_arrays) + */ interface ANGLE_instanced_arrays { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ANGLE_instanced_arrays/drawArraysInstancedANGLE) */ drawArraysInstancedANGLE(mode: GLenum, first: GLint, count: GLsizei, primcount: GLsizei): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ANGLE_instanced_arrays/drawElementsInstancedANGLE) */ drawElementsInstancedANGLE(mode: GLenum, count: GLsizei, type: GLenum, offset: GLintptr, primcount: GLsizei): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ANGLE_instanced_arrays/vertexAttribDivisorANGLE) */ vertexAttribDivisorANGLE(index: GLuint, divisor: GLuint): void; - readonly VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE: GLenum; + readonly VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE: 0x88FE; } interface ARIAMixin { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/ariaAtomic) */ ariaAtomic: string | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/ariaAutoComplete) */ ariaAutoComplete: string | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/ariaBusy) */ ariaBusy: string | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/ariaChecked) */ ariaChecked: string | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/ariaColCount) */ ariaColCount: string | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/ariaColIndex) */ ariaColIndex: string | null; - ariaColIndexText: string | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/ariaColSpan) */ ariaColSpan: string | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/ariaCurrent) */ ariaCurrent: string | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/ariaDisabled) */ ariaDisabled: string | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/ariaExpanded) */ ariaExpanded: string | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/ariaHasPopup) */ ariaHasPopup: string | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/ariaHidden) */ ariaHidden: string | null; ariaInvalid: string | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/ariaKeyShortcuts) */ ariaKeyShortcuts: string | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/ariaLabel) */ ariaLabel: string | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/ariaLevel) */ ariaLevel: string | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/ariaLive) */ ariaLive: string | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/ariaModal) */ ariaModal: string | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/ariaMultiLine) */ ariaMultiLine: string | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/ariaMultiSelectable) */ ariaMultiSelectable: string | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/ariaOrientation) */ ariaOrientation: string | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/ariaPlaceholder) */ ariaPlaceholder: string | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/ariaPosInSet) */ ariaPosInSet: string | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/ariaPressed) */ ariaPressed: string | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/ariaReadOnly) */ ariaReadOnly: string | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/ariaRequired) */ ariaRequired: string | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/ariaRoleDescription) */ ariaRoleDescription: string | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/ariaRowCount) */ ariaRowCount: string | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/ariaRowIndex) */ ariaRowIndex: string | null; - ariaRowIndexText: string | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/ariaRowSpan) */ ariaRowSpan: string | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/ariaSelected) */ ariaSelected: string | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/ariaSetSize) */ ariaSetSize: string | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/ariaSort) */ ariaSort: string | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/ariaValueMax) */ ariaValueMax: string | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/ariaValueMin) */ ariaValueMin: string | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/ariaValueNow) */ ariaValueNow: string | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/ariaValueText) */ ariaValueText: string | null; role: string | null; } -/** A controller object that allows you to abort one or more DOM requests as and when desired. */ +/** + * A controller object that allows you to abort one or more DOM requests as and when desired. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController) + */ interface AbortController { - /** Returns the AbortSignal object associated with this object. */ + /** + * Returns the AbortSignal object associated with this object. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController/signal) + */ readonly signal: AbortSignal; - /** Invoking this method will set this object's AbortSignal's aborted flag and signal to any observers that the associated activity is to be aborted. */ + /** + * Invoking this method will set this object's AbortSignal's aborted flag and signal to any observers that the associated activity is to be aborted. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController/abort) + */ abort(reason?: any): void; } @@ -2035,12 +2259,23 @@ interface AbortSignalEventMap { "abort": Event; } -/** A signal object that allows you to communicate with a DOM request (such as a Fetch) and abort it if required via an AbortController object. */ +/** + * A signal object that allows you to communicate with a DOM request (such as a Fetch) and abort it if required via an AbortController object. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal) + */ interface AbortSignal extends EventTarget { - /** Returns true if this AbortSignal's AbortController has signaled to abort, and false otherwise. */ + /** + * Returns true if this AbortSignal's AbortController has signaled to abort, and false otherwise. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/aborted) + */ readonly aborted: boolean; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_event) */ onabort: ((this: AbortSignal, ev: Event) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/reason) */ readonly reason: any; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/throwIfAborted) */ throwIfAborted(): void; addEventListener(type: K, listener: (this: AbortSignal, ev: AbortSignalEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; @@ -2051,20 +2286,43 @@ interface AbortSignal extends EventTarget { declare var AbortSignal: { prototype: AbortSignal; new(): AbortSignal; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort) */ abort(reason?: any): AbortSignal; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/timeout) */ timeout(milliseconds: number): AbortSignal; }; +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbstractRange) */ interface AbstractRange { - /** Returns true if range is collapsed, and false otherwise. */ + /** + * Returns true if range is collapsed, and false otherwise. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbstractRange/collapsed) + */ readonly collapsed: boolean; - /** Returns range's end node. */ + /** + * Returns range's end node. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbstractRange/endContainer) + */ readonly endContainer: Node; - /** Returns range's end offset. */ + /** + * Returns range's end offset. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbstractRange/endOffset) + */ readonly endOffset: number; - /** Returns range's start node. */ + /** + * Returns range's start node. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbstractRange/startContainer) + */ readonly startContainer: Node; - /** Returns range's start offset. */ + /** + * Returns range's start offset. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbstractRange/startOffset) + */ readonly startOffset: number; } @@ -2078,6 +2336,7 @@ interface AbstractWorkerEventMap { } interface AbstractWorker { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ServiceWorker/error_event) */ onerror: ((this: AbstractWorker, ev: ErrorEvent) => any) | null; addEventListener(type: K, listener: (this: AbstractWorker, ev: AbstractWorkerEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; @@ -2085,16 +2344,29 @@ interface AbstractWorker { removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; } -/** A node able to provide real-time frequency and time-domain analysis information. It is an AudioNode that passes the audio stream unchanged from the input to the output, but allows you to take the generated data, process it, and create audio visualizations. */ +/** + * A node able to provide real-time frequency and time-domain analysis information. It is an AudioNode that passes the audio stream unchanged from the input to the output, but allows you to take the generated data, process it, and create audio visualizations. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AnalyserNode) + */ interface AnalyserNode extends AudioNode { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AnalyserNode/fftSize) */ fftSize: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AnalyserNode/frequencyBinCount) */ readonly frequencyBinCount: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AnalyserNode/maxDecibels) */ maxDecibels: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AnalyserNode/minDecibels) */ minDecibels: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AnalyserNode/smoothingTimeConstant) */ smoothingTimeConstant: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AnalyserNode/getByteFrequencyData) */ getByteFrequencyData(array: Uint8Array): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AnalyserNode/getByteTimeDomainData) */ getByteTimeDomainData(array: Uint8Array): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AnalyserNode/getFloatFrequencyData) */ getFloatFrequencyData(array: Float32Array): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AnalyserNode/getFloatTimeDomainData) */ getFloatTimeDomainData(array: Float32Array): void; } @@ -2104,7 +2376,9 @@ declare var AnalyserNode: { }; interface Animatable { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/animate) */ animate(keyframes: Keyframe[] | PropertyIndexedKeyframes | null, options?: number | KeyframeAnimationOptions): Animation; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/getAnimations) */ getAnimations(options?: GetAnimationsOptions): Animation[]; } @@ -2114,28 +2388,51 @@ interface AnimationEventMap { "remove": Event; } +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Animation) */ interface Animation extends EventTarget { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Animation/currentTime) */ currentTime: CSSNumberish | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Animation/effect) */ effect: AnimationEffect | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Animation/finished) */ readonly finished: Promise; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Animation/id) */ id: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Animation/cancel_event) */ oncancel: ((this: Animation, ev: AnimationPlaybackEvent) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Animation/finish_event) */ onfinish: ((this: Animation, ev: AnimationPlaybackEvent) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Animation/remove_event) */ onremove: ((this: Animation, ev: Event) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Animation/pending) */ readonly pending: boolean; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Animation/playState) */ readonly playState: AnimationPlayState; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Animation/playbackRate) */ playbackRate: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Animation/ready) */ readonly ready: Promise; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Animation/replaceState) */ readonly replaceState: AnimationReplaceState; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Animation/startTime) */ startTime: CSSNumberish | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Animation/timeline) */ timeline: AnimationTimeline | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Animation/cancel) */ cancel(): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Animation/commitStyles) */ commitStyles(): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Animation/finish) */ finish(): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Animation/pause) */ pause(): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Animation/persist) */ persist(): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Animation/play) */ play(): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Animation/reverse) */ reverse(): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Animation/updatePlaybackRate) */ updatePlaybackRate(playbackRate: number): void; addEventListener(type: K, listener: (this: Animation, ev: AnimationEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; @@ -2148,9 +2445,13 @@ declare var Animation: { new(effect?: AnimationEffect | null, timeline?: AnimationTimeline | null): Animation; }; +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AnimationEffect) */ interface AnimationEffect { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AnimationEffect/getComputedTiming) */ getComputedTiming(): ComputedEffectTiming; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AnimationEffect/getTiming) */ getTiming(): EffectTiming; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AnimationEffect/updateTiming) */ updateTiming(timing?: OptionalEffectTiming): void; } @@ -2159,10 +2460,17 @@ declare var AnimationEffect: { new(): AnimationEffect; }; -/** Events providing information related to animations. */ +/** + * Events providing information related to animations. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AnimationEvent) + */ interface AnimationEvent extends Event { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AnimationEvent/animationName) */ readonly animationName: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AnimationEvent/elapsedTime) */ readonly elapsedTime: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AnimationEvent/pseudoElement) */ readonly pseudoElement: string; } @@ -2176,8 +2484,11 @@ interface AnimationFrameProvider { requestAnimationFrame(callback: FrameRequestCallback): number; } +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AnimationPlaybackEvent) */ interface AnimationPlaybackEvent extends Event { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AnimationPlaybackEvent/currentTime) */ readonly currentTime: CSSNumberish | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AnimationPlaybackEvent/timelineTime) */ readonly timelineTime: CSSNumberish | null; } @@ -2186,7 +2497,9 @@ declare var AnimationPlaybackEvent: { new(type: string, eventInitDict?: AnimationPlaybackEventInit): AnimationPlaybackEvent; }; +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AnimationTimeline) */ interface AnimationTimeline { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AnimationTimeline/currentTime) */ readonly currentTime: CSSNumberish | null; } @@ -2195,16 +2508,30 @@ declare var AnimationTimeline: { new(): AnimationTimeline; }; -/** A DOM element's attribute as an object. In most DOM methods, you will probably directly retrieve the attribute as a string (e.g., Element.getAttribute(), but certain functions (e.g., Element.getAttributeNode()) or means of iterating give Attr types. */ +/** + * A DOM element's attribute as an object. In most DOM methods, you will probably directly retrieve the attribute as a string (e.g., Element.getAttribute(), but certain functions (e.g., Element.getAttributeNode()) or means of iterating give Attr types. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Attr) + */ interface Attr extends Node { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Attr/localName) */ readonly localName: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Attr/name) */ readonly name: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Attr/namespaceURI) */ readonly namespaceURI: string | null; readonly ownerDocument: Document; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Attr/ownerElement) */ readonly ownerElement: Element | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Attr/prefix) */ readonly prefix: string | null; - /** @deprecated */ + /** + * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Attr/specified) + */ readonly specified: boolean; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Attr/value) */ value: string; } @@ -2213,14 +2540,25 @@ declare var Attr: { new(): Attr; }; -/** A short audio asset residing in memory, created from an audio file using the AudioContext.decodeAudioData() method, or from raw data using AudioContext.createBuffer(). Once put into an AudioBuffer, the audio can then be played by being passed into an AudioBufferSourceNode. */ +/** + * A short audio asset residing in memory, created from an audio file using the AudioContext.decodeAudioData() method, or from raw data using AudioContext.createBuffer(). Once put into an AudioBuffer, the audio can then be played by being passed into an AudioBufferSourceNode. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioBuffer) + */ interface AudioBuffer { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioBuffer/duration) */ readonly duration: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioBuffer/length) */ readonly length: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioBuffer/numberOfChannels) */ readonly numberOfChannels: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioBuffer/sampleRate) */ readonly sampleRate: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioBuffer/copyFromChannel) */ copyFromChannel(destination: Float32Array, channelNumber: number, bufferOffset?: number): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioBuffer/copyToChannel) */ copyToChannel(source: Float32Array, channelNumber: number, bufferOffset?: number): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioBuffer/getChannelData) */ getChannelData(channel: number): Float32Array; } @@ -2229,14 +2567,25 @@ declare var AudioBuffer: { new(options: AudioBufferOptions): AudioBuffer; }; -/** An AudioScheduledSourceNode which represents an audio source consisting of in-memory audio data, stored in an AudioBuffer. It's especially useful for playing back audio which has particularly stringent timing accuracy requirements, such as for sounds that must match a specific rhythm and can be kept in memory rather than being played from disk or the network. */ +/** + * An AudioScheduledSourceNode which represents an audio source consisting of in-memory audio data, stored in an AudioBuffer. It's especially useful for playing back audio which has particularly stringent timing accuracy requirements, such as for sounds that must match a specific rhythm and can be kept in memory rather than being played from disk or the network. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioBufferSourceNode) + */ interface AudioBufferSourceNode extends AudioScheduledSourceNode { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioBufferSourceNode/buffer) */ buffer: AudioBuffer | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioBufferSourceNode/detune) */ readonly detune: AudioParam; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioBufferSourceNode/loop) */ loop: boolean; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioBufferSourceNode/loopEnd) */ loopEnd: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioBufferSourceNode/loopStart) */ loopStart: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioBufferSourceNode/playbackRate) */ readonly playbackRate: AudioParam; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioBufferSourceNode/start) */ start(when?: number, offset?: number, duration?: number): void; addEventListener(type: K, listener: (this: AudioBufferSourceNode, ev: AudioScheduledSourceNodeEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; @@ -2249,16 +2598,29 @@ declare var AudioBufferSourceNode: { new(context: BaseAudioContext, options?: AudioBufferSourceOptions): AudioBufferSourceNode; }; -/** An audio-processing graph built from audio modules linked together, each represented by an AudioNode. */ +/** + * An audio-processing graph built from audio modules linked together, each represented by an AudioNode. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioContext) + */ interface AudioContext extends BaseAudioContext { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioContext/baseLatency) */ readonly baseLatency: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioContext/outputLatency) */ readonly outputLatency: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioContext/close) */ close(): Promise; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioContext/createMediaElementSource) */ createMediaElementSource(mediaElement: HTMLMediaElement): MediaElementAudioSourceNode; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioContext/createMediaStreamDestination) */ createMediaStreamDestination(): MediaStreamAudioDestinationNode; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioContext/createMediaStreamSource) */ createMediaStreamSource(mediaStream: MediaStream): MediaStreamAudioSourceNode; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioContext/getOutputTimestamp) */ getOutputTimestamp(): AudioTimestamp; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioContext/resume) */ resume(): Promise; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioContext/suspend) */ suspend(): Promise; addEventListener(type: K, listener: (this: AudioContext, ev: BaseAudioContextEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; @@ -2271,8 +2633,13 @@ declare var AudioContext: { new(contextOptions?: AudioContextOptions): AudioContext; }; -/** AudioDestinationNode has no output (as it is the output, no more AudioNode can be linked after it in the audio graph) and one input. The number of channels in the input must be between 0 and the maxChannelCount value or an exception is raised. */ +/** + * AudioDestinationNode has no output (as it is the output, no more AudioNode can be linked after it in the audio graph) and one input. The number of channels in the input must be between 0 and the maxChannelCount value or an exception is raised. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioDestinationNode) + */ interface AudioDestinationNode extends AudioNode { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioDestinationNode/maxChannelCount) */ readonly maxChannelCount: number; } @@ -2281,20 +2648,41 @@ declare var AudioDestinationNode: { new(): AudioDestinationNode; }; -/** The position and orientation of the unique person listening to the audio scene, and is used in audio spatialization. All PannerNodes spatialize in relation to the AudioListener stored in the BaseAudioContext.listener attribute. */ +/** + * The position and orientation of the unique person listening to the audio scene, and is used in audio spatialization. All PannerNodes spatialize in relation to the AudioListener stored in the BaseAudioContext.listener attribute. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioListener) + */ interface AudioListener { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioListener/forwardX) */ readonly forwardX: AudioParam; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioListener/forwardY) */ readonly forwardY: AudioParam; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioListener/forwardZ) */ readonly forwardZ: AudioParam; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioListener/positionX) */ readonly positionX: AudioParam; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioListener/positionY) */ readonly positionY: AudioParam; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioListener/positionZ) */ readonly positionZ: AudioParam; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioListener/upX) */ readonly upX: AudioParam; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioListener/upY) */ readonly upY: AudioParam; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioListener/upZ) */ readonly upZ: AudioParam; - /** @deprecated */ + /** + * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioListener/setOrientation) + */ setOrientation(x: number, y: number, z: number, xUp: number, yUp: number, zUp: number): void; - /** @deprecated */ + /** + * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioListener/setPosition) + */ setPosition(x: number, y: number, z: number): void; } @@ -2303,16 +2691,28 @@ declare var AudioListener: { new(): AudioListener; }; -/** A generic interface for representing an audio processing module. Examples include: */ +/** + * A generic interface for representing an audio processing module. Examples include: + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioNode) + */ interface AudioNode extends EventTarget { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioNode/channelCount) */ channelCount: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioNode/channelCountMode) */ channelCountMode: ChannelCountMode; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioNode/channelInterpretation) */ channelInterpretation: ChannelInterpretation; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioNode/context) */ readonly context: BaseAudioContext; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioNode/numberOfInputs) */ readonly numberOfInputs: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioNode/numberOfOutputs) */ readonly numberOfOutputs: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioNode/connect) */ connect(destinationNode: AudioNode, output?: number, input?: number): AudioNode; connect(destinationParam: AudioParam, output?: number): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioNode/disconnect) */ disconnect(): void; disconnect(output: number): void; disconnect(destinationNode: AudioNode): void; @@ -2327,19 +2727,35 @@ declare var AudioNode: { new(): AudioNode; }; -/** The Web Audio API's AudioParam interface represents an audio-related parameter, usually a parameter of an AudioNode (such as GainNode.gain). */ +/** + * The Web Audio API's AudioParam interface represents an audio-related parameter, usually a parameter of an AudioNode (such as GainNode.gain). + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioParam) + */ interface AudioParam { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioParam/automationRate) */ automationRate: AutomationRate; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioParam/defaultValue) */ readonly defaultValue: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioParam/maxValue) */ readonly maxValue: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioParam/minValue) */ readonly minValue: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioParam/value) */ value: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioParam/cancelAndHoldAtTime) */ cancelAndHoldAtTime(cancelTime: number): AudioParam; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioParam/cancelScheduledValues) */ cancelScheduledValues(cancelTime: number): AudioParam; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioParam/exponentialRampToValueAtTime) */ exponentialRampToValueAtTime(value: number, endTime: number): AudioParam; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioParam/linearRampToValueAtTime) */ linearRampToValueAtTime(value: number, endTime: number): AudioParam; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioParam/setTargetAtTime) */ setTargetAtTime(target: number, startTime: number, timeConstant: number): AudioParam; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioParam/setValueAtTime) */ setValueAtTime(value: number, startTime: number): AudioParam; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioParam/setValueCurveAtTime) */ setValueCurveAtTime(values: number[] | Float32Array, startTime: number, duration: number): AudioParam; } @@ -2348,6 +2764,7 @@ declare var AudioParam: { new(): AudioParam; }; +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioParamMap) */ interface AudioParamMap { forEach(callbackfn: (value: AudioParam, key: string, parent: AudioParamMap) => void, thisArg?: any): void; } @@ -2360,13 +2777,27 @@ declare var AudioParamMap: { /** * The Web Audio API events that occur when a ScriptProcessorNode input buffer is ready to be processed. * @deprecated As of the August 29 2014 Web Audio API spec publication, this feature has been marked as deprecated, and is soon to be replaced by AudioWorklet. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioProcessingEvent) */ interface AudioProcessingEvent extends Event { - /** @deprecated */ + /** + * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioProcessingEvent/inputBuffer) + */ readonly inputBuffer: AudioBuffer; - /** @deprecated */ + /** + * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioProcessingEvent/outputBuffer) + */ readonly outputBuffer: AudioBuffer; - /** @deprecated */ + /** + * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioProcessingEvent/playbackTime) + */ readonly playbackTime: number; } @@ -2380,9 +2811,13 @@ interface AudioScheduledSourceNodeEventMap { "ended": Event; } +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioScheduledSourceNode) */ interface AudioScheduledSourceNode extends AudioNode { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioScheduledSourceNode/ended_event) */ onended: ((this: AudioScheduledSourceNode, ev: Event) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioScheduledSourceNode/start) */ start(when?: number): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioScheduledSourceNode/stop) */ stop(when?: number): void; addEventListener(type: K, listener: (this: AudioScheduledSourceNode, ev: AudioScheduledSourceNodeEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; @@ -2395,7 +2830,11 @@ declare var AudioScheduledSourceNode: { new(): AudioScheduledSourceNode; }; -/** Available only in secure contexts. */ +/** + * Available only in secure contexts. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioWorklet) + */ interface AudioWorklet extends Worklet { } @@ -2408,10 +2847,17 @@ interface AudioWorkletNodeEventMap { "processorerror": Event; } -/** Available only in secure contexts. */ +/** + * Available only in secure contexts. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioWorkletNode) + */ interface AudioWorkletNode extends AudioNode { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioWorkletNode/processorerror_event) */ onprocessorerror: ((this: AudioWorkletNode, ev: Event) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioWorkletNode/parameters) */ readonly parameters: AudioParamMap; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioWorkletNode/port) */ readonly port: MessagePort; addEventListener(type: K, listener: (this: AudioWorkletNode, ev: AudioWorkletNodeEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; @@ -2424,10 +2870,17 @@ declare var AudioWorkletNode: { new(context: BaseAudioContext, name: string, options?: AudioWorkletNodeOptions): AudioWorkletNode; }; -/** Available only in secure contexts. */ +/** + * Available only in secure contexts. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AuthenticatorAssertionResponse) + */ interface AuthenticatorAssertionResponse extends AuthenticatorResponse { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AuthenticatorAssertionResponse/authenticatorData) */ readonly authenticatorData: ArrayBuffer; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AuthenticatorAssertionResponse/signature) */ readonly signature: ArrayBuffer; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AuthenticatorAssertionResponse/userHandle) */ readonly userHandle: ArrayBuffer | null; } @@ -2436,12 +2889,18 @@ declare var AuthenticatorAssertionResponse: { new(): AuthenticatorAssertionResponse; }; -/** Available only in secure contexts. */ +/** + * Available only in secure contexts. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AuthenticatorAttestationResponse) + */ interface AuthenticatorAttestationResponse extends AuthenticatorResponse { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AuthenticatorAttestationResponse/attestationObject) */ readonly attestationObject: ArrayBuffer; getAuthenticatorData(): ArrayBuffer; getPublicKey(): ArrayBuffer | null; getPublicKeyAlgorithm(): COSEAlgorithmIdentifier; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AuthenticatorAttestationResponse/getTransports) */ getTransports(): string[]; } @@ -2450,8 +2909,13 @@ declare var AuthenticatorAttestationResponse: { new(): AuthenticatorAttestationResponse; }; -/** Available only in secure contexts. */ +/** + * Available only in secure contexts. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AuthenticatorResponse) + */ interface AuthenticatorResponse { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AuthenticatorResponse/clientDataJSON) */ readonly clientDataJSON: ArrayBuffer; } @@ -2460,7 +2924,9 @@ declare var AuthenticatorResponse: { new(): AuthenticatorResponse; }; +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/BarProp) */ interface BarProp { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/BarProp/visible) */ readonly visible: boolean; } @@ -2473,34 +2939,67 @@ interface BaseAudioContextEventMap { "statechange": Event; } +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/BaseAudioContext) */ interface BaseAudioContext extends EventTarget { - /** Available only in secure contexts. */ + /** + * Available only in secure contexts. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/BaseAudioContext/audioWorklet) + */ readonly audioWorklet: AudioWorklet; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/BaseAudioContext/currentTime) */ readonly currentTime: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/BaseAudioContext/destination) */ readonly destination: AudioDestinationNode; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/BaseAudioContext/listener) */ readonly listener: AudioListener; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/BaseAudioContext/statechange_event) */ onstatechange: ((this: BaseAudioContext, ev: Event) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/BaseAudioContext/sampleRate) */ readonly sampleRate: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/BaseAudioContext/state) */ readonly state: AudioContextState; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/BaseAudioContext/createAnalyser) */ createAnalyser(): AnalyserNode; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/BaseAudioContext/createBiquadFilter) */ createBiquadFilter(): BiquadFilterNode; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/BaseAudioContext/createBuffer) */ createBuffer(numberOfChannels: number, length: number, sampleRate: number): AudioBuffer; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/BaseAudioContext/createBufferSource) */ createBufferSource(): AudioBufferSourceNode; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/BaseAudioContext/createChannelMerger) */ createChannelMerger(numberOfInputs?: number): ChannelMergerNode; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/BaseAudioContext/createChannelSplitter) */ createChannelSplitter(numberOfOutputs?: number): ChannelSplitterNode; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/BaseAudioContext/createConstantSource) */ createConstantSource(): ConstantSourceNode; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/BaseAudioContext/createConvolver) */ createConvolver(): ConvolverNode; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/BaseAudioContext/createDelay) */ createDelay(maxDelayTime?: number): DelayNode; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/BaseAudioContext/createDynamicsCompressor) */ createDynamicsCompressor(): DynamicsCompressorNode; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/BaseAudioContext/createGain) */ createGain(): GainNode; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/BaseAudioContext/createIIRFilter) */ createIIRFilter(feedforward: number[], feedback: number[]): IIRFilterNode; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/BaseAudioContext/createOscillator) */ createOscillator(): OscillatorNode; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/BaseAudioContext/createPanner) */ createPanner(): PannerNode; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/BaseAudioContext/createPeriodicWave) */ createPeriodicWave(real: number[] | Float32Array, imag: number[] | Float32Array, constraints?: PeriodicWaveConstraints): PeriodicWave; - /** @deprecated */ + /** + * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/BaseAudioContext/createScriptProcessor) + */ createScriptProcessor(bufferSize?: number, numberOfInputChannels?: number, numberOfOutputChannels?: number): ScriptProcessorNode; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/BaseAudioContext/createStereoPanner) */ createStereoPanner(): StereoPannerNode; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/BaseAudioContext/createWaveShaper) */ createWaveShaper(): WaveShaperNode; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/BaseAudioContext/decodeAudioData) */ decodeAudioData(audioData: ArrayBuffer, successCallback?: DecodeSuccessCallback | null, errorCallback?: DecodeErrorCallback | null): Promise; addEventListener(type: K, listener: (this: BaseAudioContext, ev: BaseAudioContextEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; @@ -2513,7 +3012,11 @@ declare var BaseAudioContext: { new(): BaseAudioContext; }; -/** The beforeunload event is fired when the window, the document and its resources are about to be unloaded. */ +/** + * The beforeunload event is fired when the window, the document and its resources are about to be unloaded. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/BeforeUnloadEvent) + */ interface BeforeUnloadEvent extends Event { returnValue: any; } @@ -2523,13 +3026,23 @@ declare var BeforeUnloadEvent: { new(): BeforeUnloadEvent; }; -/** A simple low-order filter, and is created using the AudioContext.createBiquadFilter() method. It is an AudioNode that can represent different kinds of filters, tone control devices, and graphic equalizers. */ +/** + * A simple low-order filter, and is created using the AudioContext.createBiquadFilter() method. It is an AudioNode that can represent different kinds of filters, tone control devices, and graphic equalizers. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/BiquadFilterNode) + */ interface BiquadFilterNode extends AudioNode { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/BiquadFilterNode/Q) */ readonly Q: AudioParam; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/BiquadFilterNode/detune) */ readonly detune: AudioParam; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/BiquadFilterNode/frequency) */ readonly frequency: AudioParam; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/BiquadFilterNode/gain) */ readonly gain: AudioParam; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/BiquadFilterNode/type) */ type: BiquadFilterType; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/BiquadFilterNode/getFrequencyResponse) */ getFrequencyResponse(frequencyHz: Float32Array, magResponse: Float32Array, phaseResponse: Float32Array): void; } @@ -2538,13 +3051,23 @@ declare var BiquadFilterNode: { new(context: BaseAudioContext, options?: BiquadFilterOptions): BiquadFilterNode; }; -/** A file-like object of immutable, raw data. Blobs represent data that isn't necessarily in a JavaScript-native format. The File interface is based on Blob, inheriting blob functionality and expanding it to support files on the user's system. */ +/** + * A file-like object of immutable, raw data. Blobs represent data that isn't necessarily in a JavaScript-native format. The File interface is based on Blob, inheriting blob functionality and expanding it to support files on the user's system. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob) + */ interface Blob { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/size) */ readonly size: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/type) */ readonly type: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/arrayBuffer) */ arrayBuffer(): Promise; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/slice) */ slice(start?: number, end?: number, contentType?: string): Blob; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/stream) */ stream(): ReadableStream; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/text) */ text(): Promise; } @@ -2553,8 +3076,11 @@ declare var Blob: { new(blobParts?: BlobPart[], options?: BlobPropertyBag): Blob; }; +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/BlobEvent) */ interface BlobEvent extends Event { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/BlobEvent/data) */ readonly data: Blob; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/BlobEvent/timecode) */ readonly timecode: DOMHighResTimeStamp; } @@ -2564,12 +3090,19 @@ declare var BlobEvent: { }; interface Body { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/body) */ readonly body: ReadableStream | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bodyUsed) */ readonly bodyUsed: boolean; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/arrayBuffer) */ arrayBuffer(): Promise; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/blob) */ blob(): Promise; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/formData) */ formData(): Promise; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/json) */ json(): Promise; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/text) */ text(): Promise; } @@ -2578,14 +3111,29 @@ interface BroadcastChannelEventMap { "messageerror": MessageEvent; } +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/BroadcastChannel) */ interface BroadcastChannel extends EventTarget { - /** Returns the channel name (as passed to the constructor). */ + /** + * Returns the channel name (as passed to the constructor). + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/BroadcastChannel/name) + */ readonly name: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/BroadcastChannel/message_event) */ onmessage: ((this: BroadcastChannel, ev: MessageEvent) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/BroadcastChannel/messageerror_event) */ onmessageerror: ((this: BroadcastChannel, ev: MessageEvent) => any) | null; - /** Closes the BroadcastChannel object, opening it up to garbage collection. */ + /** + * Closes the BroadcastChannel object, opening it up to garbage collection. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/BroadcastChannel/close) + */ close(): void; - /** Sends the given message to other BroadcastChannel objects set up for this channel. Messages can be structured objects, e.g. nested objects and arrays. */ + /** + * Sends the given message to other BroadcastChannel objects set up for this channel. Messages can be structured objects, e.g. nested objects and arrays. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/BroadcastChannel/postMessage) + */ postMessage(message: any): void; addEventListener(type: K, listener: (this: BroadcastChannel, ev: BroadcastChannelEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; @@ -2598,9 +3146,15 @@ declare var BroadcastChannel: { new(name: string): BroadcastChannel; }; -/** This Streams API interface provides a built-in byte length queuing strategy that can be used when constructing streams. */ +/** + * This Streams API interface provides a built-in byte length queuing strategy that can be used when constructing streams. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ByteLengthQueuingStrategy) + */ interface ByteLengthQueuingStrategy extends QueuingStrategy { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ByteLengthQueuingStrategy/highWaterMark) */ readonly highWaterMark: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ByteLengthQueuingStrategy/size) */ readonly size: QueuingStrategySize; } @@ -2609,7 +3163,11 @@ declare var ByteLengthQueuingStrategy: { new(init: QueuingStrategyInit): ByteLengthQueuingStrategy; }; -/** A CDATA section that can be used within XML to include extended portions of unescaped text. The symbols < and & don’t need escaping as they normally do when inside a CDATA section. */ +/** + * A CDATA section that can be used within XML to include extended portions of unescaped text. The symbols < and & don’t need escaping as they normally do when inside a CDATA section. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CDATASection) + */ interface CDATASection extends Text { } @@ -2618,7 +3176,9 @@ declare var CDATASection: { new(): CDATASection; }; +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSAnimation) */ interface CSSAnimation extends Animation { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSAnimation/animationName) */ readonly animationName: string; addEventListener(type: K, listener: (this: CSSAnimation, ev: AnimationEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; @@ -2631,8 +3191,13 @@ declare var CSSAnimation: { new(): CSSAnimation; }; -/** A single condition CSS at-rule, which consists of a condition and a statement block. It is a child of CSSGroupingRule. */ +/** + * A single condition CSS at-rule, which consists of a condition and a statement block. It is a child of CSSGroupingRule. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSConditionRule) + */ interface CSSConditionRule extends CSSGroupingRule { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSConditionRule/conditionText) */ readonly conditionText: string; } @@ -2641,7 +3206,12 @@ declare var CSSConditionRule: { new(): CSSConditionRule; }; +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSContainerRule) */ interface CSSContainerRule extends CSSConditionRule { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSContainerRule/containerName) */ + readonly containerName: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSContainerRule/containerQuery) */ + readonly containerQuery: string; } declare var CSSContainerRule: { @@ -2649,17 +3219,29 @@ declare var CSSContainerRule: { new(): CSSContainerRule; }; +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSCounterStyleRule) */ interface CSSCounterStyleRule extends CSSRule { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSCounterStyleRule/additiveSymbols) */ additiveSymbols: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSCounterStyleRule/fallback) */ fallback: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSCounterStyleRule/name) */ name: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSCounterStyleRule/negative) */ negative: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSCounterStyleRule/pad) */ pad: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSCounterStyleRule/prefix) */ prefix: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSCounterStyleRule/range) */ range: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSCounterStyleRule/speakAs) */ speakAs: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSCounterStyleRule/suffix) */ suffix: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSCounterStyleRule/symbols) */ symbols: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSCounterStyleRule/system) */ system: string; } @@ -2668,7 +3250,9 @@ declare var CSSCounterStyleRule: { new(): CSSCounterStyleRule; }; +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSFontFaceRule) */ interface CSSFontFaceRule extends CSSRule { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSFontFaceRule/style) */ readonly style: CSSStyleDeclaration; } @@ -2677,10 +3261,26 @@ declare var CSSFontFaceRule: { new(): CSSFontFaceRule; }; +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSFontFeatureValuesRule) */ +interface CSSFontFeatureValuesRule extends CSSRule { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSFontFeatureValuesRule/fontFamily) */ + fontFamily: string; +} + +declare var CSSFontFeatureValuesRule: { + prototype: CSSFontFeatureValuesRule; + new(): CSSFontFeatureValuesRule; +}; + +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSFontPaletteValuesRule) */ interface CSSFontPaletteValuesRule extends CSSRule { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSFontPaletteValuesRule/basePalette) */ readonly basePalette: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSFontPaletteValuesRule/fontFamily) */ readonly fontFamily: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSFontPaletteValuesRule/name) */ readonly name: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSFontPaletteValuesRule/overrideColors) */ readonly overrideColors: string; } @@ -2689,10 +3289,17 @@ declare var CSSFontPaletteValuesRule: { new(): CSSFontPaletteValuesRule; }; -/** Any CSS at-rule that contains other rules nested within it. */ +/** + * Any CSS at-rule that contains other rules nested within it. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSGroupingRule) + */ interface CSSGroupingRule extends CSSRule { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSGroupingRule/cssRules) */ readonly cssRules: CSSRuleList; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSGroupingRule/deleteRule) */ deleteRule(index: number): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSGroupingRule/insertRule) */ insertRule(rule: string, index?: number): number; } @@ -2701,10 +3308,24 @@ declare var CSSGroupingRule: { new(): CSSGroupingRule; }; +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSImageValue) */ +interface CSSImageValue extends CSSStyleValue { +} + +declare var CSSImageValue: { + prototype: CSSImageValue; + new(): CSSImageValue; +}; + +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSImportRule) */ interface CSSImportRule extends CSSRule { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSImportRule/href) */ readonly href: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSImportRule/layerName) */ readonly layerName: string | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSImportRule/media) */ readonly media: MediaList; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSImportRule/styleSheet) */ readonly styleSheet: CSSStyleSheet; } @@ -2713,9 +3334,15 @@ declare var CSSImportRule: { new(): CSSImportRule; }; -/** An object representing a set of style for a given keyframe. It corresponds to the contains of a single keyframe of a @keyframes at-rule. It implements the CSSRule interface with a type value of 8 (CSSRule.KEYFRAME_RULE). */ +/** + * An object representing a set of style for a given keyframe. It corresponds to the contains of a single keyframe of a @keyframes at-rule. It implements the CSSRule interface with a type value of 8 (CSSRule.KEYFRAME_RULE). + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSKeyframeRule) + */ interface CSSKeyframeRule extends CSSRule { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSKeyframeRule/keyText) */ keyText: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSKeyframeRule/style) */ readonly style: CSSStyleDeclaration; } @@ -2724,13 +3351,23 @@ declare var CSSKeyframeRule: { new(): CSSKeyframeRule; }; -/** An object representing a complete set of keyframes for a CSS animation. It corresponds to the contains of a whole @keyframes at-rule. It implements the CSSRule interface with a type value of 7 (CSSRule.KEYFRAMES_RULE). */ +/** + * An object representing a complete set of keyframes for a CSS animation. It corresponds to the contains of a whole @keyframes at-rule. It implements the CSSRule interface with a type value of 7 (CSSRule.KEYFRAMES_RULE). + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSKeyframesRule) + */ interface CSSKeyframesRule extends CSSRule { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSKeyframesRule/cssRules) */ readonly cssRules: CSSRuleList; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSKeyframesRule/name) */ name: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSKeyframesRule/appendRule) */ appendRule(rule: string): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSKeyframesRule/deleteRule) */ deleteRule(select: string): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSKeyframesRule/findRule) */ findRule(select: string): CSSKeyframeRule | null; + [index: number]: CSSKeyframeRule; } declare var CSSKeyframesRule: { @@ -2738,7 +3375,20 @@ declare var CSSKeyframesRule: { new(): CSSKeyframesRule; }; +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSKeywordValue) */ +interface CSSKeywordValue extends CSSStyleValue { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSKeywordValue/value) */ + value: string; +} + +declare var CSSKeywordValue: { + prototype: CSSKeywordValue; + new(value: string): CSSKeywordValue; +}; + +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSLayerBlockRule) */ interface CSSLayerBlockRule extends CSSGroupingRule { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSLayerBlockRule/name) */ readonly name: string; } @@ -2747,7 +3397,9 @@ declare var CSSLayerBlockRule: { new(): CSSLayerBlockRule; }; +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSLayerStatementRule) */ interface CSSLayerStatementRule extends CSSRule { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSLayerStatementRule/nameList) */ readonly nameList: ReadonlyArray; } @@ -2756,8 +3408,112 @@ declare var CSSLayerStatementRule: { new(): CSSLayerStatementRule; }; -/** A single CSS @media rule. It implements the CSSConditionRule interface, and therefore the CSSGroupingRule and the CSSRule interface with a type value of 4 (CSSRule.MEDIA_RULE). */ -interface CSSMediaRule extends CSSConditionRule { +interface CSSMathClamp extends CSSMathValue { + readonly lower: CSSNumericValue; + readonly upper: CSSNumericValue; + readonly value: CSSNumericValue; +} + +declare var CSSMathClamp: { + prototype: CSSMathClamp; + new(lower: CSSNumberish, value: CSSNumberish, upper: CSSNumberish): CSSMathClamp; +}; + +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSMathInvert) */ +interface CSSMathInvert extends CSSMathValue { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSMathInvert/value) */ + readonly value: CSSNumericValue; +} + +declare var CSSMathInvert: { + prototype: CSSMathInvert; + new(arg: CSSNumberish): CSSMathInvert; +}; + +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSMathMax) */ +interface CSSMathMax extends CSSMathValue { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSMathMax/values) */ + readonly values: CSSNumericArray; +} + +declare var CSSMathMax: { + prototype: CSSMathMax; + new(...args: CSSNumberish[]): CSSMathMax; +}; + +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSMathMin) */ +interface CSSMathMin extends CSSMathValue { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSMathMin/values) */ + readonly values: CSSNumericArray; +} + +declare var CSSMathMin: { + prototype: CSSMathMin; + new(...args: CSSNumberish[]): CSSMathMin; +}; + +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSMathNegate) */ +interface CSSMathNegate extends CSSMathValue { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSMathNegate/value) */ + readonly value: CSSNumericValue; +} + +declare var CSSMathNegate: { + prototype: CSSMathNegate; + new(arg: CSSNumberish): CSSMathNegate; +}; + +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSMathProduct) */ +interface CSSMathProduct extends CSSMathValue { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSMathProduct/values) */ + readonly values: CSSNumericArray; +} + +declare var CSSMathProduct: { + prototype: CSSMathProduct; + new(...args: CSSNumberish[]): CSSMathProduct; +}; + +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSMathSum) */ +interface CSSMathSum extends CSSMathValue { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSMathSum/values) */ + readonly values: CSSNumericArray; +} + +declare var CSSMathSum: { + prototype: CSSMathSum; + new(...args: CSSNumberish[]): CSSMathSum; +}; + +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSMathValue) */ +interface CSSMathValue extends CSSNumericValue { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSMathValue/operator) */ + readonly operator: CSSMathOperator; +} + +declare var CSSMathValue: { + prototype: CSSMathValue; + new(): CSSMathValue; +}; + +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSMatrixComponent) */ +interface CSSMatrixComponent extends CSSTransformComponent { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSMatrixComponent/matrix) */ + matrix: DOMMatrix; +} + +declare var CSSMatrixComponent: { + prototype: CSSMatrixComponent; + new(matrix: DOMMatrixReadOnly, options?: CSSMatrixComponentOptions): CSSMatrixComponent; +}; + +/** + * A single CSS @media rule. It implements the CSSConditionRule interface, and therefore the CSSGroupingRule and the CSSRule interface with a type value of 4 (CSSRule.MEDIA_RULE). + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSMediaRule) + */ +interface CSSMediaRule extends CSSConditionRule { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSMediaRule/media) */ readonly media: MediaList; } @@ -2766,9 +3522,15 @@ declare var CSSMediaRule: { new(): CSSMediaRule; }; -/** An object representing a single CSS @namespace at-rule. It implements the CSSRule interface, with a type value of 10 (CSSRule.NAMESPACE_RULE). */ +/** + * An object representing a single CSS @namespace at-rule. It implements the CSSRule interface, with a type value of 10 (CSSRule.NAMESPACE_RULE). + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSNamespaceRule) + */ interface CSSNamespaceRule extends CSSRule { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSNamespaceRule/namespaceURI) */ readonly namespaceURI: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSNamespaceRule/prefix) */ readonly prefix: string; } @@ -2777,9 +3539,59 @@ declare var CSSNamespaceRule: { new(): CSSNamespaceRule; }; -/** CSSPageRule is an interface representing a single CSS @page rule. It implements the CSSRule interface with a type value of 6 (CSSRule.PAGE_RULE). */ +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSNumericArray) */ +interface CSSNumericArray { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSNumericArray/length) */ + readonly length: number; + forEach(callbackfn: (value: CSSNumericValue, key: number, parent: CSSNumericArray) => void, thisArg?: any): void; + [index: number]: CSSNumericValue; +} + +declare var CSSNumericArray: { + prototype: CSSNumericArray; + new(): CSSNumericArray; +}; + +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSNumericValue) */ +interface CSSNumericValue extends CSSStyleValue { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSNumericValue/add) */ + add(...values: CSSNumberish[]): CSSNumericValue; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSNumericValue/div) */ + div(...values: CSSNumberish[]): CSSNumericValue; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSNumericValue/equals) */ + equals(...value: CSSNumberish[]): boolean; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSNumericValue/max) */ + max(...values: CSSNumberish[]): CSSNumericValue; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSNumericValue/min) */ + min(...values: CSSNumberish[]): CSSNumericValue; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSNumericValue/mul) */ + mul(...values: CSSNumberish[]): CSSNumericValue; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSNumericValue/sub) */ + sub(...values: CSSNumberish[]): CSSNumericValue; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSNumericValue/to) */ + to(unit: string): CSSUnitValue; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSNumericValue/toSum) */ + toSum(...units: string[]): CSSMathSum; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSNumericValue/type) */ + type(): CSSNumericType; +} + +declare var CSSNumericValue: { + prototype: CSSNumericValue; + new(): CSSNumericValue; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSNumericValue/parse) */ + parse(cssText: string): CSSNumericValue; +}; + +/** + * CSSPageRule is an interface representing a single CSS @page rule. It implements the CSSRule interface with a type value of 6 (CSSRule.PAGE_RULE). + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSPageRule) + */ interface CSSPageRule extends CSSGroupingRule { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSPageRule/selectorText) */ selectorText: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSPageRule/style) */ readonly style: CSSStyleDeclaration; } @@ -2788,43 +3600,106 @@ declare var CSSPageRule: { new(): CSSPageRule; }; -/** A single CSS rule. There are several types of rules, listed in the Type constants section below. */ +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSPerspective) */ +interface CSSPerspective extends CSSTransformComponent { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSPerspective/length) */ + length: CSSPerspectiveValue; +} + +declare var CSSPerspective: { + prototype: CSSPerspective; + new(length: CSSPerspectiveValue): CSSPerspective; +}; + +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSPropertyRule) */ +interface CSSPropertyRule extends CSSRule { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSPropertyRule/inherits) */ + readonly inherits: boolean; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSPropertyRule/initialValue) */ + readonly initialValue: string | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSPropertyRule/name) */ + readonly name: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSPropertyRule/syntax) */ + readonly syntax: string; +} + +declare var CSSPropertyRule: { + prototype: CSSPropertyRule; + new(): CSSPropertyRule; +}; + +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSRotate) */ +interface CSSRotate extends CSSTransformComponent { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSRotate/angle) */ + angle: CSSNumericValue; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSRotate/x) */ + x: CSSNumberish; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSRotate/y) */ + y: CSSNumberish; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSRotate/z) */ + z: CSSNumberish; +} + +declare var CSSRotate: { + prototype: CSSRotate; + new(angle: CSSNumericValue): CSSRotate; + new(x: CSSNumberish, y: CSSNumberish, z: CSSNumberish, angle: CSSNumericValue): CSSRotate; +}; + +/** + * A single CSS rule. There are several types of rules, listed in the Type constants section below. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSRule) + */ interface CSSRule { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSRule/cssText) */ cssText: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSRule/parentRule) */ readonly parentRule: CSSRule | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSRule/parentStyleSheet) */ readonly parentStyleSheet: CSSStyleSheet | null; - /** @deprecated */ + /** + * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSRule/type) + */ readonly type: number; - readonly CHARSET_RULE: number; - readonly FONT_FACE_RULE: number; - readonly IMPORT_RULE: number; - readonly KEYFRAMES_RULE: number; - readonly KEYFRAME_RULE: number; - readonly MEDIA_RULE: number; - readonly NAMESPACE_RULE: number; - readonly PAGE_RULE: number; - readonly STYLE_RULE: number; - readonly SUPPORTS_RULE: number; + readonly STYLE_RULE: 1; + readonly CHARSET_RULE: 2; + readonly IMPORT_RULE: 3; + readonly MEDIA_RULE: 4; + readonly FONT_FACE_RULE: 5; + readonly PAGE_RULE: 6; + readonly NAMESPACE_RULE: 10; + readonly KEYFRAMES_RULE: 7; + readonly KEYFRAME_RULE: 8; + readonly SUPPORTS_RULE: 12; } declare var CSSRule: { prototype: CSSRule; new(): CSSRule; - readonly CHARSET_RULE: number; - readonly FONT_FACE_RULE: number; - readonly IMPORT_RULE: number; - readonly KEYFRAMES_RULE: number; - readonly KEYFRAME_RULE: number; - readonly MEDIA_RULE: number; - readonly NAMESPACE_RULE: number; - readonly PAGE_RULE: number; - readonly STYLE_RULE: number; - readonly SUPPORTS_RULE: number; -}; - -/** A CSSRuleList is an (indirect-modify only) array-like object containing an ordered collection of CSSRule objects. */ + readonly STYLE_RULE: 1; + readonly CHARSET_RULE: 2; + readonly IMPORT_RULE: 3; + readonly MEDIA_RULE: 4; + readonly FONT_FACE_RULE: 5; + readonly PAGE_RULE: 6; + readonly NAMESPACE_RULE: 10; + readonly KEYFRAMES_RULE: 7; + readonly KEYFRAME_RULE: 8; + readonly SUPPORTS_RULE: 12; +}; + +/** + * A CSSRuleList is an (indirect-modify only) array-like object containing an ordered collection of CSSRule objects. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSRuleList) + */ interface CSSRuleList { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSRuleList/length) */ readonly length: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSRuleList/item) */ item(index: number): CSSRule | null; [index: number]: CSSRule; } @@ -2834,347 +3709,742 @@ declare var CSSRuleList: { new(): CSSRuleList; }; -/** An object that is a CSS declaration block, and exposes style information and various style-related methods and properties. */ +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSScale) */ +interface CSSScale extends CSSTransformComponent { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSScale/x) */ + x: CSSNumberish; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSScale/y) */ + y: CSSNumberish; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSScale/z) */ + z: CSSNumberish; +} + +declare var CSSScale: { + prototype: CSSScale; + new(x: CSSNumberish, y: CSSNumberish, z?: CSSNumberish): CSSScale; +}; + +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSSkew) */ +interface CSSSkew extends CSSTransformComponent { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSSkew/ax) */ + ax: CSSNumericValue; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSSkew/ay) */ + ay: CSSNumericValue; +} + +declare var CSSSkew: { + prototype: CSSSkew; + new(ax: CSSNumericValue, ay: CSSNumericValue): CSSSkew; +}; + +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSSkewX) */ +interface CSSSkewX extends CSSTransformComponent { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSSkewX/ax) */ + ax: CSSNumericValue; +} + +declare var CSSSkewX: { + prototype: CSSSkewX; + new(ax: CSSNumericValue): CSSSkewX; +}; + +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSSkewY) */ +interface CSSSkewY extends CSSTransformComponent { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSSkewY/ay) */ + ay: CSSNumericValue; +} + +declare var CSSSkewY: { + prototype: CSSSkewY; + new(ay: CSSNumericValue): CSSSkewY; +}; + +/** + * An object that is a CSS declaration block, and exposes style information and various style-related methods and properties. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSStyleDeclaration) + */ interface CSSStyleDeclaration { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/accent-color) */ accentColor: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/align-content) */ alignContent: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/align-items) */ alignItems: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/align-self) */ alignSelf: string; alignmentBaseline: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/all) */ all: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/animation) */ animation: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/animation-composition) */ + animationComposition: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/animation-delay) */ animationDelay: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/animation-direction) */ animationDirection: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/animation-duration) */ animationDuration: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/animation-fill-mode) */ animationFillMode: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/animation-iteration-count) */ animationIterationCount: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/animation-name) */ animationName: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/animation-play-state) */ animationPlayState: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/animation-timing-function) */ animationTimingFunction: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/appearance) */ appearance: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/aspect-ratio) */ aspectRatio: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/backdrop-filter) */ backdropFilter: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/backface-visibility) */ backfaceVisibility: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/background) */ background: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/background-attachment) */ backgroundAttachment: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/background-blend-mode) */ backgroundBlendMode: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/background-clip) */ backgroundClip: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/background-color) */ backgroundColor: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/background-image) */ backgroundImage: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/background-origin) */ backgroundOrigin: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/background-position) */ backgroundPosition: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/background-position-x) */ backgroundPositionX: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/background-position-y) */ backgroundPositionY: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/background-repeat) */ backgroundRepeat: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/background-size) */ backgroundSize: string; baselineShift: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/block-size) */ blockSize: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border) */ border: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-block) */ borderBlock: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-block-color) */ borderBlockColor: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-block-end) */ borderBlockEnd: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-block-end-color) */ borderBlockEndColor: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-block-end-style) */ borderBlockEndStyle: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-block-end-width) */ borderBlockEndWidth: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-block-start) */ borderBlockStart: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-block-start-color) */ borderBlockStartColor: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-block-start-style) */ borderBlockStartStyle: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-block-start-width) */ borderBlockStartWidth: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-block-style) */ borderBlockStyle: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-block-width) */ borderBlockWidth: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-bottom) */ borderBottom: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-bottom-color) */ borderBottomColor: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-bottom-left-radius) */ borderBottomLeftRadius: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-bottom-right-radius) */ borderBottomRightRadius: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-bottom-style) */ borderBottomStyle: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-bottom-width) */ borderBottomWidth: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-collapse) */ borderCollapse: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-color) */ borderColor: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-end-end-radius) */ borderEndEndRadius: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-end-start-radius) */ borderEndStartRadius: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-image) */ borderImage: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-image-outset) */ borderImageOutset: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-image-repeat) */ borderImageRepeat: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-image-slice) */ borderImageSlice: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-image-source) */ borderImageSource: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-image-width) */ borderImageWidth: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-inline) */ borderInline: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-inline-color) */ borderInlineColor: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-inline-end) */ borderInlineEnd: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-inline-end-color) */ borderInlineEndColor: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-inline-end-style) */ borderInlineEndStyle: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-inline-end-width) */ borderInlineEndWidth: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-inline-start) */ borderInlineStart: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-inline-start-color) */ borderInlineStartColor: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-inline-start-style) */ borderInlineStartStyle: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-inline-start-width) */ borderInlineStartWidth: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-inline-style) */ borderInlineStyle: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-inline-width) */ borderInlineWidth: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-left) */ borderLeft: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-left-color) */ borderLeftColor: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-left-style) */ borderLeftStyle: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-left-width) */ borderLeftWidth: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-radius) */ borderRadius: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-right) */ borderRight: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-right-color) */ borderRightColor: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-right-style) */ borderRightStyle: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-right-width) */ borderRightWidth: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-spacing) */ borderSpacing: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-start-end-radius) */ borderStartEndRadius: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-start-start-radius) */ borderStartStartRadius: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-style) */ borderStyle: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-top) */ borderTop: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-top-color) */ borderTopColor: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-top-left-radius) */ borderTopLeftRadius: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-top-right-radius) */ borderTopRightRadius: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-top-style) */ borderTopStyle: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-top-width) */ borderTopWidth: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-width) */ borderWidth: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/bottom) */ bottom: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/box-shadow) */ boxShadow: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/box-sizing) */ boxSizing: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/break-after) */ breakAfter: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/break-before) */ breakBefore: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/break-inside) */ breakInside: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/caption-side) */ captionSide: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/caret-color) */ caretColor: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/clear) */ clear: string; - /** @deprecated */ + /** + * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/clip) + */ clip: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/clip-path) */ clipPath: string; clipRule: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/color) */ color: string; colorInterpolation: string; colorInterpolationFilters: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/color-scheme) */ colorScheme: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/column-count) */ columnCount: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/column-fill) */ columnFill: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/column-gap) */ columnGap: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/column-rule) */ columnRule: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/column-rule-color) */ columnRuleColor: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/column-rule-style) */ columnRuleStyle: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/column-rule-width) */ columnRuleWidth: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/column-span) */ columnSpan: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/column-width) */ columnWidth: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/columns) */ columns: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/contain) */ contain: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/contain-intrinsic-contain-intrinsic-block-size) */ + containIntrinsicBlockSize: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/contain-intrinsic-height) */ + containIntrinsicHeight: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/contain-intrinsic-contain-intrinsic-inline-size) */ + containIntrinsicInlineSize: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/contain-intrinsic-size) */ + containIntrinsicSize: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/contain-intrinsic-width) */ + containIntrinsicWidth: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/container) */ container: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/container-name) */ containerName: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/container-type) */ containerType: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/content) */ content: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/counter-increment) */ counterIncrement: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/counter-reset) */ counterReset: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/counter-set) */ counterSet: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSStyleDeclaration/cssFloat) */ cssFloat: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSStyleDeclaration/cssText) */ cssText: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/cursor) */ cursor: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/direction) */ direction: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/display) */ display: string; dominantBaseline: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/empty-cells) */ emptyCells: string; fill: string; fillOpacity: string; fillRule: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/filter) */ filter: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/flex) */ flex: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/flex-basis) */ flexBasis: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/flex-direction) */ flexDirection: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/flex-flow) */ flexFlow: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/flex-grow) */ flexGrow: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/flex-shrink) */ flexShrink: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/flex-wrap) */ flexWrap: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/float) */ float: string; floodColor: string; floodOpacity: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/font) */ font: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/font-family) */ fontFamily: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/font-feature-settings) */ fontFeatureSettings: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/font-kerning) */ fontKerning: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/font-optical-sizing) */ fontOpticalSizing: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/font-palette) */ fontPalette: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/font-size) */ fontSize: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/font-size-adjust) */ fontSizeAdjust: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/font-stretch) */ fontStretch: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/font-style) */ fontStyle: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/font-synthesis) */ fontSynthesis: string; + fontSynthesisSmallCaps: string; + fontSynthesisStyle: string; + fontSynthesisWeight: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/font-variant) */ fontVariant: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/font-variant-alternates) */ fontVariantAlternates: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/font-variant-caps) */ fontVariantCaps: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/font-variant-east-asian) */ fontVariantEastAsian: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/font-variant-ligatures) */ fontVariantLigatures: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/font-variant-numeric) */ fontVariantNumeric: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/font-variant-position) */ fontVariantPosition: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/font-variation-settings) */ fontVariationSettings: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/font-weight) */ fontWeight: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/gap) */ gap: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/grid) */ grid: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/grid-area) */ gridArea: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/grid-auto-columns) */ gridAutoColumns: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/grid-auto-flow) */ gridAutoFlow: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/grid-auto-rows) */ gridAutoRows: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/grid-column) */ gridColumn: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/grid-column-end) */ gridColumnEnd: string; /** @deprecated This is a legacy alias of `columnGap`. */ gridColumnGap: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/grid-column-start) */ gridColumnStart: string; /** @deprecated This is a legacy alias of `gap`. */ gridGap: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/grid-row) */ gridRow: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/grid-row-end) */ gridRowEnd: string; /** @deprecated This is a legacy alias of `rowGap`. */ gridRowGap: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/grid-row-start) */ gridRowStart: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/grid-template) */ gridTemplate: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/grid-template-areas) */ gridTemplateAreas: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/grid-template-columns) */ gridTemplateColumns: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/grid-template-rows) */ gridTemplateRows: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/height) */ height: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/hyphenate-character) */ hyphenateCharacter: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/hyphens) */ hyphens: string; - /** @deprecated */ + /** + * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/image-orientation) + */ imageOrientation: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/image-rendering) */ imageRendering: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/inline-size) */ inlineSize: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/inset) */ inset: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/inset-block) */ insetBlock: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/inset-block-end) */ insetBlockEnd: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/inset-block-start) */ insetBlockStart: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/inset-inline) */ insetInline: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/inset-inline-end) */ insetInlineEnd: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/inset-inline-start) */ insetInlineStart: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/isolation) */ isolation: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/justify-content) */ justifyContent: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/justify-items) */ justifyItems: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/justify-self) */ justifySelf: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/left) */ left: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSStyleDeclaration/length) */ readonly length: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/letter-spacing) */ letterSpacing: string; lightingColor: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/line-break) */ lineBreak: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/line-height) */ lineHeight: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/list-style) */ listStyle: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/list-style-image) */ listStyleImage: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/list-style-position) */ listStylePosition: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/list-style-type) */ listStyleType: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/margin) */ margin: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/margin-block) */ marginBlock: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/margin-block-end) */ marginBlockEnd: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/margin-block-start) */ marginBlockStart: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/margin-bottom) */ marginBottom: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/margin-inline) */ marginInline: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/margin-inline-end) */ marginInlineEnd: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/margin-inline-start) */ marginInlineStart: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/margin-left) */ marginLeft: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/margin-right) */ marginRight: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/margin-top) */ marginTop: string; marker: string; markerEnd: string; markerMid: string; markerStart: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/mask) */ mask: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/mask-clip) */ maskClip: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/mask-composite) */ maskComposite: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/mask-image) */ maskImage: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/mask-mode) */ maskMode: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/mask-origin) */ maskOrigin: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/mask-position) */ maskPosition: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/mask-repeat) */ maskRepeat: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/mask-size) */ maskSize: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/mask-type) */ maskType: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/math-style) */ + mathStyle: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/max-block-size) */ maxBlockSize: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/max-height) */ maxHeight: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/max-inline-size) */ maxInlineSize: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/max-width) */ maxWidth: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/min-block-size) */ minBlockSize: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/min-height) */ minHeight: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/min-inline-size) */ minInlineSize: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/min-width) */ minWidth: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/mix-blend-mode) */ mixBlendMode: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/object-fit) */ objectFit: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/object-position) */ objectPosition: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/offset) */ offset: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/offset-distance) */ offsetDistance: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/offset-path) */ offsetPath: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/offset-rotate) */ offsetRotate: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/opacity) */ opacity: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/order) */ order: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/orphans) */ orphans: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/outline) */ outline: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/outline-color) */ outlineColor: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/outline-offset) */ outlineOffset: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/outline-style) */ outlineStyle: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/outline-width) */ outlineWidth: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/overflow) */ overflow: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/overflow-anchor) */ overflowAnchor: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/overflow-clip-margin) */ overflowClipMargin: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/overflow-wrap) */ overflowWrap: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/overflow-x) */ overflowX: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/overflow-y) */ overflowY: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/overscroll-behavior) */ overscrollBehavior: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/overscroll-behavior-block) */ overscrollBehaviorBlock: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/overscroll-behavior-inline) */ overscrollBehaviorInline: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/overscroll-behavior-x) */ overscrollBehaviorX: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/overscroll-behavior-y) */ overscrollBehaviorY: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/padding) */ padding: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/padding-block) */ paddingBlock: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/padding-block-end) */ paddingBlockEnd: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/padding-block-start) */ paddingBlockStart: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/padding-bottom) */ paddingBottom: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/padding-inline) */ paddingInline: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/padding-inline-end) */ paddingInlineEnd: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/padding-inline-start) */ paddingInlineStart: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/padding-left) */ paddingLeft: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/padding-right) */ paddingRight: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/padding-top) */ paddingTop: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/page) */ + page: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/page-break-after) */ pageBreakAfter: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/page-break-before) */ pageBreakBefore: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/page-break-inside) */ pageBreakInside: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/paint-order) */ paintOrder: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSStyleDeclaration/parentRule) */ readonly parentRule: CSSRule | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/perspective) */ perspective: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/perspective-origin) */ perspectiveOrigin: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/place-content) */ placeContent: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/place-items) */ placeItems: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/place-self) */ placeSelf: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/pointer-events) */ pointerEvents: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/position) */ position: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/print-color-adjust) */ printColorAdjust: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/quotes) */ quotes: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/resize) */ resize: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/right) */ right: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/rotate) */ rotate: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/row-gap) */ rowGap: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/ruby-position) */ rubyPosition: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/scale) */ scale: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/scroll-behavior) */ scrollBehavior: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/scroll-margin) */ scrollMargin: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/scroll-margin-block) */ scrollMarginBlock: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/scroll-margin-block-end) */ scrollMarginBlockEnd: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/scroll-margin-block-start) */ scrollMarginBlockStart: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/scroll-margin-bottom) */ scrollMarginBottom: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/scroll-margin-inline) */ scrollMarginInline: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/scroll-margin-inline-end) */ scrollMarginInlineEnd: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/scroll-margin-inline-start) */ scrollMarginInlineStart: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/scroll-margin-left) */ scrollMarginLeft: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/scroll-margin-right) */ scrollMarginRight: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/scroll-margin-top) */ scrollMarginTop: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/scroll-padding) */ scrollPadding: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/scroll-padding-block) */ scrollPaddingBlock: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/scroll-padding-block-end) */ scrollPaddingBlockEnd: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/scroll-padding-block-start) */ scrollPaddingBlockStart: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/scroll-padding-bottom) */ scrollPaddingBottom: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/scroll-padding-inline) */ scrollPaddingInline: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/scroll-padding-inline-end) */ scrollPaddingInlineEnd: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/scroll-padding-inline-start) */ scrollPaddingInlineStart: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/scroll-padding-left) */ scrollPaddingLeft: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/scroll-padding-right) */ scrollPaddingRight: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/scroll-padding-top) */ scrollPaddingTop: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/scroll-snap-align) */ scrollSnapAlign: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/scroll-snap-stop) */ scrollSnapStop: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/scroll-snap-type) */ scrollSnapType: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/scrollbar-gutter) */ scrollbarGutter: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/shape-image-threshold) */ shapeImageThreshold: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/shape-margin) */ shapeMargin: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/shape-outside) */ shapeOutside: string; shapeRendering: string; stopColor: string; @@ -3187,194 +4457,512 @@ interface CSSStyleDeclaration { strokeMiterlimit: string; strokeOpacity: string; strokeWidth: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/tab-size) */ tabSize: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/table-layout) */ tableLayout: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/text-align) */ textAlign: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/text-align-last) */ textAlignLast: string; textAnchor: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/text-combine-upright) */ textCombineUpright: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/text-decoration) */ textDecoration: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/text-decoration-color) */ textDecorationColor: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/text-decoration-line) */ textDecorationLine: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/text-decoration-skip-ink) */ textDecorationSkipInk: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/text-decoration-style) */ textDecorationStyle: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/text-decoration-thickness) */ textDecorationThickness: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/text-emphasis) */ textEmphasis: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/text-emphasis-color) */ textEmphasisColor: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/text-emphasis-position) */ textEmphasisPosition: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/text-emphasis-style) */ textEmphasisStyle: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/text-indent) */ textIndent: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/text-orientation) */ textOrientation: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/text-overflow) */ textOverflow: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/text-rendering) */ textRendering: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/text-shadow) */ textShadow: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/text-transform) */ textTransform: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/text-underline-offset) */ textUnderlineOffset: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/text-underline-position) */ textUnderlinePosition: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/top) */ top: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/touch-action) */ touchAction: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/transform) */ transform: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/transform-box) */ transformBox: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/transform-origin) */ transformOrigin: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/transform-style) */ transformStyle: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/transition) */ transition: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/transition-delay) */ transitionDelay: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/transition-duration) */ transitionDuration: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/transition-property) */ transitionProperty: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/transition-timing-function) */ transitionTimingFunction: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/translate) */ translate: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/unicode-bidi) */ unicodeBidi: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/user-select) */ userSelect: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/vertical-align) */ verticalAlign: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/visibility) */ visibility: string; - /** @deprecated This is a legacy alias of `alignContent`. */ + /** + * @deprecated This is a legacy alias of `alignContent`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/align-content) + */ webkitAlignContent: string; - /** @deprecated This is a legacy alias of `alignItems`. */ + /** + * @deprecated This is a legacy alias of `alignItems`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/align-items) + */ webkitAlignItems: string; - /** @deprecated This is a legacy alias of `alignSelf`. */ + /** + * @deprecated This is a legacy alias of `alignSelf`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/align-self) + */ webkitAlignSelf: string; - /** @deprecated This is a legacy alias of `animation`. */ + /** + * @deprecated This is a legacy alias of `animation`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/animation) + */ webkitAnimation: string; - /** @deprecated This is a legacy alias of `animationDelay`. */ + /** + * @deprecated This is a legacy alias of `animationDelay`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/animation-delay) + */ webkitAnimationDelay: string; - /** @deprecated This is a legacy alias of `animationDirection`. */ + /** + * @deprecated This is a legacy alias of `animationDirection`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/animation-direction) + */ webkitAnimationDirection: string; - /** @deprecated This is a legacy alias of `animationDuration`. */ + /** + * @deprecated This is a legacy alias of `animationDuration`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/animation-duration) + */ webkitAnimationDuration: string; - /** @deprecated This is a legacy alias of `animationFillMode`. */ + /** + * @deprecated This is a legacy alias of `animationFillMode`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/animation-fill-mode) + */ webkitAnimationFillMode: string; - /** @deprecated This is a legacy alias of `animationIterationCount`. */ + /** + * @deprecated This is a legacy alias of `animationIterationCount`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/animation-iteration-count) + */ webkitAnimationIterationCount: string; - /** @deprecated This is a legacy alias of `animationName`. */ + /** + * @deprecated This is a legacy alias of `animationName`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/animation-name) + */ webkitAnimationName: string; - /** @deprecated This is a legacy alias of `animationPlayState`. */ + /** + * @deprecated This is a legacy alias of `animationPlayState`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/animation-play-state) + */ webkitAnimationPlayState: string; - /** @deprecated This is a legacy alias of `animationTimingFunction`. */ + /** + * @deprecated This is a legacy alias of `animationTimingFunction`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/animation-timing-function) + */ webkitAnimationTimingFunction: string; - /** @deprecated This is a legacy alias of `appearance`. */ + /** + * @deprecated This is a legacy alias of `appearance`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/appearance) + */ webkitAppearance: string; - /** @deprecated This is a legacy alias of `backfaceVisibility`. */ + /** + * @deprecated This is a legacy alias of `backfaceVisibility`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/backface-visibility) + */ webkitBackfaceVisibility: string; - /** @deprecated This is a legacy alias of `backgroundClip`. */ + /** + * @deprecated This is a legacy alias of `backgroundClip`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/background-clip) + */ webkitBackgroundClip: string; - /** @deprecated This is a legacy alias of `backgroundOrigin`. */ + /** + * @deprecated This is a legacy alias of `backgroundOrigin`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/background-origin) + */ webkitBackgroundOrigin: string; - /** @deprecated This is a legacy alias of `backgroundSize`. */ + /** + * @deprecated This is a legacy alias of `backgroundSize`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/background-size) + */ webkitBackgroundSize: string; - /** @deprecated This is a legacy alias of `borderBottomLeftRadius`. */ + /** + * @deprecated This is a legacy alias of `borderBottomLeftRadius`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-bottom-left-radius) + */ webkitBorderBottomLeftRadius: string; - /** @deprecated This is a legacy alias of `borderBottomRightRadius`. */ + /** + * @deprecated This is a legacy alias of `borderBottomRightRadius`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-bottom-right-radius) + */ webkitBorderBottomRightRadius: string; - /** @deprecated This is a legacy alias of `borderRadius`. */ + /** + * @deprecated This is a legacy alias of `borderRadius`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-radius) + */ webkitBorderRadius: string; - /** @deprecated This is a legacy alias of `borderTopLeftRadius`. */ + /** + * @deprecated This is a legacy alias of `borderTopLeftRadius`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-top-left-radius) + */ webkitBorderTopLeftRadius: string; - /** @deprecated This is a legacy alias of `borderTopRightRadius`. */ + /** + * @deprecated This is a legacy alias of `borderTopRightRadius`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/border-top-right-radius) + */ webkitBorderTopRightRadius: string; - /** @deprecated This is a legacy alias of `boxAlign`. */ + /** + * @deprecated This is a legacy alias of `boxAlign`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/box-align) + */ webkitBoxAlign: string; - /** @deprecated This is a legacy alias of `boxFlex`. */ + /** + * @deprecated This is a legacy alias of `boxFlex`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/box-flex) + */ webkitBoxFlex: string; - /** @deprecated This is a legacy alias of `boxOrdinalGroup`. */ + /** + * @deprecated This is a legacy alias of `boxOrdinalGroup`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/box-ordinal-group) + */ webkitBoxOrdinalGroup: string; - /** @deprecated This is a legacy alias of `boxOrient`. */ + /** + * @deprecated This is a legacy alias of `boxOrient`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/box-orient) + */ webkitBoxOrient: string; - /** @deprecated This is a legacy alias of `boxPack`. */ + /** + * @deprecated This is a legacy alias of `boxPack`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/box-pack) + */ webkitBoxPack: string; - /** @deprecated This is a legacy alias of `boxShadow`. */ + /** + * @deprecated This is a legacy alias of `boxShadow`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/box-shadow) + */ webkitBoxShadow: string; - /** @deprecated This is a legacy alias of `boxSizing`. */ + /** + * @deprecated This is a legacy alias of `boxSizing`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/box-sizing) + */ webkitBoxSizing: string; - /** @deprecated This is a legacy alias of `filter`. */ + /** + * @deprecated This is a legacy alias of `filter`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/filter) + */ webkitFilter: string; - /** @deprecated This is a legacy alias of `flex`. */ + /** + * @deprecated This is a legacy alias of `flex`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/flex) + */ webkitFlex: string; - /** @deprecated This is a legacy alias of `flexBasis`. */ + /** + * @deprecated This is a legacy alias of `flexBasis`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/flex-basis) + */ webkitFlexBasis: string; - /** @deprecated This is a legacy alias of `flexDirection`. */ + /** + * @deprecated This is a legacy alias of `flexDirection`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/flex-direction) + */ webkitFlexDirection: string; - /** @deprecated This is a legacy alias of `flexFlow`. */ + /** + * @deprecated This is a legacy alias of `flexFlow`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/flex-flow) + */ webkitFlexFlow: string; - /** @deprecated This is a legacy alias of `flexGrow`. */ + /** + * @deprecated This is a legacy alias of `flexGrow`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/flex-grow) + */ webkitFlexGrow: string; - /** @deprecated This is a legacy alias of `flexShrink`. */ + /** + * @deprecated This is a legacy alias of `flexShrink`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/flex-shrink) + */ webkitFlexShrink: string; - /** @deprecated This is a legacy alias of `flexWrap`. */ + /** + * @deprecated This is a legacy alias of `flexWrap`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/flex-wrap) + */ webkitFlexWrap: string; - /** @deprecated This is a legacy alias of `justifyContent`. */ + /** + * @deprecated This is a legacy alias of `justifyContent`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/justify-content) + */ webkitJustifyContent: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/-webkit-line-clamp) */ webkitLineClamp: string; - /** @deprecated This is a legacy alias of `mask`. */ + /** + * @deprecated This is a legacy alias of `mask`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/mask) + */ webkitMask: string; - /** @deprecated This is a legacy alias of `maskBorder`. */ + /** + * @deprecated This is a legacy alias of `maskBorder`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/mask-border) + */ webkitMaskBoxImage: string; - /** @deprecated This is a legacy alias of `maskBorderOutset`. */ + /** + * @deprecated This is a legacy alias of `maskBorderOutset`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/mask-border-outset) + */ webkitMaskBoxImageOutset: string; - /** @deprecated This is a legacy alias of `maskBorderRepeat`. */ + /** + * @deprecated This is a legacy alias of `maskBorderRepeat`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/mask-border-repeat) + */ webkitMaskBoxImageRepeat: string; - /** @deprecated This is a legacy alias of `maskBorderSlice`. */ + /** + * @deprecated This is a legacy alias of `maskBorderSlice`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/mask-border-slice) + */ webkitMaskBoxImageSlice: string; - /** @deprecated This is a legacy alias of `maskBorderSource`. */ + /** + * @deprecated This is a legacy alias of `maskBorderSource`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/mask-border-source) + */ webkitMaskBoxImageSource: string; - /** @deprecated This is a legacy alias of `maskBorderWidth`. */ + /** + * @deprecated This is a legacy alias of `maskBorderWidth`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/mask-border-width) + */ webkitMaskBoxImageWidth: string; - /** @deprecated This is a legacy alias of `maskClip`. */ + /** + * @deprecated This is a legacy alias of `maskClip`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/mask-clip) + */ webkitMaskClip: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/-webkit-mask-composite) */ webkitMaskComposite: string; - /** @deprecated This is a legacy alias of `maskImage`. */ + /** + * @deprecated This is a legacy alias of `maskImage`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/mask-image) + */ webkitMaskImage: string; - /** @deprecated This is a legacy alias of `maskOrigin`. */ + /** + * @deprecated This is a legacy alias of `maskOrigin`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/mask-origin) + */ webkitMaskOrigin: string; - /** @deprecated This is a legacy alias of `maskPosition`. */ + /** + * @deprecated This is a legacy alias of `maskPosition`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/mask-position) + */ webkitMaskPosition: string; - /** @deprecated This is a legacy alias of `maskRepeat`. */ + /** + * @deprecated This is a legacy alias of `maskRepeat`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/mask-repeat) + */ webkitMaskRepeat: string; - /** @deprecated This is a legacy alias of `maskSize`. */ - webkitMaskSize: string; - /** @deprecated This is a legacy alias of `order`. */ - webkitOrder: string; - /** @deprecated This is a legacy alias of `perspective`. */ + /** + * @deprecated This is a legacy alias of `maskSize`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/mask-size) + */ + webkitMaskSize: string; + /** + * @deprecated This is a legacy alias of `order`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/order) + */ + webkitOrder: string; + /** + * @deprecated This is a legacy alias of `perspective`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/perspective) + */ webkitPerspective: string; - /** @deprecated This is a legacy alias of `perspectiveOrigin`. */ + /** + * @deprecated This is a legacy alias of `perspectiveOrigin`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/perspective-origin) + */ webkitPerspectiveOrigin: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/-webkit-text-fill-color) */ webkitTextFillColor: string; - /** @deprecated This is a legacy alias of `textSizeAdjust`. */ + /** + * @deprecated This is a legacy alias of `textSizeAdjust`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/text-size-adjust) + */ webkitTextSizeAdjust: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/-webkit-text-stroke) */ webkitTextStroke: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/-webkit-text-stroke-color) */ webkitTextStrokeColor: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/-webkit-text-stroke-width) */ webkitTextStrokeWidth: string; - /** @deprecated This is a legacy alias of `transform`. */ + /** + * @deprecated This is a legacy alias of `transform`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/transform) + */ webkitTransform: string; - /** @deprecated This is a legacy alias of `transformOrigin`. */ + /** + * @deprecated This is a legacy alias of `transformOrigin`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/transform-origin) + */ webkitTransformOrigin: string; - /** @deprecated This is a legacy alias of `transformStyle`. */ + /** + * @deprecated This is a legacy alias of `transformStyle`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/transform-style) + */ webkitTransformStyle: string; - /** @deprecated This is a legacy alias of `transition`. */ + /** + * @deprecated This is a legacy alias of `transition`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/transition) + */ webkitTransition: string; - /** @deprecated This is a legacy alias of `transitionDelay`. */ + /** + * @deprecated This is a legacy alias of `transitionDelay`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/transition-delay) + */ webkitTransitionDelay: string; - /** @deprecated This is a legacy alias of `transitionDuration`. */ + /** + * @deprecated This is a legacy alias of `transitionDuration`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/transition-duration) + */ webkitTransitionDuration: string; - /** @deprecated This is a legacy alias of `transitionProperty`. */ + /** + * @deprecated This is a legacy alias of `transitionProperty`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/transition-property) + */ webkitTransitionProperty: string; - /** @deprecated This is a legacy alias of `transitionTimingFunction`. */ + /** + * @deprecated This is a legacy alias of `transitionTimingFunction`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/transition-timing-function) + */ webkitTransitionTimingFunction: string; - /** @deprecated This is a legacy alias of `userSelect`. */ + /** + * @deprecated This is a legacy alias of `userSelect`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/user-select) + */ webkitUserSelect: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/white-space) */ whiteSpace: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/widows) */ widows: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/width) */ width: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/will-change) */ willChange: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/word-break) */ wordBreak: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/word-spacing) */ wordSpacing: string; - /** @deprecated */ + /** + * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/overflow-wrap) + */ wordWrap: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/writing-mode) */ writingMode: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/z-index) */ zIndex: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSStyleDeclaration/getPropertyPriority) */ getPropertyPriority(property: string): string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSStyleDeclaration/getPropertyValue) */ getPropertyValue(property: string): string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSStyleDeclaration/item) */ item(index: number): string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSStyleDeclaration/removeProperty) */ removeProperty(property: string): string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSStyleDeclaration/setProperty) */ setProperty(property: string, value: string | null, priority?: string): void; [index: number]: string; } @@ -3384,10 +4972,18 @@ declare var CSSStyleDeclaration: { new(): CSSStyleDeclaration; }; -/** CSSStyleRule represents a single CSS style rule. It implements the CSSRule interface with a type value of 1 (CSSRule.STYLE_RULE). */ +/** + * CSSStyleRule represents a single CSS style rule. It implements the CSSRule interface with a type value of 1 (CSSRule.STYLE_RULE). + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSStyleRule) + */ interface CSSStyleRule extends CSSRule { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSStyleRule/selectorText) */ selectorText: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSStyleRule/style) */ readonly style: CSSStyleDeclaration; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSStyleRule/styleMap) */ + readonly styleMap: StylePropertyMap; } declare var CSSStyleRule: { @@ -3395,19 +4991,41 @@ declare var CSSStyleRule: { new(): CSSStyleRule; }; -/** A single CSS style sheet. It inherits properties and methods from its parent, StyleSheet. */ +/** + * A single CSS style sheet. It inherits properties and methods from its parent, StyleSheet. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSStyleSheet) + */ interface CSSStyleSheet extends StyleSheet { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSStyleSheet/cssRules) */ readonly cssRules: CSSRuleList; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSStyleSheet/ownerRule) */ readonly ownerRule: CSSRule | null; - /** @deprecated */ + /** + * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSStyleSheet/rules) + */ readonly rules: CSSRuleList; - /** @deprecated */ + /** + * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSStyleSheet/addRule) + */ addRule(selector?: string, style?: string, index?: number): number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSStyleSheet/deleteRule) */ deleteRule(index: number): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSStyleSheet/insertRule) */ insertRule(rule: string, index?: number): number; - /** @deprecated */ + /** + * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSStyleSheet/removeRule) + */ removeRule(index?: number): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSStyleSheet/replace) */ replace(text: string): Promise; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSStyleSheet/replaceSync) */ replaceSync(text: string): void; } @@ -3416,7 +5034,25 @@ declare var CSSStyleSheet: { new(options?: CSSStyleSheetInit): CSSStyleSheet; }; -/** An object representing a single CSS @supports at-rule. It implements the CSSConditionRule interface, and therefore the CSSRule and CSSGroupingRule interfaces with a type value of 12 (CSSRule.SUPPORTS_RULE). */ +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSStyleValue) */ +interface CSSStyleValue { + toString(): string; +} + +declare var CSSStyleValue: { + prototype: CSSStyleValue; + new(): CSSStyleValue; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSStyleValue/parse) */ + parse(property: string, cssText: string): CSSStyleValue; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSStyleValue/parseAll) */ + parseAll(property: string, cssText: string): CSSStyleValue[]; +}; + +/** + * An object representing a single CSS @supports at-rule. It implements the CSSConditionRule interface, and therefore the CSSRule and CSSGroupingRule interfaces with a type value of 12 (CSSRule.SUPPORTS_RULE). + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSSupportsRule) + */ interface CSSSupportsRule extends CSSConditionRule { } @@ -3425,7 +5061,40 @@ declare var CSSSupportsRule: { new(): CSSSupportsRule; }; +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSTransformComponent) */ +interface CSSTransformComponent { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSTransformComponent/is2D) */ + is2D: boolean; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSTransformComponent/toMatrix) */ + toMatrix(): DOMMatrix; + toString(): string; +} + +declare var CSSTransformComponent: { + prototype: CSSTransformComponent; + new(): CSSTransformComponent; +}; + +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSTransformValue) */ +interface CSSTransformValue extends CSSStyleValue { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSTransformValue/is2D) */ + readonly is2D: boolean; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSTransformValue/length) */ + readonly length: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSTransformValue/toMatrix) */ + toMatrix(): DOMMatrix; + forEach(callbackfn: (value: CSSTransformComponent, key: number, parent: CSSTransformValue) => void, thisArg?: any): void; + [index: number]: CSSTransformComponent; +} + +declare var CSSTransformValue: { + prototype: CSSTransformValue; + new(transforms: CSSTransformComponent[]): CSSTransformValue; +}; + +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSTransition) */ interface CSSTransition extends Animation { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSTransition/transitionProperty) */ readonly transitionProperty: string; addEventListener(type: K, listener: (this: CSSTransition, ev: AnimationEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; @@ -3438,17 +5107,80 @@ declare var CSSTransition: { new(): CSSTransition; }; +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSTranslate) */ +interface CSSTranslate extends CSSTransformComponent { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSTranslate/x) */ + x: CSSNumericValue; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSTranslate/y) */ + y: CSSNumericValue; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSTranslate/z) */ + z: CSSNumericValue; +} + +declare var CSSTranslate: { + prototype: CSSTranslate; + new(x: CSSNumericValue, y: CSSNumericValue, z?: CSSNumericValue): CSSTranslate; +}; + +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSUnitValue) */ +interface CSSUnitValue extends CSSNumericValue { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSUnitValue/unit) */ + readonly unit: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSUnitValue/value) */ + value: number; +} + +declare var CSSUnitValue: { + prototype: CSSUnitValue; + new(value: number, unit: string): CSSUnitValue; +}; + +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSUnparsedValue) */ +interface CSSUnparsedValue extends CSSStyleValue { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSUnparsedValue/length) */ + readonly length: number; + forEach(callbackfn: (value: CSSUnparsedSegment, key: number, parent: CSSUnparsedValue) => void, thisArg?: any): void; + [index: number]: CSSUnparsedSegment; +} + +declare var CSSUnparsedValue: { + prototype: CSSUnparsedValue; + new(members: CSSUnparsedSegment[]): CSSUnparsedValue; +}; + +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSVariableReferenceValue) */ +interface CSSVariableReferenceValue { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSVariableReferenceValue/fallback) */ + readonly fallback: CSSUnparsedValue | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CSSVariableReferenceValue/variable) */ + variable: string; +} + +declare var CSSVariableReferenceValue: { + prototype: CSSVariableReferenceValue; + new(variable: string, fallback?: CSSUnparsedValue | null): CSSVariableReferenceValue; +}; + /** * Provides a storage mechanism for Request / Response object pairs that are cached, for example as part of the ServiceWorker life cycle. Note that the Cache interface is exposed to windowed scopes as well as workers. You don't have to use it in conjunction with service workers, even though it is defined in the service worker spec. * Available only in secure contexts. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Cache) */ interface Cache { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Cache/add) */ add(request: RequestInfo | URL): Promise; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Cache/addAll) */ addAll(requests: RequestInfo[]): Promise; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Cache/delete) */ delete(request: RequestInfo | URL, options?: CacheQueryOptions): Promise; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Cache/keys) */ keys(request?: RequestInfo | URL, options?: CacheQueryOptions): Promise>; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Cache/match) */ match(request: RequestInfo | URL, options?: CacheQueryOptions): Promise; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Cache/matchAll) */ matchAll(request?: RequestInfo | URL, options?: CacheQueryOptions): Promise>; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Cache/put) */ put(request: RequestInfo | URL, response: Response): Promise; } @@ -3460,12 +5192,19 @@ declare var Cache: { /** * The storage for Cache objects. * Available only in secure contexts. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CacheStorage) */ interface CacheStorage { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CacheStorage/delete) */ delete(cacheName: string): Promise; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CacheStorage/has) */ has(cacheName: string): Promise; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CacheStorage/keys) */ keys(): Promise; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CacheStorage/match) */ match(request: RequestInfo | URL, options?: MultiCacheQueryOptions): Promise; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CacheStorage/open) */ open(cacheName: string): Promise; } @@ -3474,8 +5213,11 @@ declare var CacheStorage: { new(): CacheStorage; }; +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasCaptureMediaStreamTrack) */ interface CanvasCaptureMediaStreamTrack extends MediaStreamTrack { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasCaptureMediaStreamTrack/canvas) */ readonly canvas: HTMLCanvasElement; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasCaptureMediaStreamTrack/requestFrame) */ requestFrame(): void; addEventListener(type: K, listener: (this: CanvasCaptureMediaStreamTrack, ev: MediaStreamTrackEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; @@ -3489,49 +5231,71 @@ declare var CanvasCaptureMediaStreamTrack: { }; interface CanvasCompositing { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/globalAlpha) */ globalAlpha: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation) */ globalCompositeOperation: GlobalCompositeOperation; } interface CanvasDrawImage { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/drawImage) */ drawImage(image: CanvasImageSource, dx: number, dy: number): void; drawImage(image: CanvasImageSource, dx: number, dy: number, dw: number, dh: number): void; drawImage(image: CanvasImageSource, sx: number, sy: number, sw: number, sh: number, dx: number, dy: number, dw: number, dh: number): void; } interface CanvasDrawPath { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/beginPath) */ beginPath(): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/clip) */ clip(fillRule?: CanvasFillRule): void; clip(path: Path2D, fillRule?: CanvasFillRule): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/fill) */ fill(fillRule?: CanvasFillRule): void; fill(path: Path2D, fillRule?: CanvasFillRule): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/isPointInPath) */ isPointInPath(x: number, y: number, fillRule?: CanvasFillRule): boolean; isPointInPath(path: Path2D, x: number, y: number, fillRule?: CanvasFillRule): boolean; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/isPointInStroke) */ isPointInStroke(x: number, y: number): boolean; isPointInStroke(path: Path2D, x: number, y: number): boolean; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/stroke) */ stroke(): void; stroke(path: Path2D): void; } interface CanvasFillStrokeStyles { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/fillStyle) */ fillStyle: string | CanvasGradient | CanvasPattern; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/strokeStyle) */ strokeStyle: string | CanvasGradient | CanvasPattern; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/createConicGradient) */ createConicGradient(startAngle: number, x: number, y: number): CanvasGradient; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/createLinearGradient) */ createLinearGradient(x0: number, y0: number, x1: number, y1: number): CanvasGradient; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/createPattern) */ createPattern(image: CanvasImageSource, repetition: string | null): CanvasPattern | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/createRadialGradient) */ createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): CanvasGradient; } interface CanvasFilters { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/filter) */ filter: string; } -/** An opaque object describing a gradient. It is returned by the methods CanvasRenderingContext2D.createLinearGradient() or CanvasRenderingContext2D.createRadialGradient(). */ +/** + * An opaque object describing a gradient. It is returned by the methods CanvasRenderingContext2D.createLinearGradient() or CanvasRenderingContext2D.createRadialGradient(). + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasGradient) + */ interface CanvasGradient { /** * Adds a color stop with the given color to the gradient at the given offset. 0.0 is the offset at one end of the gradient, 1.0 is the offset at the other end. * * Throws an "IndexSizeError" DOMException if the offset is out of range. Throws a "SyntaxError" DOMException if the color cannot be parsed. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasGradient/addColorStop) */ addColorStop(offset: number, color: string): void; } @@ -3542,44 +5306,74 @@ declare var CanvasGradient: { }; interface CanvasImageData { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/createImageData) */ createImageData(sw: number, sh: number, settings?: ImageDataSettings): ImageData; createImageData(imagedata: ImageData): ImageData; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/getImageData) */ getImageData(sx: number, sy: number, sw: number, sh: number, settings?: ImageDataSettings): ImageData; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/putImageData) */ putImageData(imagedata: ImageData, dx: number, dy: number): void; putImageData(imagedata: ImageData, dx: number, dy: number, dirtyX: number, dirtyY: number, dirtyWidth: number, dirtyHeight: number): void; } interface CanvasImageSmoothing { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/imageSmoothingEnabled) */ imageSmoothingEnabled: boolean; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/imageSmoothingQuality) */ imageSmoothingQuality: ImageSmoothingQuality; } interface CanvasPath { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/arc) */ arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, counterclockwise?: boolean): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/arcTo) */ arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/bezierCurveTo) */ bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/closePath) */ closePath(): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/ellipse) */ ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, counterclockwise?: boolean): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/lineTo) */ lineTo(x: number, y: number): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/moveTo) */ moveTo(x: number, y: number): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/quadraticCurveTo) */ quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/rect) */ rect(x: number, y: number, w: number, h: number): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/roundRect) */ roundRect(x: number, y: number, w: number, h: number, radii?: number | DOMPointInit | (number | DOMPointInit)[]): void; } interface CanvasPathDrawingStyles { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/lineCap) */ lineCap: CanvasLineCap; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/lineDashOffset) */ lineDashOffset: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/lineJoin) */ lineJoin: CanvasLineJoin; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/lineWidth) */ lineWidth: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/miterLimit) */ miterLimit: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/getLineDash) */ getLineDash(): number[]; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/setLineDash) */ setLineDash(segments: number[]): void; } -/** An opaque object describing a pattern, based on an image, a canvas, or a video, created by the CanvasRenderingContext2D.createPattern() method. */ +/** + * An opaque object describing a pattern, based on an image, a canvas, or a video, created by the CanvasRenderingContext2D.createPattern() method. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasPattern) + */ interface CanvasPattern { - /** Sets the transformation matrix that will be used when rendering the pattern during a fill or stroke painting operation. */ + /** + * Sets the transformation matrix that will be used when rendering the pattern during a fill or stroke painting operation. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasPattern/setTransform) + */ setTransform(transform?: DOMMatrix2DInit): void; } @@ -3589,14 +5383,23 @@ declare var CanvasPattern: { }; interface CanvasRect { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/clearRect) */ clearRect(x: number, y: number, w: number, h: number): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/fillRect) */ fillRect(x: number, y: number, w: number, h: number): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/strokeRect) */ strokeRect(x: number, y: number, w: number, h: number): void; } -/** The CanvasRenderingContext2D interface, part of the Canvas API, provides the 2D rendering context for the drawing surface of a element. It is used for drawing shapes, text, images, and other objects. */ +/** + * The CanvasRenderingContext2D interface, part of the Canvas API, provides the 2D rendering context for the drawing surface of a element. It is used for drawing shapes, text, images, and other objects. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D) + */ interface CanvasRenderingContext2D extends CanvasCompositing, CanvasDrawImage, CanvasDrawPath, CanvasFillStrokeStyles, CanvasFilters, CanvasImageData, CanvasImageSmoothing, CanvasPath, CanvasPathDrawingStyles, CanvasRect, CanvasShadowStyles, CanvasState, CanvasText, CanvasTextDrawingStyles, CanvasTransform, CanvasUserInterface { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/canvas) */ readonly canvas: HTMLCanvasElement; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/getContextAttributes) */ getContextAttributes(): CanvasRenderingContext2DSettings; } @@ -3606,48 +5409,74 @@ declare var CanvasRenderingContext2D: { }; interface CanvasShadowStyles { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/shadowBlur) */ shadowBlur: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/shadowColor) */ shadowColor: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/shadowOffsetX) */ shadowOffsetX: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/shadowOffsetY) */ shadowOffsetY: number; } interface CanvasState { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/restore) */ restore(): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/save) */ save(): void; } interface CanvasText { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/fillText) */ fillText(text: string, x: number, y: number, maxWidth?: number): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/measureText) */ measureText(text: string): TextMetrics; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/strokeText) */ strokeText(text: string, x: number, y: number, maxWidth?: number): void; } interface CanvasTextDrawingStyles { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/direction) */ direction: CanvasDirection; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/font) */ font: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/fontKerning) */ fontKerning: CanvasFontKerning; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/textAlign) */ textAlign: CanvasTextAlign; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/textBaseline) */ textBaseline: CanvasTextBaseline; } interface CanvasTransform { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/getTransform) */ getTransform(): DOMMatrix; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/resetTransform) */ resetTransform(): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/rotate) */ rotate(angle: number): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/scale) */ scale(x: number, y: number): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/setTransform) */ setTransform(a: number, b: number, c: number, d: number, e: number, f: number): void; setTransform(transform?: DOMMatrix2DInit): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/transform) */ transform(a: number, b: number, c: number, d: number, e: number, f: number): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/translate) */ translate(x: number, y: number): void; } interface CanvasUserInterface { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/drawFocusIfNeeded) */ drawFocusIfNeeded(element: Element): void; drawFocusIfNeeded(path: Path2D, element: Element): void; } -/** The ChannelMergerNode interface, often used in conjunction with its opposite, ChannelSplitterNode, reunites different mono inputs into a single output. Each input is used to fill a channel of the output. This is useful for accessing each channels separately, e.g. for performing channel mixing where gain must be separately controlled on each channel. */ +/** + * The ChannelMergerNode interface, often used in conjunction with its opposite, ChannelSplitterNode, reunites different mono inputs into a single output. Each input is used to fill a channel of the output. This is useful for accessing each channels separately, e.g. for performing channel mixing where gain must be separately controlled on each channel. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ChannelMergerNode) + */ interface ChannelMergerNode extends AudioNode { } @@ -3656,7 +5485,11 @@ declare var ChannelMergerNode: { new(context: BaseAudioContext, options?: ChannelMergerOptions): ChannelMergerNode; }; -/** The ChannelSplitterNode interface, often used in conjunction with its opposite, ChannelMergerNode, separates the different channels of an audio source into a set of mono outputs. This is useful for accessing each channel separately, e.g. for performing channel mixing where gain must be separately controlled on each channel. */ +/** + * The ChannelSplitterNode interface, often used in conjunction with its opposite, ChannelMergerNode, separates the different channels of an audio source into a set of mono outputs. This is useful for accessing each channel separately, e.g. for performing channel mixing where gain must be separately controlled on each channel. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ChannelSplitterNode) + */ interface ChannelSplitterNode extends AudioNode { } @@ -3665,15 +5498,26 @@ declare var ChannelSplitterNode: { new(context: BaseAudioContext, options?: ChannelSplitterOptions): ChannelSplitterNode; }; -/** The CharacterData abstract interface represents a Node object that contains characters. This is an abstract interface, meaning there aren't any object of type CharacterData: it is implemented by other interfaces, like Text, Comment, or ProcessingInstruction which aren't abstract. */ +/** + * The CharacterData abstract interface represents a Node object that contains characters. This is an abstract interface, meaning there aren't any object of type CharacterData: it is implemented by other interfaces, like Text, Comment, or ProcessingInstruction which aren't abstract. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CharacterData) + */ interface CharacterData extends Node, ChildNode, NonDocumentTypeChildNode { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CharacterData/data) */ data: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CharacterData/length) */ readonly length: number; readonly ownerDocument: Document; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CharacterData/appendData) */ appendData(data: string): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CharacterData/deleteData) */ deleteData(offset: number, count: number): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CharacterData/insertData) */ insertData(offset: number, data: string): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CharacterData/replaceData) */ replaceData(offset: number, count: number, data: string): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CharacterData/substringData) */ substringData(offset: number, count: number): string; } @@ -3687,20 +5531,30 @@ interface ChildNode extends Node { * Inserts nodes just after node, while replacing strings in nodes with equivalent Text nodes. * * Throws a "HierarchyRequestError" DOMException if the constraints of the node tree are violated. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CharacterData/after) */ after(...nodes: (Node | string)[]): void; /** * Inserts nodes just before node, while replacing strings in nodes with equivalent Text nodes. * * Throws a "HierarchyRequestError" DOMException if the constraints of the node tree are violated. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CharacterData/before) */ before(...nodes: (Node | string)[]): void; - /** Removes node. */ + /** + * Removes node. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CharacterData/remove) + */ remove(): void; /** * Replaces node with nodes, while replacing strings in nodes with equivalent Text nodes. * * Throws a "HierarchyRequestError" DOMException if the constraints of the node tree are violated. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CharacterData/replaceWith) */ replaceWith(...nodes: (Node | string)[]): void; } @@ -3709,11 +5563,19 @@ interface ChildNode extends Node { interface ClientRect extends DOMRect { } -/** Available only in secure contexts. */ +/** + * Available only in secure contexts. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Clipboard) + */ interface Clipboard extends EventTarget { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Clipboard/read) */ read(): Promise; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Clipboard/readText) */ readText(): Promise; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Clipboard/write) */ write(data: ClipboardItems): Promise; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Clipboard/writeText) */ writeText(data: string): Promise; } @@ -3722,8 +5584,13 @@ declare var Clipboard: { new(): Clipboard; }; -/** Events providing information related to modification of the clipboard, that is cut, copy, and paste events. */ +/** + * Events providing information related to modification of the clipboard, that is cut, copy, and paste events. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ClipboardEvent) + */ interface ClipboardEvent extends Event { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ClipboardEvent/clipboardData) */ readonly clipboardData: DataTransfer | null; } @@ -3732,9 +5599,17 @@ declare var ClipboardEvent: { new(type: string, eventInitDict?: ClipboardEventInit): ClipboardEvent; }; -/** Available only in secure contexts. */ +/** + * Available only in secure contexts. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ClipboardItem) + */ interface ClipboardItem { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ClipboardItem/presentationStyle) */ + readonly presentationStyle: PresentationStyle; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ClipboardItem/types) */ readonly types: ReadonlyArray; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ClipboardItem/getType) */ getType(type: string): Promise; } @@ -3743,13 +5618,29 @@ declare var ClipboardItem: { new(items: Record>, options?: ClipboardItemOptions): ClipboardItem; }; -/** A CloseEvent is sent to clients using WebSockets when the connection is closed. This is delivered to the listener indicated by the WebSocket object's onclose attribute. */ +/** + * A CloseEvent is sent to clients using WebSockets when the connection is closed. This is delivered to the listener indicated by the WebSocket object's onclose attribute. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent) + */ interface CloseEvent extends Event { - /** Returns the WebSocket connection close code provided by the server. */ + /** + * Returns the WebSocket connection close code provided by the server. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/code) + */ readonly code: number; - /** Returns the WebSocket connection close reason provided by the server. */ + /** + * Returns the WebSocket connection close reason provided by the server. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/reason) + */ readonly reason: string; - /** Returns true if the connection closed cleanly; false otherwise. */ + /** + * Returns true if the connection closed cleanly; false otherwise. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/wasClean) + */ readonly wasClean: boolean; } @@ -3758,7 +5649,11 @@ declare var CloseEvent: { new(type: string, eventInitDict?: CloseEventInit): CloseEvent; }; -/** Textual notations within markup; although it is generally not visually shown, such comments are available to be read in the source view. */ +/** + * Textual notations within markup; although it is generally not visually shown, such comments are available to be read in the source view. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Comment) + */ interface Comment extends CharacterData { } @@ -3767,10 +5662,19 @@ declare var Comment: { new(data?: string): Comment; }; -/** The DOM CompositionEvent represents events that occur due to the user indirectly entering text. */ +/** + * The DOM CompositionEvent represents events that occur due to the user indirectly entering text. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CompositionEvent) + */ interface CompositionEvent extends UIEvent { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CompositionEvent/data) */ readonly data: string; - /** @deprecated */ + /** + * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CompositionEvent/initCompositionEvent) + */ initCompositionEvent(typeArg: string, bubblesArg?: boolean, cancelableArg?: boolean, viewArg?: WindowProxy | null, dataArg?: string): void; } @@ -3779,7 +5683,18 @@ declare var CompositionEvent: { new(type: string, eventInitDict?: CompositionEventInit): CompositionEvent; }; +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CompressionStream) */ +interface CompressionStream extends GenericTransformStream { +} + +declare var CompressionStream: { + prototype: CompressionStream; + new(format: CompressionFormat): CompressionStream; +}; + +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ConstantSourceNode) */ interface ConstantSourceNode extends AudioScheduledSourceNode { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ConstantSourceNode/offset) */ readonly offset: AudioParam; addEventListener(type: K, listener: (this: ConstantSourceNode, ev: AudioScheduledSourceNodeEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; @@ -3792,9 +5707,15 @@ declare var ConstantSourceNode: { new(context: BaseAudioContext, options?: ConstantSourceOptions): ConstantSourceNode; }; -/** An AudioNode that performs a Linear Convolution on a given AudioBuffer, often used to achieve a reverb effect. A ConvolverNode always has exactly one input and one output. */ +/** + * An AudioNode that performs a Linear Convolution on a given AudioBuffer, often used to achieve a reverb effect. A ConvolverNode always has exactly one input and one output. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ConvolverNode) + */ interface ConvolverNode extends AudioNode { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ConvolverNode/buffer) */ buffer: AudioBuffer | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ConvolverNode/normalize) */ normalize: boolean; } @@ -3803,9 +5724,15 @@ declare var ConvolverNode: { new(context: BaseAudioContext, options?: ConvolverOptions): ConvolverNode; }; -/** This Streams API interface provides a built-in byte length queuing strategy that can be used when constructing streams. */ +/** + * This Streams API interface provides a built-in byte length queuing strategy that can be used when constructing streams. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CountQueuingStrategy) + */ interface CountQueuingStrategy extends QueuingStrategy { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CountQueuingStrategy/highWaterMark) */ readonly highWaterMark: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CountQueuingStrategy/size) */ readonly size: QueuingStrategySize; } @@ -3814,9 +5741,15 @@ declare var CountQueuingStrategy: { new(init: QueuingStrategyInit): CountQueuingStrategy; }; -/** Available only in secure contexts. */ +/** + * Available only in secure contexts. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Credential) + */ interface Credential { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Credential/id) */ readonly id: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Credential/type) */ readonly type: string; } @@ -3825,11 +5758,19 @@ declare var Credential: { new(): Credential; }; -/** Available only in secure contexts. */ +/** + * Available only in secure contexts. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CredentialsContainer) + */ interface CredentialsContainer { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CredentialsContainer/create) */ create(options?: CredentialCreationOptions): Promise; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CredentialsContainer/get) */ get(options?: CredentialRequestOptions): Promise; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CredentialsContainer/preventSilentAccess) */ preventSilentAccess(): Promise; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CredentialsContainer/store) */ store(credential: Credential): Promise; } @@ -3838,13 +5779,26 @@ declare var CredentialsContainer: { new(): CredentialsContainer; }; -/** Basic cryptography features available in the current context. It allows access to a cryptographically strong random number generator and to cryptographic primitives. */ +/** + * Basic cryptography features available in the current context. It allows access to a cryptographically strong random number generator and to cryptographic primitives. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto) + */ interface Crypto { - /** Available only in secure contexts. */ + /** + * Available only in secure contexts. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/subtle) + */ readonly subtle: SubtleCrypto; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/getRandomValues) */ getRandomValues(array: T): T; - /** Available only in secure contexts. */ - randomUUID(): string; + /** + * Available only in secure contexts. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/randomUUID) + */ + randomUUID(): `${string}-${string}-${string}-${string}-${string}`; } declare var Crypto: { @@ -3855,11 +5809,17 @@ declare var Crypto: { /** * The CryptoKey dictionary of the Web Crypto API represents a cryptographic key. * Available only in secure contexts. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey) */ interface CryptoKey { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/algorithm) */ readonly algorithm: KeyAlgorithm; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/extractable) */ readonly extractable: boolean; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/type) */ readonly type: KeyType; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/usages) */ readonly usages: KeyUsage[]; } @@ -3868,10 +5828,15 @@ declare var CryptoKey: { new(): CryptoKey; }; +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CustomElementRegistry) */ interface CustomElementRegistry { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CustomElementRegistry/define) */ define(name: string, constructor: CustomElementConstructor, options?: ElementDefinitionOptions): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CustomElementRegistry/get) */ get(name: string): CustomElementConstructor | undefined; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CustomElementRegistry/upgrade) */ upgrade(root: Node): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CustomElementRegistry/whenDefined) */ whenDefined(name: string): Promise; } @@ -3880,10 +5845,19 @@ declare var CustomElementRegistry: { new(): CustomElementRegistry; }; +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CustomEvent) */ interface CustomEvent extends Event { - /** Returns any custom data event was created with. Typically used for synthetic events. */ + /** + * Returns any custom data event was created with. Typically used for synthetic events. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CustomEvent/detail) + */ readonly detail: T; - /** @deprecated */ + /** + * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CustomEvent/initCustomEvent) + */ initCustomEvent(type: string, bubbles?: boolean, cancelable?: boolean, detail?: T): void; } @@ -3892,75 +5866,96 @@ declare var CustomEvent: { new(type: string, eventInitDict?: CustomEventInit): CustomEvent; }; -/** An abnormal event (called an exception) which occurs as a result of calling a method or accessing a property of a web API. */ +/** + * An abnormal event (called an exception) which occurs as a result of calling a method or accessing a property of a web API. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException) + */ interface DOMException extends Error { - /** @deprecated */ + /** + * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/code) + */ readonly code: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/message) */ readonly message: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/name) */ readonly name: string; - readonly ABORT_ERR: number; - readonly DATA_CLONE_ERR: number; - readonly DOMSTRING_SIZE_ERR: number; - readonly HIERARCHY_REQUEST_ERR: number; - readonly INDEX_SIZE_ERR: number; - readonly INUSE_ATTRIBUTE_ERR: number; - readonly INVALID_ACCESS_ERR: number; - readonly INVALID_CHARACTER_ERR: number; - readonly INVALID_MODIFICATION_ERR: number; - readonly INVALID_NODE_TYPE_ERR: number; - readonly INVALID_STATE_ERR: number; - readonly NAMESPACE_ERR: number; - readonly NETWORK_ERR: number; - readonly NOT_FOUND_ERR: number; - readonly NOT_SUPPORTED_ERR: number; - readonly NO_DATA_ALLOWED_ERR: number; - readonly NO_MODIFICATION_ALLOWED_ERR: number; - readonly QUOTA_EXCEEDED_ERR: number; - readonly SECURITY_ERR: number; - readonly SYNTAX_ERR: number; - readonly TIMEOUT_ERR: number; - readonly TYPE_MISMATCH_ERR: number; - readonly URL_MISMATCH_ERR: number; - readonly VALIDATION_ERR: number; - readonly WRONG_DOCUMENT_ERR: number; + readonly INDEX_SIZE_ERR: 1; + readonly DOMSTRING_SIZE_ERR: 2; + readonly HIERARCHY_REQUEST_ERR: 3; + readonly WRONG_DOCUMENT_ERR: 4; + readonly INVALID_CHARACTER_ERR: 5; + readonly NO_DATA_ALLOWED_ERR: 6; + readonly NO_MODIFICATION_ALLOWED_ERR: 7; + readonly NOT_FOUND_ERR: 8; + readonly NOT_SUPPORTED_ERR: 9; + readonly INUSE_ATTRIBUTE_ERR: 10; + readonly INVALID_STATE_ERR: 11; + readonly SYNTAX_ERR: 12; + readonly INVALID_MODIFICATION_ERR: 13; + readonly NAMESPACE_ERR: 14; + readonly INVALID_ACCESS_ERR: 15; + readonly VALIDATION_ERR: 16; + readonly TYPE_MISMATCH_ERR: 17; + readonly SECURITY_ERR: 18; + readonly NETWORK_ERR: 19; + readonly ABORT_ERR: 20; + readonly URL_MISMATCH_ERR: 21; + readonly QUOTA_EXCEEDED_ERR: 22; + readonly TIMEOUT_ERR: 23; + readonly INVALID_NODE_TYPE_ERR: 24; + readonly DATA_CLONE_ERR: 25; } declare var DOMException: { prototype: DOMException; new(message?: string, name?: string): DOMException; - readonly ABORT_ERR: number; - readonly DATA_CLONE_ERR: number; - readonly DOMSTRING_SIZE_ERR: number; - readonly HIERARCHY_REQUEST_ERR: number; - readonly INDEX_SIZE_ERR: number; - readonly INUSE_ATTRIBUTE_ERR: number; - readonly INVALID_ACCESS_ERR: number; - readonly INVALID_CHARACTER_ERR: number; - readonly INVALID_MODIFICATION_ERR: number; - readonly INVALID_NODE_TYPE_ERR: number; - readonly INVALID_STATE_ERR: number; - readonly NAMESPACE_ERR: number; - readonly NETWORK_ERR: number; - readonly NOT_FOUND_ERR: number; - readonly NOT_SUPPORTED_ERR: number; - readonly NO_DATA_ALLOWED_ERR: number; - readonly NO_MODIFICATION_ALLOWED_ERR: number; - readonly QUOTA_EXCEEDED_ERR: number; - readonly SECURITY_ERR: number; - readonly SYNTAX_ERR: number; - readonly TIMEOUT_ERR: number; - readonly TYPE_MISMATCH_ERR: number; - readonly URL_MISMATCH_ERR: number; - readonly VALIDATION_ERR: number; - readonly WRONG_DOCUMENT_ERR: number; -}; - -/** An object providing methods which are not dependent on any particular document. Such an object is returned by the Document.implementation property. */ + readonly INDEX_SIZE_ERR: 1; + readonly DOMSTRING_SIZE_ERR: 2; + readonly HIERARCHY_REQUEST_ERR: 3; + readonly WRONG_DOCUMENT_ERR: 4; + readonly INVALID_CHARACTER_ERR: 5; + readonly NO_DATA_ALLOWED_ERR: 6; + readonly NO_MODIFICATION_ALLOWED_ERR: 7; + readonly NOT_FOUND_ERR: 8; + readonly NOT_SUPPORTED_ERR: 9; + readonly INUSE_ATTRIBUTE_ERR: 10; + readonly INVALID_STATE_ERR: 11; + readonly SYNTAX_ERR: 12; + readonly INVALID_MODIFICATION_ERR: 13; + readonly NAMESPACE_ERR: 14; + readonly INVALID_ACCESS_ERR: 15; + readonly VALIDATION_ERR: 16; + readonly TYPE_MISMATCH_ERR: 17; + readonly SECURITY_ERR: 18; + readonly NETWORK_ERR: 19; + readonly ABORT_ERR: 20; + readonly URL_MISMATCH_ERR: 21; + readonly QUOTA_EXCEEDED_ERR: 22; + readonly TIMEOUT_ERR: 23; + readonly INVALID_NODE_TYPE_ERR: 24; + readonly DATA_CLONE_ERR: 25; +}; + +/** + * An object providing methods which are not dependent on any particular document. Such an object is returned by the Document.implementation property. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMImplementation) + */ interface DOMImplementation { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMImplementation/createDocument) */ createDocument(namespace: string | null, qualifiedName: string | null, doctype?: DocumentType | null): XMLDocument; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMImplementation/createDocumentType) */ createDocumentType(qualifiedName: string, publicId: string, systemId: string): DocumentType; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMImplementation/createHTMLDocument) */ createHTMLDocument(title?: string): Document; - /** @deprecated */ + /** + * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMImplementation/hasFeature) + */ hasFeature(...args: any[]): true; } @@ -3969,6 +5964,7 @@ declare var DOMImplementation: { new(): DOMImplementation; }; +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrix) */ interface DOMMatrix extends DOMMatrixReadOnly { a: number; b: number; @@ -3998,7 +5994,9 @@ interface DOMMatrix extends DOMMatrixReadOnly { rotateAxisAngleSelf(x?: number, y?: number, z?: number, angle?: number): DOMMatrix; rotateFromVectorSelf(x?: number, y?: number): DOMMatrix; rotateSelf(rotX?: number, rotY?: number, rotZ?: number): DOMMatrix; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrix/scale3dSelf) */ scale3dSelf(scale?: number, originX?: number, originY?: number, originZ?: number): DOMMatrix; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrix/scaleSelf) */ scaleSelf(scaleX?: number, scaleY?: number, scaleZ?: number, originX?: number, originY?: number, originZ?: number): DOMMatrix; setMatrixValue(transformList: string): DOMMatrix; skewXSelf(sx?: number): DOMMatrix; @@ -4020,48 +6018,92 @@ declare var SVGMatrix: typeof DOMMatrix; type WebKitCSSMatrix = DOMMatrix; declare var WebKitCSSMatrix: typeof DOMMatrix; +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly) */ interface DOMMatrixReadOnly { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/a) */ readonly a: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/b) */ readonly b: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/c) */ readonly c: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/d) */ readonly d: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/e) */ readonly e: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/f) */ readonly f: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/is2D) */ readonly is2D: boolean; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/isIdentity) */ readonly isIdentity: boolean; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/m11) */ readonly m11: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/m12) */ readonly m12: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/m13) */ readonly m13: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/m14) */ readonly m14: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/m21) */ readonly m21: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/m22) */ readonly m22: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/m23) */ readonly m23: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/m24) */ readonly m24: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/m31) */ readonly m31: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/m32) */ readonly m32: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/m33) */ readonly m33: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/m34) */ readonly m34: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/m41) */ readonly m41: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/m42) */ readonly m42: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/m43) */ readonly m43: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/m44) */ readonly m44: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/flipX) */ flipX(): DOMMatrix; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/flipY) */ flipY(): DOMMatrix; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/inverse) */ inverse(): DOMMatrix; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/multiply) */ multiply(other?: DOMMatrixInit): DOMMatrix; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/rotate) */ rotate(rotX?: number, rotY?: number, rotZ?: number): DOMMatrix; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/rotateAxisAngle) */ rotateAxisAngle(x?: number, y?: number, z?: number, angle?: number): DOMMatrix; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/rotateFromVector) */ rotateFromVector(x?: number, y?: number): DOMMatrix; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/scale) */ scale(scaleX?: number, scaleY?: number, scaleZ?: number, originX?: number, originY?: number, originZ?: number): DOMMatrix; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/scale3d) */ scale3d(scale?: number, originX?: number, originY?: number, originZ?: number): DOMMatrix; - /** @deprecated */ + /** + * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/scaleNonUniform) + */ scaleNonUniform(scaleX?: number, scaleY?: number): DOMMatrix; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/skewX) */ skewX(sx?: number): DOMMatrix; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/skewY) */ skewY(sy?: number): DOMMatrix; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/toFloat32Array) */ toFloat32Array(): Float32Array; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/toFloat64Array) */ toFloat64Array(): Float64Array; toJSON(): any; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/transformPoint) */ transformPoint(point?: DOMPointInit): DOMPoint; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/translate) */ translate(tx?: number, ty?: number, tz?: number): DOMMatrix; toString(): string; } @@ -4072,10 +6114,13 @@ declare var DOMMatrixReadOnly: { fromFloat32Array(array32: Float32Array): DOMMatrixReadOnly; fromFloat64Array(array64: Float64Array): DOMMatrixReadOnly; fromMatrix(other?: DOMMatrixInit): DOMMatrixReadOnly; - toString(): string; }; -/** Provides the ability to parse XML or HTML source code from a string into a DOM Document. */ +/** + * Provides the ability to parse XML or HTML source code from a string into a DOM Document. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMParser) + */ interface DOMParser { /** * Parses string using either the HTML or XML parser, according to type, and returns the resulting Document. type can be "text/html" (which will invoke the HTML parser), or any of "text/xml", "application/xml", "application/xhtml+xml", or "image/svg+xml" (which will invoke the XML parser). @@ -4085,6 +6130,8 @@ interface DOMParser { * Note that script elements are not evaluated during parsing, and the resulting document's encoding will always be UTF-8. * * Values other than the above for type will cause a TypeError exception to be thrown. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMParser/parseFromString) */ parseFromString(string: string, type: DOMParserSupportedType): Document; } @@ -4094,42 +6141,62 @@ declare var DOMParser: { new(): DOMParser; }; +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMPoint) */ interface DOMPoint extends DOMPointReadOnly { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMPoint/w) */ w: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMPoint/x) */ x: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMPoint/y) */ y: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMPoint/z) */ z: number; } declare var DOMPoint: { prototype: DOMPoint; new(x?: number, y?: number, z?: number, w?: number): DOMPoint; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMPoint/fromPoint) */ fromPoint(other?: DOMPointInit): DOMPoint; }; type SVGPoint = DOMPoint; declare var SVGPoint: typeof DOMPoint; +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMPointReadOnly) */ interface DOMPointReadOnly { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMPointReadOnly/w) */ readonly w: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMPointReadOnly/x) */ readonly x: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMPointReadOnly/y) */ readonly y: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMPointReadOnly/z) */ readonly z: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMPointReadOnly/matrixTransform) */ matrixTransform(matrix?: DOMMatrixInit): DOMPoint; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMPointReadOnly/toJSON) */ toJSON(): any; } declare var DOMPointReadOnly: { prototype: DOMPointReadOnly; new(x?: number, y?: number, z?: number, w?: number): DOMPointReadOnly; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMPointReadOnly/fromPoint) */ fromPoint(other?: DOMPointInit): DOMPointReadOnly; }; +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMQuad) */ interface DOMQuad { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMQuad/p1) */ readonly p1: DOMPoint; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMQuad/p2) */ readonly p2: DOMPoint; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMQuad/p3) */ readonly p3: DOMPoint; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMQuad/p4) */ readonly p4: DOMPoint; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMQuad/getBounds) */ getBounds(): DOMRect; toJSON(): any; } @@ -4141,6 +6208,7 @@ declare var DOMQuad: { fromRect(other?: DOMRectInit): DOMQuad; }; +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMRect) */ interface DOMRect extends DOMRectReadOnly { height: number; width: number; @@ -4168,14 +6236,23 @@ declare var DOMRectList: { new(): DOMRectList; }; +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMRectReadOnly) */ interface DOMRectReadOnly { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMRectReadOnly/bottom) */ readonly bottom: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMRectReadOnly/height) */ readonly height: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMRectReadOnly/left) */ readonly left: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMRectReadOnly/right) */ readonly right: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMRectReadOnly/top) */ readonly top: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMRectReadOnly/width) */ readonly width: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMRectReadOnly/x) */ readonly x: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMRectReadOnly/y) */ readonly y: number; toJSON(): any; } @@ -4183,16 +6260,33 @@ interface DOMRectReadOnly { declare var DOMRectReadOnly: { prototype: DOMRectReadOnly; new(x?: number, y?: number, width?: number, height?: number): DOMRectReadOnly; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMRectReadOnly/fromRect) */ fromRect(other?: DOMRectInit): DOMRectReadOnly; }; -/** A type returned by some APIs which contains a list of DOMString (strings). */ +/** + * A type returned by some APIs which contains a list of DOMString (strings). + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMStringList) + */ interface DOMStringList { - /** Returns the number of strings in strings. */ + /** + * Returns the number of strings in strings. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMStringList/length) + */ readonly length: number; - /** Returns true if strings contains string, and false otherwise. */ + /** + * Returns true if strings contains string, and false otherwise. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMStringList/contains) + */ contains(string: string): boolean; - /** Returns the string with index index from strings. */ + /** + * Returns the string with index index from strings. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMStringList/item) + */ item(index: number): string | null; [index: number]: string; } @@ -4202,7 +6296,11 @@ declare var DOMStringList: { new(): DOMStringList; }; -/** Used by the dataset HTML attribute to represent data for custom attributes added to elements. */ +/** + * Used by the dataset HTML attribute to represent data for custom attributes added to elements. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMStringMap) + */ interface DOMStringMap { [name: string]: string | undefined; } @@ -4212,14 +6310,24 @@ declare var DOMStringMap: { new(): DOMStringMap; }; -/** A set of space-separated tokens. Such a set is returned by Element.classList, HTMLLinkElement.relList, HTMLAnchorElement.relList, HTMLAreaElement.relList, HTMLIframeElement.sandbox, or HTMLOutputElement.htmlFor. It is indexed beginning with 0 as with JavaScript Array objects. DOMTokenList is always case-sensitive. */ -interface DOMTokenList { - /** Returns the number of tokens. */ - readonly length: number; +/** + * A set of space-separated tokens. Such a set is returned by Element.classList, HTMLLinkElement.relList, HTMLAnchorElement.relList, HTMLAreaElement.relList, HTMLIframeElement.sandbox, or HTMLOutputElement.htmlFor. It is indexed beginning with 0 as with JavaScript Array objects. DOMTokenList is always case-sensitive. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMTokenList) + */ +interface DOMTokenList { + /** + * Returns the number of tokens. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMTokenList/length) + */ + readonly length: number; /** * Returns the associated set as string. * * Can be set, to change the associated attribute. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMTokenList/value) */ value: string; toString(): string; @@ -4229,11 +6337,21 @@ interface DOMTokenList { * Throws a "SyntaxError" DOMException if one of the arguments is the empty string. * * Throws an "InvalidCharacterError" DOMException if one of the arguments contains any ASCII whitespace. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMTokenList/add) */ add(...tokens: string[]): void; - /** Returns true if token is present, and false otherwise. */ + /** + * Returns true if token is present, and false otherwise. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMTokenList/contains) + */ contains(token: string): boolean; - /** Returns the token with index index. */ + /** + * Returns the token with index index. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMTokenList/item) + */ item(index: number): string | null; /** * Removes arguments passed, if they are present. @@ -4241,6 +6359,8 @@ interface DOMTokenList { * Throws a "SyntaxError" DOMException if one of the arguments is the empty string. * * Throws an "InvalidCharacterError" DOMException if one of the arguments contains any ASCII whitespace. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMTokenList/remove) */ remove(...tokens: string[]): void; /** @@ -4251,12 +6371,16 @@ interface DOMTokenList { * Throws a "SyntaxError" DOMException if one of the arguments is the empty string. * * Throws an "InvalidCharacterError" DOMException if one of the arguments contains any ASCII whitespace. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMTokenList/replace) */ replace(token: string, newToken: string): boolean; /** * Returns true if token is in the associated attribute's supported tokens. Returns false otherwise. * * Throws a TypeError if the associated attribute has no supported tokens defined. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMTokenList/supports) */ supports(token: string): boolean; /** @@ -4267,6 +6391,8 @@ interface DOMTokenList { * Throws a "SyntaxError" DOMException if token is empty. * * Throws an "InvalidCharacterError" DOMException if token contains any spaces. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMTokenList/toggle) */ toggle(token: string, force?: boolean): boolean; forEach(callbackfn: (value: string, key: number, parent: DOMTokenList) => void, thisArg?: any): void; @@ -4278,7 +6404,11 @@ declare var DOMTokenList: { new(): DOMTokenList; }; -/** Used to hold the data that is being dragged during a drag and drop operation. It may hold one or more data items, each of one or more data types. For more information about drag and drop, see HTML Drag and Drop API. */ +/** + * Used to hold the data that is being dragged during a drag and drop operation. It may hold one or more data items, each of one or more data types. For more information about drag and drop, see HTML Drag and Drop API. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DataTransfer) + */ interface DataTransfer { /** * Returns the kind of operation that is currently selected. If the kind of operation isn't one of those that is allowed by the effectAllowed attribute, then the operation will fail. @@ -4286,6 +6416,8 @@ interface DataTransfer { * Can be set, to change the selected operation. * * The possible values are "none", "copy", "link", and "move". + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DataTransfer/dropEffect) */ dropEffect: "none" | "copy" | "link" | "move"; /** @@ -4294,21 +6426,51 @@ interface DataTransfer { * Can be set (during the dragstart event), to change the allowed operations. * * The possible values are "none", "copy", "copyLink", "copyMove", "link", "linkMove", "move", "all", and "uninitialized", + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DataTransfer/effectAllowed) */ effectAllowed: "none" | "copy" | "copyLink" | "copyMove" | "link" | "linkMove" | "move" | "all" | "uninitialized"; - /** Returns a FileList of the files being dragged, if any. */ + /** + * Returns a FileList of the files being dragged, if any. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DataTransfer/files) + */ readonly files: FileList; - /** Returns a DataTransferItemList object, with the drag data. */ + /** + * Returns a DataTransferItemList object, with the drag data. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DataTransfer/items) + */ readonly items: DataTransferItemList; - /** Returns a frozen array listing the formats that were set in the dragstart event. In addition, if any files are being dragged, then one of the types will be the string "Files". */ + /** + * Returns a frozen array listing the formats that were set in the dragstart event. In addition, if any files are being dragged, then one of the types will be the string "Files". + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DataTransfer/types) + */ readonly types: ReadonlyArray; - /** Removes the data of the specified formats. Removes all data if the argument is omitted. */ + /** + * Removes the data of the specified formats. Removes all data if the argument is omitted. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DataTransfer/clearData) + */ clearData(format?: string): void; - /** Returns the specified data. If there is no such data, returns the empty string. */ + /** + * Returns the specified data. If there is no such data, returns the empty string. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DataTransfer/getData) + */ getData(format: string): string; - /** Adds the specified data. */ + /** + * Adds the specified data. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DataTransfer/setData) + */ setData(format: string, data: string): void; - /** Uses the given element to update the drag feedback, replacing any previously specified feedback. */ + /** + * Uses the given element to update the drag feedback, replacing any previously specified feedback. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DataTransfer/setDragImage) + */ setDragImage(image: Element, x: number, y: number): void; } @@ -4317,16 +6479,37 @@ declare var DataTransfer: { new(): DataTransfer; }; -/** One drag data item. During a drag operation, each drag event has a dataTransfer property which contains a list of drag data items. Each item in the list is a DataTransferItem object. */ +/** + * One drag data item. During a drag operation, each drag event has a dataTransfer property which contains a list of drag data items. Each item in the list is a DataTransferItem object. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DataTransferItem) + */ interface DataTransferItem { - /** Returns the drag data item kind, one of: "string", "file". */ + /** + * Returns the drag data item kind, one of: "string", "file". + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DataTransferItem/kind) + */ readonly kind: string; - /** Returns the drag data item type string. */ + /** + * Returns the drag data item type string. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DataTransferItem/type) + */ readonly type: string; - /** Returns a File object, if the drag data item kind is File. */ + /** + * Returns a File object, if the drag data item kind is File. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DataTransferItem/getAsFile) + */ getAsFile(): File | null; - /** Invokes the callback with the string data as the argument, if the drag data item kind is text. */ + /** + * Invokes the callback with the string data as the argument, if the drag data item kind is text. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DataTransferItem/getAsString) + */ getAsString(callback: FunctionStringCallback | null): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DataTransferItem/webkitGetAsEntry) */ webkitGetAsEntry(): FileSystemEntry | null; } @@ -4335,16 +6518,36 @@ declare var DataTransferItem: { new(): DataTransferItem; }; -/** A list of DataTransferItem objects representing items being dragged. During a drag operation, each DragEvent has a dataTransfer property and that property is a DataTransferItemList. */ +/** + * A list of DataTransferItem objects representing items being dragged. During a drag operation, each DragEvent has a dataTransfer property and that property is a DataTransferItemList. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DataTransferItemList) + */ interface DataTransferItemList { - /** Returns the number of items in the drag data store. */ + /** + * Returns the number of items in the drag data store. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DataTransferItemList/length) + */ readonly length: number; - /** Adds a new entry for the given data to the drag data store. If the data is plain text then a type string has to be provided also. */ + /** + * Adds a new entry for the given data to the drag data store. If the data is plain text then a type string has to be provided also. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DataTransferItemList/add) + */ add(data: string, type: string): DataTransferItem | null; add(data: File): DataTransferItem | null; - /** Removes all the entries in the drag data store. */ + /** + * Removes all the entries in the drag data store. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DataTransferItemList/clear) + */ clear(): void; - /** Removes the indexth entry in the drag data store. */ + /** + * Removes the indexth entry in the drag data store. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DataTransferItemList/remove) + */ remove(index: number): void; [index: number]: DataTransferItem; } @@ -4354,8 +6557,22 @@ declare var DataTransferItemList: { new(): DataTransferItemList; }; -/** A delay-line; an AudioNode audio-processing module that causes a delay between the arrival of an input data and its propagation to the output. */ +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DecompressionStream) */ +interface DecompressionStream extends GenericTransformStream { +} + +declare var DecompressionStream: { + prototype: DecompressionStream; + new(format: CompressionFormat): DecompressionStream; +}; + +/** + * A delay-line; an AudioNode audio-processing module that causes a delay between the arrival of an input data and its propagation to the output. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DelayNode) + */ interface DelayNode extends AudioNode { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DelayNode/delayTime) */ readonly delayTime: AudioParam; } @@ -4367,11 +6584,17 @@ declare var DelayNode: { /** * The DeviceMotionEvent provides web developers with information about the speed of changes for the device's position and orientation. * Available only in secure contexts. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DeviceMotionEvent) */ interface DeviceMotionEvent extends Event { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DeviceMotionEvent/acceleration) */ readonly acceleration: DeviceMotionEventAcceleration | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DeviceMotionEvent/accelerationIncludingGravity) */ readonly accelerationIncludingGravity: DeviceMotionEventAcceleration | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DeviceMotionEvent/interval) */ readonly interval: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DeviceMotionEvent/rotationRate) */ readonly rotationRate: DeviceMotionEventRotationRate | null; } @@ -4380,28 +6603,48 @@ declare var DeviceMotionEvent: { new(type: string, eventInitDict?: DeviceMotionEventInit): DeviceMotionEvent; }; -/** Available only in secure contexts. */ +/** + * Available only in secure contexts. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DeviceMotionEventAcceleration) + */ interface DeviceMotionEventAcceleration { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DeviceMotionEventAcceleration/x) */ readonly x: number | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DeviceMotionEventAcceleration/y) */ readonly y: number | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DeviceMotionEventAcceleration/z) */ readonly z: number | null; } -/** Available only in secure contexts. */ +/** + * Available only in secure contexts. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DeviceMotionEventRotationRate) + */ interface DeviceMotionEventRotationRate { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DeviceMotionEventRotationRate/alpha) */ readonly alpha: number | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DeviceMotionEventRotationRate/beta) */ readonly beta: number | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DeviceMotionEventRotationRate/gamma) */ readonly gamma: number | null; } /** * The DeviceOrientationEvent provides web developers with information from the physical orientation of the device running the web page. * Available only in secure contexts. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DeviceOrientationEvent) */ interface DeviceOrientationEvent extends Event { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DeviceOrientationEvent/absolute) */ readonly absolute: boolean; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DeviceOrientationEvent/alpha) */ readonly alpha: number | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DeviceOrientationEvent/beta) */ readonly beta: number | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DeviceOrientationEvent/gamma) */ readonly gamma: number | null; } @@ -4410,7 +6653,7 @@ declare var DeviceOrientationEvent: { new(type: string, eventInitDict?: DeviceOrientationEventInit): DeviceOrientationEvent; }; -interface DocumentEventMap extends DocumentAndElementEventHandlersEventMap, GlobalEventHandlersEventMap { +interface DocumentEventMap extends GlobalEventHandlersEventMap { "DOMContentLoaded": Event; "fullscreenchange": Event; "fullscreenerror": Event; @@ -4420,47 +6663,83 @@ interface DocumentEventMap extends DocumentAndElementEventHandlersEventMap, Glob "visibilitychange": Event; } -/** Any web page loaded in the browser and serves as an entry point into the web page's content, which is the DOM tree. */ -interface Document extends Node, DocumentAndElementEventHandlers, DocumentOrShadowRoot, FontFaceSource, GlobalEventHandlers, NonElementParentNode, ParentNode, XPathEvaluatorBase { - /** Sets or gets the URL for the current document. */ +/** + * Any web page loaded in the browser and serves as an entry point into the web page's content, which is the DOM tree. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document) + */ +interface Document extends Node, DocumentOrShadowRoot, FontFaceSource, GlobalEventHandlers, NonElementParentNode, ParentNode, XPathEvaluatorBase { + /** + * Sets or gets the URL for the current document. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/URL) + */ readonly URL: string; /** * Sets or gets the color of all active links in the document. * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/alinkColor) */ alinkColor: string; /** * Returns a reference to the collection of elements contained by the object. * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/all) */ readonly all: HTMLAllCollection; /** * Retrieves a collection of all a objects that have a name and/or id property. Objects in this collection are in HTML source order. * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/anchors) */ readonly anchors: HTMLCollectionOf; /** * Retrieves a collection of all applet objects in the document. * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/applets) */ readonly applets: HTMLCollection; /** * Deprecated. Sets or retrieves a value that indicates the background color behind the object. * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/bgColor) */ bgColor: string; - /** Specifies the beginning and end of the document body. */ + /** + * Specifies the beginning and end of the document body. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/body) + */ body: HTMLElement; - /** Returns document's encoding. */ + /** + * Returns document's encoding. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/characterSet) + */ readonly characterSet: string; /** * Gets or sets the character set used to encode the object. * @deprecated This is a legacy alias of `characterSet`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/characterSet) */ readonly charset: string; - /** Gets a value that indicates whether standards-compliant mode is switched on for the object. */ + /** + * Gets a value that indicates whether standards-compliant mode is switched on for the object. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/compatMode) + */ readonly compatMode: string; - /** Returns document's content type. */ + /** + * Returns document's content type. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/contentType) + */ readonly contentType: string; /** * Returns the HTTP cookies that apply to the Document. If there are no cookies or cookies can't be applied to this resource, the empty string will be returned. @@ -4468,132 +6747,275 @@ interface Document extends Node, DocumentAndElementEventHandlers, DocumentOrShad * Can be set, to add a new cookie to the element's set of HTTP cookies. * * If the contents are sandboxed into a unique origin (e.g. in an iframe with the sandbox attribute), a "SecurityError" DOMException will be thrown on getting and setting. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/cookie) */ cookie: string; /** * Returns the script element, or the SVG script element, that is currently executing, as long as the element represents a classic script. In the case of reentrant script execution, returns the one that most recently started executing amongst those that have not yet finished executing. * * Returns null if the Document is not currently executing a script or SVG script element (e.g., because the running script is an event handler, or a timeout), or if the currently executing script or SVG script element represents a module script. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/currentScript) */ readonly currentScript: HTMLOrSVGScriptElement | null; - /** Returns the Window object of the active document. */ + /** + * Returns the Window object of the active document. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/defaultView) + */ readonly defaultView: (WindowProxy & typeof globalThis) | null; - /** Sets or gets a value that indicates whether the document can be edited. */ + /** + * Sets or gets a value that indicates whether the document can be edited. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/designMode) + */ designMode: string; - /** Sets or retrieves a value that indicates the reading order of the object. */ + /** + * Sets or retrieves a value that indicates the reading order of the object. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/dir) + */ dir: string; - /** Gets an object representing the document type declaration associated with the current document. */ + /** + * Gets an object representing the document type declaration associated with the current document. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/doctype) + */ readonly doctype: DocumentType | null; - /** Gets a reference to the root node of the document. */ + /** + * Gets a reference to the root node of the document. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/documentElement) + */ readonly documentElement: HTMLElement; - /** Returns document's URL. */ + /** + * Returns document's URL. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/documentURI) + */ readonly documentURI: string; /** * Sets or gets the security domain of the document. * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/domain) */ domain: string; - /** Retrieves a collection of all embed objects in the document. */ + /** + * Retrieves a collection of all embed objects in the document. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/embeds) + */ readonly embeds: HTMLCollectionOf; /** * Sets or gets the foreground (text) color of the document. * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/fgColor) */ fgColor: string; - /** Retrieves a collection, in source order, of all form objects in the document. */ + /** + * Retrieves a collection, in source order, of all form objects in the document. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/forms) + */ readonly forms: HTMLCollectionOf; - /** @deprecated */ + /** + * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/fullscreen) + */ readonly fullscreen: boolean; - /** Returns true if document has the ability to display elements fullscreen and fullscreen is supported, or false otherwise. */ + /** + * Returns true if document has the ability to display elements fullscreen and fullscreen is supported, or false otherwise. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/fullscreenEnabled) + */ readonly fullscreenEnabled: boolean; - /** Returns the head element. */ + /** + * Returns the head element. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/head) + */ readonly head: HTMLHeadElement; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/hidden) */ readonly hidden: boolean; - /** Retrieves a collection, in source order, of img objects in the document. */ + /** + * Retrieves a collection, in source order, of img objects in the document. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/images) + */ readonly images: HTMLCollectionOf; - /** Gets the implementation object of the current document. */ + /** + * Gets the implementation object of the current document. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/implementation) + */ readonly implementation: DOMImplementation; /** * Returns the character encoding used to create the webpage that is loaded into the document object. * @deprecated This is a legacy alias of `characterSet`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/characterSet) */ readonly inputEncoding: string; - /** Gets the date that the page was last modified, if the page supplies one. */ + /** + * Gets the date that the page was last modified, if the page supplies one. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/lastModified) + */ readonly lastModified: string; /** * Sets or gets the color of the document links. * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/linkColor) */ linkColor: string; - /** Retrieves a collection of all a objects that specify the href property and all area objects in the document. */ + /** + * Retrieves a collection of all a objects that specify the href property and all area objects in the document. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/links) + */ readonly links: HTMLCollectionOf; - /** Contains information about the current URL. */ + /** + * Contains information about the current URL. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/location) + */ get location(): Location; set location(href: string | Location); + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/fullscreenchange_event) */ onfullscreenchange: ((this: Document, ev: Event) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/fullscreenerror_event) */ onfullscreenerror: ((this: Document, ev: Event) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/pointerlockchange_event) */ onpointerlockchange: ((this: Document, ev: Event) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/pointerlockerror_event) */ onpointerlockerror: ((this: Document, ev: Event) => any) | null; /** * Fires when the state of the object has changed. * @param ev The event + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/readystatechange_event) */ onreadystatechange: ((this: Document, ev: Event) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/visibilitychange_event) */ onvisibilitychange: ((this: Document, ev: Event) => any) | null; readonly ownerDocument: null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/pictureInPictureEnabled) */ readonly pictureInPictureEnabled: boolean; - /** Return an HTMLCollection of the embed elements in the Document. */ + /** + * Return an HTMLCollection of the embed elements in the Document. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/plugins) + */ readonly plugins: HTMLCollectionOf; - /** Retrieves a value that indicates the current state of the object. */ + /** + * Retrieves a value that indicates the current state of the object. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/readyState) + */ readonly readyState: DocumentReadyState; - /** Gets the URL of the location that referred the user to the current page. */ + /** + * Gets the URL of the location that referred the user to the current page. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/referrer) + */ readonly referrer: string; - /** @deprecated */ + /** + * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/rootElement) + */ readonly rootElement: SVGSVGElement | null; - /** Retrieves a collection of all script objects in the document. */ + /** + * Retrieves a collection of all script objects in the document. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/scripts) + */ readonly scripts: HTMLCollectionOf; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/scrollingElement) */ readonly scrollingElement: Element | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/timeline) */ readonly timeline: DocumentTimeline; - /** Contains the title of the document. */ + /** + * Contains the title of the document. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/title) + */ title: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/visibilityState) */ readonly visibilityState: DocumentVisibilityState; /** * Sets or gets the color of the links that the user has visited. * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/vlinkColor) */ vlinkColor: string; /** * Moves node from another document and returns it. * * If node is a document, throws a "NotSupportedError" DOMException or, if node is a shadow root, throws a "HierarchyRequestError" DOMException. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/adoptNode) */ adoptNode(node: T): T; - /** @deprecated */ + /** + * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/captureEvents) + */ captureEvents(): void; /** @deprecated */ caretRangeFromPoint(x: number, y: number): Range | null; - /** @deprecated */ + /** + * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/clear) + */ clear(): void; - /** Closes an output stream and forces the sent data to display. */ + /** + * Closes an output stream and forces the sent data to display. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/close) + */ close(): void; /** * Creates an attribute object with a specified name. * @param name String that sets the attribute object's name. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/createAttribute) */ createAttribute(localName: string): Attr; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/createAttributeNS) */ createAttributeNS(namespace: string | null, qualifiedName: string): Attr; - /** Returns a CDATASection node whose data is data. */ + /** + * Returns a CDATASection node whose data is data. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/createCDATASection) + */ createCDATASection(data: string): CDATASection; /** * Creates a comment object with the specified data. * @param data Sets the comment object's data. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/createComment) */ createComment(data: string): Comment; - /** Creates a new document. */ + /** + * Creates a new document. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/createDocumentFragment) + */ createDocumentFragment(): DocumentFragment; /** * Creates an instance of the element for the specified tag. * @param tagName The name of an element. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/createElement) */ createElement(tagName: K, options?: ElementCreationOptions): HTMLElementTagNameMap[K]; /** @deprecated */ @@ -4613,12 +7035,17 @@ interface Document extends Node, DocumentAndElementEventHandlers, DocumentOrShad * namespace is the XMLNS namespace and neither qualifiedName nor namespace prefix is "xmlns". * * When supplied, options's is can be used to create a customized built-in element. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/createElementNS) */ createElementNS(namespaceURI: "http://www.w3.org/1999/xhtml", qualifiedName: string): HTMLElement; createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: K): SVGElementTagNameMap[K]; createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: string): SVGElement; + createElementNS(namespaceURI: "http://www.w3.org/1998/Math/MathML", qualifiedName: K): MathMLElementTagNameMap[K]; + createElementNS(namespaceURI: "http://www.w3.org/1998/Math/MathML", qualifiedName: string): MathMLElement; createElementNS(namespaceURI: string | null, qualifiedName: string, options?: ElementCreationOptions): Element; createElementNS(namespace: string | null, qualifiedName: string, options?: string | ElementCreationOptions): Element; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/createEvent) */ createEvent(eventInterface: "AnimationEvent"): AnimationEvent; createEvent(eventInterface: "AnimationPlaybackEvent"): AnimationPlaybackEvent; createEvent(eventInterface: "AudioProcessingEvent"): AudioProcessingEvent; @@ -4642,6 +7069,8 @@ interface Document extends Node, DocumentAndElementEventHandlers, DocumentOrShad createEvent(eventInterface: "IDBVersionChangeEvent"): IDBVersionChangeEvent; createEvent(eventInterface: "InputEvent"): InputEvent; createEvent(eventInterface: "KeyboardEvent"): KeyboardEvent; + createEvent(eventInterface: "MIDIConnectionEvent"): MIDIConnectionEvent; + createEvent(eventInterface: "MIDIMessageEvent"): MIDIMessageEvent; createEvent(eventInterface: "MediaEncryptedEvent"): MediaEncryptedEvent; createEvent(eventInterface: "MediaKeyMessageEvent"): MediaKeyMessageEvent; createEvent(eventInterface: "MediaQueryListEvent"): MediaQueryListEvent; @@ -4684,15 +7113,27 @@ interface Document extends Node, DocumentAndElementEventHandlers, DocumentOrShad * @param root The root element or node to start traversing on. * @param whatToShow The type of nodes or elements to appear in the node list * @param filter A custom NodeFilter function to use. For more information, see filter. Use null for no filter. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/createNodeIterator) */ createNodeIterator(root: Node, whatToShow?: number, filter?: NodeFilter | null): NodeIterator; - /** Returns a ProcessingInstruction node whose target is target and data is data. If target does not match the Name production an "InvalidCharacterError" DOMException will be thrown. If data contains "?>" an "InvalidCharacterError" DOMException will be thrown. */ + /** + * Returns a ProcessingInstruction node whose target is target and data is data. If target does not match the Name production an "InvalidCharacterError" DOMException will be thrown. If data contains "?>" an "InvalidCharacterError" DOMException will be thrown. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/createProcessingInstruction) + */ createProcessingInstruction(target: string, data: string): ProcessingInstruction; - /** Returns an empty range object that has both of its boundary points positioned at the beginning of the document. */ + /** + * Returns an empty range object that has both of its boundary points positioned at the beginning of the document. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/createRange) + */ createRange(): Range; /** * Creates a text string from the specified value. * @param data String that specifies the nodeValue property of the text node. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/createTextNode) */ createTextNode(data: string): Text; /** @@ -4700,6 +7141,8 @@ interface Document extends Node, DocumentAndElementEventHandlers, DocumentOrShad * @param root The root element or node to start traversing on. * @param whatToShow The type of nodes or elements to appear in the node list. For more information, see whatToShow. * @param filter A custom NodeFilter function to use. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/createTreeWalker) */ createTreeWalker(root: Node, whatToShow?: number, filter?: NodeFilter | null): TreeWalker; /** @@ -4708,30 +7151,49 @@ interface Document extends Node, DocumentAndElementEventHandlers, DocumentOrShad * @param showUI Display the user interface, defaults to false. * @param value Value to assign. * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/execCommand) */ execCommand(commandId: string, showUI?: boolean, value?: string): boolean; - /** Stops document's fullscreen element from being displayed fullscreen and resolves promise when done. */ + /** + * Stops document's fullscreen element from being displayed fullscreen and resolves promise when done. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/exitFullscreen) + */ exitFullscreen(): Promise; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/exitPictureInPicture) */ exitPictureInPicture(): Promise; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/exitPointerLock) */ exitPointerLock(): void; /** * Returns a reference to the first object with the specified value of the ID attribute. * @param elementId String that specifies the ID value. */ getElementById(elementId: string): HTMLElement | null; - /** Returns a HTMLCollection of the elements in the object on which the method was invoked (a document or an element) that have all the classes given by classNames. The classNames argument is interpreted as a space-separated list of classes. */ + /** + * Returns a HTMLCollection of the elements in the object on which the method was invoked (a document or an element) that have all the classes given by classNames. The classNames argument is interpreted as a space-separated list of classes. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/getElementsByClassName) + */ getElementsByClassName(classNames: string): HTMLCollectionOf; /** * Gets a collection of objects based on the value of the NAME or ID attribute. * @param elementName Gets a collection of objects based on the value of the NAME or ID attribute. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/getElementsByName) */ getElementsByName(elementName: string): NodeListOf; /** * Retrieves a collection of objects based on the specified element name. * @param name Specifies the name of an element. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/getElementsByTagName) */ getElementsByTagName(qualifiedName: K): HTMLCollectionOf; getElementsByTagName(qualifiedName: K): HTMLCollectionOf; + getElementsByTagName(qualifiedName: K): HTMLCollectionOf; + /** @deprecated */ + getElementsByTagName(qualifiedName: K): HTMLCollectionOf; getElementsByTagName(qualifiedName: string): HTMLCollectionOf; /** * If namespace and localName are "*" returns a HTMLCollection of all descendant elements. @@ -4741,19 +7203,33 @@ interface Document extends Node, DocumentAndElementEventHandlers, DocumentOrShad * If only localName is "*" returns a HTMLCollection of all descendant elements whose namespace is namespace. * * Otherwise, returns a HTMLCollection of all descendant elements whose namespace is namespace and local name is localName. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/getElementsByTagNameNS) */ getElementsByTagNameNS(namespaceURI: "http://www.w3.org/1999/xhtml", localName: string): HTMLCollectionOf; getElementsByTagNameNS(namespaceURI: "http://www.w3.org/2000/svg", localName: string): HTMLCollectionOf; + getElementsByTagNameNS(namespaceURI: "http://www.w3.org/1998/Math/MathML", localName: string): HTMLCollectionOf; getElementsByTagNameNS(namespace: string | null, localName: string): HTMLCollectionOf; - /** Returns an object representing the current selection of the document that is loaded into the object displaying a webpage. */ + /** + * Returns an object representing the current selection of the document that is loaded into the object displaying a webpage. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/getSelection) + */ getSelection(): Selection | null; - /** Gets a value indicating whether the object currently has focus. */ + /** + * Gets a value indicating whether the object currently has focus. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/hasFocus) + */ hasFocus(): boolean; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/hasStorageAccess) */ hasStorageAccess(): Promise; /** * Returns a copy of node. If deep is true, the copy also includes the node's descendants. * * If node is a document or a shadow root, throws a "NotSupportedError" DOMException. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/importNode) */ importNode(node: T, deep?: boolean): T; /** @@ -4762,6 +7238,8 @@ interface Document extends Node, DocumentAndElementEventHandlers, DocumentOrShad * @param name Specifies the name of the window. This name is used as the value for the TARGET attribute on a form or an anchor element. * @param features Contains a list of items separated by commas. Each item consists of an option and a value, separated by an equals sign (for example, "fullscreen=yes, toolbar=yes"). The following values are supported. * @param replace Specifies whether the existing entry for the document is replaced in the history list. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/open) */ open(unused1?: string, unused2?: string): Document; open(url: string | URL, name: string, features: string): WindowProxy | null; @@ -4769,43 +7247,62 @@ interface Document extends Node, DocumentAndElementEventHandlers, DocumentOrShad * Returns a Boolean value that indicates whether a specified command can be successfully executed using execCommand, given the current state of the document. * @param commandId Specifies a command identifier. * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/queryCommandEnabled) */ queryCommandEnabled(commandId: string): boolean; /** * Returns a Boolean value that indicates whether the specified command is in the indeterminate state. * @param commandId String that specifies a command identifier. * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/queryCommandIndeterm) */ queryCommandIndeterm(commandId: string): boolean; /** * Returns a Boolean value that indicates the current state of the command. * @param commandId String that specifies a command identifier. * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/queryCommandState) */ queryCommandState(commandId: string): boolean; /** * Returns a Boolean value that indicates whether the current command is supported on the current range. * @param commandId Specifies a command identifier. * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/queryCommandSupported) */ queryCommandSupported(commandId: string): boolean; /** * Returns the current value of the document, range, or current selection for the given command. * @param commandId String that specifies a command identifier. * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/queryCommandValue) */ queryCommandValue(commandId: string): string; - /** @deprecated */ - releaseEvents(): void; + /** + * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/releaseEvents) + */ + releaseEvents(): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/requestStorageAccess) */ requestStorageAccess(): Promise; /** * Writes one or more HTML expressions to a document in the specified window. * @param content Specifies the text and HTML tags to write. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/write) */ write(...text: string[]): void; /** * Writes one or more HTML expressions, followed by a carriage return, to a document in the specified window. * @param content The text and HTML tags to write. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/writeln) */ writeln(...text: string[]): void; addEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; @@ -4819,23 +7316,11 @@ declare var Document: { new(): Document; }; -interface DocumentAndElementEventHandlersEventMap { - "copy": ClipboardEvent; - "cut": ClipboardEvent; - "paste": ClipboardEvent; -} - -interface DocumentAndElementEventHandlers { - oncopy: ((this: DocumentAndElementEventHandlers, ev: ClipboardEvent) => any) | null; - oncut: ((this: DocumentAndElementEventHandlers, ev: ClipboardEvent) => any) | null; - onpaste: ((this: DocumentAndElementEventHandlers, ev: ClipboardEvent) => any) | null; - addEventListener(type: K, listener: (this: DocumentAndElementEventHandlers, ev: DocumentAndElementEventHandlersEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; - removeEventListener(type: K, listener: (this: DocumentAndElementEventHandlers, ev: DocumentAndElementEventHandlersEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; -} - -/** A minimal document object that has no parent. It is used as a lightweight version of Document that stores a segment of a document structure comprised of nodes just like a standard document. The key difference is that because the document fragment isn't part of the active document tree structure, changes made to the fragment don't affect the document, cause reflow, or incur any performance impact that can occur when changes are made. */ +/** + * A minimal document object that has no parent. It is used as a lightweight version of Document that stores a segment of a document structure comprised of nodes just like a standard document. The key difference is that because the document fragment isn't part of the active document tree structure, changes made to the fragment don't affect the document, cause reflow, or incur any performance impact that can occur when changes are made. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DocumentFragment) + */ interface DocumentFragment extends Node, NonElementParentNode, ParentNode { readonly ownerDocument: Document; getElementById(elementId: string): HTMLElement | null; @@ -4853,14 +7338,27 @@ interface DocumentOrShadowRoot { * For the purposes of this API, when a child browsing context is focused, its container is focused in the parent browsing context. For example, if the user moves the focus to a text control in an iframe, the iframe is the element returned by the activeElement API in the iframe's node document. * * Similarly, when the focused element is in a different node tree than documentOrShadowRoot, the element returned will be the host that's located in the same node tree as documentOrShadowRoot if documentOrShadowRoot is a shadow-including inclusive ancestor of the focused element, and null if not. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/activeElement) */ readonly activeElement: Element | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/adoptedStyleSheets) */ adoptedStyleSheets: CSSStyleSheet[]; - /** Returns document's fullscreen element. */ + /** + * Returns document's fullscreen element. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/fullscreenElement) + */ readonly fullscreenElement: Element | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/pictureInPictureElement) */ readonly pictureInPictureElement: Element | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/pointerLockElement) */ readonly pointerLockElement: Element | null; - /** Retrieves a collection of styleSheet objects representing the style sheets that correspond to each instance of a link or style object in the document. */ + /** + * Retrieves a collection of styleSheet objects representing the style sheets that correspond to each instance of a link or style object in the document. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/styleSheets) + */ readonly styleSheets: StyleSheetList; /** * Returns the element for the specified x coordinate and the specified y coordinate. @@ -4869,9 +7367,11 @@ interface DocumentOrShadowRoot { */ elementFromPoint(x: number, y: number): Element | null; elementsFromPoint(x: number, y: number): Element[]; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/getAnimations) */ getAnimations(): Animation[]; } +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DocumentTimeline) */ interface DocumentTimeline extends AnimationTimeline { } @@ -4880,11 +7380,18 @@ declare var DocumentTimeline: { new(options?: DocumentTimelineOptions): DocumentTimeline; }; -/** A Node containing a doctype. */ +/** + * A Node containing a doctype. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DocumentType) + */ interface DocumentType extends Node, ChildNode { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DocumentType/name) */ readonly name: string; readonly ownerDocument: Document; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DocumentType/publicId) */ readonly publicId: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DocumentType/systemId) */ readonly systemId: string; } @@ -4893,9 +7400,17 @@ declare var DocumentType: { new(): DocumentType; }; -/** A DOM event that represents a drag and drop interaction. The user initiates a drag by placing a pointer device (such as a mouse) on the touch surface and then dragging the pointer to a new location (such as another DOM element). Applications are free to interpret a drag and drop interaction in an application-specific way. */ +/** + * A DOM event that represents a drag and drop interaction. The user initiates a drag by placing a pointer device (such as a mouse) on the touch surface and then dragging the pointer to a new location (such as another DOM element). Applications are free to interpret a drag and drop interaction in an application-specific way. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DragEvent) + */ interface DragEvent extends MouseEvent { - /** Returns the DataTransfer object for the event. */ + /** + * Returns the DataTransfer object for the event. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DragEvent/dataTransfer) + */ readonly dataTransfer: DataTransfer | null; } @@ -4904,13 +7419,23 @@ declare var DragEvent: { new(type: string, eventInitDict?: DragEventInit): DragEvent; }; -/** Inherits properties from its parent, AudioNode. */ +/** + * Inherits properties from its parent, AudioNode. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DynamicsCompressorNode) + */ interface DynamicsCompressorNode extends AudioNode { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DynamicsCompressorNode/attack) */ readonly attack: AudioParam; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DynamicsCompressorNode/knee) */ readonly knee: AudioParam; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DynamicsCompressorNode/ratio) */ readonly ratio: AudioParam; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DynamicsCompressorNode/reduction) */ readonly reduction: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DynamicsCompressorNode/release) */ readonly release: AudioParam; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DynamicsCompressorNode/threshold) */ readonly threshold: AudioParam; } @@ -4919,67 +7444,84 @@ declare var DynamicsCompressorNode: { new(context: BaseAudioContext, options?: DynamicsCompressorOptions): DynamicsCompressorNode; }; +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EXT_blend_minmax) */ interface EXT_blend_minmax { - readonly MAX_EXT: GLenum; - readonly MIN_EXT: GLenum; + readonly MIN_EXT: 0x8007; + readonly MAX_EXT: 0x8008; } +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EXT_color_buffer_float) */ interface EXT_color_buffer_float { } +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EXT_color_buffer_half_float) */ interface EXT_color_buffer_half_float { - readonly FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT: GLenum; - readonly RGB16F_EXT: GLenum; - readonly RGBA16F_EXT: GLenum; - readonly UNSIGNED_NORMALIZED_EXT: GLenum; + readonly RGBA16F_EXT: 0x881A; + readonly RGB16F_EXT: 0x881B; + readonly FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT: 0x8211; + readonly UNSIGNED_NORMALIZED_EXT: 0x8C17; } +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EXT_float_blend) */ interface EXT_float_blend { } -/** The EXT_frag_depth extension is part of the WebGL API and enables to set a depth value of a fragment from within the fragment shader. */ +/** + * The EXT_frag_depth extension is part of the WebGL API and enables to set a depth value of a fragment from within the fragment shader. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EXT_frag_depth) + */ interface EXT_frag_depth { } +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EXT_sRGB) */ interface EXT_sRGB { - readonly FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT: GLenum; - readonly SRGB8_ALPHA8_EXT: GLenum; - readonly SRGB_ALPHA_EXT: GLenum; - readonly SRGB_EXT: GLenum; + readonly SRGB_EXT: 0x8C40; + readonly SRGB_ALPHA_EXT: 0x8C42; + readonly SRGB8_ALPHA8_EXT: 0x8C43; + readonly FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT: 0x8210; } +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EXT_shader_texture_lod) */ interface EXT_shader_texture_lod { } +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EXT_texture_compression_bptc) */ interface EXT_texture_compression_bptc { - readonly COMPRESSED_RGBA_BPTC_UNORM_EXT: GLenum; - readonly COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT: GLenum; - readonly COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT: GLenum; - readonly COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT: GLenum; + readonly COMPRESSED_RGBA_BPTC_UNORM_EXT: 0x8E8C; + readonly COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT: 0x8E8D; + readonly COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT: 0x8E8E; + readonly COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT: 0x8E8F; } +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EXT_texture_compression_rgtc) */ interface EXT_texture_compression_rgtc { - readonly COMPRESSED_RED_GREEN_RGTC2_EXT: GLenum; - readonly COMPRESSED_RED_RGTC1_EXT: GLenum; - readonly COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT: GLenum; - readonly COMPRESSED_SIGNED_RED_RGTC1_EXT: GLenum; + readonly COMPRESSED_RED_RGTC1_EXT: 0x8DBB; + readonly COMPRESSED_SIGNED_RED_RGTC1_EXT: 0x8DBC; + readonly COMPRESSED_RED_GREEN_RGTC2_EXT: 0x8DBD; + readonly COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT: 0x8DBE; } -/** The EXT_texture_filter_anisotropic extension is part of the WebGL API and exposes two constants for anisotropic filtering (AF). */ +/** + * The EXT_texture_filter_anisotropic extension is part of the WebGL API and exposes two constants for anisotropic filtering (AF). + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EXT_texture_filter_anisotropic) + */ interface EXT_texture_filter_anisotropic { - readonly MAX_TEXTURE_MAX_ANISOTROPY_EXT: GLenum; - readonly TEXTURE_MAX_ANISOTROPY_EXT: GLenum; + readonly TEXTURE_MAX_ANISOTROPY_EXT: 0x84FE; + readonly MAX_TEXTURE_MAX_ANISOTROPY_EXT: 0x84FF; } +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EXT_texture_norm16) */ interface EXT_texture_norm16 { - readonly R16_EXT: GLenum; - readonly R16_SNORM_EXT: GLenum; - readonly RG16_EXT: GLenum; - readonly RG16_SNORM_EXT: GLenum; - readonly RGB16_EXT: GLenum; - readonly RGB16_SNORM_EXT: GLenum; - readonly RGBA16_EXT: GLenum; - readonly RGBA16_SNORM_EXT: GLenum; + readonly R16_EXT: 0x822A; + readonly RG16_EXT: 0x822C; + readonly RGB16_EXT: 0x8054; + readonly RGBA16_EXT: 0x805B; + readonly R16_SNORM_EXT: 0x8F98; + readonly RG16_SNORM_EXT: 0x8F99; + readonly RGB16_SNORM_EXT: 0x8F9A; + readonly RGBA16_SNORM_EXT: 0x8F9B; } interface ElementEventMap { @@ -4987,110 +7529,255 @@ interface ElementEventMap { "fullscreenerror": Event; } -/** Element is the most general base class from which all objects in a Document inherit. It only has methods and properties common to all kinds of elements. More specific classes inherit from Element. */ +/** + * Element is the most general base class from which all objects in a Document inherit. It only has methods and properties common to all kinds of elements. More specific classes inherit from Element. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element) + */ interface Element extends Node, ARIAMixin, Animatable, ChildNode, InnerHTML, NonDocumentTypeChildNode, ParentNode, Slottable { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/attributes) */ readonly attributes: NamedNodeMap; - /** Allows for manipulation of element's class content attribute as a set of whitespace-separated tokens through a DOMTokenList object. */ + /** + * Allows for manipulation of element's class content attribute as a set of whitespace-separated tokens through a DOMTokenList object. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/classList) + */ readonly classList: DOMTokenList; - /** Returns the value of element's class content attribute. Can be set to change it. */ + /** + * Returns the value of element's class content attribute. Can be set to change it. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/className) + */ className: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/clientHeight) */ readonly clientHeight: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/clientLeft) */ readonly clientLeft: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/clientTop) */ readonly clientTop: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/clientWidth) */ readonly clientWidth: number; - /** Returns the value of element's id content attribute. Can be set to change it. */ + /** + * Returns the value of element's id content attribute. Can be set to change it. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/id) + */ id: string; - /** Returns the local name. */ + /** + * Returns the local name. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/localName) + */ readonly localName: string; - /** Returns the namespace. */ + /** + * Returns the namespace. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/namespaceURI) + */ readonly namespaceURI: string | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/fullscreenchange_event) */ onfullscreenchange: ((this: Element, ev: Event) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/fullscreenerror_event) */ onfullscreenerror: ((this: Element, ev: Event) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/outerHTML) */ outerHTML: string; readonly ownerDocument: Document; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/part) */ readonly part: DOMTokenList; - /** Returns the namespace prefix. */ + /** + * Returns the namespace prefix. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/prefix) + */ readonly prefix: string | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/scrollHeight) */ readonly scrollHeight: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/scrollLeft) */ scrollLeft: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/scrollTop) */ scrollTop: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/scrollWidth) */ readonly scrollWidth: number; - /** Returns element's shadow root, if any, and if shadow root's mode is "open", and null otherwise. */ + /** + * Returns element's shadow root, if any, and if shadow root's mode is "open", and null otherwise. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/shadowRoot) + */ readonly shadowRoot: ShadowRoot | null; - /** Returns the value of element's slot content attribute. Can be set to change it. */ + /** + * Returns the value of element's slot content attribute. Can be set to change it. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/slot) + */ slot: string; - /** Returns the HTML-uppercased qualified name. */ + /** + * Returns the HTML-uppercased qualified name. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/tagName) + */ readonly tagName: string; - /** Creates a shadow root for element and returns it. */ + /** + * Creates a shadow root for element and returns it. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/attachShadow) + */ attachShadow(init: ShadowRootInit): ShadowRoot; - /** Returns the first (starting at element) inclusive ancestor that matches selectors, and null otherwise. */ + checkVisibility(options?: CheckVisibilityOptions): boolean; + /** + * Returns the first (starting at element) inclusive ancestor that matches selectors, and null otherwise. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/closest) + */ closest(selector: K): HTMLElementTagNameMap[K] | null; closest(selector: K): SVGElementTagNameMap[K] | null; + closest(selector: K): MathMLElementTagNameMap[K] | null; closest(selectors: string): E | null; - /** Returns element's first attribute whose qualified name is qualifiedName, and null if there is no such attribute otherwise. */ + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/computedStyleMap) */ + computedStyleMap(): StylePropertyMapReadOnly; + /** + * Returns element's first attribute whose qualified name is qualifiedName, and null if there is no such attribute otherwise. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/getAttribute) + */ getAttribute(qualifiedName: string): string | null; - /** Returns element's attribute whose namespace is namespace and local name is localName, and null if there is no such attribute otherwise. */ + /** + * Returns element's attribute whose namespace is namespace and local name is localName, and null if there is no such attribute otherwise. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/getAttributeNS) + */ getAttributeNS(namespace: string | null, localName: string): string | null; - /** Returns the qualified names of all element's attributes. Can contain duplicates. */ + /** + * Returns the qualified names of all element's attributes. Can contain duplicates. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/getAttributeNames) + */ getAttributeNames(): string[]; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/getAttributeNode) */ getAttributeNode(qualifiedName: string): Attr | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/getAttributeNodeNS) */ getAttributeNodeNS(namespace: string | null, localName: string): Attr | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/getBoundingClientRect) */ getBoundingClientRect(): DOMRect; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/getClientRects) */ getClientRects(): DOMRectList; - /** Returns a HTMLCollection of the elements in the object on which the method was invoked (a document or an element) that have all the classes given by classNames. The classNames argument is interpreted as a space-separated list of classes. */ + /** + * Returns a HTMLCollection of the elements in the object on which the method was invoked (a document or an element) that have all the classes given by classNames. The classNames argument is interpreted as a space-separated list of classes. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/getElementsByClassName) + */ getElementsByClassName(classNames: string): HTMLCollectionOf; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/getElementsByTagName) */ getElementsByTagName(qualifiedName: K): HTMLCollectionOf; getElementsByTagName(qualifiedName: K): HTMLCollectionOf; + getElementsByTagName(qualifiedName: K): HTMLCollectionOf; + /** @deprecated */ + getElementsByTagName(qualifiedName: K): HTMLCollectionOf; getElementsByTagName(qualifiedName: string): HTMLCollectionOf; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/getElementsByTagNameNS) */ getElementsByTagNameNS(namespaceURI: "http://www.w3.org/1999/xhtml", localName: string): HTMLCollectionOf; getElementsByTagNameNS(namespaceURI: "http://www.w3.org/2000/svg", localName: string): HTMLCollectionOf; + getElementsByTagNameNS(namespaceURI: "http://www.w3.org/1998/Math/MathML", localName: string): HTMLCollectionOf; getElementsByTagNameNS(namespace: string | null, localName: string): HTMLCollectionOf; - /** Returns true if element has an attribute whose qualified name is qualifiedName, and false otherwise. */ + /** + * Returns true if element has an attribute whose qualified name is qualifiedName, and false otherwise. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/hasAttribute) + */ hasAttribute(qualifiedName: string): boolean; - /** Returns true if element has an attribute whose namespace is namespace and local name is localName. */ + /** + * Returns true if element has an attribute whose namespace is namespace and local name is localName. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/hasAttributeNS) + */ hasAttributeNS(namespace: string | null, localName: string): boolean; - /** Returns true if element has attributes, and false otherwise. */ + /** + * Returns true if element has attributes, and false otherwise. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/hasAttributes) + */ hasAttributes(): boolean; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/hasPointerCapture) */ hasPointerCapture(pointerId: number): boolean; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/insertAdjacentElement) */ insertAdjacentElement(where: InsertPosition, element: Element): Element | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/insertAdjacentHTML) */ insertAdjacentHTML(position: InsertPosition, text: string): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/insertAdjacentText) */ insertAdjacentText(where: InsertPosition, data: string): void; - /** Returns true if matching selectors against element's root yields element, and false otherwise. */ + /** + * Returns true if matching selectors against element's root yields element, and false otherwise. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/matches) + */ matches(selectors: string): boolean; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/releasePointerCapture) */ releasePointerCapture(pointerId: number): void; - /** Removes element's first attribute whose qualified name is qualifiedName. */ + /** + * Removes element's first attribute whose qualified name is qualifiedName. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/removeAttribute) + */ removeAttribute(qualifiedName: string): void; - /** Removes element's attribute whose namespace is namespace and local name is localName. */ + /** + * Removes element's attribute whose namespace is namespace and local name is localName. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/removeAttributeNS) + */ removeAttributeNS(namespace: string | null, localName: string): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/removeAttributeNode) */ removeAttributeNode(attr: Attr): Attr; /** * Displays element fullscreen and resolves promise when done. * * When supplied, options's navigationUI member indicates whether showing navigation UI while in fullscreen is preferred or not. If set to "show", navigation simplicity is preferred over screen space, and if set to "hide", more screen space is preferred. User agents are always free to honor user preference over the application's. The default value "auto" indicates no application preference. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/requestFullscreen) */ requestFullscreen(options?: FullscreenOptions): Promise; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/requestPointerLock) */ requestPointerLock(): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/scroll) */ scroll(options?: ScrollToOptions): void; scroll(x: number, y: number): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/scrollBy) */ scrollBy(options?: ScrollToOptions): void; scrollBy(x: number, y: number): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/scrollIntoView) */ scrollIntoView(arg?: boolean | ScrollIntoViewOptions): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/scrollTo) */ scrollTo(options?: ScrollToOptions): void; scrollTo(x: number, y: number): void; - /** Sets the value of element's first attribute whose qualified name is qualifiedName to value. */ + /** + * Sets the value of element's first attribute whose qualified name is qualifiedName to value. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/setAttribute) + */ setAttribute(qualifiedName: string, value: string): void; - /** Sets the value of element's attribute whose namespace is namespace and local name is localName to value. */ + /** + * Sets the value of element's attribute whose namespace is namespace and local name is localName to value. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/setAttributeNS) + */ setAttributeNS(namespace: string | null, qualifiedName: string, value: string): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/setAttributeNode) */ setAttributeNode(attr: Attr): Attr | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/setAttributeNodeNS) */ setAttributeNodeNS(attr: Attr): Attr | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/setPointerCapture) */ setPointerCapture(pointerId: number): void; /** * If force is not given, "toggles" qualifiedName, removing it if it is present and adding it if it is not present. If force is true, adds qualifiedName. If force is false, removes qualifiedName. * * Returns true if qualifiedName is now present, and false otherwise. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/toggleAttribute) */ toggleAttribute(qualifiedName: string, force?: boolean): boolean; - /** @deprecated This is a legacy alias of `matches`. */ + /** + * @deprecated This is a legacy alias of `matches`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/matches) + */ webkitMatchesSelector(selectors: string): boolean; addEventListener(type: K, listener: (this: Element, ev: ElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; @@ -5104,40 +7791,85 @@ declare var Element: { }; interface ElementCSSInlineStyle { + readonly attributeStyleMap: StylePropertyMap; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLElement/style) */ readonly style: CSSStyleDeclaration; } interface ElementContentEditable { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLElement/contentEditable) */ contentEditable: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLElement/enterKeyHint) */ enterKeyHint: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLElement/inputMode) */ inputMode: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLElement/isContentEditable) */ readonly isContentEditable: boolean; } +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ElementInternals) */ interface ElementInternals extends ARIAMixin { - /** Returns the form owner of internals's target element. */ + /** + * Returns the form owner of internals's target element. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ElementInternals/form) + */ readonly form: HTMLFormElement | null; - /** Returns a NodeList of all the label elements that internals's target element is associated with. */ + /** + * Returns a NodeList of all the label elements that internals's target element is associated with. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ElementInternals/labels) + */ readonly labels: NodeList; - /** Returns the ShadowRoot for internals's target element, if the target element is a shadow host, or null otherwise. */ + /** + * Returns the ShadowRoot for internals's target element, if the target element is a shadow host, or null otherwise. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ElementInternals/shadowRoot) + */ readonly shadowRoot: ShadowRoot | null; - /** Returns the error message that would be shown to the user if internals's target element was to be checked for validity. */ + /** + * Returns the error message that would be shown to the user if internals's target element was to be checked for validity. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ElementInternals/validationMessage) + */ readonly validationMessage: string; - /** Returns the ValidityState object for internals's target element. */ + /** + * Returns the ValidityState object for internals's target element. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ElementInternals/validity) + */ readonly validity: ValidityState; - /** Returns true if internals's target element will be validated when the form is submitted; false otherwise. */ + /** + * Returns true if internals's target element will be validated when the form is submitted; false otherwise. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ElementInternals/willValidate) + */ readonly willValidate: boolean; - /** Returns true if internals's target element has no validity problems; false otherwise. Fires an invalid event at the element in the latter case. */ + /** + * Returns true if internals's target element has no validity problems; false otherwise. Fires an invalid event at the element in the latter case. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ElementInternals/checkValidity) + */ checkValidity(): boolean; - /** Returns true if internals's target element has no validity problems; otherwise, returns false, fires an invalid event at the element, and (if the event isn't canceled) reports the problem to the user. */ + /** + * Returns true if internals's target element has no validity problems; otherwise, returns false, fires an invalid event at the element, and (if the event isn't canceled) reports the problem to the user. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ElementInternals/reportValidity) + */ reportValidity(): boolean; /** * Sets both the state and submission value of internals's target element to value. * * If value is null, the element won't participate in form submission. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ElementInternals/setFormValue) */ setFormValue(value: File | string | FormData | null, state?: File | string | FormData | null): void; - /** Marks internals's target element as suffering from the constraints indicated by the flags argument, and sets the element's validation message to message. If anchor is specified, the user agent might use it to indicate problems with the constraints of internals's target element when the form owner is validated interactively or reportValidity() is called. */ + /** + * Marks internals's target element as suffering from the constraints indicated by the flags argument, and sets the element's validation message to message. If anchor is specified, the user agent might use it to indicate problems with the constraints of internals's target element when the form owner is validated interactively or reportValidity() is called. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ElementInternals/setValidity) + */ setValidity(flags?: ValidityStateFlags, message?: string, anchor?: HTMLElement): void; } @@ -5146,12 +7878,40 @@ declare var ElementInternals: { new(): ElementInternals; }; -/** Events providing information related to errors in scripts or in files. */ +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EncodedVideoChunk) */ +interface EncodedVideoChunk { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EncodedVideoChunk/byteLength) */ + readonly byteLength: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EncodedVideoChunk/duration) */ + readonly duration: number | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EncodedVideoChunk/timestamp) */ + readonly timestamp: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EncodedVideoChunk/type) */ + readonly type: EncodedVideoChunkType; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EncodedVideoChunk/copyTo) */ + copyTo(destination: BufferSource): void; +} + +declare var EncodedVideoChunk: { + prototype: EncodedVideoChunk; + new(init: EncodedVideoChunkInit): EncodedVideoChunk; +}; + +/** + * Events providing information related to errors in scripts or in files. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent) + */ interface ErrorEvent extends Event { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/colno) */ readonly colno: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/error) */ readonly error: any; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/filename) */ readonly filename: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/lineno) */ readonly lineno: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/message) */ readonly message: string; } @@ -5160,59 +7920,136 @@ declare var ErrorEvent: { new(type: string, eventInitDict?: ErrorEventInit): ErrorEvent; }; -/** An event which takes place in the DOM. */ +/** + * An event which takes place in the DOM. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event) + */ interface Event { - /** Returns true or false depending on how event was initialized. True if event goes through its target's ancestors in reverse tree order, and false otherwise. */ + /** + * Returns true or false depending on how event was initialized. True if event goes through its target's ancestors in reverse tree order, and false otherwise. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/bubbles) + */ readonly bubbles: boolean; - /** @deprecated */ + /** + * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelBubble) + */ cancelBubble: boolean; - /** Returns true or false depending on how event was initialized. Its return value does not always carry meaning, but true can indicate that part of the operation during which event was dispatched, can be canceled by invoking the preventDefault() method. */ + /** + * Returns true or false depending on how event was initialized. Its return value does not always carry meaning, but true can indicate that part of the operation during which event was dispatched, can be canceled by invoking the preventDefault() method. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelable) + */ readonly cancelable: boolean; - /** Returns true or false depending on how event was initialized. True if event invokes listeners past a ShadowRoot node that is the root of its target, and false otherwise. */ + /** + * Returns true or false depending on how event was initialized. True if event invokes listeners past a ShadowRoot node that is the root of its target, and false otherwise. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/composed) + */ readonly composed: boolean; - /** Returns the object whose event listener's callback is currently being invoked. */ + /** + * Returns the object whose event listener's callback is currently being invoked. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/currentTarget) + */ readonly currentTarget: EventTarget | null; - /** Returns true if preventDefault() was invoked successfully to indicate cancelation, and false otherwise. */ + /** + * Returns true if preventDefault() was invoked successfully to indicate cancelation, and false otherwise. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/defaultPrevented) + */ readonly defaultPrevented: boolean; - /** Returns the event's phase, which is one of NONE, CAPTURING_PHASE, AT_TARGET, and BUBBLING_PHASE. */ + /** + * Returns the event's phase, which is one of NONE, CAPTURING_PHASE, AT_TARGET, and BUBBLING_PHASE. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/eventPhase) + */ readonly eventPhase: number; - /** Returns true if event was dispatched by the user agent, and false otherwise. */ + /** + * Returns true if event was dispatched by the user agent, and false otherwise. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/isTrusted) + */ readonly isTrusted: boolean; - /** @deprecated */ + /** + * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/returnValue) + */ returnValue: boolean; - /** @deprecated */ + /** + * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/srcElement) + */ readonly srcElement: EventTarget | null; - /** Returns the object to which event is dispatched (its target). */ + /** + * Returns the object to which event is dispatched (its target). + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/target) + */ readonly target: EventTarget | null; - /** Returns the event's timestamp as the number of milliseconds measured relative to the time origin. */ + /** + * Returns the event's timestamp as the number of milliseconds measured relative to the time origin. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/timeStamp) + */ readonly timeStamp: DOMHighResTimeStamp; - /** Returns the type of event, e.g. "click", "hashchange", or "submit". */ + /** + * Returns the type of event, e.g. "click", "hashchange", or "submit". + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/type) + */ readonly type: string; - /** Returns the invocation target objects of event's path (objects on which listeners will be invoked), except for any nodes in shadow trees of which the shadow root's mode is "closed" that are not reachable from event's currentTarget. */ + /** + * Returns the invocation target objects of event's path (objects on which listeners will be invoked), except for any nodes in shadow trees of which the shadow root's mode is "closed" that are not reachable from event's currentTarget. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/composedPath) + */ composedPath(): EventTarget[]; - /** @deprecated */ + /** + * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/initEvent) + */ initEvent(type: string, bubbles?: boolean, cancelable?: boolean): void; - /** If invoked when the cancelable attribute value is true, and while executing a listener for the event with passive set to false, signals to the operation that caused event to be dispatched that it needs to be canceled. */ + /** + * If invoked when the cancelable attribute value is true, and while executing a listener for the event with passive set to false, signals to the operation that caused event to be dispatched that it needs to be canceled. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/preventDefault) + */ preventDefault(): void; - /** Invoking this method prevents event from reaching any registered event listeners after the current one finishes running and, when dispatched in a tree, also prevents event from reaching any other objects. */ + /** + * Invoking this method prevents event from reaching any registered event listeners after the current one finishes running and, when dispatched in a tree, also prevents event from reaching any other objects. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/stopImmediatePropagation) + */ stopImmediatePropagation(): void; - /** When dispatched in a tree, invoking this method prevents event from reaching any objects other than the current object. */ + /** + * When dispatched in a tree, invoking this method prevents event from reaching any objects other than the current object. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/stopPropagation) + */ stopPropagation(): void; - readonly AT_TARGET: number; - readonly BUBBLING_PHASE: number; - readonly CAPTURING_PHASE: number; - readonly NONE: number; + readonly NONE: 0; + readonly CAPTURING_PHASE: 1; + readonly AT_TARGET: 2; + readonly BUBBLING_PHASE: 3; } declare var Event: { prototype: Event; new(type: string, eventInitDict?: EventInit): Event; - readonly AT_TARGET: number; - readonly BUBBLING_PHASE: number; - readonly CAPTURING_PHASE: number; - readonly NONE: number; + readonly NONE: 0; + readonly CAPTURING_PHASE: 1; + readonly AT_TARGET: 2; + readonly BUBBLING_PHASE: 3; }; +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventCounts) */ interface EventCounts { forEach(callbackfn: (value: number, key: string, parent: EventCounts) => void, thisArg?: any): void; } @@ -5236,21 +8073,41 @@ interface EventSourceEventMap { "open": Event; } +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource) */ interface EventSource extends EventTarget { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */ onerror: ((this: EventSource, ev: Event) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */ onmessage: ((this: EventSource, ev: MessageEvent) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */ onopen: ((this: EventSource, ev: Event) => any) | null; - /** Returns the state of this EventSource object's connection. It can have the values described below. */ + /** + * Returns the state of this EventSource object's connection. It can have the values described below. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/readyState) + */ readonly readyState: number; - /** Returns the URL providing the event stream. */ + /** + * Returns the URL providing the event stream. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/url) + */ readonly url: string; - /** Returns true if the credentials mode for connection requests to the URL providing the event stream is set to "include", and false otherwise. */ + /** + * Returns true if the credentials mode for connection requests to the URL providing the event stream is set to "include", and false otherwise. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/withCredentials) + */ readonly withCredentials: boolean; - /** Aborts any instances of the fetch algorithm started for this EventSource object, and sets the readyState attribute to CLOSED. */ + /** + * Aborts any instances of the fetch algorithm started for this EventSource object, and sets the readyState attribute to CLOSED. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/close) + */ close(): void; - readonly CLOSED: number; - readonly CONNECTING: number; - readonly OPEN: number; + readonly CONNECTING: 0; + readonly OPEN: 1; + readonly CLOSED: 2; addEventListener(type: K, listener: (this: EventSource, ev: EventSourceEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: (this: EventSource, event: MessageEvent) => any, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; @@ -5262,12 +8119,16 @@ interface EventSource extends EventTarget { declare var EventSource: { prototype: EventSource; new(url: string | URL, eventSourceInitDict?: EventSourceInit): EventSource; - readonly CLOSED: number; - readonly CONNECTING: number; - readonly OPEN: number; + readonly CONNECTING: 0; + readonly OPEN: 1; + readonly CLOSED: 2; }; -/** EventTarget is a DOM interface implemented by objects that can receive events and may have listeners for them. */ +/** + * EventTarget is a DOM interface implemented by objects that can receive events and may have listeners for them. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget) + */ interface EventTarget { /** * Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched. @@ -5283,11 +8144,21 @@ interface EventTarget { * If an AbortSignal is passed for options's signal, then the event listener will be removed when signal is aborted. * * The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener) */ addEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: AddEventListenerOptions | boolean): void; - /** Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise. */ + /** + * Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent) + */ dispatchEvent(event: Event): boolean; - /** Removes the event listener in target's event listener list with the same type, callback, and options. */ + /** + * Removes the event listener in target's event listener list with the same type, callback, and options. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/removeEventListener) + */ removeEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: EventListenerOptions | boolean): void; } @@ -5296,11 +8167,23 @@ declare var EventTarget: { new(): EventTarget; }; -/** @deprecated */ +/** + * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/External) + */ interface External { - /** @deprecated */ + /** + * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/External/AddSearchProvider) + */ AddSearchProvider(): void; - /** @deprecated */ + /** + * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/External/IsSearchProviderInstalled) + */ IsSearchProviderInstalled(): void; } @@ -5310,10 +8193,17 @@ declare var External: { new(): External; }; -/** Provides information about files and allows JavaScript in a web page to access their content. */ +/** + * Provides information about files and allows JavaScript in a web page to access their content. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/File) + */ interface File extends Blob { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/lastModified) */ readonly lastModified: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/name) */ readonly name: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/webkitRelativePath) */ readonly webkitRelativePath: string; } @@ -5322,9 +8212,15 @@ declare var File: { new(fileBits: BlobPart[], fileName: string, options?: FilePropertyBag): File; }; -/** An object of this type is returned by the files property of the HTML element; this lets you access the list of files selected with the element. It's also used for a list of files dropped into web content when using the drag and drop API; see the DataTransfer object for details on this usage. */ +/** + * An object of this type is returned by the files property of the HTML element; this lets you access the list of files selected with the element. It's also used for a list of files dropped into web content when using the drag and drop API; see the DataTransfer object for details on this usage. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileList) + */ interface FileList { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileList/length) */ readonly length: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileList/item) */ item(index: number): File | null; [index: number]: File; } @@ -5343,25 +8239,43 @@ interface FileReaderEventMap { "progress": ProgressEvent; } -/** Lets web applications asynchronously read the contents of files (or raw data buffers) stored on the user's computer, using File or Blob objects to specify the file or data to read. */ +/** + * Lets web applications asynchronously read the contents of files (or raw data buffers) stored on the user's computer, using File or Blob objects to specify the file or data to read. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileReader) + */ interface FileReader extends EventTarget { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileReader/error) */ readonly error: DOMException | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileReader/abort_event) */ onabort: ((this: FileReader, ev: ProgressEvent) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileReader/error_event) */ onerror: ((this: FileReader, ev: ProgressEvent) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileReader/load_event) */ onload: ((this: FileReader, ev: ProgressEvent) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileReader/loadend_event) */ onloadend: ((this: FileReader, ev: ProgressEvent) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileReader/loadstart_event) */ onloadstart: ((this: FileReader, ev: ProgressEvent) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileReader/progress_event) */ onprogress: ((this: FileReader, ev: ProgressEvent) => any) | null; - readonly readyState: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileReader/readyState) */ + readonly readyState: typeof FileReader.EMPTY | typeof FileReader.LOADING | typeof FileReader.DONE; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileReader/result) */ readonly result: string | ArrayBuffer | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileReader/abort) */ abort(): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileReader/readAsArrayBuffer) */ readAsArrayBuffer(blob: Blob): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileReader/readAsBinaryString) */ readAsBinaryString(blob: Blob): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileReader/readAsDataURL) */ readAsDataURL(blob: Blob): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileReader/readAsText) */ readAsText(blob: Blob, encoding?: string): void; - readonly DONE: number; - readonly EMPTY: number; - readonly LOADING: number; + readonly EMPTY: 0; + readonly LOADING: 1; + readonly DONE: 2; addEventListener(type: K, listener: (this: FileReader, ev: FileReaderEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: FileReader, ev: FileReaderEventMap[K]) => any, options?: boolean | EventListenerOptions): void; @@ -5371,13 +8285,16 @@ interface FileReader extends EventTarget { declare var FileReader: { prototype: FileReader; new(): FileReader; - readonly DONE: number; - readonly EMPTY: number; - readonly LOADING: number; + readonly EMPTY: 0; + readonly LOADING: 1; + readonly DONE: 2; }; +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystem) */ interface FileSystem { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystem/name) */ readonly name: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystem/root) */ readonly root: FileSystemDirectoryEntry; } @@ -5386,9 +8303,13 @@ declare var FileSystem: { new(): FileSystem; }; +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemDirectoryEntry) */ interface FileSystemDirectoryEntry extends FileSystemEntry { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemDirectoryEntry/createReader) */ createReader(): FileSystemDirectoryReader; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemDirectoryEntry/getDirectory) */ getDirectory(path?: string | null, options?: FileSystemFlags, successCallback?: FileSystemEntryCallback, errorCallback?: ErrorCallback): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemDirectoryEntry/getFile) */ getFile(path?: string | null, options?: FileSystemFlags, successCallback?: FileSystemEntryCallback, errorCallback?: ErrorCallback): void; } @@ -5397,12 +8318,20 @@ declare var FileSystemDirectoryEntry: { new(): FileSystemDirectoryEntry; }; -/** Available only in secure contexts. */ +/** + * Available only in secure contexts. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemDirectoryHandle) + */ interface FileSystemDirectoryHandle extends FileSystemHandle { readonly kind: "directory"; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemDirectoryHandle/getDirectoryHandle) */ getDirectoryHandle(name: string, options?: FileSystemGetDirectoryOptions): Promise; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemDirectoryHandle/getFileHandle) */ getFileHandle(name: string, options?: FileSystemGetFileOptions): Promise; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemDirectoryHandle/removeEntry) */ removeEntry(name: string, options?: FileSystemRemoveOptions): Promise; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemDirectoryHandle/resolve) */ resolve(possibleDescendant: FileSystemHandle): Promise; } @@ -5411,7 +8340,9 @@ declare var FileSystemDirectoryHandle: { new(): FileSystemDirectoryHandle; }; +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemDirectoryReader) */ interface FileSystemDirectoryReader { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemDirectoryReader/readEntries) */ readEntries(successCallback: FileSystemEntriesCallback, errorCallback?: ErrorCallback): void; } @@ -5420,12 +8351,19 @@ declare var FileSystemDirectoryReader: { new(): FileSystemDirectoryReader; }; +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemEntry) */ interface FileSystemEntry { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemEntry/filesystem) */ readonly filesystem: FileSystem; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemEntry/fullPath) */ readonly fullPath: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemEntry/isDirectory) */ readonly isDirectory: boolean; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemEntry/isFile) */ readonly isFile: boolean; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemEntry/name) */ readonly name: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemEntry/getParent) */ getParent(successCallback?: FileSystemEntryCallback, errorCallback?: ErrorCallback): void; } @@ -5434,7 +8372,9 @@ declare var FileSystemEntry: { new(): FileSystemEntry; }; +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemFileEntry) */ interface FileSystemFileEntry extends FileSystemEntry { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemFileEntry/file) */ file(successCallback: FileCallback, errorCallback?: ErrorCallback): void; } @@ -5443,9 +8383,16 @@ declare var FileSystemFileEntry: { new(): FileSystemFileEntry; }; -/** Available only in secure contexts. */ +/** + * Available only in secure contexts. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemFileHandle) + */ interface FileSystemFileHandle extends FileSystemHandle { readonly kind: "file"; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemFileHandle/createWritable) */ + createWritable(options?: FileSystemCreateWritableOptions): Promise; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemFileHandle/getFile) */ getFile(): Promise; } @@ -5454,10 +8401,17 @@ declare var FileSystemFileHandle: { new(): FileSystemFileHandle; }; -/** Available only in secure contexts. */ +/** + * Available only in secure contexts. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemHandle) + */ interface FileSystemHandle { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemHandle/kind) */ readonly kind: FileSystemHandleKind; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemHandle/name) */ readonly name: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemHandle/isSameEntry) */ isSameEntry(other: FileSystemHandle): Promise; } @@ -5466,8 +8420,32 @@ declare var FileSystemHandle: { new(): FileSystemHandle; }; -/** Focus-related events like focus, blur, focusin, or focusout. */ +/** + * Available only in secure contexts. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemWritableFileStream) + */ +interface FileSystemWritableFileStream extends WritableStream { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemWritableFileStream/seek) */ + seek(position: number): Promise; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemWritableFileStream/truncate) */ + truncate(size: number): Promise; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemWritableFileStream/write) */ + write(data: FileSystemWriteChunkType): Promise; +} + +declare var FileSystemWritableFileStream: { + prototype: FileSystemWritableFileStream; + new(): FileSystemWritableFileStream; +}; + +/** + * Focus-related events like focus, blur, focusin, or focusout. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FocusEvent) + */ interface FocusEvent extends UIEvent { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FocusEvent/relatedTarget) */ readonly relatedTarget: EventTarget | null; } @@ -5476,21 +8454,35 @@ declare var FocusEvent: { new(type: string, eventInitDict?: FocusEventInit): FocusEvent; }; +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FontFace) */ interface FontFace { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FontFace/ascentOverride) */ ascentOverride: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FontFace/descentOverride) */ descentOverride: string; - display: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FontFace/display) */ + display: FontDisplay; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FontFace/family) */ family: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FontFace/featureSettings) */ featureSettings: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FontFace/lineGapOverride) */ lineGapOverride: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FontFace/loaded) */ readonly loaded: Promise; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FontFace/status) */ readonly status: FontFaceLoadStatus; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FontFace/stretch) */ stretch: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FontFace/style) */ style: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FontFace/unicodeRange) */ unicodeRange: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FontFace/variant) */ variant: string; - variationSettings: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FontFace/weight) */ weight: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FontFace/load) */ load(): Promise; } @@ -5505,13 +8497,21 @@ interface FontFaceSetEventMap { "loadingerror": Event; } +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FontFaceSet) */ interface FontFaceSet extends EventTarget { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FontFaceSet/loading_event) */ onloading: ((this: FontFaceSet, ev: Event) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FontFaceSet/loadingdone_event) */ onloadingdone: ((this: FontFaceSet, ev: Event) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FontFaceSet/loadingerror_event) */ onloadingerror: ((this: FontFaceSet, ev: Event) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FontFaceSet/ready) */ readonly ready: Promise; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FontFaceSet/status) */ readonly status: FontFaceSetLoadStatus; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FontFaceSet/check) */ check(font: string, text?: string): boolean; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FontFaceSet/load) */ load(font: string, text?: string): Promise; forEach(callbackfn: (value: FontFace, key: FontFace, parent: FontFaceSet) => void, thisArg?: any): void; addEventListener(type: K, listener: (this: FontFaceSet, ev: FontFaceSetEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; @@ -5525,7 +8525,9 @@ declare var FontFaceSet: { new(initialFaces: FontFace[]): FontFaceSet; }; +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FontFaceSetLoadEvent) */ interface FontFaceSetLoadEvent extends Event { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FontFaceSetLoadEvent/fontfaces) */ readonly fontfaces: ReadonlyArray; } @@ -5535,27 +8537,47 @@ declare var FontFaceSetLoadEvent: { }; interface FontFaceSource { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/fonts) */ readonly fonts: FontFaceSet; } -/** Provides a way to easily construct a set of key/value pairs representing form fields and their values, which can then be easily sent using the XMLHttpRequest.send() method. It uses the same format a form would use if the encoding type were set to "multipart/form-data". */ +/** + * Provides a way to easily construct a set of key/value pairs representing form fields and their values, which can then be easily sent using the XMLHttpRequest.send() method. It uses the same format a form would use if the encoding type were set to "multipart/form-data". + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData) + */ interface FormData { - append(name: string, value: string | Blob, fileName?: string): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/append) */ + append(name: string, value: string | Blob): void; + append(name: string, value: string): void; + append(name: string, blobValue: Blob, filename?: string): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/delete) */ delete(name: string): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/get) */ get(name: string): FormDataEntryValue | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/getAll) */ getAll(name: string): FormDataEntryValue[]; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/has) */ has(name: string): boolean; - set(name: string, value: string | Blob, fileName?: string): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/set) */ + set(name: string, value: string | Blob): void; + set(name: string, value: string): void; + set(name: string, blobValue: Blob, filename?: string): void; forEach(callbackfn: (value: FormDataEntryValue, key: string, parent: FormData) => void, thisArg?: any): void; } declare var FormData: { prototype: FormData; - new(form?: HTMLFormElement): FormData; + new(form?: HTMLFormElement, submitter?: HTMLElement | null): FormData; }; +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormDataEvent) */ interface FormDataEvent extends Event { - /** Returns a FormData object representing names and values of elements associated to the target form. Operations on the FormData object will affect form data to be submitted. */ + /** + * Returns a FormData object representing names and values of elements associated to the target form. Operations on the FormData object will affect form data to be submitted. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormDataEvent/formData) + */ readonly formData: FormData; } @@ -5564,8 +8586,13 @@ declare var FormDataEvent: { new(type: string, eventInitDict: FormDataEventInit): FormDataEvent; }; -/** A change in volume. It is an AudioNode audio-processing module that causes a given gain to be applied to the input data before its propagation to the output. A GainNode always has exactly one input and one output, both with the same number of channels. */ +/** + * A change in volume. It is an AudioNode audio-processing module that causes a given gain to be applied to the input data before its propagation to the output. A GainNode always has exactly one input and one output, both with the same number of channels. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/GainNode) + */ interface GainNode extends AudioNode { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/GainNode/gain) */ readonly gain: AudioParam; } @@ -5577,16 +8604,27 @@ declare var GainNode: { /** * This Gamepad API interface defines an individual gamepad or other controller, allowing access to information such as button presses, axis positions, and id. * Available only in secure contexts. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Gamepad) */ interface Gamepad { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Gamepad/axes) */ readonly axes: ReadonlyArray; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Gamepad/buttons) */ readonly buttons: ReadonlyArray; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Gamepad/connected) */ readonly connected: boolean; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Gamepad/hapticActuators) */ readonly hapticActuators: ReadonlyArray; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Gamepad/id) */ readonly id: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Gamepad/index) */ readonly index: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Gamepad/mapping) */ readonly mapping: GamepadMappingType; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Gamepad/timestamp) */ readonly timestamp: DOMHighResTimeStamp; + readonly vibrationActuator: GamepadHapticActuator | null; } declare var Gamepad: { @@ -5597,10 +8635,15 @@ declare var Gamepad: { /** * An individual button of a gamepad or other controller, allowing access to the current state of different types of buttons available on the control device. * Available only in secure contexts. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/GamepadButton) */ interface GamepadButton { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/GamepadButton/pressed) */ readonly pressed: boolean; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/GamepadButton/touched) */ readonly touched: boolean; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/GamepadButton/value) */ readonly value: number; } @@ -5612,8 +8655,11 @@ declare var GamepadButton: { /** * This Gamepad API interface contains references to gamepads connected to the system, which is what the gamepad events Window.gamepadconnected and Window.gamepaddisconnected are fired in response to. * Available only in secure contexts. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/GamepadEvent) */ interface GamepadEvent extends Event { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/GamepadEvent/gamepad) */ readonly gamepad: Gamepad; } @@ -5622,9 +8668,16 @@ declare var GamepadEvent: { new(type: string, eventInitDict: GamepadEventInit): GamepadEvent; }; -/** This Gamepad API interface represents hardware in the controller designed to provide haptic feedback to the user (if available), most commonly vibration hardware. */ +/** + * This Gamepad API interface represents hardware in the controller designed to provide haptic feedback to the user (if available), most commonly vibration hardware. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/GamepadHapticActuator) + */ interface GamepadHapticActuator { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/GamepadHapticActuator/type) */ readonly type: GamepadHapticActuatorType; + playEffect(type: GamepadHapticEffectType, params?: GamepadEffectParameters): Promise; + reset(): Promise; } declare var GamepadHapticActuator: { @@ -5633,14 +8686,23 @@ declare var GamepadHapticActuator: { }; interface GenericTransformStream { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CompressionStream/readable) */ readonly readable: ReadableStream; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CompressionStream/writable) */ readonly writable: WritableStream; } -/** An object able to programmatically obtain the position of the device. It gives Web content access to the location of the device. This allows a Web site or app to offer customized results based on the user's location. */ +/** + * An object able to programmatically obtain the position of the device. It gives Web content access to the location of the device. This allows a Web site or app to offer customized results based on the user's location. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Geolocation) + */ interface Geolocation { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Geolocation/clearWatch) */ clearWatch(watchId: number): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Geolocation/getCurrentPosition) */ getCurrentPosition(successCallback: PositionCallback, errorCallback?: PositionErrorCallback | null, options?: PositionOptions): void; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Geolocation/watchPosition) */ watchPosition(successCallback: PositionCallback, errorCallback?: PositionErrorCallback | null, options?: PositionOptions): number; } @@ -5649,14 +8711,25 @@ declare var Geolocation: { new(): Geolocation; }; -/** Available only in secure contexts. */ +/** + * Available only in secure contexts. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/GeolocationCoordinates) + */ interface GeolocationCoordinates { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/GeolocationCoordinates/accuracy) */ readonly accuracy: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/GeolocationCoordinates/altitude) */ readonly altitude: number | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/GeolocationCoordinates/altitudeAccuracy) */ readonly altitudeAccuracy: number | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/GeolocationCoordinates/heading) */ readonly heading: number | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/GeolocationCoordinates/latitude) */ readonly latitude: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/GeolocationCoordinates/longitude) */ readonly longitude: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/GeolocationCoordinates/speed) */ readonly speed: number | null; } @@ -5665,9 +8738,15 @@ declare var GeolocationCoordinates: { new(): GeolocationCoordinates; }; -/** Available only in secure contexts. */ +/** + * Available only in secure contexts. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/GeolocationPosition) + */ interface GeolocationPosition { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/GeolocationPosition/coords) */ readonly coords: GeolocationCoordinates; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/GeolocationPosition/timestamp) */ readonly timestamp: EpochTimeStamp; } @@ -5676,20 +8755,23 @@ declare var GeolocationPosition: { new(): GeolocationPosition; }; +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/GeolocationPositionError) */ interface GeolocationPositionError { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/GeolocationPositionError/code) */ readonly code: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/GeolocationPositionError/message) */ readonly message: string; - readonly PERMISSION_DENIED: number; - readonly POSITION_UNAVAILABLE: number; - readonly TIMEOUT: number; + readonly PERMISSION_DENIED: 1; + readonly POSITION_UNAVAILABLE: 2; + readonly TIMEOUT: 3; } declare var GeolocationPositionError: { prototype: GeolocationPositionError; new(): GeolocationPositionError; - readonly PERMISSION_DENIED: number; - readonly POSITION_UNAVAILABLE: number; - readonly TIMEOUT: number; + readonly PERMISSION_DENIED: 1; + readonly POSITION_UNAVAILABLE: 2; + readonly TIMEOUT: 3; }; interface GlobalEventHandlersEventMap { @@ -5711,7 +8793,9 @@ interface GlobalEventHandlersEventMap { "compositionstart": CompositionEvent; "compositionupdate": CompositionEvent; "contextmenu": MouseEvent; + "copy": ClipboardEvent; "cuechange": Event; + "cut": ClipboardEvent; "dblclick": MouseEvent; "drag": DragEvent; "dragend": DragEvent; @@ -5746,6 +8830,7 @@ interface GlobalEventHandlersEventMap { "mouseout": MouseEvent; "mouseover": MouseEvent; "mouseup": MouseEvent; + "paste": ClipboardEvent; "pause": Event; "play": Event; "playing": Event; @@ -5795,278 +8880,432 @@ interface GlobalEventHandlers { /** * Fires when the user aborts the download. * @param ev The event. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/abort_event) */ onabort: ((this: GlobalEventHandlers, ev: UIEvent) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/animationcancel_event) */ onanimationcancel: ((this: GlobalEventHandlers, ev: AnimationEvent) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/animationend_event) */ onanimationend: ((this: GlobalEventHandlers, ev: AnimationEvent) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/animationiteration_event) */ onanimationiteration: ((this: GlobalEventHandlers, ev: AnimationEvent) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/animationstart_event) */ onanimationstart: ((this: GlobalEventHandlers, ev: AnimationEvent) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/auxclick_event) */ onauxclick: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLElement/beforeinput_event) */ onbeforeinput: ((this: GlobalEventHandlers, ev: InputEvent) => any) | null; /** * Fires when the object loses the input focus. * @param ev The focus event. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/blur_event) */ onblur: ((this: GlobalEventHandlers, ev: FocusEvent) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLDialogElement/cancel_event) */ oncancel: ((this: GlobalEventHandlers, ev: Event) => any) | null; /** * Occurs when playback is possible, but would require further buffering. * @param ev The event. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/canplay_event) */ oncanplay: ((this: GlobalEventHandlers, ev: Event) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/canplaythrough_event) */ oncanplaythrough: ((this: GlobalEventHandlers, ev: Event) => any) | null; /** * Fires when the contents of the object or selection have changed. * @param ev The event. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLElement/change_event) */ onchange: ((this: GlobalEventHandlers, ev: Event) => any) | null; /** * Fires when the user clicks the left mouse button on the object * @param ev The mouse event. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/click_event) */ onclick: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLDialogElement/close_event) */ onclose: ((this: GlobalEventHandlers, ev: Event) => any) | null; /** * Fires when the user clicks the right mouse button in the client area, opening the context menu. * @param ev The mouse event. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/contextmenu_event) */ oncontextmenu: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/copy_event) */ + oncopy: ((this: GlobalEventHandlers, ev: ClipboardEvent) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLTrackElement/cuechange_event) */ oncuechange: ((this: GlobalEventHandlers, ev: Event) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/cut_event) */ + oncut: ((this: GlobalEventHandlers, ev: ClipboardEvent) => any) | null; /** * Fires when the user double-clicks the object. * @param ev The mouse event. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/dblclick_event) */ ondblclick: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null; /** * Fires on the source object continuously during a drag operation. * @param ev The event. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLElement/drag_event) */ ondrag: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null; /** * Fires on the source object when the user releases the mouse at the close of a drag operation. * @param ev The event. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLElement/dragend_event) */ ondragend: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null; /** * Fires on the target element when the user drags the object to a valid drop target. * @param ev The drag event. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLElement/dragenter_event) */ ondragenter: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null; /** * Fires on the target object when the user moves the mouse out of a valid drop target during a drag operation. * @param ev The drag event. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLElement/dragleave_event) */ ondragleave: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null; /** * Fires on the target element continuously while the user drags the object over a valid drop target. * @param ev The event. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLElement/dragover_event) */ ondragover: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null; /** * Fires on the source object when the user starts to drag a text selection or selected object. * @param ev The event. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLElement/dragstart_event) */ ondragstart: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLElement/drop_event) */ ondrop: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null; /** * Occurs when the duration attribute is updated. * @param ev The event. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/durationchange_event) */ ondurationchange: ((this: GlobalEventHandlers, ev: Event) => any) | null; /** * Occurs when the media element is reset to its initial state. * @param ev The event. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/emptied_event) */ onemptied: ((this: GlobalEventHandlers, ev: Event) => any) | null; /** * Occurs when the end of playback is reached. * @param ev The event + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/ended_event) */ onended: ((this: GlobalEventHandlers, ev: Event) => any) | null; /** * Fires when an error occurs during object loading. * @param ev The event. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/error_event) */ onerror: OnErrorEventHandler; /** * Fires when the object receives focus. * @param ev The event. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/focus_event) */ onfocus: ((this: GlobalEventHandlers, ev: FocusEvent) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLFormElement/formdata_event) */ onformdata: ((this: GlobalEventHandlers, ev: FormDataEvent) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/gotpointercapture_event) */ ongotpointercapture: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLElement/input_event) */ oninput: ((this: GlobalEventHandlers, ev: Event) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLInputElement/invalid_event) */ oninvalid: ((this: GlobalEventHandlers, ev: Event) => any) | null; /** * Fires when the user presses a key. * @param ev The keyboard event + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/keydown_event) */ onkeydown: ((this: GlobalEventHandlers, ev: KeyboardEvent) => any) | null; /** * Fires when the user presses an alphanumeric key. * @param ev The event. * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/keypress_event) */ onkeypress: ((this: GlobalEventHandlers, ev: KeyboardEvent) => any) | null; /** * Fires when the user releases a key. * @param ev The keyboard event + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/keyup_event) */ onkeyup: ((this: GlobalEventHandlers, ev: KeyboardEvent) => any) | null; /** * Fires immediately after the browser loads the object. * @param ev The event. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SVGElement/load_event) */ onload: ((this: GlobalEventHandlers, ev: Event) => any) | null; /** * Occurs when media data is loaded at the current playback position. * @param ev The event. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/loadeddata_event) */ onloadeddata: ((this: GlobalEventHandlers, ev: Event) => any) | null; /** * Occurs when the duration and dimensions of the media have been determined. * @param ev The event. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/loadedmetadata_event) */ onloadedmetadata: ((this: GlobalEventHandlers, ev: Event) => any) | null; /** * Occurs when Internet Explorer begins looking for media data. * @param ev The event. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/loadstart_event) */ onloadstart: ((this: GlobalEventHandlers, ev: Event) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/lostpointercapture_event) */ onlostpointercapture: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null; /** * Fires when the user clicks the object with either mouse button. * @param ev The mouse event. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/mousedown_event) */ onmousedown: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/mouseenter_event) */ onmouseenter: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/mouseleave_event) */ onmouseleave: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null; /** * Fires when the user moves the mouse over the object. * @param ev The mouse event. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/mousemove_event) */ onmousemove: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null; /** * Fires when the user moves the mouse pointer outside the boundaries of the object. * @param ev The mouse event. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/mouseout_event) */ onmouseout: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null; /** * Fires when the user moves the mouse pointer into the object. * @param ev The mouse event. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/mouseover_event) */ onmouseover: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null; /** * Fires when the user releases a mouse button while the mouse is over the object. * @param ev The mouse event. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/mouseup_event) */ onmouseup: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/paste_event) */ + onpaste: ((this: GlobalEventHandlers, ev: ClipboardEvent) => any) | null; /** * Occurs when playback is paused. * @param ev The event. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/pause_event) */ onpause: ((this: GlobalEventHandlers, ev: Event) => any) | null; /** * Occurs when the play method is requested. * @param ev The event. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/play_event) */ onplay: ((this: GlobalEventHandlers, ev: Event) => any) | null; /** * Occurs when the audio or video has started playing. * @param ev The event. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/playing_event) */ onplaying: ((this: GlobalEventHandlers, ev: Event) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/pointercancel_event) */ onpointercancel: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/pointerdown_event) */ onpointerdown: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/pointerenter_event) */ onpointerenter: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/pointerleave_event) */ onpointerleave: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/pointermove_event) */ onpointermove: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/pointerout_event) */ onpointerout: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/pointerover_event) */ onpointerover: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/pointerup_event) */ onpointerup: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null; /** * Occurs to indicate progress while downloading media data. * @param ev The event. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/progress_event) */ onprogress: ((this: GlobalEventHandlers, ev: ProgressEvent) => any) | null; /** * Occurs when the playback rate is increased or decreased. * @param ev The event. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/ratechange_event) */ onratechange: ((this: GlobalEventHandlers, ev: Event) => any) | null; /** * Fires when the user resets a form. * @param ev The event. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLFormElement/reset_event) */ onreset: ((this: GlobalEventHandlers, ev: Event) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLVideoElement/resize_event) */ onresize: ((this: GlobalEventHandlers, ev: UIEvent) => any) | null; /** * Fires when the user repositions the scroll box in the scroll bar on the object. * @param ev The event. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/scroll_event) */ onscroll: ((this: GlobalEventHandlers, ev: Event) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/securitypolicyviolation_event) */ onsecuritypolicyviolation: ((this: GlobalEventHandlers, ev: SecurityPolicyViolationEvent) => any) | null; /** * Occurs when the seek operation ends. * @param ev The event. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/seeked_event) */ onseeked: ((this: GlobalEventHandlers, ev: Event) => any) | null; /** * Occurs when the current playback position is moved. * @param ev The event. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/seeking_event) */ onseeking: ((this: GlobalEventHandlers, ev: Event) => any) | null; /** * Fires when the current selection changes. * @param ev The event. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLInputElement/select_event) */ onselect: ((this: GlobalEventHandlers, ev: Event) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/selectionchange_event) */ onselectionchange: ((this: GlobalEventHandlers, ev: Event) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/selectstart_event) */ onselectstart: ((this: GlobalEventHandlers, ev: Event) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLSlotElement/slotchange_event) */ onslotchange: ((this: GlobalEventHandlers, ev: Event) => any) | null; /** * Occurs when the download has stopped. * @param ev The event. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/stalled_event) */ onstalled: ((this: GlobalEventHandlers, ev: Event) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLFormElement/submit_event) */ onsubmit: ((this: GlobalEventHandlers, ev: SubmitEvent) => any) | null; /** * Occurs if the load operation has been intentionally halted. * @param ev The event. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/suspend_event) */ onsuspend: ((this: GlobalEventHandlers, ev: Event) => any) | null; /** * Occurs to indicate the current playback position. * @param ev The event. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/timeupdate_event) */ ontimeupdate: ((this: GlobalEventHandlers, ev: Event) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLDetailsElement/toggle_event) */ ontoggle: ((this: GlobalEventHandlers, ev: Event) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/touchcancel_event) */ ontouchcancel?: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null | undefined; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/touchend_event) */ ontouchend?: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null | undefined; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/touchmove_event) */ ontouchmove?: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null | undefined; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/touchstart_event) */ ontouchstart?: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null | undefined; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/transitioncancel_event) */ ontransitioncancel: ((this: GlobalEventHandlers, ev: TransitionEvent) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/transitionend_event) */ ontransitionend: ((this: GlobalEventHandlers, ev: TransitionEvent) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/transitionrun_event) */ ontransitionrun: ((this: GlobalEventHandlers, ev: TransitionEvent) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/transitionstart_event) */ ontransitionstart: ((this: GlobalEventHandlers, ev: TransitionEvent) => any) | null; /** * Occurs when the volume is changed, or playback is muted or unmuted. * @param ev The event. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/volumechange_event) */ onvolumechange: ((this: GlobalEventHandlers, ev: Event) => any) | null; /** * Occurs when playback stops because the next frame of a video resource is not available. * @param ev The event. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/waiting_event) */ onwaiting: ((this: GlobalEventHandlers, ev: Event) => any) | null; - /** @deprecated This is a legacy alias of `onanimationend`. */ + /** + * @deprecated This is a legacy alias of `onanimationend`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/animationend_event) + */ onwebkitanimationend: ((this: GlobalEventHandlers, ev: Event) => any) | null; - /** @deprecated This is a legacy alias of `onanimationiteration`. */ + /** + * @deprecated This is a legacy alias of `onanimationiteration`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/animationiteration_event) + */ onwebkitanimationiteration: ((this: GlobalEventHandlers, ev: Event) => any) | null; - /** @deprecated This is a legacy alias of `onanimationstart`. */ + /** + * @deprecated This is a legacy alias of `onanimationstart`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/animationstart_event) + */ onwebkitanimationstart: ((this: GlobalEventHandlers, ev: Event) => any) | null; - /** @deprecated This is a legacy alias of `ontransitionend`. */ + /** + * @deprecated This is a legacy alias of `ontransitionend`. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/transitionend_event) + */ onwebkittransitionend: ((this: GlobalEventHandlers, ev: Event) => any) | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/wheel_event) */ onwheel: ((this: GlobalEventHandlers, ev: WheelEvent) => any) | null; addEventListener(type: K, listener: (this: GlobalEventHandlers, ev: GlobalEventHandlersEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; @@ -6074,10 +9313,19 @@ interface GlobalEventHandlers { removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; } +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLAllCollection) */ interface HTMLAllCollection { - /** Returns the number of elements in the collection. */ + /** + * Returns the number of elements in the collection. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLAllCollection/length) + */ readonly length: number; - /** Returns the item with index index from the collection (determined by tree order). */ + /** + * Returns the item with index index from the collection (determined by tree order). + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLAllCollection/item) + */ item(nameOrIndex?: string): HTMLCollection | Element | null; /** * Returns the item with ID or name name from the collection. @@ -6085,6 +9333,8 @@ interface HTMLAllCollection { * If there are multiple matching items, then an HTMLCollection object containing all those elements is returned. * * Only button, form, iframe, input, map, meta, object, select, and textarea elements can have a name for the purpose of this method; their name is given by the value of their name attribute. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLAllCollection/namedItem) */ namedItem(name: string): HTMLCollection | Element | null; [index: number]: Element; @@ -6095,45 +9345,79 @@ declare var HTMLAllCollection: { new(): HTMLAllCollection; }; -/** Hyperlink elements and provides special properties and methods (beyond those of the regular HTMLElement object interface that they inherit from) for manipulating the layout and presentation of such elements. */ +/** + * Hyperlink elements and provides special properties and methods (beyond those of the regular HTMLElement object interface that they inherit from) for manipulating the layout and presentation of such elements. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLAnchorElement) + */ interface HTMLAnchorElement extends HTMLElement, HTMLHyperlinkElementUtils { /** * Sets or retrieves the character set used to encode the object. * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLAnchorElement/charset) */ charset: string; /** * Sets or retrieves the coordinates of the object. * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLAnchorElement/coords) */ coords: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLAnchorElement/download) */ download: string; - /** Sets or retrieves the language code of the object. */ + /** + * Sets or retrieves the language code of the object. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLAnchorElement/hreflang) + */ hreflang: string; /** * Sets or retrieves the shape of the object. * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLAnchorElement/name) */ name: string; ping: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLAnchorElement/referrerPolicy) */ referrerPolicy: string; - /** Sets or retrieves the relationship between the object and the destination of the link. */ + /** + * Sets or retrieves the relationship between the object and the destination of the link. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLAnchorElement/rel) + */ rel: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLAnchorElement/relList) */ readonly relList: DOMTokenList; /** * Sets or retrieves the relationship between the object and the destination of the link. * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLAnchorElement/rev) */ rev: string; /** * Sets or retrieves the shape of the object. * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLAnchorElement/shape) */ shape: string; - /** Sets or retrieves the window or frame at which to target content. */ + /** + * Sets or retrieves the window or frame at which to target content. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLAnchorElement/target) + */ target: string; - /** Retrieves or sets the text of the object as a string. */ + /** + * Retrieves or sets the text of the object as a string. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLAnchorElement/text) + */ text: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLAnchorElement/type) */ type: string; addEventListener(type: K, listener: (this: HTMLAnchorElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; @@ -6146,25 +9430,51 @@ declare var HTMLAnchorElement: { new(): HTMLAnchorElement; }; -/** Provides special properties and methods (beyond those of the regular object HTMLElement interface it also has available to it by inheritance) for manipulating the layout and presentation of elements. */ +/** + * Provides special properties and methods (beyond those of the regular object HTMLElement interface it also has available to it by inheritance) for manipulating the layout and presentation of elements. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLAreaElement) + */ interface HTMLAreaElement extends HTMLElement, HTMLHyperlinkElementUtils { - /** Sets or retrieves a text alternative to the graphic. */ + /** + * Sets or retrieves a text alternative to the graphic. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLAreaElement/alt) + */ alt: string; - /** Sets or retrieves the coordinates of the object. */ + /** + * Sets or retrieves the coordinates of the object. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLAreaElement/coords) + */ coords: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLAreaElement/download) */ download: string; /** * Sets or gets whether clicks in this region cause action. * @deprecated + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLAreaElement/noHref) */ noHref: boolean; ping: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLAreaElement/referrerPolicy) */ referrerPolicy: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLAreaElement/rel) */ rel: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLAreaElement/relList) */ readonly relList: DOMTokenList; - /** Sets or retrieves the shape of the object. */ + /** + * Sets or retrieves the shape of the object. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLAreaElement/shape) + */ shape: string; - /** Sets or retrieves the window or frame at which to target content. */ + /** + * Sets or retrieves the window or frame at which to target content. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLAreaElement/target) + */ target: string; addEventListener(type: K, listener: (this: HTMLAreaElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; @@ -6177,7 +9487,11 @@ declare var HTMLAreaElement: { new(): HTMLAreaElement; }; -/** Provides access to the properties of