-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Typescript definitions not valid #737
Comments
Imho, TypeScript shouldn't use JSDoc data from d.ts files at all, because these cannot even contain JavaScript technically. Not sure that this is a protobuf.js problem in the first place. Of course we can fix this for now by excluding just |
Typescript is rather new and very swiftly evolving project, but right now use of protobufjs in typescript projects lead to above problem Personally I agree with you and see no reason typescript using JSDoc data from d.ts, but that's current situation. I also see no reason to keep JSDoc data in d.ts files, as JSDoc and d.ts both define type data Will you fix the problem? |
The idea here is to provide textual IntelliSense documentation right from the .d.ts file, even when using a .min.js file.
Sure. |
We are having the same issue, |
When not using long.js typings, just reference the stub somewhere in your project: /// <reference path="./node_modules/protobufjs/stub-long.d.ts" /> |
protobuf.js version: 6.7.0
npm i -g typescript@next
import.ts:
import * as protobuf from "protobufjs";
console.log("a");
npm install protobufjs
tsc test.ts
Expected behaviour: compile success
Current behaviour: numerous typescript errors:
node_modules/protobufjs/index.d.ts(419,13): error TS2300: Duplicate identifier 'LoadCallback'.
node_modules/protobufjs/index.d.ts(425,6): error TS2300: Duplicate identifier 'LoadCallback'.
node_modules/protobufjs/index.d.ts(1103,13): error TS2300: Duplicate identifier 'ParserResult'.
node_modules/protobufjs/index.d.ts(1111,6): error TS2300: Duplicate identifier 'ParserResult'.
node_modules/protobufjs/index.d.ts(1115,13): error TS2300: Duplicate identifier 'ParseOptions'.
node_modules/protobufjs/index.d.ts(1119,6): error TS2300: Duplicate identifier 'ParseOptions'.
node_modules/protobufjs/index.d.ts(1520,40): error TS2694: Namespace '"C:/a/node_modules/protobufjs/index".rpc.rpc' has no exported member 'Service'.
node_modules/protobufjs/index.d.ts(1526,13): error TS2300: Duplicate identifier 'RPCImpl'.
node_modules/protobufjs/index.d.ts(1541,6): error TS2300: Duplicate identifier 'RPCImpl'.
node_modules/protobufjs/index.d.ts(1545,13): error TS2300: Duplicate identifier 'RPCImplCallback'.
node_modules/protobufjs/index.d.ts(1551,6): error TS2300: Duplicate identifier 'RPCImplCallback'.
node_modules/protobufjs/index.d.ts(1610,33): error TS2300: Duplicate identifier 'TokenizerHandle'.
node_modules/protobufjs/index.d.ts(1618,6): error TS2300: Duplicate identifier 'TokenizerHandle'.
node_modules/protobufjs/index.d.ts(1821,13): error TS2300: Duplicate identifier 'ConversionOptions'.
node_modules/protobufjs/index.d.ts(1836,11): error TS2300: Duplicate identifier 'ConversionOptions'.
node_modules/protobufjs/index.d.ts(2013,13): error TS2300: Duplicate identifier 'Long'.
...
Way to fix: rebuild protobufjs file index.d.ts by pbts but with added option --no-comments
Reason: Typescript using JSDoc data to build types info, but with JSDoc comments typescript use same types twice:
/**
null
*/
type LoadCallback = (error: Error, root?: Root) => void;
The text was updated successfully, but these errors were encountered: