You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: ADVANCED.md
+17-3Lines changed: 17 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -880,15 +880,29 @@ An example github repository with a project showing how to integrate [eslint + t
880
880
881
881
## Working with Non-TypeScript Libraries (writing your own index.d.ts)
882
882
883
-
_Not written yet._
883
+
Lets say you want to use `de-indent`, but it isn't typed or on DefinitelyTyped. You get an error like this:
884
884
885
-
Please contribute on this topic! [We have an ongoing issue here with some references](https://github.com/sw-yx/react-typescript-cheatsheet/issues/8).
885
+
```
886
+
[ts]
887
+
Could not find a declaration file for module 'de-indent'. '/Users/swyx/Work/react-sfc-loader/node_modules/de-indent/index.js' implicitly has an 'any' type.
888
+
Try `npm install @types/de-indent` if it exists or add a new declaration (.d.ts) file containing `declare module 'de-indent';` [7016]
889
+
```
890
+
891
+
So create a `.d.ts` file anywhere in your project with the module definition:
892
+
893
+
```ts
894
+
// de-indent.d.ts
895
+
declare module 'de-indent' {
896
+
function deindent():void
897
+
export = deindent // default export
898
+
}
899
+
```
886
900
887
901
<details>
888
902
889
903
<summary>Further Discussion</summary>
890
904
891
-
We have more discussion and examples [in our issue here](https://github.com/sw-yx/react-typescript-cheatsheet/issues/12).
905
+
Any other tips? Please contribute on this topic! [We have an ongoing issue here with some references](https://github.com/sw-yx/react-typescript-cheatsheet/issues/8). We have more discussion and examples [in our issue here](https://github.com/sw-yx/react-typescript-cheatsheet/issues/12).
0 commit comments