Skip to content
This repository was archived by the owner on Mar 12, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions crates/stc_ts_file_analyzer/src/analyzer/assign/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use stc_ts_errors::{
};
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,
PropertySignature, QueryExpr, QueryType, Readonly, Ref, StringMapping, ThisType, TplType, Tuple, TupleElement, Type, TypeElement,
TypeLit, TypeParam,
};
use stc_utils::{cache::Freeze, dev_span, ext::SpanExt, stack};
use swc_atoms::js_word;
Expand Down Expand Up @@ -2101,6 +2101,22 @@ impl Analyzer<'_, '_> {

fail!()
}
Type::Tpl(TplType { ref types, .. }) => {
if types.iter().any(|t| match t.normalize() {
Type::Keyword(KeywordType {
kind: TsKeywordTypeKind::TsNumberKeyword,
..
})
| Type::Keyword(KeywordType {
kind: TsKeywordTypeKind::TsBigIntKeyword,
..
}) => false,
Type::Lit(ty) => !matches!(ty.lit, RTsLit::BigInt(..) | RTsLit::Number(..)),
_ => true,
}) {
fail!()
}
}
_ => {}
},

Expand Down
1 change: 0 additions & 1 deletion crates/stc_ts_file_analyzer/src/analyzer/assign/tpl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ impl Analyzer<'_, '_> {
source = tracing::field::display(&force_dump_type_as_string(source)),
target = tracing::field::display(&force_dump_type_as_string(target)),
);

if source.type_eq(target) || target.is_any() || target.is_kwd(TsKeywordTypeKind::TsStringKeyword) {
return Ok(true);
}
Expand Down
1 change: 1 addition & 0 deletions crates/stc_ts_type_checker/tests/conformance.pass.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2372,6 +2372,7 @@ types/literal/stringLiteralsWithSwitchStatements03.ts
types/literal/stringLiteralsWithSwitchStatements04.ts
types/literal/stringLiteralsWithTypeAssertions01.ts
types/literal/templateLiteralTypes2.ts
types/literal/templateLiteralTypes3.ts
types/literal/templateLiteralTypesPatternsPrefixSuffixAssignability.ts
types/localTypes/localTypes1.ts
types/localTypes/localTypes2.ts
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Stats {
required_error: 1,
matched_error: 7,
required_error: 0,
matched_error: 8,
extra_error: 0,
panic: 0,
}
4 changes: 2 additions & 2 deletions crates/stc_ts_type_checker/tests/tsc-stats.rust-debug
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Stats {
required_error: 3519,
matched_error: 6516,
required_error: 3518,
matched_error: 6517,
extra_error: 771,
panic: 74,
}