1

I have been studying this angular 2 project and I don't understand, how src/custom-typings.d.ts is included? This file contains typescript custom type definitions. There is no import src/custom-typings.d.ts in the sources. I can rename this file as anything, I can put this file in any directory and this file will be inlcuded anyway. Even if I change extension to *.ts (not *.d.ts) it will be included.

I think that because of it my IDE is slow. How to disable auto search of type definitions in all *.ts files in the project? I want to include this file manually

2 Answers 2

1

It seems it is loaded by webpack : https://github.com/AngularClass/angular2-webpack-starter/blob/8e93ae998e76efbd7166e0b0c531396098bd4e34/config/webpack.common.js#L137 which look for all .*.ts files excluding .spec.ts and .e2e.ts

If you don't want it to be loaded by webpack, you could exclude .d.ts extension in the loader too and add /// <reference path="../path_to/custom-typings.d.ts" /> in files where you need these custom typings.

Sign up to request clarification or add additional context in comments.

Comments

0

When you write import {} from 'fileName' it automaticlly looks for fileName.d.ts. those files have only the declaration for the function and variable (saying what type they are) not the functions themselves, this is why it still works- the generated js file is still there.

And for the second question- you didn't mention what IDE you have. so I cant answer you. I didn't understand what you ment in type definitions in all *.ts files... if you don't want to work with type annotations, don't use typescript. and only the type in the function you are working on (and importing) is being looked

3 Comments

Welcome to SO :) You should comment the question if you need more information to complete your answer rather than commenting into your answer.
I cannot comment, not enough repo. and I tried to give an answer without all the needed info
I didn't write 'import {} from custom-typings' but this file is included. If I will rename this file, then this file will be included too. This is why I think that all *.ts files are scanned for type definitions

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.