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

Commit

Permalink
Update to typescript@2.5.1 (#3151)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajafff authored Aug 24, 2017
1 parent e832ede commit 6b05193
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 25 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@
"resolve": "^1.3.2",
"semver": "^5.3.0",
"tslib": "^1.7.1",
"tsutils": "^2.7.1"
"tsutils": "^2.8.1"
},
"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"
"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"
},
"devDependencies": {
"@types/babel-code-frame": "^6.20.0",
Expand All @@ -72,9 +72,9 @@
"npm-run-all": "^4.0.2",
"nyc": "^10.2.0",
"rimraf": "^2.5.4",
"tslint": "^5.5.0",
"tslint": "^5.6.0",
"tslint-test-config-non-relative": "file:test/external/tslint-test-config-non-relative",
"typescript": "~2.4.1"
"typescript": "~2.5.1"
},
"license": "Apache-2.0",
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion src/rules/memberOrderingRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ class MemberOrderingWalker extends Lint.AbstractWalker<Options> {
return ts.forEachChild(sourceFile, cb);
}

private checkMembers(members: Member[]) {
private checkMembers(members: ts.NodeArray<Member>) {
let prevRank = -1;
let prevName: string | undefined;
for (const member of members) {
Expand Down
5 changes: 4 additions & 1 deletion src/rules/noInferrableTypesRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ class NoInferrableTypesWalker extends Lint.AbstractWalker<Options> {
}
}

function shouldCheck(node: ts.Node, { ignoreParameters, ignoreProperties }: Options): node is ts.VariableLikeDeclaration {
function shouldCheck(
node: ts.Node,
{ ignoreParameters, ignoreProperties }: Options,
): node is ts.ParameterDeclaration | ts.PropertyDeclaration | ts.VariableDeclaration {
switch (node.kind) {
case ts.SyntaxKind.Parameter:
return !ignoreParameters &&
Expand Down
3 changes: 2 additions & 1 deletion src/rules/noSubmoduleImportsRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ class NoSubmoduleImportsWalker extends Lint.AbstractWalker<string[]> {

private checkForBannedImport(expression: ts.Expression) {
if (isTextualLiteral(expression) &&
ts.moduleHasNonRelativeName(expression.text) &&
// TODO remove assertion on upgrade to typescript@2.5.2
!(ts as any as {isExternalModuleNameRelative(m: string): boolean}).isExternalModuleNameRelative(expression.text) &&
isSubmodulePath(expression.text)) {
/*
* A submodule is being imported.
Expand Down
10 changes: 6 additions & 4 deletions src/rules/preferConstRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,12 @@ class PreferConstWalker extends Lint.AbstractWalker<Options> {
if (node.kind === ts.SyntaxKind.VariableDeclarationList) {
this.handleVariableDeclaration(node as ts.VariableDeclarationList);
} else if (node.kind === ts.SyntaxKind.CatchClause) {
this.handleBindingName((node as ts.CatchClause).variableDeclaration.name, {
canBeConst: false,
isBlockScoped: true,
});
if ((node as ts.CatchClause).variableDeclaration !== undefined) {
this.handleBindingName((node as ts.CatchClause).variableDeclaration!.name, {
canBeConst: false,
isBlockScoped: true,
});
}
} else if (node.kind === ts.SyntaxKind.Parameter) {
this.handleBindingName((node as ts.ParameterDeclaration).name, {
canBeConst: false,
Expand Down
6 changes: 5 additions & 1 deletion src/rules/typedefRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ class TypedefWalker extends Lint.AbstractWalker<Options> {
name?: ts.Node): void {
if (this.options[option] === true && typeAnnotation === undefined) {
const failure = `expected ${option}${name === undefined ? "" : `: '${name.getText()}'`} to have a typedef`;
if (Array.isArray(location)) {
if (isNodeArray(location)) {
this.addFailure(location.pos - 1, location.end + 1, failure);
} else {
this.addFailureAtNode(location, failure);
Expand All @@ -212,3 +212,7 @@ class TypedefWalker extends Lint.AbstractWalker<Options> {
function isTypedPropertyDeclaration(node: ts.Node): boolean {
return utils.isPropertyDeclaration(node) && node.type !== undefined;
}

export function isNodeArray(nodeOrArray: ts.Node | ts.NodeArray<ts.Node>): nodeOrArray is ts.NodeArray<ts.Node> {
return Array.isArray(nodeOrArray);
}
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export function flatMap<T, U>(inputs: ReadonlyArray<T>, getOutputs: (input: T, i
}

/** Returns an array of all outputs that are not `undefined`. */
export function mapDefined<T, U>(inputs: T[], getOutput: (input: T) => U | undefined): U[] {
export function mapDefined<T, U>(inputs: ReadonlyArray<T>, getOutput: (input: T) => U | undefined): U[] {
const out = [];
for (const input of inputs) {
const output = getOutput(input);
Expand Down
4 changes: 2 additions & 2 deletions test/executable/executableTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ function execCli(args: string[], options: cp.ExecFileOptions | ExecFileCallback,
}

if (isFunction(options)) {
cb = options as ExecFileCallback;
cb = options;
options = {};
}

Expand All @@ -475,7 +475,7 @@ function execCli(args: string[], options: cp.ExecFileOptions | ExecFileCallback,
});
}

function isFunction(fn: any): boolean {
function isFunction(fn: any): fn is (...args: any[]) => any {
return ({}).toString.call(fn) === "[object Function]";
}

Expand Down
20 changes: 10 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1473,9 +1473,9 @@ tslib@^1.7.1:
"tslint-test-config-non-relative@file:test/external/tslint-test-config-non-relative":
version "0.0.1"

tslint@^5.5.0:
version "5.5.0"
resolved "https://registry.yarnpkg.com/tslint/-/tslint-5.5.0.tgz#10e8dab3e3061fa61e9442e8cee3982acf20a6aa"
tslint@^5.6.0:
version "5.6.0"
resolved "https://registry.yarnpkg.com/tslint/-/tslint-5.6.0.tgz#088aa6c6026623338650b2900828ab3edf59f6cf"
dependencies:
babel-code-frame "^6.22.0"
colors "^1.1.2"
Expand All @@ -1486,11 +1486,11 @@ tslint@^5.5.0:
resolve "^1.3.2"
semver "^5.3.0"
tslib "^1.7.1"
tsutils "^2.5.1"
tsutils "^2.7.1"

tsutils@^2.5.1, tsutils@^2.7.1:
version "2.7.1"
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.7.1.tgz#411a0e9466525a2b2869260a55620d7292155e24"
tsutils@^2.7.1, tsutils@^2.8.1:
version "2.8.1"
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.8.1.tgz#3771404e7ca9f0bedf5d919a47a4b1890a68efff"
dependencies:
tslib "^1.7.1"

Expand All @@ -1502,9 +1502,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.4.1:
version "2.4.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.4.2.tgz#f8395f85d459276067c988aa41837a8f82870844"
typescript@~2.5.1:
version "2.5.1"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.5.1.tgz#ce7cc93ada3de19475cc9d17e3adea7aee1832aa"

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

0 comments on commit 6b05193

Please sign in to comment.