-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Forbid unused locals/parameters in compiler #11715
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
Conversation
mhegazy
left a comment
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.
👍
can you also build LKG and make sure non of these changes change typesript.d.ts, we do not want to break API users
src/compiler/comments.ts
Outdated
| } | ||
|
|
||
| function emitTripleSlashLeadingComment(commentPos: number, commentEnd: number, kind: SyntaxKind, hasTrailingNewLine: boolean, rangePos: number) { | ||
| function emitTripleSlashLeadingComment(commentPos: number, commentEnd: number, _kind: SyntaxKind, hasTrailingNewLine: boolean, rangePos: number) { |
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.
why _kind? seems it is used two lines below.
src/compiler/core.ts
Outdated
| } | ||
| else { | ||
| return t => u => u; | ||
| return _t => u => u; |
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.
consider making it jsut _
src/compiler/emitter.ts
Outdated
|
|
||
| const id = (s: SourceFile) => s; | ||
| const nullTransformers: Transformer[] = [ctx => id]; | ||
| const nullTransformers: Transformer[] = [_ctx => id]; |
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.
_ instead of _ctx
src/compiler/moduleNameResolver.ts
Outdated
| /* @internal */ | ||
| export function trace(host: ModuleResolutionHost, message: DiagnosticMessage, ...args: any[]): void; | ||
| export function trace(host: ModuleResolutionHost, message: DiagnosticMessage): void { | ||
| export function trace(host: ModuleResolutionHost, _message: DiagnosticMessage): void { |
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.
consider removing _message all together from the implementation signature, export function trace(host: ModuleResolutionHost): void { .. }
src/compiler/parser.ts
Outdated
| // attached to the EOF token. | ||
| let parseErrorBeforeNextFinishedNode = false; | ||
|
|
||
| export function parseSourceFile(fileName: string, _sourceText: string, languageVersion: ScriptTarget, _syntaxCursor: IncrementalParser.SyntaxCursor, setParentNodes?: boolean, scriptKind?: ScriptKind): SourceFile { |
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.
why do these start with _?
src/compiler/sys.ts
Outdated
| getCurrentDirectory: () => ChakraHost.currentDirectory, | ||
| getDirectories: ChakraHost.getDirectories, | ||
| getEnvironmentVariable: ChakraHost.getEnvironmentVariable || ((name: string) => ""), | ||
| getEnvironmentVariable: ChakraHost.getEnvironmentVariable || ((_name: string) => ""), |
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.
do not think you need ht type annotation here.
|
|
Mostly I just removed any parameter that wasn't used, and then removed it from callers. If a function is used as a callback, and other callbacks use that parameter, I use an
_underscoredparameter name.TODO: The same thing for harness/server/services, and probably use tsconfig inheritance.