33430 Commits

Author SHA1 Message Date
Sheetal Nandi
f5ad78720f
Always recreate the file watcher when rename event occurs (#48997)
* Convert some of the watchEnvironment tests to baselines for updating later

* Add tests for inode watching by making fsWatch part of system function that tests presence before creating fs watch

* Refactor for simpler tests

* Accept map of file content or file or symlink or folder

* Add test when rename event occurs when file has already reappeared

* On rename event for the file, replace file watcher irrespective of file presence

* Fix regex

* Ensure that when doing inode watching watchers is replaces only on disappearance or appearance

* Some logging for debugging further

* Revert "Some logging for debugging further"

This reverts commit dd2164ac83666725c4cc58e0223425b10530d682.

* Add test when rename event occurs on mac with ~ appended to file name

* If the relativeFileName ends with tilde, remove it from the event

* Some logging for debugging further

* Revert "Some logging for debugging further"

This reverts commit e1ba8a8d5f2f30cc039a89a1e8e4e6c64ba7c44d.

* Add documentation and fail safe the event firing
2022-06-08 17:54:57 -07:00
Wesley Wigham
ce639352bb
Serialize inaccessible class declarations the same as class expressions in declaration emit (#49440) 2022-06-08 16:33:09 -07:00
Wesley Wigham
86ff3f6fec
Give cjs export assigned types an alias symbol (#49407) 2022-06-08 16:32:18 -07:00
Anders Hejlsberg
7e4a96e2fa
Revise and simplify CFA for typeof check expressions (#49422)
* Revise and simplify CFA for `typeof` check expressions

* Accept new baselines

* Add regression test

* Slight change to preserve type when related in both directions

* Add regression test

* Explain reasons for exact sequence of type checks
2022-06-08 11:30:28 -07:00
Sheetal Nandi
5cedf3e680
Handle package.json watch in tsc and tsserver. (#49328)
* refactoring

* Maintain packagejson paths per resolution so we dont have invalidate everything on package json change

* Fix todo
2022-06-08 10:22:29 -07:00
Sheetal Nandi
b8f6488323
Build improvements (#48784)
* Use fixed time for vfs so baselining is consistent

* Baseline buildinfos

* Write new file text in baseline even if the file wasnt read on the shadow

* Remove unnecessary debugger statement

* Make sure that incremental correctness is checked with correct writeFile so we know buildInfo was written
Also baseline these so its easy to verify the changes

* More baselines for the tsbuildinfo

* If we are writing dts file and have used file text as version, we can update the signature when doing actual emit

* Make WriteFileCallback Api ready for future

* Assert that there is only single source file when emitting d.ts file

* Add test

* Renames

* More refactoring

* If we are updating dts of any of the file and it affects global scope, everything needs update in signature and dts emit
Fixes #42769

* Stacktrace optimization for getModified time in anticipation of using it more than fileExists wherever possible

* Baseline getModifiedTime, setModifiedTime, fileExits and directoryExits for experiment

* Remove unnecessary write file finger print code since its not used at all

* Use modified time instead of file existence check

* Remove unnecessary getModifiedTime

* No need to check for file existence before reading the d.ts file

* Do project reference errors before doing input/output file checks

* Dont call getModifiedTimes if dts change

* Passdown modified time if queried

* Use modified time passed through the file watching in tsbuild

* Handle force build as separate upto date status

* uptodate status worker to read buildinfo and use it to determine upto date ness

* No need to update output timestamps if buildinfo will determine uptodateness

* Store change file set instead of hasPendingChange to be able to reuse the information

* Add test that shows input file is not present

* No need to check input time stamp before buildinfo

* Keep buildinfos for lifetime of the solution builder and project

* Store modified time along with text of buildinfo

* Non composite projects dont need to track declaration change time

* Pass through buildInfo so we dont have to parse it back

* Save dts change time in buildinfo itself

* Store dts time for --out in the buildInfo

* Store hash of text in the bundle info so it can be verified before manipulating text for fast updates during prepend
This helps when text changes during incremental build toggling and we determine we can just manipulate text

* Since buildinfo is cached no need to maintain version check state

* Store output time stamps for non incremental builds

* Revert "Baseline getModifiedTime, setModifiedTime, fileExits and directoryExits for experiment"

This reverts commit 7e65cd3315ccf387f6d7e7c40263e85bcc3c961c.

* Change verbose messages for upto date status

* Reconcile reusable builder state and builder state so there are not two different types that are almost similar looking

* Cleanup impliedFormat

* Cleanup

* Cleanup noEmit option

* BuildInfo options emit as a flag

* Factor out types for program written in buildinfo with and without bundle emit

* No need to store output file stamps if not in watch mode

* Cleanup

* Test for single watch per file

* Fix emit and error update baselines that were duplicate

* More refactoring

* Only copy emit state fields when backing up to restore if emit fails

* Instead of maintaining delta of changes, maintain old state for those changes

* Add test to verify build when input file does not change

* If version of the input file does not change, dont mark as out of date

* Disable lint warning as build fails without the assert

* Report aggregate statistics for solution as well as some solution perf numbers

* Options solutionDiagnostics instead so that its not too verbose when printing diagnostics

* When tsc --build --clean, only remove tsbuildinfo if its incremental build

* Revert "Options solutionDiagnostics instead so that its not too verbose when printing diagnostics"

This reverts commit 0cf9e301038267bc1d9439c15d279940809b0c00.

* Revert "Report aggregate statistics for solution as well as some solution perf numbers"

This reverts commit 405d8e91978708a613fe8cb631a83b13c430a808.

* Revert "When tsc --build --clean, only remove tsbuildinfo if its incremental build"

This reverts commit e4e66726098201f38f5e8908a538e7a506f15efd.

* Comments in the code

* Feedback
2022-06-08 09:48:34 -07:00
TypeScript Bot
7bff2dd28b Update package-lock.json 2022-06-08 06:06:20 +00:00
Jack Bates
9357c183cb
Fix up "Use symbolic GitHub Actions Node.js versions (#49403)" (#49420)
* Fix up "Use symbolic GitHub Actions Node.js versions (#49403)"

* Use npm v6 to update package-lock.json
2022-06-07 14:20:05 -07:00
Gabriel Grubba
4c5060181f
Fix(49198): Added missing definition for Atomics.waitAsync and es2022 sharedmemory file (#49204)
* feat(sharedmemory): Added file waitAsync function

* fix: Adjusted promise return type

* Fix(sharedmemory): Addressed PR comments

* Fix: Removed unused @see at sharedmemory

* Feat: Added tests to shared memory

* Fix: fixed ordering in libs.json

* Feat: Added shared memory to line parser

* Update tests es2022SharedMemory.ts as sugested

Co-authored-by: Eyal Halpern Shalev <eyalsh@gmail.com>

* Update es2022SharedMemory.ts

* feat: Accepted baselines

* fix: Adjusted grammar changes in jsdoc

* fix(47821): skip nodes with export modifiers (#47829)

* Use symbolic GitHub Actions Node.js versions (#49403)

* update baselines

Co-authored-by: Eyal Halpern Shalev <eyalsh@gmail.com>
Co-authored-by: Oleksandr T <oleksandr.tarasiuk@outlook.com>
Co-authored-by: Jack Bates <jack@nottheoilrig.com>
Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2022-06-07 08:46:23 -07:00
Jake Bailey
f72b1badff
Replace ts.hasOwnProperty.call(...) with hasProperty(...) (#49410) 2022-06-06 20:10:40 -07:00
Jack Bates
0d7fbbb415
Use symbolic GitHub Actions Node.js versions (#49403) 2022-06-06 13:51:04 -07:00
Oleksandr T
2f13eba42c
fix(47821): skip nodes with export modifiers (#47829) 2022-06-06 10:49:55 -07:00
Anders Hejlsberg
565249fbbe
Fix definite assignment analysis issue caused by x !== null checks (#49387)
* Check for non-intersected `undefined` type in definite assignment analysis

* Add regression test
2022-06-06 09:51:13 -07:00
Oleksandr T
6c77996337
remove unnecessary files (#49401) 2022-06-06 09:40:50 -07:00
Oleksandr T
62668c6c1d
feat(47558): check JSDoc link tags in TypeScript/JavaScript files (#47822) 2022-06-06 09:04:18 -07:00
TypeScript Bot
3a8c630747 Update package-lock.json 2022-06-06 06:06:54 +00:00
TypeScript Bot
b2617d6e38 Update package-lock.json 2022-06-04 06:06:25 +00:00
Andrew Branch
f483ab5c2f
Explicit types should prevent ATA from doing package.json discovery (#49380) 2022-06-03 15:21:21 -07:00
Ron Buckton
cb1bc6169b
Move legacy decorators into separate transform (#48669) 2022-06-03 09:36:29 -07:00
Wesley Wigham
3ccbe804f8
Expose import mode calculation functions (#49360)
* Expose import mode calculation functions

* Make `SourceFileImportsList` internal again.

* Accepted API baselines.

* Fix lints.

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
2022-06-02 18:06:50 -07:00
Oleksandr T
9c8e6b53b8
fix(49223): checker.getTypeAtLocation for ExpressionWithTypeArguments returns an error any type (#49284)
* fix(49223): handle ExpressionWithTypeArguments nodes in isExpressionNode

* Update src/compiler/utilities.ts

* Just use `!isHeritageClause(node.parent)`.

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
2022-06-02 17:28:36 -07:00
Andrew Branch
34fe835f33
Add nightly-only error on ImportType resolution mode assertion (#49356)
* Add nightly-only error on ImportType resolution mode assertion

* Temporarily change version to demonstrate errors

* Revert "Temporarily change version to demonstrate errors"

This reverts commit 40c2469647f129ea088a16d60f3f070f9f5beeb2.

* "Resolution mode" -> "resolution-mode"
2022-06-02 15:50:44 -07:00
Wesley Wigham
19b22844d8
Use node's algorithm for calculating the longest matching export/import pattern (#49361) 2022-06-02 15:43:26 -07:00
Oleksandr T
2cb8ee27f0
fix(48653): throw an error on an invalid optional chain from new expression (#48656) 2022-06-02 14:21:36 -07:00
Oleksandr T
c6447f9454
fix(49306): add isImportTypeAssertionContainer helper (#49313) 2022-06-02 14:07:03 -07:00
TypeScript Bot
ce9b4c1d5b Update package-lock.json 2022-06-02 06:06:32 +00:00
uhyo
f3d57ccea8
Remove undefined from source type of renaming destructuring assignment with default (#41042)
* Remove undefined from source type of destructuring assignment with renaming

* add a test

* add test case from original issue

* add test with undefined default value

* add more test cases with const declaration
2022-06-01 15:34:37 -07:00
Anders Hejlsberg
1beb1037c0
Fix check in isMappedTypeGenericIndexedAccess (#49341)
* Fix check in isMappedTypeGenericIndexedAccess

* Add regression tests
2022-06-01 10:01:56 -07:00
TypeScript Bot
9031497b92 Update package-lock.json 2022-06-01 06:10:42 +00:00
Anders Hejlsberg
3cdb8081f7
Use NonNullable<T> in more scenarios (#49330)
* Remove getFalsyFlags and improve getNonNullableType

* Apply getNonNullableType to left operand of || operator

* Accept new baselines

* Add tests
2022-05-31 17:05:33 -07:00
Harsheet Kakar
75f4e95e85
Fix46246 (#46357)
* changed error message for interface extending primitive type

* moved interface check to different function

* changed part of interface declaration to is extended by interface

Co-authored-by: harsheetkakar <harsheetkakar@bitbucket.com>
Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2022-05-31 16:47:07 -07:00
TRCYX
44b9745942
fix(49151): format type parameters/arguments (#49165)
Before, the formatter did not consider these constructs as comma
separated lists in general, leading to wrong indentation of '>' after
the list.
2022-05-31 16:03:17 -07:00
Wesley Wigham
bf5acb5c4d
Issue serialization error when attempting to serialize a late-bound name from a mapped type (#49221) 2022-05-31 15:36:13 -07:00
Oleksandr T
3da165e3df
fix(49178): check expression with type arguments in inlay hints (#49179) 2022-05-31 15:22:16 -07:00
Nathan Shively-Sanders
a5b1f95c23
Allow accessors to override non-class or abstract properties (#41994)
* remove too-late fix

* Allow any property from a mapped type

* turn off error for any non-class base

* Also handle synthetic properties more laxly

Originally from #42635, but this version is simpler.

* update baselines

* Update baselines

* createUnionProperty of accessors creates an accessor

Seems simple and doesn't break much. I need to double-check the few test
failures, however.

* Fix computation of write type of accessors

* Calculate property-vs-accessor in existing loop

Instead of looping over the props list 3 more times.

* Undo synthetic accessor change

* Minimise diff
2022-05-31 14:51:08 -07:00
Andrew Branch
39f5dbff43
Fix index fallback of CJS package from ESM-mode import when main is present but does not resolve (#49327) 2022-05-31 14:10:17 -07:00
bentongxyz
3939b38aa1
fixes #48630 array binding pattern with only OmittedExpressions does not check RHS of for-of loop (#49008)
* fix RHS of for..of loop not evaluated when LHS is array binding element with OmittedExpression

* expand widened type check

* add more test cases

* update code with suggestions

* Make test target es2015

Co-authored-by: Andrew Branch <andrew@wheream.io>
2022-05-31 11:06:19 -07:00
TypeScript Bot
7baaf7be1c Update package-lock.json 2022-05-31 06:07:27 +00:00
TypeScript Bot
6cda20d61f Update package-lock.json 2022-05-30 06:07:25 +00:00
csigs
fa364b85d0
LEGO: Merge pull request 49300
LEGO: Merge pull request 49300
2022-05-29 04:17:15 -07:00
TypeScript Bot
80832a8d08 Update package-lock.json 2022-05-29 06:06:26 +00:00
TypeScript Bot
0d9a9dc75d Update package-lock.json 2022-05-28 06:06:51 +00:00
Anders Hejlsberg
51b346d65a
Improve intersection reduction and CFA for truthy, equality, and typeof checks (#49119)
* Improve reduction of intersection types

* Accept new baselines

* Improve CFA for truthy, equality, and typeof checks

* Accept new baselines

* Remove special case for Function type

* Don't reduce intersections of form {...} & object

* Accept new baselines

* Anything is assignable to unknown-like union

* Accept new baselines

* Tweak subtype check

* Recombine unknown type from unknown-like union in more cases

* Display union origin only if it is shorter than union itself

* Accept new baselines

* Add tests

* Only attach origin type when it is shorter than union itself

* Specially preserve string & {}, number & {}, bigint & {}

* Accept new baselines

* Add additional tests

* Fix getNormalizedType and getNarrowableTypeForReference for intersections

* Switch NonNullable<T> to use T & {}

* Accept new baselines

* Use NonNullable<T> in place of anonymous T & {}

* Accept new baselines

* Add fourslash test

* More fourslash tests

* Fix getFalsyFlags handling of intersections

* Accept new baselines

* Add constraint to compareProperties type parameter

* Unconstrained type parameter not assignable to {} with strictNullChecks

* Accept new baselines
2022-05-27 14:02:54 -07:00
Ron Buckton
ba4525202e
More specific inference for constrained 'infer' types in template literal types (#48094)
* More specific inference for constrained 'infer' types in template literal types

* PR feedback

* Add inference priority for template type placeholders

* Infer to a preferred constraint instead of a union

* Add reduceType

* Switch tests to use infer..extends

* Add missing primitive constraint cases

* Update .types tests

* Remove TemplateTypePlaceholderPriority

* Remove reduceType
2022-05-27 11:05:24 -07:00
TRCYX
38631e6412
fix(30003): formatter deletes comment after trailing comma (#49168)
Co-authored-by: TRCYX <trcyxs@gmail.com>
2022-05-27 10:09:52 -07:00
Andrew Casey
757a3acbde
Port #48978 forward to the revised FAR code (#49267)
* Port #48978 forward to the revised FAR code

The old regression test didn't catch the corresponding bug in the new code because it hit the fast path where there's only a single project.

* Drop spurious non-null assertion
2022-05-27 09:52:20 -07:00
TypeScript Bot
46e53016e4 Update package-lock.json 2022-05-27 06:07:28 +00:00
Wesley Wigham
67673f324d
moduleDetection: auto makes cjs files parse as modules, module: node sets moduleDetection: force (#49268) 2022-05-26 16:49:55 -07:00
Andrew Branch
5b86612f68
Fix crash from inaccurate type guard implementation (#49252)
* Fix `isVariableDeclarationInitializedToBareOrAccessedRequire` returning true on binding elements

* Undo auto format change
2022-05-26 16:43:22 -07:00
Andrew Casey
84974838c7
Handle the case where the FAR results map is empty (#49254)
* Handle the case where the FAR results map is empty

Searching exactly one project does not imply the presence of exactly one references list.

Fixes #49217

* Use emptyArray

Co-authored-by: Sheetal Nandi <shkamat@microsoft.com>

Co-authored-by: Sheetal Nandi <shkamat@microsoft.com>
2022-05-26 11:00:28 -07:00