32894 Commits

Author SHA1 Message Date
Daniel Rosenwasser
04d77fe900
Update to TypeScript 4.5.5, fix semantic lints. (#47529)
* Update to TypeScript 4.5.5, fix semantic lints.

* Remove extra parens.

* Remove now-outdated non-null comment around #18217.
2022-01-20 11:33:30 -08:00
TypeScript Bot
6c8c829148 Update package-lock.json 2022-01-20 06:07:54 +00:00
Eli Barzilay
c240380519 Add a comment to maybeSetLocalizedDiagnosticMessages
(Should have included it in the previous PR but missed it...)
2022-01-19 22:04:45 -05:00
Eli Barzilay
8d9fa685b5 Avoid global mutations
This removes a few places where global compiler bindings are mutated:

1. Make `sysLog` call an internal binding which is changed via
   `setSysLog`.

2. Use `Object.assign` to change values *in* `objectAllocator` instead
   of mutating the binding itself.  (The type should verify that any
   future uses of this will properly override all bindings.)

3. `localizedDiagnosticMessages` is not really needed as an exported
   value, there's only one place that uses it to test whether it is set
   or not.  So drop the export and replace it with a new
   `maybeSetLocalizedDiagnosticMessages` (internal) function.
2022-01-19 20:01:19 -05:00
mickey-stringer
9e2b7ad0d8
fix(47492): more detailed parseTryStatement error message (#47504)
* more detailed parseTryStatement error message

* move custom error to diagnosticMessages.json

* update error code

Co-authored-by: mickey-stringer <fcstring31@yahoo.com>
2022-01-19 15:32:47 -08:00
Daniel Rosenwasser
ad5ca673e6
Avoid crash for import code fixes with dotted require (#47433)
* Add failing test.

* Update failing test.

* Finalized failing test case.

* Separate our usages of utilities that expect variables initialized to require(...) and require(...).foo.

* Renamed types and utilities, removed accidental indentation.

* Renamed both utilitiy functions uniformly.
2022-01-19 15:05:01 -08:00
Jake Bailey
049d4e049f
Modify debug assertion to avoid crashing on SyntaxList (#47500) 2022-01-19 13:37:55 -08:00
Orta Therox
818962087c
Update dom.generated.d.ts (#47507) 2022-01-19 12:45:43 +00:00
Orta Therox
113a681aee
Do not show the additional file/errors table when there's 1 file with many errors (#47345)
* Use relative paths for the end of compile report

* Have a tighter suffix for multiple errors in one file

* Review feedback

* Refactors, and adds color

* Update baselinies
2022-01-19 11:56:27 +00:00
TypeScript Bot
9f6483929b Update package-lock.json 2022-01-19 06:06:17 +00:00
Oleksandr T
c44fd466a7
fix(47451): Implicit 'any' quick fix text grabs text from wrong file (#47493) 2022-01-18 20:59:26 -08:00
Jake Bailey
97017ee5f3
Delay "File change detected" reporting until createProgram (#47427) 2022-01-18 18:13:18 -08:00
TypeScript Bot
4e689bc075
🤖 Update TypeScript DOM Libs (#47445)
Co-authored-by: orta <orta@users.noreply.github.com>
2022-01-18 17:43:20 -08:00
Robert Snow
08221166d9
Add missing currencyDisplay to resolved number format options (#44006)
* Add missing currencyDisplay to resolved number format options

* Move declaration to es2020

* Update es2020.intl.d.ts

* Fix bad merge

Co-authored-by: Orta Therox <ortam@microsoft.com>
Co-authored-by: Orta Therox <git@orta.io>
Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2022-01-18 13:54:25 -08:00
Jake Bailey
2635102f7b
Deprecate ScriptElementKind.jsxAttribute (#47414) 2022-01-18 13:53:51 -08:00
Andrew Branch
d0b3ac376d
Better reuse of package.json cache, module resolution cache, and package.json auto import filter (#47388)
* Use package.json cache in module specifier generation

* Let AutoImportProviderProject reuse module resolution cache of host project

* Add missing module resolution cache access, add logging to getRootFileNames

* Reuse packageJsonImportFilter

* Only log when the project will be created, update API baseline

* Remove override that could mess up watches
2022-01-18 13:23:13 -08:00
Oleksandr T
8153475ca5
fix(47438): show auto-complete for this inside class static blocks (#47460) 2022-01-18 12:40:00 -08:00
Jake Bailey
e2c00331d6
Bind RHS of comma expressions too (#47049) 2022-01-18 11:46:09 -08:00
Oleksandr T
16e96f62d7
feat(47439): omit optional key from jsx output (#47467) 2022-01-18 11:38:52 -08:00
Pimm "de Chinchilla" Hogeling
cecd8c50a0
Make Map constructor argument optional and nullable (#43396)
* Make Iterable Map constructor argument optional

Fixes #37779

* Change Map constructor in iterable to accept both null and undefined.

According to the spec (https://tc39.es/ecma262/#sec-map-iterable), the sole argument passed to Map is allowed to be null or undefined.

* Changed Map constructor to ensure new Map() still types as Map<any, any>.

* Add map constructor test.

This proves that the previous commit fixes #37779, as well as that new Map() still types as Map<any, any>.

* Update baseline.

Co-authored-by: Jared Neil <jaredneil@lucidchart.com>
2022-01-18 13:39:05 +00:00
TypeScript Bot
7490b329a7 Update package-lock.json 2022-01-18 06:06:28 +00:00
Oleksandr T
febfd442cd
fix(47417): allow undefined type to be added to JSDoc types (#47449) 2022-01-16 13:44:07 -08:00
TypeScript Bot
c71ff4dcdf Update package-lock.json 2022-01-15 06:06:32 +00:00
Andrew Branch
28c2084aca
Deprioritize import paths made up of only dots and slashes (#47432)
* Deprioritize import paths made up of only dots and slashes

* Fix test

* Hoist regex

* Yaaaay RegExp state
2022-01-14 10:33:05 -08:00
Jake Bailey
16bbddbd22
Rewrite logic for JSX attribute completion detection (#47412) 2022-01-14 09:56:57 -08:00
Josh Goldberg
b7fee7f1ee
Allowed non-this, non-super code before super call in derived classes with property initializers (#29374)
* Allowed non-this, non-super code before super call in derived classes

Fixes #8277.

It feels wrong to put a new `forEachChild` loop in the checker, though in the vast majority of user files this will be a very quick one. Is there a better way to check for a reference to `super` or `this`?

* Used new isNewThisScope utility and dummy prop in baselines

* Accounted for parameters and get/set accessor bodies

* Accounted for class extensions

* (node|statement)RefersToSuperOrThis wasn't checking root level scope boundaries

```ts
function () {
    return this;
}
```

It was immediately going to `ts.forEachChild` so the statement itself wasn't being counted as a new `this` scope.

* Better 'references' name and comments; accounted for more method edge case

* Limited super calls to root-level statements in constructor bodies

As per discussion in the issue, it would be ideal to consider any block that always ends up calling to super() the equivalent of a root-level super() statement. This would be valid:

```ts
foo = 1;
constructor() {
    condition() ? super(1) : super(0);
    this.foo;
}
```

...as it would compile to the equivalent of:
```ts
function () {
    condition() ? super(1) : super(0);
    this.foo = 1;
    this.foo;
}

That change would a bit more intense and I'm very timid, so leaving it out of this PR. In the meantime the requirement is that the super() statement must itself be root-level.

* Fixed error number following 'master' merge

* Added decorator test cases

* Again allowed arrow functions

* Accepted new baselines

* Added allowance for (super())

* Reworked emitter transforms for ES this binding semantics

In trying to adjust to rbuckton's PR feedback, this orders derived class constructor bodies into five sections:

1. Pre-`super()` code
2. The `super()` call itself
3. Class properties with initializers
4. Parameter properties
5. The rest of the constructor

I've looked through the updated baselines and it looks like they're generally better than before. Within the existing test cases that result in semantic errors for `this` access before `super`, several previously resulted in a global `_this` being created; now, they correctly defer referring to `_this` until it's assigned to `_super.call(this) || this`.

* Used skipOuterExpressions when diving for super()s; fix prop ordering

* Allow direct var _this = super() when no pre-super() statements; lint fixes

* Always with the TSLint

* One last touchup: skipOuterExpressions in es2015 transformer

* Fixed new lint complaint in utilities.ts

* Again added a falls-through; it'd be swell if I could run linting locally

* This time I think I got it

* Well at least the error is a different one

* Undid irrelevant whitespace changes

* Mostly addressed private/field issues

* Accepted derivedClassSuperProperties baseline

* Lint fix, lovely

* Remove now-unnecesary comment

* First round of feedback

* Moved prologue statements to start of statements

* Added consideration for super statements in loops and the like

* Ordering and a _this_1 test

* Missed the one change I needed...

* First round of feedback corrections

* Feedback round two: statements

* Feedback: used more direct statements

* Fixed classFields emit to not duplicate temp variables

* Refactored es2015 helper to be less overloaded

* Accounted for parentheses

* Simpler feedback: -1, and emptyArray

* Next feedback: superStatementIndex

* Feedback: simplified to no longer create slice arrays

* Adjusted for default and rest parameters

* Added test case for commas

* Corrected comment ranges

* Handled comments after super, with tests

* Fixed Bad/Late super baselines

* Remove unused param and unnecessary baseline comments

Co-authored-by: Orta Therox <orta.therox@gmail.com>
Co-authored-by: Ron Buckton <ron.buckton@microsoft.com>
2022-01-13 20:29:37 -08:00
Jake Bailey
70097c4908
Fix type error in fourslash.ts (#47430) 2022-01-13 16:51:02 -08:00
Andrew Branch
a158b7ed7d
Fix implicit glob detection when ancestor directory contains . (#47418) 2022-01-13 15:33:38 -08:00
Eli Barzilay
ce18254c77 optimize __createBinding
When the binding is itself one that was created by `__createBinding`,
re-use its descriptor, which avoids piling multiple levels of getters in
the case of multiple levels of exports.

In addition, reuse a descriptor if the bindings is marked as
non-writable and non-configurable, which makes a getter not
necessary.  (This can be done manually if needed, even though tsc
doesn't do it now.)

Also related to #46744 and to microsoft/tslib#165.
2022-01-13 15:57:51 -05:00
Oleksandr T
42ea5ec3d8
fix(47415): don't show addConvertToUnknownForNonOverlappingTypes QF in JS (#47424) 2022-01-13 11:17:36 -08:00
Oleksandr T
82377825d7
fix(46406): add Template Literal types to decorator metadata serialization (#46913) 2022-01-12 21:34:00 -08:00
Daniel Rosenwasser
461fb65623
Fix for crash for auto import completions with a rooted rootDirs entry (#47411)
* Add failing test case.

* Guard against undefined relative path.
2022-01-12 13:45:06 -08:00
Daniel Rosenwasser
14f33d5c4b
Fix for crash in navbar with double ambient modules (#47395)
* Add failing test.

* Guard against undefined module bodies in navbar/navtree.
2022-01-11 18:14:22 -08:00
Daniel Rosenwasser
ed014db864
Add names for refactoring functions. (#47375)
* Add names for refactoring functions.

* Consistency in function names.
2022-01-11 12:20:17 -08:00
Martin Probst
faee7b3621
Avoid printing comments on static fields twice. (#47363)
* Avoid printing comments on static fields twice.

In TS4.4, when a transformer adds a static field with a synthetic
comment to a decorated class, TS prints the synthetic comment twice:

  @Decorator
  class MyClass {
    /* comment */ staticField = 'x';  // field and comment added by transformer
  }

Becomes:

  var MyClass = class MyClass {}
  /*comment*/
  /*comment*/
  MyClass.newField = "x";
  __decorate(MyClass, Decorator, ...)

This is because the classFields transformer calls `setOriginalNode(n,
propertyDeclaration)` on both the expression statement , and the
assignment expression contained in it, leading to the synthetic comment
appearing twice.

This change avoids the problem by explicitly deleting any synthetic
comments from the assignment expression created for static fields when
creating the expression statement containing the assignment. This allows
us to retain the information of the original node without printing the
synthetic comment twice.

* Update src/testRunner/unittests/transform.ts

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
2022-01-11 12:19:36 -08:00
Andrew Branch
0f1496f354
Process package.json exports with auto-import provider (#47092)
* Have auto-import provider pull in `exports`

* Revert filtering of node_modules relative paths, to do in separate PR

* Do @types and JS prioritization correctly

* Cache entrypoints on PackageJsonInfo

* Add one more test

* Delete unused function

* Fix other tests - dependencies need package.json files

* Do two passes of exports resolution

* Fix missed refactor

* Apply suggestions from code review

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

* Uncomment rest of test

* Handle array targets

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2022-01-11 11:10:35 -08:00
Orta Therox
935c05cf34
Fix the related repos CI (#47386) 2022-01-11 15:27:51 +00:00
Anders Hejlsberg
4d6dd119d5
Add missing mapped type indexed access constraint (#47370)
* Type { [P in K]: E }[X] has constraint E with X substutited for P

* Add regression test

* Fix PragmaMap and ReadonlyPragmaMap declarations

* Explore additional constraint

* Revert previous change

* Add tests
2022-01-11 07:23:18 -08:00
Andrew Branch
852b1c2b73
Fix checker initialization crash with esModuleInterop and global merges resolving to ImportEquals aliases (#47348)
* Add minimal failing test

* Fix checker initialization crash with esModuleInterop global merges resolving to ImportEquals aliases
2022-01-10 16:04:12 -08:00
TypeScript Bot
337bbcccbe Update package-lock.json 2022-01-10 06:07:07 +00:00
TypeScript Bot
b53073bf66 Update package-lock.json 2022-01-08 06:07:09 +00:00
Kat Marchán
7f189b9701
fix ATA toplevel dep detection (#47164)
ATA tried to use the `_requiredBy` field to determine toplevel deps,
but this is not portable. Not only is it unavailable in npm@>=7, but
neither Yarn nor pnpm write this metadata to node_modules pkgjsons.

This also adds support for ATA acquiring types for scoped packages.

Fixes: https://github.com/microsoft/TypeScript/issues/44130
2022-01-07 13:48:31 -08:00
Orta Therox
8a8c71c147
Use relative paths for the end of compile report (#47344) 2022-01-07 19:55:55 +00:00
Oleksandr T
6fc0584dd5
fix(46402): create valid property keys/jsx attribute names (#46716) 2022-01-07 11:46:26 -08:00
Jake Bailey
484f1414d6
Prevent merged class/namespace from overlapping with Record<string, unknown> (#47088) 2022-01-07 11:02:48 -08:00
Anders Hejlsberg
a3d23d36cc
Fix conditional type constraint exploration + signature relations (#47341) 2022-01-07 07:44:57 -10:00
Kagami Sascha Rosylight
363e3a78f4
Add Error.prototype.cause (#47020)
* Add `Error.prototype.cause`

Fixes #47019

* Update test baselines
2022-01-07 14:58:58 +00:00
Orta Therox
e46f3baec1
Adds a github actions workflow which pings related repos with a blank commit once a month to ensure their automation stays running (#46747) 2022-01-07 13:37:16 +00:00
Alka Vats
0fcd86150e
docs(common): url link format updated (#47336)
fix the url link format from http to https
2022-01-06 22:08:19 +00:00
TypeScript Bot
95d8921641 Update package-lock.json 2022-01-06 06:07:15 +00:00