Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected /// <reference types="angular" /> in .d.ts files #11039

Closed
mhevery opened this issue Sep 21, 2016 · 9 comments
Closed

Unexpected /// <reference types="angular" /> in .d.ts files #11039

mhevery opened this issue Sep 21, 2016 · 9 comments

Comments

@mhevery
Copy link

mhevery commented Sep 21, 2016

TypeScript Version: 2.0.2

Code

I am sorry I don't have a smaller repro case. :-(
(https://github.com/mhevery/angular/tree/ts-issue-11039)

The issue is that d.ts file contains /// <reference types="angular" /> and I don't know why.

Angular had incorrectly included @types/angularjs. The PR changes it to @types/angular The only place where @types/angular should be used is in modules/@angular/upgrade/tsconfig-build.json as that is the only folder which imports from @types/angular

The change (@types/angularjs => @types/angular) now sprinkles /// <reference types="angular" /> in some d.ts files where it did not before. An example for it is dist/packages-dist/core/src/type.d.ts.

Steps to repro:

  1. clone the repo git clone https://github.com/mhevery/angular.git
  2. check out ts-issue-11039: git checkout ts-issue-11039
  3. npm i
  4. ./build.sh
  5. Examine that dist/packages-dist/core/src/type.d.ts has /// <reference types="angular" /> Why?
  6. Delete compiler folder rm -rf dist/packages-dist/core
  7. Rebuild manually node --max-old-space-size=3000 dist/tools/@angular/tsc-wrapped/src/main -p modules/@angular/core/tsconfig-build.json (We have a custom TSC main to deal with our sim link issue, which is why $(npm bin)/tsc -p modules/@angular/core/tsconfig-build.json) does not work. Notice that after rebuild the dist/packages-dist/core/src/type.d.ts has /// <reference types="angular" /> yet there is no reference to @types/angular in the modules/@angular/core folder

NOTE: There are many more files which have this issue (not just the core)`

@mhevery mhevery changed the title Unexpected /// <reference types="angular" /> Unexpected /// <reference types="angular" /> in .d.ts files Sep 21, 2016
@mhegazy
Copy link
Contributor

mhegazy commented Sep 21, 2016

We have a custom TSC main to deal with our sim link issue

what is you symlink issue? can we fix it?

@mhevery
Copy link
Author

mhevery commented Sep 21, 2016

The issue is that we have modules/@angular/facade which is being symlinked into modules/@angular/*/src/facade. (This is due to historical Dart support and we are slowly getting rid of it.) Because TSC resolves symlinks into absolute links. It then throws an error like so:

$(npm bin)/tsc -p modules/@angular/core/tsconfig-build.json 
error TS6059: File '/Users/misko/work/angular/modules/@angular/facade/src/async.ts' is not under 'rootDir' '/Users/misko/work/angular/modules/@angular/core'. 'rootDir' is expected to contain all source files.
error TS6059: File '/Users/misko/work/angular/modules/@angular/facade/src/collection.ts' is not under 'rootDir' '/Users/misko/work/angular/modules/@angular/core'. 'rootDir' is expected to contain all source files.
error TS6059: File '/Users/misko/work/angular/modules/@angular/facade/src/errors.ts' is not under 'rootDir' '/Users/misko/work/angular/modules/@angular/core'. 'rootDir' is expected to contain all source files.
error TS6059: File '/Users/misko/work/angular/modules/@angular/facade/src/lang.ts' is not under 'rootDir' '/Users/misko/work/angular/modules/@angular/core'. 'rootDir' is expected to contain all source files.
error TS6059: File '/Users/misko/work/angular/modules/@angular/facade/src/math.ts' is not under 'rootDir' '/Users/misko/work/angular/modules/@angular/core'. 'rootDir' is expected to contain all source files.

@mhegazy
Copy link
Contributor

mhegazy commented Sep 21, 2016

this sounds like the same underlying issue in #9552. we should be fixing this in the next release.

@mhevery
Copy link
Author

mhevery commented Sep 21, 2016

But the original question remains. Why is there /// <reference types="angular" /> when no one references it? And why only in some files?

@mhegazy
Copy link
Contributor

mhegazy commented Sep 21, 2016

ah sorry @vladima looked into it. and the issue is the compiler automatically loads all @types packages in the containing directories. so it did include @types\angular. it so happens that @types\angular adds $inject to Function and some of other part of your code extends Function creating a false dependency. The solution would be to add types: [] to your tsconfig.json to state you do not want to include @types\angular in your compilation. this seems to address the issue on the angular repo.

@mhevery
Copy link
Author

mhevery commented Sep 21, 2016

Hmm. I thought I tried it and it did not work for me. Will try again.
On Wed, Sep 21, 2016 at 1:36 PM Mohamed Hegazy [email protected]
wrote:

ah sorry @vladima https://github.com/vladima looked into it. and the
issue is the compiler automatically loads all @types
https://github.com/types packages in the containing directories. so it
did include @types\angular. it so happens that @types\angular adds $inject
to Function and some of other part of your code extends Function creating
a false dependency. The solution would be to add types: [] to your
tsconfig.json to state you do not want to include @types\angular in your
compilation. this seems to address the issue on the angular repo.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#11039 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAG1TwFwHIBl6KiaE7hGXmzYexfp0Z-Eks5qsZUvgaJpZM4KDCBU
.

@mhevery mhevery closed this as completed Sep 22, 2016
@JulienBier
Copy link

@mhevery Hi, I have the same issue with update to typescript 2.0.3. Did you find a solution to fix this ?

@mhevery
Copy link
Author

mhevery commented Sep 22, 2016

Did types: [] not work?

On Thu, Sep 22, 2016 at 1:20 PM Julien Bier [email protected]
wrote:

@mhevery https://github.com/mhevery Hi, I have the same issue with
update to typescript 2.0.3. Did you find a solution to fix this ?


You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub
#11039 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAG1Tyd0iQTk6ovqeri4q5q4_PMlWmaFks5qsuMXgaJpZM4KDCBU
.

@JulienBier
Copy link

No it didn't. Issue seems to be in @types/angular-mocks npm package.

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants