Home > Back-end >  Configure true absolute imports in TypeScript
Configure true absolute imports in TypeScript

Time:01-31

import foo from '/foo';

should import {sourceRoot}/foo

where sourceRoot is {pwd}/src

Is it possible to do this via tsconfig.json?

CodePudding user response:

Adding this to tsconfig should work:

    "paths": {
        "/*": [ "./src/*" ]
    },

Based on this comment https://github.com/microsoft/TypeScript/issues/47646#issuecomment-1024456182

  •  Tags:  
  • Related