0.9.1 compiler crash

Topics: General
Aug 7, 2013 at 12:23 PM
After migrating from 0.8.3.1 to 0.9.1 and resolving all the breaking changes I get a compiler crash:

VSTSC : tsc.js(29052, 13) Microsoft JScript runtime error : Unable to get value of the property 'flags': object is null or undefined

Looking at line 29052 in tsc.js I see it has something to do with Ambient. Anybody has any advise on how I go about debugging this?
Aug 7, 2013 at 3:12 PM
Issue has been raised here
Aug 7, 2013 at 3:17 PM
Try the following:
  • In Visual Studio expand the project that is failing to build.
  • Expand all folders containing TypeScript files.
  • Select a group of files by clicking on the first file, holding down shift then clicking on the last file.
  • Right click on the selected files and select "Properties".
  • Change the "Build Action" from "TypeScriptCompile" to "None".
  • Build the project to see if you are still getting the error.
  • Keep repeating this process until you have identified the offending file.
  • Drill down into the offending file in order to determine the exact circumstances under which the compiler crashes.
Aug 7, 2013 at 4:15 PM
Edited Aug 7, 2013 at 4:18 PM
Thanks nabog, I managed to find the culprit using your advise.
The compiler crashed on the following function:

export function requestUpdate(model: IData, selector?: (model: IData) => IData) {
    var deferred = $.Deferred<{ d: IData; }>(),
        selector = selector || (model: IData) => {
            var result = <IData>$.extend({}, model);
            delete result.__metadata;
            return result;
        };
    OData.request({
        requestUri: model.__metadata.uri,
        method: "POST",
        data: selector(model),
        headers: {
            "If-Match": model.__metadata.etag,
            "X-HTTP-Method": "MERGE"
        }
    }, (data, response) => {
            model.__metadata.etag = response.headers.ETag;
            deferred.resolve({ d: model });
        }, deferred.reject);
    return deferred.promise();
}
I remember promoting the selector variable to a parameter some time ago, but forgot to remove the variable declaration for it in the function body. This was no problem with TypeScript 0.8.3.1, but it crashes the TypeScript 0.9.1 compiler.
The fix is:

export function requestUpdate(model: IData, selector?: (model: IData) => IData) {
    var deferred = $.Deferred<{ d: IData; }>();
    selector = selector || (model: IData) => {
        var result = <IData>$.extend({}, model);
        delete result.__metadata;
        return result;
    };
    OData.request({
        requestUri: model.__metadata.uri,
        method: "POST",
        data: selector(model),
        headers: {
            "If-Match": model.__metadata.etag,
            "X-HTTP-Method": "MERGE"
        }
    }, (data, response) => {
            model.__metadata.etag = response.headers.ETag;
            deferred.resolve({ d: model });
        }, deferred.reject);
    return deferred.promise();
}
Coordinator
Aug 7, 2013 at 8:43 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.