emit-decorator-circular-loader
v1.0.1
Published
Add support circular import on typescript emit decorator metadata
Downloads
4
Maintainers
Readme
Emit Decorator Circular reflect-metadata
Add support circular import on typescript emit decorator metadata
Install
npm install -s emit-decorator-circular-reflect-metadata
npm install -D emit-decorator-circular-loader
tsconfig.json
{
// [...]
"compilerOptions": {
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"types": [
"reflect-metadata"
// [...]
],
// [...]
}
// [...]
}
Webpack
module.exports = {
// [...]
module: {
rules: [
// [...]
{
test: /\.tsx?$/,
use: [
// [...]
{
loader: 'emit-decorator-circular-loader'
},
{
loader: 'ts-loader',
// [...]
}
// [...]
],
}
// [...]
]
}
// [...]
}
Use
Replace classic import:
import 'reflect-metadata';
By:
import 'emit-decorator-circular-reflect-metadata';
Example
This example not works if classic typescript whithout loader
file Book.ts
import {Author} from './Author';
@DecoratorClass()
export class Book {
@DecoratorField()
public author: Author;
}
file Author.ts
import {Book} from './Book';
@DecoratorClass()
export class Author {
@DecoratorField()
public author: Book;
}