Error Levels
mion could not build the code at all, so there is nothing to ship for it. The build stops there, everywhere, and nothing you write or set turns it off.
The build is not stopped during dev mode but code will generate an error at runtime. Production build will fail so you don't ship runtime errors.
Worth knowing, nothing is broken, but the result may surprise you: a clone that shares a value with the original, a tag that does nothing. It never stops anything.
mion works as documented: a method a validator skips, a validator on a type you wrote as any. Hidden unless you set levels to all.
Every diagnostic has a name like validate-symbol-root: its area, then what went wrong. Error and RuntimeError both print the word error, so check the name to see which one you got. Every name is listed in All Diagnostics.
Where Each Level Shows
The dev server shows only what breaks your running code.
| Where | Error | RuntimeError | Warning | Info |
|---|---|---|---|---|
| Editor, through the lint rules | mion/error | mion/runtime-error | mion/warning | mion/info, off by default |
| Dev server terminal | printed once | printed once | one line counting them | not printed |
| Browser overlay | shown when its file loads | not shown | not shown | not shown |
| Build and CI | printed, the build stops | printed, the build stops | printed | printed with levels: 'all' |
Disabling Errors
Two comments turn an error off:
@mion-expect-errorhides it.@mion-downgrade-errorshows it as a warning, so the build does not fail.
Use // above a line to cover that line. Use /* */ at the top of the file, before any code, to cover the whole file. Several names fit on one comment.
/* @mion-downgrade-error validate-symbol-root */
import {createValidateFn} from '@mionjs/run-types';
// both raise validate-symbol-root; the file comment above makes them warnings
export const validateSymbol = createValidateFn<symbol>();
export const validateAnotherSymbol = createValidateFn<symbol>();
// the line comment hides this one completely
// @mion-expect-error validate-symbol-root
export const validateSymbolQuietly = createValidateFn<symbol>();
| Comment | Placement | What happens |
|---|---|---|
// @mion-expect-error validate-symbol-root | its own line | validate-symbol-root on the next line is hidden |
// @mion-downgrade-error validate-symbol-root | its own line | validate-symbol-root on the next line becomes a warning |
/* @mion-expect-error validate-symbol-root */ | top of the file | every validate-symbol-root in the file is hidden |
/* @mion-downgrade-error validate-symbol-root */ | top of the file | every validate-symbol-root in the file becomes a warning |
/* @mion-expect-error */ | top of the file | every error in the file is hidden |
comment-expect-error-unused or comment-downgrade-error-unused).Downgrading Errors in Config
downgradeErrors turns the errors you list into warnings, across the whole project. Use it when you cannot add a comment: the type is in a package you do not own, or the problem is in your config. Only the tsconfig setting also lowers them in the linter.
mionVitePlugin({
runTypes: {
downgradeErrors: ['marker-comptime-arg-forbidden-construct'],
},
});
{
"compilerOptions": {
"plugins": [{"name": "mion", "downgradeErrors": ["marker-comptime-arg-forbidden-construct"]}]
}
}
A downgraded error still prints on every build:
node_modules/some-lib/adapter.js(41,9): warning marker-comptime-arg-forbidden-construct: ... (downgraded)
All the options are listed in Configuration.
'*' turns every error into a warning at once, useful when adding mion to an existing project. List the real names once you know them. An Error is never downgraded, not even by '*'.Showing Info Messages
Info messages are hidden in the build, the mion command line and the linter. Set levels: 'all' in your tsconfig to show them in the build and the command line. The build plugin also has its own setting, and the linter shows them with its mion/info rule.
mionVitePlugin({
runTypes: {
levels: 'all',
},
});
{
"compilerOptions": {
"plugins": [{"name": "mion", "levels": "all"}]
}
}
Grouping Messages
The build, the dev server and the mion command line print each message once, then every place it happens. A value that is the same in every place goes into the message.
error validate-non-data-root (2)
Type `{type}` can never be validated: the generated function will always fail.
src/routes/user.ts:12:7 type=FileHandle
src/jobs/upload.ts:41:2 type=Socket
mion: 2 errors in 2 files
One Line per Message
Set logStyle: 'lines' to print one full line per message, the form CI tools read.
mionVitePlugin({
runTypes: {
logStyle: 'lines',
},
});
{
"compilerOptions": {
"plugins": [{"name": "mion", "logStyle": "lines"}]
}
}