-
Notifications
You must be signed in to change notification settings - Fork 687
Open
Description
Environment
- Mac m1 2020
- Node 18.14.2
- nvm
- @grpc/grpc-js: "^1.8.13",
- @grpc/proto-loader: "^0.7.6"
Problem description
The generated file(s) are not compatible with ES modules.
Reproduction steps
- Package.json with
"type": "module" - tsconfig with
"module": "node16", "moduleResolution": "node16" - generate types using command:
proto-loader-gen-types --longs=String --enums=String --defaults --oneofs --grpcLib=@grpc/grpc-js --outDir=src/generated src/.proto
How to Fix
The generated import should end with ".js": (See image below)
import type { BookItem as _bookStorePackage_BookItem, BookItem__Output as _bookStorePackage_BookItem__Output } from '../bookStorePackage/BookItem.js';Additional context
Current error:
error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './bookStorePackage/Book.js'?Proto file:
syntax = 'proto3';
package bookStorePackage;
service Book {
rpc createBook (BookItem) returns (BookItem);
}
message BookItem {
int32 id = 1;
string book = 2;
}sumbad, magiclen, glebbash, chernodub, dbollinger and 2 moreNickKelly1
