Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Dec 7, 2021. It is now read-only.

Conversation

@justinfagnani
Copy link
Contributor

No description provided.

Copy link
Contributor

@rictic rictic left a comment

Choose a reason for hiding this comment

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

I think we want something that throws rather than console.assert, otherwise LGTM

let head = dom5.query(ast, dom5.predicates.hasTagName('head'));
const ast = parse5.parse(contents);
// parse5 always produces a <head> element
const head = dom5.query(ast, dom5.predicates.hasTagName('head'))!;
Copy link
Contributor

Choose a reason for hiding this comment

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

+1 to constifying. Looks like typescript finds more and more places where they're able to do better type inference with const over let. (yes, const-like behavior can ~always be inferred but the convenience of not having to do that does seem to be paying out for the tsc team) microsoft/TypeScript#10676

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried to only touch declarations near other edits for this PR. We can do this incrementally or do a constification PR to follow up.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1, agree and affirm.

if (this.config.entrypoint && this.config.shell) {
let file = this.fileMap.get(this.config.entrypoint);
const file = this.fileMap.get(this.config.entrypoint)!;
console.assert(file != null);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this only logs, when I think you want to throw.

https://developer.mozilla.org/en-US/docs/Web/API/console/assert

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I really want a short, real assertion. I'll make these a check + throw though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh nice, if I check null and throw, I don't need the ! type operator.

let deps = fragmentToDeps.get(im);
for (const importUrl of this.config.allFragments) {
const file = this.fileMap.get(importUrl)!;
console.assert(file != null);
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

let commandArgs = parsedArgs.argv;
let command = this.commands.get(commandName);
let command = this.commands.get(commandName)!;
console.assert(command != null);
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@justinfagnani
Copy link
Contributor Author

PTAL

@justinfagnani justinfagnani merged commit 4a581ab into master Nov 9, 2016
@justinfagnani justinfagnani deleted the tsc2 branch November 9, 2016 20:27
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.

2 participants