Skip to content
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

Enable noImplicitAny option #200

Merged
merged 2 commits into from
Nov 28, 2023
Merged

Enable noImplicitAny option #200

merged 2 commits into from
Nov 28, 2023

Conversation

castrodd
Copy link
Member

Currently, noImplicitAny is set to false. In general, this setting should be turned on, but I know it is useful for codebases transitioning from non-typed JavaScript to TypeScript.

When I checked how much work was needed to set noImplicitAny to true, I found that there were only two errors:

ERROR in ./src/converters/fromRpcNullable.ts:13:13
TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'.
  No index signature with a parameter of type 'string' was found on type '{}'.
    11 |     if (nullableMapping && Object.keys(nullableMapping).length > 0) {
    12 |         for (const key in nullableMapping) {
  > 13 |             converted[key] = nullableMapping[key].value || '';
       |             ^^^^^^^^^^^^^^
    14 |         }
    15 |     } else if (originalMapping && Object.keys(originalMapping).length > 0) {
    16 |         converted = originalMapping;

ERROR in ./src/converters/toCamelCase.ts:12:13
TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'.
  No index signature with a parameter of type 'string' was found on type '{}'.
    10 |         const result = {};
    11 |         for (const [key, value] of Object.entries(data)) {
  > 12 |             result[toCamelCaseKey(key)] = toCamelCaseValue(value);
       |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    13 |         }
    14 |         return result;
    15 |     }

This PR addresses these two errors and sets noImplicitAny to true (this is the default when strict is true).

src/converters/toCamelCase.ts Outdated Show resolved Hide resolved
@castrodd castrodd merged commit 069646b into v4.x Nov 28, 2023
11 checks passed
@castrodd castrodd deleted the dc/noImplicitAny branch November 28, 2023 22:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants