24559 Commits

Author SHA1 Message Date
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
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
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
csigs
fa364b85d0
LEGO: Merge pull request 49300
LEGO: Merge pull request 49300
2022-05-29 04:17:15 -07: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
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
Andrew Branch
77ffb96b1a
Fix extensions for noDtsResolution in node16/nodenext (#49233) 2022-05-25 15:27:27 -07:00
Sheetal Nandi
0ad5f82d62
Fix the implicit glob key so that recursive keys are not differing just directory separator for wildcard directory (#49246)
* Add failing test

* Fix the implicit glob key so that recursive keys are not differing just by directory seperator
Fixes #49078

* Reset the reload level once program is loaded
2022-05-25 12:30:40 -07:00
Huy
1fb2b2d70f
fix(47562): Add option to suppress type hint if variable name matches type name (#48529)
* fix(47562): Add option to suppress type hint if variable name matches type

* Remove the unnecessary debug code

* Re-run gulp runtests

* Use equateStringsCaseInsensitive to compare strings
2022-05-25 12:07:38 -07:00
Oleksandr T
b57d6e1df4
fix(49131): allow type keyword inside functions (#49134) 2022-05-24 15:16:48 -07:00
Andrew Branch
a2b785b6cb
Limit type argument inference from binding patterns (#49086)
* WIP

* Don’t widen literals based on bogus contextual type instantiation

* Split tests

* Skip unnecessary inference pass

* Accept test baselines

* Fix stray edit

* Fix type mapper combination

* Revert src/ of 7dc1952a82

* Make empty binding pattern provide no contextual type

* Add missed baseline
2022-05-24 09:05:34 -07:00
Wesley Wigham
194a2aea0d
Key validity of import=require in module: node off of module and not target (#49222) 2022-05-24 03:33:23 -07:00
Sheetal Nandi
7c6521e8fb
When building projects in watch mode, only schedule projects that need build or need update to bundle (#48865)
* Handle timesouts to reflect the time it was set with

* Remove unused internal calls from solution builder

* If the project doesnt need building or updating bundle, dont schedule it but do it right away

* Reduce the time between project builds to 100ms

* Some tests for projects building

* Schedule builds such that when change is not detected 5 projects are built at a time

* Fix tests in main
2022-05-23 11:40:57 -07:00
Anders Hejlsberg
c592ee781d
Instantiate original target type in substituteIndexedMappedType (#49205) 2022-05-23 11:07:33 -07:00
Nathan Shively-Sanders
006ae339bf
Add es2018.intl ref to es2020.intl (#49152)
* Add es2018.intl ref to es2020.intl

es2020.intl refers to NumberFormatPartTypes declared in es2018.intl
as of #46508.

I'm not sure how to test this; it repros on Definitely Typed in
types/ndarray, but when I copy the same files into a compiler test it
passes without a problem.

* Add a test that shows the change works

It doesn't actually show that the original bug has been fixed,
though.
2022-05-20 11:04:34 -07:00
Andrew Branch
0921eac6dc
Fix path completions for typesVersions (#49154)
* Fix path completions for typesVersions

* Add more tests

* Fix case when * is a fragment of a path component

* Once a path pattern matches, only return completions from that pattern and higher priority ones

* Fix iteration order issue

* Aesthetics
2022-05-19 14:33:46 -07:00
Andrew Casey
5aa0053c74
Use changeCompilerHostLikeToUseCache in synchronizeHostData (#48980)
* Remove unnecessary members of HostCache

* Standardize on calling compiler host members in preparation for adding caching at that layer

* Call changeCompilerHostLikeToUseCache to cache existence checks

* Drop now-redundant HostCache

* Don't make directoryExists caching contingent on createDirectory

* Clear compilerHost rather than tracking state
2022-05-18 17:26:55 -07:00
Andrew Casey
12ed01203c
Clean up FAR aggregation (#48619)
* Clean up FAR and RenameLocations

This change had two goals:

1. Make the code easier to understand, primarily by simplifying the callback structure and minimizing side-effects
2. Improve performance by reducing repeated work, both FAR searches of individual projects and default tsconfig searches

This implementation attempts to preserve the merging order found in the original code (someone less relevant in the present state of using syntactic isDefinition).

* Stop enforcing search and aggregation order

...in preparation for implementing isDefinition explicitly.

Also restore convention of referring to `DocumentPosition`s as "locations".

* Introduce LanguageService.updateIsDefinitionOfReferencedSymbols

...to allow use of the checker when computing isDefinition across projects.

* Update baselines

* Tidy diff

* De-dup simplified results

* Baseline cross-project isDefinition results

* Move de-duping upstream to fix Full output

* Add server baseline test to confirm searches are not repeated

* Manually merge #48758

* Update baseline for newer fix to #48963
2022-05-18 17:26:17 -07:00
Andrew Branch
e56a067801
Fix uncalled function check usage detection for && expressions (#49157) 2022-05-18 13:58:06 -07:00
csigs
ce85d647ef
LEGO: Merge pull request 49148
LEGO: Merge pull request 49148
2022-05-17 03:46:13 -07:00
Oleksandr T
0df9462a96
fix(49058): Language service crashes for static member in class with unresolved base members (#49059)
* fix(49058): skip unresolved base members

* use getTypeOfSymbol instead of getExportsOfModule
2022-05-16 14:29:40 -07:00
Nathan Shively-Sanders
95731f0397
No errors on apparent type of bigint or symbol, even for recent targets (#49104)
* Remove bigint from Object.freeze in es5.d.ts

`BigInt` isn't resolved whenever `lib < es2020`, but it's not an error
when `target < es2020`. I have a few ideas for improving this situation
but for the RC I'm going to remove `bigint` from Object.freeze's
signature.

* Update other baselines

* No errors for missing apparent type of bigint,symbol for any target

* Update test text
2022-05-16 09:14:00 -07:00
csigs
528f708ab8
LEGO: Merge pull request 49130
LEGO: Merge pull request 49130
2022-05-16 08:16:23 -07:00
csigs
9e70b69a97
LEGO: Merge pull request 49117
LEGO: Merge pull request 49117
2022-05-15 09:00:13 -07:00
csigs
fba6eeaf6e
LEGO: Merge pull request 49108
LEGO: Merge pull request 49108
2022-05-14 05:10:05 -07:00
Daniel Rosenwasser
0414deeaaf
Merge pull request #48954 from a-tarasyuk/fix/48948
fix(48948): constructor can't be the name of class accessors and generators
2022-05-13 12:20:45 -07:00
csigs
90b1321baa
LEGO: Merge pull request 49098
LEGO: Merge pull request 49098
2022-05-13 03:59:47 -07:00
Oleksandr T
9607a5310f add messages to plainJSErrors 2022-05-13 09:24:08 +03:00
Jake Bailey
92894d36af
Make watch/FS testing code friendlier for project loading in module transformation (#49087) 2022-05-12 16:43:44 -07:00
Jack Works
b689cd0aa9
feat: support error when comparing with object/array literals (#45978)
* feat: support error when comparing with object/array literals

* chore: include regexp, function and class literal

* chore: include regexp, function and class literal

* test: update baseline

* fix: baseline
2022-05-12 15:45:22 -07:00
Anton Gilgur
da00ba67ed
fix: getDefaultLibFilePath should normalize __dirname (#49051)
- this currently causes a bug on Windows with mixed path separators
  - it returns a POSIX backslash path for __dirname, and then adds a
    forward slash from the directorySeparator, causing mixed separators
    - TS uses `/` internally and lets the host convert if needed, so
      I assume this should be normalized to all forward slashses instead
  - example of the bug from my tests:
    ```
    Expected: "D:\\a\\rollup-plugin-typescript2\\rollup-plugin-typescript2\\node_modules\\typescript\\lib\\lib.d.ts"
    Received: "D:\\a\\rollup-plugin-typescript2\\rollup-plugin-typescript2\\node_modules\\typescript\\lib/lib.d.ts"
    ```

- every other use of __dirname in the codebase seems to be normalized
  except for this one
  - could use normalizeSlashes for this, but I figure combinePaths is
    more appropriate since that will handle it and combine properly as
    well without any `+ directorySeparator +` stuff
2022-05-12 13:21:56 -07:00
csigs
1ba609660b
LEGO: Merge pull request 49081
LEGO: Merge pull request 49081
2022-05-12 04:28:47 -07:00
Oleksandr T
c300fea325
fix(7410): allow using JSXElement as JSXAttributeValue (#47994) 2022-05-11 14:47:35 -07:00
Andrew Branch
5c2febfe02
Allow referencing type-only exports as namespace members in ImportTypes and TypeQueries (#49056)
* Allow referencing type-only exports as namespace members in ImportTypes and TypeQueries

* Add extra test case

* ;; -> ;

* undefined -> false

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
2022-05-11 11:44:59 -07:00
csigs
3c87170604
LEGO: Merge pull request 49069
LEGO: Merge pull request 49069
2022-05-11 08:29:06 -07:00
Daniel Rosenwasser
3e24f14871
Merge pull request #49029 from DavidSouther/fix/44466-contextual-keyword-assertion
fix(44466): Fixes parsing contextual keyword casts as arrow functions
2022-05-10 16:37:49 -07:00