Commit Graph

25080 Commits

Author SHA1 Message Date
Sheetal Nandi
84e475c105 Make resolution cache use sets instead of arrays for easier checking (#51735) 2022-12-06 14:25:19 -08:00
Sheetal Nandi
38f33ade06 Use non relative name cache for type reference resolutions and API updates (#51732)
* Make the non relative name resolution cache generic

* Add cache for non relative type reference resolution

* Add getter only methods so we can use these in future for sharing resolutions across the projects

* Mark existing non relative module name cache getOrCreate as deprecated

* Prefer getters for getting directory results
2022-12-06 14:22:03 -08:00
Jake Bailey
703652cebf Remove some files from the repo root (#51446) 2022-12-06 13:42:54 -08:00
Daniel Rosenwasser
3c99d50da5 Replace a few type assertions with annotations and satisfies. (#51685) 2022-12-06 11:52:17 -08:00
Eric Ferreira
af1d91d9d9 Fix missed errors in switch when using union of literal and non-literal types (#38686) (#51373)
* Fix missed errors in switch when using union of literal and non-literal types (#38686)

This commit makes it so we don’t use the base type of literals when checking comparability in switch. The comparability checks handle that case already, is my understanding, so we don’t need to clobber the type before actually doing the check, causing missed errors.

When comparing the types in switch, if a union with a literal and a non-literal was used, the compiler in `checker.ts` would automatically get the base type of all parts of the union, resulting in missed errors. For example, if the union of the non-literal `number` and literal `"hello"` was compared to the literal `"world"` in a switch case, the compiler would miss that they’re actually not comparable.

Maybe someone can tell me why we were getting the base type before checking comparability, rather than relying on the logic within the comparability checks to handle literal/base type comparability?

* Fix lint (whitespace) issue in checker.ts by running lint with fix flag.
2022-12-06 10:50:21 -08:00
Jake Bailey
bb42b5c1a6 Unconditionally use WeakMap in debug (#51785) 2022-12-06 10:41:39 -08:00
Isabel Duan
ae9c671d59 (fix #50725, #50710) add file extensions in import statements (#51702)
* fixes #50725

* fixed 50710

* fixed broken test

* clean up

* variable rename

* rename variable to newFileBaseName
2022-12-06 09:28:10 -08:00
Nathan Shively-Sanders
5bb204e321 Remove webServer (#51699)
* Remove webServer

First draft; I may move some things around to be more readable.

* Refactor moved code

1. Move StartSessionOptions to common next to where it's first used.
2. Inline single-use BaseLogger base class into its only child class,
Logger.
3. Start using direct imports, eg `import {} from './common'`. I hope
this is OK?!

* Fix lint

* move imports back to namespace import

* hereby tsserver: remove exportIsTsObject
2022-12-06 08:41:01 -08:00
Oleksandr T
0eca6b0edc fix(40365): handle deprecated properties of merged interfaces (#51640) 2022-12-05 15:06:18 -08:00
Wesley Wigham
e9e7a9d49a Fix #51623 (#51762)
* Fix #51623

* Revert newline changes
2022-12-05 12:48:11 -08:00
Wesley Wigham
b23b29b71b Use formatting newline rather than host newline in extractType (#51764) 2022-12-05 12:47:36 -08:00
Lyu, Wei-Da
0c09d2f172 quick fix for a nullable missing callback function (#51743) 2022-12-05 12:23:59 -08:00
Sheetal Nandi
9e845d2248 Api cleanup for Module and Type Reference directive resolution (#51546)
* Refactoring so CacheWithRedirects has Key and Value type parameters

* ModuleResolutionCache or TypeRefDirectiveCache will look in directory before solving, so ResolutionCache doesnt need this check

* Test showing module resolution is not shared because resolution cache doesnt update own options

* Enable traceResolution on some of the project reference tests

* Simplify CacheWithRedirects and ensure the options are set in all common scenarios so cache can be shared between redirects

* Make failedlookup etc optional in ResolvedModule/TypeRefefWithFailedLookupLocations
Also make accidental public failed lookup internal

* Add new API for module and type ref resolution

* Store auto type reference resolutions

* Modify test to show how using program partially doesnt report resolution diagnostics

* Ensure that resolution diagnostics are reported in filePreocessingDiagnostics so they can be reused when program is reused

* Some cleanup

* Remove the newly added ReoslutionInfo in favor of new APIs

* update
2022-12-05 11:56:33 -08:00
Anders Hejlsberg
c07f51242c Fix narrowing by typeof applied to discriminant property (#51720)
* Fix narrowing by typeof applied to discriminant property

* Include effects of getReferenceCandidate

* Add tests
2022-12-05 11:51:54 -08:00
Gabriela Araujo Britto
6a3c9ea125 Exhaustive case completion for switch statements (#50996)
* fix services' type's isLiteral

* update literal completions tests

* initial prototype

* use symbol to expression. TODO: filter existing, replace import nodes

* WIP

* WIP

* remove booleans from literals

* trigger at case keyword positions

* clean up tests

* fix element access expression case

* refactor dealing with existing values into a tracker

* fix merge errors

* cleanup and more tests

* fix lint errors

* more merge conflict fixes and cleanup

* use appropriate quotes

* small indentation fix

* refactor case clause tracker

* experiment: support tabstops after each case clause

* address small CR comments

* fix completion entry details; add test case

* fix lint errors

* remove space before tab stops; refactor
2022-12-01 16:48:32 -08:00
Eyal Halpern Shalev
5435efbf37 Fixed method signature of Atomics.waitAsync (#51602)
* Added method overloading for Atomics.waitAsync(Int32Array, number, number, number)

* fixed types

* fixed types

* fixed line ending

* CR fix

* Forgot the baseline
2022-12-01 16:41:28 -08:00
Oleksandr T
1b75edcec6 fix(51053): Extract type on JSDoc causes an assertion failure (#51056)
* fix(51053): allow extract type from the jsdoc without a host

* change diagnostic message
2022-12-01 16:09:31 -08:00
Sheetal Nandi
7b7f6a75ea Code refactoring for module resolution api (#51675)
* Refactoring so CacheWithRedirects has Key and Value type parameters

* ModuleResolutionCache or TypeRefDirectiveCache will look in directory before solving, so ResolutionCache doesnt need this check

* Test showing module resolution is not shared because resolution cache doesnt update own options

* Enable traceResolution on some of the project reference tests

* Simplify CacheWithRedirects and ensure the options are set in all common scenarios so cache can be shared between redirects
2022-12-01 10:17:58 -08:00
Ryan Cavanaugh
9089d5390a Unconditionally call checkExpression from checkSatisfiesExpression (#51704)
* Unconditionally call `checkExpression` in `checkSatisfiesExpression`

* A testcase
2022-12-01 09:11:37 -08:00
Anders Hejlsberg
8036b149a4 Fix isUnitLikeType to (again) handle tagged literal types (#51545)
* Fix isUnitLikeType to (again) handle tagged literal types

* Add regression test
2022-11-30 13:30:52 -08:00
Sheetal Nandi
16edc29bc9 Handle empty string when getting file version (#51689)
* Test for empty string change

* Fix empty string for file versioning
2022-11-30 10:30:32 -08:00
Sheetal Nandi
c2519bb301 When there is no change in file text for program, no need to update program (#51626)
* When fsEvent for change is repeated

* When trying to check if program is uptodate, read the files from disk to determine the version instead of delaying so that new program is not created if file contents have not changed
2022-11-29 12:20:41 -08:00
Sheetal Nandi
af36a859b9 Fix the crash when affected file pending emit is not in program is being serialized into buildInfo (#51674)
Fixes #51641
2022-11-29 12:20:09 -08:00
Sheetal Nandi
9f93c6717d Dont calculate version paths proactively as they may not be needed (#51593) 2022-11-29 12:19:44 -08:00
Anders Hejlsberg
cee6366c48 Fix isTypeDerivedFrom to properly handle {} and intersections (#51631)
* Fix isTypeDerivedFrom to properly handle {} and intersections

* Add tests
2022-11-29 08:29:35 -08:00
Sheetal Nandi
59e659ac4a More test cleanup/baselining for future changes (#51635)
* More test cleanup/baselining for future changes

* More cleanup

* More cleanup

* Make the reuse program structure stable for each test
2022-11-28 15:49:08 -08:00
Andrew Branch
e6d7b526c8 Fix multiline import specifier sorting (#51634)
* Fix multiline import specifier sorting

* Update baselines

* Switch to EmitFlag, set hasTrailingComma on original node array

* Update API baseline

* Update baselines
2022-11-28 15:35:32 -08:00
Sheetal Nandi
c1427c90b6 Convert reuse program structure and tracing of module resolution to baseline for easier updates (#51628)
* Modify all usages of file name lower casing to use custom lower casing method

* Baseline reuse program structure tests for easy update when making changes to module resolution
2022-11-22 20:58:21 -08:00
Mateusz Burzyński
5cd2d975c3 Fixed an issue with in not being able to be used on narrowed down expression of a generic nullable type (#51502)
* Fixed an issue with `in` not being able to be used on narrowed down expression of a generic nullable type

* Add another test case from a new issue

* Move the fix to `hasEmptyObjectIntersection`
2022-11-22 07:03:58 +01:00
Joshua Chen
df7f5fc94e Avoid emitting temp variable in downleveled import() (#51562) 2022-11-20 01:22:41 -05:00
Wesley Wigham
b4024a5506 Preserve input key style when writing mapped type keys in declaration emit (#50781) 2022-11-18 12:54:12 -08:00
Wesley Wigham
a3092c798a Preserve alias symbols on references to type aliases via imports (#51152)
* Preserve alias symbols on references to type aliases via imports

* Fix lint
2022-11-17 21:25:31 -08:00
Jake Bailey
00dc0b6674 Flip imports to case insensitive sorting (#51579) 2022-11-17 15:35:28 -08:00
Jake Bailey
2d2a4343b8 Reformat imports to be one identifier per line (#51565) 2022-11-17 13:42:18 -08:00
Anders Hejlsberg
7b85cd6b72 Numeric literals assignable to enum literals only when values match (#51561)
* Numeric literal assignable to enum literal only when values match

* Accept new baselines

* Update compiler sources

* Accept new baselines

* Fix test runner

* Any numeric literal type is assignable to a computed numeric enum type
2022-11-16 18:56:01 -08:00
Sheetal Nandi
2f2a17ad0b Removing some unnecessary methods from host and function parameters (#51499) 2022-11-15 17:34:58 -08:00
Jake Bailey
4d53a1f8f1 Move deprecate from Debug to deprecatedCompat (#51522) 2022-11-15 16:00:33 -08:00
Simon Tretter
f4ddc1a09b visitEachChild not traversing all nodes (#51543)
fixes https://github.com/microsoft/TypeScript/issues/51542
2022-11-15 18:18:17 -05:00
Tomasz Lenarcik
dfc1242aaf Fix asyncDelegator reporting "done" too early (#51274)
* Fix asyncDelegator reporting done too early

* Add unit test for yields inside finally block

See #45400
2022-11-15 18:12:26 -05:00
Andrew Branch
89ce16ccfd Fix auto-import when paths points to project reference redirect (#51492)
* Fix auto-import when `paths` points to project reference redirect

* Put paths specifiers to redirects in lower priority bucket
2022-11-15 14:19:15 -08:00
Andrew Branch
3fcd1b51a1 Refactor module resolution Extensions, fix lookup priorities (#51471)
* Refactor `Extensions`, fix lookup priorities

* Update baselines

* Clean up

* Temporarily apply same fix to `node` for testing

* Revert ancestor node_modules lookups back to two passes

* Revert "Temporarily apply same fix to `node` for testing"

This reverts commit 4014f3005a.

* Update baselines

* Add new test for node_modules searching behavior

* Update new baseline
2022-11-15 14:18:11 -08:00
Charlie Fish
53ef2fc90d Improving Date.getTime documentation (#51365) 2022-11-15 08:48:20 -08:00
Jonathan Kingston
c0f8d1cf75 fix(51277): Array find thisArg fix from being void (#51278) 2022-11-14 16:49:11 -08:00
Oleksandr T
5016d13f8d fix(51112): skip checking binding parameters for functions that contains arguments (#51258) 2022-11-14 16:32:36 -08:00
Jake Bailey
fbdf00ce12 Undo accidental style changes from Map/Set PR (#51529) 2022-11-14 14:52:00 -08:00
Sheetal Nandi
9ede7ce006 Fix incorrect spelling of packageId (#51483) 2022-11-10 16:55:49 -08:00
Sheetal Nandi
c5aea89230 Add alias ResolutionMode for ModuleKind.ESNext | ModuleKind.CommonJs | undefined (#51482)
* Add alias ResolutionMode for ModuleKind.ESNext | ModuleKind.CommonJs | undefined

* ResolutionMode | undefined = ResolutionMode

* More
2022-11-10 16:47:46 -08:00
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
Jake Bailey
10125e48c0 Fix __importDefault when used on typescript libraries (#51474) 2022-11-10 13:57:57 -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