Skip to content

version 1.1.0.0: misleading error for incorrectly referenced interface #722

Closed

Description

@psnider

I just installed the 1.1.0.0 tsc compiler, and found a misleading error message, in which the compiler indicates that an existing symbol doesn't exist.

I work with external modules, so this minimal example has two files:

Envelope.d.ts:

declare module 'Envelope' {
    export interface IEnvelope {
        get() : string;
    }

    export class Envelope implements IEnvelope {
        get() : string;
    }
}

and Letter.ts. Note that Letter.ts has an error on line 4: Envelope refers to the class, but this line should instead refer to Envelope_module.

/// <reference path='Envelope.d.ts' />
import Envelope_module  = require('Envelope');
import Envelope      = Envelope_module.Envelope;
export class Letter implements Envelope.IEnvelope {
    get() : string {return 'something'}
}

When I run the 1.1.0.0 compiler:

tsc --module commonjs Letter.ts

The compiler issues this error:

Letter.ts(4,32): error TS2304: Cannot find name 'Envelope'.

However, Envelope definitely exists. It is Envelope.IEnvelope that doesn't exist.

(Upon changing Letter.ts#4 to reference Envelope_module.IEnvelope, the file compiles cleanly.)

Activity

  1. added
    In Discussion
    Suggestion
    on Sep 22, 2014
  2. RyanCavanaugh commented on Sep 22, 2014

    @RyanCavanaugh
    Member

    The error is technically correct (the worst kind of correct for an error message) -- when you have a dotted identifier in a type position (Envelope.IEnvelope), the things to the left of the final dot are known to be "namespace" identifiers. There isn't a namespace named Envelope in scope, only values and types.

    A possible improvement on our side is to either tell you that we found some non-namespace thing called Envelope, or to be more clear and say "Cannot find namespace 'Envelope'" to give you some better clue as to what's going on.

  3. psnider commented on Sep 22, 2014

    @psnider
    Author

    Thanks for the explanation.
    The second option seems clearer to me: "Cannot find namespace 'Envelope'".
    The first is less clear to me, perhaps because I think of a class as a type of namespace.

  4. DanielRosenwasser commented on Apr 21, 2015

    @DanielRosenwasser
    Member

    Can we mark this as "Accepting PRs"?

    Also, #102 is almost the dual of this issue; perhaps any changes that address this should address that as well.

  5. RyanCavanaugh commented on Apr 27, 2015

    @RyanCavanaugh
    Member

    Mistagged

  6. niemyjski commented on Apr 28, 2015

    @niemyjski

    +1

  7. mhegazy commented on May 6, 2015

    @mhegazy
    Contributor
  8. added
    Fixed
    on May 6, 2015
  9. added this to the milestone on May 6, 2015
  10. locked and limited conversation to collaborators on Jun 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixedSuggestion

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions