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

TypeScript error in index.d.ts with Long type #753

Closed
microshine opened this issue Apr 8, 2017 · 6 comments
Closed

TypeScript error in index.d.ts with Long type #753

microshine opened this issue Apr 8, 2017 · 6 comments

Comments

@microshine
Copy link

protobuf.js version: 6.7.1

I'm using you library in my project, but I've got error after last protobufjs update

Log

node_modules/protobufjs/index.d.ts(1293,21): error TS2304: Cannot find name 'Long'.
node_modules/protobufjs/index.d.ts(1301,22): error TS2304: Cannot find name 'Long'.
node_modules/protobufjs/index.d.ts(1309,22): error TS2304: Cannot find name 'Long'.
node_modules/protobufjs/index.d.ts(1335,23): error TS2304: Cannot find name 'Long'.
node_modules/protobufjs/index.d.ts(1343,24): error TS2304: Cannot find name 'Long'.
node_modules/protobufjs/index.d.ts(2112,36): error TS2304: Cannot find name 'Long'.
node_modules/protobufjs/index.d.ts(2126,44): error TS2304: Cannot find name 'Long'.
node_modules/protobufjs/index.d.ts(2274,33): error TS2304: Cannot find name 'Long'.
node_modules/protobufjs/index.d.ts(2282,63): error TS2304: Cannot find name 'Long'.
node_modules/protobufjs/index.d.ts(2827,27): error TS2304: Cannot find name 'Long'.
node_modules/protobufjs/index.d.ts(2836,26): error TS2304: Cannot find name 'Long'.
node_modules/protobufjs/index.d.ts(2844,27): error TS2304: Cannot find name 'Long'.
node_modules/protobufjs/index.d.ts(2874,28): error TS2304: Cannot find name 'Long'.
node_modules/protobufjs/index.d.ts(2883,29): error TS2304: Cannot find name 'Long'.

the problem is that you have @types/long in devDependencies, but it must be in dependencies

@dcodeIO
Copy link
Member

dcodeIO commented Apr 8, 2017

See: https://github.com/dcodeIO/protobuf.js#usage-with-typescript

I moved it to dev because frontend people (not using long.js) were complaining. Now it's all opt-in.

@microshine
Copy link
Author

microshine commented Apr 8, 2017

there is no problem to compile module directly from VS Code. But what if i use npm for it. It doesn't download modules automatically

@types/long is lib only for TS. I think if you publish your module with d.ts in it it has to install other TS dependencies too

@dcodeIO
Copy link
Member

dcodeIO commented Apr 8, 2017

Related: #711

No matter how I do it...

@microshine
Copy link
Author

@types/long doesn't dependence of node.d.ts. It's safe for using in frontend and backend applications

So you can move it to dependencies without @types/node

@dcodeIO
Copy link
Member

dcodeIO commented Apr 8, 2017

It's a similar situation, though. Without @types/node, tsc will error out because of Buffer. With @types/node, #711 comes on the table.

This is a mess. Having strict types in JS where everything is optional is a mess. Not for the user, but for developers of libraries like this one - i.e. where using long.js is optional and running on node is just one side of the coin. Damn it, TypeScript.

dcodeIO added a commit that referenced this issue Apr 8, 2017


It's impossible anyway to get this right for everyone, so here's the intended setup and everything else is re-configuration.
@dcodeIO
Copy link
Member

dcodeIO commented Apr 8, 2017

Ok then, this is the intended setup now, born from a bold decision on the management level, and it's doing exactly what you want, surprisingly. I'll send everyone arguing about it in the future right into your direction. It's all your fault now. I wash my hands of it. (jk)

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

2 participants