Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@polymer-vis/decorator-transformer
Advanced tools
A typescript transformer to replace "@property" and "@custom-element" decorators with vanilla javascript for Polymer and LitElement webcomponents.
@polymer-vis/decorator-transformer
Replace PolymerElement
or LitElement
decorators (@customElement
, @property
) in your typescript codes.
Before
@customElement("x-foo")
class XFoo extends HTMLElement {
static get properties() {
return {};
}
/** some comment */
@property
public a: string;
}
After
class XFoo {
static get properties() {
return {
/*Some comment*/
prop1: String
};
}
}
customElements.define("x-foo", XFoo);
TODO:
- Fix error when
declaration
istrue
ifproperties
is not declared.- Fix output formatting.
npm i -D @polymer-vis/decorator-transformer
If declaration
for your tsconfig.json
is set to true
, you MUST include the properties
getAccessor in your class:
class SomeElement {
@property
prop1: string;
// this must be include if u are emitting
// type declaration.
static get properties() {
return {};
}
}
Update your tsconfig.json
with @polymer-vis/decorator-transformer
plugin.
Then run ttsc
to compile your typescript sources.
{
"compilerOptions": {
"plugins": [
{ "transform": "@polymer-vis/decorator-transformer", "type": "config" }
]
}
}
import * as ts from "typescript";
import decoratorTransformer from "@polymer-vis/decorator-transformer";
let source = `
@customElement('x-foo')
class XFoo extends HTMLElement {
static get properties() { return {}; }
@property
public a: string;
@property
public b: number;
@property
public c: boolean;
@property
public d: string[];
@property
public e: Array<Date>;
@property
public f: object;
public g: string;
}
`;
let result = ts.transpileModule(source, {
compilerOptions: { module: ts.ModuleKind.CommonJS },
transformers: { before: [decoratorTransformer()] }
});
console.log(result.outputText);
The source codes are originally by 43081j at lit-element PR#145. I made some minor improvements to replace @property
with the corresponding comment and property declarations (if present).
FAQs
A typescript transformer to replace "@property" and "@custom-element" decorators with vanilla javascript for Polymer and LitElement webcomponents.
We found that @polymer-vis/decorator-transformer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.