Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

stop typescript compiler from creating .d.ts files

I want typescript to not create .d.ts files when compiling. This is because it causes a "duplicate Identifier" error on all class names. I have added this to the tsconfig file:

{
    "compileOnSave": true,
    "compilerOptions": {
        "target": "es5",
        "noImplicitAny": true,
        "module": "system",
        "moduleResolution": "node",
        "sourceMap": false,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "removeComments": true,
        "outDir":"js/",
        "declaration": true
    },
  "exclude": [
    "bower_components",
    "node_modules",
    "wwwroot" // this is the key line
  ]  
}

This is supposed to make it stop creating .d.ts files as shown in this answer

But I guess that is not the folder that I need to exclude because excluding it doesn't stop it creating .d.ts files for me. I am using visual studio code. What file do I need to exclude?

like image 894
BeniaminoBaggins Avatar asked Mar 19 '16 08:03

BeniaminoBaggins


People also ask

What is TypeScript D ts file?

d. ts files are declaration files that contain only type information. These files don't produce . js outputs; they are only used for typechecking. We'll learn more about how to write our own declaration files later.

Do TypeScript files need to be compiled?

Typescript is a superset of javascript but it is a strongly typed, object-oriented programming language. Typescript file does not run directly on the browser as javascript run, we have to compile the typescript file to the javascript then it will work as usual.

What does TSC do in TypeScript?

Tsc stands for `TypeScript compiler` and is a simple tool included in Typescript itself, allowing you to compile any ts files into js.


1 Answers

If what you want is not to generate the d.tsfiles, then you need to remove:

declaration: true

from your compiler options in tsconfig.json

As specified in the compiler options doc

--declaration -d Generates corresponding '.d.ts' file.

like image 51
Fidan Hakaj Avatar answered Sep 20 '22 20:09

Fidan Hakaj