Skip to content

fix(usage): add chrome namespace to Window and add usage directions, fixes #17 - #34

Open
MichaelSolati wants to merge 1 commit into
GoogleChrome:mainfrom
MichaelSolati:fix/usage
Open

fix(usage): add chrome namespace to Window and add usage directions, fixes #17#34
MichaelSolati wants to merge 1 commit into
GoogleChrome:mainfrom
MichaelSolati:fix/usage

Conversation

@MichaelSolati

Copy link
Copy Markdown
Contributor
  1. Add dist/global.d.ts which takes the build output and adds it to the Window interface.
  2. Update dist/README.md to document how to include this lib into a projects global typings.
  3. Tell .gitignore to include dist/global.d.ts.
  4. Update dist/package.template.json with some keywords for search on npm.

See this video for a little better explenation. I also didn't want to modify any of the existing files so that we don't break the chrome types being used for dcc.

@codecov

codecov Bot commented Mar 2, 2022

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 35.47%. Comparing base (dfe80f3) to head (b93130d).
⚠️ Report is 73 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #34   +/-   ##
=======================================
  Coverage   35.47%   35.47%           
=======================================
  Files          21       21           
  Lines        3986     3986           
  Branches      183      183           
=======================================
  Hits         1414     1414           
  Misses       2572     2572           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@MichaelSolati

Copy link
Copy Markdown
Contributor Author

@devnook ptal

@someengineer-nordsec

Copy link
Copy Markdown

this will not force it to be a primary resolution in case some third party package installed @types/chrome

@MichaelSolati

Copy link
Copy Markdown
Contributor Author

@olso-nordsec without being in the @types namespace this isn't an easy (possible?) thing to achieve. Additionally, merging with @DefinitelyTyped is something that makes sense to do. The way the typed libraries work with DefinitelyTyped and this lib work are very different. It would be interesting if there was a @types/* lib that digests what's generated and exports it would be interesting, but that depends on the bandwidth of the Chrome team.

@someengineer-nordsec

Copy link
Copy Markdown

For now, I'm using patch-package

diff --git a/node_modules/chrome-types/index.d.ts b/node_modules/chrome-types/index.d.ts
index 4438d02..41e7899 100644
--- a/node_modules/chrome-types/index.d.ts
+++ b/node_modules/chrome-types/index.d.ts
@@ -1,3 +1,4 @@
+declare module 'chrome-types' {
 /**
  * Copyright 2022 Google LLC
  *
@@ -28738,3 +28739,4 @@ declare namespace chrome {
     ): void;
   }
 }
+}

and then using it as

import type { chrome } from 'chrome-types';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants