New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

typescript-transform-extensions

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typescript-transform-extensions

Transforms import and export extensions for compatibility with native ES Modules

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

typescript-transform-extensions

npm version code style: prettier

Transforms imports to include the file extension of the resolved import, necessary for ES Modules.

This TypeScript plugin is helpful along with typescript-transform-paths. This plugin was inspired by typescript-transform-paths, thank you for all of your hard work!

Usable with ttypescript or ts-patch

Install

npm:

npm i -D typescript-transform-extensions

yarn:

yarn add -D typescript-transform-extensions

Example Config

Add it to plugins in your tsconfig.json

{
  "compilerOptions": {
    "plugins": [
      {
        "transform": "typescript-transform-extensions",
        "extensions": {".ts": ".js"}
      }
    ]
  }
}

Example output

- dest/
  - path/
    - to/
      -import/
        - file.js
  - subdir/
    - main.js

- src/
  - path/
    - to/
      -import/
        - file.ts
  - subdir/
    - main.ts

src/path/to/import/file.ts

export function sum2(first: number, second: number) {
  return first + second;
}

src/subdir/main.ts

import {sum2} from "../path/to/import/file";

sum2(2, 3);

Gets compiled to:

If compilerOptions.module is "CommonJS"

dest/subdir/main.js

var sum_1 = require("../path/to/import/file.js");
sum_1.sum2(2, 3);

If compilerOpions.module is "ES2015", "ES2020", "ES6", or "ESNext"

dest/subdir/main.js

import {sum2} from "../path/to/import/file.js";
sum2(2, 3);

Contributting

Contributions are welcome!

  • make sure to format code with prettier:
npm run format

Keywords

typescript

FAQs

Package last updated on 30 Oct 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts