Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion _packages/native-preview/src/api/async/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import type {
ProfileResult,
ProjectReference,
ProjectResponse,
ReadConfigFileResult,
SignatureResponse,
SourceFileMetadata,
SymbolResponse,
Expand All @@ -69,6 +70,7 @@ import type {
TypeResponse,
UpdateSnapshotParams,
UpdateSnapshotResponse,
WatchOptions,
} from "../proto.ts";
import {
resolveFileName,
Expand Down Expand Up @@ -129,7 +131,7 @@ import type {

export { documentURIToFileName, fileNameToDocumentURI } from "../path.ts";
export { CheckFlags, CompletionItemKind, DiagnosticCategory, ElementFlags, EmitOnly, ModifierFlags, ModuleKind, NodeBuilderFlags, ObjectFlags, SignatureFlags, SignatureKind, SymbolFlags, TypeFlags, TypePredicateKind };
export type { APIOptions, AssertsIdentifierTypePredicate, AssertsThisTypePredicate, BigIntLiteralType, BooleanLiteralType, ClientSocketOptions, ClientSpawnOptions, CompilerOptions, CompletionEntry, CompletionInfo, CompletionOptions, ConditionalType, Diagnostic, DocumentIdentifier, DocumentPosition, EmitOutput, EmitOutputFile, EmitResult, FreshableType, GetImportEditsForSymbolsOptions, IdentifierTypePredicate, ImportAdderAction, IndexedAccessType, IndexInfo, IndexType, InterfaceType, IntersectionType, IntrinsicType, JSDocTagInfo, LiteralType, LSPConnectionOptions, NumberLiteralType, ObjectType, ParsedCommandLine, ProjectReference, RequestTiming, SourceFileMetadata, StringLiteralType, StringMappingType, SubstitutionType, TemplateLiteralType, TextEdit, ThisTypePredicate, TimingAccumulators, TimingInfo, TupleType, Type, TypeAcquisition, TypeParameter, TypePredicate, TypePredicateBase, TypeReference, UnionOrIntersectionType, UnionType };
export type { APIOptions, AssertsIdentifierTypePredicate, AssertsThisTypePredicate, BigIntLiteralType, BooleanLiteralType, ClientSocketOptions, ClientSpawnOptions, CompilerOptions, CompletionEntry, CompletionInfo, CompletionOptions, ConditionalType, Diagnostic, DocumentIdentifier, DocumentPosition, EmitOutput, EmitOutputFile, EmitResult, FreshableType, GetImportEditsForSymbolsOptions, IdentifierTypePredicate, ImportAdderAction, IndexedAccessType, IndexInfo, IndexType, InterfaceType, IntersectionType, IntrinsicType, JSDocTagInfo, LiteralType, LSPConnectionOptions, NumberLiteralType, ObjectType, ParsedCommandLine, ProjectReference, ReadConfigFileResult, RequestTiming, SourceFileMetadata, StringLiteralType, StringMappingType, SubstitutionType, TemplateLiteralType, TextEdit, ThisTypePredicate, TimingAccumulators, TimingInfo, TupleType, Type, TypeAcquisition, TypeParameter, TypePredicate, TypePredicateBase, TypeReference, UnionOrIntersectionType, UnionType, WatchOptions };

interface EmitOutputResponse {
readonly emitSkipped: boolean;
Expand Down Expand Up @@ -189,6 +191,26 @@ export class API<FromLSP extends boolean = false> {
return this.client.apiRequest<ParsedCommandLine>("parseConfigFile", { file });
}

async parseCommandLine(commandLine: readonly string[]): Promise<ParsedCommandLine> {
await this.ensureInitialized();
return this.client.apiRequest<ParsedCommandLine>("parseCommandLine", { commandLine });
}

async readConfigFile(file: DocumentIdentifier): Promise<ReadConfigFileResult> {
await this.ensureInitialized();
return this.client.apiRequest<ReadConfigFileResult>("readConfigFile", { file });
}

async parseJsonConfigFileContent(
json: any,
options:
| { configDirectory: string; configFileName?: never; }
| { configFileName: DocumentIdentifier; configDirectory?: never; },
): Promise<ParsedCommandLine> {
await this.ensureInitialized();
return this.client.apiRequest<ParsedCommandLine>("parseJsonConfigFileContent", { json, ...options });
}

async transpileModule(input: string, options: TranspileOptions = {}): Promise<TranspileOutput> {
await this.ensureInitialized();
return this.client.apiRequest<TranspileOutput>("transpileModule", { input, options });
Expand Down
30 changes: 3 additions & 27 deletions _packages/native-preview/src/api/async/types.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import type { CompletionItemKind } from "#enums/completionItemKind";
import type { DiagnosticCategory } from "#enums/diagnosticCategory";
import type { ElementFlags } from "#enums/elementFlags";
import type { ObjectFlags } from "#enums/objectFlags";
import type { TypeFlags } from "#enums/typeFlags";
import type { TypePredicateKind } from "#enums/typePredicateKind";
import type { Diagnostic } from "../proto.ts";
import type {
NodeHandle,
Signature,
Symbol,
} from "./api.ts";

export type { Diagnostic } from "../proto.ts";

/**
* A TypeScript type.
*
Expand Down Expand Up @@ -361,32 +363,6 @@ export interface CompletionInfo {
readonly entries: readonly CompletionEntry[];
}

/**
* A diagnostic message from the TypeScript compiler.
*/
export interface Diagnostic {
/** File name of the source file this diagnostic belongs to, if any */
readonly fileName?: string | undefined;
/** Start position of the diagnostic */
readonly pos: number;
/** End position of the diagnostic */
readonly end: number;
/** Diagnostic error code */
readonly code: number;
/** Diagnostic category (error, warning, suggestion, message) */
readonly category: DiagnosticCategory;
/** Localized diagnostic message text */
readonly text: string;
/** Whether this diagnostic highlights unnecessary code */
readonly reportsUnnecessary?: boolean | undefined;
/** Whether this diagnostic highlights deprecated code */
readonly reportsDeprecated?: boolean | undefined;
/** Chained diagnostic messages */
readonly messageChain?: readonly Diagnostic[] | undefined;
/** Related diagnostic information */
readonly relatedInformation?: readonly Diagnostic[] | undefined;
}

export interface EmitOutputFile {
readonly text: string;
readonly sourceFileName?: string | undefined;
Expand Down
45 changes: 45 additions & 0 deletions _packages/native-preview/src/api/proto.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { CheckFlags } from "#enums/checkFlags";
import type { CompletionItemKind } from "#enums/completionItemKind";
import type { DiagnosticCategory } from "#enums/diagnosticCategory";
import type { ModuleKind } from "#enums/moduleKind";
import type {
__String,
Expand Down Expand Up @@ -97,12 +98,56 @@ export interface ProjectReference {
circular?: boolean;
}

/**
* A diagnostic message from the TypeScript compiler.
*/
export interface Diagnostic {
/** File name of the source file this diagnostic belongs to, if any */
readonly fileName?: string | undefined;
/** Start position of the diagnostic */
readonly pos: number;
/** End position of the diagnostic */
readonly end: number;
/** Diagnostic error code */
readonly code: number;
/** Diagnostic category (error, warning, suggestion, message) */
readonly category: DiagnosticCategory;
/** Localized diagnostic message text */
readonly text: string;
/** Whether this diagnostic highlights unnecessary code */
readonly reportsUnnecessary?: boolean | undefined;
/** Whether this diagnostic highlights deprecated code */
readonly reportsDeprecated?: boolean | undefined;
/** Chained diagnostic messages */
readonly messageChain?: readonly Diagnostic[] | undefined;
/** Related diagnostic information */
readonly relatedInformation?: readonly Diagnostic[] | undefined;
}

export interface WatchOptions {
watchInterval?: number;
watchFile?: number;
watchDirectory?: number;
fallbackPolling?: number;
synchronousWatchDirectory?: boolean;
excludeDirectories?: string[];
excludeFiles?: string[];
}

export interface ParsedCommandLine {
options: CompilerOptions;
fileNames: string[];
watchOptions?: WatchOptions;
Comment thread
johnfav03 marked this conversation as resolved.
Outdated
projectReferences?: ProjectReference[];
typeAcquisition?: TypeAcquisition;
compileOnSave?: boolean;
raw?: any;
errors: readonly Diagnostic[];
}

export interface ReadConfigFileResult {
config: any;
error?: Diagnostic;
}

export interface LSPUpdateSnapshotParams {
Expand Down
24 changes: 23 additions & 1 deletion _packages/native-preview/src/api/sync/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ import type {
ProfileResult,
ProjectReference,
ProjectResponse,
ReadConfigFileResult,
SignatureResponse,
SourceFileMetadata,
SymbolResponse,
Expand All @@ -77,6 +78,7 @@ import type {
TypeResponse,
UpdateSnapshotParams,
UpdateSnapshotResponse,
WatchOptions,
} from "../proto.ts";
import {
resolveFileName,
Expand Down Expand Up @@ -137,7 +139,7 @@ import type {

export { documentURIToFileName, fileNameToDocumentURI } from "../path.ts";
export { CheckFlags, CompletionItemKind, DiagnosticCategory, ElementFlags, EmitOnly, ModifierFlags, ModuleKind, NodeBuilderFlags, ObjectFlags, SignatureFlags, SignatureKind, SymbolFlags, TypeFlags, TypePredicateKind };
export type { APIOptions, AssertsIdentifierTypePredicate, AssertsThisTypePredicate, BigIntLiteralType, BooleanLiteralType, ClientSocketOptions, ClientSpawnOptions, CompilerOptions, CompletionEntry, CompletionInfo, CompletionOptions, ConditionalType, Diagnostic, DocumentIdentifier, DocumentPosition, EmitOutput, EmitOutputFile, EmitResult, FreshableType, GetImportEditsForSymbolsOptions, IdentifierTypePredicate, ImportAdderAction, IndexedAccessType, IndexInfo, IndexType, InterfaceType, IntersectionType, IntrinsicType, JSDocTagInfo, LiteralType, LSPConnectionOptions, NumberLiteralType, ObjectType, ParsedCommandLine, ProjectReference, RequestTiming, SourceFileMetadata, StringLiteralType, StringMappingType, SubstitutionType, TemplateLiteralType, TextEdit, ThisTypePredicate, TimingAccumulators, TimingInfo, TupleType, Type, TypeAcquisition, TypeParameter, TypePredicate, TypePredicateBase, TypeReference, UnionOrIntersectionType, UnionType };
export type { APIOptions, AssertsIdentifierTypePredicate, AssertsThisTypePredicate, BigIntLiteralType, BooleanLiteralType, ClientSocketOptions, ClientSpawnOptions, CompilerOptions, CompletionEntry, CompletionInfo, CompletionOptions, ConditionalType, Diagnostic, DocumentIdentifier, DocumentPosition, EmitOutput, EmitOutputFile, EmitResult, FreshableType, GetImportEditsForSymbolsOptions, IdentifierTypePredicate, ImportAdderAction, IndexedAccessType, IndexInfo, IndexType, InterfaceType, IntersectionType, IntrinsicType, JSDocTagInfo, LiteralType, LSPConnectionOptions, NumberLiteralType, ObjectType, ParsedCommandLine, ProjectReference, ReadConfigFileResult, RequestTiming, SourceFileMetadata, StringLiteralType, StringMappingType, SubstitutionType, TemplateLiteralType, TextEdit, ThisTypePredicate, TimingAccumulators, TimingInfo, TupleType, Type, TypeAcquisition, TypeParameter, TypePredicate, TypePredicateBase, TypeReference, UnionOrIntersectionType, UnionType, WatchOptions };

interface EmitOutputResponse {
readonly emitSkipped: boolean;
Expand Down Expand Up @@ -197,6 +199,26 @@ export class API<FromLSP extends boolean = false> {
return this.client.apiRequest<ParsedCommandLine>("parseConfigFile", { file });
}

parseCommandLine(commandLine: readonly string[]): ParsedCommandLine {
this.ensureInitialized();
return this.client.apiRequest<ParsedCommandLine>("parseCommandLine", { commandLine });
}

readConfigFile(file: DocumentIdentifier): ReadConfigFileResult {
this.ensureInitialized();
return this.client.apiRequest<ReadConfigFileResult>("readConfigFile", { file });
}

parseJsonConfigFileContent(
json: any,
options:
| { configDirectory: string; configFileName?: never; }
| { configFileName: DocumentIdentifier; configDirectory?: never; },
): ParsedCommandLine {
this.ensureInitialized();
return this.client.apiRequest<ParsedCommandLine>("parseJsonConfigFileContent", { json, ...options });
}

transpileModule(input: string, options: TranspileOptions = {}): TranspileOutput {
this.ensureInitialized();
return this.client.apiRequest<TranspileOutput>("transpileModule", { input, options });
Expand Down
30 changes: 3 additions & 27 deletions _packages/native-preview/src/api/sync/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@
// Regenerate: npm run generate (from _packages/native-preview)
//
import type { CompletionItemKind } from "#enums/completionItemKind";
import type { DiagnosticCategory } from "#enums/diagnosticCategory";
import type { ElementFlags } from "#enums/elementFlags";
import type { ObjectFlags } from "#enums/objectFlags";
import type { TypeFlags } from "#enums/typeFlags";
import type { TypePredicateKind } from "#enums/typePredicateKind";
import type { Diagnostic } from "../proto.ts";
import type {
NodeHandle,
Signature,
Symbol,
} from "./api.ts";

export type { Diagnostic } from "../proto.ts";

/**
* A TypeScript type.
*
Expand Down Expand Up @@ -369,32 +371,6 @@ export interface CompletionInfo {
readonly entries: readonly CompletionEntry[];
}

/**
* A diagnostic message from the TypeScript compiler.
*/
export interface Diagnostic {
/** File name of the source file this diagnostic belongs to, if any */
readonly fileName?: string | undefined;
/** Start position of the diagnostic */
readonly pos: number;
/** End position of the diagnostic */
readonly end: number;
/** Diagnostic error code */
readonly code: number;
/** Diagnostic category (error, warning, suggestion, message) */
readonly category: DiagnosticCategory;
/** Localized diagnostic message text */
readonly text: string;
/** Whether this diagnostic highlights unnecessary code */
readonly reportsUnnecessary?: boolean | undefined;
/** Whether this diagnostic highlights deprecated code */
readonly reportsDeprecated?: boolean | undefined;
/** Chained diagnostic messages */
readonly messageChain?: readonly Diagnostic[] | undefined;
/** Related diagnostic information */
readonly relatedInformation?: readonly Diagnostic[] | undefined;
}

export interface EmitOutputFile {
readonly text: string;
readonly sourceFileName?: string | undefined;
Expand Down
Loading