Socket
Socket
Sign inDemoInstall

@polymer/gen-typescript-declarations

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@polymer/gen-typescript-declarations - npm Package Compare versions

Comparing version 1.1.2 to 1.1.3

3

CHANGELOG.md

@@ -9,2 +9,5 @@ # Changelog

## [1.1.3] - 2018-02-12
- Mixin functions now include all of the additional mixins they automatically apply. Previously, only the immediately applied mixins were accounted for, but not ones that were applied transitively.
## [1.1.2] - 2018-02-08

@@ -11,0 +14,0 @@ - Elements that are constructable (usually a call to the Polymer function whose result is assigned to some variable) can now have behaviors.

@@ -99,3 +99,3 @@ "use strict";

for (const analyzerDoc of analyzerDocs) {
handleDocument(analyzerDoc, tsDoc, rootDir, config.excludeIdentifiers || []);
handleDocument(analysis, analyzerDoc, tsDoc, rootDir, config.excludeIdentifiers || []);
}

@@ -163,3 +163,3 @@ for (const ref of tsDoc.referencePaths) {

*/
function handleDocument(doc, root, rootDir, excludeIdentifiers) {
function handleDocument(analysis, doc, root, rootDir, excludeIdentifiers) {
for (const feature of doc.getFeatures()) {

@@ -179,3 +179,3 @@ if (excludeIdentifiers.some((id) => feature.identifiers.has(id))) {

else if (feature.kinds.has('element-mixin')) {
handleMixin(feature, root);
handleMixin(feature, root, analysis);
}

@@ -330,3 +330,3 @@ else if (feature.kinds.has('class')) {

*/
function handleMixin(feature, root) {
function handleMixin(feature, root, analysis) {
const [namespacePath, mixinName] = splitReference(feature.name);

@@ -347,3 +347,4 @@ const parentNamespace = findOrCreateNamespace(root, namespacePath);

new ts.NameType(mixinName + 'Constructor'),
...feature.mixins.map((m) => new ts.NameType(m.identifier + 'Constructor'))
...Array.from(transitiveMixins(feature, analysis))
.map((mixin) => new ts.NameType(mixin + 'Constructor'))
]),

@@ -381,2 +382,24 @@ }));

/**
* Mixins can automatically apply other mixins, indicated by the @appliesMixin
* annotation. However, since those mixins may themselves apply other mixins, to
* know the full set of them we need to traverse down the tree.
*/
function transitiveMixins(parentMixin, analysis, result) {
if (result === undefined) {
result = new Set();
}
for (const childRef of parentMixin.mixins) {
result.add(childRef.identifier);
const childMixinSet = analysis.getFeatures({ id: childRef.identifier, kind: 'element-mixin' });
if (childMixinSet.size !== 1) {
console.error(`Found ${childMixinSet.size} features for mixin ` +
`${childRef.identifier}, expected 1.`);
continue;
}
const childMixin = childMixinSet.values().next().value;
transitiveMixins(childMixin, analysis, result);
}
return result;
}
/**
* Add the given Class to the given TypeScript declarations document.

@@ -383,0 +406,0 @@ */

2

package.json
{
"name": "@polymer/gen-typescript-declarations",
"version": "1.1.2",
"version": "1.1.3",
"description": "Generate TypeScript type declarations for Polymer components.",

@@ -5,0 +5,0 @@ "main": "lib/gen-ts.js",

@@ -147,3 +147,7 @@ /**

handleDocument(
analyzerDoc, tsDoc, rootDir, config.excludeIdentifiers || []);
analysis,
analyzerDoc,
tsDoc,
rootDir,
config.excludeIdentifiers || []);
}

@@ -221,2 +225,3 @@ for (const ref of tsDoc.referencePaths) {

function handleDocument(
analysis: analyzer.Analysis,
doc: analyzer.Document,

@@ -238,3 +243,3 @@ root: ts.Document,

} else if (feature.kinds.has('element-mixin')) {
handleMixin(feature as analyzer.ElementMixin, root);
handleMixin(feature as analyzer.ElementMixin, root, analysis);
} else if (feature.kinds.has('class')) {

@@ -399,3 +404,6 @@ handleClass(feature as analyzer.Class, root);

*/
function handleMixin(feature: analyzer.ElementMixin, root: ts.Document) {
function handleMixin(
feature: analyzer.ElementMixin,
root: ts.Document,
analysis: analyzer.Analysis) {
const [namespacePath, mixinName] = splitReference(feature.name);

@@ -417,4 +425,4 @@ const parentNamespace = findOrCreateNamespace(root, namespacePath);

new ts.NameType(mixinName + 'Constructor'),
...feature.mixins.map(
(m) => new ts.NameType(m.identifier + 'Constructor'))
...Array.from(transitiveMixins(feature, analysis))
.map((mixin) => new ts.NameType(mixin + 'Constructor'))
]),

@@ -456,2 +464,30 @@ }));

/**
* Mixins can automatically apply other mixins, indicated by the @appliesMixin
* annotation. However, since those mixins may themselves apply other mixins, to
* know the full set of them we need to traverse down the tree.
*/
function transitiveMixins(
parentMixin: analyzer.ElementMixin,
analysis: analyzer.Analysis,
result?: Set<string>): Set<string> {
if (result === undefined) {
result = new Set();
}
for (const childRef of parentMixin.mixins) {
result.add(childRef.identifier);
const childMixinSet =
analysis.getFeatures({id: childRef.identifier, kind: 'element-mixin'});
if (childMixinSet.size !== 1) {
console.error(
`Found ${childMixinSet.size} features for mixin ` +
`${childRef.identifier}, expected 1.`);
continue;
}
const childMixin = childMixinSet.values().next().value;
transitiveMixins(childMixin, analysis, result);
}
return result;
}
/**
* Add the given Class to the given TypeScript declarations document.

@@ -458,0 +494,0 @@ */

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