fix: add explicit .js extensions to relative imports so declarations resolve under NodeNext/Node16

The emitted .d.ts copy relative specifiers verbatim, and the extensionless form
(e.g. `from "./events"`) doesn't resolve under Node16/NodeNext, hiding inherited
members such as `addEventListener` (TS2339). Appending `.js` matches the existing
SDK-import style and works with both bundler-mode type-checking and Bun.build.
Types-only; runtime is unaffected.

Fixes #704
This commit is contained in:
Ken Jo 2026-07-11 21:03:43 +09:00 • committed by Olivier Chafik
commit 264d9cae44
12 changed files with 35 additions and 35 deletions

View file

@ -3,8 +3,8 @@ import { Client, InMemoryTransport } from "@modelcontextprotocol/client";
import { Server, type ServerCapabilities } from "@modelcontextprotocol/server";
import { z } from "zod/v4";
import { App } from "./app";
import { LATEST_PROTOCOL_VERSION } from "./types";
import { App } from "./app.js";
import { LATEST_PROTOCOL_VERSION } from "./types.js";
import {
AppBridge,
buildAllowAttribute,
@ -13,7 +13,7 @@ import {
isToolVisibilityAppOnly,
McpUiOpenLinkResultSchema,
type McpUiHostCapabilities,
} from "./app-bridge";
} from "./app-bridge.js";
/** Wait for pending microtasks to complete */
const flush = () => new Promise((resolve) => setTimeout(resolve, 0));

View file

@ -34,7 +34,7 @@ import {
EmptyResultSchema,
LoggingMessageNotificationSchema,
} from "@modelcontextprotocol/core";
import { EventDispatcher } from "./events";
import { EventDispatcher } from "./events.js";
import type { ZodLiteral, ZodObject, ZodType } from "zod/v4";
type MethodSchema = ZodObject<{
@ -87,11 +87,11 @@ import {
McpUiRequestDisplayModeResultSchema,
McpUiResourcePermissions,
McpUiToolMeta,
} from "./types";
export * from "./types";
export { RESOURCE_URI_META_KEY, RESOURCE_MIME_TYPE } from "./constants";
import { RESOURCE_URI_META_KEY } from "./constants";
export { PostMessageTransport } from "./message-transport";
} from "./types.js";
export * from "./types.js";
export { RESOURCE_URI_META_KEY, RESOURCE_MIME_TYPE } from "./constants.js";
import { RESOURCE_URI_META_KEY } from "./constants.js";
export { PostMessageTransport } from "./message-transport.js";
/**
* Extract UI resource URI from tool metadata.

View file

@ -22,10 +22,10 @@ import {
type Transport,
} from "@modelcontextprotocol/client";
import { EmptyResultSchema } from "@modelcontextprotocol/core";
export { RESOURCE_MIME_TYPE, RESOURCE_URI_META_KEY } from "./constants";
import { EventDispatcher } from "./events";
export { EventDispatcher } from "./events";
import { PostMessageTransport } from "./message-transport";
export { RESOURCE_MIME_TYPE, RESOURCE_URI_META_KEY } from "./constants.js";
import { EventDispatcher } from "./events.js";
export { EventDispatcher } from "./events.js";
import { PostMessageTransport } from "./message-transport.js";
import {
LATEST_PROTOCOL_VERSION,
McpUiAppCapabilities,
@ -59,12 +59,12 @@ import {
McpUiToolResultNotificationSchema,
McpUiRequestDisplayModeRequest,
McpUiRequestDisplayModeResultSchema,
} from "./types";
} from "./types.js";
import {
StandardSchemaV1,
standardSchemaToJsonSchema,
validateStandardSchema,
} from "./standard-schema";
} from "./standard-schema.js";
import { z, type ZodLiteral, type ZodObject, type ZodType } from "zod/v4";
type MethodSchema = ZodObject<{
@ -92,16 +92,16 @@ function mergeAppCapabilities(
export type {
StandardSchemaV1,
StandardSchemaWithJSON,
} from "./standard-schema";
} from "./standard-schema.js";
export { PostMessageTransport } from "./message-transport";
export * from "./types";
export { PostMessageTransport } from "./message-transport.js";
export * from "./types.js";
export {
applyHostStyleVariables,
applyHostFonts,
getDocumentTheme,
applyDocumentTheme,
} from "./styles";
} from "./styles.js";
/**
* Metadata key for associating a UI resource URI with a tool.

View file

@ -1,7 +1,7 @@
import { describe, it, expect, beforeEach, afterEach, mock } from "bun:test";
import type { JSONRPCMessage } from "@modelcontextprotocol/client";
import { PostMessageTransport } from "./message-transport";
import { PostMessageTransport } from "./message-transport.js";
/**
* Minimal `window` stub for bun's DOM-less test environment.

View file

@ -5,7 +5,7 @@ import type {
Transport,
TransportSendOptions,
} from "@modelcontextprotocol/client";
import { TOOL_INPUT_PARTIAL_METHOD } from "./spec.types";
import { TOOL_INPUT_PARTIAL_METHOD } from "./spec.types.js";
/**
* JSON-RPC transport using `window.postMessage` for iframe↔parent communication.

View file

@ -31,7 +31,7 @@
* }
* ```
*/
export * from "./useApp";
export * from "./useAutoResize";
export * from "./useDocumentTheme";
export * from "./useHostStyles";
export * from "./useApp.js";
export * from "./useAutoResize.js";
export * from "./useDocumentTheme.js";
export * from "./useHostStyles.js";

View file

@ -5,8 +5,8 @@ import {
AppOptions,
McpUiAppCapabilities,
PostMessageTransport,
} from "../app";
export * from "../app";
} from "../app.js";
export * from "../app.js";
/**
* Options for configuring the {@link useApp `useApp`} hook.

View file

@ -1,5 +1,5 @@
import { useEffect, RefObject } from "react";
import { App } from "../app";
import { App } from "../app.js";
/**
* React hook that automatically reports UI size changes to the host.

View file

@ -1,6 +1,6 @@
import { useEffect, useState } from "react";
import { getDocumentTheme } from "../styles";
import { McpUiTheme } from "../types";
import { getDocumentTheme } from "../styles.js";
import { McpUiTheme } from "../types.js";
/**
* React hook that provides the current document theme reactively.

View file

@ -1,11 +1,11 @@
import { useEffect, useRef } from "react";
import { App } from "../app";
import { App } from "../app.js";
import {
applyDocumentTheme,
applyHostFonts,
applyHostStyleVariables,
} from "../styles";
import { McpUiHostContext } from "../types";
} from "../styles.js";
import { McpUiHostContext } from "../types.js";
/**
* React hook that applies host style variables and theme as CSS custom properties.

View file

@ -6,7 +6,7 @@ import {
RESOURCE_MIME_TYPE,
getUiCapability,
EXTENSION_ID,
} from "./index";
} from "./index.js";
import type { McpServer } from "@modelcontextprotocol/server";
describe("registerAppTool", () => {

View file

@ -1,4 +1,4 @@
import { McpUiStyles, McpUiTheme } from "./types";
import { McpUiStyles, McpUiTheme } from "./types.js";
/**
* Get the current document theme from the root HTML element.