fix(semantic): add interfaces and functions to SymbolFlags::ClassExcludes (#6057)

This brings ClassExcludes into alignment with TypeScript.
This commit is contained in:
DonIsaac 2024-09-27 05:57:03 +00:00
parent 93d509db2b
commit 933a7431b1
2 changed files with 19 additions and 2 deletions

View file

@ -475,3 +475,18 @@ fn test_module_like_declarations() {
"A symbol should not be created for global augmentation declarations."
);
}
#[test]
fn test_class_merging() {
// classes can be merged with interfaces, resulting in a single symbol
SemanticTester::ts(
"
class Foo {}
interface Foo {}
",
)
.has_root_symbol("Foo")
.contains_flags(SymbolFlags::Class)
.contains_flags(SymbolFlags::Interface)
.test();
}

View file

@ -100,8 +100,10 @@ bitflags! {
const Ambient = 1 << 19;
const Enum = Self::ConstEnum.bits() | Self::RegularEnum.bits();
const Variable = Self::FunctionScopedVariable.bits() | Self::BlockScopedVariable.bits();
const BlockScoped = Self::BlockScopedVariable.bits() | Self::Enum.bits() | Self::Class.bits();
const Value = Self::Variable.bits() | Self::Class.bits() | Self::Enum.bits() | Self::EnumMember.bits() | Self::ValueModule.bits();
const Type = Self::Class.bits() | Self::Interface.bits() | Self::Enum.bits() | Self::EnumMember.bits() | Self::TypeLiteral.bits() | Self::TypeParameter.bits() | Self::TypeAlias.bits();
@ -113,7 +115,7 @@ bitflags! {
/// they can not merge with anything in the value space
const BlockScopedVariableExcludes = Self::Value.bits();
const ClassExcludes = (Self::Value.bits() | Self::TypeAlias.bits()) & !Self::ValueModule.bits() ;
const ClassExcludes = (Self::Value.bits() | Self::TypeAlias.bits()) & !(Self::ValueModule.bits() | Self::Interface.bits() | Self::Function.bits());
const ImportBindingExcludes = Self::Import.bits() | Self::TypeImport.bits();
// Type specific excludes
const TypeAliasExcludes = Self::Type.bits();