Skip to content

Commit

Permalink
Remove unusable usages from prior TS docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Corbin Crutchley committed Sep 17, 2019
1 parent 1596cf9 commit c59bd6a
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 23 deletions.
20 changes: 1 addition & 19 deletions packages/jimp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,30 +57,12 @@ Jimp.read('lenna.png')

## TypeScript Usage

If you're using this library with TypeScript the method of importing slightly differs from JavaScript. You can import the library with three methods

First of all using [`import = require()`](https://www.typescriptlang.org/docs/handbook/modules.html#export--and-import--require) method to import it as a `commonJS` module:

```ts
import Jimp = require('jimp');
```

Alternatively you can import it with ES6 default import scheme, if you set the `esModuleInterop` compiler flag to `true` in your `tsconfig`
If you're using this library with TypeScript the method of importing slightly differs from JavaScript. Instead of using require, you must import it with ES6 default import scheme

```ts
import Jimp from 'jimp';
```

Lastly you can import it with a synthetic default import. This requires setting the `allowSyntheticDefaultImports` compiler option to `true` in your `tsconfig`

```ts
import * as Jimp from 'jimp';
```

**Note 1**: `esModuleInterop` implicitly sets `allowSyntheticDefaultImports` to `true`

**Note 2**: `allowSyntheticDefaultImports` nor `esModuleInterop` change the runtime behavior of your code at all. They are just flags that tells TypeScript you need the compatibility they offer.

## Module Build

If you're using a web bundles (webpack, rollup, parcel) you can benefit from using the `module` build of jimp. Using the module build will allow your bundler to understand your code better and exclude things you aren't using.
Expand Down
2 changes: 0 additions & 2 deletions packages/jimp/types/ts3.1/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"noEmit": true,

// If the library is an external module (uses `export`), this allows your test file to import "mylib" instead of "./index".
Expand Down
2 changes: 0 additions & 2 deletions packages/jimp/types/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"strictFunctionTypes": true,
"noEmit": true,

Expand Down

0 comments on commit c59bd6a

Please sign in to comment.