-
Notifications
You must be signed in to change notification settings - Fork 234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: use type guard instead of unnecessary or incorrect type assertions #659
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,7 +64,7 @@ function computeLineAndCharacterOfPosition(lineStarts: number[], position: numbe | |
} | ||
|
||
function computeLineStarts(text: string): number[] { | ||
const result: number[] = new Array(); | ||
const result: number[] = []; | ||
let pos = 0; | ||
let lineStart = 0; | ||
while (pos < text.length) { | ||
|
@@ -95,7 +95,7 @@ export class SourceMappingVisitor extends RuleWalker { | |
parentAST: any; | ||
private consumer: SourceMapConsumer; | ||
|
||
constructor(sourceFile: ts.SourceFile, options: IOptions, protected codeWithMap: CodeWithSourceMap, protected basePosition: number) { | ||
constructor(sourceFile: ts.SourceFile, options: IOptions, public codeWithMap: CodeWithSourceMap, protected basePosition: number) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was necessary because I've changed the type of
|
||
super(sourceFile, options); | ||
if (this.codeWithMap.map) { | ||
this.consumer = new SourceMapConsumer(this.codeWithMap.map); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs defaults in order to guard the same way the original did. Not sure if intentional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The property
controller
always exists according to:codelyzer/src/angular/metadata.ts
Lines 23 to 27 in da0f553
... and it makes sense, because once we instantiate a
DirectiveMetadata
, we pass all properties:codelyzer/src/angular/metadataReader.ts
Lines 63 to 67 in da0f553
... now I'm curious on why we are using
Object.assign
instead of a trivialconstructor
. Thoughts?Anyway, these "defaults" should have been changed in #631, but I really forgot about it. 😞