Published package is missing type declarations
See original GitHub issue[REQUIRED] Environment info
firebase-tools: 8.4.3
Platform: macOS Catalina
[REQUIRED] Test case
import * as firebaseTools from 'firebase-tools'
or
import firebaseTools from 'firebase-tools'
[REQUIRED] Steps to reproduce
Just import the ‘firebase-tools’ module in a TypeScript file and run tsc
on it.
[REQUIRED] Expected behavior
It should come with its own types (it is written in TypeScript, after all).
[REQUIRED] Actual behavior
TypeScript complains that this module has no type declations:
Could not find a declaration file for module 'firebase-tools'. '<REDACTED>/node_modules/firebase-tools/lib/index.js' implicitly has an 'any' type.
Try `npm install @types/firebase-tools` if it exists or add a new declaration (.d.ts) file containing `declare module 'firebase-tools';`
Sure enough, looking at the actual published package in my node_modules
, it contains no .d.ts
files. Why?
There’s also nothing at @types/firebase-tools
.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:31
- Comments:7 (3 by maintainers)
Top Results From Across the Web
How to Declare Missing Types for External Libraries -- newline
Custom Types Declaration#. First, in your tsconfig.json add a directory path to type declarations:.
Read more >Missing type definition information in VS Code when own ...
Missing type definitions when referencing the published package: import { CrmRpc} from "efficy-enterprise-api"; const crm = new ...
Read more >Documentation - Publishing - TypeScript
There are two main ways you can publish your declaration files to npm: bundling with your npm package; publishing to the @types organization...
Read more >A Complete Guide to Using TypeScript in Node.js - Better Stack
Fixing errors caused by missing types. Setting up linting and formatting for TypeScript files. Debugging TypeScript in Chrome or VS Code.
Read more >A quick introduction to “Type Declaration” files and adding ...
The DefinitelyTyped community writes declaration packages for such third-party libraries and platforms. These declaration packages are published ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
ditto. Why isn’t this high priority?
@samtstern thanks for the quick response! I did try using that schema with
json-schema-to-typescript
to essentially recreatefirebaseConfig.ts
, but the generated TypeScript is more convoluted and missing granular type definitions.You can see the difference by comparing the original firebaseConfig.ts to what is generated from
json-schema-to-typescript
.I do feel a bit icky copying
firebaseConfig.ts
directly into the package I’m working on, but certainly less icky than using a schema generated from TypeScript to recreate an approximation of types not yet exported from this package. The ‘Advanced’ example from the package I linked above would not be possible without those type definitions: