Skip to content

Conversation

saschanaz
Copy link
Contributor

@saschanaz saschanaz commented Dec 18, 2016

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
Copy link
Contributor Author

saschanaz commented Dec 18, 2016

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

ghost commented Dec 18, 2016

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
Contributor Author

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

Copy link
Contributor

@mhegazy mhegazy left a comment

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.

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
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?

Copy link
Contributor Author

@saschanaz saschanaz Dec 19, 2016

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?

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
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
Contributor

mhegazy commented Dec 19, 2016

@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
Contributor Author

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

@mhegazy
Copy link
Contributor

mhegazy commented Dec 19, 2016

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
Copy link

ghost commented Dec 19, 2016

@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
Contributor Author

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

@ghost
Copy link

ghost commented Dec 19, 2016

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

@vladima
Copy link
Contributor

vladima commented Dec 19, 2016

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

@mhegazy
Copy link
Contributor

mhegazy commented Dec 21, 2016

@nchen63 any news about palantir/tslint#1908?

@nchen63
Copy link
Contributor

nchen63 commented Dec 23, 2016

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

@saschanaz
Copy link
Contributor Author

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

@nchen63
Copy link
Contributor

nchen63 commented Dec 23, 2016

should be fixed now

@saschanaz saschanaz closed this Dec 23, 2016
@saschanaz saschanaz reopened this Dec 23, 2016
@mhegazy mhegazy merged commit e4b81d0 into microsoft:master Dec 26, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
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