TypeScript Compiler Options

rewriteRelativeImportExtensions — TypeScript compiler option

Rewrites eligible relative TypeScript-extension specifiers to corresponding JavaScript extensions. Does not rewrite bare package aliases or arbitrary paths mappings. Default (5.8.3): false. Create the labeled files in an isolated local project and run tsc -p tsconfig.json. Expected: no diagnostics; emitted files: main.js, value.js. Run node main.js; expected stdout: '7'. Local multi-file fixture, not a single-file editor.

Formal Syntax & Structure

typescript syntaxtypescript
{  "compilerOptions": {    "rewriteRelativeImportExtensions": true  }}

Parameters & Attributes

NameTypeDescription
rewriteRelativeImportExtensionsbooleanSet in compilerOptions; default: false.

Working Example

Example Snippettypescript
// File: tsconfig.json (omit this label){  "compilerOptions": {    "target": "ES2022",    "module": "CommonJS",    "strict": true,    "types": [],    "noEmitOnError": true,    "rewriteRelativeImportExtensions": true  },  "files": [    "main.ts"  ]}// File: main.tsimport { value } from "./value.ts"; console.log(value);// File: value.tsexport const value = 7;
TypeScript Reference