Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@hqjs/babel-plugin-add-type-metadata

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hqjs/babel-plugin-add-type-metadata - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

42

index.js

@@ -1,2 +0,2 @@

module.exports = function({ types: t }) {
module.exports = function ({ types: t }) {
return {

@@ -14,24 +14,22 @@ visitor: {

null);
const typeMetadata = t.assignmentExpression(
'=',
t.memberExpression(
t.identifier(cls.node.id.name),
t.identifier('ctorParameters')
),
t.functionExpression(
null,
[],
t.blockStatement([
t.returnStatement(t.arrayExpression(types.map(type => type ?
t.objectExpression([
t.objectProperty(
t.stringLiteral('type'),
t.identifier(type)
),
]) :
t.nullLiteral()))),
])
)
const ctorParameters = t.classMethod(
'method',
t.stringLiteral('ctorParameters'),
[],
t.blockStatement([
t.returnStatement(t.arrayExpression(types.map(type => type ?
t.objectExpression([
t.objectProperty(
t.stringLiteral('type'),
t.identifier(type)
),
]) :
t.nullLiteral()))),
]),
false,
true
);
nodePath.insertAfter(t.expressionStatement(typeMetadata));
nodePath.get('body').unshiftContainer('body', ctorParameters);
}

@@ -38,0 +36,0 @@ },

{
"name": "@hqjs/babel-plugin-add-type-metadata",
"version": "0.0.1",
"version": "0.0.2",
"description": "Add plugin metadata",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -9,1 +9,41 @@ # babel-plugin-add-type-metadata

# Transformation
Plugin adds type metadata to classes to help Angular e.g.
```ts
...
import { MessageService } from './message.service';
@Injectable({
providedIn: 'root',
})
export class HeroService {
constructor(private messageService: MessageService) { }
...
}
```
will turn into
```ts
...
import { MessageService } from './message.service';
@Injectable({
providedIn: 'root',
})
export class HeroService {
static "ctorParameters"() {
return [{
"type": HeroService
}];
}
constructor(private messageService: MessageService) { }
...
}
```
that works nice with decorator plugin.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc