Skip to content

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

Closed
@mihailik

Description

@mihailik

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions