astroEnhancements() — astro Function Reference
Architecture documentation for the astroEnhancements() function in diagnostics.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD 18ef5ae1_c678_a965_c14e_4502c9f17ab2["astroEnhancements()"] eb2f7d36_9d97_e74c_0d2e_fc25c2af688f["diagnostics.ts"] 18ef5ae1_c678_a965_c14e_4502c9f17ab2 -->|defined in| eb2f7d36_9d97_e74c_0d2e_fc25c2af688f be35e5e8_d2ee_ceca_8e9a_5da51e32a48d["enhancedProvideSemanticDiagnostics()"] be35e5e8_d2ee_ceca_8e9a_5da51e32a48d -->|calls| 18ef5ae1_c678_a965_c14e_4502c9f17ab2 style 18ef5ae1_c678_a965_c14e_4502c9f17ab2 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/language-tools/language-server/src/plugins/typescript/diagnostics.ts lines 54–107
function astroEnhancements(diagnostic: Diagnostic): Diagnostic {
// When the language integrations are not installed, the content of the imported snapshot is empty
// As such, it triggers the "is not a module error", which we can enhance with a more helpful message for the related framework
if (diagnostic.code === DiagnosticCodes.IS_NOT_A_MODULE) {
if (diagnostic.message.includes('.svelte')) {
diagnostic.message +=
'\n\nIs the `@astrojs/svelte` package installed? You can add it to your project by running the following command: `astro add svelte`. If already installed, restarting the language server might be necessary in order for the change to take effect.';
}
if (diagnostic.message.includes('.vue')) {
diagnostic.message +=
'\n\nIs the `@astrojs/vue` package installed? You can add it to your project by running the following command: `astro add vue`. If already installed, restarting the language server might be necessary in order for the change to take effect.';
}
return diagnostic;
}
// JSX element has no closing tag. JSX -> HTML
if (diagnostic.code === DiagnosticCodes.JSX_NO_CLOSING_TAG) {
return {
...diagnostic,
message: diagnostic.message.replace('JSX', 'HTML'),
};
}
// JSX Element can't be constructed or called. This happens on syntax errors / invalid components
if (diagnostic.code === DiagnosticCodes.JSX_ELEMENT_NO_CALL) {
return {
...diagnostic,
message: diagnostic.message
.replace('JSX element type', 'Component')
.replace(
'does not have any construct or call signatures.',
'is not a valid component.\n\nIf this is a Svelte or Vue component, it might have a syntax error that makes it impossible to parse.',
),
};
}
// For the rare case where an user might try to put a client directive on something that is not a component
if (diagnostic.code === DiagnosticCodes.TYPE_NOT_ASSIGNABLE) {
if (
diagnostic.message.includes("Property 'client:") &&
diagnostic.message.includes("to type 'HTMLAttributes")
) {
return {
...diagnostic,
message:
diagnostic.message + '\n\nClient directives are only available on framework components.',
};
}
}
return diagnostic;
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does astroEnhancements() do?
astroEnhancements() is a function in the astro codebase, defined in packages/language-tools/language-server/src/plugins/typescript/diagnostics.ts.
Where is astroEnhancements() defined?
astroEnhancements() is defined in packages/language-tools/language-server/src/plugins/typescript/diagnostics.ts at line 54.
What calls astroEnhancements()?
astroEnhancements() is called by 1 function(s): enhancedProvideSemanticDiagnostics.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free