{"componentChunkName":"component---src-templates-documentation-tsx","path":"/docs/handbook/declaration-files/publishing.html","result":{"data":{"allSitePage":{"nodes":[{"path":"/dev-404-page/"},{"path":"/docs/handbook/nightly-builds.html"},{"path":"/docs/handbook/declaration-files/by-example.html"},{"path":"/docs/handbook/declaration-files/consumption.html"},{"path":"/docs/handbook/declaration-files/deep-dive.html"},{"path":"/docs/handbook/declaration-files/do-s-and-don-ts.html"},{"path":"/docs/handbook/declaration-files/introduction.html"},{"path":"/docs/handbook/declaration-files/library-structures.html"},{"path":"/docs/handbook/declaration-files/publishing.html"},{"path":"/docs/handbook/declaration-files/templates.html"},{"path":"/docs/handbook/typescript-in-5-minutes-func.html"},{"path":"/docs/handbook/typescript-in-5-minutes.html"},{"path":"/docs/handbook/typescript-in-5-minutes-oop.html"},{"path":"/docs/handbook/typescript-from-scratch.html"},{"path":"/docs/handbook/basic-types.html"},{"path":"/docs/handbook/classes.html"},{"path":"/docs/handbook/enums.html"},{"path":"/docs/handbook/functions.html"},{"path":"/docs/handbook/generics.html"},{"path":"/docs/handbook/interfaces.html"},{"path":"/docs/handbook/literal-types.html"},{"path":"/docs/handbook/intro.html"},{"path":"/docs/handbook/unions-and-intersections.html"},{"path":"/docs/handbook/declaration-files/dts-from-js.html"},{"path":"/docs/handbook/intro-to-js-ts.html"},{"path":"/docs/handbook/jsdoc-supported-types.html"},{"path":"/docs/handbook/type-checking-javascript-files.html"},{"path":"/docs/handbook/compiler-options-in-msbuild.html"},{"path":"/docs/handbook/compiler-options.html"},{"path":"/docs/handbook/configuring-watch.html"},{"path":"/docs/handbook/integrating-with-build-tools.html"},{"path":"/docs/handbook/project-references.html"},{"path":"/docs/handbook/tsconfig-json.html"},{"path":"/docs/handbook/advanced-types.html"},{"path":"/docs/handbook/declaration-merging.html"},{"path":"/docs/handbook/decorators.html"},{"path":"/docs/handbook/iterators-and-generators.html"},{"path":"/docs/handbook/jsx.html"},{"path":"/docs/handbook/mixins.html"},{"path":"/docs/handbook/module-resolution.html"},{"path":"/docs/handbook/modules.html"},{"path":"/docs/handbook/namespaces-and-modules.html"},{"path":"/docs/handbook/namespaces.html"},{"path":"/docs/handbook/symbols.html"},{"path":"/docs/handbook/triple-slash-directives.html"},{"path":"/docs/handbook/type-compatibility.html"},{"path":"/docs/handbook/type-inference.html"},{"path":"/docs/handbook/utility-types.html"},{"path":"/docs/handbook/variable-declarations.html"},{"path":"/docs/handbook/release-notes/typescript-1-1.html"},{"path":"/docs/handbook/release-notes/typescript-1-3.html"},{"path":"/docs/handbook/release-notes/typescript-1-4.html"},{"path":"/docs/handbook/release-notes/typescript-1-5.html"},{"path":"/docs/handbook/release-notes/typescript-1-6.html"},{"path":"/docs/handbook/release-notes/typescript-1-7.html"},{"path":"/docs/handbook/release-notes/typescript-1-8.html"},{"path":"/docs/handbook/release-notes/typescript-2-0.html"},{"path":"/docs/handbook/release-notes/typescript-2-1.html"},{"path":"/docs/handbook/release-notes/typescript-2-2.html"},{"path":"/docs/handbook/release-notes/typescript-2-3.html"},{"path":"/docs/handbook/release-notes/typescript-2-4.html"},{"path":"/docs/handbook/release-notes/typescript-2-5.html"},{"path":"/docs/handbook/release-notes/typescript-2-6.html"},{"path":"/docs/handbook/release-notes/typescript-2-7.html"},{"path":"/docs/handbook/release-notes/typescript-2-8.html"},{"path":"/docs/handbook/release-notes/typescript-2-9.html"},{"path":"/docs/handbook/release-notes/typescript-3-0.html"},{"path":"/docs/handbook/release-notes/typescript-3-1.html"},{"path":"/docs/handbook/release-notes/typescript-3-2.html"},{"path":"/docs/handbook/release-notes/typescript-3-3.html"},{"path":"/docs/handbook/release-notes/typescript-3-4.html"},{"path":"/docs/handbook/release-notes/typescript-3-5.html"},{"path":"/docs/handbook/release-notes/typescript-3-6.html"},{"path":"/docs/handbook/release-notes/typescript-3-7.html"},{"path":"/docs/handbook/release-notes/typescript-3-8.html"},{"path":"/docs/handbook/release-notes/typescript-3-9.html"},{"path":"/docs/handbook/asp-net-core.html"},{"path":"/docs/handbook/angular.html"},{"path":"/docs/handbook/babel-with-typescript.html"},{"path":"/docs/handbook/dom-manipulation.html"},{"path":"/docs/handbook/gulp.html"},{"path":"/docs/handbook/migrating-from-javascript.html"},{"path":"/docs/handbook/react.html"},{"path":"/docs/handbook/typescript-tooling-in-5-minutes.html"},{"path":"/vo/docs/handbook/basic-types.html"},{"path":"/docs/handbook/declaration-files/templates/global-modifying-module-d-ts.html"},{"path":"/docs/handbook/declaration-files/templates/global-plugin-d-ts.html"},{"path":"/docs/handbook/declaration-files/templates/global-d-ts.html"},{"path":"/docs/handbook/declaration-files/templates/module-class-d-ts.html"},{"path":"/docs/handbook/declaration-files/templates/module-function-d-ts.html"},{"path":"/docs/handbook/declaration-files/templates/module-plugin-d-ts.html"},{"path":"/docs/handbook/declaration-files/templates/module-d-ts.html"},{"path":"/docs/handbook/release-notes/overview.html"},{"path":"/tsconfig"},{"path":"/en/tsconfig"},{"path":"/vo/tsconfig"},{"path":"/ja/tsconfig"},{"path":"/pt/tsconfig"},{"path":"/play"},{"path":"/en/play"},{"path":"/es/play"},{"path":"/ja/play"},{"path":"/pt/play"},{"path":"/vo/play"},{"path":"/zh/play"},{"path":"/fa/play"},{"path":"/play/3-7/fixits/big-number-literals.ts"},{"path":"/play/3-7/fixits/const-to-let.ts"},{"path":"/play/3-7/fixits/infer-from-usage-changes.ts"},{"path":"/play/3-7/syntax-and-messaging/flattened-error-reporting.ts"},{"path":"/play/3-7/syntax-and-messaging/nullish-coalescing.ts"},{"path":"/play/3-7/syntax-and-messaging/optional-chaining.ts"},{"path":"/play/3-7/types-and-code-flow/assertion-functions.ts"},{"path":"/play/3-7/types-and-code-flow/recursive-type-references.ts"},{"path":"/play/3-7/types-and-code-flow/uncalled-function-checks.ts"},{"path":"/play/3-8/breaking-changes/checking-unions-with-index-signatures.ts"},{"path":"/play/3-8/jsdoc-improvements/accessibility-modifiers.js"},{"path":"/play/3-8/syntax-and-messaging/export-modules-from.ts"},{"path":"/play/3-8/syntax-and-messaging/private-class-fields.ts"},{"path":"/play/4-0/new-checks/class-constructor-code-flow.ts"},{"path":"/play/4-0/new-js-features/jsdoc-deprecated.ts"},{"path":"/play/4-0/new-js-features/logical-operators-and-assignment.ts"},{"path":"/play/4-0/new-js-features/nullish-coalescing.ts"},{"path":"/play/4-0/new-ts-features/named-tuples.ts"},{"path":"/play/4-0/new-ts-features/unknown-in-catch.ts"},{"path":"/play/4-0/new-ts-features/variadic-tuples.ts"},{"path":"/play/javascript/external-apis/typescript-with-deno.ts"},{"path":"/play/javascript/external-apis/typescript-with-node.js"},{"path":"/play/javascript/external-apis/typescript-with-web.js"},{"path":"/play/javascript/external-apis/typescript-with-webgl.js"},{"path":"/play/javascript/functions-with-javascript/function-chaining.ts"},{"path":"/play/javascript/functions-with-javascript/generic-functions.ts"},{"path":"/play/javascript/functions-with-javascript/typing-functions.ts"},{"path":"/play/javascript/helping-with-javascript/errors.ts"},{"path":"/play/javascript/helping-with-javascript/quick-fixes.ts"},{"path":"/play/javascript/javascript-essentials/code-flow.ts"},{"path":"/play/javascript/javascript-essentials/functions.ts"},{"path":"/play/javascript/javascript-essentials/hello-world.ts"},{"path":"/play/javascript/javascript-essentials/objects-and-arrays.ts"},{"path":"/play/javascript/modern-javascript/async-await.ts"},{"path":"/play/javascript/modern-javascript/immutability.ts"},{"path":"/play/javascript/modern-javascript/import-export.ts"},{"path":"/play/javascript/modern-javascript/jsdoc-support.js"},{"path":"/play/javascript/working-with-classes/classes-101.ts"},{"path":"/play/javascript/working-with-classes/generic-classes.ts"},{"path":"/play/javascript/working-with-classes/mixins.ts"},{"path":"/play/javascript/working-with-classes/this.ts"},{"path":"/play/playground/config/javascript-playgrounds.js"},{"path":"/play/playground/config/new-compiler-defaults.ts"},{"path":"/play/playground/language/automatic-type-acquisition.ts"},{"path":"/play/playground/language/fixits.ts"},{"path":"/play/playground/tooling/mobile-support.ts"},{"path":"/play/playground/tooling/sharable-urls.ts"},{"path":"/play/playground/tooling/typescript-versions.ts"},{"path":"/play/typescript/language/soundness.ts"},{"path":"/play/typescript/language/structural-typing.ts"},{"path":"/play/typescript/language/type-guards.ts"},{"path":"/play/typescript/language/type-widening-and-narrowing.ts"},{"path":"/play/typescript/language-extensions/enums.ts"},{"path":"/play/typescript/language-extensions/nominal-typing.ts"},{"path":"/play/typescript/language-extensions/types-vs-interfaces.ts"},{"path":"/play/typescript/meta-types/conditional-types.ts"},{"path":"/play/typescript/meta-types/discriminate-types.ts"},{"path":"/play/typescript/meta-types/indexed-types.ts"},{"path":"/play/typescript/meta-types/mapped-types.ts"},{"path":"/play/typescript/primitives/any.ts"},{"path":"/play/typescript/primitives/literals.ts"},{"path":"/play/typescript/primitives/union-and-intersection-types.ts"},{"path":"/play/typescript/primitives/unknown-and-never.ts"},{"path":"/play/typescript/type-primitives/built-in-utility-types.ts"},{"path":"/play/typescript/type-primitives/nullable-types.ts"},{"path":"/play/typescript/type-primitives/tuples.ts"},{"path":"/es/play/javascript/external-apis/typescript-with-deno.ts"},{"path":"/es/play/javascript/external-apis/typescript-with-node.js"},{"path":"/es/play/javascript/external-apis/typescript-with-web.js"},{"path":"/es/play/javascript/functions-with-javascript/function-chaining.ts"},{"path":"/es/play/javascript/functions-with-javascript/generic-functions.ts"},{"path":"/es/play/javascript/javascript-essentials/hello-world.ts"},{"path":"/es/play/javascript/javascript-essentials/objects-and-arrays.ts"},{"path":"/es/play/typescript/language/soundness.ts"},{"path":"/es/play/typescript/language/structural-typing.ts"},{"path":"/es/play/typescript/language/type-guards.ts"},{"path":"/es/play/typescript/language/type-widening-and-narrowing.ts"},{"path":"/es/play/typescript/meta-types/conditional-types.ts"},{"path":"/es/play/typescript/meta-types/discriminate-types.ts"},{"path":"/es/play/typescript/meta-types/indexed-types.ts"},{"path":"/es/play/typescript/meta-types/mapped-types.ts"},{"path":"/es/play/typescript/primitives/any.ts"},{"path":"/es/play/typescript/primitives/literals.ts"},{"path":"/es/play/typescript/primitives/union-and-intersection-types.ts"},{"path":"/es/play/typescript/primitives/unknown-and-never.ts"},{"path":"/es/play/typescript/type-primitives/built-in-utility-types.ts"},{"path":"/es/play/typescript/type-primitives/nullable-types.ts"},{"path":"/es/play/typescript/type-primitives/tuples.ts"},{"path":"/fa/play/javascript/javascript-essentials/hello-world.ts"},{"path":"/ja/play/3-7/fixits/big-number-literals.ts"},{"path":"/ja/play/3-7/syntax-and-messaging/nullish-coalescing.ts"},{"path":"/ja/play/3-7/syntax-and-messaging/optional-chaining.ts"},{"path":"/ja/play/3-8/breaking-changes/checking-unions-with-index-signatures.ts"},{"path":"/ja/play/javascript/external-apis/typescript-with-deno.ts"},{"path":"/ja/play/typescript/language-extensions/enums.ts"},{"path":"/ja/play/typescript/language-extensions/nominal-typing.ts"},{"path":"/ja/play/typescript/language-extensions/types-vs-interfaces.ts"},{"path":"/ja/play/typescript/primitives/any.ts"},{"path":"/ja/play/typescript/primitives/literals.ts"},{"path":"/ja/play/typescript/primitives/union-and-intersection-types.ts"},{"path":"/ja/play/typescript/primitives/unknown-and-never.ts"},{"path":"/ja/play/typescript/type-primitives/built-in-utility-types.ts"},{"path":"/ja/play/typescript/type-primitives/nullable-types.ts"},{"path":"/ja/play/typescript/type-primitives/tuples.ts"},{"path":"/pt/play/javascript/javascript-essentials/code-flow.ts"},{"path":"/pt/play/javascript/javascript-essentials/functions.ts"},{"path":"/pt/play/javascript/javascript-essentials/hello-world.ts"},{"path":"/pt/play/javascript/javascript-essentials/objects-and-arrays.ts"},{"path":"/vo/play/javascript/javascript-essentials/code-flow.ts"},{"path":"/vo/play/javascript/javascript-essentials/functions.ts"},{"path":"/vo/play/javascript/javascript-essentials/hello-world.ts"},{"path":"/vo/play/javascript/javascript-essentials/objects-and-arrays.ts"},{"path":"/zh/play/javascript/external-apis/typescript-with-deno.ts"},{"path":"/zh/play/javascript/external-apis/typescript-with-node.js"},{"path":"/zh/play/javascript/external-apis/typescript-with-web.js"},{"path":"/zh/play/javascript/external-apis/typescript-with-webgl.js"},{"path":"/zh/play/javascript/functions-with-javascript/function-chaining.ts"},{"path":"/zh/play/javascript/functions-with-javascript/generic-functions.ts"},{"path":"/zh/play/javascript/functions-with-javascript/typing-functions.ts"},{"path":"/zh/play/javascript/helping-with-javascript/errors.ts"},{"path":"/zh/play/javascript/helping-with-javascript/quick-fixes.ts"},{"path":"/zh/play/javascript/javascript-essentials/code-flow.ts"},{"path":"/zh/play/javascript/javascript-essentials/functions.ts"},{"path":"/zh/play/javascript/javascript-essentials/hello-world.ts"},{"path":"/zh/play/javascript/javascript-essentials/objects-and-arrays.ts"},{"path":"/zh/play/javascript/modern-javascript/async-await.ts"},{"path":"/zh/play/javascript/modern-javascript/immutability.ts"},{"path":"/zh/play/javascript/modern-javascript/import-export.ts"},{"path":"/zh/play/javascript/modern-javascript/jsdoc-support.js"},{"path":"/zh/play/javascript/working-with-classes/classes-101.ts"},{"path":"/zh/play/javascript/working-with-classes/generic-classes.ts"},{"path":"/zh/play/javascript/working-with-classes/mixins.ts"},{"path":"/zh/play/javascript/working-with-classes/this.ts"},{"path":"/zh/play/playground/config/javascript-playgrounds.js"},{"path":"/zh/play/playground/config/new-compiler-defaults.ts"},{"path":"/zh/play/playground/language/automatic-type-acquisition.ts"},{"path":"/zh/play/playground/language/fixits.ts"},{"path":"/zh/play/playground/tooling/mobile-support.ts"},{"path":"/zh/play/playground/tooling/sharable-urls.ts"},{"path":"/zh/play/playground/tooling/typescript-versions.ts"},{"path":"/zh/play/typescript/language/soundness.ts"},{"path":"/zh/play/typescript/language/structural-typing.ts"},{"path":"/zh/play/typescript/language/type-guards.ts"},{"path":"/zh/play/typescript/language/type-widening-and-narrowing.ts"},{"path":"/zh/play/typescript/language-extensions/enums.ts"},{"path":"/zh/play/typescript/language-extensions/nominal-typing.ts"},{"path":"/zh/play/typescript/language-extensions/types-vs-interfaces.ts"},{"path":"/zh/play/typescript/meta-types/conditional-types.ts"},{"path":"/zh/play/typescript/meta-types/discriminate-types.ts"},{"path":"/zh/play/typescript/meta-types/indexed-types.ts"},{"path":"/zh/play/typescript/meta-types/mapped-types.ts"},{"path":"/zh/play/typescript/primitives/any.ts"},{"path":"/zh/play/typescript/primitives/literals.ts"},{"path":"/zh/play/typescript/primitives/union-and-intersection-types.ts"},{"path":"/zh/play/typescript/primitives/unknown-and-never.ts"},{"path":"/zh/play/typescript/type-primitives/built-in-utility-types.ts"},{"path":"/zh/play/typescript/type-primitives/nullable-types.ts"},{"path":"/zh/play/typescript/type-primitives/tuples.ts"},{"path":"/ja/play/3-7/syntax-and-messaging/flattened-error-reporting.ts"},{"path":"/ja/play/3-7/fixits/infer-from-usage-changes.ts"},{"path":"/ja/play/3-7/fixits/const-to-let.ts"},{"path":"/community"},{"path":"/es/community"},{"path":"/ja/community"},{"path":"/vo/community"},{"path":"/zh/community"},{"path":"/download"},{"path":"/es/download"},{"path":"/ja/download"},{"path":"/vo/download"},{"path":"/zh/download"},{"path":"/empty"},{"path":"/es/empty"},{"path":"/ja/empty"},{"path":"/vo/empty"},{"path":"/zh/empty"},{"path":"/"},{"path":"/es/"},{"path":"/ja/"},{"path":"/vo/"},{"path":"/zh/"},{"path":"/tools"},{"path":"/es/tools"},{"path":"/ja/tools"},{"path":"/vo/tools"},{"path":"/zh/tools"},{"path":"/why-create-typescript"},{"path":"/es/why-create-typescript"},{"path":"/ja/why-create-typescript"},{"path":"/vo/why-create-typescript"},{"path":"/zh/why-create-typescript"},{"path":"/docs/bootstrap"},{"path":"/es/docs/bootstrap"},{"path":"/ja/docs/bootstrap"},{"path":"/vo/docs/bootstrap"},{"path":"/zh/docs/bootstrap"},{"path":"/docs/"},{"path":"/es/docs/"},{"path":"/ja/docs/"},{"path":"/vo/docs/"},{"path":"/zh/docs/"},{"path":"/docs/handbook/"},{"path":"/es/docs/handbook/"},{"path":"/ja/docs/handbook/"},{"path":"/vo/docs/handbook/"},{"path":"/zh/docs/handbook/"},{"path":"/branding/"},{"path":"/dev/bug-workbench/"},{"path":"/dev/playground-plugins/"},{"path":"/dev/sandbox/"},{"path":"/dev/twoslash/"},{"path":"/dev/typescript-vfs/"},{"path":"/upcoming/"}]},"markdownRemark":{"id":"78bc2800-9adf-5ca5-8171-ef22c5221a4d","excerpt":"Now that you have authored a declaration file following the steps of this guide, it is time to publish it to npm.\nThere are two main ways you can publish your…","html":"<p>Now that you have authored a declaration file following the steps of this guide, it is time to publish it to npm.\nThere are two main ways you can publish your declaration files to npm:</p>\n<ol>\n<li>bundling with your npm package</li>\n<li>publishing to the <a href=\"https://www.npmjs.com/~types\">@types organization</a> on npm.</li>\n</ol>\n<p>If your types are generated by your source code, publish the types with your source code. Both TypeScript and JavaScript projects can generate types via <a href=\"/tsconfig#declaration\"><code>--declaration</code></a>.</p>\n<p>Otherwise, we recommend submitting the types to DefinitelyTyped, which will publish them to the <code>@types</code> organization on npm.</p>\n<h2 id=\"including-declarations-in-your-npm-package\" style=\"position:relative;\"><a href=\"#including-declarations-in-your-npm-package\" aria-label=\"including declarations in your npm package permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Including declarations in your npm package</h2>\n<p>If your package has a main <code>.js</code> file, you will need to indicate the main declaration file in your <code>package.json</code> file as well.\nSet the <code>types</code> property to point to your bundled declaration file.\nFor example:</p>\n<pre class=\"shiki\"><div class=\"language-id\">json</div><div class='code-container'><code><span style=\"color: #000000\">{</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0451A5\">\"name\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"awesome\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0451A5\">\"author\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"Vandelay Industries\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0451A5\">\"version\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"1.0.0\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0451A5\">\"main\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"./lib/main.js\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0451A5\">\"types\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"./lib/main.d.ts\"</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Note that the <code>\"typings\"</code> field is synonymous with <code>\"types\"</code>, and could be used as well.</p>\n<p>Also note that if your main declaration file is named <code>index.d.ts</code> and lives at the root of the package (next to <code>index.js</code>) you do not need to mark the <code>\"types\"</code> property, though it is advisable to do so.</p>\n<h2 id=\"dependencies\" style=\"position:relative;\"><a href=\"#dependencies\" aria-label=\"dependencies permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Dependencies</h2>\n<p>All dependencies are managed by npm.\nMake sure all the declaration packages you depend on are marked appropriately in the <code>\"dependencies\"</code> section in your <code>package.json</code>.\nFor example, imagine we authored a package that used Browserify and TypeScript.</p>\n<pre class=\"shiki\"><div class=\"language-id\">json</div><div class='code-container'><code><span style=\"color: #000000\">{</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0451A5\">\"name\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"browserify-typescript-extension\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0451A5\">\"author\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"Vandelay Industries\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0451A5\">\"version\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"1.0.0\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0451A5\">\"main\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"./lib/main.js\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0451A5\">\"types\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"./lib/main.d.ts\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0451A5\">\"dependencies\"</span><span style=\"color: #000000\">: {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"browserify\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"latest\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"@types/browserify\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"latest\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"typescript\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"next\"</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Here, our package depends on the <code>browserify</code> and <code>typescript</code> packages.\n<code>browserify</code> does not bundle its declaration files with its npm packages, so we needed to depend on <code>@types/browserify</code> for its declarations.\n<code>typescript</code>, on the other hand, packages its declaration files, so there was no need for any additional dependencies.</p>\n<p>Our package exposes declarations from each of those, so any user of our <code>browserify-typescript-extension</code> package needs to have these dependencies as well.\nFor that reason, we used <code>\"dependencies\"</code> and not <code>\"devDependencies\"</code>, because otherwise our consumers would have needed to manually install those packages.\nIf we had just written a command line application and not expected our package to be used as a library, we might have used <code>devDependencies</code>.</p>\n<h2 id=\"red-flags\" style=\"position:relative;\"><a href=\"#red-flags\" aria-label=\"red flags permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Red flags</h2>\n<h3 id=\"-reference-path-\" style=\"position:relative;\"><a href=\"#-reference-path-\" aria-label=\" reference path  permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code>/// &#x3C;reference path=\"...\" /></code></h3>\n<p><em>Don’t</em> use <code>/// &#x3C;reference path=\"...\" /></code> in your declaration files.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">/// </span><span style=\"color: #800000\">&lt;reference</span><span style=\"color: #008000\"> </span><span style=\"color: #DC0000\">path</span><span style=\"color: #000000\">=</span><span style=\"color: #A31515\">\"../typescript/lib/typescriptServices.d.ts\"</span><span style=\"color: #008000\"> </span><span style=\"color: #800000\">/&gt;</span>\n<span style=\"color: #000000\">....</span></code></div></pre>\n<p><em>Do</em> use <code>/// &#x3C;reference types=\"...\" /></code> instead.</p>\n<pre class=\"shiki\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">/// </span><span style=\"color: #800000\">&lt;reference</span><span style=\"color: #008000\"> </span><span style=\"color: #DC0000\">types</span><span style=\"color: #000000\">=</span><span style=\"color: #A31515\">\"typescript\"</span><span style=\"color: #008000\"> </span><span style=\"color: #800000\">/&gt;</span>\n<span style=\"color: #000000\">....</span></code></div></pre>\n<p>Make sure to revisit the <a href=\"/docs/handbook/declaration-files/library-structures.html#consuming-dependencies\">Consuming dependencies</a> section for more information.</p>\n<h3 id=\"packaging-dependent-declarations\" style=\"position:relative;\"><a href=\"#packaging-dependent-declarations\" aria-label=\"packaging dependent declarations permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Packaging dependent declarations</h3>\n<p>If your type definitions depend on another package:</p>\n<ul>\n<li><em>Don’t</em> combine it with yours, keep each in their own file.</li>\n<li><em>Don’t</em> copy the declarations in your package either.</li>\n<li><em>Do</em> depend on the npm type declaration package if it doesn’t package its declaration files.</li>\n</ul>\n<h2 id=\"version-selection-with-typesversions\" style=\"position:relative;\"><a href=\"#version-selection-with-typesversions\" aria-label=\"version selection with typesversions permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Version selection with <code>typesVersions</code></h2>\n<p>When TypeScript opens a <code>package.json</code> file to figure out which files it needs to read, it first looks at a new field called <code>typesVersions</code>.</p>\n<p>A <code>package.json</code> with a <code>typesVersions</code> field might look like this:</p>\n<pre class=\"shiki\"><div class=\"language-id\">json</div><div class='code-container'><code><span style=\"color: #000000\">{</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0451A5\">\"name\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"package-name\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0451A5\">\"version\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"1.0\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0451A5\">\"types\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"./index.d.ts\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0451A5\">\"typesVersions\"</span><span style=\"color: #000000\">: {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"&gt;=3.1\"</span><span style=\"color: #000000\">: { </span><span style=\"color: #0451A5\">\"*\"</span><span style=\"color: #000000\">: [</span><span style=\"color: #A31515\">\"ts3.1/*\"</span><span style=\"color: #000000\">] }</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>This <code>package.json</code> tells TypeScript to check whether the current version of TypeScript is running.\nIf it’s 3.1 or later, it figures out the path you’ve imported relative to the package, and reads from the package’s <code>ts3.1</code> folder.\nThat’s what that <code>{ \"*\": [\"ts3.1/*\"] }</code> means - if you’re familiar with path mapping today, it works exactly like that.</p>\n<p>In the above example, if we’re importing from <code>\"package-name\"</code>, TypeScript will try to resolve from <code>[...]/node_modules/package-name/ts3.1/index.d.ts</code> (and other relevant paths) when running in TypeScript 3.1.\nIf we import from <code>package-name/foo</code>, we’ll try to look for <code>[...]/node_modules/package-name/ts3.1/foo.d.ts</code> and <code>[...]/node_modules/package-name/ts3.1/foo/index.d.ts</code>.</p>\n<p>What if we’re not running in TypeScript 3.1 in this example?\nWell, if none of the fields in <code>typesVersions</code> get matched, TypeScript falls back to the <code>types</code> field, so here TypeScript 3.0 and earlier will be redirected to <code>[...]/node_modules/package-name/index.d.ts</code>.</p>\n<h2 id=\"matching-behavior\" style=\"position:relative;\"><a href=\"#matching-behavior\" aria-label=\"matching behavior permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Matching behavior</h2>\n<p>The way that TypeScript decides on whether a version of the compiler &#x26; language matches is by using Node’s <a href=\"https://github.com/npm/node-semver#ranges\">semver ranges</a>.</p>\n<h2 id=\"multiple-fields\" style=\"position:relative;\"><a href=\"#multiple-fields\" aria-label=\"multiple fields permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Multiple fields</h2>\n<p><code>typesVersions</code> can support multiple fields where each field name is specified by the range to match on.</p>\n<pre class=\"shiki\"><div class=\"language-id\">json</div><div class='code-container'><code><span style=\"color: #000000\">{</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0451A5\">\"name\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"package-name\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0451A5\">\"version\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"1.0\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0451A5\">\"types\"</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"./index.d.ts\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0451A5\">\"typesVersions\"</span><span style=\"color: #000000\">: {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"&gt;=3.2\"</span><span style=\"color: #000000\">: { </span><span style=\"color: #0451A5\">\"*\"</span><span style=\"color: #000000\">: [</span><span style=\"color: #A31515\">\"ts3.2/*\"</span><span style=\"color: #000000\">] },</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"&gt;=3.1\"</span><span style=\"color: #000000\">: { </span><span style=\"color: #0451A5\">\"*\"</span><span style=\"color: #000000\">: [</span><span style=\"color: #A31515\">\"ts3.1/*\"</span><span style=\"color: #000000\">] }</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<p>Since ranges have the potential to overlap, determining which redirect applies is order-specific.\nThat means in the above example, even though both the <code>>=3.2</code> and the <code>>=3.1</code> matchers support TypeScript 3.2 and above, reversing the order could have different behavior, so the above sample would not be equivalent to the following.</p>\n<pre class=\"shiki\"><div class=\"language-id\">json</div><div class='code-container'><code><span style=\"color: #000000\">{</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #AF0B08\">name</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"package-name\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #AF0B08\">version</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"1.0\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #AF0B08\">types</span><span style=\"color: #000000\">: </span><span style=\"color: #A31515\">\"./index.d.ts\"</span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #AF0B08\">typesVersions</span><span style=\"color: #000000\">: {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #008000\">// NOTE: this doesn't work!</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"&gt;=3.1\"</span><span style=\"color: #000000\">: { </span><span style=\"color: #0451A5\">\"*\"</span><span style=\"color: #000000\">: [</span><span style=\"color: #A31515\">\"ts3.1/*\"</span><span style=\"color: #000000\">] },</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0451A5\">\"&gt;=3.2\"</span><span style=\"color: #000000\">: { </span><span style=\"color: #0451A5\">\"*\"</span><span style=\"color: #000000\">: [</span><span style=\"color: #A31515\">\"ts3.2/*\"</span><span style=\"color: #000000\">] },</span>\n<span style=\"color: #000000\">  },</span>\n<span style=\"color: #000000\">}</span></code></div></pre>\n<h2 id=\"publish-to-types\" style=\"position:relative;\"><a href=\"#publish-to-types\" aria-label=\"publish to types permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Publish to <a href=\"https://www.npmjs.com/~types\">@types</a></h2>\n<p>Packages under the <a href=\"https://www.npmjs.com/~types\">@types</a> organization are published automatically from <a href=\"https://github.com/DefinitelyTyped/DefinitelyTyped\">DefinitelyTyped</a> using the <a href=\"https://github.com/Microsoft/types-publisher\">types-publisher tool</a>.\nTo get your declarations published as an @types package, please submit a pull request to <a href=\"https://github.com/DefinitelyTyped/DefinitelyTyped\">DefinitelyTyped</a>.\nYou can find more details in the <a href=\"http://definitelytyped.org/guides/contributing.html\">contribution guidelines page</a>.</p>","headings":[{"value":"Including declarations in your npm package","depth":2},{"value":"Dependencies","depth":2},{"value":"Red flags","depth":2},{"value":"/// <reference path=\"...\" />","depth":3},{"value":"Packaging dependent declarations","depth":3},{"value":"Version selection with typesVersions","depth":2},{"value":"Matching behavior","depth":2},{"value":"Multiple fields","depth":2},{"value":"Publish to @types","depth":2}],"frontmatter":{"permalink":"/docs/handbook/declaration-files/publishing.html","title":"Publishing","disable_toc":null,"oneline":"How to get your d.ts files to users"}},"prev":{"childMarkdownRemark":{"frontmatter":{"title":"Deep Dive","oneline":"How do d.ts files work, a deep dive","permalink":"/docs/handbook/declaration-files/deep-dive.html"}}},"next":{"childMarkdownRemark":{"frontmatter":{"title":"Consumption","oneline":"How to download d.ts files for your project","permalink":"/docs/handbook/declaration-files/consumption.html"}}}},"pageContext":{"id":"publishing","slug":"/docs/handbook/declaration-files/publishing.html","repoPath":"/packages/documentation/copy/en/declaration-files/Publishing.md","previousID":"ed88254c-dd20-5bf8-a82b-9026bcee6164","nextID":"0ed5b202-bf43-5638-a856-0612d1e650d9","lang":"en","modifiedTime":"2020-08-07T17:00:36.335Z"}}}