Socket
Socket
Sign inDemoInstall

typescript-strictly-typed

Package Overview
Dependencies
12
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.13.1 to 3.0.0

19

angular-strict.js

@@ -1,4 +0,2 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const config_utils_1 = require("./config-utils");
import { findConfig, getConfig, modifyJSON, saveConfig } from './config-utils.js';
/**

@@ -15,16 +13,15 @@ * Enable the following Angular compiler options:

*/
function enableAngularStrict(cwd) {
const file = (0, config_utils_1.findConfig)(cwd, ['tsconfig.base.json', 'tsconfig.json']);
export async function enableAngularStrict(cwd) {
const file = findConfig(cwd, ['tsconfig.base.json', 'tsconfig.json']);
if (!file) {
return false;
}
const config = (0, config_utils_1.getConfig)(cwd, file);
const config = await getConfig(cwd, file);
if (!config) {
return false;
}
config.raw = (0, config_utils_1.modifyJSON)(config.raw, ['angularCompilerOptions', 'strictInjectionParameters'], true);
config.raw = (0, config_utils_1.modifyJSON)(config.raw, ['angularCompilerOptions', 'strictTemplates'], true);
config.raw = (0, config_utils_1.modifyJSON)(config.raw, ['angularCompilerOptions', 'strictInputAccessModifiers'], true);
return (0, config_utils_1.saveConfig)(cwd, file, config);
config.raw = modifyJSON(config.raw, ['angularCompilerOptions', 'strictInjectionParameters'], true);
config.raw = modifyJSON(config.raw, ['angularCompilerOptions', 'strictTemplates'], true);
config.raw = modifyJSON(config.raw, ['angularCompilerOptions', 'strictInputAccessModifiers'], true);
return saveConfig(cwd, file, config);
}
exports.default = enableAngularStrict;

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

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const process = require("process");
const index_1 = require("./index");
import { cwd } from 'node:process';
import { typescriptStrictlyTyped } from './index.js';
import { logError } from './log-utils.js';
/* Get the path where the command is invoked */
const cwd = process.cwd();
(0, index_1.default)(cwd);
typescriptStrictlyTyped(cwd()).catch(() => {
logError(`Unknown error.\n`);
});

@@ -1,11 +0,8 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.checkDependencyVersion = exports.modifyJSON = exports.saveConfig = exports.getConfig = exports.findConfig = void 0;
const path = require("path");
const fs = require("fs");
const jsonc_parser_1 = require("jsonc-parser");
const yaml = require("js-yaml");
const pkgUp = require("pkg-up");
const semver = require("semver");
const log_utils_1 = require("./log-utils");
import { basename, extname, join } from 'node:path';
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
import { applyEdits, modify, parse } from 'jsonc-parser';
import { dump, load } from 'js-yaml';
import { pkgUpSync } from 'pkg-up';
import { coerce, satisfies } from 'semver';
import { logError, logInfo } from './log-utils.js';
/**

@@ -19,6 +16,6 @@ * Search the config file of a tool

*/
function findConfig(cwd, files) {
export function findConfig(cwd, files) {
for (const file of files) {
const filePath = path.join(cwd, file);
if (fs.existsSync(filePath)) {
const filePath = join(cwd, file);
if (existsSync(filePath)) {
return file;

@@ -28,7 +25,6 @@ }

if (files[0]) {
(0, log_utils_1.logInfo)(`Can't find ${path.basename(files[0], '.json')} config file. Skipping this configuration.`);
logInfo(`Can't find ${basename(files[0], '.json')} config file. Skipping this configuration.`);
}
return null;
}
exports.findConfig = findConfig;
/**

@@ -42,6 +38,6 @@ * Get the config of a tool

*/
function getConfig(cwd, file) {
const filePath = path.join(cwd, file);
const raw = fs.readFileSync(filePath, { encoding: 'utf8' });
const fileType = path.extname(file);
export async function getConfig(cwd, file) {
const filePath = join(cwd, file);
const raw = readFileSync(filePath, { encoding: 'utf8' });
const fileType = extname(file);
let config = null;

@@ -53,3 +49,3 @@ try {

raw,
json: (0, jsonc_parser_1.parse)(raw),
json: parse(raw),
};

@@ -60,3 +56,3 @@ break;

case '.yml': {
const json = yaml.load(raw);
const json = load(raw);
config = {

@@ -69,3 +65,4 @@ raw: JSON.stringify(json),

case '.js': {
const json = require(filePath); // eslint-disable-line @typescript-eslint/no-var-requires
const moduleImport = await import(filePath);
const json = moduleImport.default;
config = {

@@ -79,8 +76,7 @@ raw: JSON.stringify(json),

}
catch (_a) {
(0, log_utils_1.logError)(`Can't parse ${file}. Check the file syntax is valid.`);
catch {
logError(`Can't parse ${file}. Check the file syntax is valid.`);
}
return config;
}
exports.getConfig = getConfig;
/**

@@ -95,5 +91,5 @@ * Write config file on disk

*/
function saveConfig(cwd, file, config) {
const filePath = path.join(cwd, file);
const fileType = path.extname(file);
export function saveConfig(cwd, file, config) {
const filePath = join(cwd, file);
const fileType = extname(file);
let configStringified = null;

@@ -107,25 +103,24 @@ try {

case '.yml':
configStringified = yaml.dump(config.json, { indent: 2 });
configStringified = dump(config.json, { indent: 2 });
break;
}
}
catch (_a) {
(0, log_utils_1.logError)(`Can't save ${file} config.`);
catch {
logError(`Can't save ${file} config.`);
return false;
}
if (!configStringified) {
(0, log_utils_1.logError)(`Can't save ${file} config.`);
logError(`Can't save ${file} config.`);
return false;
}
try {
fs.writeFileSync(filePath, configStringified);
writeFileSync(filePath, configStringified);
return true;
}
catch (_b) {
(0, log_utils_1.logError)(`Can't write ${file} file. Maybe a permission issue?`);
catch {
logError(`Can't write ${file} file. Maybe a permission issue?`);
return false;
}
}
exports.saveConfig = saveConfig;
function modifyJSON(json, path, value, otherOptions) {
export function modifyJSON(json, path, value, otherOptions) {
const options = {

@@ -138,5 +133,4 @@ formattingOptions: {

};
return (0, jsonc_parser_1.applyEdits)(json, (0, jsonc_parser_1.modify)(json.toString(), path, value, options !== null && options !== void 0 ? options : {}));
return applyEdits(json, modify(json.toString(), path, value, options ?? {}));
}
exports.modifyJSON = modifyJSON;
/**

@@ -149,13 +143,12 @@ * Check a dependency version

*/
function checkDependencyVersion(cwd, name, wantedVersion) {
var _a, _b;
const filePath = pkgUp.sync({ cwd });
export function checkDependencyVersion(cwd, name, wantedVersion) {
const filePath = pkgUpSync({ cwd });
if (filePath) {
const packageJsonFile = fs.readFileSync(filePath, { encoding: 'utf8' });
const packageJsonConfig = (0, jsonc_parser_1.parse)(packageJsonFile);
const prodDependencyVersion = (_a = packageJsonConfig === null || packageJsonConfig === void 0 ? void 0 : packageJsonConfig.dependencies) === null || _a === void 0 ? void 0 : _a[name];
const devDependencyVersion = (_b = packageJsonConfig === null || packageJsonConfig === void 0 ? void 0 : packageJsonConfig.devDependencies) === null || _b === void 0 ? void 0 : _b[name];
const dependencyVersion = semver.coerce(prodDependencyVersion !== null && prodDependencyVersion !== void 0 ? prodDependencyVersion : devDependencyVersion);
const packageJsonFile = readFileSync(filePath, { encoding: 'utf8' });
const packageJsonConfig = parse(packageJsonFile);
const prodDependencyVersion = packageJsonConfig?.dependencies?.[name];
const devDependencyVersion = packageJsonConfig?.devDependencies?.[name];
const dependencyVersion = coerce(prodDependencyVersion ?? devDependencyVersion);
if (dependencyVersion) {
return semver.satisfies(dependencyVersion, wantedVersion);
return satisfies(dependencyVersion, wantedVersion);
}

@@ -165,2 +158,1 @@ }

}
exports.checkDependencyVersion = checkDependencyVersion;

@@ -1,5 +0,3 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const config_utils_1 = require("./config-utils");
const log_utils_1 = require("./log-utils");
import { findConfig, getConfig, modifyJSON, saveConfig } from './config-utils.js';
import { logWarning } from './log-utils.js';
/**

@@ -15,4 +13,3 @@ * Enable the following ESLint rules:

*/
function enableESLintStrict(cwd) {
var _a, _b, _c, _d, _e, _f, _g;
export async function enableESLintStrict(cwd) {
const possibleConfigFiles = ['.eslintrc.json', '.eslintrc.yaml', '.eslintrc.yml', '.eslintrc.js', 'package.json'];

@@ -24,3 +21,3 @@ const tsFilesConfig = '*.ts';

let packageJSONConfig = null;
const file = (0, config_utils_1.findConfig)(cwd, possibleConfigFiles);
const file = findConfig(cwd, possibleConfigFiles);
if (!file) {

@@ -30,3 +27,3 @@ return false;

if (file === 'package.json') {
packageJSONConfig = (0, config_utils_1.getConfig)(cwd, file);
packageJSONConfig = await getConfig(cwd, file);
if (!packageJSONConfig || !packageJSONConfig.json.eslintConfig) {

@@ -41,3 +38,3 @@ return false;

else {
config = (0, config_utils_1.getConfig)(cwd, file);
config = await getConfig(cwd, file);
}

@@ -50,7 +47,7 @@ if (!config) {

/* If there is an override, rules must be set inside it, or they won't be checked */
for (const [index, override] of Object.entries((_a = config.json.overrides) !== null && _a !== void 0 ? _a : [])) {
for (const [index, override] of Object.entries(config.json.overrides ?? [])) {
const indexNumber = Number.parseInt(index, 10);
const files = normalizeConfigToArray(override.files);
if (files.some((file) => file.includes(tsFilesConfig))) {
addTSConfig(config, ['overrides', indexNumber], (_c = (_b = config.json.overrides) === null || _b === void 0 ? void 0 : _b[indexNumber]) === null || _c === void 0 ? void 0 : _c.rules);
addTSConfig(config, ['overrides', indexNumber], config.json.overrides?.[indexNumber]?.rules);
tsConfigAdded = true;

@@ -60,5 +57,5 @@ }

const extendsConfig = normalizeConfigToArray(override.extends);
if (((_d = override.plugins) === null || _d === void 0 ? void 0 : _d.includes(eslintAngularTemplatePlugin))
if (override.plugins?.includes(eslintAngularTemplatePlugin)
|| extendsConfig.some((extendConfig) => extendConfig.includes(eslintAngularTemplatePlugin)))
addAngularHTMLConfig(config, ['overrides', indexNumber], (_f = (_e = config.json.overrides) === null || _e === void 0 ? void 0 : _e[indexNumber]) === null || _f === void 0 ? void 0 : _f.rules);
addAngularHTMLConfig(config, ['overrides', indexNumber], config.json.overrides?.[indexNumber]?.rules);
}

@@ -68,19 +65,17 @@ }

if (!tsConfigAdded) {
addTSConfig(config, [], (_g = config.json) === null || _g === void 0 ? void 0 : _g.rules);
addTSConfig(config, [], config.json?.rules);
}
if (packageJSONConfig) {
config.raw = (0, config_utils_1.modifyJSON)(packageJSONConfig.raw, ['eslintConfig'], config.json);
return (0, config_utils_1.saveConfig)(cwd, file, packageJSONConfig);
config.raw = modifyJSON(packageJSONConfig.raw, ['eslintConfig'], config.json);
return saveConfig(cwd, file, packageJSONConfig);
}
else if (file === '.eslintrc.js') {
(0, log_utils_1.logWarning)(`Your project is using the advanced .eslintrc.js format for ESLint config, and it can't be overwrited directly, as it could mess up with advanced configuration. So the new strict configuration was saved in .eslintrc.json. As .eslintrc.js has precedence over .eslintrc.json, you need to manually copy the new options from the new .eslintrc.json to your preexisting .eslintrc.js. If you know a way to automate this, please open a PR.`);
return (0, config_utils_1.saveConfig)(cwd, '.eslintrc.json', config);
logWarning(`Your project is using the advanced .eslintrc.js format for ESLint config, and it can't be overwrited directly, as it could mess up with advanced configuration. So the new strict configuration was saved in .eslintrc.json. As .eslintrc.js has precedence over .eslintrc.json, you need to manually copy the new options from the new .eslintrc.json to your preexisting .eslintrc.js. If you know a way to automate this, please open a PR.`);
return saveConfig(cwd, '.eslintrc.json', config);
}
else {
return (0, config_utils_1.saveConfig)(cwd, file, config);
return saveConfig(cwd, file, config);
}
}
exports.default = enableESLintStrict;
function checkConfig(config) {
var _a, _b, _c;
const eslintTypeScriptPlugin = '@typescript-eslint';

@@ -92,3 +87,3 @@ const eslintReactPlugin = 'react-app';

/* Case: @typescript-eslint */
if ((_a = config.plugins) === null || _a === void 0 ? void 0 : _a.includes(eslintTypeScriptPlugin))
if (config.plugins?.includes(eslintTypeScriptPlugin))
return;

@@ -104,4 +99,4 @@ /* Case: extensions */

/* Case: plugin in `overrides[x].extends` */
for (const override of (_b = config.overrides) !== null && _b !== void 0 ? _b : []) {
if ((_c = override.plugins) === null || _c === void 0 ? void 0 : _c.includes(eslintTypeScriptPlugin))
for (const override of config.overrides ?? []) {
if (override.plugins?.includes(eslintTypeScriptPlugin))
return;

@@ -115,24 +110,24 @@ const overrideExtends = normalizeConfigToArray(override.extends);

}
(0, log_utils_1.logWarning)(`ESLint must be configured with "${eslintTypeScriptPlugin}" plugin or with a tool extending it like "${eslintVuePlugin}", "${eslintReactPlugin}" or "${eslintAngularPlugin}", otherwise rules won't be checked.`);
logWarning(`ESLint must be configured with "${eslintTypeScriptPlugin}" plugin or with a tool extending it like "${eslintVuePlugin}", "${eslintReactPlugin}" or "${eslintAngularPlugin}", otherwise rules won't be checked.`);
}
function addTSConfig(config, path, rules) {
if (Array.isArray(rules === null || rules === void 0 ? void 0 : rules['@typescript-eslint/no-explicit-any'])) {
config.raw = (0, config_utils_1.modifyJSON)(config.raw, [...path, 'rules', '@typescript-eslint/no-explicit-any', 0], 'error');
if (Array.isArray(rules?.['@typescript-eslint/no-explicit-any'])) {
config.raw = modifyJSON(config.raw, [...path, 'rules', '@typescript-eslint/no-explicit-any', 0], 'error');
}
else {
config.raw = (0, config_utils_1.modifyJSON)(config.raw, [...path, 'rules', '@typescript-eslint/no-explicit-any'], 'error');
config.raw = modifyJSON(config.raw, [...path, 'rules', '@typescript-eslint/no-explicit-any'], 'error');
}
if (Array.isArray(rules === null || rules === void 0 ? void 0 : rules['@typescript-eslint/explicit-module-boundary-types'])) {
config.raw = (0, config_utils_1.modifyJSON)(config.raw, [...path, 'rules', '@typescript-eslint/explicit-module-boundary-types', 0], 'error');
if (Array.isArray(rules?.['@typescript-eslint/explicit-module-boundary-types'])) {
config.raw = modifyJSON(config.raw, [...path, 'rules', '@typescript-eslint/explicit-module-boundary-types', 0], 'error');
}
else {
config.raw = (0, config_utils_1.modifyJSON)(config.raw, [...path, 'rules', '@typescript-eslint/explicit-module-boundary-types'], 'error');
config.raw = modifyJSON(config.raw, [...path, 'rules', '@typescript-eslint/explicit-module-boundary-types'], 'error');
}
}
function addAngularHTMLConfig(config, path, rules) {
if (Array.isArray(rules === null || rules === void 0 ? void 0 : rules['@angular-eslint/template/no-any'])) {
config.raw = (0, config_utils_1.modifyJSON)(config.raw, [...path, 'rules', '@angular-eslint/template/no-any', 0], 'error');
if (Array.isArray(rules?.['@angular-eslint/template/no-any'])) {
config.raw = modifyJSON(config.raw, [...path, 'rules', '@angular-eslint/template/no-any', 0], 'error');
}
else {
config.raw = (0, config_utils_1.modifyJSON)(config.raw, [...path, 'rules', '@angular-eslint/template/no-any'], 'error');
config.raw = modifyJSON(config.raw, [...path, 'rules', '@angular-eslint/template/no-any'], 'error');
}

@@ -139,0 +134,0 @@ }

@@ -1,8 +0,6 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const config_utils_1 = require("./config-utils");
const log_utils_1 = require("./log-utils");
const typescript_strict_1 = require("./typescript-strict");
const eslint_strict_1 = require("./eslint-strict");
const angular_strict_1 = require("./angular-strict");
import { findConfig } from './config-utils.js';
import { logError, logSuccess } from './log-utils.js';
import { enableTypescriptStrict } from './typescript-strict.js';
import { enableESLintStrict } from './eslint-strict.js';
import { enableAngularStrict } from './angular-strict.js';
/**

@@ -16,21 +14,20 @@ * Enable strictly typed configurations for:

*/
function typescriptStrictlyTyped(cwd) {
export async function typescriptStrictlyTyped(cwd) {
const success = [];
if ((0, typescript_strict_1.default)(cwd)) {
if (await enableTypescriptStrict(cwd)) {
success.push('TypeScript');
}
if ((0, eslint_strict_1.default)(cwd)) {
if (await enableESLintStrict(cwd)) {
success.push('ESLint');
}
if ((0, config_utils_1.findConfig)(cwd, ['angular.json', '.angular.json', 'angular-cli.json', '.angular-cli.json'])
&& (0, angular_strict_1.default)(cwd)) {
if (findConfig(cwd, ['angular.json', '.angular.json', 'angular-cli.json', '.angular-cli.json'])
&& await enableAngularStrict(cwd)) {
success.push('Angular');
}
if (success.length === 0) {
(0, log_utils_1.logError)(`Configuration failed. Please fix the issues and run the command again.\n`);
logError(`Configuration failed. Please fix the issues and run the command again.\n`);
}
else {
(0, log_utils_1.logSuccess)(`Configuration finished. It succeeded for: ${success.join(', ')}.\n`);
logSuccess(`Configuration finished. It succeeded for: ${success.join(', ')}.\n`);
}
}
exports.default = typescriptStrictlyTyped;

@@ -1,20 +0,13 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.logInfo = exports.logError = exports.logWarning = exports.logSuccess = void 0;
const chalk = require("chalk");
function logSuccess(message) {
import chalk from 'chalk';
export function logSuccess(message) {
console.log(`\n${chalk.green(message)}`);
}
exports.logSuccess = logSuccess;
function logWarning(message) {
export function logWarning(message) {
console.log(`\n${chalk.yellow(message)}`);
}
exports.logWarning = logWarning;
function logError(message) {
export function logError(message) {
console.log(`\n${chalk.red(message)}`);
}
exports.logError = logError;
function logInfo(message) {
export function logInfo(message) {
console.log(`\n${chalk.white(message)}`);
}
exports.logInfo = logInfo;
{
"name": "typescript-strictly-typed",
"version": "2.13.1",
"version": "3.0.0",
"description": "Enable configurations for strictly typed TypeScript, ESLint, and optionally Angular.",

@@ -13,6 +13,6 @@ "funding": {

},
"type": "commonjs",
"type": "module",
"engines": {
"node": ">=12.13.0",
"npm": ">=6.12.0"
"node": ">=16.13.0",
"npm": ">=8.1.0"
},

@@ -39,6 +39,6 @@ "scripts": {

"dependencies": {
"chalk": "^4.1.2",
"chalk": "^5.2.0",
"js-yaml": "^4.1.0",
"jsonc-parser": "^3.0.0",
"pkg-up": "^3.1.0",
"pkg-up": "^4.0.0",
"semver": "^7.3.6"

@@ -48,3 +48,3 @@ },

"@types/js-yaml": "^4.0.5",
"@types/node": "^12.12.70",
"@types/node": "~16.11.0",
"@types/semver": "^7.3.9",

@@ -55,5 +55,5 @@ "@typescript-eslint/eslint-plugin": "^5.18.0",

"eslint": "^8.13.0",
"rimraf": "^3.0.2",
"typescript": "^4.6.3"
"rimraf": "^4.4.0",
"typescript": "^5.0.2"
}
}

@@ -1,5 +0,2 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const config_utils_1 = require("./config-utils");
const config_utils_2 = require("./config-utils");
import { checkDependencyVersion, findConfig, getConfig, modifyJSON, saveConfig } from './config-utils.js';
/**

@@ -19,40 +16,45 @@ * Enable the following TypeScript compiler options:

*/
function enableTypescriptStrict(cwd) {
const file = (0, config_utils_1.findConfig)(cwd, ['tsconfig.base.json', 'tsconfig.json']);
export async function enableTypescriptStrict(cwd) {
const file = findConfig(cwd, ['tsconfig.base.json', 'tsconfig.json']);
if (!file) {
return false;
}
const config = (0, config_utils_1.getConfig)(cwd, file);
const config = await getConfig(cwd, file);
if (!config) {
return false;
}
config.raw = (0, config_utils_2.modifyJSON)(config.raw, ['compilerOptions', 'strict'], true);
config.raw = (0, config_utils_2.modifyJSON)(config.raw, ['compilerOptions', 'noFallthroughCasesInSwitch'], true);
config.raw = (0, config_utils_2.modifyJSON)(config.raw, ['compilerOptions', 'noImplicitReturns'], true);
config.raw = (0, config_utils_2.modifyJSON)(config.raw, ['compilerOptions', 'forceConsistentCasingInFileNames'], true);
/*
if (checkDependencyVersion(cwd, 'typescript', '>=4.1.0')) {
config.compilerOptions.noUncheckedIndexedAccess = true;
config.raw = modifyJSON(config.raw, ['compilerOptions', 'strict'], true);
config.raw = modifyJSON(config.raw, ['compilerOptions', 'noFallthroughCasesInSwitch'], true);
config.raw = modifyJSON(config.raw, ['compilerOptions', 'noImplicitReturns'], true);
if (checkDependencyVersion(cwd, 'typescript', '>=4.2.0')) {
config.raw = modifyJSON(config.raw, ['compilerOptions', 'noPropertyAccessFromIndexSignature'], true);
}
*/
if ((0, config_utils_1.checkDependencyVersion)(cwd, 'typescript', '>=4.2.0')) {
config.raw = (0, config_utils_2.modifyJSON)(config.raw, ['compilerOptions', 'noPropertyAccessFromIndexSignature'], true);
if (checkDependencyVersion(cwd, 'typescript', '>=4.3.0')) {
config.raw = modifyJSON(config.raw, ['compilerOptions', 'noImplicitOverride'], true);
}
if ((0, config_utils_1.checkDependencyVersion)(cwd, 'typescript', '>=4.3.0')) {
config.raw = (0, config_utils_2.modifyJSON)(config.raw, ['compilerOptions', 'noImplicitOverride'], true);
if (checkDependencyVersion(cwd, 'typescript', '>=4.4.0')) {
config.raw = modifyJSON(config.raw, ['compilerOptions', 'exactOptionalPropertyTypes'], true);
}
// if (checkDependencyVersion(cwd, 'typescript', '>=4.4.0')) {
// config.raw = modifyJSON(config.raw, ['compilerOptions', 'exactOptionalPropertyTypes'], true);
// }
/* Already true by defaut since TypeScript 5.0 */
if (checkDependencyVersion(cwd, 'typescript', '<5.0.0')) {
config.raw = modifyJSON(config.raw, ['compilerOptions', 'forceConsistentCasingInFileNames'], true);
}
else {
config.raw = modifyJSON(config.raw, ['compilerOptions', 'forceConsistentCasingInFileNames'], undefined);
}
/* Available since 4.1.0 but before 5.0.0 compiler was not smart enough and thus too annoying with Records
* Still annoying with arrays, but it should not happen if using modern syntaxes */
if (checkDependencyVersion(cwd, 'typescript', '>=5.0.0')) {
config.raw = modifyJSON(config.raw, ['compilerOptions', 'noUncheckedIndexedAccess'], true);
}
/* Clean up options included in strict mode */
config.raw = (0, config_utils_2.modifyJSON)(config.raw, ['compilerOptions', 'alwaysStrict'], undefined);
config.raw = (0, config_utils_2.modifyJSON)(config.raw, ['compilerOptions', 'noImplicitAny'], undefined);
config.raw = (0, config_utils_2.modifyJSON)(config.raw, ['compilerOptions', 'noImplicitThis'], undefined);
config.raw = (0, config_utils_2.modifyJSON)(config.raw, ['compilerOptions', 'strictBindCallApply'], undefined);
config.raw = (0, config_utils_2.modifyJSON)(config.raw, ['compilerOptions', 'strictFunctionTypes'], undefined);
config.raw = (0, config_utils_2.modifyJSON)(config.raw, ['compilerOptions', 'strictNullChecks'], undefined);
config.raw = (0, config_utils_2.modifyJSON)(config.raw, ['compilerOptions', 'strictPropertyInitialization'], undefined);
config.raw = (0, config_utils_2.modifyJSON)(config.raw, ['compilerOptions', 'useUnknownInCatchVariables'], undefined);
return (0, config_utils_1.saveConfig)(cwd, file, config);
config.raw = modifyJSON(config.raw, ['compilerOptions', 'alwaysStrict'], undefined);
config.raw = modifyJSON(config.raw, ['compilerOptions', 'noImplicitAny'], undefined);
config.raw = modifyJSON(config.raw, ['compilerOptions', 'noImplicitThis'], undefined);
config.raw = modifyJSON(config.raw, ['compilerOptions', 'strictBindCallApply'], undefined);
config.raw = modifyJSON(config.raw, ['compilerOptions', 'strictFunctionTypes'], undefined);
config.raw = modifyJSON(config.raw, ['compilerOptions', 'strictNullChecks'], undefined);
config.raw = modifyJSON(config.raw, ['compilerOptions', 'strictPropertyInitialization'], undefined);
config.raw = modifyJSON(config.raw, ['compilerOptions', 'useUnknownInCatchVariables'], undefined);
return saveConfig(cwd, file, config);
}
exports.default = enableTypescriptStrict;
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