Skip to content

Commit

Permalink
Move user documentation up to the top of Readme (#3464)
Browse files Browse the repository at this point in the history
  • Loading branch information
schloerke authored Aug 3, 2021
1 parent 9a65890 commit f01dc9f
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions srcts/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
# TypeScript build tools
# Using Shiny TypeScript Definitions

When developing TypeScript projects that use `window.Shiny`, we recommend installing the Shiny TypeScript definitions to your package. To install the latest stable definitions, call

```bash
yarn add https://github.com/rstudio/shiny\#v1.7.0
```

, matching the GitHub tag to your current the Shiny CRAN release (ex: `v1.7.0`). If you are asked to select a version of `@types/jquery`, please select the closest matching version.

This will provide a global type defintion of `Shiny`, let your IDE know that `window.Shiny` is of type `Shiny`, and declare a globally available variable `Shiny` within your project. You **should not** need to import anything. Similar to `jQuery`, it should _Just Work_<sup>TM</sup>.

When loading your compiled file, it should be loaded after `shiny.js` is loaded. If you are using an `htmlDependency()` to add your code to the page, your script will automatically be loaded after has been loaded.


----------------------------------------------------

# TypeScript build tools (Shiny Developers)

All files will be described as if the working directory is the root folder of `rstudio/shiny`, not relative to this `README.md` file.

Expand Down Expand Up @@ -177,21 +194,6 @@ Both JavaScript files will produce a sourcemap (`**.js.map`) that the browser wi

`./extras/globalShiny.ts` contains global declarations to define `window.Shiny`, a globally available `Shiny` variable, and a globally available `Shiny` type. This file is in a parallel folder to `./src` to avoid `Shiny` from being globally accessable within the source code. However, this file is the default type defintion when the Type definitions are installed by external developers.

#### External development

When developing TypeScript projects that leverage Shiny, we recommend installing the Shiny TypeScript definitions to your package. To install the definitions, call

```bash
yarn add https://github.com/rstudio/shiny\#v1.7.0
```

, matching the GitHub tag to your current the Shiny CRAN release (ex: `v1.7.0`). If you are asked to select a version of `@types/jquery`, please select the closest version.

This will provide a global type defintion of `Shiny`, let your IDE know that `window.Shiny` is of type `Shiny`, and declare a globally available variable `Shiny` within your project. You **should not** need to import anything. Similar to `jQuery`, it should _Just Work_<sup>TM</sup>.

When loading your compiled file, it should be loaded after Shiny is loaded. If you are using an `htmlDependency()` to add your code to the page, your script will automatically be loaded after has been loaded.


### GitHub Actions

On push to the `master` branch or push to a Pull Request to the `master` branch, a GitHub Action will be run to make sure the bundled JavaScript code is up to date. If the source code does not compile to the exact same file, it will be committed an pushed back to the outdated branch. (This makes it so the full build tools are not necessary for small tweaks and comments. 🎉)
Expand Down

0 comments on commit f01dc9f

Please sign in to comment.