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

Error with syntax import x = require('x') #47

Closed
OliverJAsh opened this issue Jul 13, 2016 · 5 comments
Closed

Error with syntax import x = require('x') #47

OliverJAsh opened this issue Jul 13, 2016 · 5 comments
Labels

Comments

@OliverJAsh
Copy link

OliverJAsh commented Jul 13, 2016

Hi, thanks for your amazing work. I have some feedback but I am very aware this project is still in the very early stages.

TypeScript has the syntax import x = require('x') for importing specifically CommonJS modules. (ES6 module syntax is used for ES6 modules.) I have found that when using this syntax, the parser throws because it doesn't recognise the imported identifier. Example below.

Versions:

$ npm ls eslint typescript-eslint-parser
/Users/OliverJAsh/Development/samefourchords.com
├── [email protected]
└── [email protected]

ESLint config:

{
    "extends": "eslint:recommended",
    "parser": "typescript-eslint-parser",
    "parserOptions": {
        "ecmaVersion": 6,
        "sourceType": "module",
        "ecmaFeatures": {
            "modules": true
        }
    }
}

Input and output:

$ echo "import slug = require('slug'); slug;" > test.js
$ eslint test.js
224

/Users/OliverJAsh/Development/samefourchords.com/test.js
  1:32  error  'slug' is not defined  no-undef

✖ 1 problem (1 error, 0 warnings)
@nzakas
Copy link
Member

nzakas commented Jul 16, 2016

That's not a parser error, it's an ESLint warning. We aren't yet at the point where it makes sense to track such problems because nothing is known to work at this point. The version you're using just completely skips over that import statement. Even if that started to work, ESlint would still produce a warning because scope calculation wouldn't recognize the syntax. So, we have a long way before this has a chance to work.

@OliverJAsh
Copy link
Author

Hi, this still appears to be an issue. Do you know whether this is something we can fix? Keen to help :-)

@nzakas
Copy link
Member

nzakas commented Aug 16, 2016

We are a long ways from being able to fix this. It requires an augmentation to how scope variables are found in ESLint, and that's a ton of work. Sit tight, we are very early in this process and will get there eventually. If you want to help otherwise, we do need help addressing bugs as they are found.

@j-f1
Copy link
Contributor

j-f1 commented Jan 30, 2018

@grenudi What version of TypeScript-ESLint-parser are you using?

@grenudi
Copy link

grenudi commented Jan 30, 2018

sorry, my fault

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants