#How to configure rootDirs for multiple directories?

27 messages · Page 1 of 1 (latest)

vapid kernel
#

Hello,

I need to define rootDirs so .d.ts seems to be collocated with .js file, which it would type check. So I've set:

{
    "compilerOptions": {
        "rootDirs": [ "src/**/", "src/**/types/" ]
    }
}

I think ** causes problems, because I have two different folders and structures I need to match with two different folders containing types.

E.g.

/src/v1/ -> /src/v1/types/
/src/v2/ -> /src/v2/types/

Would it be possible? I don't want ./src/v1/ and ./src/v2/types/ to match. I really need only v1/ and v1/types/ to look like they are in same folder (like if there is symlink).

#

ExpressJS Type Decorators to type returned object and configuration of rootDirs.

vapid kernel
#

How to configure rootDirs for multiple directories?

minor valley
#

But those are all in the same folder...

#

"rootDir": "src"

#

Your imports are using relative paths or no?

#

Or you want imports from v1 only to match things in v1/types, but you want the output merged into a single folder? Probably could do that with a post build step - just a single file copy operation.

vapid kernel
# minor valley `"rootDir": "src"`

I'm configuring rootDirs not rootDir... I need virtually to make typescript see structure:

./src/v1/file.js
./src/v1/file.d.ts

When real FS structure is:

./src/v1/file.js
./src/v1/types/file.d.ts
minor valley
#

hmm

vapid kernel
minor valley
#

so you have

src/v1/file.js
src/v1/types/file.d.ts
src/v2/files.js
src/v2/types/file.d.ts

?

#

seems like it would work if you had

src/v1/file.js
src/types/v1/file.d.ts
src/v2/files.js
src/types/v2/file.d.ts

no?

#

Also, unclear why you have .js and .d.ts in your TS source files? What are you using TS for?

vapid kernel
#

It doesn't work, my .src/v1/file.js doesn't see ./src/v1/types/file.d.ts and get's type "any".

minor valley
#

yeah but you added src/types not src/v1/types

#

and if you add src/v1/types and src/v2/types it will merge them together

#

so can you put v1 and v2 folders in types?

minor valley
#

-v1
---types
-v2
---types

-v1
-v2
-types
---v1
---v2

vapid kernel
minor valley
#

I don't think what you want is supported

vapid kernel
#

types are always generated inside v1 and v2 dirs

#

I'm sure it is... nearly same way works sveltekit and it works fine there.

minor valley
#

you could use separate tsconfigs and make 2 projects

vapid kernel
#

That's not possible. They depends on each other and need to be in one project.

minor valley
#

Alright. Good luck

vapid kernel