16350 Commits

Author SHA1 Message Date
Will Nayes
501e442ffc
Elide import equals in transpileModule if referenced only by export type (#49664)
* Elide import equals in transpileModule if referenced only by export type.

* Revise approach to avoid marking alias in export type as referenced.

* Handle type only export specifier.
2022-07-05 09:08:43 -07:00
Ron Buckton
c6ff5f3b52
Fix for Awaited<T> inference (#49748) 2022-07-01 15:00:54 -07:00
Andrew Branch
f8aa570b23
Get type arguments lazily for instantiating inferred type parameter constraint (#49744)
* Get type arguments lazily for instantiating inferred constraint

* Use new deferred type mapper
2022-06-30 16:23:07 -07:00
Wesley Wigham
4c34f2c792
Fix mapper used to instantiate distributive conditional manufactured in declaration emit (#49737) 2022-06-30 15:03:25 -07:00
Sheetal Nandi
c251d60095
Instead of storing timestamp of when last d.ts file was modified, store its name so buildinfo becomes portable again (#49717)
* Store dts change file path in buildinfo

* With composite, do not write d.ts files if they changed

* Determine dts change based on outputs

* Instead of storing time in buildinfo store filename which was last updated to get modified time stamp from

* Get declaration time change lazily

* Rename per feedback
2022-06-30 09:49:27 -07:00
Andrew Branch
93f2d2b9a1
Add variance results to tracing, capture variance verification on annotated type params (#49712)
* Add variance results to tracing

* Tweak format, prohibit `results` on `E` events
2022-06-29 16:30:57 -07:00
Mateusz Burzyński
bd11ce2aeb
Fixed an issue with self-referential awaited union (#49677) 2022-06-29 13:01:36 -07:00
Jake Bailey
b379e7fc79
Pass contextFlags when getting contextual type of JSX elements/attributes (#49707) 2022-06-28 14:40:26 -07:00
Andrew Casey
2f86a83dff
Fix mis-completed variable name in tracepoint (#49715) 2022-06-28 14:32:44 -07:00
Sheetal Nandi
7e91485bec
Use value meaning for computed property name for visibility check (#49678)
* Test

* Use value meaning for computed property name
Fixes #49562
2022-06-27 15:16:33 -07:00
Sheetal Nandi
df21926976
To handle d.ts emit errors that could affect other files, in incremental mode use d.ts emit text + diagnostics as signature of the file (#49543)
* Add test when declaration emit has errors and d.ts emit doesnt change which results in incorrect incremental behaviour

* Refactor

* Use declaration diagnostics in the d.ts signature for the file so it can be more accurate for detecting changes to file that could affect other files
Fixes #49527

* Renames and clarifications

* Simplify serialize declaration diagnostics for signature purpose
Do not serialize file name if error is in same file we are emitting. this should avoid having to do file path computation in most cases.
Locations are start and length instead of line and character.
Do not use any indents

* Fix baselines
2022-06-27 15:02:11 -07:00
Andrew Branch
2bc91a6b46
Fix parser TODO (#49679) 2022-06-27 09:05:41 -07:00
Jake Bailey
569cdf1b07
Disallow expression with type parameters as left side of property access (#49464) 2022-06-24 15:54:21 -07:00
Andrew Casey
020ef41543
Add a simple queue implementation with better performance than Array.shift (#49623)
* Add a simple queue implementation with better performance than `Array.shift`

This lets us clean up the hack introduced in #49581

* Correct typo

Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>

Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
2022-06-24 10:07:28 -07:00
Oleksandr T
8636adbbb9
fix(49449): change error location when passing objects/arrays to an argument of type (#49593) 2022-06-22 10:06:01 -07:00
Jake Bailey
71b5bdf980
Ensure resolved signature is cached before processing call errors (#49598) 2022-06-21 13:15:03 -07:00
Anders Hejlsberg
529ba99e29
Use separate marker types for variance annotation validation (#49616)
* Use separate marker types for variance annotation validation

* Add regression test
2022-06-21 06:42:10 -07:00
Jake Bailey
d7e58c8ea9
Fix arrow expressions in conditional expressions, take N+1 (#49531) 2022-06-17 16:34:27 -07:00
Andrew Branch
7e7c53961a
Add TS Server option to exclude files from auto-imports (#49578)
* Basic functionality

* Add tests

* Add test for ambient modules

* Add to protocol
2022-06-17 14:39:51 -07:00
Andrew Branch
1213c35d57
Add error when importing/exporting types in JS files (#49580)
* Add error when importing/exporting types in JS files

* Ignore type-only imports, update other baselines

* Clean up
2022-06-17 14:39:24 -07:00
Wesley Wigham
5c4caafc2a
Allow nongeneric string mapping types to exist (#47050)
* Allow nongeneric string mapping types to exist

* Accept baseline

* Recusive membership testing function

* Fix lint

* Add @DanielRosenwasser's comment
2022-06-16 17:02:31 -07:00
Gabriela Araujo Britto
86d5040031
Fix renaming of node_modules (#49568)
* add bug repro test

* add test and start fix implementation

* adjust for useAlias preference

* fix existing renaming test

* refactor to get rid of options

* fix named bindings & other imports cases

* fix eslint error

* address cr comments

* hopefully actually fix eslint

* clean up stale baseline

* make API change non-breaking

* add/fix comments
2022-06-16 17:01:44 -07:00
Oleksandr T
f83ce9bd9c
fix(49566): Implicit this.property completions not returned while writing property (#49574)
* fix(49566): show this.prop completions in class scoped property declaration

* remove duplicate default value
2022-06-16 12:43:50 -07:00
Anders Hejlsberg
18ac37221b
Properly re-scan > token in type argument list determination logic (#49560)
* Properly re-scan '>' token in type argument list determination logic

* Add regression test
2022-06-15 12:06:08 -07:00
Wesley Wigham
ba38fe1df2
Expand constraint suggestion related span and add quick fix (#49481)
* Expand constraint suggestion related span and add quick fix

* Remove circular constraint suggestions

* Add error code

* Style feedback and new error code in quickfix
2022-06-15 10:35:51 -07:00
Wesley Wigham
eb4b8a4d2e
Handle this in isEntityNameVisible (#49521) 2022-06-15 10:15:19 -07:00
Oleksandr T
0ada54c006
fix(49483): throw error on await inside non-async function (#49496) 2022-06-14 16:08:25 -07:00
uhyo
29dffc3079
Forbid unused property renaming in destructuring binding in function types (#41044)
* Forbid renaming a propertyin function type parameters

* add tests

* Remove renaming from declaration output

* accept baseline

* accept baseline

* renew tests (not very right now)

* get correct result

* update diagnostic text

* accept baseline

* add declaration emit test

* fix declaration emit

* fix formatting

* revert unnecessary change

* accept baseline

* extend tests

* Revert "revert unnecessary change"

This reverts commit 17a29fff6c4ce48e9c3f13b55332ce3411c90dc4.

* accept baseline

* Rename and refactor potentialAlways... stuff

* add non-identifier names

* extend check to non-identifier original property names

* update diagnostic message

* add related span

* accept baseline

* add symbol-keyed test case

* oops?

* workaround for unstable test

* fix suggested name

* add comment about non-identifier property names

* simplify isReferenced check

* accept baseline

* move it one step further
2022-06-14 12:13:49 -07:00
bentongxyz
dbab6eb898
fix #49235 Objects that pass the spread syntax can no longer be assigned to assignable types. (#49337)
* fix issue 49235

* update code with suggested changes

Co-authored-by: Benjamin Tong <benjamin.tong@iddy.ai>
2022-06-14 10:43:18 -07:00
Sheetal Nandi
4c1e8f2281
Fix incorrectly added resolution to resolutionsWithOnlyAffectingLocations (#49523) 2022-06-13 22:46:41 -07:00
Anders Hejlsberg
dc6a80bd00
Fresh {} is subtype of object (#49503)
* Fresh {} is subtype of object

* Add regression test
2022-06-13 12:21:51 -07:00
Jake Bailey
e9ba547d6e
Eliminate (ts as any).SyntaxKind (and similar) in favor of Debug.format functions (#49485) 2022-06-10 16:15:15 -07:00
Jake Bailey
678afe8b9c
Improve performance of Debug.format functions (#49487) 2022-06-10 16:14:59 -07:00
Anders Hejlsberg
e6808c4290
Instantiation expression can be followed by line break or binary operator (#49353)
* Allow instantiation expression to be followed by let or interface on new line

* Add tests

* Update src/compiler/parser.ts

* Instantiation expressions followed by line breaks or binary operators

* Add more tests

* Accept new baselines

* Fix lint error

* Update fourslash test

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
2022-06-10 10:26:42 -07:00
Ron Buckton
1e65b330a7
Merge 'decorators' into 'modifiers' on various nodes (#49089)
* Merge 'decorators' into 'modifiers' on various Nodes

* Drop RESERVED argument in favor of removing parameter

* Ignore grammar error nodes when asserting invariants

* Revert 'illegalX' property renames

* PR Feedback
2022-06-09 17:24:02 -07:00
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
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
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
62668c6c1d
feat(47558): check JSDoc link tags in TypeScript/JavaScript files (#47822) 2022-06-06 09:04:18 -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