Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add typings to package output #1300

Closed
wants to merge 1 commit into from

Conversation

dnikitop
Copy link

Changelog

Docs

Description

Getting these errors in when importing

node_modules/@mcap/support/dist/esm/src/protobufDescriptors.d.ts:1:22 - error TS6053: File '/home/dimitri/src/rosbags2js/node_modules/@mcap/support/typings/protobufjs.d.ts' not found.

1 /// <reference path="../../../typings/protobufjs.d.ts" />
                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@mcap/support/dist/esm/src/protobufDescriptors.d.ts:3:61 - error TS2339: Property 'toDescriptor' does not exist on type 'Root'.

3 export type ProtobufDescriptor = ReturnType<protobufjs.Root["toDescriptor"]>;                                       

PR adds typings/protobufjs.d.ts to package

BeforeAfter

@jtbandes
Copy link
Member

jtbandes commented Jan 6, 2025

What were you importing that caused this error? I've never seen this before.

@dnikitop
Copy link
Author

dnikitop commented Jan 6, 2025

What were you importing that caused this error? I've never seen this before.

Create a new package that imports this.
Importing

import { parse as parseMessageDefinition } from "@foxglove/rosmsg";
import {
  LazyMessageReader as ROS1LazyMessageReader,
  Time,
} from "@foxglove/rosmsg-serialization";
import { MessageReader as ROS2MessageReader } from "@foxglove/rosmsg2-serialization";
import { McapStreamReader, McapTypes } from "@mcap/core";
import { loadDecompressHandlers } from "@mcap/support";
import { createReadStream } from "fs";
import { isEqual } from "lodash";
import { performance } from "perf_hooks";
import protobufjs from "protobufjs";
import { FileDescriptorSet } from "protobufjs/ext/descriptor";

Using this tsconfig

{
  "compilerOptions": {
    "module": "commonjs",
    "esModuleInterop": true,
    "target": "es2020",
    "moduleResolution": "node",
    "sourceMap": true,
    "outDir": "dist",
    "lib": ["es2020"]
  }
}

@dnikitop
Copy link
Author

dnikitop commented Jan 8, 2025

@jtbandes any updates on this?

I can create sample repo trying to import the mcap packages to show the issue

@amacneil
Copy link
Contributor

amacneil commented Jan 22, 2025

Replaced by #1318

@amacneil amacneil closed this Jan 23, 2025
jtbandes added a commit that referenced this pull request Jan 24, 2025
…ource file (#1318)

### Changelog
@mcap/support: Fixed a TS error from an import that did not work in the
published package

### Docs

None

### Description

Supersedes / closes #1300 
See also protobufjs/protobuf.js#1499

This area of TypeScript arcana is confusing, but I don't think there is
anything about [module
augmentations](https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation)
that requires them to be in a `.d.ts` file.

The way it's currently done was generally working, except as pointed out
in #1300 we didn't include the `typings` dir in the published package.

I believe we didn't run into this problem in our own code because we
usually turn on `"skipLibCheck": true`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants