Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

Commit 519907e

Browse files
soda0289JamesHenry
authored andcommitted
Breaking: Use ESTree export node types in modules (fixes# 263) (#265)
1 parent c4b0b64 commit 519907e

File tree

5 files changed

+838
-12
lines changed

5 files changed

+838
-12
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
A parser that converts TypeScript into an [ESTree](https://github.com/estree/estree)-compatible form so it can be used in ESLint.
44

5-
**Important:** This parser is not fully compatbile with all ESLint rules and plugins. Some rules will improperly mark source code as failing or not find problems where it should.
5+
**Important:** This parser is not fully compatible with all ESLint rules and plugins. Some rules will improperly mark source code as failing or not find problems where it should.
66

77
## Supported TypeScript Version
88

@@ -24,6 +24,8 @@ The following ESLint rules will fail on acceptable code:
2424

2525
The follow ESLint plugins have issues when used with this parser:
2626
- eslint-plugin-react [#213](https://github.com/eslint/typescript-eslint-parser/issues/213)
27+
- eslint-plugin-import
28+
- prefer-default-export - Will fail exports inside of Namespaces or Modules
2729

2830
The following TypeScript syntax will cause rules to fail or ESLint v3 to crash:
2931
- Empty body functions
@@ -51,7 +53,7 @@ If you're familiar with TypeScript and ESLint, and you'd like to see this projec
5153

5254
## Reporting Bugs
5355

54-
Please check the current list of open and known issues and ensure the bug has not been reported before. When creating a new issue provide as much information about your enviroment as possible. This includes:
56+
Please check the current list of open and known issues and ensure the bug has not been reported before. When creating a new issue provide as much information about your environment as possible. This includes:
5557
- ESLint Version
5658
- TypeScript version
5759
- TypeScript parser version

lib/node-utils.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -491,15 +491,7 @@ function fixExports(node, result, ast) {
491491
result.range[0] = varToken.getStart();
492492
result.loc = getLocFor(result.range[0], result.range[1], ast);
493493

494-
let declarationType = declarationIsDefault ? "ExportDefaultDeclaration" : "ExportNamedDeclaration";
495-
496-
/**
497-
* Prefix exports from TypeScript namespaces with "TS" to distinguish
498-
* them from ES2015 exports
499-
*/
500-
if (node.parent && node.parent.kind === SyntaxKind.ModuleBlock) {
501-
declarationType = "TSNamespaceExportDeclaration";
502-
}
494+
const declarationType = declarationIsDefault ? "ExportDefaultDeclaration" : "ExportNamedDeclaration";
503495

504496
const newResult = {
505497
type: declarationType,

tests/fixtures/typescript/namespaces-and-modules/declare-namespace-with-exported-function.result.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ module.exports = {
8686
},
8787
"body": [
8888
{
89-
"type": "TSNamespaceExportDeclaration",
89+
"type": "ExportNamedDeclaration",
9090
"declaration": {
9191
"type": "TSNamespaceFunctionDeclaration",
9292
"range": [

0 commit comments

Comments
 (0)