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

Avoid type modifiers on import names to support TS older than 4.5 #731

Merged
merged 1 commit into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ module.exports = {
"@typescript-eslint/no-base-to-string": "error",
"import/no-cycle": "error",
"import/no-duplicates": "error",
"import/consistent-type-specifier-style": ["error", "prefer-top-level"], // TS 4.5 adds type modifiers on import names, but we want to support lower versions
},
};
}),
Expand Down
3 changes: 2 additions & 1 deletion packages/connect-node-test/src/helpers/testserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import * as http from "http";
import * as https from "https";
import * as fs from "fs";
import * as path from "path";
import { cors, createRouterTransport, type Transport } from "@bufbuild/connect";
import { cors, createRouterTransport } from "@bufbuild/connect";
import type { Transport } from "@bufbuild/connect";
import {
compressionGzip,
connectNodeAdapter,
Expand Down
8 changes: 4 additions & 4 deletions packages/connect-node/src/connect-transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import type {
import type { Interceptor, Transport } from "@bufbuild/connect";
import type { Compression } from "@bufbuild/connect/protocol";
import { createTransport } from "@bufbuild/connect/protocol-connect";
import {
type DeprecatedNodeTransportOptions,
type NodeTransportOptions,
validateNodeTransportOptions,
import { validateNodeTransportOptions } from "./node-transport-options.js";
import type {
DeprecatedNodeTransportOptions,
NodeTransportOptions,
} from "./node-transport-options.js";

/**
Expand Down
8 changes: 4 additions & 4 deletions packages/connect-node/src/grpc-transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import type {
JsonReadOptions,
JsonWriteOptions,
} from "@bufbuild/protobuf";
import {
type DeprecatedNodeTransportOptions,
type NodeTransportOptions,
validateNodeTransportOptions,
import { validateNodeTransportOptions } from "./node-transport-options.js";
import type {
DeprecatedNodeTransportOptions,
NodeTransportOptions,
} from "./node-transport-options.js";

/**
Expand Down
8 changes: 4 additions & 4 deletions packages/connect-node/src/grpc-web-transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import type {
JsonReadOptions,
JsonWriteOptions,
} from "@bufbuild/protobuf";
import {
type DeprecatedNodeTransportOptions,
type NodeTransportOptions,
validateNodeTransportOptions,
import { validateNodeTransportOptions } from "./node-transport-options.js";
import type {
DeprecatedNodeTransportOptions,
NodeTransportOptions,
} from "./node-transport-options.js";

/**
Expand Down
12 changes: 4 additions & 8 deletions packages/connect-node/src/node-transport-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,10 @@ import type {
} from "@bufbuild/connect/protocol";
import { validateReadWriteMaxBytes } from "@bufbuild/connect/protocol";
import { compressionBrotli, compressionGzip } from "./compression.js";
import {
createNodeHttpClient,
type NodeHttp2ClientSessionManager,
} from "./node-universal-client.js";
import {
Http2SessionManager,
type Http2SessionOptions,
} from "./http2-session-manager.js";
import { createNodeHttpClient } from "./node-universal-client.js";
import type { NodeHttp2ClientSessionManager } from "./node-universal-client.js";
import { Http2SessionManager } from "./http2-session-manager.js";
import type { Http2SessionOptions } from "./http2-session-manager.js";
import * as http2 from "http2";
import * as http from "http";
import * as https from "https";
Expand Down
2 changes: 1 addition & 1 deletion packages/connect-node/src/node-universal-handler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import { getNodeErrorProps } from "./node-error.js";
import {
assertByteStreamRequest,
readAllBytes,
type UniversalServerRequest,
} from "@bufbuild/connect/protocol";
import type { UniversalServerRequest } from "@bufbuild/connect/protocol";

// Polyfill the Headers API for Node versions < 18
import "./node-headers-polyfill.js";
Expand Down
3 changes: 2 additions & 1 deletion packages/connect-web-test/src/helpers/crosstestserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import { type Transport, createRouterTransport } from "@bufbuild/connect";
import { createRouterTransport } from "@bufbuild/connect";
import type { Transport } from "@bufbuild/connect";
import {
createConnectTransport,
createGrpcWebTransport,
Expand Down
28 changes: 13 additions & 15 deletions packages/connect/src/protocol-connect/handler-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,28 +58,26 @@ import {
requireProtocolVersionHeader,
requireProtocolVersionParam,
} from "./version.js";
import {
type Compression,
compressionNegotiate,
} from "../protocol/compression.js";
import {
type MethodSerializationLookup,
type Serialization,
createMethodSerializationLookup,
import { compressionNegotiate } from "../protocol/compression.js";
import type { Compression } from "../protocol/compression.js";
import { createMethodSerializationLookup } from "../protocol/serialization.js";
import type {
MethodSerializationLookup,
Serialization,
} from "../protocol/serialization.js";
import { validateUniversalHandlerOptions } from "../protocol/universal-handler.js";
import type { UniversalHandlerOptions } from "../protocol/universal-handler.js";
import {
type UniversalHandlerOptions,
validateUniversalHandlerOptions,
} from "../protocol/universal-handler.js";
import {
type UniversalHandlerFn,
type UniversalServerRequest,
type UniversalServerResponse,
assertByteStreamRequest,
uResponseMethodNotAllowed,
uResponseOk,
uResponseUnsupportedMediaType,
} from "../protocol/universal.js";
import type {
UniversalHandlerFn,
UniversalServerRequest,
UniversalServerResponse,
} from "../protocol/universal.js";
import {
createAsyncIterable,
pipe,
Expand Down
18 changes: 8 additions & 10 deletions packages/connect/src/protocol-grpc-web/handler-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,20 @@ import { createMethodUrl } from "../protocol/create-method-url.js";
import type { EnvelopedMessage } from "../protocol/envelope.js";
import { transformInvokeImplementation } from "../protocol/invoke-implementation.js";
import type { ProtocolHandlerFactory } from "../protocol/protocol-handler-factory.js";
import { createMethodSerializationLookup } from "../protocol/serialization.js";
import type { Serialization } from "../protocol/serialization.js";
import { validateUniversalHandlerOptions } from "../protocol/universal-handler.js";
import type { UniversalHandlerOptions } from "../protocol/universal-handler.js";
import {
type Serialization,
createMethodSerializationLookup,
} from "../protocol/serialization.js";
import {
type UniversalHandlerOptions,
validateUniversalHandlerOptions,
} from "../protocol/universal-handler.js";
import {
type UniversalServerRequest,
type UniversalServerResponse,
assertByteStreamRequest,
uResponseUnsupportedMediaType,
uResponseMethodNotAllowed,
uResponseOk,
} from "../protocol/universal.js";
import type {
UniversalServerRequest,
UniversalServerResponse,
} from "../protocol/universal.js";

const protocolName = "grpc-web";
const methodPost = "POST";
Expand Down
12 changes: 6 additions & 6 deletions packages/connect/src/protocol-grpc/handler-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,18 @@ import { createMethodUrl } from "../protocol/create-method-url.js";
import { transformInvokeImplementation } from "../protocol/invoke-implementation.js";
import type { ProtocolHandlerFactory } from "../protocol/protocol-handler-factory.js";
import { createMethodSerializationLookup } from "../protocol/serialization.js";
import { validateUniversalHandlerOptions } from "../protocol/universal-handler.js";
import type { UniversalHandlerOptions } from "../protocol/universal-handler.js";
import {
type UniversalHandlerOptions,
validateUniversalHandlerOptions,
} from "../protocol/universal-handler.js";
import {
type UniversalServerRequest,
type UniversalServerResponse,
assertByteStreamRequest,
uResponseUnsupportedMediaType,
uResponseMethodNotAllowed,
uResponseOk,
} from "../protocol/universal.js";
import type {
UniversalServerRequest,
UniversalServerResponse,
} from "../protocol/universal.js";

const protocolName = "grpc";
const methodPost = "POST";
Expand Down
8 changes: 2 additions & 6 deletions packages/connect/src/protocol/run-call.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import {
Int32Value,
MethodKind,
type ServiceType,
StringValue,
} from "@bufbuild/protobuf";
import { Int32Value, MethodKind, StringValue } from "@bufbuild/protobuf";
import type { ServiceType } from "@bufbuild/protobuf";
import { runStreamingCall, runUnaryCall } from "./run-call.js";
import type {
StreamRequest,
Expand Down
6 changes: 4 additions & 2 deletions packages/connect/src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ import { createHandlerFactory as handlerFactoryGrpcWeb } from "./protocol-grpc-w
import { createHandlerFactory as handlerFactoryGrpc } from "./protocol-grpc/handler-factory.js";
import { createHandlerFactory as handlerFactoryConnect } from "./protocol-connect/handler-factory.js";
import {
type UniversalHandler,
type UniversalHandlerOptions,
createUniversalMethodHandler,
createUniversalServiceHandlers,
validateUniversalHandlerOptions,
} from "./protocol/universal-handler.js";
import type {
UniversalHandler,
UniversalHandlerOptions,
} from "./protocol/universal-handler.js";
import type { ProtocolHandlerFactory } from "./protocol/protocol-handler-factory.js";

/**
Expand Down