Skip to content

Isolated declarations errors occur in third-party node_modules when they ship with original TypeScript source filesΒ #58909

@MichaelMitchell-at

Description

@MichaelMitchell-at

πŸ”Ž Search Terms

isolated declarations node_modules

πŸ•— Version & Regression Information

  • Currently reproduces in nightly

⏯ Playground Link

No response

πŸ’» Code

// @filename: package.json
{
  "dependencies": {
    "@trpc/server": "10.29.1",
    "typescript": "5.6.0-dev.20240617"
  }
}

// @filename: tsconfig.json
{
  "compilerOptions": {
    "declaration": true,
    "emitDeclarationOnly": true,
    "isolatedDeclarations": true,
    "outDir": "declarations",
    "skipLibCheck": true
  },
  "files": ["index.ts"],
  "include": ["index.ts"]
}

// @filename: index.ts
import { initTRPC } from "@trpc/server";

const trpc = initTRPC.create();

export const middleware = trpc.middleware;
export const router = trpc.router;
export const publicProcedure = trpc.procedure;

πŸ™ Actual behavior

Error:

index.ts:5:14 - error TS9010: Variable must have an explicit type annotation with --isolatedDeclarations.

5 export const middleware = trpc.middleware;
               ~~~~~~~~~~

  index.ts:5:14
    5 export const middleware = trpc.middleware;
                   ~~~~~~~~~~
    Add a type annotation to the variable middleware.

index.ts:6:14 - error TS9010: Variable must have an explicit type annotation with --isolatedDeclarations.

6 export const router = trpc.router;
               ~~~~~~

  index.ts:6:14
    6 export const router = trpc.router;
                   ~~~~~~
    Add a type annotation to the variable router.

index.ts:7:14 - error TS9010: Variable must have an explicit type annotation with --isolatedDeclarations.

7 export const publicProcedure = trpc.procedure;
               ~~~~~~~~~~~~~~~

  index.ts:7:14
    7 export const publicProcedure = trpc.procedure;
                   ~~~~~~~~~~~~~~~
    Add a type annotation to the variable publicProcedure.

node_modules/@trpc/server/dist/core/initTRPC.d.ts:72:22 - error TS9039: Type containing private name 'RootConfig' can't be used with --isolatedDeclarations.

