From 6ecacef56e15e7846adc374753c8fd1debf51f78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Se=CC=81bastien?= Date: Mon, 26 Nov 2018 08:45:00 +0100 Subject: [PATCH 1/3] docs(Typescript): Update doc to put eui typings in global typings file --- TYPESCRIPT.md | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/TYPESCRIPT.md b/TYPESCRIPT.md index ebcac32d59409..5c0430582f7db 100644 --- a/TYPESCRIPT.md +++ b/TYPESCRIPT.md @@ -14,12 +14,20 @@ The first thing that will probably happen when you convert a `.js` file in our s #### EUI component is missing types 1. Check https://github.com/elastic/eui/issues/256 to see if they know it’s missing, if it’s not on there, add it. -2. Temporarily get around the issue by using a declared module and exporting the missing types with the most basic types available. Bonus points if you write a PR yourself to the EUI repo to add the types, but having them available back in Kibana will take some time, as a new EUI release will need to be generated, then that new release pointed to in Kibana. Best, to make forward progress, to do a temporary workaround. +2. Temporarily get around the issue by adding the missing type in the `typings/@elastic/eui/index.d.ts` file. Bonus points if you write a PR yourself to the EUI repo to add the types, but having them available back in Kibana will take some time, as a new EUI release will need to be generated, then that new release pointed to in Kibana. Best, to make forward progress, to do a temporary workaround. ```ts +// typings/@elastic/eui/index.d.ts + declare module '@elastic/eui' { + // Add your types here export const EuiPopoverTitle: React.SFC; + ... } +``` + +```ts +// you can now import it in import { EuiPopoverTitle } from '@elastic/eui'; ``` @@ -36,7 +44,8 @@ A `.d.ts` file is treated as a module if it contains any top-level `import` or ` Since `@elastic/eui` already ships with a module declaration, any local additions must be performed using module augmentation, e.g. ```typescript -// file `my_plugin/types/eui.d.ts` +// file `typings/@elastic/eui/index.d.ts` + import { CommonProps } from '@elastic/eui'; import { SFC } from 'react'; From 9db68b783bad411c63e8f31d932afa420c19001a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20St=C3=BCrmer?= Date: Tue, 27 Nov 2018 11:55:44 +0100 Subject: [PATCH 2/3] Update TYPESCRIPT.md Co-Authored-By: sebelga --- TYPESCRIPT.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TYPESCRIPT.md b/TYPESCRIPT.md index 5c0430582f7db..96cfb4fa8ec11 100644 --- a/TYPESCRIPT.md +++ b/TYPESCRIPT.md @@ -21,7 +21,7 @@ The first thing that will probably happen when you convert a `.js` file in our s declare module '@elastic/eui' { // Add your types here - export const EuiPopoverTitle: React.SFC; + export const EuiPopoverTitle: React.SFC; ... } ``` From 3c162d4013efb811776517462733d98c35eda312 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Se=CC=81bastien?= Date: Wed, 28 Nov 2018 08:50:27 +0100 Subject: [PATCH 3/3] Update Typescript.md --- TYPESCRIPT.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TYPESCRIPT.md b/TYPESCRIPT.md index 96cfb4fa8ec11..68cb32ce36c74 100644 --- a/TYPESCRIPT.md +++ b/TYPESCRIPT.md @@ -21,7 +21,7 @@ The first thing that will probably happen when you convert a `.js` file in our s declare module '@elastic/eui' { // Add your types here - export const EuiPopoverTitle: React.SFC; + export const EuiPopoverTitle: React.SFC; ... } ```