Merge pull request #10046 from RyanCavanaugh/fix10045
Correctly check for ambient class flag
This commit is contained in:
commit
030fbdc0d5
|
@ -16227,7 +16227,7 @@ namespace ts {
|
|||
checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node,
|
||||
Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1);
|
||||
|
||||
if (baseType.symbol.valueDeclaration && !(baseType.symbol.valueDeclaration.flags & NodeFlags.Ambient)) {
|
||||
if (baseType.symbol.valueDeclaration && !isInAmbientContext(baseType.symbol.valueDeclaration)) {
|
||||
if (!isBlockScopedNameDeclaredBeforeUse(baseType.symbol.valueDeclaration, node)) {
|
||||
error(baseTypeNode, Diagnostics.A_class_must_be_declared_after_its_base_class);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
=== tests/cases/compiler/a.d.ts ===
|
||||
|
||||
declare namespace ns {
|
||||
>ns : Symbol(ns, Decl(a.d.ts, 0, 0))
|
||||
|
||||
class SecondNS extends FirstNS { }
|
||||
>SecondNS : Symbol(SecondNS, Decl(a.d.ts, 1, 22))
|
||||
>FirstNS : Symbol(FirstNS, Decl(a.d.ts, 2, 36))
|
||||
|
||||
class FirstNS { }
|
||||
>FirstNS : Symbol(FirstNS, Decl(a.d.ts, 2, 36))
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
=== tests/cases/compiler/a.d.ts ===
|
||||
|
||||
declare namespace ns {
|
||||
>ns : typeof ns
|
||||
|
||||
class SecondNS extends FirstNS { }
|
||||
>SecondNS : SecondNS
|
||||
>FirstNS : FirstNS
|
||||
|
||||
class FirstNS { }
|
||||
>FirstNS : FirstNS
|
||||
}
|
||||
|
6
tests/cases/compiler/ambientClassDeclaredBeforeBase.ts
Normal file
6
tests/cases/compiler/ambientClassDeclaredBeforeBase.ts
Normal file
|
@ -0,0 +1,6 @@
|
|||
// @filename: a.d.ts
|
||||
|
||||
declare namespace ns {
|
||||
class SecondNS extends FirstNS { }
|
||||
class FirstNS { }
|
||||
}
|
Loading…
Reference in a new issue