Skip to content

Commit 7d9604f

Browse files
committed
changes for latest typescript version
1 parent bb75a20 commit 7d9604f

File tree

4 files changed

+21
-7
lines changed

4 files changed

+21
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"nyc": "^12.0.1",
4848
"rimraf": "^2.6.2",
4949
"tslint": "^5.8.0",
50-
"typescript": "~2.8.1"
50+
"typescript": "2.9.1"
5151
},
5252
"peerDependencies": {
5353
"tslint": "^5.0.0",

rules/namingConventionRule.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,10 @@ class IdentifierNameWalker extends Lint.AbstractWalker<NormalizedConfig[]> {
312312
return this._usage.get(name)!.uses.length === 0;
313313
}
314314

315-
private _checkTypeParameters(node: ts.DeclarationWithTypeParameters, modifiers: Modifiers) {
315+
private _checkTypeParameters(
316+
node: ts.SignatureDeclaration | ts.ClassLikeDeclaration | ts.InterfaceDeclaration | ts.TypeAliasDeclaration,
317+
modifiers: Modifiers,
318+
) {
316319
if (node.typeParameters !== undefined)
317320
for (const {name} of node.typeParameters)
318321
this._checkName(name, TypeSelector.genericTypeParameter, modifiers);

rules/noUnnecessaryTypeAnnotationRule.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,11 @@ function walk(ctx: Lint.WalkContext<IOptions>, checker: ts.TypeChecker) {
221221
}
222222

223223
function signatureHasGenericOrTypePredicateReturn(signature: ts.Signature): boolean {
224+
if (signature.declaration === undefined)
225+
return false;
224226
if (signature.declaration.type !== undefined && isTypePredicateNode(signature.declaration.type))
225227
return true;
226-
const original = checker.getSignatureFromDeclaration(signature.declaration);
228+
const original = checker.getSignatureFromDeclaration(<ts.SignatureDeclaration>signature.declaration);
227229
return original !== undefined && isTypeParameter(original.getReturnType());
228230
}
229231

@@ -277,7 +279,10 @@ function walk(ctx: Lint.WalkContext<IOptions>, checker: ts.TypeChecker) {
277279
function getMatchingSignature(type: ts.Type, parameters: ReadonlyArray<ts.ParameterDeclaration>): [ts.Signature, boolean] | undefined {
278280
const minArguments = getMinArguments(parameters);
279281

280-
const signatures = getSignaturesOfType(type).filter((s) => getNumParameters(s.declaration.parameters) >= minArguments);
282+
const signatures = getSignaturesOfType(type).filter(
283+
(s) => s.declaration !== undefined &&
284+
getNumParameters(<ReadonlyArray<ts.ParameterDeclaration>>s.declaration.parameters) >= minArguments,
285+
);
281286

282287
switch (signatures.length) {
283288
case 0:

rules/preferConstEnumRule.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,9 @@ function onlyConstUses(track: IEnum): boolean {
110110
default:
111111
return false;
112112
case ts.SyntaxKind.ElementAccessExpression:
113-
if ((<ts.ElementAccessExpression>parent).argumentExpression === undefined ||
114-
(<ts.ElementAccessExpression>parent).argumentExpression!.kind !== ts.SyntaxKind.StringLiteral)
113+
// wotan-disable-next-line no-useless-predicate
114+
if ((<ts.ElementAccessExpression>parent).argumentExpression === undefined || // compatibilty with typescript@<2.9.0
115+
(<ts.ElementAccessExpression>parent).argumentExpression.kind !== ts.SyntaxKind.StringLiteral)
115116
return false;
116117
break;
117118
case ts.SyntaxKind.PropertyAccessExpression:
@@ -147,7 +148,12 @@ function isConstInitializer(initializer: ts.Expression, members: Map<string, IEn
147148
return member !== undefined && member.isConst && (allowStrings || !member.stringValued);
148149
}
149150
if (isElementAccessExpression(node)) {
150-
if (!isIdentifier(node.expression) || node.argumentExpression === undefined || !isStringLiteral(node.argumentExpression))
151+
if (
152+
!isIdentifier(node.expression) ||
153+
// wotan-disable-next-line no-useless-predicate
154+
node.argumentExpression === undefined || // compatibility with typescript@<2.9.0
155+
!isStringLiteral(node.argumentExpression)
156+
)
151157
return false;
152158
const track = findEnum(node.expression);
153159
if (track === undefined)

0 commit comments

Comments
 (0)