Repository navigation
fix(types)!: fix @netlify/headers-parser types - #6104
Conversation
| "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.
moved this down to this specific package so I could enable it in the base config
| "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.
moved this down to this specific package so I could enable it in the base config
| "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.
moved this down to this specific package so I could enable it in the base config
| 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.
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.
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.
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.
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
anys, 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
parseAllHeadersoptionminimalas requiredAll callers already pass in a non-nil
boolean, so this is only technically breaking.fix(@netlify/config)!: mark
NetlifyTOML.headers[].valuesas 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:
strictflag onThere's a lot more work to do here, but this is a start...