Skip to content

Commit 986c3dd

Browse files
Port "make exported destructured discriminated union narrowing work" (#1806)
Co-authored-by: =?UTF-8?q?Michal=20Mar=C5=A1=C3=A1lek?= <[email protected]>
1 parent 1ce1c51 commit 986c3dd

File tree

3 files changed

+2
-11
lines changed

3 files changed

+2
-11
lines changed

internal/checker/flow.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1427,7 +1427,7 @@ func (c *Checker) getCandidateDiscriminantPropertyAccess(f *FlowState, expr *ast
14271427
// parameter declared in the same parameter list is a candidate.
14281428
if ast.IsIdentifier(expr) {
14291429
symbol := c.getResolvedSymbol(expr)
1430-
declaration := symbol.ValueDeclaration
1430+
declaration := c.getExportSymbolOfValueSymbolIfExported(symbol).ValueDeclaration
14311431
if declaration != nil && (ast.IsBindingElement(declaration) || ast.IsParameter(declaration)) && f.reference == declaration.Parent && declaration.Initializer() == nil && !hasDotDotDotToken(declaration) {
14321432
return declaration
14331433
}

testdata/baselines/reference/submodule/conformance/dependentDestructuredVariablesWithExport.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,5 @@ if (discriminator2) {
4949
>discriminator2 : boolean
5050

5151
value2;
52-
>value2 : string | null | undefined
52+
>value2 : string
5353
}

testdata/baselines/reference/submodule/conformance/dependentDestructuredVariablesWithExport.types.diff

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)