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 CHANGED
@@ -16,7 +16,7 @@ def("Node")
16
16
  .field("loc", or(
17
17
  def("SourceLocation"),
18
18
  null
19
- ), defaults["null"]);
19
+ ), defaults["null"], true);
20
20
 
21
21
  def("SourceLocation")
22
22
  .build("start", "end", "source")
package/lib/types.js CHANGED
@@ -278,14 +278,18 @@ function Def(typeName) {
278
278
  }
279
279
 
280
280
  Def.fromValue = function(value) {
281
- if (isObject.check(value) &&
282
- hasOwn.call(value, "type") &&
283
- hasOwn.call(defCache, value.type))
284
- {
285
- var vDef = defCache[value.type];
286
- assert.strictEqual(vDef.finalized, true);
287
- return vDef;
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
@@ -18,7 +18,7 @@
18
18
  "transformation",
19
19
  "syntax"
20
20
  ],
21
- "version": "0.3.37",
21
+ "version": "0.3.38",
22
22
  "homepage": "http://github.com/benjamn/ast-types",
23
23
  "repository": {
24
24
  "type": "git",
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", "loc"
293
+ "type", "block", "handler", "guardedHandlers", "finalizer"
296
294
  ]);
297
295
  });
298
296
 
299
297
  check({ type: "CatchClause" }, [
300
- "type", "param", "guard", "body", "loc"
298
+ "type", "param", "guard", "body"
301
299
  ]);
302
300
 
303
301
  it("should complain about invalid types", function() {