safeConvertToTSX() — astro Function Reference
Architecture documentation for the safeConvertToTSX() function in astro2tsx.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD ec4054c5_ef8e_0bdd_5f55_3c3469ddd9ac["safeConvertToTSX()"] b348b824_2985_3524_9b17_fd7579f42c1f["astro2tsx.ts"] ec4054c5_ef8e_0bdd_5f55_3c3469ddd9ac -->|defined in| b348b824_2985_3524_9b17_fd7579f42c1f acdd7f41_dc47_4c7c_d901_ea0356cddf50["astro2tsx()"] acdd7f41_dc47_4c7c_d901_ea0356cddf50 -->|calls| ec4054c5_ef8e_0bdd_5f55_3c3469ddd9ac style ec4054c5_ef8e_0bdd_5f55_3c3469ddd9ac fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/language-tools/ts-plugin/src/astro2tsx.ts lines 8–47
function safeConvertToTSX(content: string, options: ConvertToTSXOptions) {
try {
const tsx = convertToTSX(content, { filename: options.filename });
return tsx;
} catch (e) {
console.error(
`There was an error transforming ${options.filename} to TSX. An empty file will be returned instead. Please create an issue: https://github.com/withastro/astro/issues\nError: ${e}.`,
);
return {
code: '',
map: {
file: options.filename ?? '',
sources: [],
sourcesContent: [],
names: [],
mappings: '',
version: 0,
},
diagnostics: [
{
code: 1000,
location: { file: options.filename!, line: 1, column: 1, length: content.length },
severity: 1,
text: `The Astro compiler encountered an unknown error while parsing this file. Please create an issue with your code and the error shown in the server's logs: https://github.com/withastro/astro/issues`,
},
],
metaRanges: {
frontmatter: {
start: 0,
end: 0,
},
body: {
start: 0,
end: 0,
},
},
} satisfies TSXResult;
}
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does safeConvertToTSX() do?
safeConvertToTSX() is a function in the astro codebase, defined in packages/language-tools/ts-plugin/src/astro2tsx.ts.
Where is safeConvertToTSX() defined?
safeConvertToTSX() is defined in packages/language-tools/ts-plugin/src/astro2tsx.ts at line 8.
What calls safeConvertToTSX()?
safeConvertToTSX() is called by 1 function(s): astro2tsx.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free