Skip to content

Add declarationDir option #7170

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

Merged
merged 7 commits into from
Feb 24, 2016
Merged

Conversation

masaeedu
Copy link
Contributor

Fixes #6723.

export function getDeclarationEmitOutputFilePath(sourceFile: SourceFile, host: EmitHost) {
const options = host.getCompilerOptions();
const outputDir = options.declarationDir || options.outDir; // Prefer declaration folder if specified
return options.declaration ? removeFileExtension(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turn this into an if and add a newline above.

@DanielRosenwasser
Copy link
Member

We have a function verifyCompilerOptions in program.ts. Can you add a line for "declarationDir" and "declaration" with Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1?

@masaeedu
Copy link
Contributor Author

@DanielRosenwasser Ok, done. I should mention that I wasn't sure what the expected behavior for declarationDir is when outFile or out are specified. Right now the behavior is to simply create a declaration file adjacent to the bundled JS file, regardless of whether the declarationDir option is specified. Possible alternative behaviors would be:

  • Produce an error when verifying options if declarationDir is specified alongside out or outFile
  • Produce the bundled declaration file in the path specified by declarationDir

Let me know if either of those are what's needed.

@masaeedu masaeedu force-pushed the addDeclarationDirOption branch from d1d6169 to 75a70d9 Compare February 20, 2016 22:52
@DanielRosenwasser
Copy link
Member

I think that if --declarationDir was specified separately from --outFile or --out, that was probably intentional and should be respected independently.

@@ -107,7 +107,7 @@ namespace Harness.LanguageService {
}
}

class DefaultHostCancellationToken implements ts.HostCancellationToken {
export class DefaultHostCancellationToken implements ts.HostCancellationToken {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need these exported?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't reproduce this anymore, but I was getting compile errors concerning the visibility of these classes. I might have brainfarted and forgot to jake local before jake tests. I'll pull this commit out.

@masaeedu masaeedu force-pushed the addDeclarationDirOption branch from 75a70d9 to 05e1a32 Compare February 23, 2016 20:25
@masaeedu
Copy link
Contributor Author

Okay, I've pulled out the test harness changes and made specifying declarationDir alongside out or outFile invalid per @mhegazy's instructions

@masaeedu
Copy link
Contributor Author

Looks like there's linter errors on lines 242, 243 of tsc.ts. I haven't touched that file, and running the tests locally seems to pass. I think the offending whitespace was introduced in 54ae270 @mhegazy

@RyanCavanaugh
Copy link
Member

Lint PR #7202 going to wait for CI to pass :)

programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "declarationDir", "declaration"));
}
if (options.out || options.outFile) {
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "declarationDir", options.out ? "out" : options.outFile));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"outFile" instead of options.outFile

@mhegazy
Copy link
Contributor

mhegazy commented Feb 23, 2016

one small typo. other than that LGTM

@masaeedu masaeedu force-pushed the addDeclarationDirOption branch from 05e1a32 to f251768 Compare February 23, 2016 22:46
@masaeedu
Copy link
Contributor Author

@mhegazy Whoops. Fixed

@mhegazy
Copy link
Contributor

mhegazy commented Feb 24, 2016

Thanks!

mhegazy added a commit that referenced this pull request Feb 24, 2016
@mhegazy mhegazy merged commit 0f67f4b into microsoft:master Feb 24, 2016
@masaeedu masaeedu deleted the addDeclarationDirOption branch February 25, 2016 03:25
@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
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants