Commit Graph
26450 Commits
Author SHA1 Message Date
Sheetal NandiandGitHub 243186685b Increase the idle time before which ensureProject for open file is called (#37121)
* Increase timeout for ensuring projects for open files

* Condense the project/file printing in the log (given now we have project printed anytime its structure changes)
2020-03-11 16:47:11 -07:00
csigs f68a0b2626 LEGO: check in for master to temporary branch. 2020-03-11 22:10:31 +00:00
Sheetal NandiandGitHub 1a9c8197ff Optimize module resolution cache for watch and editor (#37055)
* Refactor resolveName

* Have resolutions of failed lookups as array and resolved to fileName map
2020-03-11 14:35:26 -07:00
Anders HejlsbergandGitHub 6856c012d2 Use objects instead of closures for type mappers (#36576)
* Use objects instead of closures for type mappers

* Flatten combined type mappers

* Single point of creation for type mappers

* More optimizations

* Fix lint error

* Fewer symbol instantiations / discard type mapper after instantiation

* More optimizations

* Simplify mapper layout and cache in composite mappers

* Removing cache as it doesn't seem to matter much

* Get rid of identityMapper
2020-03-11 13:28:49 -07:00
ae3d28b5eb Implement constructor type guard (#32774)
* Implement constructor type guard

* Fix code review issues for constructor type guard.
- Do not limit constructor expression to only identifiers
- Fix `assumeTrue` and operator no-narrow check
- Use better way to check that identifier type is a function
- Loosen restriction on what expr is left of ".constructor"
- Update typeGuardConstructorClassAndNumber test to include else cases

* Fix grammar & spacing in `narrowTypeByConstructor`

* fix bad merge

* switch (back?) to crlf

* update baselines

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2020-03-11 13:16:33 -07:00
Anders HejlsbergandGitHub b78ef30cb7 No union subtype reduction during type inference (#37327)
* No union type subtype reduction in getImplicitIndexTypeOfType

* Add regression test
2020-03-11 10:27:51 -07:00
csigs ffa35e14b7 LEGO: check in for master to temporary branch. 2020-03-11 16:10:34 +00:00
Arpad BorsosandGitHub 5937ffdf25 Add constructor functions for {Symbol,Node}Links (#36845)
Using a constructor function like this can help node better optimize
object allocation. This improves memory usage when compiling
`src/compiler` from **277M** to **270M**, a nice ~3% win.
2020-03-11 08:40:51 -07:00
20625a964b add promise.any (#33844)
* add promise.prototype.any

* add AggregateError

* Update src/lib/esnext.promise.d.ts

Co-Authored-By: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>

* update baseline again

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2020-03-11 08:36:00 -07:00
csigs dd09e65673 LEGO: check in for master to temporary branch. 2020-03-11 04:10:30 +00:00
csigs 94ff6fd15c LEGO: check in for master to temporary branch. 2020-03-10 22:10:33 +00:00
Jack WilliamsandGitHub 67ca82b375 Add flag to omit default case (#33574) 2020-03-10 15:04:03 -07:00
Iku IwasaandGitHub 5e0f584b67 Support NetBSD platform (#34756) 2020-03-10 14:53:37 -07:00
csigs 8507a23b91 LEGO: check in for master to temporary branch. 2020-03-10 16:10:29 +00:00
Anders HejlsbergandGitHub c4da90368f Infer to erased signatures (#37261)
* Use erased signatures as inference targets

* Add tests
2020-03-10 08:42:36 -07:00
csigs fe8decb316 LEGO: check in for master to temporary branch. 2020-03-10 10:10:28 +00:00
Sheetal NandiandGitHub e68524a8d2 Handle WatchCompilerHost without timeout methods to retrieve correct Program (#37308) 2020-03-09 16:30:52 -07:00
Josh GoldbergandGitHub bf15eac16e Removed unused host variable in createProgramHost (#37278)
As stated in 26417, `host` is only ever written to and never read from. `createProgramHost` is the only place I could find that provides a member for `ProgramHost`'s `onCachedDirectoryStructureHostCreate`, so that's removed as well.
2020-03-09 13:53:49 -07:00
Andrew BranchandGitHub bc0e5a241c Fix longer type-only property access in non-emitting heritage clauses (#37264)
* Fix longer type-only property access in non-emitting heritage clauses

* Rename misnomer function
2020-03-09 12:05:36 -07:00
Josh Goldberg 94f3ca142f Added runtime TypeError for non-function, non-null __extends
As per the linked issue, although TypeScript already has checking in place that tries to prevent users from extending classes before their declaration, it's still possible to accidentally work around the checker. This adds a block to `__extends` that throws a `TypeError` if the base class `b` isn't a function.

My _hope_ is that this will not have a negative performance impact on community performance-critical applications, as they would likely already prefer newer browser/Node versions and output ES2015+ code. If there is something you can think of that I should do to verify that hope, I'd love to know!

For reference, runtime errors in Node 12.0.0 (Chrome exhibits the same messages):

```js
class X extends null { }
// undefined

class Y extends undefined { }
// TypeError: Class extends value undefined is not a constructor or null

class Z extends 0 { }
// TypeError: Class extends value 0 is not a constructor or null
```

`Class extends value {0} is not a constructor or null` matches the Node.js behavior:
* [Message template](https://github.com/nodejs/node/blob/2bdeb88c27b4d8de3a8f6b7a438cf0bcb88fa927/deps/v8/src/common/message-template.h) for `ExtendsValueNotConstructor`
* [Error thrown with that message](https://github.com/nodejs/node/blob/6ca81ad72a3c6fdf16c683335be748f22aaa9a0d/deps/v8/src/runtime/runtime-classes.cc#L617) when `!super_class->IsConstructor()`

Runtime errors in Firefox 72.0.1:

```js
class X extends null { }
// undefined

class Y extends undefined { }
// TypeError: class heritage undefined is not an object or null

class Z extends 0 { }
// TypeError: class heritage 0 is not an object or null
```
2020-03-08 16:25:23 -04:00
Alexander TandGitHub 8d63a7a842 fix(28163): change outdated options (#37268) 2020-03-07 10:23:07 -08:00
Sheetal NandiandGitHub 8dede43365 Reset hasChangedAutomaticTypeDirectiveNames once new program is created (#37266)
* Allow passing watch to the change as parameter

* Reset hasChangedAutomaticTypeDirectiveNames once new program is created
Also dont invoke afterProgramCreate if the program is not new
2020-03-06 18:21:16 -08:00
Jonathan ShareandGitHub c0c5760d15 Fixes duplicated comment when executing code fix to add missing enum member (#28163)
Resolves issue #28031 by overriding default value of
`useNonAdjustedStartPosition` option to replaceNode. Test case included
that confirms intended behaviour.
2020-03-06 16:53:37 -08:00
Ben LichtmanandGitHub 631def81d5 Merge pull request #37260 from uniqueiniquity/watchFileExistsFix
Fix fileExists check for a watch program
2020-03-06 13:01:03 -08:00
Ben Lichtman a4430f7baf Update tests to be more precise 2020-03-06 12:41:00 -08:00
Ben Lichtman 0ed21e34ed Fix file exists check for watch program 2020-03-06 09:44:16 -08:00
csigs ec83e9f6f9 LEGO: check in for master to temporary branch. 2020-03-06 04:10:31 +00:00
csigs 755e99fe21 LEGO: check in for master to temporary branch. 2020-03-05 22:10:33 +00:00
Nathan Shively-SandersandGitHub 458977b94b Reinstate incorrectly removed esnext.bigint (#37233)
* Reinstate incorrectly removed esnext.bigint

From a bad merge I made in #33845

* fix esnext.bigint alias
2020-03-05 10:11:48 -08:00
csigs 6a79c585ce LEGO: check in for master to temporary branch. 2020-03-05 16:10:29 +00:00
ffde92349d Added @ts-expect-error to @ts-ignore directives (#36014)
* Added @ts-expect-error to @ts-ignore directives

Similar to `// @ts-ignore`, but will itself cause a new error diagnostic if it does not cause an existing diagnostic to be ignored.

Technical summary:
1. The scanner will now keep track of `CommentDirective`s it comes across: both `@ts-expect-error` and `@ts-ignore`
2. During type checking, the program will turn those directives into a map keying them by line number
3. For each diagnostic, if it's preceded by a directive, that directive is marked as "used"
4. All `@ts-expect-error` directives not marked as used generate a new diagnostic error

* Renamed to getDiagnosticsWithPrecedingDirectives per suggestion

* Added JSDoc comment I thought I did already

Co-authored-by: Orta <orta.therox+github@gmail.com>
2020-03-05 10:37:36 -05:00
csigs 5b06ce6068 LEGO: check in for master to temporary branch. 2020-03-05 10:10:40 +00:00
csigs 89410e9cb2 LEGO: check in for master to temporary branch. 2020-03-04 22:10:31 +00:00
Nathan Shively-SandersandGitHub 0a1af90bb6 add string.prototype.replaceAll (#33845)
* add string.prototype.replaceAll

* accept baseline

* fix bad merge in tests

* update missed baselines

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2020-03-04 13:25:17 -08:00
Nathan Shively-SandersandGitHub 061338e82b Don't inferFromIndexTypes() twice (#34501)
* Don't inferFromIndexTypes() twice

* Add tests
2020-03-04 13:19:35 -08:00
Eli Barzilay 5c8def9a06 Fix emitting ?.
Use `emit()` for writing `questionDotToken`, leading to properly calling
the emit hooks (which `emitTokenWithComment` doesn't) and printing the
comments.  This fixes #35372 by calling its hooks to set the `.__pos`
and `.__end` fields.

Also, remove `getDotOrQuestionDotToken` which was used only here --
mainly because it seems likely to encourage misusing the
`questionDotToken` again.

Also, fix a bunch of `visitor` -> `tokenVisiton` calls in
`visitorPublic.ts`.
2020-03-04 14:52:33 -05:00
Ryan CavanaughandGitHub 67930fc163 Don't crash when there's no class type to derive a 'this' type from (#37164)
Fixes #37161
2020-03-04 09:34:28 -08:00
Wesley WighamandGitHub dfc0b58fe7 Preserve arity for preserving js optional parameters (#37173) 2020-03-04 00:48:53 -08:00
csigs b28e1b8374 LEGO: check in for master to temporary branch. 2020-03-04 04:10:28 +00:00
Nathan Shively-SandersandGitHub b481dd4d4b More precise property-overwritten-by-spread errors (#37192)
* More precise property-overwritten-by-spread errors

Trying to do this check in getSpreadType just doesn't have enough
information, so I moved it to checkObjectLiteral, which is a better
place for issuing errors anyway.

Unfortunately, the approach is kind of expensive in that it

1. creates a new map for each property and
2. iterates over all properties of the spread type, even if it's a
union.

I have some ideas to improve (1) that might work out. I'm not sure how
bad (2) is since we're going to iterate over all properties of all
constituents of a union.

Fixes #36779

* another test and rename
2020-03-03 15:10:19 -08:00
Alexander TandGitHub 3046a54401 fix(36883): accessor allows this parameter but is not checke… (#36889) 2020-03-03 12:26:41 -08:00
Alexander TandGitHub 176241cca9 fix(36238): allow aliases in spelling suggestions (#37168) 2020-03-03 10:58:29 -08:00
Wesley WighamandGitHub 5941c6e1b1 Emit an any for namepath types (#37176) 2020-03-03 10:55:21 -08:00
Alexander TandGitHub ab8adc5f95 fix(37135): handle PrivateIdentifiers in isPropertyName (#37184) 2020-03-03 10:51:50 -08:00
Wesley WighamandGitHub b9c0999a2a Thread host.useCaseSensitiveFileNames through program and node builder into specifier generation (#37170) 2020-03-03 10:50:01 -08:00
Ryan CavanaughandGitHub 0c5878dfb1 symbol.parent really is possibly sometimes undefined here. (#37159)
Fixes #37158
2020-03-03 10:47:07 -08:00
67c6cebfc8 Reinterpret a type parameter constrained to any as an upper bound constraint (#29571)
* Reinterpret a type parameter constrained to any as an upper bound constraint

* Use real constraqint in alias in test

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2020-03-03 09:51:15 -08:00
csigs 344b0a8f67 LEGO: check in for master to temporary branch. 2020-03-03 16:10:36 +00:00
Andrew BranchandGitHub 3c468d2617 Clean up convert-to-async refactor (#36858)
* Start renaming some stuff, fix deep cloning identifiers, which apparently fixed some unnoticed bugs

* Wow a lot of stuff seems to be unused
2020-03-03 07:47:18 -08:00
Andrew CaseyandGitHub dd6811fbe3 Stop looking for the default configured project at node_modules (#35011)
* Optionally stop looking for the default configured project at
node_modules

* Make stopping at node_modules non-optional

* Generalize and simplify the change - node_modules files don't have default configured projects
2020-03-02 16:52:03 -08:00