file_path
stringlengths
3
280
file_language
stringclasses
66 values
content
stringlengths
1
1.04M
repo_name
stringlengths
5
92
repo_stars
int64
0
154k
repo_description
stringlengths
0
402
repo_primary_language
stringclasses
108 values
developer_username
stringlengths
1
25
developer_name
stringlengths
0
30
developer_company
stringlengths
0
82
crates/swc_plugin_proxy/src/comments/plugin_comments_proxy.rs
Rust
#[cfg(feature = "__plugin_mode")] use swc_common::{ comments::{Comment, Comments}, BytePos, }; #[cfg(feature = "__plugin_mode")] use swc_trace_macro::swc_trace; #[cfg(all(feature = "__rkyv", feature = "__plugin_mode", target_arch = "wasm32"))] use crate::memory_interop::read_returned_result_from_host; #[cfg(t...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_plugin_proxy/src/lib.rs
Rust
#![cfg_attr(not(feature = "__rkyv"), allow(warnings))] mod comments; mod memory_interop; mod metadata; mod source_map; #[cfg(feature = "__plugin_mode")] pub use comments::PluginCommentsProxy; #[cfg(feature = "__plugin_rt")] pub use comments::{HostCommentsStorage, COMMENTS}; pub use memory_interop::AllocatedBytesPtr; #...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_plugin_proxy/src/memory_interop/mod.rs
Rust
mod read_returned_result_from_host; #[cfg(all(feature = "__rkyv", feature = "__plugin_mode", target_arch = "wasm32"))] pub(crate) use read_returned_result_from_host::read_returned_result_from_host; pub use read_returned_result_from_host::AllocatedBytesPtr;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_plugin_proxy/src/memory_interop/read_returned_result_from_host.rs
Rust
#[cfg_attr(not(target_arch = "wasm32"), allow(unused))] #[cfg(any(feature = "__plugin_rt", feature = "__plugin_mode"))] use swc_common::plugin::serialized::PluginSerializedBytes; /// A struct to exchange allocated data between memory spaces. #[cfg_attr( feature = "__rkyv", derive(rkyv::Archive, rkyv::Serialize...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_plugin_proxy/src/metadata/mod.rs
Rust
mod transform_plugin_metadata; #[cfg(feature = "__plugin_mode")] pub use transform_plugin_metadata::TransformPluginProgramMetadata;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_plugin_proxy/src/metadata/transform_plugin_metadata.rs
Rust
#[cfg(feature = "__plugin_mode")] use swc_common::Mark; #[cfg(feature = "__plugin_mode")] use swc_trace_macro::swc_trace; #[cfg(all(feature = "__rkyv", feature = "__plugin_mode", target_arch = "wasm32"))] use crate::memory_interop::read_returned_result_from_host; #[cfg(feature = "__plugin_mode")] #[cfg_attr(not(target...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_plugin_proxy/src/source_map/mod.rs
Rust
mod plugin_source_map_proxy; #[cfg(feature = "__plugin_mode")] pub use plugin_source_map_proxy::PluginSourceMapProxy;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_plugin_proxy/src/source_map/plugin_source_map_proxy.rs
Rust
#![allow(unused_imports)] #![allow(unused_variables)] #[cfg(feature = "__plugin_mode")] use swc_common::{ source_map::{ DistinctSources, FileLinesResult, MalformedSourceMapPositions, PartialFileLinesResult, PartialLoc, SmallPos, SpanSnippetError, }, sync::Lrc, BytePos, FileName, Loc, Sou...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_plugin_runner/benches/ecma_invoke.rs
Rust
#![cfg_attr(not(feature = "__rkyv"), allow(warnings))] extern crate swc_malloc; use std::{ env, path::{Path, PathBuf}, process::Command, sync::Arc, }; use codspeed_criterion_compat::{black_box, criterion_group, criterion_main, Bencher, Criterion}; #[cfg(feature = "__rkyv")] use swc_common::plugin::se...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_plugin_runner/build.rs
Rust
use std::error::Error; use vergen::{BuildBuilder, CargoBuilder, Emitter}; fn main() -> Result<(), Box<dyn Error>> { let build = BuildBuilder::all_build()?; let cargo = CargoBuilder::default() .dependencies(true) .name_filter("*_ast") .build()?; Emitter::default() .add_inst...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_plugin_runner/src/cache.rs
Rust
#![allow(unused)] use std::{ env::current_dir, path::{Path, PathBuf}, str::FromStr, }; use anyhow::{Context, Error}; use enumset::EnumSet; use parking_lot::Mutex; use rustc_hash::FxHashMap; use swc_common::sync::{Lazy, OnceCell}; #[cfg(not(target_arch = "wasm32"))] use wasmer::{sys::BaseTunables, CpuFeatu...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_plugin_runner/src/host_environment.rs
Rust
use wasmer::Memory; /// An external environment state imported (declared in host, injected into /// guest) fn can access. This'll allow host to read from updated state from /// guest. /// /// This is `base` environment exposes nothing. For other /// calls requires additional data to be set in the host, separate /// ho...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_plugin_runner/src/imported_fn/comments.rs
Rust
use std::sync::Arc; use parking_lot::Mutex; use swc_common::{ comments::{Comments, SingleThreadedComments}, plugin::serialized::{PluginSerializedBytes, VersionedSerializable}, BytePos, }; use swc_plugin_proxy::COMMENTS; use wasmer::{AsStoreMut, FunctionEnvMut, Memory, TypedFunction}; use crate::memory_int...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_plugin_runner/src/imported_fn/diagnostics.rs
Rust
use std::sync::Arc; use parking_lot::Mutex; use wasmer::{FunctionEnvMut, Memory}; use crate::memory_interop::copy_bytes_into_host; /// External environment to read swc_core diagnostics from the host. #[derive(Clone)] pub struct DiagnosticContextHostEnvironment { pub memory: Option<Memory>, /// A buffer to st...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_plugin_runner/src/imported_fn/handler.rs
Rust
use swc_common::{ errors::{Diagnostic, HANDLER}, plugin::serialized::PluginSerializedBytes, }; use wasmer::FunctionEnvMut; use crate::{host_environment::BaseHostEnvironment, memory_interop::copy_bytes_into_host}; #[tracing::instrument(level = "info", skip_all)] pub fn emit_diagnostics( env: FunctionEnvMut...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_plugin_runner/src/imported_fn/hygiene.rs
Rust
use swc_common::{ hygiene::MutableMarkContext, plugin::serialized::{PluginSerializedBytes, VersionedSerializable}, Mark, SyntaxContext, }; use wasmer::{AsStoreMut, FunctionEnvMut}; use crate::{host_environment::BaseHostEnvironment, memory_interop::write_into_memory_view}; /// A proxy to Mark::fresh() that...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_plugin_runner/src/imported_fn/metadata_context.rs
Rust
use std::sync::Arc; use parking_lot::Mutex; use swc_common::plugin::{ metadata::{TransformPluginMetadataContext, TransformPluginMetadataContextKind}, serialized::{PluginSerializedBytes, VersionedSerializable}, }; use wasmer::{AsStoreMut, FunctionEnvMut, Memory, TypedFunction}; use crate::memory_interop::{allo...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_plugin_runner/src/imported_fn/mod.rs
Rust
//! Functions for syntax_pos::hygiene imported into the guests (plugin) runtime //! allows interop between host's state to plugin. When guest calls these fn, //! it'll be executed in host's memory space. /* * Below diagram shows one reference example how guest does trampoline between * host's memory space. *┌──────────...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_plugin_runner/src/imported_fn/set_transform_result.rs
Rust
use std::sync::Arc; use parking_lot::Mutex; use wasmer::{FunctionEnvMut, Memory}; use crate::memory_interop::copy_bytes_into_host; /// Environment states allow to return guest's transform result back to the /// host, using a buffer `transform_result` attached to the environment. /// /// When plugin performs its tran...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_plugin_runner/src/imported_fn/source_map.rs
Rust
#![allow(dead_code)] use std::sync::Arc; use parking_lot::Mutex; use swc_common::{ plugin::serialized::{PluginSerializedBytes, VersionedSerializable}, source_map::{PartialFileLines, PartialLoc}, BytePos, SourceMap, SourceMapper, Span, }; use wasmer::{AsStoreMut, FunctionEnvMut, Memory, TypedFunction}; us...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_plugin_runner/src/imported_fn/span.rs
Rust
pub fn span_dummy_with_cmt_proxy() -> u32 { // Instead of trying to serialize whole span, send bytepos only swc_common::Span::dummy_with_cmt().lo.0 }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_plugin_runner/src/lib.rs
Rust
#![cfg_attr(not(feature = "__rkyv"), allow(warnings))] use std::sync::Arc; use swc_common::{plugin::metadata::TransformPluginMetadataContext, SourceMap}; use transform_executor::TransformExecutor; pub mod cache; mod host_environment; #[cfg(feature = "__rkyv")] mod imported_fn; #[cfg(feature = "__rkyv")] mod memory_i...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_plugin_runner/src/memory_interop.rs
Rust
use swc_common::plugin::serialized::{PluginSerializedBytes, VersionedSerializable}; use swc_plugin_proxy::AllocatedBytesPtr; use wasmer::{Memory, MemoryView, StoreMut, TypedFunction, WasmPtr}; #[tracing::instrument(level = "info", skip_all)] pub fn copy_bytes_into_host(memory: &MemoryView, bytes_ptr: i32, bytes_ptr_le...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_plugin_runner/src/plugin_module_bytes.rs
Rust
use anyhow::Error; use serde::{Deserialize, Serialize}; use wasmer::{Module, Store}; use crate::wasix_runtime::new_store; // A trait abstracts plugin's wasm compilation and instantiation. // Depends on the caller, this could be a simple clone from existing module, or // load from file system cache. pub trait PluginMo...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_plugin_runner/src/transform_executor.rs
Rust
use std::{env, sync::Arc}; use anyhow::{anyhow, Context, Error}; use parking_lot::Mutex; #[cfg(feature = "__rkyv")] use swc_common::plugin::serialized::{PluginError, PluginSerializedBytes}; #[cfg(any( feature = "plugin_transform_schema_v1", feature = "plugin_transform_schema_vtest" ))] use swc_common::plugin::...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_plugin_runner/src/wasix_runtime.rs
Rust
#![allow(unused)] use std::{path::PathBuf, sync::Arc}; use parking_lot::Mutex; use swc_common::sync::Lazy; use wasmer::Store; use wasmer_wasix::Runtime; /// A shared instance to plugin runtime engine. /// ref: https://github.com/wasmerio/wasmer/issues/3793#issuecomment-1607117480 static ENGINE: Lazy<Mutex<wasmer::En...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_plugin_runner/tests/css-plugins/swc_noop_plugin/src/lib.rs
Rust
use swc_core::{ css::ast::Stylesheet, plugin::{css_plugin_transform, metadata::TransformPluginProgramMetadata}, }; #[css_plugin_transform] pub fn process(program: Stylesheet, metadata: TransformPluginProgramMetadata) -> Stylesheet { program }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_plugin_runner/tests/css_rkyv.rs
Rust
#![cfg_attr(not(feature = "__rkyv"), allow(warnings))] use std::{ env, fs, path::{Path, PathBuf}, process::{Command, Stdio}, sync::Arc, }; use anyhow::{anyhow, Error}; use rustc_hash::FxHashMap; use serde_json::json; #[cfg(feature = "__rkyv")] use swc_common::plugin::serialized::PluginSerializedBytes; ...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_plugin_runner/tests/ecma_integration.rs
Rust
#![cfg_attr(not(feature = "__rkyv"), allow(warnings))] use std::{ env, fs, path::{Path, PathBuf}, process::{Command, Stdio}, sync::Arc, }; use anyhow::{anyhow, Error}; use rustc_hash::FxHashMap; use serde_json::json; #[cfg(feature = "__rkyv")] use swc_common::plugin::serialized::PluginSerializedBytes;...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_plugin_runner/tests/ecma_rkyv.rs
Rust
#![cfg_attr(not(feature = "__rkyv"), allow(warnings))] use std::{ env, fs, path::{Path, PathBuf}, process::{Command, Stdio}, sync::Arc, }; use anyhow::{anyhow, Error}; use rustc_hash::FxHashMap; use serde_json::json; #[cfg(feature = "__rkyv")] use swc_common::plugin::serialized::PluginSerializedBytes; ...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_plugin_runner/tests/fixture/issue_6404/src/lib.rs
Rust
use swc_core::{ common::{BytePos, SourceMapper, Span, SyntaxContext}, ecma::ast::*, plugin::{metadata::TransformPluginProgramMetadata, plugin_transform}, }; #[plugin_transform] pub fn process_transform(program: Program, metadata: TransformPluginProgramMetadata) -> Program { for i in 1..5 { let ...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_plugin_runner/tests/fixture/swc_internal_plugin/src/lib.rs
Rust
use swc_core::{ common::{SourceMapper, DUMMY_SP}, ecma::{ast::*, atoms::*, visit::*}, plugin::{ errors::HANDLER, metadata::{TransformPluginMetadataContextKind, TransformPluginProgramMetadata}, plugin_transform, }, quote, }; struct ConsoleOutputReplacer { metadata: Transf...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_plugin_runner/tests/fixture/swc_noop_plugin/src/lib.rs
Rust
use swc_core::{ ecma::ast::*, plugin::{metadata::TransformPluginProgramMetadata, plugin_transform}, }; #[plugin_transform] pub fn process(program: Program, _metadata: TransformPluginProgramMetadata) -> Program { program }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_plugin_runner/tests/issues.rs
Rust
#![cfg_attr(not(feature = "__rkyv"), allow(warnings))] use std::{ env, fs, path::{Path, PathBuf}, process::{Command, Stdio}, sync::Arc, }; use anyhow::{anyhow, Error}; use rustc_hash::FxHashMap; use serde_json::json; #[cfg(feature = "__rkyv")] use swc_common::plugin::serialized::PluginSerializedBytes;...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_plugin_testing/src/lib.rs
Rust
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_timer/src/lib.rs
Rust
#[doc(hidden)] pub extern crate tracing; use tracing::{info, span::EnteredSpan}; /// Prints time elapsed since `start` when dropped. /// /// See [timer] for usages. pub struct Timer { #[cfg(not(target_arch = "wasm32"))] _span: EnteredSpan, #[cfg(not(target_arch = "wasm32"))] start: std::time::Instant,...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_timer/tests/timer.rs
Rust
use swc_timer::timer; #[test] fn logging() { testing::run_test(false, |_, _| { let _timer = timer!("operation"); Ok(()) }) .unwrap(); }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_trace_macro/src/lib.rs
Rust
extern crate proc_macro; use quote::ToTokens; use syn::{parse_quote, AttrStyle, Attribute, ImplItem, ItemImpl}; /// Utility proc macro to add `#[tracing::instrument(level = "info", /// skip_all)]` to all methods in an impl block. /// /// This attribute macro is typically applied on an `VisitMut` impl block. /// If th...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_transform_common/src/lib.rs
Rust
pub mod output;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_transform_common/src/output.rs
Rust
//! (Experimental) Output capturing. //! //! This module provides a way to emit metadata to the JS caller. use std::cell::RefCell; use better_scoped_tls::scoped_tls; use rustc_hash::FxHashMap; use serde_json::Value; scoped_tls!(static OUTPUT: RefCell<FxHashMap<String, serde_json::Value>>); /// (Experimental) Captur...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/examples/isolated_declarations.rs
Rust
use std::{env, path::Path}; use swc_common::{comments::SingleThreadedComments, Mark}; use swc_ecma_codegen::to_code_with_comments; use swc_ecma_parser::{parse_file_as_program, Syntax, TsSyntax}; use swc_ecma_transforms_base::{fixer::paren_remover, resolver}; use swc_typescript::fast_dts::{FastDts, FastDtsOptions}; pu...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/src/diagnostic.rs
Rust
//! References //! * <https://github.com/oxc-project/oxc/blob/main/crates/oxc_isolated_declarations/src/diagnostics.rs> use std::{borrow::Cow, sync::Arc}; use swc_common::{FileName, Span}; use crate::fast_dts::FastDts; #[derive(Debug, Clone)] pub struct SourceRange { pub filename: Arc<FileName>, pub span: S...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/src/fast_dts/class.rs
Rust
use rustc_hash::FxHashMap; use swc_common::{util::take::Take, Spanned, SyntaxContext, DUMMY_SP}; use swc_ecma_ast::{ Accessibility, BindingIdent, Class, ClassMember, ClassProp, Expr, Key, Lit, MethodKind, Param, ParamOrTsParamProp, Pat, PrivateName, PrivateProp, PropName, TsParamProp, TsParamPropParam, TsTy...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/src/fast_dts/decl.rs
Rust
use swc_common::Spanned; use swc_ecma_ast::{ Decl, DefaultDecl, Expr, Lit, Pat, TsNamespaceBody, VarDeclKind, VarDeclarator, }; use swc_ecma_visit::VisitMutWith; use super::{ type_ann, util::{ast_ext::PatExt, types::any_type_ann}, visitors::internal_annotation::InternalAnnotationTransformer, FastDt...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/src/fast_dts/enum.rs
Rust
use core::f64; use rustc_hash::FxHashMap; use swc_atoms::Atom; use swc_common::{Spanned, SyntaxContext, DUMMY_SP}; use swc_ecma_ast::{ BinExpr, BinaryOp, Expr, Ident, Lit, Number, Str, TsEnumDecl, TsEnumMemberId, UnaryExpr, UnaryOp, }; use swc_ecma_utils::number::JsNumber; use super::{util::ast_ext::MemberPro...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/src/fast_dts/function.rs
Rust
use std::mem; use swc_atoms::Atom; use swc_common::{Span, Spanned, DUMMY_SP}; use swc_ecma_ast::{ AssignPat, Decl, ExportDecl, Function, ModuleDecl, ModuleItem, Param, Pat, Script, Stmt, TsKeywordTypeKind, TsType, TsTypeAnn, TsUnionOrIntersectionType, TsUnionType, }; use super::{ type_ann, util::types...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/src/fast_dts/inferrer.rs
Rust
use swc_common::{Spanned, DUMMY_SP}; use swc_ecma_ast::{ ArrowExpr, BindingIdent, BlockStmtOrExpr, Class, Expr, Function, Ident, Lit, ReturnStmt, Stmt, TsKeywordTypeKind, TsParenthesizedType, TsType, TsTypeAliasDecl, TsTypeAnn, TsUnionOrIntersectionType, TsUnionType, UnaryExpr, UnaryOp, }; use swc_ecma_visi...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/src/fast_dts/mod.rs
Rust
use std::{borrow::Cow, mem::take, sync::Arc}; use rustc_hash::{FxHashMap, FxHashSet}; use swc_atoms::Atom; use swc_common::{ comments::SingleThreadedComments, util::take::Take, BytePos, FileName, Mark, Span, Spanned, DUMMY_SP, }; use swc_ecma_ast::{ BindingIdent, Decl, DefaultDecl, ExportDefaultExpr, Id, I...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/src/fast_dts/types.rs
Rust
use swc_common::{BytePos, Span, Spanned, DUMMY_SP}; use swc_ecma_ast::{ ArrayLit, ArrowExpr, Expr, Function, Lit, ObjectLit, Param, Pat, Prop, PropName, PropOrSpread, Str, Tpl, TsFnOrConstructorType, TsFnParam, TsFnType, TsKeywordTypeKind, TsLit, TsMethodSignature, TsPropertySignature, TsTupleElement, TsTup...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/src/fast_dts/util/ast_ext.rs
Rust
use std::borrow::Cow; use swc_atoms::Atom; use swc_ecma_ast::{ BindingIdent, Expr, Ident, Lit, MemberProp, ObjectPatProp, Pat, PropName, TsTypeAnn, }; pub trait ExprExit { fn get_root_ident(&self) -> Option<&Ident>; } impl ExprExit for Expr { fn get_root_ident(&self) -> Option<&Ident> { match sel...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/src/fast_dts/util/expando_function_collector.rs
Rust
use rustc_hash::FxHashSet; use swc_atoms::Atom; use swc_ecma_ast::{FnDecl, FnExpr, Id, VarDecl}; use super::ast_ext::PatExt; pub(crate) struct ExpandoFunctionCollector<'a> { declared_function_names: FxHashSet<Atom>, used_refs: &'a FxHashSet<Id>, } impl<'a> ExpandoFunctionCollector<'a> { pub(crate) fn new...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/src/fast_dts/util/mod.rs
Rust
pub mod ast_ext; pub mod expando_function_collector; pub mod types;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/src/fast_dts/util/types.rs
Rust
use swc_common::DUMMY_SP; use swc_ecma_ast::{TsKeywordType, TsKeywordTypeKind, TsLit, TsLitType, TsType, TsTypeAnn}; pub fn any_type_ann() -> Box<TsTypeAnn> { type_ann(ts_keyword_type(TsKeywordTypeKind::TsAnyKeyword)) } pub fn type_ann(ts_type: Box<TsType>) -> Box<TsTypeAnn> { Box::new(TsTypeAnn { spa...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/src/fast_dts/visitors/internal_annotation.rs
Rust
use rustc_hash::FxHashSet; use swc_common::{BytePos, Spanned}; use swc_ecma_ast::TsTypeElement; use swc_ecma_visit::VisitMut; pub struct InternalAnnotationTransformer<'a> { internal_annotations: &'a FxHashSet<BytePos>, } impl<'a> InternalAnnotationTransformer<'a> { pub fn new(internal_annotations: &'a FxHashS...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/src/fast_dts/visitors/mod.rs
Rust
pub(crate) mod internal_annotation; pub(crate) mod type_usage;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/src/fast_dts/visitors/type_usage.rs
Rust
use petgraph::{ graph::{DiGraph, NodeIndex}, visit::Bfs, Graph, }; use rustc_hash::{FxHashMap, FxHashSet}; use swc_common::{BytePos, Spanned, SyntaxContext}; use swc_ecma_ast::{ Accessibility, Class, ClassMember, Decl, ExportDecl, ExportDefaultDecl, ExportDefaultExpr, Function, Id, Ident, ModuleExpo...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/src/lib.rs
Rust
#![allow(clippy::boxed_local)] pub mod diagnostic; pub mod fast_dts;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/tests/deno_test.rs
Rust
//! Tests copied from deno //! Make some changes to align with tsc use swc_common::Mark; use swc_ecma_ast::EsVersion; use swc_ecma_codegen::to_code; use swc_ecma_parser::{parse_file_as_program, Syntax, TsSyntax}; use swc_ecma_transforms_base::resolver; use swc_typescript::fast_dts::FastDts; #[track_caller] fn transfo...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/tests/fixture/abstract-overloads.ts
TypeScript
export abstract class Value { protected body?(): string | undefined | Promise<string | undefined>; protected footer(): string | undefined { return ""; } } function overloadsNonExportDecl(args: string): void; function overloadsNonExportDecl(args: number): void; function overloadsNonExportDecl(args: a...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/tests/fixture/binding-ref.ts
TypeScript
export const ssrUtils = { createComponentInstance: 1 }; const { createComponentInstance } = ssrUtils; export function createComponentInstance(): void {}
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/tests/fixture/class-abstract-method.ts
TypeScript
export abstract class Manager { protected abstract A(): void; protected B(): void { console.log("B"); } protected C(): void { console.log("B"); } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/tests/fixture/class-params-initializers.ts
TypeScript
export class Object { constructor( values: {}, { a, b, }: { a?: A; b?: B; } = {} ) {} method( values: {}, { a, b, }: { a?: A; b?: B; } = {}, ...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/tests/fixture/class-properties-computed.ts
TypeScript
export class Test { [Symbol.for("nodejs.util.inspect.custom")]() {} ["string"]: string; ["string2" as string]: string; [1 as number]: string; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/tests/fixture/issues/10034.ts
TypeScript
const A_SYMBOL = Symbol("A_SYMBOL"); const func = () => null; export class SomeClass { private func( queryFingerprint: string, onStale: () => void ): null | typeof A_SYMBOL { return null; } private func2( queryFingerprint: string, onStale: () => void ): null...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/tests/fixture/issues/9550.ts
TypeScript
/** * Sample JSDoc that I wish was in the swc.transform output * @param a - string param * @param b - number param * @returns - object with a and b */ function sampleFunc(a: string, b: number): void {}
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/tests/fixture/issues/9817.tsx
TypeScript (TSX)
import React from "react"; export class Component<T> extends React.PureComponent<{}, {}> { render(): React.ReactNode { return <div>Hello world</div>; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/tests/fixture/issues/9859.ts
TypeScript
export class NumberRange implements Iterable<number> { private start: number; private end: number; constructor(start: number, end: number) { this.start = start; this.end = end; } [Symbol.iterator](): Iterator<number> { let current = this.start; const end = this.end;...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/tests/fixture/private-accessibility.ts
TypeScript
const A_SYMBOL = Symbol("A_SYMBOL"); export class A { private p1: typeof A_SYMBOL; private constructor(a: typeof A_SYMBOL) {} private accessor myProperty: typeof A_SYMBOL; private func1(a: typeof A_SYMBOL): typeof A_SYMBOL | null { return null; } } export class B { private constructor(...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/tests/fixture/signature-computed-property-name.ts
TypeScript
export interface A { ["foo" as string]: number; ["bar" as string](a: number): string; } export type B = { ["foo" as string]: number; ["bar" as string](a: number): string; }; export type C = { [D?.b]: number; };
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/tests/fixture/simple-constants.ts
TypeScript
export const foo1 = 1; export var foo2: number = "abc"; export enum Foo3 { A = "foo", B = "bar", }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/tests/fixture/symbol-properties.ts
TypeScript
// Correct export const foo = { [Symbol.iterator]: (): void => {}, [Symbol.asyncIterator]: async (): Promise<void> => {}, [globalThis.Symbol.iterator]: (): void => {}, get [Symbol.toStringTag]() { return "foo"; }, }; export abstract class Foo { [Symbol.iterator](): void {} async [Sy...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/tests/fixture/transitive-references.ts
TypeScript
type A = number; type B = A | string; export function exp1(): void {} var a = 1; var b: typeof a = 2; export function exp2(): void {} export {};
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/tests/fixture/ts-property.ts
TypeScript
const A = "123"; const B = "456"; export interface I { [A]: "123"; [B]: "456"; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/tests/fixture/type-usage.ts
TypeScript
import type * as Member from "some-path/my_module"; export interface IMember extends Member.C<"SimpleEntity"> {} import type * as Ident from "some-path/my_module"; export interface IIdent extends Ident {} import * as Paren from "some-path/my_module"; export class CParen extends Paren {} import * as OptChain from "so...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/tests/oxc_fixture/arrow-function-return-type.ts
TypeScript
function A() { return () => { return C; } } const B = () => { return B }; const C = function () {} const D = () => `${''}`; const E = (): (() => void) | undefined => { return () => {}; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/tests/oxc_fixture/as-const.ts
TypeScript
const F = { string: `string`, templateLiteral: `templateLiteral`, number: 1.23, bigint: -1_2_3n, boolean: true, null: null, undefined: undefined, function(a: string): void {}, arrow: (a: string): void => {}, object: { a: `a`, b: `b` }, array: [`a`, , { b: `\n` }], } as const
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/tests/oxc_fixture/async-function.ts
TypeScript
// Correct async function asyncFunctionGood(): Promise<number> {} const asyncFunctionGoo2 = async (): Promise<number> => { return Promise.resolve(0); } class AsyncClassGood { async method(): number { return 42; } } // Need to explicit return type for async functions // Incorrect async function asyncFunctio...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/tests/oxc_fixture/class.ts
TypeScript
export class Foo { private constructor(a: number = 0) {} } export class Bar { public constructor(a: number = 0) {} } export class Zoo { foo<F>(f: F): F { return f; } } export abstract class Qux { abstract foo(): void; protected foo2?(): void; bar(): void {} baz(): void {} } export class Baz { ...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/tests/oxc_fixture/declare-global.ts
TypeScript
function MyFunction() { return 'here is my function' } declare global { interface Window { MyFunction: typeof MyFunction } } export {}
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/tests/oxc_fixture/eliminate-imports.ts
TypeScript
import { AExtend, BExtend, Type, CImplements1, CImplements2, CType, ThisType1, ThisType2, Unused } from 'mod'; export interface A extends AExtend<Type> {} export class B extends BExtend<Type> {} export class C implements CImplements1<CType>, CImplements2<CType> {} export function foo(this: ThisType1): void {} export c...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/tests/oxc_fixture/empty-export.ts
TypeScript
type A = string; export function a(): A { return "" } export declare const ShallowReactiveMarker: unique symbol export type ShallowReactive<T> = T & { [ShallowReactiveMarker]?: true }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/tests/oxc_fixture/empty-export2.ts
TypeScript
import * as a from "mod";
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/tests/oxc_fixture/expando-function.ts
TypeScript
export function foo(): void {} foo.apply = () => {} export const bar = (): void => {} bar.call = () => {} export namespace NS { export const goo = (): void => {} goo.length = 10 } export namespace foo { // declaration must be exported let bar = 42; export let baz = 100; } foo.bar = 42; foo.baz = 100; //...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/tests/oxc_fixture/export-default.ts
TypeScript
const defaultDelimitersClose = new Uint8Array([125, 125]) export default class Tokenizer { public delimiterClose: Uint8Array = defaultDelimitersClose }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/tests/oxc_fixture/function-overloads.ts
TypeScript
function a(a: number): number; function a(a: string): string; function a(a: any): any {} function b(a: number): number {}; function b(a: string): string {};
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/tests/oxc_fixture/function-parameters.ts
TypeScript
// Correct export function fnDeclGood(p: T = [], rParam = ""): void { }; export function fnDeclGood2(p: T = [], rParam?: number): void { }; export function fooGood([a, b]: any[] = [1, 2]): number { return 2; } export const fooGood2 = ({a, b}: object = { a: 1, b: 2 }): number => { return 2; } const x = 42; const ...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/tests/oxc_fixture/function-signatures.ts
TypeScript
// All of these are valid function signatures under isolatedDeclarations export function A(): void { return; } export function B(): (() => void) | undefined { return () => {}; } // There should be no declaration for the implementation signature, just the // two overloads. export function C(x: string): void ex...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/tests/oxc_fixture/generator.ts
TypeScript
// Correct function *generatorGood(): Generator<number> {} class GeneratorClassGood { *method(): Generator<number> { yield 50; return 42; } } // Need to explicit return type for async functions // Incorrect function *generatorBad() { yield 50; return 42; } class GeneratorClassBad { *method() { ...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/tests/oxc_fixture/infer-expression.ts
TypeScript
// Correct // ParenthesizedExpression const n = (0); const s = (""); const t = (``); const b = (true); // UnaryExpression let unaryA = +12; const unaryB = -1_2n; // Incorrect // UnaryExpression const unaryC = +"str" const unaryD = typeof "str" const unaryE = {E: -"str"} as const const unaryF = [+"str"] as const
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/tests/oxc_fixture/infer-return-type.ts
TypeScript
function foo() { return 1; } // inferred type is number function bar() { if (a) { return; } return 1; } // inferred type is number | undefined function baz() { if (a) { return null; } return 1; } // We can't infer return type if there are multiple return statements with different types function qux(...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/tests/oxc_fixture/infer-template-literal.ts
TypeScript
export const CSS_VARS_HELPER = `useCssVars` export function g(func = `useCssVar`) : void {} export const F = { a: `a`, b: [`b`] } as const export let GOOD = `useCssV${v}ars` export const BAD = `useCssV${v}ars` export let BAD2 = `useCssV${v}ars` as const
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/tests/oxc_fixture/mapped-types.ts
TypeScript
import {K} from 'foo' import {T} from 'bar' export interface I { prop: {[key in K]: T} }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/tests/oxc_fixture/module-declaration-with-export.ts
TypeScript
export namespace OnlyOneExport { export const a = 0; } export namespace TwoExports { export const c = 0; export const a: typeof c = 0; } export namespace OneExportReferencedANonExported { const c = 0; export const a: typeof c = c; } declare module "OnlyOneExport" { export const a = 0; } declare modu...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/tests/oxc_fixture/module-declaration.ts
TypeScript
import "foo"; declare module "foo" { interface Foo {} const foo = 42; } declare global { interface Bar {} const bar = 42; } import { type X } from "./x"; type Y = 1; declare module "foo" { interface Foo { x: X; y: Y; } } // should not be emitted module baz { interface Baz {} const baz = 42; ...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/tests/oxc_fixture/non-exported-binding-elements.ts
TypeScript
// Correct const [A, B] = [1, 2, 3]; export function foo(): number { return A; } // Incorrect const { c, d } = { c: 1, d: 2 }; const [ e ] = [4]; export { c, d, e } export const { f, g } = { f: 5, g: 6 };
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/tests/oxc_fixture/readonly.ts
TypeScript
export const EMPTY_OBJ: { readonly [key: string]: any } = __DEV__ ? Object.freeze({}) : {} export const EMPTY_ARR: readonly never[] = __DEV__ ? Object.freeze([]) : []
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/tests/oxc_fixture/set-get-accessor.ts
TypeScript
// Correct class Cls { get a() { return 1; } set a() { return; } get b(): string { } set b(v) { } private get c() {} private set c() {} } // Incorrect class ClsBad { get a() { return; } set a(v) { } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/tests/oxc_fixture/signatures.ts
TypeScript
export interface X { set value(_: string); } export type A = { set value({ a, b, c }: { a: string; b: string; c: string }); get value(); }; export interface I { set value(_); get value(): string; } // Do nothing export interface Ref<T = any, S = T> { get value(): T set value(_: S) } export interface ...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/tests/oxc_fixture/strip-internal.ts
TypeScript
/* @internal */ class StripInternalClass { public test() { console.log("test"); } } class StripInternalClassFields { /** * @internal */ internalProperty: string = "internal"; // @internal internalMethod(): void {} } /** @internal */ function stripInternalFunction() { console.log("test"); } e...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_typescript/tests/oxc_fixture/ts-export-assignment.ts
TypeScript
const Res = 0; export = function Foo(): typeof Res { return Res; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University