Commit graph

10 commits

Author SHA1 Message Date
Nathan Shively-Sanders ec0e8cbe2b
noImplicitAny as suggestion (#27693)
* noImplicitAny as suggestion

Note that not all noImplicitAny errors turn into suggestions. In
particular,

1. reportErrorsFromWidening does not, because it doesn't log an error
that infer-from-usage fixes, and fixing it would require
otherwise-unnecessary code.
2. auto types do not have implicit any suggestions, because that would
require running control flow in noImplicitAny mode.

* Rename reportImplicitAny+forbid it for non-checkJS

In JS, you only get implicit any errors/suggestions with checkJS or
ts-check turned on.

* Update baselines

* Use isCheckJsEnabledForFile

* Remove noImplicitAny parameter since it's in scope already
2018-10-11 16:15:38 -07:00
Nathan Shively-Sanders cdfa63aa40
Fix exported type resolution in commonjs (#24495)
* Fix resolution of exported types in commonjs

It is fine to resolve the types of exported classes in ES6:

```js
export class C {
}
var c = new C()
```

But not for commonjs exported classes:

```js
module.exports.C = class {
}
var c = new C() // should error
```

Fixes #24492

* All jsdoc type aliases are available locally in commonjs modules

* Check that location isSourceFile before commonJsModuleIndicator
2018-05-30 14:12:38 -07:00
Nathan Shively-Sanders 7cda045d52
Always export typedefs (#23723)
* Always export typedefs

This actually just required deleting a check in declareModuleMembers
and checking for external AND commonjs modules in a couple of places.

However, while experimenting with this feature, I discovered that even
previously-exported typedefs would only be exported if they came after a
commonjs export node. So I added a commonjs check to the pass in the
parser. It will not catch nested module.exports, but it will catch
top-level assignments.

The new test tests both changes.

* Post-bind typedef instead of pre-checking for commonjs

* Duplicate identifier errors

* Fix class type reference resolution+update baselines

* Move to a type-based check for duplicate identifiers
2018-04-30 14:55:26 -07:00
Andy fc30bd10e3
Suggestion to convert to ES6 module should only trigger in projects which express some intent to use ES6 (#23576) 2018-04-23 16:05:37 -07:00
Andy 40fd6aebdc
Shrink span for convert-to-es6-module suggestion (#23441) 2018-04-16 16:46:27 -07:00
Andy aac9ef5e51
convertToEs6Module: Avoid replacing entire function (#22507)
* convertToEs6Module: Avoid replacing entire function

* Code review

* Fix typo
2018-04-16 13:16:04 -07:00
Andy 2ac2291b84
Convert use-default-import refactor to a codefix (#22334) 2018-03-05 12:43:01 -08:00
Andy 6385c66215
Simplify diagnostics fourslash tests (#22245) 2018-03-01 07:34:51 -08:00
Andy fa4619c5c1
Add 'info' diagnostics (#22204)
* Add 'info' diagnostics

* Code review
2018-02-28 11:16:32 -08:00
Andy 8bce69e6bd
Add refactoring to convert CommonJS module to ES6 module (#19916)
* Add refactoring to convert CommonJS module to ES6 module

* Code review

* includeGlobals -> excludeGlobals

* Improve handling of `module.exports = require("...")`

* Allow NoSubstitutionTemplateLiteral as argument to createLiteral
2018-01-09 13:15:47 -08:00