Skip to content

Create Plugin: Support Typescript 6 #2613

@samjewell

Description

@samjewell

Summary

#2595 ("feat: add support for Typescript 6", merged 2026-04-30) fixed two of the three TS6 deprecation errors by updating @grafana/tsconfig (dropping downlevelIteration and switching moduleResolution from nodebundler), but the third deprecation — baseUrl — still ships in the scaffolded .config/tsconfig.json template. As a result, any plugin scaffolded by @grafana/create-plugin that bumps to TypeScript 6 still fails tsc --noEmit.

Reproduction

In any plugin scaffolded by @grafana/create-plugin@7.3.0 (or earlier) with typescript@^6.0.0 and the latest @grafana/tsconfig@2.1.0:

$ npm run typecheck
error TS5101: Option 'baseUrl' is deprecated and will stop functioning in TypeScript 7.0.
  Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.
  Visit https://aka.ms/ts6 for migration information.

The other two errors (downlevelIteration, moduleResolution=node10) that #2595 documented are now gone — only baseUrl remains.

Root cause

packages/create-plugin/templates/common/.config/tsconfig.json still contains:

{
  "compilerOptions": {
    ...
    "rootDir": "../src",
    "baseUrl": "../src",
    ...
  },
  ...
}

baseUrl cannot be unset from a child tsconfig that extends the scaffold (TypeScript has no "remove an inherited option" mechanism), so plugin authors hitting this on TS6 either have to:

  1. Add "ignoreDeprecations": "6.0" to their root tsconfig.json — a band-aid that just defers the problem to TS7.
  2. Edit the "DO NOT EDIT THIS FILE DIRECTLY" scaffolded .config/tsconfig.json and rewrite any baseUrl-resolving non-relative imports in their source.

Neither option is great when the fix really belongs in the scaffold itself.

Proposed fix

Remove "baseUrl": "../src" from packages/create-plugin/templates/common/.config/tsconfig.json. rootDir stays — only baseUrl is deprecated.

Optionally, ship a migration (e.g. 008-remove-tsconfig-baseUrl) that:

  1. Removes the baseUrl line from .config/tsconfig.json if present.
  2. Rewrites any non-relative imports in src/** that resolved via baseUrl to relative form.

Step 2 isn't strictly necessary for the migration if .config/jest.config.js's modulePaths: ['<rootDir>/src'] is left in place (Jest will keep resolving them at test runtime), but TypeScript itself will fail without it. A codemod could be helpful but plugins differ enough that a manual rewrite may be acceptable for the migration.

Worked example

I just shipped this fix in grafana/grafana-cube-datasource#314:

  • Removed baseUrl: "../src" from .config/tsconfig.json (despite the warning).
  • Rewrote 13 files (16 import statements + 1 jest.mock call) to use relative paths.
  • Net diff: 18 files, +21/-22 lines.
  • tsc --noEmit now passes cleanly under both TS 5.9.3 and TS 6.0.3 with no ignoreDeprecations escape hatch.

The pattern was small and mechanical — happy to help with a PR against the scaffold and/or a migration script if you'd find that useful.

Why this matters

Every plugin scaffolded by create-plugin currently inherits this latent problem. As Renovate or maintainers bump TypeScript to 6, every one of them will independently hit this and have to choose between band-aid and scaffold-edit. Fixing it at the scaffold solves it for everyone in one stroke and unblocks a clean TS7 path before the deprecation becomes a hard error.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

Status

🔍 In review

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions