mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 12:51:30 -05:00
Allow references to uninitialized ambient properties (#36112)
Previously these were incorrectly treated just like normal properties:
```ts
class Parent {
a: any;
constructor(arg: any) {
this.a = arg;
}
}
class Child extends Parent {
declare a: number;
constructor(arg: number) {
super(arg);
console.log(this.a); // Property 'a' is used before being assigned. (2565)
}
}
```
Fixes #35327
This commit is contained in:
committed by
GitHub
parent
357f715382
commit
13cddae3f7
@@ -23298,7 +23298,7 @@ namespace ts {
|
||||
const declaration = prop && prop.valueDeclaration;
|
||||
if (declaration && isInstancePropertyWithoutInitializer(declaration)) {
|
||||
const flowContainer = getControlFlowContainer(node);
|
||||
if (flowContainer.kind === SyntaxKind.Constructor && flowContainer.parent === declaration.parent) {
|
||||
if (flowContainer.kind === SyntaxKind.Constructor && flowContainer.parent === declaration.parent && !(declaration.flags & NodeFlags.Ambient)) {
|
||||
assumeUninitialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user