@tevm/ts-plugin
npm install --save-dev @tevm/ts-pluginA TypeScript
language service plugin
that decorates tsserver so .sol imports resolve to real types.
Setup
{
"compilerOptions": {
"plugins": [{ "name": "@tevm/ts-plugin" }]
}
}The name must be exactly @tevm/ts-plugin — @tevm/config looks
for that literal string when it reads Tevm settings out of tsconfig.json, so
an alias will silently disable configuration inheritance.
You can put Tevm config on the same entry:
{
"compilerOptions": {
"plugins": [
{
"name": "@tevm/ts-plugin",
"foundryProject": true,
"libs": ["lib"]
}
]
}
}This is only consulted when there is no tevm.config.json. See
Configuration.
In VS Code you must also select the workspace TypeScript version — see Editor & TypeScript setup.
What it provides
- Types on
.solimports. The plugin generates.d.tscontent from the compiled ABI, soCounter.read.count()is typed from the real contract. - Autocompletion over
abi,read,write,eventsand the rest of theContractsurface. - Go to definition from a TypeScript call site into the Solidity function that backs it.
- NatSpec on hover —
/// @noticecomments become documentation.
How it works
The plugin is a PluginModuleFactory. On create it:
- Loads the config with
loadConfig, warning and falling back todefaultConfigwhen notevm.config.jsonexists. - Builds two file access objects. One reads through the language service host — so the file you are editing is seen as it is right now, not as it was last saved — and one reads the real filesystem, for the cache.
- Creates a
@tevm/bundler-cacheinstance pointed at the samecacheDirthe bundlers use, which is why opening a file in your editor warms the cache for the next build. - Decorates the language service host with:
getScriptKindDecorator— tells TypeScript to treat.solfiles as TS,resolveModuleNameLiteralsDecorator— makes./Counter.solresolvable,getScriptSnapshotDecorator— serves generated.d.tscontent in place of Solidity source.
- Decorates the language service itself with
getDefinitionServiceDecorator, which maps a definition request on a generated member back to the Solidity source range.
Everything downstream of step 1 is the same code the bundlers run, which is the point: the editor and the build cannot disagree.
Limitations
tscdoes not load language service plugins. Onlytsserverdoes. A command-linetsc --noEmitwill still reportCannot find module './Counter.sol'. See Editor & TypeScript setup for the options.- Next.js
next buildruns its own project-wide check that has the same limitation — see the webpack guide. - Resolution here is synchronous, because the language service demands it.
That is why
@tevm/base-bundlercarries a sync twin for every resolver.
Export
import tsPlugin = require('@tevm/ts-plugin')The package exports the PluginModuleFactory via export =, which is what
TypeScript's plugin loader expects. You should not need to import it yourself —
listing it in tsconfig.json is the whole integration.

