ast-types 0.3.37 → 0.3.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/def/core.js +1 -1
- package/lib/types.js +11 -7
- package/package.json +1 -1
- package/test/run.js +3 -5
package/def/core.js
CHANGED
package/lib/types.js
CHANGED
|
@@ -278,14 +278,18 @@ function Def(typeName) {
|
|
|
278
278
|
}
|
|
279
279
|
|
|
280
280
|
Def.fromValue = function(value) {
|
|
281
|
-
if (
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
281
|
+
if (value && typeof value === "object") {
|
|
282
|
+
var type = value.type;
|
|
283
|
+
if (typeof type === "string" &&
|
|
284
|
+
hasOwn.call(defCache, type)) {
|
|
285
|
+
var d = defCache[type];
|
|
286
|
+
if (d.finalized) {
|
|
287
|
+
return d;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
288
290
|
}
|
|
291
|
+
|
|
292
|
+
return null;
|
|
289
293
|
};
|
|
290
294
|
|
|
291
295
|
var Dp = Def.prototype;
|
package/package.json
CHANGED
package/test/run.js
CHANGED
|
@@ -274,9 +274,7 @@ describe("types.eachField", function() {
|
|
|
274
274
|
}
|
|
275
275
|
|
|
276
276
|
it("should give correct keys for supertypes", function() {
|
|
277
|
-
check({ type: "Expression" }, [
|
|
278
|
-
"type", "loc"
|
|
279
|
-
]);
|
|
277
|
+
check({ type: "Expression" }, ["type"]);
|
|
280
278
|
});
|
|
281
279
|
|
|
282
280
|
it("should work for non-buildable types", function() {
|
|
@@ -292,12 +290,12 @@ describe("types.eachField", function() {
|
|
|
292
290
|
it("should respect hidden fields", function() {
|
|
293
291
|
check({ type: "TryStatement" }, [
|
|
294
292
|
// Note that the "handlers" field is now hidden from eachField.
|
|
295
|
-
"type", "block", "handler", "guardedHandlers", "finalizer"
|
|
293
|
+
"type", "block", "handler", "guardedHandlers", "finalizer"
|
|
296
294
|
]);
|
|
297
295
|
});
|
|
298
296
|
|
|
299
297
|
check({ type: "CatchClause" }, [
|
|
300
|
-
"type", "param", "guard", "body"
|
|
298
|
+
"type", "param", "guard", "body"
|
|
301
299
|
]);
|
|
302
300
|
|
|
303
301
|
it("should complain about invalid types", function() {
|