Skip to content

after compile .d.ts files will not be included in build (outDir) folder #5112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
stepancar opened this issue Oct 5, 2015 · 11 comments
Closed
Labels
Question An issue which isn't directly actionable in code

Comments

@stepancar
Copy link

Hello.
i have typescript project.
it contains autogenerated from .net interfaces.
file has .d.ts extension and contains in tsconfig.json
after compile in outDir i have js, d.ts for my source but i havnt autogenerated.d.ts
Why d.ts is not included in compilation result?

I think, each d.ts files should be included in outDir according project sources tree

@danquirk
Copy link
Member

danquirk commented Oct 5, 2015

The .d.ts files you use are an input to the build system but not an output. It's perfectly reasonable to consume some types from a .d.ts but have your output not use those types, so there'd be no reason to distribute the input .d.ts with your build results. It sounds like you'll want a post-build step in your build tool to copy the relevant .d.ts files wherever you need them.

@danquirk danquirk added the Question An issue which isn't directly actionable in code label Oct 5, 2015
@stepancar
Copy link
Author

@danquirk , thank you for your answer! I have in serverModels.d.ts declarations of server models. In my projects i use this declarations for checking translation from client models to server models.
d.ts participates in project type checking. Imagine that project which i described is npm module, which contains api-services. In another typescript code i will import this one apiservice from package described before.
api service returns server models, described in serverModels.d.ts, but after compile d.ts has not was copyed to putput of package, and it not available. Yep, i can use grunt, gulp for copy, but i think that its compile problem. exported d.ts can relates to serverModels.d.ts, which is not in output dir, it means out tree of d.ts is not correct

@stepancar
Copy link
Author

@danquirk, @RyanCavanaugh, @basarat, Can you help me to solve my problem? Or maybe I should provide you repo with example?
Thank you!

@mhegazy
Copy link
Contributor

mhegazy commented Oct 7, 2015

The .d.ts files are considered "references" the compiler will not touch them, not move them, or recreate them. the only thing it will do, if you have a /// <reference > to an input.d.ts, the generated output will have the reference rewritten to point to the source location.
An easy way to think of the .d.ts files is that they go along with your .js files. if you are copying the .js files, you should copy the matching .d.ts.

@basarat
Copy link
Contributor

basarat commented Oct 7, 2015

what he said ^ .d.ts are not moved around -> by design 🌹

There are reasons why I feel this is good ... e.g. one would not want node.d.ts to be moved around ... its just an ambient ref, that any module consumer should include themselves if they need it.

@stepancar
Copy link
Author

Thank you!

@vsarunov
Copy link

Is there a workaround to include custom typings files? For instance I have a custom main.d.ts file with interfaces:

interface s1 {
  ...
}

interface s2 {
....
}

interface s3 {
...
}

I have a main file index.ts which is refered in the package.json file:

import t1=require('...');
import t2=require('..');

export{
t1,
t2
}

if I add to it tripple slash references the generated d.ts file for it will change it references to refer to the source. How can I include the custom d.ts files and still have the correct references (without manually changing the generated files and without manually dragging and dropping custom d.ts files.

@mhegazy
Copy link
Contributor

mhegazy commented Mar 10, 2017

Add the file in your tsconfig.json in the "include" section.

@vsarunov
Copy link

vsarunov commented Mar 13, 2017

No, it is not being included. I have read the documentation and read all the responses on github and stackoverflow concerning this topic, if I specify only the d.ts file nothing gets compiled, if I specify both files (the main entry point file and the d.ts file) it compiles, but still the d.ts file is not included.

Update: Found a way around.

@JonWallsten
Copy link

@vsarunov If you found a way around please publish it here for others to find.

@motss
Copy link

motss commented Mar 29, 2018

When include does not include in the compilation, it sounds very ironic to me.

@microsoft microsoft locked and limited conversation to collaborators Jul 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Question An issue which isn't directly actionable in code
Projects
None yet
Development

No branches or pull requests

7 participants