Skip to content

Commit e7d3283

Browse files
Disable noUnusedLocals compiler option during script compilation
1 parent 1a39596 commit e7d3283

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"typescript",
1919
"verify"
2020
],
21-
"version": "1.0.1",
21+
"version": "1.1.0",
2222
"main": "dist/index.js",
2323
"bin": "./dist/bin/compile-typescript-docs.js",
2424
"license": "Apache-2.0",

src/CodeBlockExtractor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export class CodeBlockExtractor {
2222

2323
private static extractCodeBlocksFromMarkdown (markdown: string): string[] {
2424
const codeBlocks: string[] = []
25-
markdown.replace(this.TYPESCRIPT_CODE_PATTERN, (fullMatch, code) => {
25+
markdown.replace(this.TYPESCRIPT_CODE_PATTERN, (_, code) => {
2626
codeBlocks.push(code)
2727
return code
2828
})

src/SnippetCompiler.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,20 @@ export class SnippetCompiler {
2525
private readonly runner: TypeScriptRunner
2626

2727
constructor (private readonly workingDirectory: string) {
28-
const configOptions = tsconfig.loadSync(process.cwd())
28+
const configOptions = SnippetCompiler.loadTypeScriptConfig()
2929
this.runner = new TypeScriptRunner(this.workingDirectory, configOptions.config)
3030
}
3131

32+
private static loadTypeScriptConfig (): any {
33+
const typeScriptConfig = tsconfig.loadSync(process.cwd())
34+
if (typeScriptConfig &&
35+
typeScriptConfig.config &&
36+
typeScriptConfig.config.compilerOptions) {
37+
typeScriptConfig.config.compilerOptions.noUnusedLocals = false
38+
}
39+
return typeScriptConfig
40+
}
41+
3242
compileSnippets (documentationFiles: string[]): Bluebird<SnippetCompilationResult[]> {
3343
return Bluebird.resolve()
3444
.then(() => this.cleanWorkingDirectory())

tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
"alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
2929

3030
/* Additional Checks */
31-
// "noUnusedLocals": true, /* Report errors on unused locals. */
32-
// "noUnusedParameters": true, /* Report errors on unused parameters. */
31+
"noUnusedLocals": true , /* Report errors on unused locals. */
32+
"noUnusedParameters": true, /* Report errors on unused parameters. */
3333
"noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
3434
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
3535

0 commit comments

Comments
 (0)