9001 Commits

Author SHA1 Message Date
Anders Hejlsberg
294580287d Merge branch 'master' into saferIndexedAccessTypes 2019-04-05 16:23:48 -10:00
Wesley Wigham
0ddd847e03
Small addition to user PR script to support fork/branch PRs 2019-04-05 16:28:25 -07:00
Nathan Shively-Sanders
9e2446073d
Merge pull request #30773 from Microsoft/update-user-tests
Update TypeScript-React-Native-Starter
2019-04-05 11:18:27 -07:00
Nathan Shively-Sanders
0b3b4ea127
Added error for class properties used within their own declaration (#29395)
* Added error for class properties used within their own declaration

Fixes #5987.

Usages of a class property in a preceding property already gave an error, but the following doesn't yet:

```ts
class Test {
    x: number = this.x;
}
```

As with other use-before-declare checking, IIFEs are not treated as invalid uses.

* Accepted 'witness' baselines; removed unnecessary !==

* Addressed quick feedback items

* Accepted odd new baseline

* Fixed post-merge introduced lint errors

* Updated baselines again
2019-04-05 09:06:36 -07:00
Anders Hejlsberg
739acee1c9 Add tests 2019-04-04 16:30:26 -07:00
Wesley Wigham
16450a027a
Change the default type parameter constraints and defaults to unknown from {} (#30637)
* Change the default type parameter constraint and default to unknown from {}

* Relax unknown checking outside of strictNullChecks a bit

* Increase strictness on index signatures with type `unknown` so inference doesnt change surprisingly

* Remove redundant switch
2019-04-04 12:25:15 -07:00
Nathan Shively-Sanders
762a557fcc Update TypeScript-React-Native-Starter
Add a 'path' field to test.json.
2019-04-04 11:37:15 -07:00
Josh Goldberg
e767ee0472 Merge branch 'master' into property-use-before-declare 2019-04-04 14:05:19 -04:00
Daniel Rosenwasser
1dae8fcc30 Fix tests to be non-global. 2019-04-04 10:02:46 -07:00
Ron Buckton
8a19e4bcf9
Merge pull request #30726 from Microsoft/fix30653
Treat hoisted temp variables as a custom prologue.
2019-04-03 11:54:37 -07:00
Andrew Branch
fed46ea3bf
Merge pull request #30719 from andrewbranch/bug/30668
Fix crash when binding deep module.exports assignment
2019-04-03 09:19:36 -07:00
Josh Goldberg
ee4e90c1fb Merge branch 'master' into property-use-before-declare 2019-04-03 08:35:22 -04:00
Ron Buckton
f04a40dd49 Treat hoisted temp variables as a custom prologue 2019-04-02 17:35:26 -07:00
Andrew Branch
3f3444be80
Merge pull request #30699 from andrewbranch/bug/30635
Fix ternaries where "true" is a parenthesized variable and "false" is a function expression
2019-04-02 14:03:11 -07:00
Andrew Branch
85135c38c1
Add baselines for new test 2019-04-02 14:02:29 -07:00
Andrew Branch
c07f219cca
Add failing test 2019-04-02 14:02:23 -07:00
Andrew Branch
46ae059200
Merge pull request #30695 from andrewbranch/bug/30638
Add type error when destructuring zero elements from void
2019-04-02 13:23:31 -07:00
Nathan Shively-Sanders
bf0dd79e4a Update user test submodules (#30705) 2019-04-02 12:49:39 -07:00
Andrew Branch
f383c3c42d
Add test for parenthesized variable and function keyword within ternary 2019-04-01 14:11:30 -07:00
Andrew Branch
9a3149b967
Add failing tests for destructuring void 2019-04-01 13:33:41 -07:00
Sheetal Nandi
025d826339
Merge pull request #30513 from Microsoft/incrementalFromCommandLine
Allow --incremental from command line
2019-03-29 15:06:48 -07:00
Sheetal Nandi
17ceddaa1a
Merge pull request #29493 from Kingwl/avoid-quickfix-for-declaration-file
avoid add missing member in declaration file
2019-03-29 11:58:08 -07:00
Gabriela Araujo Britto
bb5eb025a8
Handle imports and exports in 'convert parameters to destructured object' (#30475)
* add test for imported function

* start to implement import references check

* fix imported function test

* skip alias when looking for symbol target

* recognize ES6 imports

* recognize some export syntax

* add tests for imports/exports

* add test for imported function

* start to implement import references check

* fix imported function test

* skip alias when looking for symbol target

* recognize ES6 imports

* recognize some export syntax

* add tests for imports/exports

* add test for imported function

* start to implement import references check

* fix imported function test

* recognize ES6 imports

* recognize some export syntax

* add mode import/export syntax cases

* fix entryToFunctionCall to deal with new calls through property/element access expressions

* add more tests for imports/exports

* allow function and class declarations that have no name but have a default modifier

* rename tests

* fix conflict

* fix tests

* add test for nameless class

* rename function

* minor refactor

* remove old tests

* delete old test

* refactor as suggested

* use getContainingFunctionDeclaration
2019-03-28 13:34:29 -07:00
Anders Hejlsberg
c03b7f525c
Merge pull request #30568 from Microsoft/instantiateContextualTypes
Contextual typing based on instantiated types
2019-03-28 12:38:01 -07:00
Daniel Rosenwasser
6a244b9058 Added test. 2019-03-27 23:29:22 -07:00
Wesley Wigham
b7881a26a0 Unify substitution type any handling into costruction and instantiation (#30592)
* Unify substitution type `any` handling into costruction and instantiation

* Strengthen supertype reduction check to reduce breakage

* Rename conditional type fields per convention

* Explicitly handle anyish signatures in compareSignaturesRelated so strict variance doesnt kill subtyping

* Allow tuple expansions to an `any` rest to be considered an `any` signature as well
2019-03-27 12:55:17 -07:00
王文璐
9050d0fdf8 update external files api 2019-03-27 19:06:21 +08:00
王文璐
6bc5ef3474 Merge branch 'master' into avoid-quickfix-for-declaration-file 2019-03-27 18:36:56 +08:00
Sheetal Nandi
6deb9cdfc7 Add test for incremental with --tsbuildinfo file without specifying --out or config 2019-03-26 16:03:06 -07:00
Sheetal Nandi
a4091ae8e3 Merge branch 'master' into incrementalFromCommandLine 2019-03-26 14:57:18 -07:00
Sheetal Nandi
35470b3f3b Make tsbuildInfoFile as commandline option to tsc (and not tsc -b) 2019-03-25 14:47:36 -07:00
Nathan Shively-Sanders
32054f1c31
Forbid accessing block-scoped variables on globalThis (#30510)
* Forbid accessing const & let on globalThis

It's just an error; you still get the type of the property.

* Disallow access of blockscoped vars on globalThis

Also change Array, Function, String, et al from `const` to `var` so that
they remain accessible via `globalThis.String`.

* Update baselines after lib.d.ts change

Note especially the change in redefineArray, which is now allowed as
long as you provide a type that is assignable to ArrayConstructor.

* Remove blockscoped vars from typeof globalThis

Unlike forbidding them, this removes the properties entirely.

Unfortunately, this means that accessing these properties is only an
error with noImplicitAny, and that error is quite confusing.

Let's discuss our options. I see 3:

1. Forbid access of block-scoped vars as properties (in all flag
settings), but leave them on the type. Simple to implement.
2. Remove block-scoped vars from the globalThis type. Has the bad
error/flag behaviour described above, but simple to implement.
3. Remove block-scoped vars from the globalThis type. Also, forbid
accessing them by executing another resolveName lookup for failed
property accesses on globalThisSymbol. If the second lookup returns a
blockscoped var, issue an error instead of falling back to the index
signature. This seems too complex to me.

* Update baselines

* Better error for block-scoped usage on globalThis

So that value-space references have as clear an error as type-space
references.

* Update fourslash tests

* Fix semi-colon lint

* Don't copy so much when filtering blockscoped vars
2019-03-25 14:07:48 -07:00
Anders Hejlsberg
887b30682b Add tests 2019-03-24 11:34:14 -07:00
Gabriela Araujo Britto
0f6f3b79b5
Fix find all references of inherited constructor (#30514)
* recursively look for inherited constructor references

* add test

* remove outdated comment

* add tests

* move function

* improve tests

* minor refactor

* fix convert params refactoring to deal with inherited constructor calls

* simplify refactor test
2019-03-22 15:17:50 -07:00
Wesley Wigham
b86dea03f2
Fix crash caused by cyclic defaults (#30532) 2019-03-21 18:27:14 -07:00
Sheetal Nandi
34c3233d18 Allow --incremental to be command line option 2019-03-20 14:48:47 -07:00
Ron Buckton
2932421370
Merge pull request #30495 from Microsoft/fix29427
Adjust offset to account for 'this' parameter when emitting parameter decorators
2019-03-20 12:56:50 -07:00
Sheetal Nandi
800f7a3447
Merge pull request #30414 from Microsoft/jsSyntaxCompletions
Filter ts only keywords from js file completion
2019-03-20 10:38:11 -07:00
Ron Buckton
cfb0adeadf
Merge pull request #28609 from ajafff/class-decorator-generics
resolve TypeReference in class decorator at parent of class
2019-03-19 15:46:58 -07:00
Ron Buckton
07bec2893f Adjust offset to account for 'this' parameter when emitting parameter decorators 2019-03-19 11:46:18 -07:00
Ron Buckton
e19c7f1a45 Prevent substitution of 'super' in async super helper 2019-03-19 11:35:18 -07:00
Ron Buckton
4e54f30fb4 Fix _superIndex emit when super access captured in async arrow 2019-03-19 10:20:08 -07:00
Gabriela Araujo Britto
84087d0e0a
Use shorthand property assignment in convert parameters to object (#30468)
* create shorthand property assignment in argument object when possible

* add shorthand property assignment test

* don't offer refactor on jsdoc comment

* add jsdoc test

* improve jsdoc test

* use crlf
2019-03-19 09:28:09 -07:00
Gabriela Britto
10b9051624
Fix convert to named parameters rest parameter tuple (#30286)
* check if rest parameter is of tuple type in isOptionalParameter

* expose isArrayType and isTupleType in checker

* don't offer refactor if rest parameter type is neither array nor tuple type

* add tests for rest parameters

* fix tests for renamed refactor

* remove unnecessary conditional operator
2019-03-18 10:31:38 -07:00
Masahiro Wakame
18b8625ef8 fix error on globalThis type extend (#30460)
* Add test for extend globalThis

* Fix compile aborting
2019-03-18 09:18:27 -07:00
Anders Hejlsberg
d0646a629a
Merge pull request #30084 from dragomirtitian/GH-26563
Improved argument description for parameters originating from tuples
2019-03-18 06:14:52 -10:00
Anders Hejlsberg
36cf12fe0a
Merge pull request #30363 from Microsoft/fixTypeParameterPromotion
Higher order type parameter promotion fixes
2019-03-18 08:48:03 -07:00
Anders Hejlsberg
b6aff98fd7 Add test relating type predicates with and without this parameters 2019-03-17 17:39:08 -10:00
Nathan Shively-Sanders
658798032b
Fix globalThis completions (#30441)
* Fix, but with test not quite right

* Add missing completions to test

* Remove out-of-date comment
2019-03-15 19:10:39 -07:00
Nathan Shively-Sanders
0f598db3e5
Fixes #29524, a merged UMD-global (#30403)
This kind of merged symbol causes crashes in two places because it's
marked BlockScoped, which makes us assume that it must be something that
is inside a SourceFile. However, block-scoped checks don't make sense
for this kind of symbol, so I exclude them by looking at the kind of
the valueDeclaration, as @mprobst suggested in the original bug.
2019-03-15 09:45:33 -07:00