CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-cra-template-typescript

The official TypeScript template for Create React App providing preconfigured TypeScript support and development environment setup.

Overall
score

98%

Overview
Eval results
Files

task.mdevals/scenario-6/

CRA Strict Config Guardian

Create a utility that inspects a TypeScript configuration file and reports whether it still matches the strict defaults generated by cra-template-typescript.

The CRA defaults to enforce include: target: "es5", lib: ["dom", "dom.iterable", "es6"], allowJs: true, skipLibCheck: true, esModuleInterop: true, allowSyntheticDefaultImports: true, strict: true, forceConsistentCasingInFileNames: true, noFallthroughCasesInSwitch: true, module: "esnext", moduleResolution: "node", resolveJsonModule: true, isolatedModules: true, noEmit: true, jsx: "react-jsx", and include: ["src"].

Capabilities

Reports CRA match

  • When given a tsconfig.json with exactly the CRA TypeScript defaults above, the validator returns a pass state with empty missing/mismatched lists and a summary that mentions CRA defaults are intact. @test

Flags strict deviations

  • If any listed default is missing or set to a different value (for example, strict flipped to false or lib missing dom.iterable), the validator returns fail with explicit option names and expected vs actual values for each deviation. @test

Ignores extras

  • Additional custom options not in the CRA default set (such as baseUrl or paths) do not trigger a failure; they are captured separately in an extras list while status stays pass when defaults are unchanged. @test

Generates corrected config

  • Produces a corrected configuration object that re-applies CRA defaults for only the deviating options while preserving unrelated entries, and reports which options were corrected. @test

Implementation

@generates

API

export type CraStrictOption =
  | 'target'
  | 'lib'
  | 'allowJs'
  | 'skipLibCheck'
  | 'esModuleInterop'
  | 'allowSyntheticDefaultImports'
  | 'strict'
  | 'forceConsistentCasingInFileNames'
  | 'noFallthroughCasesInSwitch'
  | 'module'
  | 'moduleResolution'
  | 'resolveJsonModule'
  | 'isolatedModules'
  | 'noEmit'
  | 'jsx'
  | 'include';

export interface CraDefaults {
  compilerOptions: {
    target: 'es5';
    lib: ['dom', 'dom.iterable', 'es6'];
    allowJs: true;
    skipLibCheck: true;
    esModuleInterop: true;
    allowSyntheticDefaultImports: true;
    strict: true;
    forceConsistentCasingInFileNames: true;
    noFallthroughCasesInSwitch: true;
    module: 'esnext';
    moduleResolution: 'node';
    resolveJsonModule: true;
    isolatedModules: true;
    noEmit: true;
    jsx: 'react-jsx';
  };
  include: ['src'];
}

export interface ValidationIssue {
  option: CraStrictOption;
  expected: unknown;
  actual: unknown;
}

export interface ValidationResult {
  status: 'pass' | 'fail';
  missing: CraStrictOption[];
  mismatched: ValidationIssue[];
  extras: string[];
  summary: string;
}

export function loadCraStrictDefaults(): CraDefaults;
export function validateTsconfig(configPath: string): ValidationResult;
export function correctedConfig(configPath: string): {
  corrected: Record<string, unknown>;
  correctedOptions: CraStrictOption[];
};

Dependencies { .dependencies }

cra-template-typescript { .dependency }

Provides the CRA TypeScript template and its strict tsconfig defaults.

Install with Tessl CLI

npx tessl i tessl/npm-cra-template-typescript

tile.json