Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
496 views
in Technique[技术] by (71.8m points)

angular - Angualar 10 : Add descritpion (*d.ts) file manually to compilation

I have a angular library which has the description files *.d.ts. in a below structure

├ src
│  ├ my-lib
│  │   ├ my-typedef.d.ts
│  │      
│  │
│  └public_apit.ts
│  
└ tsconfig.lib.json

On tsconfig.lib.json i have include it like below:

"include": [
    "src/lib/typedefs"
  ],

Edit

Before upgrading to 10 it was set to angular 8. This files were compiled in the final build package, but after Angular 10. I am facing this issue. though other folders are there but typedefs.

I see on angular upgrade guidelines that we need to add manually but not sure what is the correct way.

We have updated the tsconfig.app.json to limit the files compiled. If you rely on other files being included in the compilation, such as a typings.d.ts file, you need to manually add it to the compilation.

https://update.angular.io/?l=3&v=8.0-9.0

repo to the issue: https://github.com/amirgc/angular10-ng-build.git

  • Download the repo.
  • npm install
  • ng build
question from:https://stackoverflow.com/questions/65945268/angualar-10-add-descritpion-d-ts-file-manually-to-compilation

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I found out that this is the expected behavior as type definitions are not emitted with the upgdrade of ng-packagr. If we want to emit type description. To emit the .d.ts we can use the assets option, or alternatively change the file to a .ts extensions. we can add below section on ng-package.json file.

{
  "ngPackage": {
    "assets": [
      "CHANGELOG.md",
      "./typedefs/**/*.d.ts"
    ],
    "lib": {
      ...
    }
  }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...