Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Commit

Permalink
Fix prefer-const for TypeScript <2.1 (#1989)
Browse files Browse the repository at this point in the history
  • Loading branch information
nchen63 authored Jan 5, 2017
1 parent b20dfce commit 23552e0
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/rules/preferConstRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,15 @@ class PreferConstWalker extends Lint.BlockScopeAwareRuleWalker<{}, ScopeInfo> {
}

private static collectInVariableDeclarationList(node: ts.VariableDeclarationList, scopeInfo: ScopeInfo) {
if (isCombinedNodeFlagSet(node, ts.NodeFlags.Let) && !isCombinedModifierFlagSet(node, ts.ModifierFlags.Export)) {
let allowConst: boolean;
if ((ts as any).getCombinedModifierFlags === undefined) {
// for back-compat, TypeScript < 2.1
allowConst = isCombinedNodeFlagSet(node, ts.NodeFlags.Let)
&& !Lint.hasModifier(node.parent!.modifiers, ts.SyntaxKind.ExportKeyword);
} else {
allowConst = isCombinedNodeFlagSet(node, ts.NodeFlags.Let) && !isCombinedModifierFlagSet(node, ts.ModifierFlags.Export);
}
if (allowConst) {
for (const decl of node.declarations) {
PreferConstWalker.addDeclarationName(decl.name, node, scopeInfo);
}
Expand Down

0 comments on commit 23552e0

Please sign in to comment.