mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
Handle const binding elements with initializers correctly
This commit is contained in:
parent
a28c7034f5
commit
2344a80e6f
@ -3117,7 +3117,8 @@ namespace ts {
|
||||
// pattern. Otherwise, it is the type any.
|
||||
function getTypeFromBindingElement(element: BindingElement, includePatternInType?: boolean, reportErrors?: boolean): Type {
|
||||
if (element.initializer) {
|
||||
return getBaseTypeOfLiteralType(checkExpressionCached(element.initializer));
|
||||
const exprType = checkExpressionCached(element.initializer);
|
||||
return getCombinedNodeFlags(element) & NodeFlags.Const ? exprType : getBaseTypeOfLiteralType(exprType);
|
||||
}
|
||||
if (isBindingPattern(element.name)) {
|
||||
return getTypeFromBindingPattern(<BindingPattern>element.name, includePatternInType, reportErrors);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user