javascript - DefinitelyTyped vs index.d.ts for angular library -
i created simple library unit testing helpers angular 1.x: https://github.com/dakolech/angular-unit-testing-helpers
and want add types definitions. question is: should create index.d.ts
file in repository or should create w new folder in definitelytyped
repository?
if first, how import angular types in files (e.g. ng.iscope
)?
the preferred approach if possible include types within npm package , specify location in package.json.
you need include [something].d.ts file in project, add "typings" property package.json referencing it, , publish , code npm.
see https://www.typescriptlang.org/docs/handbook/typings-for-npm-packages.html official documentation on this.
if project depends on types don't have types included in npm packages, gets more complicated. see https://github.com/typings/typings/blob/master/docs/faq.md#should-i-use-the-typings-field-in-packagejson details. want include typings.json file specifies how hold of dependencies typings, , tell users run typings install npm:your-page
, give them both type definitions , dependent definitions typings.json.
Comments
Post a Comment