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

Commit

Permalink
Merge pull request #524 from msutkowski/docs/ts-clarification
Browse files Browse the repository at this point in the history
Docs: TypeScript docs updates
  • Loading branch information
peterp authored Jan 24, 2021
2 parents a48e63e + cee8813 commit f78c047
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
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.

0 comments on commit f78c047

Please sign in to comment.