Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

Docs: TypeScript docs updates #524

Merged
merged 2 commits into from
Jan 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Other documentation is pulled from various READMEs in the main [redwoodjs/redwoo

This codebase is built with https://cameronjs.com and relies on plain HTML pages and Javascript with a couple helpers built in to abstract things like partials and layouts. We use https://stimulusjs.org for the few sprinkles of interactivity throughout the site.

First, make sure that you are running Node 14+. If you're not sure of how to manage your node versions, see [nvm](https://github.com/nvm-sh/nvm) or [nvm-windows](https://github.com/coreybutler/nvm-windows).

Then build the tutorial and doc pages (after you've installed all dependencies with `yarn install`):

yarn build
Expand Down
24 changes: 19 additions & 5 deletions docs/typescript.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Typescript


> TypeScript support is in development: The ability to use TypeScript is one of our main points of focus, check out our [TypeScript Project Board](https://github.com/redwoodjs/redwood/projects/2) to follow the progress.

Redwood does not use the TypeScript compiler; instead, we use babel, which strips out the types before transpiling them.
Expand All @@ -12,6 +11,7 @@ Redwood does not use the TypeScript compiler; instead, we use babel, which strip
### API

Create a `./api/tsconfig.json` file:

```json
{
"compilerOptions": {
Expand All @@ -25,9 +25,10 @@ Create a `./api/tsconfig.json` file:
"paths": {
"src/*": ["./src/*"]
},
"typeRoots": ["../.redwood"]
"typeRoots": ["../.redwood"],
"types": []
},
"include": ["src"],
"include": ["src"]
}
```

Expand All @@ -36,6 +37,7 @@ You should now have type definitions, you can rename your files from `.js` to `.
### WEB

Create a `./web/tsconfig.json` file:

```json
{
"compilerOptions": {
Expand All @@ -50,12 +52,24 @@ Create a `./web/tsconfig.json` file:
"paths": {
"src/*": ["./src/*"]
},
"typeRoots": ["../.redwood"]
"typeRoots": ["../.redwood"],
"types": []
},
"include": ["src"],
"include": ["src"]
}
```

You should now have type definitions, you can rename your files from `.js` to `.ts`, and the files that contain JSX to `.tsx`.

#### Getting types for `jest` in test files

If you're adding tests, you'll want to include the types for `jest` in your `tsconfig`.

```diff
-"types": []
+"types": ["jest"]
```

Currently, these are added to `node_modules` by `@redwoodjs/core` and the above approach should just work. If this is not the case, you can `yarn add -D @types/jest` in the `web` folder and they will resolve.

If you have any problems please open an issue and let us know.