Skip to content

Commit

Permalink
Fix CI: no-implicit-dependencies test failure; typescript@next failure (
Browse files Browse the repository at this point in the history
palantir#4019)

* Fix CI, which became red after consequent merge palantir#3979, palantir#3875

* Upgrade [email protected], [email protected]

* Remove unneded type assertion after typescript upgrade

* Add runtime check for 'ts.unescapeIdentifier()' presence
  • Loading branch information
pablobirukov authored and johnwiseheart committed Jul 11, 2018
1 parent 9d7db47 commit 29fbace
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 9 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"resolve": "^1.3.2",
"semver": "^5.3.0",
"tslib": "^1.8.0",
"tsutils": "^2.12.1"
"tsutils": "^2.27.2"
},
"peerDependencies": {
"typescript": ">=2.1.0 || >=2.1.0-dev || >=2.2.0-dev || >=2.3.0-dev || >=2.4.0-dev || >=2.5.0-dev || >=2.6.0-dev || >=2.7.0-dev || >=2.8.0-dev || >=2.9.0-dev"
Expand All @@ -75,7 +75,7 @@
"ts-node": "^3.3.0",
"tslint": "^5.8.0",
"tslint-test-config-non-relative": "file:test/external/tslint-test-config-non-relative",
"typescript": "~2.8.3"
"typescript": "~2.9.2"
},
"license": "Apache-2.0",
"engines": {
Expand Down
12 changes: 10 additions & 2 deletions src/rules/noStringLiteralRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ export class Rule extends Lint.Rules.AbstractRule {

public static FAILURE_STRING = "object access via string literals is disallowed";

public static id(input: string) {
return input;
}

public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
return this.applyWithFunction(sourceFile, walk);
}
Expand All @@ -52,8 +56,12 @@ function walk(ctx: Lint.WalkContext<void>) {
if (isElementAccessExpression(node)) {
const argument = node.argumentExpression;
if (argument !== undefined && isStringLiteral(argument) && isValidPropertyAccess(argument.text)) {
// for compatibility with typescript@<2.5.0 to avoid fixing expr['__foo'] to expr.___foo
const propertyName = ts.unescapeIdentifier(argument.text); // tslint:disable-line:deprecation
// typescript@<2.5.0 has an extra underscore in escaped identifier text content,
// to avoid fixing issue `expr['__foo'] → expr.___foo`, unescapeIdentifier() is to be used
// As of typescript@3, unescapeIdentifier() removed, thus check in runtime, if the method exists
// tslint:disable-next-line no-unsafe-any strict-boolean-expressions
const unescapeIdentifier: typeof Rule["id"] = (ts as any).unescapeIdentifier || Rule.id;
const propertyName = unescapeIdentifier(argument.text);
ctx.addFailureAtNode(
argument,
Rule.FAILURE_STRING,
Expand Down
2 changes: 1 addition & 1 deletion src/rules/noUnsafeAnyRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ function isPropertyAny(node: ts.PropertyDeclaration, checker: ts.TypeChecker) {
if (!isNodeAny(node.name, checker) || node.name.kind === ts.SyntaxKind.ComputedPropertyName) {
return false;
}
for (const base of checker.getBaseTypes(checker.getTypeAtLocation(node.parent!) as ts.InterfaceType)) {
for (const base of checker.getBaseTypes(checker.getTypeAtLocation(node.parent) as ts.InterfaceType)) {
const prop = base.getProperty(node.name.text);
if (prop !== undefined && prop.declarations !== undefined) {
return isAny(checker.getTypeOfSymbolAtLocation(prop, prop.declarations[0]));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as ts from 'typescript';
~~~~~~~~~~~~ [err % ('typescript')]

import * from 'src/a';

Expand Down
16 changes: 13 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1568,6 +1568,10 @@ tslib@^1.8.0:
version "1.8.0"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.8.0.tgz#dc604ebad64bcbf696d613da6c954aa0e7ea1eb6"

tslib@^1.8.1:
version "1.9.3"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286"

"tslint-test-config-non-relative@file:test/external/tslint-test-config-non-relative":
version "0.0.1"

Expand All @@ -1593,6 +1597,12 @@ tsutils@^2.12.1:
dependencies:
tslib "^1.7.1"

tsutils@^2.27.2:
version "2.27.2"
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.27.2.tgz#60ba88a23d6f785ec4b89c6e8179cac9b431f1c7"
dependencies:
tslib "^1.8.1"

[email protected]:
version "0.1.1"
resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-0.1.1.tgz#0ba5ec2a885640e470ea4e8505971900dac58822"
Expand All @@ -1601,9 +1611,9 @@ type-detect@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-1.0.0.tgz#762217cc06db258ec48908a1298e8b95121e8ea2"

typescript@~2.8.3:
version "2.8.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.8.3.tgz#5d817f9b6f31bb871835f4edf0089f21abe6c170"
typescript@~2.9.2:
version "2.9.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.9.2.tgz#1cbf61d05d6b96269244eb6a3bce4bd914e0f00c"

uglify-js@^2.6:
version "2.8.28"
Expand Down

0 comments on commit 29fbace

Please sign in to comment.