Skip to content

Commit

Permalink
[docs] expand typescript mentions in plugin docs
Browse files Browse the repository at this point in the history
  • Loading branch information
spalger committed May 16, 2018
1 parent a721f19 commit 61475ab
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
22 changes: 21 additions & 1 deletion docs/development/plugin/development-plugin-resources.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,24 @@ The Kibana directory must be named `kibana`, and your plugin directory must be l
If you're developing a plugin that has a user interface, take a look at our https://elastic.github.io/eui[Elastic UI Framework].
It documents the CSS and React components we use to build Kibana's user interface.

You're welcome to use these components, but be aware that they are rapidly evolving and we might introduce breaking changes that will disrupt your plugin's UI.
You're welcome to use these components, but be aware that they are rapidly evolving and we might introduce breaking changes that will disrupt your plugin's UI.

[float]
==== TypeScript Support
Plugin code can be written in http://www.typescriptlang.org/[TypeScript] if desired. To enable TypeScript support create a `tsconfig.json` file at the root of your plugin that looks something like this:

["source","js"]
-----------
{
// extend Kibana's tsconfig, or use your own settings
"extends": "../../kibana/tsconfig.json",
// tell the TypeScript compiler where to find your source files
"include": [
"server/**/*",
"public/**/*"
]
}
-----------

TypeScript code is automatically converted into JavaScript during development, but not in the distributable version of Kibana. If you use the {repo}blob/{branch}/packages/kbn-plugin-helpers[@kbn/plugin-helpers] to build your plugin then your `.ts` and `.tsx` files will be permanently transpiled before your plugin is archived. If you have your own build process, make sure to run the TypeScript compiler on your source files and ship the compilation output so that your plugin will work with the distributable version of Kibana.
17 changes: 16 additions & 1 deletion packages/kbn-plugin-helpers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,19 @@ Setting | Description

## TypeScript support

Plugin code that runs in the browser can be written in [TypeScript](http://www.typescriptlang.org/) if desired. During development the Kibana Optimizer will transform your TypeScript into JavaScript automatically, but that does not happen in production mode. Instead, when building plugins with the plugin-helpers, the `tsconfig.json` file at the root of the plugin is temporarily copied into the build and the local `tsc` executable is used to transpile `.ts` and `.tsx` files into `.js` files that will ultimately be included in the built version of the plugin. All `.ts`, `.tsx`, and `.d.ts` files will be removed along with the `tsconfig.json` file before archiving the built version of your plugin.
Plugin code can be written in [TypeScript](http://www.typescriptlang.org/) if desired. To enable TypeScript support create a `tsconfig.json` file at the root of your plugin that looks something like this:

```js
{
// extend Kibana's tsconfig, or use your own settings
"extends": "../../kibana/tsconfig.json",

// tell the TypeScript compiler where to find your source files
"include": [
"server/**/*",
"public/**/*"
]
}
```

> NOTE: If you define a custom `buildSourcePatterns`, make sure to include your `tsconfig.json` file so that the build task will transpile your `.ts` files into `.js` files before archiving your plugin.

0 comments on commit 61475ab

Please sign in to comment.