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

feat(typescript): Align isolatedDeclaration implementation with tsc #9715

Merged
merged 49 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
d583101
port: fix(fast_check/dts): remove initializers in class methods/ctors…
CPunisher Nov 4, 2024
8551a4e
port: fix(fast_check/dts): better handling of computed properties #522
CPunisher Nov 4, 2024
db1b136
port: feat: analyze commonjs files #540
CPunisher Nov 4, 2024
8f7bdda
fix overloads
CPunisher Nov 5, 2024
60370af
impl
CPunisher Nov 5, 2024
f8dd99c
check binding
CPunisher Nov 5, 2024
4d0ab66
ts snapshot tests
CPunisher Nov 5, 2024
dcc3162
Split transformations
CPunisher Nov 13, 2024
a0c4ea4
Fix rebase conflict
CPunisher Nov 13, 2024
34726be
Fix
CPunisher Nov 13, 2024
5486c8b
is_declare
CPunisher Nov 13, 2024
e70157b
finish function
CPunisher Nov 14, 2024
5d41a43
finish class
CPunisher Nov 15, 2024
61f003a
collect_getter_or_setter_annotations
CPunisher Nov 15, 2024
ccd4e44
var decl
CPunisher Nov 15, 2024
d19679a
type inferer
CPunisher Nov 16, 2024
696d55f
deno test, fix dts_function_test
CPunisher Nov 16, 2024
a34cb0c
reset fixtures
CPunisher Nov 16, 2024
d97b1ab
pass deno tests
CPunisher Nov 16, 2024
d8e60d5
fix ts module block
CPunisher Nov 17, 2024
08764b7
fix arrow-function-return-type
CPunisher Nov 17, 2024
aa23875
enum
CPunisher Nov 18, 2024
e2d3221
fix as-const
CPunisher Nov 18, 2024
eda081f
fix async function
CPunisher Nov 18, 2024
e7e6613
fix class
CPunisher Nov 18, 2024
466609b
fix eliminate-imports
CPunisher Nov 18, 2024
43c83e0
fix empty-export
CPunisher Nov 18, 2024
35403f5
fix expando-function
CPunisher Nov 22, 2024
1b969c5
fix export-default
CPunisher Nov 22, 2024
84090fe
fix function-*
CPunisher Nov 22, 2024
5eea8d8
fix module-declaration-with-export
CPunisher Nov 22, 2024
e044ce1
fix non-exported-binding-elements
CPunisher Nov 22, 2024
9c54c78
fix ts-export-assignment
CPunisher Nov 22, 2024
d78421a
fix set-get-accessor
CPunisher Nov 22, 2024
a759710
strip internal
CPunisher Nov 22, 2024
8f720f8
add example
CPunisher Nov 22, 2024
a6db37c
refactor
CPunisher Nov 22, 2024
d402015
use fx hash
CPunisher Nov 22, 2024
7ae548b
type usage graph
CPunisher Nov 23, 2024
bf181bb
add benchmark
CPunisher Nov 23, 2024
bf3c9b6
remove usage analysis for script
CPunisher Nov 23, 2024
3d6694c
update license
CPunisher Nov 23, 2024
bbc9a58
update tests and enable comments
CPunisher Nov 24, 2024
a885a27
remove decl that is not ident
CPunisher Nov 24, 2024
e4b34dd
remove enum and ts import equals
CPunisher Nov 24, 2024
6bafe04
fix binding-ref and ts-property
CPunisher Nov 24, 2024
8df2bd8
Revert manual tokio runtime
CPunisher Nov 28, 2024
eb88853
change iter_with_large_drop to iter
CPunisher Nov 28, 2024
858d762
Create tiny-snakes-train.md
kdy1 Dec 2, 2024
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
Prev Previous commit
Next Next commit
fix eliminate-imports
  • Loading branch information
CPunisher committed Nov 23, 2024
commit 466609b62789fe75bf8833eae83602b4afcfbadd
22 changes: 20 additions & 2 deletions crates/swc_typescript/src/fast_dts/type_usage.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::collections::HashSet;

use swc_ecma_ast::{
Decl, ExportDefaultExpr, Id, ImportSpecifier, ModuleDecl, ModuleExportName, ModuleItem,
NamedExport, Stmt, TsEntityName,
Class, Decl, ExportDefaultExpr, Id, ImportSpecifier, ModuleDecl, ModuleExportName, ModuleItem,
NamedExport, Stmt, TsEntityName, TsExprWithTypeArgs,
};
use swc_ecma_visit::{Visit, VisitMut, VisitMutWith, VisitWith};

Expand All @@ -12,6 +12,24 @@ pub struct TypeUsageAnalyzer {
}

impl Visit for TypeUsageAnalyzer {
fn visit_class(&mut self, node: &Class) {
if let Some(super_class) = &node.super_class {
// TODO:
if let Some(ident) = super_class.as_ident() {
self.used_ids.insert(ident.to_id());
}
}
node.visit_children_with(self);
}

fn visit_ts_expr_with_type_args(&mut self, node: &TsExprWithTypeArgs) {
// TODO:
if let Some(ident) = node.expr.as_ident() {
self.used_ids.insert(ident.to_id());
}
node.visit_children_with(self);
}

fn visit_ts_entity_name(&mut self, node: &TsEntityName) {
match node {
TsEntityName::TsQualifiedName(ts_qualified_name) => {
Expand Down
11 changes: 11 additions & 0 deletions crates/swc_typescript/tests/oxc_fixture/declare-global.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
```==================== .D.TS ====================

declare function MyFunction(): string;
declare global {
interface Window {
MyFunction: typeof MyFunction;
}
}
export { };


15 changes: 15 additions & 0 deletions crates/swc_typescript/tests/oxc_fixture/eliminate-imports.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
```==================== .D.TS ====================

import { BExtend } from 'mod';
export interface A extends AExtend<Type> {
}
export declare class B extends BExtend<Type> {
}
export declare class C implements CImplements1<CType>, CImplements2<CType> {
}
export declare function foo(this: ThisType1): void;
export declare const bar: (this: ThisType2) => void;
export type F<X extends InferType1> = X extends infer U extends InferType2 ? U : never;
export { Unused } from './unused';