Skip to content

Commit 5757724

Browse files
authored
add troubleshooting for importing images
1 parent 2a1b745 commit 5757724

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -966,6 +966,20 @@ function foo(bar: string) {
966966
// inside your app, if you need { baz: number }
967967
type FooReturn = ReturnType<typeof foo>; // { baz: number }
968968
```
969+
# Troubleshooting Handbook: Images and other non-TS/TSX files
970+
971+
Use [declaration merging](https://www.typescriptlang.org/docs/handbook/declaration-merging.html):
972+
973+
```ts
974+
// declaration.d.ts
975+
// anywhere in your project, NOT the same name as any of your .ts/tsx files
976+
declare module '*.png'
977+
978+
// importing in a tsx file
979+
import * as logo from "./logo.png";
980+
```
981+
982+
Related issue: https://github.com/Microsoft/TypeScript-React-Starter/issues/12 and [StackOverflow](https://stackoverflow.com/a/49715468/4216035)
969983

970984
# Troubleshooting Handbook: TSLint
971985

0 commit comments

Comments
 (0)