Tapuscrit - TypeError myclass.myFunction n'est pas une fonction

Je suis confronté à un problème avec le code suivant.

Ce que fondamentalement, ça devrait le faire. Il doit charger et analyser un fichier JSON. Et dans le RequestListender elle doit montrer le ID et la chaîne Hello qui est retourné par la ToString() méthode dans Produit.ts. Où la tProduct.Id est affiche correctement, le tProduct.ToString() méthode échoue avec le message d'erreur indiqué ci-dessous.

Merci beaucoup à l'avance.

Message d'erreur:

TypeError: tProduct.ToString is not a function. 
 (In 'tProduct.ToString()', 'tProduct.ToString' is undefined)

Fichier: Test.ts

var currentProduct = null as pvis.Product;

function runTest(path) {
    var request = new XMLHttpRequest();
    request.onload = loadRequestListener;
    request.open("get", path, true);
    request.send();
}

function loadRequestListener () {
    var tProduct : pvis.Product = JSON.parse(this.responseText);
    if (tProduct.Id) {
        currentProduct = tProduct;
        alert('loaded with Id: ' + tProduct.Id );   
        alert('loaded with Content: ' + tProduct.ToString() );  
    }
    else {
        alert('product failed to load');
    }

}

Fichier Produit.ts

module pvis {
    export class Product {

        Id: string;

        ToString():string {
            return 'Hello';
        }
    }
}

La partie HTML:

<body onload="runTest('assets/products/json/A379N.json')">

L'compilé en Javascript:

var pvis;
(function (pvis) {
    var Product = (function () {
        function Product() {
        }
        Product.prototype.ToString = function () {
            return 'Hello';
        };
        return Product;
    })();
    pvis.Product = Product;
})(pvis || (pvis = {}));
var currentProduct = null;
function runTest(path) {
    var request = new XMLHttpRequest();
    request.onload = loadRequestListener;
    request.open("get", path, true);
    request.send();
}
function loadRequestListener() {
    var tProduct = JSON.parse(this.responseText);
    if (tProduct.Id) {
        currentProduct = tProduct;
        alert('loaded with Id: ' + tProduct.Id);
        alert('loaded with Content: ' + tProduct.ToString());
    }
    else {
        alert('product failed to load');
    }
}

Le tsconfig.json (je ne sais pas si c'est pertinent):

{
    "compilerOptions": {
        "target": "ES5",
        "removeComments": true,
        "preserveConstEnums": true,
        "out": "js/main.js",
        "sourceMap": true
    },
    "files": [
       "src/Test.ts"
    ]
}
InformationsquelleAutor FrW | 2015-12-01