Socket
Socket
Sign inDemoInstall

@babel/plugin-transform-typescript

Package Overview
Dependencies
61
Maintainers
4
Versions
123
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 7.21.4-esm to 7.21.4-esm.1

12

lib/const-enum.js

@@ -1,9 +0,3 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = transpileConstEnum;
var _enum = require("./enum");
function transpileConstEnum(path, t) {
import { translateEnumValues } from "./enum.js";
export default function transpileConstEnum(path, t) {
const {

@@ -19,3 +13,3 @@ name

enumValues: entries
} = (0, _enum.translateEnumValues)(path, t);
} = translateEnumValues(path, t);
if (isExported) {

@@ -22,0 +16,0 @@ const obj = t.objectExpression(entries.map(([name, value]) => t.objectProperty(t.isValidIdentifier(name) ? t.identifier(name) : t.stringLiteral(name), value)));

@@ -1,13 +0,6 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = transpileEnum;
exports.translateEnumValues = translateEnumValues;
var _core = require("@babel/core");
var _assert = require("assert");
var _helperAnnotateAsPure = require("@babel/helper-annotate-as-pure");
import { template, types as t } from "@babel/core";
import assert from "assert";
import annotateAsPure from "@babel/helper-annotate-as-pure";
const ENUMS = new WeakMap();
const buildEnumWrapper = _core.template.expression(`
const buildEnumWrapper = template.expression(`
(function (ID) {

@@ -18,3 +11,3 @@ ASSIGNMENTS;

`);
function transpileEnum(path, t) {
export default function transpileEnum(path, t) {
const {

@@ -48,3 +41,3 @@ node,

}));
if (isPure) (0, _helperAnnotateAsPure.default)(enumIIFE);
if (isPure) annotateAsPure(enumIIFE);
if (isSeen) {

@@ -74,6 +67,6 @@ const toReplace = parentPath.isExportDeclaration() ? parentPath : path;

}
const buildStringAssignment = (0, _core.template)(`
const buildStringAssignment = template(`
ENUM["NAME"] = VALUE;
`);
const buildNumericAssignment = (0, _core.template)(`
const buildNumericAssignment = template(`
ENUM[ENUM["NAME"] = VALUE] = "NAME";

@@ -117,3 +110,3 @@ `);

};
function translateEnumValues(path, t) {
export function translateEnumValues(path, t) {
const seen = new Map();

@@ -136,3 +129,3 @@ let constValue = -1;

} else {
_assert(typeof constValue === "string");
assert(typeof constValue === "string");
value = t.stringLiteral(constValue);

@@ -224,3 +217,3 @@ }

const prop = expr.property;
if (!_core.types.isIdentifier(obj) || (expr.computed ? !_core.types.isStringLiteral(prop) : !_core.types.isIdentifier(prop))) {
if (!t.isIdentifier(obj) || (expr.computed ? !t.isStringLiteral(prop) : !t.isIdentifier(prop))) {
return;

@@ -227,0 +220,0 @@ }

@@ -1,13 +0,7 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _helperPluginUtils = require("@babel/helper-plugin-utils");
var _pluginSyntaxTypescript = require("@babel/plugin-syntax-typescript");
var _helperCreateClassFeaturesPlugin = require("@babel/helper-create-class-features-plugin");
var _constEnum = require("./const-enum");
var _enum = require("./enum");
var _namespace = require("./namespace");
import { declare } from "@babel/helper-plugin-utils";
import syntaxTypeScript from "@babel/plugin-syntax-typescript";
import { injectInitialization } from "@babel/helper-create-class-features-plugin";
import transpileConstEnum from "./const-enum.js";
import transpileEnum from "./enum.js";
import transpileNamespace from "./namespace.js";
function isInType(path) {

@@ -53,3 +47,3 @@ switch (path.parent.type) {

}
var _default = (0, _helperPluginUtils.declare)((api, opts) => {
export default declare((api, opts) => {
const {

@@ -149,3 +143,3 @@ types: t,

}
(0, _helperCreateClassFeaturesPlugin.injectInitialization)(classPath, path, assigns);
injectInitialization(classPath, path, assigns);
}

@@ -155,3 +149,3 @@ };

name: "transform-typescript",
inherits: _pluginSyntaxTypescript.default,
inherits: syntaxTypeScript,
visitor: {

@@ -372,3 +366,3 @@ Pattern: visitPattern,

TSModuleDeclaration(path) {
(0, _namespace.default)(path, allowNamespaces);
transpileNamespace(path, allowNamespaces);
},

@@ -383,5 +377,5 @@ TSInterfaceDeclaration(path) {

if (optimizeConstEnums && path.node.const) {
(0, _constEnum.default)(path, t);
transpileConstEnum(path, t);
} else {
(0, _enum.default)(path, t);
transpileEnum(path, t);
}

@@ -467,4 +461,3 @@ },

});
exports.default = _default;
//# sourceMappingURL=index.js.map

@@ -1,9 +0,3 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = transpileNamespace;
var _core = require("@babel/core");
function transpileNamespace(path, allowNamespaces) {
import { template, types as t } from "@babel/core";
export default function transpileNamespace(path, allowNamespaces) {
if (path.node.declare || path.node.id.type === "StringLiteral") {

@@ -17,3 +11,3 @@ path.remove();

const name = path.node.id.name;
const value = handleNested(path, _core.types.cloneNode(path.node, true));
const value = handleNested(path, t.cloneNode(path.node, true));
const bound = path.scope.hasOwnBinding(name);

@@ -35,6 +29,6 @@ if (path.parent.type === "ExportNamedDeclaration") {

function getDeclaration(name) {
return _core.types.variableDeclaration("let", [_core.types.variableDeclarator(_core.types.identifier(name))]);
return t.variableDeclaration("let", [t.variableDeclarator(t.identifier(name))]);
}
function getMemberExpression(name, itemName) {
return _core.types.memberExpression(_core.types.identifier(name), _core.types.identifier(itemName));
return t.memberExpression(t.identifier(name), t.identifier(itemName));
}

@@ -48,14 +42,14 @@ function handleVariableDeclaration(node, name, hub) {

} = node;
if (declarations.every(declarator => _core.types.isIdentifier(declarator.id))) {
if (declarations.every(declarator => t.isIdentifier(declarator.id))) {
for (const declarator of declarations) {
declarator.init = _core.types.assignmentExpression("=", getMemberExpression(name, declarator.id.name), declarator.init);
declarator.init = t.assignmentExpression("=", getMemberExpression(name, declarator.id.name), declarator.init);
}
return [node];
}
const bindingIdentifiers = _core.types.getBindingIdentifiers(node);
const bindingIdentifiers = t.getBindingIdentifiers(node);
const assignments = [];
for (const idName in bindingIdentifiers) {
assignments.push(_core.types.assignmentExpression("=", getMemberExpression(name, idName), _core.types.cloneNode(bindingIdentifiers[idName])));
assignments.push(t.assignmentExpression("=", getMemberExpression(name, idName), t.cloneNode(bindingIdentifiers[idName])));
}
return [node, _core.types.expressionStatement(_core.types.sequenceExpression(assignments))];
return [node, t.expressionStatement(t.sequenceExpression(assignments))];
}

@@ -68,5 +62,5 @@ function buildNestedAmbientModuleError(path, node) {

const realName = node.id;
_core.types.assertIdentifier(realName);
t.assertIdentifier(realName);
const name = path.scope.generateUid(realName.name);
const namespaceTopLevel = _core.types.isTSModuleBlock(node.body) ? node.body.body : [_core.types.exportNamedDeclaration(node.body)];
const namespaceTopLevel = t.isTSModuleBlock(node.body) ? node.body.body : [t.exportNamedDeclaration(node.body)];
for (let i = 0; i < namespaceTopLevel.length; i++) {

@@ -77,3 +71,3 @@ const subNode = namespaceTopLevel[i];

{
if (!_core.types.isIdentifier(subNode.id)) {
if (!t.isIdentifier(subNode.id)) {
throw buildNestedAmbientModuleError(path, subNode);

@@ -98,3 +92,3 @@ }

{
for (const name in _core.types.getBindingIdentifiers(subNode)) {
for (const name in t.getBindingIdentifiers(subNode)) {
names.add(name);

@@ -118,3 +112,3 @@ }

names.add(itemName);
namespaceTopLevel.splice(i++, 1, subNode.declaration, _core.types.expressionStatement(_core.types.assignmentExpression("=", getMemberExpression(name, itemName), _core.types.identifier(itemName))));
namespaceTopLevel.splice(i++, 1, subNode.declaration, t.expressionStatement(t.assignmentExpression("=", getMemberExpression(name, itemName), t.identifier(itemName))));
break;

@@ -131,6 +125,6 @@ }

{
if (!_core.types.isIdentifier(subNode.declaration.id)) {
if (!t.isIdentifier(subNode.declaration.id)) {
throw buildNestedAmbientModuleError(path, subNode.declaration);
}
const transformed = handleNested(path, subNode.declaration, _core.types.identifier(name));
const transformed = handleNested(path, subNode.declaration, t.identifier(name));
const moduleName = subNode.declaration.id.name;

@@ -146,14 +140,14 @@ if (names.has(moduleName)) {

}
let fallthroughValue = _core.types.objectExpression([]);
let fallthroughValue = t.objectExpression([]);
if (parentExport) {
const memberExpr = _core.types.memberExpression(parentExport, realName);
fallthroughValue = _core.template.expression.ast`
${_core.types.cloneNode(memberExpr)} ||
(${_core.types.cloneNode(memberExpr)} = ${fallthroughValue})
const memberExpr = t.memberExpression(parentExport, realName);
fallthroughValue = template.expression.ast`
${t.cloneNode(memberExpr)} ||
(${t.cloneNode(memberExpr)} = ${fallthroughValue})
`;
}
return _core.template.statement.ast`
(function (${_core.types.identifier(name)}) {
return template.statement.ast`
(function (${t.identifier(name)}) {
${namespaceTopLevel}
})(${realName} || (${_core.types.cloneNode(realName)} = ${fallthroughValue}));
})(${realName} || (${t.cloneNode(realName)} = ${fallthroughValue}));
`;

@@ -160,0 +154,0 @@ }

{
"name": "@babel/plugin-transform-typescript",
"version": "7.21.4-esm",
"version": "7.21.4-esm.1",
"description": "Transform TypeScript into ES.next",

@@ -20,15 +20,15 @@ "repository": {

"dependencies": {
"@babel/helper-annotate-as-pure": "^7.21.4-esm",
"@babel/helper-create-class-features-plugin": "^7.21.4-esm",
"@babel/helper-plugin-utils": "^7.21.4-esm",
"@babel/plugin-syntax-typescript": "^7.21.4-esm"
"@babel/helper-annotate-as-pure": "^7.21.4-esm.1",
"@babel/helper-create-class-features-plugin": "^7.21.4-esm.1",
"@babel/helper-plugin-utils": "^7.21.4-esm.1",
"@babel/plugin-syntax-typescript": "^7.21.4-esm.1"
},
"peerDependencies": {
"@babel/core": "^7.0.0-0 || 7.21.4-esm"
"@babel/core": "^7.0.0-0 || 7.21.4-esm.1"
},
"devDependencies": {
"@babel/core": "^7.21.4-esm",
"@babel/helper-plugin-test-runner": "^7.21.4-esm",
"@babel/traverse": "^7.21.4-esm",
"@babel/types": "^7.21.4-esm"
"@babel/core": "^7.21.4-esm.1",
"@babel/helper-plugin-test-runner": "^7.21.4-esm.1",
"@babel/traverse": "^7.21.4-esm.1",
"@babel/types": "^7.21.4-esm.1"
},

@@ -40,3 +40,3 @@ "homepage": "https://babel.dev/docs/en/next/babel-plugin-transform-typescript",

"author": "The Babel Team (https://babel.dev/team)",
"type": "commonjs"
"type": "module"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc