Commit Graph

7535 Commits

Author SHA1 Message Date
Jack Williams
0d79831ead Add typeof-for-switch
Initial draft that works for union types

First draft of PR ready code with tests

Revert changed line for testing

Add exhaustiveness checking and move narrowByTypeOfWitnesses

Try caching mechanism

Comment out exhaustiveness checking to find perf regression

Re-enable exhaustiveness checking for typeof switches

Check if changes to narrowByTypeOfWitnesses fix perf alone.

Improve switch narrowing:

+ Take into account repeated clauses in the switch.
+ Handle unions of constrained type parameters.

Add more tests

Comments

Revert back to if-like behaviour

Remove redundant checks and simplify exhaustiveness checks

Change comment for narrowBySwitchOnTypeOf

Reduce implied type with getAssignmentReducedType

Remove any annotations
2018-04-18 23:17:36 +01:00
Mohamed Hegazy
52192006cf Merge pull request #20671 from Kingwl/fix-import-not-existed-module
error if import empty object form module not existed
2018-04-17 17:29:07 -07:00
Nathan Shively-Sanders
e26745f129 Add axios' source to user tests (#23490)
* Add axios' source to user tests

We already have the npm-installed version in order to test their d.ts so
that we don't break their users.

* Just compile lib, plus fix some config lint
2018-04-17 15:20:48 -07:00
Andy
f5101e21c3 Find-all-references: Don't crash on 'typeof import' (#23448)
* Find-all-references: Don't crash on 'typeof import'

* Move `| ImportTypeNode` out of `AnyImportOrReExport`
2018-04-17 15:01:36 -07:00
Andy
d1fde3786c Symbol kind for a method on a mapped type should still be 'method' (#23478) 2018-04-17 14:07:59 -07:00
Wesley Wigham
c645f1753f Update configurePrerelease to not utilize ts internals (#23476)
* update configure nightly to not utilize ts internals

* Nightly -> Prerelease

* Remove alias
2018-04-17 15:42:31 -04:00
Andy
b00e370605 Add '?' in quick info for optional properties/methods (#23480) 2018-04-17 12:42:23 -07:00
Benjamin Lichtman
48f98bdd4d Merge pull request #23452 from uniqueiniquity/normalizeDocumentHighlightsPaths
Normalize document highlights paths
2018-04-17 12:31:00 -07:00
Nathan Shively-Sanders
db68075b67 Add create-react-app and puppeteer user tests (#23471)
* Add create-react-app

* Add puppeteer

Everything is broken now. I am going back to master to see if that fixes
things.

* Add puppeteer baseline

* Add chalk override (gitignore was ignoring it)
2018-04-17 11:21:11 -07:00
Andy
e50b24a83b convertFunctionToEs6Class: Copy comment from variable declaration (#23445) 2018-04-17 09:15:05 -07:00
Andy
55f9a6ffc2 Fix bug: VariableDeclaration initiazer may be undefined (#23439) 2018-04-17 08:59:07 -07:00
Andy
bc285aa9a1 findAllReferences: Mark *every* search symbol as seen, not just search.symbol (#23451) 2018-04-17 07:53:43 -07:00
Andy
40fd6aebdc Shrink span for convert-to-es6-module suggestion (#23441) 2018-04-16 16:46:27 -07:00
Benjamin Lichtman
221ac50c4c Merge pull request #23437 from Microsoft/getOutliningSpansDepthElseIf
In outliningElementsCollector, treat 'else if' as having same depth as the 'if'
2018-04-16 16:25:57 -07:00
uniqueiniquity
e9d6f788ca Add test 2018-04-16 15:59:22 -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 Hanson
a60caba467 In outliningElementsCollector, treat 'else if' as having same depth as the 'if' 2018-04-16 11:33:30 -07:00
Nathan Shively-Sanders
941777848f Switch webpack to submodule (#23372)
* Prepare for adding webpack submodule

* Actually switch webpack to submodule

I'm sure this will work with no problems!

* Add ignore=all to webpack gitmodule entry

The other submodules do this, although I'm not sure why.

* Add newline at end of .gitmodules
2018-04-12 14:09:07 -07:00
Andy
d2dc2e6d48 Don't copy trivia when implementing an interface (#23343)
* Don't copy trivia when implementing an interface

* Use an `includeTrivia` flag instead of a separate function
2018-04-12 11:47:42 -07:00
Nathan Shively-Sanders
5d23cb49d0 Exclude generated files from user tests (#23371)
* Exclude generated files from user tests

The top 3 offenders, at least: bcryptjs, bluebird and lodash.

* Clean url-search-params too

Only need to build the commonjs original, not the browserified ones.
2018-04-12 10:25:53 -07:00
Andy
d36f83a98d Remove TODO: GH#18795 comments (#23337) 2018-04-11 16:23:04 -07:00
Andy
b0552b089d Don't include "/index" in import from @types even with classic resolution (#23347) 2018-04-11 16:22:10 -07:00
Nathan Shively-Sanders
79ad7df7e1 Improve user test tsconfig (#23325)
* Improve user test tsconfigs

Also incorporate updates from the packages themselves (they fixed
some of the bugs the compiler noticed).

* Fix enhanced-resolve module resolution

* Update baselines after merge w/master
2018-04-11 15:59:19 -07:00
Andy
f6b206a75a When testing references, also test documentHighlights respects filesToSearch (#23306)
* When testing references, also test documentHighlights respects filesToSearch

* Fix handling for redirects and move assertion inside getDocumentHighlights

* Add another assert
2018-04-11 14:07:22 -07:00
Nathan Shively-Sanders
9ceb113ec5 Allow exports assignments (#23319)
1. Allow assignment to `exports`.
2. The type of the rhs is not checked against the type of `exports`
since they are aliased declarations.

To support more complex patterns like `exports = c.name = c`, we may
have to treat `c.name` as a declaration. That will be more complicated
than this PR.
2018-04-11 06:49:58 -07:00
Wesley Wigham
8a2b4646f0 Include guards on comment kind in pragma extraction (#23313) 2018-04-10 20:50:31 -07:00
Wesley Wigham
b2e0c4bea6 Add support for destructuring well-known and late-bound names (#23297)
* Add support for destructuring well-known and late-bound names

* Add test of not present late bound prop
2018-04-10 18:21:24 -07:00
Wesley Wigham
1243d1a9ba handle any'd method signature types (ie, from special property declarations) (#23316) 2018-04-10 18:17:57 -07:00
Nathan Shively-Sanders
22919d57fe JSDoc:positional matching of destructured params (#23307)
* JSDoc:positional matching of destructured params

1. When looking up tags for a parameter whose name is a binding pattern, use
the index of the parameter to get the type.
2. When reporting errors for `@param` tags with no matching parameter
name, do not report the error for tags whose index in the `@param` tag list
matches the index of a parameter whose name is a binding pattern.

* Change to an assert

* Improve comment text
2018-04-10 12:48:35 -07:00
Wenlu Wang
9c0671d661 add refactor of convert private field to getter and setter (#22143)
* add refactor of convert private field to getter and setter

* fix refactor

* stash

* refactor accessor generate

* revert merge union type

* refeactor and accept baseline

* add support of PropertyAssignment and StringLiteral

* add support for js file

* allow static modifier in js file
2018-04-10 11:51:41 -07:00
Andy
ce5d22fef0 Fix bug: don't insert a semicolon when inserting a FunctionDeclaration (#23240) 2018-04-09 15:03:24 -07:00
Wesley Wigham
83ab341531 Allow variable statements used as declaration sites to be marked visible (#22798)
* Allow variable statements used as declaration sites to be marked visible and included in declaration emit by alias marking

* Dont forget to transform statements

* Accept baselines

* Accept updated baselines for new test

* Emit scope fix markers

* Add partial private variable declaration emit test
2018-04-09 14:30:40 -07:00
Andy
98a5e5cc0d Prioritize spelling fix over add-missing-member fix (#23268) 2018-04-09 13:23:11 -07:00
Andy
998beadba2 Support goto-definition for index signatures (#23220)
* Support goto-definition for index signatures

* Use checker.getIndexInfoOfType

* Handle undefined info.declaration
2018-04-09 12:48:41 -07:00
Andy
9762598775 findAllReferences: forEachRelatedSymbol can always include shorthand destructuring (#23223)
* findAllReferences: forEachRelatedSymbol can always include shorthand destructuring

* Update rename tests
2018-04-06 16:30:55 -07:00
Nathan Shively-Sanders
c4788f9198 Update user tests with improved lib settings (#23238) 2018-04-06 16:16:34 -07:00
Nathan Shively-Sanders
a7a01eadba Allow both module.exports= and module.exports property assignments (#23228)
* Combining symbol and removing error done but messy

* Small fix + add new test baselines

All other tests are unchanged

* Union conflicting assignment types+better names

* Add tests and update baselines

* Check commonjs export= from resolveExternalModuleSymbol
2018-04-06 13:04:39 -07:00
Andy
70682b7799 Clean up code for nonrelative path completions (#23150)
* Clean up code for nonrelative path completions

* Remove unnecessary test and simplify based on that

* More code review

* Call getCompletionEntriesFromTypings unconditionally
2018-04-06 12:19:08 -07:00
Andy
05cd784230 Remove unnecessary test file (#23214) 2018-04-06 10:45:01 -07:00
Andy
2b59c9a0d7 Don't add import completion for re-export with different name (#23211) 2018-04-06 10:05:38 -07:00
Mohamed Hegazy
da312398f5 Merge pull request #23050 from gagoman/fix/22923
Fix issue #22923
2018-04-06 09:31:43 -07:00
Andy
aa8631de98 findAllReferences: Share code between populateSearchSymbolSet and getRelatedSymbol (#23028) 2018-04-05 15:00:14 -07:00
Alex Khomchenko
134b3411ee Fix issue #22923 2018-04-05 21:39:33 +02:00
Andy
24842b4002 When --noUnusedLocals/--noUnusedParameters is disabled, add suggestions instead of errors (#22361)
* When --noUnusedLocals/--noUnusedParameters is disabled, add suggestions instead of errors

* Improve performance: do not add unused suggestion diagnostics unless asking for a suggestion

* Add "unused" flag to diagnostics

* Code review

* reportsUnused -> reportsUnnecessary

* Fix test
2018-04-05 12:33:00 -07:00
Andy
f61f12613c findAllReferences: Be consistent how we handle unions in root symobls (#23002) 2018-04-05 10:55:55 -07:00
Nathan Shively-Sanders
9dd8e296f3 Fix crash in type resolution in JS IIFEs (#23171)
* Fix crash in type resolution in JS IIFEs

We recognise IIFEs as JS special assignment initialisers, but not as
containers otherwise. That means that IIFEs will not have a symbol
unless they have an *outside* assignment.

The permanent fix will be to make IIFEs a container, based on the
containership of the value that they return. This fix does not do that;
it just makes type resolution return undefined instead of crashing.

* Comment the IIFE-fix line
2018-04-05 09:57:35 -07:00
Nathan Shively-Sanders
154ac342cb Allow extending any, with noImplicitAny errors (#23153)
Allow extending any, without noImplicitAny errors
2018-04-05 08:52:56 -07:00
Andy
7520f9578b Fix bug: <div a="1" b/**/ > is not a jsx initializer (#23138) 2018-04-05 08:30:02 -07:00
Wesley Wigham
de669cf827 Only include unique symbols when getting index types for access checks (#23145)
* Only include unique symbols when getting index types for access checks

* Filter all nonstrings

* Inline ternary
2018-04-04 18:03:21 -07:00
Nathan Shively-Sanders
dca3a94f88 Print js-constructor function type names (#23089)
* Print js-constructor function type names

Instead of printing them as a type literal, which is scary.

* Use assigned name for functions and classes

That otherwise have no name. This helps quick info for javascript a
*lot*. Typescript mainly benefits when printing the type of class
expressions.

* Improve names of functions in binding elements

Also fix some fourslash baselines
2018-04-04 15:43:41 -07:00