0

I have a folder structure like this

--src
   -services
      test.ts
   -pages
     -testFolder
       -testFolder.vue
--tsconfig.json

Now in the testFolder.vue i am trying to access test.ts . I wrote like this ../../services/test, this is working. Is there any possibility that i can use some thing like this ./services/test or services/test. How do i configure in tsconfig.json.

Sam
  • 2,275
  • 9
  • 30
  • 53
  • https://stackoverflow.com/questions/43281741/how-to-use-paths-in-tsconfig-json I haven't tried it but I hope this will help you. – hazib Aug 27 '18 at 09:28

1 Answers1

0

Use baseUrl:

{
  "compilerOptions": {
    "baseUrl": "./src"
  }
}

This way when you use absolute paths (like services/test), it will look in the folder ./src.

sroes
  • 14,663
  • 1
  • 53
  • 72
  • This is working thanks. Is there any other way, i have line in webpack `'@': resolve('src')` . so if i use @/services/test working while building, but it is not in parallel with tsconfig. Is there any possibility that i can config in tsconfig.js to go with @/services/... – Sam Aug 27 '18 at 11:54
  • is this possible in tsconfig.js, or do i need to change it in the webpack only? why i want to change it in the tsconfig.js because in my project the paths and all are started with @/... . – Sam Aug 27 '18 at 12:03
  • Try adding `"paths: {"@/*": ["src/*"]}` to the compilerOptions in your tsconfig – sroes Aug 27 '18 at 12:57