1378 Commits

Author SHA1 Message Date
Sheetal Nandi
3eafb64faf
Handle reusing type reference resolution in resolution cache correctly (#51475)
* Add tests where typeRef resolution is not in the cache

* Ensure that type ref reuse is actually handled since type ref resolution only sends containingSourceFileMode and not containingSourceFile
2022-11-10 16:03:25 -08:00
Sheetal Nandi
57a916c455
Emit buildinfo if file deleted isnt global (#51472)
* Add test for when file is deleted

* Emit buildinfo if file deleted isnt global
2022-11-09 18:07:17 -08:00
Jake Bailey
9f64a3a58c
Remove ts.{Map,Set,ESMap,Iterator} and associated types (#51439) 2022-11-09 15:06:31 -08:00
Jake Bailey
d798493647
Remove no-unnecessary-qualifier from eslintrc (#51456) 2022-11-09 15:02:29 -08:00
Sheetal Nandi
6e0a62e8dd
Detangle unittests to reference helpers directly (#51450)
* Remove unnecessary redirection now that we are not in namespaces

* Move the tsc helpers in one place

* Move virtual file system with watch in unittests folder instead of harness since harness doesnt use it anyways

* Replace protocol and commandNames

* Revert incorrect pick
2022-11-09 10:02:40 -08:00
Sheetal Nandi
48aebcdcdb
TypeReference directive reuse (#49750) 2022-11-07 15:15:11 -08:00
Jake Bailey
776907cd4d Add ts to globalThis in run.js for convenience during debugging
In namespaces, we'd have access to a variable named "ts" when debugging,
because that was just the ts namespace in the current file. But when
modules, that variable doesn't exist, either because we are pure modules
(so no ts variable), or named something else (when bundled, for export).

Tack a "ts" object onto the globals, which should make this easier. Of
course, someone may eventually declare a variable in the top level scope
named "ts" and break this, but we can cross that bridge when we come to
it.
2022-11-07 13:35:48 -08:00
Jake Bailey
4139807e75 Add build via esbuild
This configures the existing build tasks to use esbuild by default. If
using the plain files is desired, passing `--bundle=false` will build
using plain files and still produce a runnable system.

This is only a basic build; a more efficient build is provided later
when gulp is replaced by hereby.
2022-11-07 13:34:44 -08:00
Jake Bailey
36e29448e9 Get codebase building pre bundling
This isn't totally complete, but enough to get everything building and
tests running manually. The next commit will make the build work fully.
2022-11-07 13:34:44 -08:00
Jake Bailey
01e5200096 Convert require calls to imports
Although the existing require calls would work fine, it's more
consistent to make them actual imports and let them be converted at
compile/bundle time. It also lets us emit ESM if needed.

There are still conditional requires present for things like the node
System, but that's a more difficult problem to solve.
2022-11-07 13:34:44 -08:00
Jake Bailey
39e27fbb6b Fix up linting, make lint clean
Now that we are modules, there's no reason to ban multiple namespaces
per file; each file is its own scope and declaring a namespace won't
merge it into any other files.
2022-11-07 13:33:07 -08:00
Jake Bailey
07758c08ab Generated module conversion step - inlineImports
This step converts as many explicit accesses as possible in favor of direct imports from the modules in which things were declared. This restores the code (as much as possible) back to how it looked originally before the explicitify step, e.g. instead of "ts.Node" and "ts.Symbol", we have just "Node" and "Symbol".
2022-11-07 13:33:07 -08:00
Jake Bailey
b6c0538826 Generated module conversion step - stripNamespaces
This step converts each file into an exported module by hoisting the namespace bodies into the global scope and transferring internal markers down onto declarations as needed.

The namespaces are reconstructed as "barrel"-style modules, which are identical to the old namespace objects in structure. These reconstructed namespaces are then imported in the newly module-ified files, making existing expressions like "ts." valid.
2022-11-07 13:32:03 -08:00
Jake Bailey
9a0b85ce2a Generated module conversion step - explicitify
This step makes all implicit namespace accesses explicit, e.g. "Node" turns into "ts.Node".
2022-11-07 13:29:05 -08:00
Jake Bailey
94724a8c2e Generated module conversion step - unindent
This step makes further commits look clearer by unindenting all of the top level namespaces preemptively.
2022-11-07 13:28:13 -08:00
Sheetal Nandi
7b0df1ff99
Pass in information for the module name resolution when resolutions from file are partially used (#49738)
* Test showing wrong resolution is returned because of incorrect mode calculation
Test for #48229

* Pass in information for the module name resolution when resolutions from file are partially used
Fixes #48229

* Make the resolution info complete
2022-11-07 11:51:04 -08:00
Sheetal Nandi
eac566b8c3
Enables passing --declaration, --emitDeclarationOnly, --declarationMap, --soureMap and --inlineSourceMap to tsc --build (#51241)
* Add different tests for baselining before behavior

* Fix assert for first project output

* Add ability to pass declaration, declarationMap, emitDeclarationOnly, sourceMap and inlineSourceMap on commandline of --build

* Store these options in --out scenario

* Store buildInfo program for --out even if not composite

* Changes to make these commanline options work

* Do not include sourceMapUrl text in the sourceFile version

* Emit complete program in --out scenario as well since we need to determine uptodate ness

* Copy js or dts bundle from old build if emitting only js or dts files

* Dont emit dts if we want to emit only js files even though options suggest emitting d.ts files as well

* Adding comments and refactoring some of the code
2022-11-07 10:53:22 -08:00
Sheetal Nandi
5e3fa9b87b
There is no use of creating reference map with --out since its not used anyways (#51379)
* Convert some of the tests to baselines

* There is no use of creating reference map with --out since its not used anyways.
The changes to affectedFileList returned should be intended since --out needs saving just one file for correct output and not both
2022-11-03 15:30:32 -07:00
Sheetal Nandi
8ed84e1c85
Write original fileInfo when its not just string = version = signature in readable baseline (#51391) 2022-11-02 13:55:20 -07:00
Sheetal Nandi
7c580111df
Set impliedNodeFormat on sourceFile we get from host to ensure the field is set correctly (#50977)
* Add test that fails

* Handle impliedNodeFormat when handling sourceFileCache
Fixes #50872

* Revert the fix

* Make sure impliedNodeFormat is set for the sourceFile

* Revert "Make sure impliedNodeFormat is set for the sourceFile"

This reverts commit 651a47fdd6ea200e59fdf150dfa913230a86653a.

* Revert "Revert the fix"

This reverts commit 5c98b9cfc1f275877d8d57a60f8f28a5c8d08157.

* Swap the keys for map
2022-10-31 11:26:36 -07:00
Sheetal Nandi
cfa55f1c2d
Fixes the tests that got disabled when generating config set es2016 expecting to find libFile and remove incorrect affects flag from listFilesOnly (#51243)
* Fix the existing test

* Remove affectsEmit from listFilesOnly
2022-10-31 10:15:19 -07:00
Sheetal Nandi
18f559faf9
Store array only if dtsOnly emit is pending to compress buildinfo (#51246) 2022-10-31 10:14:22 -07:00
Ron Buckton
5cfb3a2fe3
Only call return() for an abrupt completion in user code (#51297) 2022-10-28 18:36:40 -04:00
Ron Buckton
702de1eeaa
Fix early call to return/throw on generator (#51294) 2022-10-24 22:37:42 -04:00
Oleksandr T
d0bfd8caed
fix(51072): ts.preProcessFile finds import in template string after conditional expression with template strings (#51082) 2022-10-07 10:33:20 -07:00
Jake Bailey
ad56b5ca56
Convert scripts/Gulpfile to checked mjs/cjs so they can run without compilation (#50988) 2022-10-07 09:50:46 -07:00
Oleksandr T
dbeae5d943
fix(51017): Make lineText in the references response opt-out (#51081)
* add option to exclude lineText from the response

* add comments

* update baseline
2022-10-07 09:13:22 -07:00
Sheetal Nandi
2648f6ab09
Plugins in project were adding up after every config file reload (#51087)
* Add test where current plugins dont get reset when reloading config file

* Reset loaded plugins when reloading configured project and closing project
2022-10-06 13:40:21 -07:00
Sheetal Nandi
43c6fd4c09
Covert some of the config testing to baselines for easy validation (#51063)
* Baseline config tests for easy validation

* Refactor

* Fix incorrect pick

* Dont print unnecessary plugin host not implemented msg in logs
2022-10-04 18:14:14 -07:00
Sheetal Nandi
fc5e72b92c
Remove unused defaultWatchFileKind method since useFsEvents is default for tsserver and tsc (#51044) 2022-10-04 15:06:41 -07:00
Ron Buckton
865848fcfb
Fix <= and > comparisons when compared against prerelease versions (#50915)
* Fix <= and > comparisons when compared against prerelease versions

* Improve coverage for semver
2022-09-28 18:46:06 -04:00
Sheetal Nandi
8192d55049
Pick correct compilerOptions when checking if we can share emitSignatures (#50910)
* Pick correct compilerOptions when checking if we can share emitSignatures
Fixes #50902

* Add a note

* Rewording
2022-09-27 21:34:39 -07:00
Sheetal Nandi
16faef1d8d
During uptodate ness check with buildInfo, check if there are errors explicitly with noEmit (#50974)
* Add test

* During uptodate ness check, with buildInfo, check if there are errors in the program to determine uptodateness
Fixes #50959

* Comment update
2022-09-27 15:57:29 -07:00
Sheetal Nandi
09368bcbae
Handle if project for open file will get recollected because of pending cleanup from closed script info (#50908)
* Handle if project for open file will get recollected because of pending cleanup from closed script info
Fixes #50868

* Rename
2022-09-26 12:40:23 -07:00
Daniel Rosenwasser
9740bcc534
Pluralized hasInvalidatedResolution -> hasInvalidatedResolutions (#50912)
* Pluralize hasInvalidatedResolution to hasInvalidatedResolutions.

* Accepted baselines.
2022-09-22 18:33:09 -07:00
Sheetal Nandi
a455955aac
Make hasInvalidatedResolution non internal for program and add it watchApi (#50776)
* Make stub for hasInvalidatedResolution

* Wire through hasInvalidatedResolutions
Fixes #48057

* Update comment

* Feedback
2022-09-22 16:51:53 -07:00
Oleksandr T
4d91204c9d
fix(37030): Expand Selection in function and arrow function skips body block (#50711)
* fix(37030): include curly braces from function body in the selection

* add missed sourceFile argument
2022-09-21 10:47:24 -07:00
Jake Bailey
16156b1baf
Add rules from eslint's recommended set that triggered good lints (#50422) 2022-09-19 16:20:55 -07:00
Gabriela Araujo Britto
48a8e8953a
Improve check of whether type query node possibly contains reference to type parameter (#50070)
* WIP

* implement typequery contains reference check + tests

* add unit test

* fix unit test

* use symbols in scope to check type query type parameter references

* remove comment on unit test

* remove comment

* use isNodeDescendantOf implementation to check scoping

* CR: small fixes

* treat the different kinds of type parameter declarations

* undo test change
2022-09-18 21:13:30 -07:00
Sheetal Nandi
a88c36655b
Fix test baselining for tsserver host timeouts (#50748) 2022-09-12 20:36:24 -07:00
Sheetal Nandi
6b890f93c4
Handle more places where package direcroy is converted to canonical file path (#50740)
* Add test for node16 resolution with package json lookup making casing incorrect

* Handle more places where package direcroy is converted to canonical file path
2022-09-12 15:11:35 -07:00
Ron Buckton
a4cabe725b
Support for auto-accessor fields from the Stage 3 Decorators proposal (#49705)
* Support for auto-accessor fields

* Add tests, ensure accessors are initialized in ctor

* classFields cleanup and PR feedback
2022-09-12 15:12:11 -04:00
Sheetal Nandi
7c918fb766
Baseline host state when baselining tsserver tests (#50678)
* Some more formatting to have baselines similar to what we have in tsserver.log

* Some refactor

* Baselines

* Baseline host details on each request

* More formatting per tsserver log

* More baselining of host state

* Update Baselines and/or Applied Lint Fixes

* Use utc time in logger for baselines

Co-authored-by: TypeScript Bot <typescriptbot@microsoft.com>
2022-09-08 12:31:14 -07:00
Amit Dahan
ab831d0180
Ignore --help and -? in tsc init generated compilerOptions (#50628)
* Ignore --help and -? in `tsc init` generated compilerOptions

* Disregard -?

* Remove unused fixture
2022-09-07 12:43:16 -07:00
Sheetal Nandi
fd05c0cc6d
Make useFsEvents as default strategy for the watching (#50366)
* Remove unnecessary parameter

* Dont store name unnecessarily in the watchers

* Polled watches and not files

* Use fs events as default watching

* Some refactoring

* Make single per directory native watchers now that we are using it as default

* Rename

* Comment
2022-09-06 13:14:50 -07:00
Sheetal Nandi
62f980aff8
Check if its same buildinfo only for directly referenced projects and not recursively (#50617)
Fixes #50545
2022-09-02 13:38:00 -07:00
Sheetal Nandi
298309271b
Do not canonicalize the file names when getting absolute paths during nodenext resolution (#50557)
* Add test to show how scope messes with casing

* Do not canonicalize the file names when getting absolute paths
Fixes #50544

* Unnecessary exports

* Add test for self referencing package

* Fix self reference package with casing
2022-09-01 06:48:41 -07:00
Sheetal Nandi
d293e723a2
Rename API to importPlugin (#50554)
* Rename API to importPlugin

* Make it internal too
2022-08-31 14:21:56 -07:00
Ryan Cavanaugh
3557092b14
Rephrase error message to be 100% technically correct (#50471) 2022-08-26 14:22:49 -07:00
Oleksandr T
164dddc48e
feat(7481): Operator to ensure an expression is contextually typed by, and satisfies, some type (#46827)
* feat(7481): add explicit type compatibility check with 'satisfies' expression

* Add failing test for lack of intersectioned contextual type

* Implement the behavior

* Add test corresponding to the 'if'

* Add test based on defined scenarios

* remove isExpression in favor of using type casting

* move tests from compiler to conformance folder

* update baseline

* add missing contextFlags argument

* use asserted type

* accept baseline

Co-authored-by: Ryan Cavanaugh <ryanca@microsoft.com>
2022-08-26 10:05:52 -07:00