From ac4011386a26d0480290e6072fcc32fb5c752124 Mon Sep 17 00:00:00 2001 From: Matt Sutkowski Date: Sun, 17 Jan 2021 13:29:30 -0800 Subject: [PATCH 1/2] Add notes about the min req. node version to README, add TypeScript info --- README.md | 2 ++ docs/typescript.md | 24 +++++++++++++++++++----- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index df134ad4..8c4f57df 100644 --- a/README.md +++ b/README.md @@ -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). + Then build the tutorial and doc pages (after you've installed all dependencies with `yarn install`): yarn build diff --git a/docs/typescript.md b/docs/typescript.md index cf10444a..519dc7c1 100644 --- a/docs/typescript.md +++ b/docs/typescript.md @@ -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. @@ -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": { @@ -25,9 +25,10 @@ Create a `./api/tsconfig.json` file: "paths": { "src/*": ["./src/*"] }, - "typeRoots": ["../.redwood"] + "typeRoots": ["../.redwood"], + "types": [] }, - "include": ["src"], + "include": ["src"] } ``` @@ -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": { @@ -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 `npm i -D @types/jest` in the `web` folder and they will resolve. + If you have any problems please open an issue and let us know. From cee88132a8edffdbef398f28dcecc97fc0c4a6e2 Mon Sep 17 00:00:00 2001 From: Matt Sutkowski Date: Sun, 17 Jan 2021 14:56:14 -0800 Subject: [PATCH 2/2] Prefer yarn instructions, reference nvm-windows --- README.md | 2 +- docs/typescript.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8c4f57df..f556c3ea 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ 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). +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`): diff --git a/docs/typescript.md b/docs/typescript.md index 519dc7c1..fa037ddb 100644 --- a/docs/typescript.md +++ b/docs/typescript.md @@ -70,6 +70,6 @@ If you're adding tests, you'll want to include the types for `jest` in your `tsc +"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 `npm i -D @types/jest` in the `web` folder and they will resolve. +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.