-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat: enable TS strict mode #425
Conversation
@@ -186,8 +188,8 @@ export default function fetchHAR(har: Har, opts: FetchHAROptions = {}) { | |||
|
|||
const form = new FormData(); | |||
|
|||
request.postData.params.forEach(param => { | |||
if ('fileName' in param) { | |||
request.postData.params?.forEach(param => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: might DRY things up a bit to deconstruct params up here
Co-Authored-By: Ilias Tsangaris <[email protected]>
@@ -4,9 +4,12 @@ | |||
"baseUrl": "./src", | |||
"declaration": true, | |||
"esModuleInterop": true, | |||
"lib": ["dom", "es2020"], | |||
"lib": ["DOM", "ES2022"], | |||
"module": "NodeNext", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this mean it outputs ESM?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope, we're doing that in #427! we're still emitting CJS in this PR, but this just gives us support for the exports
object in the package.json
when loading in external packages. you can read more at these links:
https://www.typescriptlang.org/tsconfig/#node16nodenext-nightly-builds
@@ -144,7 +144,7 @@ export default function fetchHAR(har: Har, opts: FetchHAROptions = {}) { | |||
} | |||
|
|||
if ('postData' in request) { | |||
if ('params' in request.postData) { | |||
if (request.postData && 'params' in request.postData) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kinda funky that TS wants you to check request.postData
again here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah 😬 I wonder there's some minor detail about in
that TS knows that we don't know here lol
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ts won't remember existence checks because side effects could change the value. You would want to throw postData into a variable at line 145 and then check that at 146, and use it at 147.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ohhh that's a great callout @Dashron!
Changes
Enables TypeScript's
strict
mode on this codebase. Mostly just adding type-guards and the like! No real code changes as far as we should be concerned.