Skip to content

Commit

Permalink
chore: Update dependencies. Fixed up readme (microsoft#11)
Browse files Browse the repository at this point in the history
* Update dependencies

* chore: Specify node version

* docs: Rename codeblock syntax for npm

* docs: Add yarn to docs

* chore: Migrate to new husky config

* fix: Set CORRECT node version
  • Loading branch information
Xapphire13 authored Nov 27, 2018
1 parent f59282d commit 683306f
Show file tree
Hide file tree
Showing 5 changed files with 295 additions and 408 deletions.
5 changes: 5 additions & 0 deletions .huskyrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"hooks": {
"pre-push": "npm test"
}
}
29 changes: 17 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@ constructor injection.
* [Contributing](#contributing)

## Installation

Install by `npm`
```sh
npm install --save tsyringe
```

**or** install with `yarn` (this project is developed using `yarn`)
```sh
yarn install --save tsyringe
```

Modify your `tsconfig.json` to include the following settings
```json
{
Expand All @@ -38,7 +43,7 @@ Class decorator factory that allows the class' dependencies to be injected at
runtime.

#### Usage
```TypeScript
```typescript
import {decorators} from "tsyringe";
const {injectable} = decorators;

Expand All @@ -59,7 +64,7 @@ Class decorator factory that registers the class as a singleton within the
global container.

#### Usage
```TypeScript
```typescript
import {decorators} from "tsyringe";
const {singleton} = decorators;

Expand All @@ -82,7 +87,7 @@ a parameterless constructor that has dependencies auto-resolved.
**Note** Resolution is performed using the global container

#### Usage
```TypeScript
```typescript
import {decorators} from "tsyringe";
const {autoInjectable} = decorators;

Expand All @@ -105,7 +110,7 @@ Parameter decorator factory that allows for interface and other non-class
information to be stored in the constructor's metadata

#### Usage
```TypeScript
```typescript
import {decorators} from "tsyringe";
const {injectable, inject} = decorators;

Expand All @@ -124,11 +129,11 @@ class Foo {
Since classes have type information at runtime, we can resolve them without any
extra information.

```TypeScript
```typescript
// Foo.ts
export class Foo {}
```
```TypeScript
```typescript
// Bar.ts
import {Foo} from "./Foo";
import {decorators} from "tsyringe";
Expand All @@ -139,7 +144,7 @@ export class Bar {
constructor(public myFoo: Foo) {}
}
```
```TypeScript
```typescript
// main.ts
import {container} from "tsyringe";
import {Bar} from "./Bar";
Expand All @@ -152,20 +157,20 @@ const myBar = container.resolve(Bar);
Interfaces don't have type information at runtime, so we need to decorate them
with `@inject(...)` so the container knows how to resolve them.

```TypeScript
```typescript
// SuperService.ts
export interface SuperService {
// ...
}
```
```TypeScript
```typescript
// TestService.ts
import {SuperService} from "./SuperService";
export class TestService implements SuperService {
//...
}
```
```TypeScript
```typescript
// Client.ts
import {decorators} from "tsyringe";
const {injectable, inject} = decorators;
Expand All @@ -175,7 +180,7 @@ export class Client {
constructor(@inject("SuperService") private service: SuperService) {}
}
```
```TypeScript
```typescript
// main.ts
import {Client} from "./Client";
import {TestService} from "./TestService";
Expand Down
3 changes: 1 addition & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ module.exports = {
],
globals: {
"ts-jest": {
tsConfigFile: "tests/tsconfig.json",
skipBabel: true
tsConfig: "tests/tsconfig.json"
}
},
moduleFileExtensions: [
Expand Down
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
"build": "rimraf ./dist ./types && tsc -p ./src",
"test": "npm run lint && jest",
"test:coverage": "jest --coverage",
"lint": "tslint -p src && tslint -p tests",
"prepush": "npm test"
"lint": "tslint -p src && tslint -p tests"
},
"repository": {
"type": "git",
Expand All @@ -22,6 +21,9 @@
"ioc",
"container"
],
"engines": {
"node": ">= 6.0.0"
},
"types": "types/index.d.ts",
"author": "Steven Hobson-Campbell",
"license": "MIT",
Expand All @@ -35,12 +37,12 @@
"devDependencies": {
"@types/jest": "^23.3.9",
"@types/node": "^8.10.16",
"husky": "^0.14.3",
"husky": "^1.2.0",
"jest": "^23.6.0",
"rimraf": "^2.6.2",
"ts-jest": "^22.4.6",
"ts-jest": "^23.10.5",
"tslint": "^5.10.0",
"tslint-eslint-rules": "^5.3.1",
"typescript": "^2.8.3"
"typescript": "^3.1.6"
}
}
Loading

0 comments on commit 683306f

Please sign in to comment.