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

Add strict flag to CI TS typechecking #144

Merged
merged 2 commits into from
Aug 13, 2022
Merged

Conversation

MasterOdin
Copy link
Contributor

PR adds the --strict flag to the tsc typechecking that the CI was doing. This increases the strength of typechecking (see https://www.typescriptlang.org/tsconfig#strict for full details), but for this particular case, it's mostly just for catching no implicit any usage. An alternative would be to use --noImplicitAny flag instead, but it doesn't hurt to have tsc validate the definition file is as strict as possible even if some of the stuff doesn't really apply.

Note, this PR will fail until #143 is merged.

@eriktrom
Copy link
Member

thankyou

i knew there was a flag :)

will wait for build

@eriktrom
Copy link
Member

An alternative would be to use --noImplicitAny flag instead, but it doesn't hurt to have tsc validate the definition file is as strict as possible even if some of the stuff doesn't really apply.

let me rethink my typescript days a sec

@MasterOdin
Copy link
Contributor Author

Yup, for posterity, can see https://github.com/MasterOdin/node-portfinder/runs/7820328564?check_suite_focus=true from the first commit for an example of a failed test run due to the usage of implicit any.

@eriktrom
Copy link
Member

Approved, awesome.

Let's use strict - i wonder if any of the people 'building' this library (something that is "news" to me, i'll learn more soon i'm sure) - might be affected? is that a remote possibility?

if not, i'm game, let's ship this

@eriktrom
Copy link
Member

aka, httptoolkit/httptoolkit-server#51

hmmm

no implicit any i think then b/c of this? what do u think?

does it make it harder to fork if it's strict?

@eriktrom
Copy link
Member

i would need to think - what is your suggestion?

@eriktrom
Copy link
Member

strict

@eriktrom eriktrom merged commit 65b2ab7 into http-party:master Aug 13, 2022
@MasterOdin MasterOdin deleted the patch-3 branch August 13, 2022 16:21
@eriktrom
Copy link
Member

@MasterOdin - thanks again for your help today and last weekend

@MasterOdin
Copy link
Contributor Author

People aren't "building" this library directly per se, but rather that when a consumer project uses tsc with skipLibCheck disabled, tsc will go through all dependencies' definition file and validate that they meet the tsconfig of the base project. There shouldn't be any meaningful change to maintainers of this project itself, other than that writing the definition file is a bit stricter. However, given that the definition file is a simple one at 62 lines, I'd hope that anyone with TS experience wouldn't find the new requirement onerous.

does it make it harder to fork if it's strict?

Only in that people cannot write type definitions that use implicit any, which isn't hard to avoid, so the added difficulty should be near zero in the scheme of things.

@MasterOdin
Copy link
Contributor Author

I would add that this PR didn't need a new release as it wasn't touching anything end user facing, but I suppose there's no harm in it 🤷

@eriktrom
Copy link
Member

i left a comment and then deleted it - yeah right?

@MasterOdin
Copy link
Contributor Author

skipLibCheck just means that the declaration file for portfinder isn't validated against the consumer project, but the consumer is still validated that it's using whatever declarations were provided correctly, so there's still value in having the definition file.

So like, with skipLibCheck: true, then firebase-tools wouldn't have an error without #143, but like it would throw an error if I were to add:

import * as portfinder from 'portfinder';

portfinder.setBasePort('foo');

complaining about how setBasePort only accepts numbers, not strings.

@eriktrom
Copy link
Member

@MasterOdin - check this out when u have a chance httptoolkit/httptoolkit-server#51


thanks - yeah - recalling how microsoft pulled this altogether now :)

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