New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@lit/ts-transformers

Package Overview
Dependencies
Maintainers
8
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lit/ts-transformers - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

6

CHANGELOG.md
# Changelog
## 1.1.1
### Patch Changes
- [#2780](https://github.com/lit/lit/pull/2780) [`0f3a87b8`](https://github.com/lit/lit/commit/0f3a87b83ccf32a997208ca8328a8a3fbbafe955) - Fix reactive prop support for getters
## 1.1.0

@@ -4,0 +10,0 @@

2

internal/decorators/property.d.ts

@@ -33,4 +33,4 @@ /**

constructor({ factory }: ts.TransformationContext);
visit(litClassContext: LitClassContext, property: ts.ClassElement, decorator: ts.Decorator): void;
visit(litClassContext: LitClassContext, propertyOrGetter: ts.ClassElement, decorator: ts.Decorator): void;
protected _augmentOptions(options: ts.ObjectLiteralExpression | undefined): ts.ObjectLiteralExpression | undefined;
}

@@ -15,2 +15,19 @@ "use strict";

/**
* Copies the comments and, optionally, leading blank lines from one node to
* another.
*
* @param fromNode Node from which to copy comments.
* @param toNode Node where comments should be copied to.
* @param blankLines (Default: false) Whether to preserve leading blank lines.
* Useful for classmembers not moved to the constructor.
*/
const copyComments = (fromNode, toNode, blankLines = false) => {
// Omit blank lines from the PreserveBlankLines transformer, because they
// usually look awkward in the constructor.
const nonBlankLineSyntheticComments = typescript_1.default
.getSyntheticLeadingComments(fromNode)
?.filter((comment) => blankLines || comment.text !== preserve_blank_lines_js_1.BLANK_LINE_PLACEHOLDER_COMMENT);
typescript_1.default.setSyntheticLeadingComments(toNode, nonBlankLineSyntheticComments);
};
/**
* Transform:

@@ -40,7 +57,8 @@ *

}
visit(litClassContext, property, decorator) {
if (!typescript_1.default.isPropertyDeclaration(property)) {
visit(litClassContext, propertyOrGetter, decorator) {
const isGetter = typescript_1.default.isGetAccessor(propertyOrGetter);
if (!typescript_1.default.isPropertyDeclaration(propertyOrGetter) && !isGetter) {
return;
}
if (!typescript_1.default.isIdentifier(property.name)) {
if (!typescript_1.default.isIdentifier(propertyOrGetter.name)) {
return;

@@ -56,15 +74,19 @@ }

const options = this._augmentOptions(arg0);
const name = property.name.text;
litClassContext.litFileContext.nodeReplacements.set(property, undefined);
const name = propertyOrGetter.name.text;
const factory = this._factory;
if (isGetter) {
// Decorators is readonly so clone the property.
const getterWithoutDecorators = factory.createGetAccessorDeclaration(undefined, propertyOrGetter.modifiers, propertyOrGetter.name, propertyOrGetter.parameters, propertyOrGetter.type, propertyOrGetter.body);
copyComments(propertyOrGetter, getterWithoutDecorators, true);
litClassContext.litFileContext.nodeReplacements.set(propertyOrGetter, getterWithoutDecorators);
}
else {
// Delete the member property
litClassContext.litFileContext.nodeReplacements.set(propertyOrGetter, undefined);
}
litClassContext.reactiveProperties.push({ name, options });
if (property.initializer !== undefined) {
const factory = this._factory;
const initializer = factory.createExpressionStatement(factory.createBinaryExpression(factory.createPropertyAccessExpression(factory.createThis(), factory.createIdentifier(name)), factory.createToken(typescript_1.default.SyntaxKind.EqualsToken), property.initializer));
typescript_1.default.setTextRange(initializer, property);
// Omit blank lines from the PreserveBlankLines transformer, because they
// usually look awkward in the constructor.
const nonBlankLineSyntheticComments = typescript_1.default
.getSyntheticLeadingComments(property)
?.filter((comment) => comment.text !== preserve_blank_lines_js_1.BLANK_LINE_PLACEHOLDER_COMMENT);
typescript_1.default.setSyntheticLeadingComments(initializer, nonBlankLineSyntheticComments);
if (!isGetter && propertyOrGetter.initializer !== undefined) {
const initializer = factory.createExpressionStatement(factory.createBinaryExpression(factory.createPropertyAccessExpression(factory.createThis(), factory.createIdentifier(name)), factory.createToken(typescript_1.default.SyntaxKind.EqualsToken), propertyOrGetter.initializer));
typescript_1.default.setTextRange(initializer, propertyOrGetter);
copyComments(propertyOrGetter, initializer);
litClassContext.extraConstructorStatements.push(initializer);

@@ -71,0 +93,0 @@ }

{
"name": "@lit/ts-transformers",
"version": "1.1.0",
"version": "1.1.1",
"publishConfig": {

@@ -5,0 +5,0 @@ "access": "public"

Sorry, the diff of this file is not supported yet

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