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

Undefined warnings for variables in ref files #208

Closed
quantuminformation opened this issue Mar 25, 2017 · 8 comments
Closed

Undefined warnings for variables in ref files #208

quantuminformation opened this issue Mar 25, 2017 · 8 comments
Labels

Comments

@quantuminformation
Copy link

What version of TypeScript are you using?
2.1.4

What version of typescript-eslint-parser are you using?

^2.0.0
What code were you trying to parse?
https://github.com/QuantumInformation/Density-Wars/blob/master/client/Game.ts

What did you expect to happen?

Have no warnings for variables declared in REF declarations: (BABYLON )
https://github.com/QuantumInformation/Density-Wars/blob/master/client/Game.ts#L1

What happened?
warnings about BABYLON like
image

@soda0289
Copy link
Member

We do not currently parse reference files. If we did we would still need an eslint plugin rule to parse the typing declarations and add them to the global scope. This could be done in the future.

A workaround would be to use an import statement instead of the reference file. For example:

import * as BABYLON from 'babylonjs';

If you get a warning about no types found you can install them but it looks like the library might come with type definitions already.
You can then install the typing file with the command here:
npm install @types/babylonjs

Since typescript 2.0 these typing files are loaded by default and the reference line is no longer needed.

@quantuminformation
Copy link
Author

Thanks, originally I used import BABYLON from 'babylonjs'; but was having build errors with webpack and now I just copy the babylon lib to the public dir. I guess I can just ignore undef vars for now. What do you think?

@soda0289
Copy link
Member

There are some other errors with no-undef, when using interfaces, that cause false positives. So it would be best to leave it off. Typescript compiler has built in handling of no undefined parameters and local variables with noUnusedLocals and noUnusedParameters.

You can check this issue for other problems with eslint rules and this typescript parser:
#77

@quantuminformation
Copy link
Author

@quantuminformation
Copy link
Author

I'm not sure if it uses this lib or not.

@soda0289
Copy link
Member

soda0289 commented Mar 25, 2017

I think that uses tslint, which is a great linter as well just has less rules and configuration options. Eslint still needs some more work to allow for all the current rules to work. This is being worked on and will continue to get better.

@quantuminformation
Copy link
Author

quantuminformation commented Mar 25, 2017 via email

@soda0289 soda0289 added bug and removed triage labels Apr 12, 2017
@JamesHenry
Copy link
Member

I'm going to close this due to lack of activity.

We now have a brand new way of running integration tests for this project, which allows for complex setups to be reproduced in isolation: https://github.com/eslint/typescript-eslint-parser#integration-tests

If this is still an issue for you using the latest version, please create a failing integration test for it and open a new issue to discuss.

Thanks!

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

4 participants