create() — astro Function Reference
Architecture documentation for the create() function in index.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD 404c28b5_e9a6_50b8_f251_491c4fd00a7e["create()"] 02725282_48b3_dec7_9602_7400485ced81["index.ts"] 404c28b5_e9a6_50b8_f251_491c4fd00a7e -->|defined in| 02725282_48b3_dec7_9602_7400485ced81 style 404c28b5_e9a6_50b8_f251_491c4fd00a7e fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/language-tools/language-server/src/plugins/typescript/index.ts lines 9–104
export const create = (
ts: typeof import('typescript'),
options?: {
disableAutoImportCache: boolean | undefined;
},
): LanguageServicePlugin[] => {
const tsServicePlugins = createTypeScriptServices(ts as typeof import('typescript'), {
disableAutoImportCache: options?.disableAutoImportCache,
});
return tsServicePlugins.map<LanguageServicePlugin>((plugin) => {
if (plugin.name === 'typescript-semantic') {
return {
...plugin,
create(context): LanguageServicePluginInstance {
const typeScriptPlugin = plugin.create(context);
return {
...typeScriptPlugin,
async provideFileRenameEdits(oldUri, newUri, token) {
const astroConfig = await context.env.getConfiguration?.<{
updateImportsOnFileMove: { enabled: boolean };
}>('astro');
// Check for `false` explicitly, as the default value is `true`, but it might not be set explicitly depending on the editor
if (astroConfig?.updateImportsOnFileMove.enabled === false) {
return null;
}
return typeScriptPlugin.provideFileRenameEdits!(oldUri, newUri, token);
},
async provideCompletionItems(document, position, completionContext, token) {
const originalCompletions = await typeScriptPlugin.provideCompletionItems!(
document,
position,
completionContext,
token,
);
if (!originalCompletions) return null;
return enhancedProvideCompletionItems(originalCompletions);
},
async resolveCompletionItem(item, token) {
const resolvedCompletionItem = await typeScriptPlugin.resolveCompletionItem!(
item,
token,
);
if (!resolvedCompletionItem) return item;
return enhancedResolveCompletionItem(resolvedCompletionItem, context);
},
async provideCodeActions(document, range, codeActionContext, token) {
const originalCodeActions = await typeScriptPlugin.provideCodeActions!(
document,
range,
codeActionContext,
token,
);
if (!originalCodeActions) return null;
return enhancedProvideCodeActions(originalCodeActions, context);
},
async resolveCodeAction(codeAction, token) {
const resolvedCodeAction = await typeScriptPlugin.resolveCodeAction!(
codeAction,
token,
);
if (!resolvedCodeAction) return codeAction;
return enhancedResolveCodeAction(resolvedCodeAction, context);
},
async provideDiagnostics(document, token) {
const decoded = context.decodeEmbeddedDocumentUri(URI.parse(document.uri));
const sourceScript = decoded && context.language.scripts.get(decoded[0]);
const root = sourceScript?.generated?.root;
let tsxLineCount = undefined;
if (root instanceof AstroVirtualCode && decoded?.[1] === 'tsx') {
// If we have compiler errors, our TSX isn't valid so don't bother showing TS errors
if (root.hasCompilationErrors) return null;
// We'll use this to filter out diagnostics that are outside the mapped range of the TSX
Domain
Subdomains
Source
Frequently Asked Questions
What does create() do?
create() is a function in the astro codebase, defined in packages/language-tools/language-server/src/plugins/typescript/index.ts.
Where is create() defined?
create() is defined in packages/language-tools/language-server/src/plugins/typescript/index.ts at line 9.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free