Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

255
Views
How to Export SVG Icons from TypeScript Library

Goal

I'm working on a proof of concept project where the goal is to create an NPM package with TypeScript which exports custom SVG icons. The library is to only export the raw SVG's themselves, and not as a [framework] component.

Problem

Right now, I am receiving various TypeScript errors, either about an export not existing, or the library not having been typed correctly. Because there's not one specific problem, I am hoping to share some of my configurations for someone more familiar with this tooling to hopefully help.

I'm not very strong with tooling, so I am not sure where the disconnect is with

  • Exporting the SVG icons to be imported by the end user
  • Creating the proper type declarations for the library

Configuration

package.json

{
  ...
  "module": "dist/index.js",
  "types": "dist/index.d.ts",
  "scripts": {
    "build": "tsc",
  }
}

tsconfig.json

{
  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "baseUrl": "src",
    "declaration": true,
    "esModuleInterop": true,
    "isolatedModules": true,
    "lib": ["dom", "dom.iterable", "esnext"],
    "module": "esnext",
    "moduleResolution": "node",
    "outDir": "dist",
    "resolveJsonModule": true,
    "skipLibCheck": true,
    "target": "es5"
  },
  "include": ["src", "global.d.ts"]
}

global.d.ts

declare module '*.svg' {
  const content: string;
  export default content;
}

src/index.ts

import TestIcon from "./svg/test.svg";
import ArrowThinLeft from "./svg/arrow-thin-left.svg";

export { TestIcon, ArrowThinLeft };

Thanks for taking a look :)

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!