Microsoft/TypeScript

Report error if code precedes /// reference

Open

#1.920 geöffnet am 4. Feb. 2015

Auf GitHub ansehen
 (9 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)TypeScript (6.726 Forks)batch import
BugDomain: Something ElseHelp Wanted

Repository-Metriken

Stars
 (48.455 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 6T 17h) (9 gemergte PRs in 30 T)

Beschreibung

a.ts:

'use strict'
/// <reference path='b.d.ts'/>

var x: Foo;

b.d.ts:

interface Foo { x: string; }
declare module "b" {
        export = Foo;
}
D:\test\refs\a> tsc a.ts
a.ts(4,8): error TS2304: Cannot find name 'Foo'.

There's no mention in section 11.1.1 of the spec that /// references must be the first thing in a file in order to work, although I do remember us deciding that was the case at one point. If that is the rule we should update the spec appropriately. We should also add an error to the compiler or else you may spend awhile trying to figure this out since we don't provide much (read: anything) in the way of diagnostics for debugging reference resolution.

Contributor Guide