Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@babel/preset-typescript

Package Overview
Dependencies
Maintainers
4
Versions
94
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@babel/preset-typescript - npm Package Compare versions

Comparing version 7.13.0 to 7.22.5

lib/normalize-options.js

94

lib/index.js

@@ -7,2 +7,4 @@ 'use strict';

var transformTypeScript = require('@babel/plugin-transform-typescript');
require('@babel/plugin-syntax-jsx');
var transformModulesCommonJS = require('@babel/plugin-transform-modules-commonjs');
var helperValidatorOption = require('@babel/helper-validator-option');

@@ -13,2 +15,3 @@

var transformTypeScript__default = /*#__PURE__*/_interopDefaultLegacy(transformTypeScript);
var transformModulesCommonJS__default = /*#__PURE__*/_interopDefaultLegacy(transformModulesCommonJS);

@@ -22,49 +25,94 @@ const v = new helperValidatorOption.OptionValidator("@babel/preset-typescript");

} = options;
const jsxPragmaFrag = v.validateStringOption("jsxPragmaFrag", options.jsxPragmaFrag, "React.Fragment");
const allExtensions = v.validateBooleanOption("allExtensions", options.allExtensions, false);
const isTSX = v.validateBooleanOption("isTSX", options.isTSX, false);
if (isTSX) {
v.invariant(allExtensions, "isTSX:true requires allExtensions:true");
const TopLevelOptions = {
ignoreExtensions: "ignoreExtensions",
allowNamespaces: "allowNamespaces",
disallowAmbiguousJSXLike: "disallowAmbiguousJSXLike",
jsxPragma: "jsxPragma",
jsxPragmaFrag: "jsxPragmaFrag",
onlyRemoveTypeImports: "onlyRemoveTypeImports",
optimizeConstEnums: "optimizeConstEnums",
allExtensions: "allExtensions",
isTSX: "isTSX"
};
const jsxPragmaFrag = v.validateStringOption(TopLevelOptions.jsxPragmaFrag, options.jsxPragmaFrag, "React.Fragment");
{
var allExtensions = v.validateBooleanOption(TopLevelOptions.allExtensions, options.allExtensions, false);
var isTSX = v.validateBooleanOption(TopLevelOptions.isTSX, options.isTSX, false);
if (isTSX) {
v.invariant(allExtensions, "isTSX:true requires allExtensions:true");
}
}
return {
allExtensions,
const ignoreExtensions = v.validateBooleanOption(TopLevelOptions.ignoreExtensions, options.ignoreExtensions, false);
const disallowAmbiguousJSXLike = v.validateBooleanOption(TopLevelOptions.disallowAmbiguousJSXLike, options.disallowAmbiguousJSXLike, false);
if (disallowAmbiguousJSXLike) {
{
v.invariant(allExtensions, "disallowAmbiguousJSXLike:true requires allExtensions:true");
}
}
const optimizeConstEnums = v.validateBooleanOption(TopLevelOptions.optimizeConstEnums, options.optimizeConstEnums, false);
const normalized = {
ignoreExtensions,
allowNamespaces,
isTSX,
disallowAmbiguousJSXLike,
jsxPragma,
jsxPragmaFrag,
onlyRemoveTypeImports
onlyRemoveTypeImports,
optimizeConstEnums
};
{
normalized.allExtensions = allExtensions;
normalized.isTSX = isTSX;
}
return normalized;
}
var index = helperPluginUtils.declare((api, opts) => {
var index = helperPluginUtils.declarePreset((api, opts) => {
api.assertVersion(7);
const {
allExtensions,
ignoreExtensions,
allowNamespaces,
disallowAmbiguousJSXLike,
isTSX,
jsxPragma,
jsxPragmaFrag,
onlyRemoveTypeImports
onlyRemoveTypeImports,
optimizeConstEnums
} = normalizeOptions(opts);
const pluginOptions = isTSX => ({
const pluginOptions = disallowAmbiguousJSXLike => ({
allowDeclareFields: opts.allowDeclareFields,
allowNamespaces,
isTSX,
disallowAmbiguousJSXLike,
jsxPragma,
jsxPragmaFrag,
onlyRemoveTypeImports
onlyRemoveTypeImports,
optimizeConstEnums
});
const getPlugins = (isTSX, disallowAmbiguousJSXLike) => {
{
return [[transformTypeScript__default["default"], Object.assign({
isTSX
}, pluginOptions(disallowAmbiguousJSXLike))]];
}
};
const disableExtensionDetect = allExtensions || ignoreExtensions;
return {
overrides: allExtensions ? [{
plugins: [[transformTypeScript__default['default'], pluginOptions(isTSX)]]
overrides: disableExtensionDetect ? [{
plugins: getPlugins(isTSX, disallowAmbiguousJSXLike)
}] : [{
test: /\.ts$/,
plugins: [[transformTypeScript__default['default'], pluginOptions(false)]]
plugins: getPlugins(false, false)
}, {
test: /\.mts$/,
sourceType: "module",
plugins: getPlugins(false, true)
}, {
test: /\.cts$/,
sourceType: "unambiguous",
plugins: [[transformModulesCommonJS__default["default"], {
allowTopLevelThis: true
}], [transformTypeScript__default["default"], pluginOptions(true)]]
}, {
test: /\.tsx$/,
plugins: [[transformTypeScript__default['default'], pluginOptions(true)]]
plugins: getPlugins(true, false)
}]

@@ -74,3 +122,3 @@ };

exports.default = index;
exports["default"] = index;
//# sourceMappingURL=index.js.map
{
"name": "@babel/preset-typescript",
"version": "7.13.0",
"version": "7.22.5",
"description": "Babel preset for TypeScript.",

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

},
"main": "lib/index.js",
"main": "./lib/index.js",
"keywords": [

@@ -21,5 +21,7 @@ "babel-preset",

"dependencies": {
"@babel/helper-plugin-utils": "^7.13.0",
"@babel/helper-validator-option": "^7.12.17",
"@babel/plugin-transform-typescript": "^7.13.0"
"@babel/helper-plugin-utils": "^7.22.5",
"@babel/helper-validator-option": "^7.22.5",
"@babel/plugin-syntax-jsx": "^7.22.5",
"@babel/plugin-transform-modules-commonjs": "^7.22.5",
"@babel/plugin-transform-typescript": "^7.22.5"
},

@@ -30,7 +32,12 @@ "peerDependencies": {

"devDependencies": {
"@babel/core": "7.13.0",
"@babel/helper-plugin-test-runner": "7.12.13"
"@babel/core": "^7.22.5",
"@babel/helper-plugin-test-runner": "^7.22.5"
},
"homepage": "https://babel.dev/docs/en/next/babel-preset-typescript",
"bugs": "https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22area%3A%20typescript%22+is%3Aopen"
"bugs": "https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22area%3A%20typescript%22+is%3Aopen",
"engines": {
"node": ">=6.9.0"
},
"author": "The Babel Team (https://babel.dev/team)",
"type": "commonjs"
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc