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 noUncheckedIndexedAccess #1175

Merged
merged 28 commits into from
Jul 10, 2023
Merged

Enable noUncheckedIndexedAccess #1175

merged 28 commits into from
Jul 10, 2023

Conversation

samchungy
Copy link
Contributor

@samchungy samchungy commented May 17, 2023

Release seek-tsconfig 2.0

@changeset-bot
Copy link

changeset-bot bot commented May 17, 2023

🦋 Changeset detected

Latest commit: 4cf0b2b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
skuba Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@@ -0,0 +1,35 @@
---
'skuba': major
Copy link
Contributor Author

@samchungy samchungy May 17, 2023

Choose a reason for hiding this comment

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

minor or major? 🤔 I think because it will likely be a breaking change for alot of repos we should probably make it major

@samchungy samchungy mentioned this pull request May 25, 2023
1 task
@samchungy samchungy marked this pull request as ready for review May 25, 2023 03:38
@samchungy samchungy requested review from a team as code owners May 25, 2023 03:38
Copy link
Member

Choose a reason for hiding this comment

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

Oof, I'm kinda hot and cold on this change now that the tsconfig-seek upgrade has propagated to a couple of our repos and I'm seeing this PR as well 😅. It seems like there are many common scenarios that are not inferred. For example:

const result = /^([a-z])/.match(input);

if (result) {
  // !!!
  result[1];
}

// !!!
''.split('#')[0];

const xs: Array<{key: string, value: string}>;

if (xs.length === 1) {
  // !!!
  const x = xs[0];

  const record = Object.fromEntries(xs.map(x) => [x.key, x.value]);

  // !!!
  record[x.key];
}

I don't blame TypeScript here but I worry about the DX on generally well-behaved codebases once we enforce this option. We need to make sure that we can somehow deliver this without normalising usage of easy escape hatches like !; what we don't want is for this change to end up proliferating unsafe practices, and beyond just indexed access.

template/lambda-sqs-worker/src/app.ts Outdated Show resolved Hide resolved
src/cli/init/getConfig.ts Outdated Show resolved Hide resolved
Comment on lines +45 to +47
if (!modulePath) {
return `${chalk.bold(value)} is an invalid module path`;
}
Copy link
Member

Choose a reason for hiding this comment

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

Is this even possible? The only way I've been able to arrive at an empty array is by doing ''.split('').

@@ -44,7 +44,7 @@ describe('soft', () => {

const directory = await fs.promises.readdir(dir);

expect(commits[0].oid).toEqual(initialCommit);
expect(commits[0]?.oid).toEqual(initialCommit);
Copy link
Member

Choose a reason for hiding this comment

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

It's unfortunate that this applies to tests too; ideally we'd have an ESLint rule so we could disable it on test files.

It's a bit of a wash in this example, but I'd be open to use of ! in tests. A runtime error is harmless here and would equally indicate that the test failed.

scripts/package.ts Outdated Show resolved Hide resolved
@samchungy samchungy enabled auto-merge (squash) July 9, 2023 23:59
@samchungy samchungy merged commit 8b42656 into master Jul 10, 2023
19 checks passed
@samchungy samchungy deleted the tsconfig-indexed-access branch July 10, 2023 00:07
@seek-oss-ci seek-oss-ci mentioned this pull request Jul 10, 2023
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.

None yet

2 participants