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

Using declarationMap is causing unexpected errors #1464

Closed
tobi-or-not-tobi opened this issue Dec 3, 2019 · 9 comments · Fixed by #1664
Closed

Using declarationMap is causing unexpected errors #1464

tobi-or-not-tobi opened this issue Dec 3, 2019 · 9 comments · Fixed by #1664
Labels

Comments

@tobi-or-not-tobi
Copy link

@tobi-or-not-tobi tobi-or-not-tobi commented Dec 3, 2019

Type of Issue

[ x] Bug Report
[ ] Feature Request

(perhaps it's an unsupported ts feature, and we should threat this as a feature request)

Description

I've tried to use the tsconfig property declarationMap for getting sources with generated libraries. (see https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-9.html#new---declarationmap). Enabling this flag on a project in an angular-cli generated project (either ng 8 or v9.0.0-rc.4), causes the following issues:

ERROR: error TS5069: Option 'declarationMap' cannot be specified without specifying option 'declaration' or option 'composite'.
An unhandled exception occurred: error TS5069: Option 'declarationMap' cannot be specified without specifying option 'declaration' or option 'composite'.

The message indicates that I should add 'declaration' or 'composite' as well. In the default generated tsconfig.lib.json, the declaration is actually set to true. I've tried to enable the 'composite' flag as well, but this is causing other issues.

How To Reproduce

  • create a new cli workspace (ng new mywebsite)
  • create a new project in the workspace (ng g library myproject)
  • add the flag declarationMap to projects/myproject/tsconfig.lib.json
  • build the library (ng build myproject)

Expected Behaviour

I was expecting that .d.ts.map files would be generated

Version Information

$ node_modules/.bin/ng-packagr --version
ng-packagr: 5.7.1
@angular/*: 8.3.20
typescript: 3.5.3
rxjs: 6.4.0
node: v10.16.0
npm: 6.13.1
@tobi-or-not-tobi
Copy link
Author

@tobi-or-not-tobi tobi-or-not-tobi commented Dec 12, 2019

@alan-agius4 did you get anywhere with this? I saw you created a PR, but the code doesn't seem to reflect the issue. Just to make sure, I'm trying to enable the declarationMap feature.

@alan-agius4
Copy link
Contributor

@alan-agius4 alan-agius4 commented Dec 12, 2019

I need to continue looking at this. Yeah the in the PR is to fix that issue.

Since there are 2 compilation we only enable declarations for the 1st one.

@JonWallsten
Copy link

@JonWallsten JonWallsten commented Feb 10, 2020

@alan-agius4: We really need this in our project, so I can help you take a look. Can you add your thoughts, and I'll go from there?

@JonWallsten
Copy link

@JonWallsten JonWallsten commented Feb 11, 2020

I can add to this that the declaration maps also ends up in the wrong folder.
Using the following settings still makes the d.ts.map files to end next to the source file.

    "declaration": true,
    "declarationMap": true,
    "declarationDir": "./dist",

@tobi-or-not-tobi
Copy link
Author

@tobi-or-not-tobi tobi-or-not-tobi commented Feb 19, 2020

This issue came today again within our community, it's getting more and more important to use a library without relying on the source project.

@alan-agius4 wondering if you see capacity to move this forward?

@danilchican
Copy link

@danilchican danilchican commented Feb 25, 2020

I need to continue looking at this. Yeah the in the PR is to fix that issue.

Since there are 2 compilation we only enable declarations for the 1st one.

hi, @alan-agius4 . do you have a solution for that for now?

@alan-agius4
Copy link
Contributor

@alan-agius4 alan-agius4 commented Feb 25, 2020

This is currently a low-priority feature.

@arobinson
Copy link

@arobinson arobinson commented Feb 26, 2020

While I understand being busy, this feature is very important for mono-repo development. Without this working, VS code ends up loading the *.d.ts files instead of the source files.

Example layout:

project-root/
  angular-application/
    src/
      foo.ts
  angular-libraries/
    projects/
      some-library/
        src/
          lib/
            bar.ts
  other-local-library/

In the angular-application, to get Ivy working, one cannot use symlinks and tsconfig paths to get angular-application to reference something in one of the libraries since it uses package.json and node_modules. When trying to go to the definition Bar defined in angular-libraries/projects/some-library/src/bar.ts file from angular-application/src/foo.ts file, opened file is angular-application/node_modules/some-library/lib/bar.d.ts which is not helpful at all if you mean to edit the bar.ts source code.

If I understand this right, having the declarationMap working would allow that bar.ts file be loaded instead, making the development experience in a mono-repo much better.

@github-actions
Copy link

@github-actions github-actions bot commented Jul 12, 2020

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

This action has been performed automatically by a bot.

@github-actions github-actions bot locked and limited conversation to collaborators Jul 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
5 participants