Skip to content
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

Add separate compiler option for generated declarations output directory. #6723

Closed
ylepikhov opened this issue Jan 29, 2016 · 9 comments
Closed
Labels
Fixed A PR has been merged for this issue Good First Issue Well scoped, documented and has the green light Help Wanted You can do this Suggestion An idea for TypeScript

Comments

@ylepikhov
Copy link

I need to make an automated building of my typescript projects. Typescript compilation results (i.e .js and .d.ts files) need further separate processing.

It would be nice if there is separate compilation option to specify output directory for generated declarations. Something like this:

//tsconfig.json
{
  "CompilerOptions": {
    ...
      "declaration": true,
      "declarationDir": "target/typings"
    ...
  }
}```
@RyanCavanaugh RyanCavanaugh added Suggestion An idea for TypeScript In Discussion Not yet reached consensus labels Jan 29, 2016
@RyanCavanaugh RyanCavanaugh added Help Wanted You can do this Good First Issue Well scoped, documented and has the green light and removed In Discussion Not yet reached consensus labels Feb 1, 2016
@RyanCavanaugh
Copy link
Member

Didn't come up with a name, but we'd take a PR on this. Should be easy enough.

@masaeedu
Copy link
Contributor

masaeedu commented Feb 5, 2016

@RyanCavanaugh I think I've narrowed it down to some fooling around that needs to be done here: https://github.com/Microsoft/TypeScript/blob/a324176102b4657b4de6759b5d03f5eeda38f422/src/compiler/utilities.ts#L2070. Some questions though...

What organization should be followed inside the declarations folder? Do I just remove the .js from a file, snip the path relative to the outDir or project root (whichever comes first), and plant that relative to the declarationDir?

Also, how would I write a test to check where declaration files end up?

@mhegazy
Copy link
Contributor

mhegazy commented Feb 6, 2016

the logic should map to that of --outDir today. for tests just add compliler tests, with flags as "@" comments (see https://github.com/Microsoft/TypeScript/blob/master/tests/cases/compiler/outModuleConcatAmd.ts) the output will have the file name in it

@masaeedu
Copy link
Contributor

masaeedu commented Feb 9, 2016

@mhegazy It seems the generated JS file from the test doesn't contain any artifact that lets you see where the file ends up relative to the project root. E.g. the JS file generated for the following test:

// @allowJs: true,map
// @sourcemap: true
// @outdir: out

// @filename: a.ts
class c {
}

// @filename: b.js.map
function foo() {
}

// @filename: b.js
function bar() {
}

is:

//// [tests/cases/compiler/jsFileCompilationWithMapFileAsJsWithOutDir.ts] ////

//// [a.ts]

class c {
}

//// [b.js.map]
function foo() {
}

//// [b.js]
function bar() {
}

//// [a.js]
var c = (function () {
    function c() {
    }
    return c;
}());
//# sourceMappingURL=a.js.map

There's no mention of the out directory specified in the outDir option. I was expecting something like //// [out/a.js]. Is there a good way to write a test for this?

@masaeedu
Copy link
Contributor

@mhegazy Thanks. This is slightly off topic, but it looks like the test harness stops emitting as soon as it detects a single difference between the local and reference baselines. This means you have to run the testcase until it chokes, copy the mismatched file to the reference folder, run it again until it finds the next difference, and so on. Is this by design?

@RyanCavanaugh
Copy link
Member

@masaeedu the tests keep running when they detect differences. Afterwards you can run jake baseline-accept to move the new baselines from local to reference automatically.

@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Feb 24, 2016
@mhegazy mhegazy added this to the TypeScript 2.0 milestone Feb 24, 2016
@ca0v
Copy link

ca0v commented Mar 31, 2016

I couldn't figure it out from reading the above comments but will there be a similar "declarationOutFile" which will concatenate all the definitions into one? Something akin to what https://github.com/SitePen/dts-generator is doing?

@masaeedu
Copy link
Contributor

@ca0v There isn't a declarationOutFile yet (although this was discussed on the PR). You can file an issue if you need it.

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Fixed A PR has been merged for this issue Good First Issue Well scoped, documented and has the green light Help Wanted You can do this Suggestion An idea for TypeScript
5 participants