72             _config: RootConfig<{
                        ~~~~~~~~~~

node_modules/@trpc/server/dist/core/initTRPC.d.ts:75:29 - error TS9039: Type containing private name 'ErrorFormatterShape' can't be used with --isolatedDeclarations.

75                 errorShape: ErrorFormatterShape<PickFirstDefined<TOptions["errorFormatter"], ErrorFormatter<TParams["ctx"] extends object ? TParams["ctx"] : object, DefaultErrorShape>>>;
                               ~~~~~~~~~~~~~~~~~~~

node_modules/@trpc/server/dist/core/initTRPC.d.ts:75:49 - error TS9039: Type containing private name 'PickFirstDefined' can't be used with --isolatedDeclarations.

75                 errorShape: ErrorFormatterShape<PickFirstDefined<TOptions["errorFormatter"], ErrorFormatter<TParams["ctx"] extends object ? TParams["ctx"] : object, DefaultErrorShape>>>;
                                                   ~~~~~~~~~~~~~~~~

node_modules/@trpc/server/dist/core/initTRPC.d.ts:75:94 - error TS9039: Type containing private name 'ErrorFormatter' can't be used with --isolatedDeclarations.

75                 errorShape: ErrorFormatterShape<PickFirstDefined<TOptions["errorFormatter"], ErrorFormatter<TParams["ctx"] extends object ? TParams["ctx"] : object, DefaultErrorShape>>>;
                                                                                                ~~~~~~~~~~~~~~

node_modules/@trpc/server/dist/core/initTRPC.d.ts:75:166 - error TS9039: Type containing private name 'DefaultErrorShape' can't be used with --isolatedDeclarations.

75                 errorShape: ErrorFormatterShape<PickFirstDefined<TOptions["errorFormatter"], ErrorFormatter<TParams["ctx"] extends object ? TParams["ctx"] : object, DefaultErrorShape>>>;
                                                                                                                                                                        ~~~~~~~~~~~~~~~~~

node_modules/@trpc/server/dist/core/initTRPC.d.ts:76:62 - error TS9039: Type containing private name 'DataTransformerOptions' can't be used with --isolatedDeclarations.

76                 transformer: TOptions["transformer"] extends DataTransformerOptions ? TOptions["transformer"] : DefaultDataTransformer;
                                                                ~~~~~~~~~~~~~~~~~~~~~~

node_modules/@trpc/server/dist/core/initTRPC.d.ts:76:113 - error TS9039: Type containing private name 'DefaultDataTransformer' can't be used with --isolatedDeclarations.

76                 transformer: TOptions["transformer"] extends DataTransformerOptions ? TOptions["transformer"] : DefaultDataTransformer;
                                                                                                                   ~~~~~~~~~~~~~~~~~~~~~~

node_modules/@trpc/server/dist/core/initTRPC.d.ts:88:157 - error TS9039: Type containing private name 'RootConfig' can't be used with --isolatedDeclarations.

88         router: <TProcRouterRecord extends import("./router").ProcedureRouterRecord>(procedures: TProcRouterRecord) => import("./router").CreateRouterInner<RootConfig<{
                                                                                                                                                               ~~~~~~~~~~

node_modules/@trpc/server/dist/core/initTRPC.d.ts:91:25 - error TS9039: Type containing private name 'ErrorFormatterShape' can't be used with --isolatedDeclarations.

91             errorShape: ErrorFormatterShape<PickFirstDefined<TOptions["errorFormatter"], ErrorFormatter<TParams["ctx"] extends object ? TParams["ctx"] : object, DefaultErrorShape>>>;
                           ~~~~~~~~~~~~~~~~~~~

node_modules/@trpc/server/dist/core/initTRPC.d.ts:91:45 - error TS9039: Type containing private name 'PickFirstDefined' can't be used with --isolatedDeclarations.

91             errorShape: ErrorFormatterShape<PickFirstDefined<TOptions["errorFormatter"], ErrorFormatter<TParams["ctx"] extends object ? TParams["ctx"] : object, DefaultErrorShape>>>;
                                               ~~~~~~~~~~~~~~~~

node_modules/@trpc/server/dist/core/initTRPC.d.ts:91:90 - error TS9039: Type containing private name 'ErrorFormatter' can't be used with --isolatedDeclarations.

91             errorShape: ErrorFormatterShape<PickFirstDefined<TOptions["errorFormatter"], ErrorFormatter<TParams["ctx"] extends object ? TParams["ctx"] : object, DefaultErrorShape>>>;
                                                                                            ~~~~~~~~~~~~~~

node_modules/@trpc/server/dist/core/initTRPC.d.ts:91:162 - error TS9039: Type containing private name 'DefaultErrorShape' can't be used with --isolatedDeclarations.

91             errorShape: ErrorFormatterShape<PickFirstDefined<TOptions["errorFormatter"], ErrorFormatter<TParams["ctx"] extends object ? TParams["ctx"] : object, DefaultErrorShape>>>;
                                                                                                                                                                    ~~~~~~~~~~~~~~~~~

node_modules/@trpc/server/dist/core/initTRPC.d.ts:92:58 - error TS9039: Type containing private name 'DataTransformerOptions' can't be used with --isolatedDeclarations.

92             transformer: TOptions["transformer"] extends DataTransformerOptions ? TOptions["transformer"] : DefaultDataTransformer;
                                                            ~~~~~~~~~~~~~~~~~~~~~~

node_modules/@trpc/server/dist/core/initTRPC.d.ts:92:109 - error TS9039: Type containing private name 'DefaultDataTransformer' can't be used with --isolatedDeclarations.

92             transformer: TOptions["transformer"] extends DataTransformerOptions ? TOptions["transformer"] : DefaultDataTransformer;
                                                                                                               ~~~~~~~~~~~~~~~~~~~~~~


Found 17 errors in 2 files.

Errors  Files
     3  index.ts:5
    14  node_modules/@trpc/server/dist/core/initTRPC.d.ts:72

πŸ™‚ Expected behavior

Type errors only occur in index.ts

Additional information about the issue

@trpc/server is packaged with the original source files, e.g. node_modules/@trpc/server/src/core/initTRPC.ts, rather than declaration files.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptDomain: flag: isolatedDeclarationsRelated to the --isolatedDeclarations compiler flagFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions