Closed marekdedic closed 1 week ago
This isn't on us to implement. We are fine with undefined
as a value for optional properties.
You should be using skipLibCheck
on your own project, as you shouldn't be applying a compiler config our code isn't written for.
Hi, thanks for the quick response. Let me push back on it somewhat :)
You should be using skipLibCheck on your own project, as you shouldn't be applying a compiler config our code isn't written for.
Your code is part of the source for my project, AFAIK, skipLibCheck
is an escape hatch for incorrect and/or incompatible typings. I could very well use this escape hatch, but I'm trying to fix the typings instead :)
This isn't on us to implement. We are fine with undefined as a value for optional properties.
I think there is a misunderstanding between us. I don't want you to make the properties required, I would like to see the typings reformulated in such a way that they allow undefined
explicitly. I tried looking into what this would take and it turns out the whole thing would consist of just modifying the following type to add | undefined
to some of its properties:
type AgnosticBaseRouteObject = {
caseSensitive?: boolean | undefined;
path?: string | undefined;
id?: string | undefined;
loader?: LoaderFunction | boolean | undefined;
action?: ActionFunction | boolean | undefined;
hasErrorBoundary?: boolean | undefined;
shouldRevalidate?: ShouldRevalidateFunction | undefined;
handle?: any;
lazy?: LazyRouteFunction<AgnosticBaseRouteObject>;
};
Happy to send in a PR if you agree.
You should be importing our built type definition from npm, not including the full source in your project. That's not something we support. We have validated those according to our own compiler config, so you don't have to validate them again. That is the main purpose of skipLibCheck
, so you're not trying to validate types against an incompatible config.
And we would prefer not to have to be explicit about undefined
. We are fine with the default behavior without exactOptionalPropertyTypes
enabled.
You should be importing our built type definition from npm, not including the full source in your project.
I am using the NPM package and the issue is present nonetheless.
We have validated those according to our own compiler config, so you don't have to validate them again. That is the main purpose of
skipLibCheck
, so you're not trying to validate types against an incompatible config.
The way I understand it and read it in the available resources, compiled lib type definitions are to be considered as part of the compilation. skipLibCheck
exists s a hack around incorrect upstream type definitions.
And we would prefer not to have to be explicit about
undefined
. We are fine with the default behavior withoutexactOptionalPropertyTypes
enabled.
Unfortunately, this means you are forcing all your downstream users to either forgo more precise optional property typing (which I get not everybody wants, but this way it's not possible for me), or to have to have the compatibility with libraries disabled.
What version of React Router are you using?
6.26.2
Steps to Reproduce
exactOptionalPropertyTypes
in your tsconfigExpected Behavior
No errors
Actual Behavior