Commit Graph

18894 Commits

Author SHA1 Message Date
Sheetal Nandi
448f385e3c Fix lint errors 2018-11-06 15:49:17 -08:00
Sheetal Nandi
4a51f12c3e Add metadata to response if it exists for results from language service.
Currently its wired through for completions requests.
Handles #21999
2018-11-06 15:06:54 -08:00
Wesley Wigham
d7390c03f0 Avoid elaborating on generic indexes (#28294) 2018-11-06 12:51:11 -08:00
Daniel Rosenwasser
41d3f0ad57 Merge pull request #28071 from pesca/improveCodeFix
Improve code fix for missing members
2018-11-06 11:29:51 -08:00
Wesley Wigham
cc36e294cc Add related span pointing to this-shadowing location for implicitly-any this (#28299)
* Add diagnostic pointing to this-shadowing location

* Fix almost-top-level-this case

* Change message on span
2018-11-06 11:27:07 -08:00
Andy
772f6cdf48 Remove JSDocTag#atToken (#28376) 2018-11-06 09:54:23 -08:00
Wesley Wigham
929791868f Make for..in expressions allowed to be null/undefined (#28348) 2018-11-05 17:23:19 -08:00
Anders Hejlsberg
85dbc0438f Merge pull request #28312 from Microsoft/genericRest
Generic object rest variables and parameters
2018-11-05 16:36:45 -08:00
Andy
c22c7e687d Strcter testing for global completions; and 'excludes' can only be a string (#28349) 2018-11-05 16:16:28 -08:00
Sheetal Nandi
597aacad88 Merge pull request #28346 from Microsoft/transitiveExports
When removing old diagnostics for files referencing modules that export affected file with signature change, delete the diagnostics of the module as well as anything that exports that module
2018-11-05 15:58:22 -08:00
Anders Hejlsberg
f9dd44517a Merge branch 'master' into genericRest
# Conflicts:
#	src/compiler/checker.ts
2018-11-05 15:41:53 -08:00
Sheetal Nandi
576fdf98d7 Merge pull request #25886 from calebsander/feature/bigint
BigInt support
2018-11-05 13:08:48 -08:00
Andy
f37101e871 Fix bug when augmenting parent-less symbol (#28345) 2018-11-05 12:57:33 -08:00
Caleb Sander
bb99c41230 Don't error on bigint literal used in type 2018-11-05 12:23:02 -08:00
Sheetal Nandi
23e7330ddb When removing old diagnostics for files referencing modules that export affected file with signature change, delete the diagnostics of the module as well as anything that exports that module
Fixes #28328
2018-11-05 12:17:41 -08:00
Caleb Sander
6c59a3b890 Fix ambient initializer emit for bigint 2018-11-05 11:36:33 -08:00
Caleb Sander
28e9ec497c Address review comments 2018-11-05 11:36:32 -08:00
Caleb Sander
95c24c6c6a experimentalBigInt compiler flag 2018-11-05 11:36:31 -08:00
Caleb Sander
188c07865a Scan bigint literals 2018-11-05 11:36:31 -08:00
Caleb Sander
ac2a118f07 Add bigint type 2018-11-05 11:36:31 -08:00
Caleb Sander
3e10dedbce Add diagnostic messages for bigints 2018-11-05 11:36:30 -08:00
Caleb Sander
ece27eb177 Utilities for PseudoBigInt 2018-11-05 11:36:30 -08:00
Caleb Sander
0c1bf316a2 Declaration files for BigInt 2018-11-05 11:36:30 -08:00
Nathan Shively-Sanders
4cb210ce2e Parameters infer from body and call sites (#28342)
* Parameters infer from body usage and call sites

* Function expressions infer from variable decl usages

If the function expression is the initialiser of a variable declaration.

* Update isApplicableFunctionForInference too

* Update baseline
2018-11-05 11:29:16 -08: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
Anders Hejlsberg
abebf15af8 Ensure '{ [key]: x } = obj' for generic key is the same as 'x = obj[key]' 2018-11-02 07:53:25 -07:00
Anders Hejlsberg
9fd7d0a5f4 Remove Rest<T, K> and use Pick<T, Exclude<keyof T, K>> instead 2018-11-02 06:40:26 -07:00
Anders Hejlsberg
396642d03e Only create Rest<T, K> types when object and/or key type is generic 2018-11-01 17:49:49 -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
Anders Hejlsberg
0b194a2b34 Define Rest<T, K> as Pick<T, Exclude<keyof T, K>> to ensure it is homomorphic 2018-11-01 16:48:12 -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
Anders Hejlsberg
b0a5337604 Merge branch 'master' into genericRest
# Conflicts:
#	tests/baselines/reference/objectRest.errors.txt
#	tests/baselines/reference/objectRest.types
2018-11-01 14:23:25 -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
Anders Hejlsberg
6f8959b86b Use Rest<T, K> for rest properties in object destructuring 2018-11-01 12:41:39 -07:00
Anders Hejlsberg
f555261d7a Add Rest<T, K> type to lib.d.ts 2018-11-01 12:33:18 -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