-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
[v2] Usage with TypeScript #3424
Comments
Hey, We are still figuring out how to provide the best TypeScript experience in Docusaurus, by trying to use it first on Docusaurus 2 site itself. @SamChou19815 has done some initial work, and you could probably get started by using a
We don't have much TS code in our website yet, but hopefully we'll migrate over time and be able to recommend a good TS setup to our users. |
I like how CRA works. Including a TypeScript template in the |
Adding the The @docusaurus/module-type-aliases is outdated on npm (2.0.0-alpha.51). It doesn't declare those modules. It has since been updated but not published to npm. Can someone publish? |
I see, if you install it at the correct version it works. |
Initializing a TS site is definitively something we want, and contributions are welcome (but this does not seem like an easy one as it requires more general better TS support) But what we want more is i18n support and get out of alpha asap ;) About packages, that's unfortunate that an alpha has been published as "current", you should install package with @next anyway, but hopefully this will be solved automatically when we move out of alpha ;) |
this problem still appears to exist. Probably because the classic template doesn't have a tsconfig or anything. However, the tutorial that tells you that you can just use a tsx file if you want -uses the classic template and makes no mention of tsconfig |
This problem still exists for
These errors don't appear with I looked through the file Edit: Added |
still actual! |
Still having problems with this. |
@raphzandrade Consider upgrading your Also, I just recently added a |
@Josh-Cena I am using the version you said and added the |
"It doesn't work" is not very actionable for maintainers. |
@slorber Will try to mock up a env close to the one I am experiencing the problem. Since we are inside a monorepo solution, using nx, I am exhausting the possibility of being a problem on our side first. |
@tiffanynguyen0211 This is because ESLint doesn't understand module definitions. These aren't actual paths, but Webpack aliases which ESLint doesn't know about. We solve this ourselves by disabling it on certain circumstances: 'import/no-unresolved': [
ERROR,
{ignore: ['^@theme', '^@docusaurus', '^@generated', 'unist', 'mdast']},
], |
@Josh-Cena thank you |
Closing because we are now fully prioritizing TS and the website itself is using TypeScript. Please report any specific regressions / bugs in separate issues. |
This is not working for me: Do you know what I'm missing? |
@matthewmuscat looks like your eslint rule config is not applied (ie the ignore does not take effect). We can't tell why but we just see it's not applied. Maybe you have another rule or config that conflicts with this one? |
@matthewmuscat |
For the
definitions.d.ts:
And Typescript does not complain anymore. However, I would appreciate this to not complain out of the box with docusaurus+typescript+docusaurus-plugin-sass |
Docusaurus does not use sass internally and is modular, and we probably don't want to have any ref to sass in core. We do have this: declare module '*.module.css' {
const classes: {readonly [key: string]: string};
export default classes;
}
declare module '*.css' {
const src: string;
export default src;
} It is the responsibility of the sass plugin to provide the appropriate declarations and/or install instructions |
🐛 Bug Report
Regression of #2675
To Reproduce
Follow steps https://v2.docusaurus.io/docs/typescript-support#setup.
Rename
src/pages/index.js
tosrc/pages/index.tsx
.VSCode displays the following errors:
Your Environment
The text was updated successfully, but these errors were encountered: