Skip to content

createDiagnosticCollection should be @internal, or DiagnosticCollection should not be #2268

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
mihailik opened this issue Mar 9, 2015 · 2 comments
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@mihailik
Copy link
Contributor

mihailik commented Mar 9, 2015

Generated definitions in bin/typescriptServices_internal.d.ts are invalid, causing compilation error if used:

typescriptServices_internal.d.ts 2304 @272:43 Cannot find name 'DiagnosticCollection'

declare module ts {
    // ...
    function createDiagnosticCollection(): DiagnosticCollection;

This is because DiagnosticCollection is defined with @internal flag in src/compiler/types.ts:

module ts {
    // ...

    // @internal
    export interface DiagnosticCollection {
        // Adds a diagnostic to this diagnostic collection.
        add(diagnostic: Diagnostic): void;

        // Gets all the diagnostics that aren't associated with a file.
        getGlobalDiagnostics(): Diagnostic[];

        // If fileName is provided, gets all the diagnostics associated with that file name.
        // Otherwise, returns all the diagnostics (global and file associated) in this colletion.
        getDiagnostics(fileName?: string): Diagnostic[];

        // Gets a count of how many times this collection has been modified.  This value changes
        // each time 'add' is called (regardless of whether or not an equivalent diagnostic was
        // already in the collection).  As such, it can be used as a simple way to tell if any
        // operation caused diagnostics to be returned by storing and comparing the return value 
        // of this method before/after the operation is performed.
        getModificationCount(): number;
    }

The interface looks internal enough, so I guess ts.createDiagnosticCollection() function should go under the internal flag together with the interface.

Also there need to be tests for the validity of all the generated d.ts files, shouldn't there?

@mihailik
Copy link
Contributor Author

mihailik commented Mar 9, 2015

I've added a separate issue #2269 for generatedfiles.d.ts validity tests.

@mihailik
Copy link
Contributor Author

mihailik commented Mar 9, 2015

The createDiagnosticCollection is defined in src/compiler/utilities.ts and used only in one place in src/compiler/program.ts:

    export function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program {
        var program: Program;
        var files: SourceFile[] = [];
        var filesByName: Map<SourceFile> = {};
        var diagnostics = createDiagnosticCollection();  //  <--- here you go
        var seenNoDefaultLib = options.noLib;

@danquirk danquirk added the Bug A bug in TypeScript label Mar 9, 2015
mhegazy added a commit that referenced this issue Mar 10, 2015
Fix for #2268 createDiagnosticCollection should be @internal
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Mar 11, 2015
@mhegazy mhegazy added this to the TypeScript 1.5 milestone Mar 11, 2015
@mhegazy mhegazy closed this as completed Mar 11, 2015
@microsoft microsoft locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

3 participants