Refused to execute script from '*.ts' because its MIME type ('video/vnd.dlna.mpeg-tts') is not executable

Issue

I am new to typescript.
I have an angularjs controller which I am trying to convert to typescript controller.

To start with I declared the controller and module

    /// <reference path='../../Scripts/typings/angularjs/angular.d.ts' />
/// <reference path='../../Scripts/typings/jquery/jquery.d.ts' />
'use strict'

interface IRouteParams extends ng.route.IRouteParamsService {
    propertyAddress: string;
}

class Controller1 {
    public propertyAdd: string;
    constructor($scope: any,
        $routeParams: IRouteParams,
        ServicesFactory,
        growl,
        blockUI,
        IMAGE_RELATED_MESSAGES,
        BUSY_MESSAGES,
        $timeout: ng.ITimeoutService,
        $modal,
        Lightbox,
        $filter) {

        this.propertyAdd = $routeParams.propertyAddress;

    }
}

angular.module('Controller').controller('Controller1', Controller1);

when I run this code in browser I get following error

Refused to execute script from ‘http://localhost/……/Controller1.ts‘ because its MIME type (‘video/vnd.dlna.mpeg-tts’) is not executable.

whats is the pain point?

Solution

You have to transpile your typescript code to a regular javascript code. TypeScript is not supposed to run directly in the browser.

Use tsc compiler to produce javascript like this:

tsc helloworld.ts

More details on the official site.

Answered By – shadeglare

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published