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

Protobuf .d.ts file overwritten at compile time? #23

Open
jbrjake opened this issue Sep 15, 2022 · 0 comments
Open

Protobuf .d.ts file overwritten at compile time? #23

jbrjake opened this issue Sep 15, 2022 · 0 comments

Comments

@jbrjake
Copy link

jbrjake commented Sep 15, 2022

I noticed that I couldn't compile a TypeScript project which depended on sketch-js, because it couldn't find interfaces exported by the proto:

node_modules/@datadog/sketches-js/dist/ddsketch/mapping/CubicallyInterpolatedMapping.d.ts:2:10 - error TS2305: Module '"../proto/compiled"' has no exported member 'IndexMapping'.

Looking in the node_modules of my project, I noticed that @datadog/sketches-js/dist/ddsketch/proto/compiled.d.ts contained only the lines:

export = $root;
declare var $root: $protobuf.Root;
import $protobuf = require("protobufjs/minimal");

...instead of the rich types you provide in that file in this git repo.

This looks similar to an issue in another project, which I found when googling the error message I was seeing:
https://github.com/cryptowatch/cw-sdk-node/issues/31

The problem is that tsc, when generating declarations, overrides the existing compiled.d.ts file in its zeal to declare types for compiled.js.

When I simply paste the real file into my node_modules, I'm able to successfully build my dependent project.

I looked for ways to avoid generating declarations for only one file, but couldn't find an option like that in tsc.

I believe this should be resolvable by appending a copy to the build script in package.json:

    "build": "yarn clean; tsc -p tsconfig.build.json; cp src/ddsketch/proto/compiled.d.ts dist/ddsketch/proto/compiled.d.ts",
jbrjake added a commit to jbrjake/sketches-js that referenced this issue Jul 11, 2023
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

No branches or pull requests

1 participant