16439 Commits

Author SHA1 Message Date
Daniel Rosenwasser
76357ba802
Swap forEachChild to use a table of functions instead of a switch statement. (#50225)
* Swap `forEachChild` to use an array of functions instead of a `switch` statement.

* Let's see if 'new' changes anything.

* Co-locate each assignment into `forEachChildTable`.

* Try `push`ing undefined to create a packed Array.

* Try using an unconditional no-op function.

* `forEach` -> `forEachChildIn`

* Remove the optional chain if we are pre-filling with no-ops.

* Grab function directly to avoid possible `.call` overhead from downlevel emit.

* Swap to object literal.

* Lints and formatting.
2022-08-21 17:48:45 -07:00
Ron Buckton
284837d66b
Fixes for decorators property deprecations (#50343)
* Change type of deprecated 'decorators' property

* fix 'Invalid Arguments' error for create/update constructor in factory

* Update deprecation comments

* Make 'decorators' optional and 'undefined'

* Rename '_decorators' to 'illegalDecorators'

* Update baselines
2022-08-19 14:27:26 -04:00
Oleksandr T
5969ae9ef7
fix(50075): do not strip undefined from the function class properties (#50169) 2022-08-19 09:34:42 -07:00
Wesley Wigham
05d7d6bb12
Unify default import resolution across specifier target codepaths (#49814)
* Unify default import resolution across specifier target codepaths

* Use differing type aliases, per request
2022-08-19 02:25:41 -07:00
Sheetal Nandi
1f0f7c8246
If resolvedFileName differs with realPath only in casing use the resolvedFileName before realpath so that errors can be reported with forceConsistentCasingInFileNames (#50364)
* Add tests when realpath supresses the casing error

* Fix when real path results in value that differs only in case
Fixes #49470

* Comment
2022-08-18 14:51:46 -07:00
Ron Buckton
1592210673
Add a jump-table for visitEachChild (#50266)
* Add a jump-table for visitEachChild

* Name each visitor function for better stack traces

* Fix node tests and some minor cleanup
2022-08-18 15:03:17 -04:00
Andrew Branch
330e33cdda
Ignore related info in diagnostic deduplication (#50309)
* Ignore related info in diagnostic deduplication

* Add another test
2022-08-16 09:28:59 -07:00
Andrew Branch
4e33e0eb6c
Make literal types not comparable to weak object types without property overlap (#49865) 2022-08-15 17:10:11 -07:00
Andrew Branch
64ee1e88e0
Strip literal freshness of contextually typed literals (#49884)
* Strip literal freshness of contextually typed literals

* Add more tests
2022-08-15 17:04:09 -07:00
Sheetal Nandi
9c1baeede6
On windows handle the long paths in realpathSync.native (#50306)
Fixes #49470
2022-08-15 16:57:47 -07:00
Wesley Wigham
e989d840f1
Forward intersectionState flag when comparing indexed access constraints (#50261) 2022-08-15 16:10:32 -07:00
Andrew Branch
bc52ff6f4b
Make React import fix not block component import fix (#50307)
* Stop React import fix from blocking component import fixes

* Add additional promote-type-only test
2022-08-15 13:13:41 -07:00
Jake Bailey
fd3c46b2f0
Fix export = error message to not have redundant language (#50308) 2022-08-15 13:13:33 -07:00
Ryan Cavanaugh
adf26ffa4b
Revert "Fixed an issue with contextual type for intersection properties (#48668)" (#50279)
This reverts commit 9236e39374c0ec9a1e3f9894af4fb9eb34ba0021.
2022-08-12 10:24:50 -07:00
Sheetal Nandi
b19741c65d
Report aggregate statistics for solution as well as some solution perf numbers (#50267)
* Report aggregate statistics for solution as well as some solution perf numbers
This change under --extendedDiagnostics aggregates the diagnostics from all projects built and reports it at the end. Apart from that it also outputs some measurements for work that happens in tsc --build like finding if projects are uptodate etc.
Also removes unnecessary node count per suggestion

* Apply suggestions from code review

Co-authored-by: Ron Buckton <ron.buckton@microsoft.com>

* Fix condition

* Remove extra time

Co-authored-by: Ron Buckton <ron.buckton@microsoft.com>
2022-08-11 13:20:48 -07:00
Jack Works
075ee3d4b6
refactor: follow gh-50257 JSX.IntrinsicClassAttributes logic (#50271) 2022-08-11 09:32:31 -07:00
Sheetal Nandi
924c68ca95
use cache for program creation on watch mode. (#49958) 2022-08-10 16:56:54 -07:00
Sheetal Nandi
90cfbaee37
Make build info tolerant to json errors (#50265)
* Make build info tolerant to json errors
Fixes #49754

* Fix incorrect code
2022-08-10 16:44:35 -07:00
Jake Bailey
8a24fe75c9
Fix up code so we don't crash when TS itself is emitted with let/const (#50151) 2022-08-10 13:38:38 -07:00
Jake Bailey
b56483feb8
Remove shims project (#50049) 2022-08-10 11:49:59 -07:00
Jake Bailey
7f1dc78f54
Simplify normalizeSlashes (#50154) 2022-08-10 11:20:00 -07:00
Jake Bailey
5fbf3b04dc
Don't treat object properties as potential JS contructors without JSDoc class tag (#49735) 2022-08-10 11:19:19 -07:00
Jack Works
382f0c3af3
fix: crashes when JSX.IntrinsicClassAttributes is an alias type close GH-50254 (#50257) 2022-08-10 10:41:12 -07:00
Jack Bates
35c6fbfee0
JSDoc @type tag optional parameters (#48132)
* JSDoc @type tag optional parameters

* Don't repeat isInJSFile() condition

* Exclude variable initializers

* Add tests for class methods

* Don't contextually type JS function declarations

* Update Baselines and/or Applied Lint Fixes

* Reword comment

Co-authored-by: TypeScript Bot <typescriptbot@microsoft.com>
2022-08-09 17:03:30 -07:00
Andrew Casey
2513a2d98c
Use binary search in file system cache (#50163)
* Use binary search in file system cache

Previously, we were linear searching a linear number of times, resulting in too many `toLowerCaseFileName` calls on Windows.

* Use SortedArray types for clarity

* Use insertSorted after making it return a flat

* Drop redundant undefined

* Correct copy-paste error
2022-08-09 16:47:07 -07:00
Oleksandr T
af90e703ab
feat(49903): omit declare on type declarations (#49925) 2022-08-09 16:38:42 -07:00
Zzzen
b94b299a11
fix CFA for BindingElement. #49759 (#49836)
* fix CFA for BindingElement. #49759

* fix Parameter

* fix controlFlowBindingPatternOrder

* fix bindParameterFlow

* add tests

* refactor

* refactor

* refactor
2022-08-09 16:37:39 -07:00
Nathan Shively-Sanders
dd98c17b10
Merge multiple symbols even when re-exported (#49987)
* Merge multiple symbols even when re-exported

As far as I remember, the target of `mergeSymbol` needs to be a merged
symbol, not a symbol with a mergeId that points to mergedSymbol.
However, mergeSymbolTable didn't check for this.

I can't remember if symbol tables may contain
symbols-with-mergeId. If they can, then mergeSymbolTable needs to call
getMergedSymbol on the individual targets of the merge. That's what I
did in this PR.

* Call getMergeSymbol eagerly

On the source, not target, of mergeSymbolTable's contents
2022-08-09 16:36:53 -07:00
magic-akari
abc2a350e6
Fix System module export import = (#49788)
* Add more SystemJS test case

* Fix System module `export import =`

* Update test case
2022-08-09 16:31:02 -07:00
Oleksandr T
19e2a310c0
feat(49834): Suggestion: filter enum member ids from their own jsdocs (#49843)
* feat(49834): omit self-referenced enum declaration in JsDoc

* change code style
2022-08-09 15:02:45 -07:00
Daniel Rosenwasser
6aa9b87f54
Bump version to 4.9. (#50239) 2022-08-09 13:33:52 -07:00
Mateusz Burzyński
0e17dc7769
Fixed a false positive related to binding patterns and spread expressions (#49684)
* Fixed a false positive related to binding patterns and spread expressions

* Improve ancestor lookup when checking if an expression is spread into an object

* Fixed ancestor lookup for more node types

* Remove equality check for contextual types

* Reformat code

* Use `isWithinSpreadAssignment` flag + `objectsWithinSpread` cache instead of ancestor traversal

* Revert "Use `isWithinSpreadAssignment` flag + `objectsWithinSpread` cache instead of ancestor traversal"

This reverts commit be387e3bbf8a5cce2bc4c31fd77b061ea6cf8e0b.

* Expand on the existing comment
2022-08-08 17:01:50 -07:00
Gabriela Araujo Britto
bdb8514b82
Fix contextual typing on yield and return expressions in generator function (#49736)
* add tests and initial fix

* fix contextual return type in generator funcs

* fix return statement contextual typing

* filter using getiterationtypeofgeneratorfunctionreturntype

* update baselines
2022-08-05 11:24:43 -07:00
Andrew Branch
7afd14f263
Update error messages for CJS imports resolving to ES modules (#50088)
* Update error messages for CJS imports resolving to ES modules

* Update error message

* Use package scope from source file

* Update baselines

* Issue error for JSX/TSX files

* Switch from related info to message chain
2022-08-04 16:58:13 -07:00
Ron Buckton
6bbe6d67d1
Fix return value and error reporting for getIterationTypesOfMethod (#50146) 2022-08-03 19:07:29 -04:00
Sheetal Nandi
bc7786b24e
Ensure that file watcher is closed only once for affected file locations that share watcher because of different names but same real path (#50150)
* Add test where clearing affected files watcher that also is shared by real path causes Debug failure

* Ensure that file watcher is closed only once for affected file locations that share watcher because of different names but same real path

* Lift up package json map
2022-08-03 15:39:07 -07:00
Ron Buckton
d6d26430c7
Add rule to auto-paren optional chain in normal prop or element access (#50156) 2022-08-03 17:17:26 -04:00
Andrew Branch
c82c9a9744
Fix bugs in module specifier generation with paths/typesVersions (#49792)
* Write a test and a huge comment

* Finish fixing everything

* Clean up comment

* Remove obsolete comment

* Fix comment trailing off

* Optimize to hit the file system much less
2022-08-03 13:58:15 -07:00
Anders Hejlsberg
697935da47
Restore ordering of operations involving type parameters and unions (#50116) 2022-08-03 00:32:41 -04:00
Oleksandr T
c0072aad80
fix(49935): omit parentheses in the operand of the unary expression (#50111) 2022-08-01 17:22:45 -04:00
Ron Buckton
55f2c0cb49
No synthetic Awaited for unconstrained type when not a type variable (#50100) 2022-08-01 17:19:15 -04:00
Sheetal Nandi
394f51aeed
Fix implied formats, file watching, new source file creating during edits (#50098)
* Add test where module resolution cache is not local and hence doesnt report errors in watch mode

* Ensure module resolution cache is passed through in watch mode

* Remove unnecessary setting of impliedFormat which should anyways be done as part of create source file

* Add test for packge.json changing and modifying implied format

* Distinguish between package.json watch and affecting file location watch

* Pass in failed lookup and affected file locations for source file's implied format
Also stop creating options if we already have them

* Add diagnostic for explaining file's implied format if based on package.json

* Watch implied format dependencies for modules and schedule update on change

* For program if implied node format doesnt match create new source file. Handle implied node format in document registry
Fixes #50086

* Modify tests to show package.json being watched irrespective of folder its in

* Check file path if it can be watched before watching package.json file

* Because we are watching package.json files and failed lookups its safe to invalidate package json entries instead of clearing them out everytime program is created

* Remove todos

* Fix the incorrect merge

* Pickup PackageJsonInfo renames from #50088

* Rename
2022-08-01 12:41:37 -07:00
Nathan Shively-Sanders
427d43691a
Improve import type support for commonjs exports (#49745)
* Improve import type support for commonjs exports

This PR makes getTypeFromImportTypeNode a little more like
getExternalModuleMember: for JS files, it now uses both
`getTypeOfSymbol` and `getExportsOfSymbol`, and uses whichever one
returns a symbol. This allows using arbitrary properties of a CJS export=
as types in JSDoc; previously a special case in the binder enabled only
CJS export= where all properties were shorthand assignments.

Fixes #49195

* Add js types/value test case

* Improve binding of CJS property assignments

1. Bind property assignments same as shorthand property assignments in
module.exports object literal assignments.
2. Bind all such assignments, even if the object literal contains
non-property assignments. This is different from before, and it requires
slightly smarter code to prefer aliases when checking CJS imports.

* Remove new binder code

Just include the original fix

* revert missed type in binder
2022-08-01 10:57:38 -07:00
Oleksandr T
ae7d2325e9
fix(49869): throw an error on optional binding pattern parameter in JavaScript (#50094) 2022-07-29 16:05:34 -07:00
Ron Buckton
88a1e3a1dd
Transform decorators that reference private names into a 'static {}' block (#50074) 2022-07-29 15:29:48 -04:00
Zzzen
1490037f17
fix dts generation of jsdoc (#49904) 2022-07-28 17:44:23 -07:00
Sheetal Nandi
5d790526a1
Pass correct module resolution state when reading package.json info so that they are correctly tracked in the resolution (#50085) 2022-07-28 17:19:10 -07:00
Oleksandr T
949fffb1e0
feat(47983): Negative tuple index access should not be allowed (#49901)
* feat(47983): disallow negative integers for indexing tuple

* change error message

* add additional tests
2022-07-28 14:22:13 -07:00
Sheetal Nandi
5b0eea48e9
Report error only on local declaration with additional related information (#49746)
* Add test where the errors are reported in different file
Test for #49739

* Report error only on local declaration with additional related information
Fixes #49739

* Handle existing tests
2022-07-27 15:31:45 -07:00
Jake Bailey
8d0c72d5e0
Normalize effective constraint intersection before checking if source is a part of it (#49956) 2022-07-27 10:06:01 -07:00