61 Commits

Author SHA1 Message Date
Andrew Casey
3db6d803d5
Don't build type catalog during server tracing (#43354)
Bonus: this also drops the redundant type catalog from the
non-diagnostics-producing checker.
2021-03-25 15:52:04 -07:00
Sheetal Nandi
0cf834ceec
Move fixed chunk size polling as a watch option and move it out of server (#42542)
* Move fixed chunk size polling as a watch option and move it out of server
Fixes #41549

* Feedback
2021-03-02 16:45:53 -08:00
Eli Barzilay
4fc9c8446d Refactor the tracing namespace organization
Also changes the `tracingEnabled.Mode.*` enum to a string union.
2021-02-11 16:08:35 -05:00
Eli Barzilay
f462576ac2 Re-do tracing initialization and tests around calls
Make `tracing` either `undefined` or the same namespace as before.
Switching all calls to `tracing?.___` means that there is no cost for
a call or the arguments when tracing is not used.  Comparing two runs
without tracing (27 runs, drop 5+5, avg rest) I get:

    master:
      42.59s user 1.00s system 165% cpu 26.372 total
    changed:
      42.01s user 0.982 system 165% cpu 26.039 total

(Makes it all private, so no api changes.)
2021-02-08 15:41:35 -05:00
Matt Bierner
49d7de17d6
Adds experimental support for running TS Server in a web worker (#39656)
* Adds experimental support for running TS Server in a web worker

This change makes it possible to run a syntax old TS server in a webworker. This is will let serverless versions of VS Code web run the TypeScript extension with minimal changes.

As the diff on `server.ts` is difficult to parse, here's an overview of the changes:

- Introduce the concept of a `Runtime`. Valid values are `Node` and `Web`.
- Move calls to `require` into the functions that use these modules
- Wrap existing server logic into `startNodeServer`
- Introduce web server with `startWebServer`. This uses a `WorkerSession`
- Add a custom version of `ts.sys` for web
- Have the worker server start when it is passed an array of arguments in a message

In order to make the server logic more clear, this change also tries to reduce the reliance on closures and better group function declarations vs the server spawning logic.

**Next Steps**
I'd like someone from the TS team to help get these changes into a shippable state. This will involve:

- Adddress todo comments
- Code cleanup
- Make sure these changes do not regress node servers
- Determine if we should add a new `tsserver.web.js` file instead of having the web worker logic all live in `tsserver.js`

* Shim out directoryExists

* Add some regions

* Remove some inlined note types

Use import types instead

* Use switch case for runtime

* Review and updates

* Enable loading std library d.ts files

This implements enough of `ServerHost` that we can load the standard d.ts files using synchronous XMLHttpRequests.

I also had to patch some code in `editorServices`. I don't know if these changes are correct and need someone on the TS team to review

* Update src/tsserver/webServer.ts

* Update src/tsserver/webServer.ts

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

* Addressing feedback

* Allow passing in explicit executingFilePath

This is required for cases where `self.location` does not point to the directory where all the typings are stored

* Adding logging support

* Do not create auto import provider in partial semantic mode

* Handle lib files by doing path mapping instead

* TODO

* Add log message

This replaces the console based logger with a logger that post log messages back to the host. VS Code will write these messages to its output window

* Move code around so that exported functions are set on namespace

* Log response

* Map the paths back to https:
// TODO: is this really needed or can vscode take care of this
How do we handle when opening lib.d.ts as response to goto def in open files

* If files are not open dont schedule open file project ensure

* Should also check if there are no external projects before skipping scheduling
Fixes failing tests

* Revert "Map the paths back to https:"

This reverts commit 0edf650622da11e89e42238523d57f3ea780cdcf.

* Revert "TODO"

This reverts commit 04a4fe75563ea9fe4747d42a4448d5dd421fbba5.

* Revert "Should also check if there are no external projects before skipping scheduling"

This reverts commit 7e4939014a414c7651f1fa01516c81a37a10e9be.

* Refactoring so we can test the changes out

* Feedback

Co-authored-by: Sheetal Nandi <shkamat@microsoft.com>
2020-12-08 16:09:43 -08:00
Andrew Casey
669305b914
Pass throwIfNoEntry to fs.statSync (#41604)
Future versions of node will be able to return undefined, rather than
allocating and throwing an exception, when a file is not found.

See https://github.com/nodejs/node/pull/33716
2020-11-23 12:43:00 -08:00
Andrew Casey
79ffd03f8b
Add tracing support to tsserver (#41374)
* Add tracing support to tsserver

Read the `TSS_TRACE` environment variable to determine which directory
trace files should be written to.

Notable changes from tsc tracing:
1) Drop all tracepoints that depend on type IDs
2) Write output to trace.PID.json
3) New, server-specific events (request/response, cancellation, etc)

* Drop try-finally blocks that aren't strictly necessary

* Fix lint error

* Trace background work (for diagnostics)

* Move try-finally blocks into session so tsc doesn't use them

* Add missing try-finally

* Use consistent capitalization

* Inline canPop call where underlying variable is available

* Clarify comments

* Include PID in build-mode file names

* Introduce more efficient popAll function

* Trace throwIfCancellationRequested rather than isCancellationRequested

* Remove unnecessary try-finally blocks

* Add a command-line argument for consistency with logging

* Fix rebase issues

* Address PR feedback

* Rename completionEvents to eventStack

* Drop assertStackEmpty as hard-to-maintain and marginally valuable

* Rename stepCancellation to stepCanceledEarly

* Rename stepEarlyCancellation to stepCanceled and use flag instead

* Check correct variable on exit
2020-11-16 09:26:28 -08:00
Daniel Rosenwasser
373b352333
Rename 'compat' to 'deprecatedCompat'. (#41000) 2020-11-02 14:25:12 -08:00
Jack Works
ad96a52cc6
fix: IOSession access this before calling super (#40645)
* fix: IOSession access this before calling super

close #40399 

This makes the TS server crashes if the build target is ES6 or higher.

* fix

* revert unrelated changes

* revert unrelated changes

* revert unrelated changes

* better way
2020-10-15 11:01:26 -07:00
Sheetal Nandi
da5ff57608
Renames in servermode per feedback (#39883)
* Server mode renames as per feedback

* More renames
2020-08-05 12:19:15 -07:00
Sheetal Nandi
aee78acedb
Add separate flag serverMode for server mode (#39735)
* Add separate flag serverMode for server mode to allow back compatibility

* Addressed code review feedback.

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
2020-08-02 18:18:26 -07:00
Ron Buckton
9d5cd280ef Merge branch 'master' into migrateMapsAndSets
# Conflicts:
#	src/compiler/checker.ts
#	src/compiler/commandLineParser.ts
#	src/compiler/core.ts
#	src/compiler/moduleNameResolver.ts
#	src/compiler/transformers/declarations.ts
#	src/compiler/tsbuildPublic.ts
#	src/compiler/types.ts
#	src/compiler/utilities.ts
#	src/harness/client.ts
#	src/server/editorServices.ts
#	src/server/typingsCache.ts
#	src/server/utilities.ts
#	src/services/codefixes/convertToAsyncFunction.ts
#	src/services/documentRegistry.ts
#	src/services/importTracker.ts
#	src/services/refactorProvider.ts
#	src/services/refactors/extractSymbol.ts
#	src/testRunner/unittests/programApi.ts
#	src/typingsInstallerCore/typingsInstaller.ts
#	tests/baselines/reference/api/tsserverlibrary.d.ts
#	tests/baselines/reference/api/typescript.d.ts
2020-07-07 13:53:46 -07:00
Ron Buckton
7b942b4fa8
Revert the type change to ts.Map (#39366) 2020-07-01 17:00:26 -07:00
Ron Buckton
611b77f2e6 Migrate more places to use Map/Set 2020-06-26 10:15:53 -07:00
Ron Buckton
eb2f4e2337
Switch to ES Map/Set internally (#33771)
* Add full implemention of Map and Set to shims

* Update default Map interface

* Remove WeakMap/WeakSet

* Add tests for set shim

* Update most usages of Map<K, true> to Set

* PR Feedback

* Fix lint issues

* Change key in fsWatchCallback

* Simpler shim, more tests

* Fix typo in collection shim
2020-06-26 10:12:47 -07:00
Ron Buckton
eb3645f16b
Refactor node factory API, use node factory in parser (#35282)
* Refactor node factory API, use node factory in parser

* Move UnparsedSource nodes to factory

* Make most Node properties read-only

* Make pos/end/parent and JSDoc 'comment' read-only

* Update function/constructor-type factories

* Remove treeStateObserver

* Simplify Debug.deprecate

* Remove unused factory methods, simplify lazy factory methods

* Fix base factory used for source file updates

* Update test baseline due to merge from master

* Rename factory methods to be more consistent (#39058)
2020-06-16 16:55:03 -07:00
Iku Iwasa
5e0f584b67
Support NetBSD platform (#34756) 2020-03-10 14:53:37 -07:00
Wesley Wigham
77d3a69039
Fix lint 2020-02-19 17:03:10 -08:00
Wesley Wigham
283bf999df
Cast sys.bufferFrom results in cases where global buffer and sys copy of buffer mismatch 2020-02-19 17:02:30 -08:00
Sheetal Nandi
80ad0de87e
Fixes to handle file names in module resolution watching and createGetCanonicalFileName (#36106)
* Add test case to verify directory casing preservation when watching

* Fix unicode file name handling when watching failed lookup locations

* Add special file name lower conversion routine and use that instead of toLowerCase
Fixes #31819 and #35559

* Remove unicode from code

* Replace toLocaleLowerCase on filenames with ts.toFileNameLowerCase

* Make the intent of using toFileNameLowerCase more clear and why we make the restriction on turkish I with dot on top of it

* Update baselines for newly added tests in master
2020-01-31 10:40:57 -08:00
Sheetal Nandi
236012e47b
Add watchOptions to tsconfig and allow supplying them on command line as well (#35615)
* Create different watch options in compiler options

* Thread through the new watch options

* Actually use the options passed through for watch strategy

* Support delay on updating child directory watches

* Make watchOptions separate from compilerOptions

* Support passing watch options from command line

* Handle displaying of watchOptions
2019-12-11 13:26:44 -08:00
Alexander T
6988e25985 Merge branch 'master' of https://github.com/Microsoft/TypeScript into feature/eslint 2019-08-09 09:39:36 +03:00
Alexander
536f59cd7d fix formatting 2019-08-08 21:49:10 +03:00
Alexander
ceccfd8867 array-type: [ default: array, generic: array ] 2019-08-08 21:30:18 +03:00
Orta
b70f894881
Merge pull request #32668 from orta/fix_31209
Suppress console.log & others inside the TS Server runtime so that language service plugins don't accidentally use them and kill the server
2019-08-08 08:56:35 -07:00
Alexander
481d70d50d Merge branch 'master' of https://github.com/Microsoft/TypeScript into feature/eslint 2019-08-07 21:23:10 +03:00
Orta Therox
f8b7a05777 Handle the variadic args for inline console.logs 2019-08-06 14:09:37 -04:00
Orta Therox
f04c7ed833 Supress console.log & others inside the TS Server runtime so that language service plugins don't accidentally use them and kill the server - fixes #31209 2019-08-01 17:36:09 -04:00
Michael Crane
fa3e9c86db Add PerfLogger and NullLogger to simplify conditional logic 2019-08-01 12:46:33 -07:00
Bill Ticehurst
996e7e50d5 Use optional module "@microsoft/typescript-etw" for ETW logging 2019-07-29 15:32:40 -07:00
Alexander T
2c32308f35 no-null/no-null 2019-07-18 10:50:38 +03:00
Alexander T
a8ee8fbe87 Merge branch 'master' of https://github.com/Microsoft/TypeScript into feature/eslint 2019-07-18 10:00:16 +03:00
Sheetal Nandi
49ba408e4f Handle scoped package names in typing installer
Fixes #32075
2019-07-16 11:13:03 -07:00
Alexander T
769bb0b475 remove tslint configuration 2019-06-27 13:49:35 +03:00
Alexander T
f6a50067d3 @typescript-eslint/indent 2019-06-27 11:30:03 +03:00
Alexander T
a18aeee1eb @typescript-eslint/no-unnecessary-qualifier 2019-06-14 12:34:28 +03:00
Alexander T
bea1bcb466 brace-style 2019-06-14 10:51:09 +03:00
Alexander T
f96fb53e4c no-restricted-globals 2019-06-14 10:12:06 +03:00
Ryan Cavanaugh
885d4d63c8
Remove "generate types" code (#31075) 2019-04-23 13:51:47 -07:00
Matt Bierner
7ccc89b0d7 Check to make sure default npm exists at path before trying to use it (#30910)
* Check to make sure default npm exists at path before trying to use it

**Bug**
If the typings installer is run under a copy of node that does not include npm—but on a machine that does have npm installed—it will incorrectly try to use the npm that does not exist next to its running version of node

**Fix**
Make sure that we check that npm we select exists before trying to use it as the default. Otherwise, fall back to using plain old `npm`

* Add command line flag to gate new behavior

* Fix missing semicolon
2019-04-18 14:24:41 -07:00
Ryan Cavanaugh
02a5ef6a17 Add setInterval/setTimeout 2019-02-11 11:26:19 -08:00
Sheetal Nandi
e51a2fe80d Skip declaration emit for files that are just executables 2019-01-25 14:24:35 -08:00
Ron Buckton
60487dc7cb Enable debug info by default when debugging the language server 2019-01-22 15:41:22 -08:00
Ron Buckton
76b78a4df5 Fix crash in signatureHelp 2019-01-22 15:02:30 -08:00
Wesley Wigham
4f7184a587
Fix all new lint failures (#29080) 2018-12-18 11:34:02 -08:00
Andy
12f3d0d54c
Enable --strictPropertyInitialization (#27558)
* Enable --strictPropertyInitialization

* Code review
2018-11-16 16:02:23 -08:00
Andrew Casey
eaf6c692e8
Merge pull request #22776 from amcasey/GH22607
Thread typesMapLocation down to the ProjectService
2018-09-19 10:57:49 -07:00
Andy
c57ff087d6
Add codefix to generate types for untyped module (#26588) 2018-09-18 11:47:29 -07:00
Andrew Casey
1bcb4910ca Thread typesMapLocation down to the ProjectService
Fixes #22607
2018-09-18 10:38:43 -07:00
Nathan Shively-Sanders
64d0e0d448
Shorten more internal names to JS or TS (#27080) 2018-09-13 15:05:57 -07:00