Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] feat: expose AST parser API to Deno namespace. #6893

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
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
1 change: 1 addition & 0 deletions cli/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ fn create_compiler_snapshot(
"lib.deno.unstable.d.ts".to_string(),
cwd.join("dts/lib.deno.unstable.d.ts"),
);
custom_libs.insert("swc.d.ts".to_string(), cwd.join("dts/swc.d.ts"));
runtime_isolate.register_op(
"op_fetch_asset",
op_fetch_asset::op_fetch_asset(custom_libs),
Expand Down
18 changes: 17 additions & 1 deletion cli/dts/lib.deno.unstable.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

/// <reference no-default-lib="true" />
/// <reference lib="deno.ns" />
/// <reference path="swc" />

declare namespace Deno {
/**
Expand Down Expand Up @@ -456,7 +457,22 @@ declare namespace Deno {
sources: Record<string, string>,
options?: CompilerOptions,
): Promise<Record<string, TranspileOnlyResult>>;


/** **UNSTABLE**: new API, yet to be vetted.
* Returns the AST for the provided source file.
* The extension of the module name will be used to determine the media type of the module.
*
* ```ts
* const ast = await Deno.ast("foo.ts");
* ```
*
* @param source A source file to be parsed. The extension of the key will determine
* the media type of the file when processing.
*/
export function ast(
source: string,
): Promise<Module>;

/** **UNSTABLE**: new API, yet to be vetted.
*
* Takes a root module name, and optionally a record set of sources. Resolves
Expand Down
Loading