MCPcopy
hub / github.com/babel/babel / execTest

Function execTest

packages/babel-core/test/api.js:420–462  ·  view source on GitHub ↗
(passPerPreset)

Source from the content-addressed store, hash-verified

418 let aliasBaseType = null;
419
420 function execTest(passPerPreset) {
421 return transformSync("type Foo = number; let x = (y): Foo => y;", {
422 sourceType: "script",
423 passPerPreset: passPerPreset,
424 presets: [
425 // First preset with our plugin, "before"
426 function () {
427 return {
428 plugins: [
429 () => ({
430 visitor: {
431 Function: function (path) {
432 const alias = path.scope
433 .getProgramParent()
434 .path.get("body")[0].node;
435 if (!babel.types.isTypeAlias(alias)) return;
436
437 // In case of `passPerPreset` being `false`, the
438 // alias node is already removed by Flow plugin.
439 if (!alias) {
440 return;
441 }
442
443 // In case of `passPerPreset` being `true`, the
444 // alias node should still exist.
445 aliasBaseType = alias.right.type; // NumberTypeAnnotation
446 },
447 },
448 }),
449 ],
450 };
451 },
452
453 // env preset
454 [presetEnv, { targets: { browsers: "ie 6" } }],
455
456 // Third preset for Flow.
457 () => ({
458 plugins: [pluginSyntaxFlow, pluginFlowStripTypes],
459 }),
460 ],
461 });
462 }
463
464 // 1. passPerPreset: true
465

Callers 1

api.jsFile · 0.85

Calls 4

getProgramParentMethod · 0.80
isTypeAliasMethod · 0.80
transformSyncFunction · 0.70
getMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…