ts-proto 1.116.1 → 1.117.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [1.117.0](https://github.com/stephenh/ts-proto/compare/v1.116.1...v1.117.0) (2022-07-05)
2
+
3
+
4
+ ### Features
5
+
6
+ * add importSuffix option and remove default .js suffix ([#612](https://github.com/stephenh/ts-proto/issues/612)) ([63a8895](https://github.com/stephenh/ts-proto/commit/63a8895f5a3a38fa3d5c0868f44e950e137fb697))
7
+
1
8
  ## [1.116.1](https://github.com/stephenh/ts-proto/compare/v1.116.0...v1.116.1) (2022-07-02)
2
9
 
3
10
 
package/README.markdown CHANGED
@@ -388,6 +388,8 @@ Generated code will be placed in the Gradle build directory.
388
388
 
389
389
  - With `--ts_proto_opt=fileSuffix=<SUFFIX>`, ts-proto will emit generated files using the specified suffix. A `helloworld.proto` file with `fileSuffix=.pb` would be generated as `helloworld.pb.ts`. This is common behavior in other protoc plugins and provides a way to quickly glob all the generated files.
390
390
 
391
+ - With `--ts_proto_opt=importSuffix=<SUFFIX>`, ts-proto will emit file imports using the specified suffix. An import of `helloworld.ts` with `fileSuffix=.js` would generate `import "helloworld.js"`. The default is to import without a file extension. Supported by TypeScript 4.7.x and up.
392
+
391
393
  - With `--ts_proto_opt=enumsAsLiterals=true`, the generated enum types will be enum-ish object with `as const`.
392
394
 
393
395
  - With `--ts_proto_opt=useExactTypes=false`, the generated `fromPartial` method will not use Exact types.
package/build/options.js CHANGED
@@ -43,6 +43,7 @@ function defaultOptions() {
43
43
  oneof: OneofOption.PROPERTIES,
44
44
  esModuleInterop: false,
45
45
  fileSuffix: '',
46
+ importSuffix: '',
46
47
  lowerCaseServiceMethods: false,
47
48
  outputEncodeMethods: true,
48
49
  outputJsonMethods: true,
@@ -163,7 +164,7 @@ function parseParameter(parameter) {
163
164
  });
164
165
  return options;
165
166
  }
166
- function getTsPoetOpts(options) {
167
+ function getTsPoetOpts(_options) {
167
168
  return { forceModuleImport: ['protobufjs/minimal'] };
168
169
  }
169
170
  exports.getTsPoetOpts = getTsPoetOpts;
package/build/utils.js CHANGED
@@ -170,8 +170,7 @@ function getPropertyAccessor(objectName, propertyName, optional = false) {
170
170
  }
171
171
  exports.getPropertyAccessor = getPropertyAccessor;
172
172
  function impProto(options, module, type) {
173
- // NOTE: TypeScript resolves importing foo.js to importing foo.ts.
174
- const importString = `${type}@./${module}${options.fileSuffix}.js`;
173
+ const importString = `${type}@./${module}${options.fileSuffix}${options.importSuffix}`;
175
174
  if (options.onlyTypes) {
176
175
  return (0, ts_poet_1.imp)('t:' + importString);
177
176
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-proto",
3
- "version": "1.116.1",
3
+ "version": "1.117.0",
4
4
  "description": "",
5
5
  "main": "build/plugin.js",
6
6
  "repository": "github:stephenh/ts-proto",
@@ -68,6 +68,6 @@
68
68
  "object-hash": "^1.3.1",
69
69
  "protobufjs": "^6.11.3",
70
70
  "ts-poet": "^4.15.0",
71
- "ts-proto-descriptors": "1.7.0"
71
+ "ts-proto-descriptors": "1.7.1"
72
72
  }
73
73
  }