==== tests/cases/compiler/variableDeclaratorResolvedDuringContextualTyping.ts (3 errors) ==== module WinJS { export interface ValueCallback { (value: any): any; } export interface EventCallback { (value: any): void; } export interface ErrorCallback { (error: any): any; } export interface ProgressCallback { (progress: any): any; } export declare class Promise { constructor(init: (complete: ValueCallback, error: ErrorCallback, progress: ProgressCallback) => void, oncancel?: any); static as(value: any): Promise; static join(promises: { [name: string]: Promise; }): Promise; static join(promises: Promise[]): Promise; static any(promises: Promise[]): Promise; static timeout(delay: number): Promise; static wrapError(error: any): Promise; static is(value: any): boolean; static addEventListener(type: string, fn: EventCallback); public then(success?: ValueCallback, error?: ErrorCallback, progress?: ProgressCallback): Promise; public done(success?: ValueCallback, error?: ErrorCallback, progress?: ProgressCallback): void; public cancel(): void; } export declare class TPromise { constructor(init: (complete: (value: V) => void, error: (err: any) => void, progress: ProgressCallback) => void, oncancel?: any); public then(success?: (value: V) => TPromise, error?: (err: any) => TPromise, progress?: ProgressCallback): TPromise; public then(success?: (value: V) => TPromise, error?: (err: any) => U, progress?: ProgressCallback): TPromise; public then(success?: (value: V) => U, error?: (err: any) => TPromise, progress?: ProgressCallback): TPromise; public then(success?: (value: V) => U, error?: (err: any) => U, progress?: ProgressCallback): TPromise; public done(success?: (value: V) => void, error?: (err: any) => any, progress?: ProgressCallback): void; public cancel(): void; public static as(value: ValueType): TPromise; public static timeout(delay: number): TPromise; public static join(promises: TPromise[]): TPromise; public static any(promises: TPromise[]): TPromise; public static wrapError(error: any): TPromise; } export interface IXHROptions { type?: string; url?: string; user?: string; password?: string; responseType?: string; headers?: any; customRequestInitializer?: (req: any) => void; data?: any; } } module Services { export interface IRequestService { /** * Returns the URL that can be used to access the provided service. The optional second argument can * be provided to narrow down the request URL to a specific file system resource. The third argument * allows to specify to return a fully absolute server URL. */ getRequestUrl(service: string, path?: string): string; getRequestUrl(service: string, path?: string, absolute?: boolean): string; /** * Wraps the call into WinJS.XHR to allow for mocking and telemetry. Use this instead * of calling WinJS.XHR directly. */ makeRequest(options: WinJS.IXHROptions): WinJS.Promise; } } module Errors { export class ConnectionError /* extends Error */ { constructor(request: XMLHttpRequest) { } } } module Files { export interface IUploadResult { stat: string; isNew: boolean; } } interface XMLHttpRequest { status: number; responseText: string; statusText: string; } class FileService { private requestService: Services.IRequestService; public uploadData(): WinJS.TPromise { var path = ""; return this.requestService.makeRequest({ url: this.requestService.getRequestUrl('root', path), type: 'POST', headers: {}, data: "someData" }).then((response: XMLHttpRequest) => { var result: IUploadResult = { // This should be error ~~~~~~~~~~~~~ !!! Cannot find name 'IUploadResult'. stat: this.jsonToStat(newFilePath, "someString"), // _this needs to be emitted to the js file ~~~~~~~~~~ !!! Property 'jsonToStat' does not exist on type 'FileService'. ~~~~~~~~~~~ !!! Cannot find name 'newFilePath'. isNew: response.status === 201 }; return WinJS.TPromise.as(result); }, (xhr: XMLHttpRequest) => { return WinJS.Promise.wrapError(new Errors.ConnectionError(xhr)); }); } }