Commit graph

25662 commits

Author SHA1 Message Date
Kagami Sascha Rosylight
7995f9153a apply suggested changes 2018-11-09 11:26:58 +09:00
Kagami Sascha Rosylight
8ed21a8a6a adjust test: always indented inside a list 2018-11-05 21:45:19 +09:00
Kagami Sascha Rosylight
7fa447b56f strict types 2018-11-05 21:45:19 +09:00
Kagami Sascha Rosylight
7bc40cead8 indent size 8 based on list startline indentation 2018-11-05 21:45:19 +09:00
Kagami Sascha Rosylight
c6174f6914 resolve TODO 2018-11-05 21:45:19 +09:00
Kagami Sascha Rosylight
90d5413ccb tests 2018-11-05 21:45:19 +09:00
Kagami Sascha Rosylight
ac517336c4 indent using list start position 2018-11-05 21:45:18 +09:00
Kagami Sascha Rosylight
655bf203d0 indent using list start position before first list item 2018-11-05 21:45:18 +09:00
Kagami Sascha Rosylight
cd19a8910d add getListByPosition 2018-11-05 21:45:18 +09:00
Kagami Sascha Rosylight
d7f1935c30 remove deprecated function 2018-11-05 21:45:18 +09:00
Kagami Sascha Rosylight
7561ec0f39 use last line indentation on formatter
... and add explicit delta suppressor for list end tokens
2018-11-05 21:45:18 +09:00
Wesley Wigham
eba83f4ea7
Add related span for mixin constructor error (#28319)
* Add related span for mixin constructor error

* Remove unneeded casts

* Nicer style
2018-11-02 17:29:05 -07:00
Andy
92a48d8880
Improve error message when scriptInfo is missing in mapTextChangeToCodeEdit (#28258)
* Improve error message when scriptInfo is missing in mapTextChangeToCodeEdit

* Include both fileName and path, and use in more places

* Move logErrorForScriptInfoNotFound to editorServices.ts

* Update API
2018-11-02 16:12:46 -07:00
Nathan Shively-Sanders
ce85ee5115
Move infer-from-usage earlier in codefix list (#28318)
This makes it appear before the ts-ignore codefix, specifically.
2018-11-02 15:39:27 -07:00
Andy
4e59096ea5
Exclude keywords from import completions (#28114)
* Exclude keywords from import completions

* Still allow contextual keywords

* Add excludes tests
2018-11-02 14:33:02 -07:00
Andy
afbf89e3b3
Refactors can return ReadonlyArray<ApplicableRefactorInfo> (#28305)
* Refactors can return ReadonlyArray<ApplicableRefactorInfo>

* Remove unnecessary type assertions
2018-11-02 10:07:21 -07:00
Nathan Shively-Sanders
a682a525b8
module.exports aliases have correct flags (#28303)
* module.exports aliases have correct flags

They are marked both as (1) alias and (2) assignment declaration. This
fixes alias resolution in cases where multiple module.exports
assignments exist, but differ in whether they are aliases or not:

```js
function f() { }
module.exports = f
module.exports = 23
```

Previously, this construct would fail to resolve the alias `f` because
the `export=` symbol would be marked as Alias | Value but not
Assignment. This change just adds Assignment so that the assignment
declaration alias-following rules apply: you should always follow the
alias, regardless of other flags.

Also, isAliasSymbolDeclaration needed to be tightened up. Previously, I
missed the condition that `module.exports =` aliases required an
EntityNameDeclaration on right-hand-side, just like `export default` and
`export =` aliases.

* Address PR comments

1. Rename test to be more accurate.
2. Always mark module.exports assignments with SymbolFlags.Assignment.
2018-11-02 09:08:04 -07:00
Nathan Shively-Sanders
8056e2b12f
infer from usage's unification uses multiple passes (#28244)
* infer from usage's unification uses multiple passes

Previously, the unification step of infer-from-usage codefix would stop
as soon an answer was found. Now it continues if the result is
*incomplete*, with the idea that later passes may provide a better
inference.

Currently, an *incomplete* inference is

1. The type any.
2. The empty object type `{}` or a union or intersection that contains
`{}`.

In the checker, any takes priority over other types since it basically
shuts down type checking. For type inference, however, any is one of the least
useful inferences.

`{}` is not a good inference for a similar reason; as a parameter
inference, it doesn't tell the caller much about what is expected, and
it doesn't allow the function author to use an object as expected. But
currently it's inferred whenever there's an initialisation with the
value `{}`. With this change, subsequent property assignments to the
same parameter will replace the `{}` with a specific anonymous type. For
example:

```js
function C(config) {
  if (config === undefined) config = {};
  this.x = config.x;
  this.y = config.y;
  this.z = config.z;
}
```

* Unify all passes of inference from usage

In the previous commit, I changed inference from usage to continue
inference if a the result was *incomplete*. This commit now runs all 4
inference passes and combines them in a unification step. Currently the
unification step is simple, it:

1. Gathers all inferences in a list.
2. Makes properties of anonymous types optional if there is an empty
object in the inference list.
3. Removes *vacuous* inferences.
4. Combines the type in a union.

An inference is *vacuous* if it:

1. Is any or void, when a non-any, non-void type is also inferred.
2. Is the empty object type, when an object type that is not empty is
also inferred.
3. Is an anonymous type, when a non-nullable, non-any, non-void,
non-anonymous type is also inferred.

I think I might eventually want a concept of priorities, like the
compiler's type parameter inference, but I don't have enough examples to
be sure yet.

Eventually, unification should have an additional step that examines the
whole inference list to see if its contents are collectively
meaningless. A good example is `null | undefined`, which is not useful.

* Remove isNumberOrString

* Unify anonymous types

@andy-ms pointed out that my empty object code was a special case of
merging all anonymous types from an inference and making properties
optional that are not in all the anonymous type. So I did that instead.

* Use getTypeOfSymbolAtLocation instead of Symbol.type!

* Unify parameter call-site inferences too

Because they still have a separate code path, they didn't use the new
unification code.

Also some cleanup from PR comments.

* Add object type unification test

Also remove dead code.

* Only use fallback if no inferences were found

Instead of relying on the unification code to remove the fallback.
2018-11-02 09:07:32 -07:00
Sheetal Nandi
29dc7b2811
Merge pull request #28300 from Microsoft/prettyErrorSummary
Report error summary in pretty mode during normal compilation
2018-11-01 17:29:29 -07:00
Sheetal Nandi
77ef9cedab Report error summary in pretty mode during normal compilation 2018-11-01 16:11:22 -07:00
Andy
eabbaa415f
Fix symbolCanBeReferencedAtTypeLocation for namespace that exports itself (#28295) 2018-11-01 15:10:21 -07:00
Sheetal Nandi
901476fae3
Merge pull request #28271 from Microsoft/containerOnlyProgramFiles
Do not add source files to container only project
2018-11-01 14:54:00 -07:00
Wesley Wigham
deeee77f18
Check destructuring validity the same way element accesses and indexed accesses are checked (#24700)
* Check destructuring validity the same way element accesses and indexed accesses are checked

* Accept updated test baseline

* Use raw apparent type instead of passing in flag to sometimes make one

* Use `checkComputedPropertyName`
2018-11-01 13:46:41 -07:00
Sheetal Nandi
4f6f713e8d
Merge pull request #28287 from ajafff/cleanup-internal
remove some useless internal comments
2018-11-01 10:28:36 -07:00
Klaus Meinhardt
a0767437f6 remove some useless internal comments 2018-11-01 17:48:52 +01:00
Sheetal Nandi
121a350c5d Instead of adding lib files, avoid creating diagnostics producing checker for container projects 2018-10-31 19:55:58 -07:00
Sheetal Nandi
c780186a92
Merge pull request #28266 from Microsoft/fixProjectLoadingFinishEvent
Fix incorrectly passed event name for ProjectLoadingFinish event
2018-10-31 18:13:56 -07:00
Sheetal Nandi
0544b7745d
Merge pull request #28273 from Microsoft/buildSourceMapNavigation
Fix source map decoding to handle case sensitivity and --out option
2018-10-31 18:13:05 -07:00
Sheetal Nandi
72aec56fe8 Use mapDefined and combine event name inputs 2018-10-31 15:57:32 -07:00
Wesley Wigham
a4a1bed88b
Add showConfig tsc flag for debugging configs (#27353)
* Add showConfig tsc flag for debugging configs

* Merge showConfig implementation with init implementation, add basic unit tests

* Fix lint

* Add missing semicolon

* showConfig when theres no config file
2018-10-31 15:57:09 -07:00
Sheetal Nandi
851f739c82 Dont ignore libs since that could result in unexpected error 2018-10-31 15:50:22 -07:00
Sheetal Nandi
9f844c4b08 Test to verify that file with --out and case mismatch works with source map 2018-10-31 15:39:31 -07:00
Sheetal Nandi
efe5dd6b6d Handle case sensitivity correctly in source map decoder 2018-10-31 15:14:08 -07:00
Sheetal Nandi
a373029f54 Public API 2018-10-31 15:11:54 -07:00
Sheetal Nandi
78174657e7 Do not add source files to container only project 2018-10-31 15:03:42 -07:00
Wesley Wigham
3a2f7c0df1
Allow intersections of readonlys to be assignable to a readonly intersection (#28218)
* Allow intersections of readonlys to be assignable to a readonly intersection

* Add real motivating react example to test suite
2018-10-31 14:09:12 -07:00
Sheetal Nandi
677f04b165 Test to verify project loading events with default event handler 2018-10-31 13:37:00 -07:00
Wesley Wigham
0ef844ff2b
Avoid this-instantiation if not necessary for relationship (#28263) 2018-10-31 13:21:35 -07:00
Sheetal Nandi
f7189e17f4 Some reorg in creating sessions for testing 2018-10-31 13:05:12 -07:00
Sheetal Nandi
878b7a21ce Fix incorrect event 2018-10-31 13:05:00 -07:00
Anders Hejlsberg
8e4b90da00
Merge pull request #28234 from Microsoft/genericSpread
Generic spread expressions in object literals
2018-10-31 12:52:16 -07:00
TypeScript Bot
6fd6a04f2e Update user baselines (#28249) 2018-10-31 07:25:43 -07:00
Andy
dce6668070
Change pathCompletions to stringCompletions, move more code there (#28245) 2018-10-30 22:01:31 -07:00
Sheetal Nandi
dcdda87258
Merge pull request #28243 from Microsoft/containerOnlyRef
Report error requiring references to have composite only if the program is not container only
2018-10-30 21:20:52 -07:00
Sheetal Nandi
305303cc0d Fix test case for project reference with composite not true 2018-10-30 18:59:25 -07:00
Sheetal Nandi
4606a4b700
Merge pull request #28209 from Microsoft/ignorePathsStartingWithDotInNodeModules
Ignore any changes to file or folder that are in node_modules and start with "."
2018-10-30 18:06:00 -07:00
Andy
903e68164e
Redo resolution on ATA when previous resolution was to '.js' file (#28236)
* Redo resolution on ATA when previous resolution was to '.js' file

* Use a separate test case
2018-10-30 16:39:40 -07:00
Andy
3458360322
Prefer getValidSourceFile over Debug.assertDefined(program.getSourceFile(*)) (#28242) 2018-10-30 16:38:52 -07:00
Anders Hejlsberg
1577f9429d Accept new baselines 2018-10-30 16:33:26 -07:00
Anders Hejlsberg
2ed627aaf1 Update tests 2018-10-30 16:33:14 -07:00