-
Notifications
You must be signed in to change notification settings - Fork 61
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
fix(types)!: fix @netlify/headers-parser
types
#6104
fix(types)!: fix @netlify/headers-parser
types
#6104
Conversation
@@ -1,7 +1,8 @@ | |||
{ | |||
"extends": "../../tsconfig.base.json", | |||
"compilerOptions": { | |||
"outDir": "lib" /* Specify an output folder for all emitted files. */ | |||
"outDir": "lib" /* Specify an output folder for all emitted files. */, | |||
"strictBindCallApply": false /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ |
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.
moved this down to this specific package so I could enable it in the base config
@@ -1,7 +1,8 @@ | |||
{ | |||
"extends": "../../tsconfig.base.json", | |||
"compilerOptions": { | |||
"outDir": "lib" /* Specify an output folder for all emitted files. */ | |||
"outDir": "lib" /* Specify an output folder for all emitted files. */, | |||
"strictBindCallApply": false /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ |
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.
moved this down to this specific package so I could enable it in the base config
@@ -1,7 +1,8 @@ | |||
{ | |||
"extends": "../../tsconfig.base.json", | |||
"compilerOptions": { | |||
"outDir": "lib" /* Specify an output folder for all emitted files. */ | |||
"outDir": "lib" /* Specify an output folder for all emitted files. */, | |||
"strictBindCallApply": false /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ |
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.
moved this down to this specific package so I could enable it in the base config
@@ -2,6 +2,8 @@ import { promises as fs } from 'fs' | |||
import { basename, extname, dirname, join } from 'path' | |||
|
|||
import isPathInside from 'is-path-inside' | |||
// @ts-expect-error(serhalp) -- Remove once https://github.com/schnittstabil/merge-options/pull/28 is merged, or replace |
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.
This seemed worthwhile, as it allowed enabling noImplicitAny
in zisi
"strict": true | ||
"noImplicitAny": true, | ||
"strictFunctionTypes": true, | ||
"strictPropertyInitialization": true, | ||
"useUnknownInCatchVariables": false, | ||
"exactOptionalPropertyTypes": false, | ||
"noImplicitReturns": false, | ||
"noUncheckedIndexedAccess": false, | ||
"noImplicitOverride": true, | ||
"noPropertyAccessFromIndexSignature": false |
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.
The intent here was presumably to opt into strict mode, but the tsconfig files get merged on a field-by-field basis... so "strict": true
here wasn't really doing anything, as the specific flags were all still disabled from the base config.
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.
I reenabled what I could but had to leave a few disabled 😞
This requires the fixes in netlify/build#6104.
These types were very weak, containing plentiful `any`s, both explicit and implicit, as well as some incorrect inferred types.
We should be opting *into* strict mode and only opting *out* of some flags incrementally while we fix errors. This commit: - flips the global `strict` on - removes values being set to the default via the above - stops disabling flags that obscured no errors (or very few, which I then fixed) - moves a few flag disablings to the specific packages that require it - explictly configures strict flags for already rather strict packages
f53fa6b
to
1fa08ca
Compare
This requires the fixes in netlify/build#6104.
This requires the fixes in netlify/build#6104.
This pull request adds or modifies JavaScript ( |
@netlify/headers-parser
types
All callers already pass in a non-nil `boolean`, so this is only technically breaking.
41e53b7
to
e339cc6
Compare
This pull request adds or modifies JavaScript ( |
...input | ||
minimal, | ||
}: { | ||
headersFiles?: undefined | string[] | ||
netlifyConfigPath?: undefined | string | ||
configHeaders?: undefined | MinimalHeader[] | ||
minimal?: undefined | boolean | ||
headersFiles: undefined | string[] | ||
netlifyConfigPath: undefined | string | ||
configHeaders: undefined | MinimalHeader[] | ||
minimal: boolean | ||
}) { | ||
return await parseAllHeaders({ | ||
...(headersFiles && { headersFiles: headersFiles.map(addFileFixtureDir) }), | ||
...(netlifyConfigPath && { netlifyConfigPath: addConfigFixtureDir(netlifyConfigPath) }), | ||
configHeaders, | ||
// Default `minimal` to `true` but still allows passing `undefined` to | ||
// test the default value of that option | ||
minimal: 'minimal' in input ? input.minimal : true, | ||
minimal, |
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.
This change is the reason why all the test files had to change. And this change is because of the change to parseAllHeaders
.
(Yes, parseHeaders
calls parseAllHeaders
and not the other way around 🙃)
This pull request adds or modifies JavaScript ( |
This requires the fixes in netlify/build#6104.
Summary
Fix poor/incorrect types
These types were very weak, containing plentiful
any
s, both explicit and implicit, as well as some incorrect inferred types. This overhauls those types and fixes uncovered errors.(This is needed to fix type errors in the CLI.)
fix(@netlify/headers-parser)!: mark
parseAllHeaders
optionminimal
as requiredAll callers already pass in a non-nil
boolean
, so this is only technically breaking.fix(@netlify/config)!: mark
NetlifyTOML.headers[].values
as requiredThis was just a mistake, but it is technically a breaking change.
Simplify/fix tsconfig strict config
We should be opting into strict mode and only opting out of some flags incrementally while we fix errors. The current setup makes this difficult.
This PR:
strict
flag onThere's a lot more work to do here, but this is a start...