Commit graph

15891 commits

Author SHA1 Message Date
Orta Therox 07fd7bce64
Intl 2021 Updates (#45647)
* Import of Intl.Locale from #39664

* Handle updating es2020.intl and add es2021 for new DateTimeFormatOptions options - re: #39664

* Extends DateTimeFormatOptions for new Intl APIs - re: #45420

* Handle migrating Intl.NumberFormat.formatToParts to es2018 (keeping esnext.intl around)

* Adds Intl.DisplayNames to es2020 - re: #44022

* Remove attributes added in es2021 from es2020 - re: #42944

* Add a reference to es2021 in the command line parser

* Adds some docs about the lib files

* Baselines

* Allow undefined in Intl inputs to allow for ergonomic usage of exactOptionalPropertyTypes - see #45652

* Adds some tests covering the APIs

* Apply suggestions from code review

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

* Handle PR feedback

* More review improvements

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2021-09-08 10:43:01 +01:00
Orta Therox 32168ed653
Add support for raising if you set a tsconfig entry of target/module with the right setting in the root (#44964)
* Add support for raising if you set a tsconfig entry of target/module with the right setting in the root

* Switch to check for any compiler option in the root which doesn't include compilerOptions

* Get green

* Apply suggestions from code review

Co-authored-by: Andrew Branch <andrewbranch@users.noreply.github.com>

* Update src/compiler/commandLineParser.ts

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>

Co-authored-by: Andrew Branch <andrewbranch@users.noreply.github.com>
Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
2021-09-08 10:17:43 +01:00
Andrew Branch be618b1446
Stop looking at binding patterns for type argument inference (#45719)
* Ignore empty binding patterns for contextual typing

* Stop looking at binding patterns for type argument inference entirely
2021-09-07 17:14:06 -07:00
Anders Hejlsberg 7032f6bcee
Include index signatures for tagged primitives in keyof (#45773)
* Properly include tagged primitive types in keyof

* Add regression test
2021-09-07 10:46:13 -07:00
Zzzen 1d51dfa550
improve error message for using property of type as type (#45354)
* improve error message for using property of type as type

* suggest typeof when possible

* fix naming and error location
2021-09-03 12:17:50 -07:00
Ron Buckton 6f7f3b1775
Minor fixes to "Convert To Async" refactor (#45536)
* Minor fixes to convertToAsync

* Back out on nested return in inner continuation

* Baseline update

* Verify type argument for call can be used, add a few more early exit shortcuts
2021-09-01 13:13:12 -07:00
Orta Therox f9a3d85b00
Fix the default text for --useDefineForClassFields (#45513)
* Fix the default text for --useDefineForClassFields

* Update with feedback
2021-09-01 15:10:47 +01:00
Wesley Wigham f598076e68
Close package json watches in watch mode on close (#45642) 2021-08-30 12:53:26 -07:00
Ron Buckton 107c556fe4
Fix 'as const'-like behavior in JSDoc type cast (#45464) 2021-08-27 18:22:02 -07:00
Andrew Casey 7fc1cb4b36
Use realpathSync.native on case-insensitive file systems (#44966)
* Make getSourceOfProjectReferenceRedirect take a Path

* Add useCaseSensitiveFileNames to ModuleResolutionHost

...so that path comparisons can use it during module resolution.

* Re-enable realpathSync.native for case-insensitive file systems
2021-08-26 15:35:04 -07:00
Stef Busking 2a2962a916
Properties on intersections should be readonly only if all declarations are (#45263)
Fixes #45122
2021-08-25 16:55:14 -07:00
Andrew Branch 30103de1dd
Let AutoImportProviderProject resolve JS when allowJs and maxNodeModulesJsDepth allows (#45524)
* Let AutoImportProviderProject resolve JS when allowJs and maxNodeModulesJsDepth allows

* Simplify function
2021-08-25 15:06:14 -07:00
Orta Therox 41dcad056a
Adds a script for removing unused diagnostics (#44324)
* Adds a script for removing unused diagnostics

* Accidentally deleted the wrong one
2021-08-24 13:03:18 +01:00
David Rogers d18e82b380
fix for 45006 (#45020)
* fix for 45006

* treat setters like getters in preceding commit; move test accordingly

* fix test baselines

* changes per code review

in `getContainerFlags`, move cases for get/set accessors
to fallthrough into the block that currently handles MethodDeclaration;
so get/set accessors and method declarations all get the same container flags,
such that during `bindContainer`, `startFlow.node` is assigned to
getters/accessors
(this changes a public api in tsserverlibrary.d.ts and typescript.d.ts
by adding `GetAccessorDeclaration` and `SetAccessorDeclaration` to the type
of `FlowStart.node`)

consolidate predicates checking whether a node is either a get or set
accessor, into `isObjectLiteralOrClassExpressionMethodOrAccessor`
(formerly `isObjectLiteralOrClassExpressionMethod`)

annotate updated test with `@target: es2020`

* fix `isObjectLiteralOrClassExpressionMethodOrAccessor`

require that Getter/Setters are parented by an ObjectLiteralExpression or ClassExpression
2021-08-20 17:05:19 -07:00
Gabriela Araujo Britto 84b057828e
Fix incorrect suggestion for package that bundles types (#45507)
* Fix incorrect suggestion for package that bundles types

* determine if a package ships types from its files

* update new error message
2021-08-20 11:12:34 -07:00
Zzzen 693c2d08c1
support contextual return type of iife (#45007) 2021-08-19 16:37:50 -07:00
Gabriela Araujo Britto 945179fb64
Reuse checker's property accessibility check for completions (#45388)
* add test for completions crash

* WIP: experiment

* remove comments

* add call to getParseTreeNode

* Revert "add call to getParseTreeNode"

This reverts commit 8dd1cf67cf.

* Fix comments

* minor fixes

* fix formatting

* rename type to containingType
2021-08-19 13:02:20 -07:00
Anders Hejlsberg 79474fdfd2
Increase type instantiation depth limit (#45025)
* Bump instantiation depth limit to 500

* Accept new baselines

* Update tests

* Accept new baselines
2021-08-17 07:00:19 -07:00
Gerrit Birkeland e263fcebf8
Expose getTypePredicateOfSignature (#44863) 2021-08-16 17:17:42 -07:00
Ryan Cavanaugh e00b5ecd40
Enable max-statements-per-line lint rule (#45475)
* Enable the rule

* Fix all the violations
2021-08-16 13:53:51 -07:00
Oleksandr T 5b3072f687
fix(45233): allow type assertion in ExportAssignment with JSDoc type definition (#45342) 2021-08-13 16:32:23 -07:00
Oleksandr T dfd84ec0b2
fix(45417): show inlay hints for null and literal-like identifiers (#45426) 2021-08-13 11:31:47 -07:00
Nathan Shively-Sanders 8d4fe5a0fb
Fix unassignable properties by adding undefined with exactOptionalPropertyTypes (#45032)
* Simple first version

Doesn't cover or test any complicated variations.

* Lots of cases work

Destructuring does not. But

- skipping node_modules and lib.* does.
- call expressions does
- property access, including with private identifiers, does

* Support variable declarations, property assignments, destructuring

As long as it's not nested

* More cleanup

* skip all d.ts, not just node_modules/lib

* Offer a codefix for a lot more cases

* remove incorrect tuple check

* Use getSymbolId instead of converting to string

Co-authored-by: Andrew Branch <andrewbranch@users.noreply.github.com>

* add test + switch to tracking number symbol ids

* Address PR comments

* Exclude tuples from suggestion

* Better way to get error node

Plus add a check that errorNode is an argument to the call, not the
call's expression.

* fix semicolon lint

* fix another crash

* Simplify: add undefined to all optional propertie

whether or not somebody tried to assign undefined to them in the
erroneous assignment

* remove fix-all

Co-authored-by: Andrew Branch <andrewbranch@users.noreply.github.com>
2021-08-10 16:57:38 -07:00
Oleksandr T ad894f74b3
fix(45345): throw an error on overridden member that is defined in multiple interfaces (#45352) 2021-08-10 11:50:22 -07:00
Ron Buckton d8e830d132
Fix __spreadArray for non-concat-spreadables (#45386) 2021-08-09 17:08:07 -07:00
Daniel Rosenwasser 66980fc8dc Bump version to 4.5. 2021-08-06 23:28:17 +00:00
Henrique Inonhe 7753efae79
Improve error message TS1210 (#44892) 2021-08-06 15:00:26 -07:00
Oleksandr T cce2e926de
feat(45163): add QF to declare missing jsx attributes (#45179) 2021-08-06 12:38:22 -07:00
Anders Hejlsberg 409be37bf5
Fix index signature assignability from optional properties in --exactOptionalPropertyTypes mode (#45185)
* Explicit undefined not assignable to non-undefined index signature in exactOptionalPropertyTypes mode

* Add tests
2021-08-06 08:54:00 +02:00
Anders Hejlsberg 3bd5079f1c
Fix check for generic types in control flow analysis (#45148)
* Fix check in hasNonBindingPatternContextualTypeWithNoGenericTypes

* Add regression tests

* Accept new baselines

* Compute both ObjectFlags.IsGenericXXXType flags in one go
2021-08-06 08:53:30 +02:00
Orta Therox 1f85123821
Revisions for the new --help (#44800)
* WIP on refining the new --help

* Fix types in the boolean trivial lint rule

* Update baselines

* More work

* Updates the color logic

* Simplifies the CLI color code

* Use cyan instead of blue for win powershell/command prompt

* Use bright white when blue is probably going to look off

* Fix NO_COLOR

* Adds a test to cover NO_COLOR

* Update src/compiler/diagnosticMessages.json

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>

* Update compiler diagnostic text

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
2021-08-05 16:41:01 +01:00
Eli Barzilay 635f5bdf8c Some tweaks for backtick strings
1. `getRawLiteral()`: barf if `currentSourceFile` is missing, since if
   it is, then the following `getSourceTextOfNodeFromSourceFile` will
   return a bogus `""`.

2. One `||` -> `??` change.

3. `backtickQuoteEscapedCharsRegExp`: escape the usual control
   characters except for a simple LF.  This code does get used to
   generate backtick strings when `rawText` is not given, and not
   escaping things like TAB characters can get mangled by editor
   settings.  Worse, not escaping a CRLF and putting it verbatim in sthe
   string source will interpret it as LF, so add a special case for
   escaping these as `\r\n`.
   Added test.

Related to #44313 and #40625.
2021-08-05 05:45:34 -04:00
Andrew Branch f80bc3f5f0
Store symbol table map key in CachedSymbolExportInfo (#45289)
* Store symbol table map key in CachedSymbolExportInfo

* Remove debug assertion

* Filter out known symbols (again) and private identifiers
2021-08-04 16:31:47 -07:00
David Sherret 03dff41c9f
Fix getting completion details for meta properties (#45031)
* Fix getting completion details for meta properties.

* Move inside the worker.

* Move ImportMeta handling to completions.ts

* Fix property type name for new.target.

* Use symbols for ImportMeta completions.

* Accept baselines.

* Revert lib change.

* Revert needless parser change.

* Missed these reverts.

* Remove now unused `isMetaPropertyExpression`

* Move up meta property keyword check to be done in `getSymbolAtLocation` and `getTypeOfNode`

* Call `checkNewTargetMetaProperty` directly and handle when it's an error type.

* Make meta property expression types synthetic.

* Make event.target and import.meta properties readonly

* Add a test for go to definition (I think?)

* Copy built-in types/values test for go to definition.

* Add tests for go to definition when not a module.

* Fix "go to definition" for new.target
2021-08-04 09:41:04 -07:00
Nathan Shively-Sanders f1ce0f5528
Visit children of jsdoc type aliases in the binder (#45312)
* Visit children of jsdoc type aliases in the binder

This sets up parent pointers.

Fixes #45254 and almost certainly #45248, though I haven't figured out
to repro the second case.

* move incorrect parenthesis

* manually set comment parent instead

* Bind children of typedef where possible

* add explanatory comment to binding
2021-08-04 07:05:11 -07:00
Oleksandr T 5971b68231
fix(45224): show inlay hints for setter parameter (#45229) 2021-08-03 11:33:26 -07:00
Oleksandr T c4080437b2
fix(45102): do not suggest refactoring for functions contains arguments reference (#45116) 2021-08-03 11:31:56 -07:00
Martin Johns 5a2153a729
Fix position of keyword in "Add 'override' modifier" code fix (#45274)
fixes #45270
2021-08-03 11:01:30 -07:00
Kubilay Kahveci 9cc3070938
expose getImmediateAliasedSymbol() publicly (#44644)
Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
2021-08-02 15:57:54 -07:00
Armando Aguirre 642060db6f
Replace non-null assertion with optional chain on assert nodes (#43788) 2021-08-02 15:26:48 -07:00
Andrew Branch bfd5b2f7f0
Fix decorator metadata references to type-only-imported namespaces (#44915)
* Add test

* Fix metadata references to type-only-imported namespaces

* Use `!!` instead of `|| false`
2021-08-02 14:18:15 -07:00
Wesley Wigham 7669bfba15
Actually instantiate the type of the annotation used for contextual types (#45285) 2021-08-02 12:44:56 -07:00
Andrew Casey 0f6e6efde0
Avoid no-op export map updates (#45238)
* Add id and version to ManyToManyPathMap

...so that unchanged maps can be recognized without having to examine
their contents.

* Track cache version on BuilderState

In practice, `updateExportedFilesMapFromCache` is called repeatedly
without the cache changing in between.  When this occurs, there's no
need to update the `BuilderState` (this was already the net effect, but
it took a long time to determine that no work was required).

* Fix typo in comment
2021-07-30 09:27:32 -07:00
Gabriela Araujo Britto db0f7938dd
Allow narrowing for any left-hand in operand (#45152)
* allow narrowing for any left-hand in operand
2021-07-29 14:06:45 -07:00
Gabriela Araujo Britto 366e9de264
Fix compiler crash on property symbols without declarations (#45190)
* don't track computed name if symbol has no declaration

* add compiler test

* add non serializable property declaration emit error

* don't track computed name if symbol has no declaration

* fix small stuff

* rebase: add non serializable property declaration emit error

* use symbolToString instead of symbolName
2021-07-29 12:42:54 -07:00
Eli Barzilay 7e8bba6908 Fix template string refactoring and nodeFactory bug
Instead of letting `createTemplate*` generate a broken raw string from
the cooked one, grab the source code for it.

Also, add a missing bit to `\`-quote `$`s.  As the comment in the code
says, it could just `\`-quote `${` since other `$`s are valid, but I
think that it's less confusing to always quote $s (but the change is in
the comment if minimalism is preferred).

Also, a small-but-confusing bug in `getCookedText()`.

Many tests for all of this.

Fixes #40625
2021-07-29 04:23:06 -04:00
Oleksandr T b81eb6cfe1
fix(45182): allow property access in arrow function (#45193) 2021-07-27 09:46:17 -07:00
Oleksandr T 11c7daef62
fix(45114): throw an error when using '#' as an identifier (#45124) 2021-07-26 11:39:17 -07:00
Oleksandr T ba226167bc
fix(45157): omit error after property declaration without semicolon (#45165) 2021-07-26 09:57:58 -07:00
Andrew Branch 48aecfa5a5
Consider module augmentations in files referenced by imports in watch/incremental (#45156)
* Consider module augmentations in files referenced by importsin watch/incremental

* Accept baselines

* Accept other baseline

* Hooray optional chaining

* Delete outdated and unuseful comment
2021-07-23 16:32:52 -07:00