Skip to content

Fix latest tslint errors - #13006

Merged
Mohamed Hegazy (mhegazy) merged 8 commits into
microsoft:masterfrom
saschanaz:lintfix
Dec 26, 2016
Merged

Mohamed Hegazy (mhegazy) merged 8 commits into
microsoft:masterfrom
saschanaz:lintfix

Conversation

@saschanaz

@saschanaz Kagami Sascha Rosylight (saschanaz) commented Dec 18, 2016 •

Copy link
Copy Markdown
Contributor

Except this type of errors:

export function getNavigationTree(sourceFile: SourceFile): NavigationTree {
    curSourceFile = sourceFile;
    const result = convertToTree(rootNavigationBarNode(sourceFile));
    curSourceFile = undefined;
    return result;
}
let curSourceFile: SourceFile;
// Identifier 'curSourceFile' is never reassigned; use 'const' instead of 'let'.
let response: protocol.Response;
try {
    ({ response } = this.executeCommand(msg));
}
//  Identifier 'response' is never reassigned; use 'const' instead of 'let'.

I think they are tslint bugs rather than actual code problem. (palantir/tslint#1898)

BTW I feel fairly painful to create a new constant for every for-loop, I hope there is a better way to keep high performance...

@saschanaz

Kagami Sascha Rosylight (saschanaz) commented Dec 18, 2016 •

Copy link
Copy Markdown
Contributor Author

A benchmark shows for-of loop is much slower on Chrome (and thus node.js), does this mean we shouldn't use for-of?

@ghost

Copy link
Copy Markdown

for-of gets emitted as a for loop, since we use an ES5 target. (So maybe some of those manually-written for loops could be upgraded.)
Also, this would be a good time to delete our own preferConstRule.ts since tslint has that now.

@saschanaz

Copy link
Copy Markdown
Contributor Author

Already done the upgrade for obvious cases but many of them are using indices so I couldn't do it for them.

@mhegazy Mohamed Hegazy (mhegazy) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would inline the collection.length check instead of adding a new variable for it. There is not much perf difference on modern engines anyways.

Comment thread src/compiler/checker.ts Outdated
const result: Signature[] = [];
for (let i = 0, len = symbol.declarations.length; i < len; i++) {
const len = symbol.declarations.length;
for (let i = 0; i < len; i++) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

switch to for..of?

@saschanaz Kagami Sascha Rosylight (saschanaz) Dec 19, 2016 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inner lines of code use i for some purpose. It seems I can still switch to for-of in this case but should I do it?

Comment thread src/compiler/checker.ts
for (let i = isJSConstructSignature ? 1 : 0, n = declaration.parameters.length; i < n; i++) {
const n = declaration.parameters.length;
for (let i = isJSConstructSignature ? 1 : 0; i < n; i++) {
const param = declaration.parameters[i];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for (let i = isJSConstructSignature ? 1 : 0; i < declaration.parameters.length; i++) {

@mhegazy

Copy link
Copy Markdown
Contributor

Kagami Sascha Rosylight (@saschanaz) i have merged a change to move tslint back to 4.0.0-dev.3 (#13028). can you update it with your PR to next again.

@saschanaz

Copy link
Copy Markdown
Contributor Author

It still won't pass because of some bugs, which should be fixed on tslint side.

@mhegazy

Copy link
Copy Markdown
Contributor

It still won't pass because of some bugs, which should be fixed on tslint side.

do you have a list of the issues?

@ghost

Deleted user (ghost) commented Dec 19, 2016 •

Copy link
Copy Markdown

Mohamed Hegazy (@mhegazy) See first post and palantir/tslint#1898. I actually fixed one of them yesterday. The other one is also a legitimate issue, but could be fixed on our end by moving the declaration ( let curSourceFile: SourceFile;) to before the function.

@saschanaz

Copy link
Copy Markdown
Contributor Author

Andy (Andrewkraft) (@Andy-MS) I'm still seeing destructuring issue on Travis, should I do something to get the merged fix?

@ghost

Copy link
Copy Markdown

tslint hasn't published a new version yet, so there's not much to do but wait.

@vladima

Copy link
Copy Markdown
Contributor

I'd prefer not to change our code to workaround bugs in the toolchain hence palantir/tslint#1908

@mhegazy

Copy link
Copy Markdown
Contributor

Noah Chen (@nchen63) any news about palantir/tslint#1908?

@nchen63

Copy link
Copy Markdown
Contributor

it's merged and included in a new release, v4.2.0

@saschanaz

Copy link
Copy Markdown
Contributor Author

It seems tslint@next is still giving tslint@4.1.0-dev.0.

@nchen63

Copy link
Copy Markdown
Contributor

should be fixed now

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants