Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ impl NoUnusedVars {
let declared_binding = symbol.name();
match symbol.declaration().kind() {
AstKind::BindingRestElement(_)
| AstKind::Function(_)
| AstKind::ImportDefaultSpecifier(_)
| AstKind::ImportNamespaceSpecifier(_)
| AstKind::ImportSpecifier(_)
Expand All @@ -69,9 +68,13 @@ impl NoUnusedVars {
| AstKind::TSModuleDeclaration(_)
| AstKind::TSTypeAliasDeclaration(_)
| AstKind::TSTypeParameter(_) => self.is_ignored_var(declared_binding),
AstKind::Function(func) => {
func.r#type.is_typescript_syntax() || self.is_ignored_var(declared_binding)
}
AstKind::Class(class) => {
if self.ignore_class_with_static_init_block
&& class.body.body.iter().any(ClassElement::is_static_block)
if class.declare
|| self.ignore_class_with_static_init_block
&& class.body.body.iter().any(ClassElement::is_static_block)
{
return true;
}
Expand Down
3 changes: 0 additions & 3 deletions crates/oxc_semantic/src/binder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,6 @@ fn is_function_part_of_if_statement(function: &Function, builder: &SemanticBuild

impl<'a> Binder<'a> for Function<'a> {
fn bind(&self, builder: &mut SemanticBuilder) {
if self.r#type.is_typescript_syntax() {
return;
}
if let Some(ident) = &self.id {
if is_function_part_of_if_statement(self, builder) {
let symbol_id = builder.scoping.create_symbol(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ input_file: crates/oxc_semantic/tests/fixtures/typescript-eslint/decorators/clas
"symbols": [
{
"flags": "SymbolFlags(FunctionScopedVariable)",
"id": 0,
"id": 1,
"name": "param",
"node": "BindingRestElement",
"references": []
Expand All @@ -40,9 +40,23 @@ input_file: crates/oxc_semantic/tests/fixtures/typescript-eslint/decorators/clas
"id": 0,
"node": "Program",
"symbols": [
{
"flags": "SymbolFlags(Function)",
"id": 0,
"name": "deco",
"node": "Function(deco)",
"references": [
{
"flags": "ReferenceFlags(Read)",
"id": 0,
"name": "deco",
"node_id": 19
}
]
},
{
"flags": "SymbolFlags(Class)",
"id": 1,
"id": 2,
"name": "Foo",
"node": "Class(Foo)",
"references": []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ input_file: crates/oxc_semantic/tests/fixtures/typescript-eslint/functions/funct
"symbols": [
{
"flags": "SymbolFlags(FunctionScopedVariable)",
"id": 0,
"id": 1,
"name": "a",
"node": "FormalParameter(a)",
"references": []
},
{
"flags": "SymbolFlags(FunctionScopedVariable)",
"id": 1,
"id": 2,
"name": "b",
"node": "FormalParameter(b)",
"references": []
Expand Down Expand Up @@ -63,7 +63,7 @@ input_file: crates/oxc_semantic/tests/fixtures/typescript-eslint/functions/funct
"symbols": [
{
"flags": "SymbolFlags(Function)",
"id": 2,
"id": 0,
"name": "foo",
"node": "Function(foo)",
"references": []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ input_file: crates/oxc_semantic/tests/fixtures/typescript-eslint/type-declaratio
"symbols": [
{
"flags": "SymbolFlags(FunctionScopedVariable)",
"id": 2,
"id": 3,
"name": "value",
"node": "FormalParameter(value)",
"references": []
Expand Down Expand Up @@ -66,6 +66,13 @@ input_file: crates/oxc_semantic/tests/fixtures/typescript-eslint/type-declaratio
"node_id": 31
}
]
},
{
"flags": "SymbolFlags(Function)",
"id": 2,
"name": "setAlignment",
"node": "Function(setAlignment)",
"references": []
}
]
}
Expand Down
110 changes: 102 additions & 8 deletions tasks/coverage/snapshots/parser_typescript.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ commit: 15392346

parser_typescript Summary:
AST Parsed : 6522/6531 (99.86%)
Positive Passed: 6511/6531 (99.69%)
Negative Passed: 1290/5754 (22.42%)
Positive Passed: 6510/6531 (99.68%)
Negative Passed: 1296/5754 (22.52%)
Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/ClassDeclaration24.ts
Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/ExportAssignment7.ts
Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/ExportAssignment8.ts
Expand Down Expand Up @@ -220,9 +220,6 @@ Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/callOnInstan
Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/callOverloadViaElementAccessExpression.ts
Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/callOverloads1.ts
Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/callOverloads2.ts
Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/callOverloads3.ts
Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/callOverloads4.ts
Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/callOverloads5.ts
Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/callSignaturesShouldBeResolvedBeforeSpecialization.ts
Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/callWithWrongNumberOfTypeArguments.ts
Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/callbackArgsDifferByOptionality.ts
Expand Down Expand Up @@ -321,7 +318,6 @@ Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/classMemberI
Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/classMergedWithInterfaceMultipleBasesNoError.ts
Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/classOrder2.ts
Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/classOverloadForFunction.ts
Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/classOverloadForFunction2.ts
Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/classPropertyErrorOnNameOnly.ts
Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/classSideInheritance1.ts
Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/classSideInheritance2.ts
Expand Down Expand Up @@ -686,7 +682,6 @@ Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/enumsWithMul
Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/erasableSyntaxOnly.ts
Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/erasableSyntaxOnlyDeclaration.ts
Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/errorCause.ts
Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/errorElaboration.ts
Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/errorElaborationDivesIntoApparentlyPresentPropsOnly.ts
Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/errorForBareSpecifierWithImplicitModuleResolutionNone.ts
Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/errorForConflictingExportEqualsValue.ts
Expand Down Expand Up @@ -1885,7 +1880,6 @@ Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/spreadInvali
Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/spreadOfParamsFromGeneratorMakesRequiredParams.ts
Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/spyComparisonChecking.ts
Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/staticAsIdentifier.ts
Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/staticClassMemberError.ts
Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/staticInstanceResolution4.ts
Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/staticInstanceResolution5.ts
Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/staticMemberExportAccess.ts
Expand Down Expand Up @@ -4563,6 +4557,20 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/compiler/bom-utf16be.ts
1 │ ￾瘀愀爀 砀㴀㄀ 㬀ഀ਀
· ─
╰────
Expect to Parse: tasks/coverage/typescript/tests/cases/compiler/constructorOverloads5.ts

× Identifier `RegExp` has already been declared
╭─[typescript/tests/cases/compiler/constructorOverloads5.ts:4:21]
3 │ declare module M {
4 │ export function RegExp(pattern: string): RegExp;
· ───┬──
· ╰── `RegExp` has already been declared here
5 │ export function RegExp(pattern: string, flags: string): RegExp;
6 │ export class RegExp {
· ───┬──
· ╰── It can not be redeclared here
7 │ constructor(pattern: string);
╰────
Expect to Parse: tasks/coverage/typescript/tests/cases/compiler/elidedEmbeddedStatementsReplacedWithSemicolon.ts

× 'with' statements are not allowed
Expand Down Expand Up @@ -5849,6 +5857,42 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/salsa/private
· ─
╰────

× Identifier `Foo` has already been declared
╭─[typescript/tests/cases/compiler/callOverloads3.ts:1:10]
1 │ function Foo():Foo; // error
· ─┬─
· ╰── `Foo` has already been declared here
2 │ function Foo(s:string):Foo; // error
3 │ class Foo { // error
· ─┬─
· ╰── It can not be redeclared here
4 │ bar1() { /*WScript.Echo("bar1");*/ }
╰────

× Identifier `Foo` has already been declared
╭─[typescript/tests/cases/compiler/callOverloads4.ts:1:10]
1 │ function Foo():Foo; // error
· ─┬─
· ╰── `Foo` has already been declared here
2 │ function Foo(s:string):Foo; // error
3 │ class Foo { // error
· ─┬─
· ╰── It can not be redeclared here
4 │ bar1() { /*WScript.Echo("bar1");*/ }
╰────

× Identifier `Foo` has already been declared
╭─[typescript/tests/cases/compiler/callOverloads5.ts:1:10]
1 │ function Foo():Foo; // error
· ─┬─
· ╰── `Foo` has already been declared here
2 │ function Foo(s:string):Foo; // error
3 │ class Foo { // error
· ─┬─
· ╰── It can not be redeclared here
4 │ bar1(s:string);
╰────

× Unexpected token
╭─[typescript/tests/cases/compiler/cannotInvokeNewOnErrorExpression.ts:5:22]
4 │ }
Expand Down Expand Up @@ -5953,6 +5997,16 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/salsa/private
3 │ }
╰────

× Identifier `bar` has already been declared
╭─[typescript/tests/cases/compiler/classOverloadForFunction2.ts:1:10]
1 │ function bar(): string;
· ─┬─
· ╰── `bar` has already been declared here
2 │ class bar {}
· ─┬─
· ╰── It can not be redeclared here
╰────

× Expected a semicolon or an implicit semicolon after a statement, but found none
╭─[typescript/tests/cases/compiler/classUpdateTests.ts:93:9]
92 │ constructor() {
Expand Down Expand Up @@ -7797,6 +7851,22 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/salsa/private
· ╰── `,` expected
╰────

× Identifier `foo` has already been declared
╭─[typescript/tests/cases/compiler/errorElaboration.ts:10:18]
9 │ }
10 │ declare function foo(x: () => Container<Ref<number>>): void;
· ─┬─
· ╰── `foo` has already been declared here
11 │ let a: () => Container<Ref<string>>;
╰────
╭─[typescript/tests/cases/compiler/errorElaboration.ts:22:7]
21 │
22 │ const foo = { bar: 'a' };
· ─┬─
· ╰── It can not be redeclared here
23 │ const x = ({ [foo.bar]: c }) => undefined;
╰────

× Unexpected token
╭─[typescript/tests/cases/compiler/errorForUsingPropertyOfTypeAsType01.ts:44:24]
43 │
Expand Down Expand Up @@ -10060,6 +10130,18 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/salsa/private
· ┬
· ╰── `f` has already been declared here
2 │
3 │ export function f();
· ┬
· ╰── It can not be redeclared here
4 │ export function f() {
╰────

× Identifier `f` has already been declared
╭─[typescript/tests/cases/compiler/nonMergedOverloads.ts:1:5]
1 │ var f = 10;
· ┬
· ╰── `f` has already been declared here
2 │
3 │ export function f();
4 │ export function f() {
· ┬
Expand Down Expand Up @@ -12038,6 +12120,18 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/salsa/private
╰────
help: A `break` statement can only be used within an enclosing iteration or switch statement.

× Identifier `Foo` has already been declared
╭─[typescript/tests/cases/compiler/staticClassMemberError.ts:9:10]
8 │ // just want to make sure this one doesn't crash the compiler
9 │ function Foo();
· ─┬─
· ╰── `Foo` has already been declared here
10 │ class Foo {
· ─┬─
· ╰── It can not be redeclared here
11 │ static bar;
╰────

× Expected a semicolon or an implicit semicolon after a statement, but found none
╭─[typescript/tests/cases/compiler/staticClassProps.ts:4:15]
3 │ public foo() {
Expand Down
Loading