Skip to content

Use private TypeScript APIs from internal module #314

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 2 commits into from
Oct 20, 2016

Conversation

christopherthielen
Copy link
Contributor

@christopherthielen christopherthielen commented Oct 20, 2016

Do not expose the private TypeScript APIs by augmenting the "typescript" module. Modifying the declarations of the "typescript" module causes problems when attempting to use TypeDoc programmatically (for building plugins, etc) because the

No longer augment the "typescript" module's typings to expose private APIs being used by TypeDoc (like this):

// no longer do this
declare module "typescript" {
  function somePrivateTypeScriptApi();
}

Instead, create a ES6 module in TypeDoc which has passthroughs to the private TypeDoc API.

import * as ts from "typescript";
const tsany = ts as any;

export function somePrivateTypeScriptApi() {
  return tsany.somePrivateTypeScriptApi.apply(this, arguments);
}

Elsewhere, import the passthrough APIs from the internal ES6 module.

import * as _ts from "../ts-internal";

var result = _ts.somePrivateTypeScriptApi();

@blakeembrey blakeembrey merged commit 0867cc2 into TypeStrong:master Oct 20, 2016
@aciccarello
Copy link
Collaborator

I just want to note (if I remember correctly) that this PR was made in response to comments in #310

@aciccarello aciccarello mentioned this pull request Aug 17, 2018
@christopherthielen christopherthielen deleted the tsinternal branch August 18, 2018 00:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants