Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(parser): fix visiting props of TSDeclareFunction (#244)
- Loading branch information
Showing
7 changed files
with
1,101 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { TSESTree } from '@typescript-eslint/typescript-estree'; | ||
|
||
import EslintScopeManager, { | ||
ScopeManagerOptions | ||
} from 'eslint-scope/lib/scope-manager'; | ||
import { EmptyFunctionScope, EnumScope } from './scopes'; | ||
import { Scope } from 'eslint-scope/lib/scope'; | ||
|
||
/** | ||
* based on eslint-scope | ||
*/ | ||
export class ScopeManager extends EslintScopeManager { | ||
scopes!: Scope[]; | ||
globalScope!: Scope; | ||
|
||
constructor(options: ScopeManagerOptions) { | ||
super(options); | ||
} | ||
|
||
/** @internal */ | ||
__nestEnumScope(node: TSESTree.TSEnumDeclaration) { | ||
return this.__nestScope(new EnumScope(this, this.__currentScope, node)); | ||
} | ||
|
||
/** @internal */ | ||
__nestEmptyFunctionScope(node: TSESTree.TSDeclareFunction) { | ||
return this.__nestScope( | ||
new EmptyFunctionScope(this, this.__currentScope, node) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { Scope } from 'eslint-scope/lib/scope'; | ||
import { ScopeManager } from './scope-manager'; | ||
import { TSESTree } from '@typescript-eslint/typescript-estree'; | ||
|
||
/** The scope class for enum. */ | ||
export class EnumScope extends Scope { | ||
constructor( | ||
scopeManager: ScopeManager, | ||
upperScope: Scope, | ||
block: TSESTree.TSEnumDeclaration | null | ||
) { | ||
super(scopeManager, 'enum', upperScope, block, false); | ||
} | ||
} | ||
|
||
/** The scope class for empty functions. */ | ||
export class EmptyFunctionScope extends Scope { | ||
constructor( | ||
scopeManager: ScopeManager, | ||
upperScope: Scope, | ||
block: TSESTree.TSDeclareFunction | null | ||
) { | ||
super(scopeManager, 'empty-function', upperScope, block, false); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
packages/parser/tests/fixtures/scope-analysis/declare-function-with-typeof.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
function eachr<Key, Value>(subject: Map<Key, Value>): typeof subject; |
Oops, something went wrong.