Socket
Socket
Sign inDemoInstall

@babel/plugin-transform-typescript

Package Overview
Dependencies
61
Maintainers
4
Versions
124
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 7.18.10 to 7.18.12

27

lib/index.js

@@ -42,6 +42,7 @@ "use strict";

function isGlobalType(path, name) {
const program = path.find(path => path.isProgram()).node;
if (path.scope.hasOwnBinding(name)) return false;
if (GLOBAL_TYPES.get(program).has(name)) return true;
function isGlobalType({
scope
}, name) {
if (scope.hasBinding(name)) return false;
if (GLOBAL_TYPES.get(scope).has(name)) return true;
console.warn(`The exported identifier "${name}" is not declared in Babel's scope tracker\n` + `as a JavaScript value binding, and "@babel/plugin-transform-typescript"\n` + `never encountered it as a TypeScript type declaration.\n` + `It will be treated as a JavaScript value.\n\n` + `This problem is likely caused by another plugin injecting\n` + `"${name}" without registering it in the scope tracker. If you are the author\n` + ` of that plugin, please use "scope.registerDeclaration(declarationPath)".`);

@@ -51,4 +52,4 @@ return false;

function registerGlobalType(programNode, name) {
GLOBAL_TYPES.get(programNode).add(name);
function registerGlobalType(programScope, name) {
GLOBAL_TYPES.get(programScope).add(name);
}

@@ -174,6 +175,6 @@

let fileJsxPragmaFrag = null;
const programNode = path.node;
const programScope = path.scope;
if (!GLOBAL_TYPES.has(programNode)) {
GLOBAL_TYPES.set(programNode, new Set());
if (!GLOBAL_TYPES.has(programScope)) {
GLOBAL_TYPES.set(programScope, new Set());
}

@@ -215,3 +216,3 @@

for (const specifier of stmt.node.specifiers) {
registerGlobalType(programNode, specifier.local.name);
registerGlobalType(programScope, specifier.local.name);
}

@@ -230,3 +231,3 @@

if (specifier.type === "ImportSpecifier" && specifier.importKind === "type") {
registerGlobalType(programNode, specifier.local.name);
registerGlobalType(programScope, specifier.local.name);
const binding = stmt.scope.getBinding(specifier.local.name);

@@ -285,3 +286,3 @@

for (const name of Object.keys(stmt.getBindingIdentifiers())) {
registerGlobalType(programNode, name);
registerGlobalType(programScope, name);
}

@@ -295,3 +296,3 @@ } else if (stmt.isTSTypeAliasDeclaration() || stmt.isTSDeclareFunction() && stmt.get("id").isIdentifier() || stmt.isTSInterfaceDeclaration() || stmt.isClassDeclaration({

}) && stmt.get("id").isIdentifier()) {
registerGlobalType(programNode, stmt.node.id.name);
registerGlobalType(programScope, stmt.node.id.name);
}

@@ -298,0 +299,0 @@ }

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

@@ -30,3 +30,3 @@ "repository": {

"@babel/helper-plugin-test-runner": "^7.18.6",
"@babel/traverse": "^7.18.10",
"@babel/traverse": "^7.18.11",
"@babel/types": "^7.18.10"

@@ -33,0 +33,0 @@ },

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