This package provides comprehensive TypeScript type definitions for the W3C Navigation API, accessible via `window.navigation` in modern browsers. It is a types-only package, meaning it does not include a polyfill or runtime implementation of the API, focusing solely on providing accurate typings for development. The current stable version is 0.6.1, with releases occurring periodically to align with updates and changes in the Navigation API specification. Its primary differentiator is offering early access to these types, enabling developers to leverage the Navigation API in TypeScript projects before broader `lib.dom` support or for specific browser targetting, ensuring type safety and improved developer experience.
npm install navigation-api-typesVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to set up the global ambient types for the Navigation API and then use `window.navigation` with full type safety to add event listeners and access properties, preventing TypeScript errors.
Review the package's changelog for specific changes and update your code to use the latest type definitions and adhere to the current Navigation API specification. This may involve renaming types or adjusting property access.
Ensure your global `.d.ts` file contains only `/// <reference types="navigation-api-types" />` and other ambient declarations, without any `import` or `export` keywords.
Always use `/// <reference types='navigation-api-types' />` at the top of your `.ts` files or in a global `.d.ts` file to make the types available. Do not use `import` statements for this package's types.
Ensure you have correctly added `/// <reference types="navigation-api-types" />` to either a global `.d.ts` file or at the top of the specific `.ts` file where you are using `window.navigation`.
Verify that your `/// <reference types="navigation-api-types" />` directive is correctly placed and visible to TypeScript according to your `tsconfig.json` settings. For global availability, ensure the `.d.ts` file containing the directive is not treated as a module (no `import`/`export` statements).
Remove all `import` and `export` statements from your `global.d.ts` (or similar ambient type declaration) file. It should only contain `declare` statements or triple-slash directives.
No dependency data recorded yet.