Skip to content

Commit

Permalink
fix(NOJIRA-123): strict typechecks enable noImplicitAny by default
Browse files Browse the repository at this point in the history
  • Loading branch information
trapped committed Aug 8, 2023
1 parent 44de8f2 commit e8f4bcd
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
21 changes: 21 additions & 0 deletions src/checks/requiredTypeScript.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -445,4 +445,25 @@ describe('missingTsConfigSettings', () => {
})
).not.toContainEqual(expect.stringMatching(/compilerOptions.noImplicitAny/))
})
it('considers compilerOptions.noImplicitAny = true if compilerOptions.strict = true', () => {
expect(
missingTsConfigSettings({
compilerOptions: {
strict: true,
allowUnreachableCode: false,
},
})
).not.toContainEqual(expect.stringMatching(/compilerOptions.noImplicitAny/))
})
it('requires not setting compilerOptions.noImplicitAny = false if compilerOptions.strict = true', () => {
expect(
missingTsConfigSettings({
compilerOptions: {
strict: true,
noImplicitAny: false,
allowUnreachableCode: false,
},
})
).toContainEqual(expect.stringMatching(/compilerOptions.noImplicitAny/))
})
})
7 changes: 6 additions & 1 deletion src/checks/requiredTypeScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import ignore, { Ignore as IgnoredFileFilter } from 'ignore'

type TsConfig = {
compilerOptions?: {
strict?: boolean
allowUnreachableCode?: boolean
noImplicitAny?: boolean
}
Expand Down Expand Up @@ -208,7 +209,11 @@ export function missingTsConfigSettings(tsconfig: TsConfig): string[] {
errors.push('compilerOptions.allowUnreachableCode must be false')
}

if (tsconfig.compilerOptions?.noImplicitAny !== true) {
if (
(tsconfig.compilerOptions?.strict !== true &&
tsconfig.compilerOptions?.noImplicitAny !== true) ||
tsconfig.compilerOptions?.noImplicitAny === false
) {
errors.push('compilerOptions.noImplicitAny must be true')
}

Expand Down

0 comments on commit e8f4bcd

Please sign in to comment.