-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
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 "@satisfies" JSDoc tag to every "@type" JSDoc tag throughout the repository #8639
Comments
By "not strict", do you mean we mark things as optional? Or do you mean you can add properties that do not match the declared type? |
I mean that end-users can add properties that do not match any of the valid declared types. |
e.g. When working in a Docusaurus config, I expect that most people will expect an error like this: |
Do you have a repro? When you hover over the |
When I hit F12 on the export type ThemeConfig = {
algolia: {
contextualSearch: boolean;
externalUrlRegex?: string;
appId: string;
apiKey: string;
indexName: string;
searchParameters: {[key: string]: unknown};
searchPagePath: string | false | null;
replaceSearchResultPathname?: {
from: string;
to: string;
};
};
}; The corresponds to this file, which I already included in the OP: https://github.com/facebook/docusaurus/blob/main/packages/docusaurus-theme-search-algolia/src/theme-search-algolia.d.ts#L11
Does the bug not happen for you? If you want, you can clone my repository and see for yourself: https://github.com/IsaacScript/isaacscript |
This is working as intended. We are using /** @typedef {{
value1: number;
value2: number;
}} Foo */
const foo = {
prop: /** @type {Foo} */ ({
value1: 2,
value2: 1,
value3: 3,
})
}; This will be fixed in TS 5.0 by using the |
Ah, I see. Well then maybe we can turn this into an issue for tracking the adding of the Another good option is to have the config file be generated in TypeScript from the get-go, at least when the --typescript flag is used to bootstrap the website. I see that that is being tracked in #7911, so I'll eagerly await either (or both) of these upgrades. |
Yes, we'll probably close this by changing to Well actually, even if you use TS, you can't type an object embedded within another object without using const foo: Foo = {...}; Is to also use /** @typedef {{
value1: number;
value2: number;
}} Foo */
/** @type {Foo} */
const foo = {
value1: 2,
value2: 1,
value3: 3,
}; And this works. So there's nothing unique about JSDoc either, it's just neither of us know JSDoc much :) |
We now have TS configs so if you want strict type validations you should use that. Closing this as resolved! |
[edit - Original issue was about specifying bogus fields in my "docusaurus.config.js" file and it not throwing any errors.]
Description
This is nice, because it allows for auto-complete and in-editor validation when adding entries to your configuration file.
However, this interface is not strict insofar that you can add bogus entries to the Algolia config without getting an error from the TypeScript compiler. This is a mistake, as we surely want to alert users with a red squiggly line in their editor (e.g. VSCode) the moment that they make a typo here (or insert a non-valid entry).
Motivation
I wasted months troubleshooting issues with Algolia due to Docusaurus essentially lying to me about what were valid configuration entries: algolia/docsearch#1658 (comment)
The text was updated successfully, but these errors were encountered: