Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Update typescript #109

Merged
merged 1 commit into from
Jan 28, 2021
Merged

Update typescript #109

merged 1 commit into from
Jan 28, 2021

Conversation

mdonnalley
Copy link
Contributor

@mdonnalley mdonnalley commented Jan 19, 2021

Updates

  • typescript to 4.1.3
  • @typescript-eslint/eslint-plugin to ^4.2.0
  • @typescript-eslint/parser to ^4.2.0

@W-8667867@

@mdonnalley mdonnalley self-assigned this Jan 19, 2021
@mdonnalley mdonnalley requested a review from amphro January 19, 2021 20:08
Copy link
Contributor

@shetzel shetzel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lots of great changes in this! However, I think we can remove more rule disablements. It should be very rare when we disable rules and there should be a reason provided when we do....unless we're planning to file more stories about removing rule disablements.

Not sure where things are with the lazy loader code. Maybe @amphro has a better sense of the status of that lib.

@@ -9,6 +9,8 @@ import { expect } from 'chai';
import { Env } from '../src/env';
import { InvalidDefaultEnvValueError } from '../src/errors';

/* eslint-disable no-shadow */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO we should change the code to not shadow.

@@ -280,6 +280,7 @@ export namespace Duration {
/**
* Units of duration.
*/
/* eslint-disable-next-line no-shadow */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just remove the shadowed vars?

@@ -5,6 +5,9 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

/* eslint-disable @typescript-eslint/ban-types */
/* eslint-disable no-shadow */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the types we're using that it doesn't like? Can't we fix that instead? And refactor the shadowed vars?

@@ -69,7 +72,8 @@ export function defaults(obj: unknown, ...otherArgs: unknown[]): unknown {
* @param predicate The function invoked per iteration.
*/
export function findKey<T>(obj: Nullable<T>, predicate?: ObjectIteratee<T>): Optional<string> {
return _.findKey(obj, predicate);
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem necessary anymore since it's disabled for the entire file above. However, we should do what we can to avoid disabling typescript rules. If we really have to, then add a comment to describe why it's necessary.

* Typescript recommends using Record<string, unknown> instead of the generic object type. See https://github.com/microsoft/TypeScript/issues/21732.
* However, this breaks current functionality so we aliased the object type and disabled eslint for now.
*/
// eslint-disable-next-line @typescript-eslint/ban-types
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we create a work item to make this change in a major version bump of the library?

@@ -39,6 +39,7 @@ export function toAnyJson<T>(value: Nullable<T>, defaultValue: AnyJson): AnyJson
// underlying function
export function toAnyJson<T>(value: Nullable<T>, defaultValue?: AnyJson): Optional<AnyJson> {
try {
/* eslint-disable-next-line @typescript-eslint/no-unsafe-return */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we just coerce the type returned by JSON.parse() to be AnyJson rather than disable the rule?

Base automatically changed from develop to main January 19, 2021 21:36
@mdonnalley mdonnalley force-pushed the mdonnalley/update-ts branch from ea4a484 to a5f0810 Compare January 20, 2021 02:49
@mdonnalley mdonnalley requested a review from shetzel January 20, 2021 02:57
@mdonnalley mdonnalley force-pushed the mdonnalley/update-ts branch 3 times, most recently from 071900b to 11ca471 Compare January 20, 2021 21:38
Copy link
Collaborator

@amphro amphro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ya, bummer we need to exclude so many rules. Some of these libraries are so low level that we will probably never completely remove all the exclusions. It might be nice to have comments on ones we will never change and TODOs for the ones we want to fix.

"@typescript-eslint/eslint-plugin": "^2.30.0",
"@typescript-eslint/parser": "^2.30.0",
"@typescript-eslint/eslint-plugin": "^4.2.0",
"@typescript-eslint/parser": "^4.2.0",
"eslint": "^6.8.0",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Geesh, I wonder if we also need a similar story around keeping eslint up-to-date... it is never ending.

@mdonnalley mdonnalley force-pushed the mdonnalley/update-ts branch from 11ca471 to ea52ae2 Compare January 22, 2021 22:35
@mdonnalley mdonnalley force-pushed the mdonnalley/update-ts branch from ea52ae2 to ec3b8cd Compare January 25, 2021 16:18
@amphro
Copy link
Collaborator

amphro commented Jan 28, 2021

I ran and tested this locally, as well as linked it to several projects. The new versions of kit and ts-types works great. The new dev scripts cause a lot of compilation problems in new repos but that is expected with a major bump of typescript, but that is only a dev dep.

@amphro amphro merged commit 399a0b0 into main Jan 28, 2021
@amphro amphro deleted the mdonnalley/update-ts branch January 28, 2021 04:35
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants