refactor: clean Canny integration + rename 'Feedback' to 'Feature Requests' + improve TS doc page (#5389)

* Better Canny integration

* Add missing netlify redirects

* polish

* TS doc: mention it's possible to use JSDoc in config

* issue templates: use /feature-requests new url
This commit is contained in:
Sébastien Lorber 2021-08-20 11:42:13 +02:00 committed by GitHub
parent 974644d16b
commit f40ce05102
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 95 additions and 66 deletions

View file

@ -183,4 +183,4 @@ In comparison with statically generated HTML and interactivity added using `<scr
If you find issues with the documentation or have suggestions on how to improve the documentation or the project in general, please [file an issue](https://github.com/facebook/docusaurus) for us, or send a tweet mentioning the [@docusaurus](https://twitter.com/docusaurus) Twitter account.
For new feature requests, you can create a post on our [Canny board](/feedback), which is a handy tool for roadmapping and allows for sorting by upvotes, which gives the core team a better indicator of what features are in high demand, as compared to GitHub issues which are harder to triage. Refrain from making a Pull Request for new features (especially large ones) as someone might already be working on it or will be part of our roadmap. Talk to us first!
For new feature requests, you can create a post on our [feature requests board (Canny)](/feature-requests), which is a handy tool for roadmapping and allows for sorting by upvotes, which gives the core team a better indicator of what features are in high demand, as compared to GitHub issues which are harder to triage. Refrain from making a Pull Request for new features (especially large ones) as someone might already be working on it or will be part of our roadmap. Talk to us first!

View file

@ -3,6 +3,8 @@ id: typescript-support
title: TypeScript Support
---
Docusaurus is written in TypeScript, and provide first-class TypeScript support.
## Initialization {#initialization}
Docusaurus supports writing and using TypeScript theme components. If the init template provides a Typescript variant, you can directly initialize a site with full TypeScript support by using the `--typescript` flag.
@ -34,6 +36,44 @@ Docusaurus doesn't use this `tsconfig.json` to compile your project. It is added
Now you can start writing TypeScript theme components.
## Typing the config file {#typing-config}
It is **not possible** to use a TypeScript config file in Docusaurus, unless you compile it yourself to JavaScript.
We recommend using [JSDoc type annotations](https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html):
```js title="docusaurus.config.js
// highlight-start
/** @type {import('@docusaurus/types').Plugin} */
// highlight-end
function MyPlugin(context, options) {
return {
name: 'my-plugin',
};
}
// highlight-start
/** @type {import('@docusaurus/types').DocusaurusConfig} */
// highlight-end
const config = {
title: 'Docusaurus',
tagline: 'Build optimized websites quickly, focus on your content',
organizationName: 'facebook',
projectName: 'docusaurus',
plugins: [MyPlugin],
};
module.exports = config;
```
:::tip
Type annotations are very useful and help your IDE understand the type of config objects!
The best IDEs (VSCode, WebStorm, Intellij...) will provide a nice auto-completion experience.
:::
## Swizzling TypeScript theme components {#swizzling-typescript-theme-components}
For themes that supports TypeScript theme components, you can add the `--typescript` flag to the end of swizzling command to get TypeScript source code. For example, the following command will generate `index.tsx` and `styles.module.css` into `src/theme/Footer`.