typescript-eslint-parser
Advanced tools
+4
-0
@@ -0,1 +1,5 @@ | ||
| v0.1.1 - August 10, 2016 | ||
| * 62d14b4 Fix: Class implements generic syntax (fixes #44) (#53) (James Henry) | ||
| v0.1.0 - August 9, 2016 | ||
@@ -2,0 +6,0 @@ |
+41
-1
@@ -456,2 +456,38 @@ /** | ||
| /** | ||
| * Converts a TSNode's typeArguments array to a flow-like typeParameters node | ||
| * @param {Array} typeArguments TSNode typeArguments | ||
| * @returns {TypeParameterInstantiation} TypeParameterInstantiation node | ||
| */ | ||
| function convertTypeArgumentsToTypeParameters(typeArguments) { | ||
| var firstTypeArgument = typeArguments[0]; | ||
| var lastTypeArgument = typeArguments[typeArguments.length - 1]; | ||
| return { | ||
| type: "TypeParameterInstantiation", | ||
| range: [ | ||
| firstTypeArgument.pos - 1, | ||
| lastTypeArgument.end + 1 | ||
| ], | ||
| loc: getLocFor(firstTypeArgument.pos - 1, lastTypeArgument.end + 1, ast), | ||
| params: typeArguments.map(function(typeArgument) { | ||
| /** | ||
| * Have to manually calculate the start of the range, | ||
| * because TypeScript includes leading whitespace but Flow does not | ||
| */ | ||
| var typeArgumentStart = (typeArgument.typeName && typeArgument.typeName.text) | ||
| ? typeArgument.end - typeArgument.typeName.text.length | ||
| : typeArgument.pos; | ||
| return { | ||
| type: "GenericTypeAnnotation", | ||
| range: [ | ||
| typeArgumentStart, | ||
| typeArgument.end | ||
| ], | ||
| loc: getLocFor(typeArgumentStart, typeArgument.end, ast), | ||
| id: convertChild(typeArgument.typeName) | ||
| }; | ||
| }) | ||
| }; | ||
| } | ||
| /** | ||
| * Converts a child into a class implements node. This creates an intermediary | ||
@@ -464,3 +500,3 @@ * ClassImplements node to match what Flow does. | ||
| var id = convertChild(child.expression); | ||
| return { | ||
| var classImplementsNode = { | ||
| type: "ClassImplements", | ||
@@ -471,2 +507,6 @@ loc: id.loc, | ||
| }; | ||
| if (child.typeArguments && child.typeArguments.length) { | ||
| classImplementsNode.typeParameters = convertTypeArgumentsToTypeParameters(child.typeArguments); | ||
| } | ||
| return classImplementsNode; | ||
| } | ||
@@ -473,0 +513,0 @@ |
+1
-1
@@ -7,3 +7,3 @@ { | ||
| "main": "parser.js", | ||
| "version": "0.1.0", | ||
| "version": "0.1.1", | ||
| "files": [ | ||
@@ -10,0 +10,0 @@ "lib", |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
90194
2.34%2029
1.96%0
-100%