10907 Commits

Author SHA1 Message Date
TypeScript Bot
7b61fa2393
Cherry-pick PR #44724 into release-4.3 (#44822)
Component commits:
55459467d6 Fix auto imports in opening JSX tag

Co-authored-by: Andrew Branch <andrew@wheream.io>
2021-06-30 14:33:26 -07:00
TypeScript Bot
89a171e308
Cherry-pick PR #44126 into release-4.3 (#44189)
Component commits:
99110e9d9d Consider inferences between mapped type templates lower priority

Co-authored-by: Wesley Wigham <t-weswig@microsoft.com>
2021-06-16 15:45:46 -07:00
TypeScript Bot
4f7fe4a1de
Cherry-pick PR #44290 into release-4.3 (#44425)
Component commits:
f3bf29a71c fix(44273): preserves 'override' modifier in JavaScript output

Co-authored-by: Oleksandr T <oleksandr.tarasiuk@outlook.com>
2021-06-03 16:35:21 -07:00
Daniel Rosenwasser
e425f573aa
Fix unintended 'as const' name lookup error (#44311) (#44370)
* Fix logic for methods in isTypeParameterPossiblyReferenced

* Add regression tests

Co-authored-by: Anders Hejlsberg <andersh@microsoft.com>
2021-06-01 14:55:21 -07:00
TypeScript Bot
28e3e6ff2f
🤖 Pick PR #44219 (Properly remove generic types that ...) into release-4.3 (#44243)
* Cherry-pick PR #44219 into release-4.3

Component commits:
4475012558 Improve getNonNullableType function

86f09ae87c Add tests

d45806a984 More closely match previous behavior

634b01ab3a Add non-strict mode test

* Update LKG

Co-authored-by: Anders Hejlsberg <andersh@microsoft.com>
Co-authored-by: typescript-bot <typescript@microsoft.com>
2021-05-25 11:40:42 -07:00
TypeScript Bot
d6e6fa728e
Cherry-pick PR #44129 into release-4.3 (#44240)
Component commits:
7a9854c4a4 Ensure static index signatures have an errorNode available

626b4319cb Merge branch 'master' into error-node-static-index-signatures

a8327a0396 Lookup static index signature declarations in the right symbol table, stop checking prototype props

Co-authored-by: Wesley Wigham <t-weswig@microsoft.com>
2021-05-24 16:12:47 -07:00
TypeScript Bot
fed2315062
Cherry-pick PR #44186 into release-4.3 (#44188)
Component commits:
acdaf368c6 Move class name capture for private state until after declaration evaluates

Co-authored-by: Ron Buckton <rbuckton@microsoft.com>
2021-05-20 15:07:31 -07:00
Jesse Trinity
dec8261174
Revert #43460 and #40884 (#44175) (#44177)
* Revert "Only issue matching token errors on non-dupe locations (#43460)"

This reverts commit 76a2ae3d69e7eba33890d65159ee66719c69b916.

* Revert "Adding Diagnostic message for missing ']' and ')' in Array literal and conditional statements (#40884)"

This reverts commit 555ef73da88a9316a5769b9329eb01f7ac0fc92b.

* re-add clobbered merge lines
2021-05-20 13:46:30 -07:00
TypeScript Bot
22c3c24cf0
Cherry-pick PR #44125 into release-4.3 (#44136)
Component commits:
34b80a51af Don’t offer import statement completions at `from` position

afa4d051a9 Set isGlobalCompletion to false, use indexOf lookup

Co-authored-by: Andrew Branch <andrew@wheream.io>
2021-05-17 17:48:35 -07:00
Wenlu Wang
5b1e873b03
Update diagnostic message and quickfix for parameter property (#44010) 2021-05-08 23:22:20 -07:00
Anders Hejlsberg
42f0cf6ffc
Don't eagerly get apparent type of spread expression contextual type (#44002)
* Don't get apparent type of contextual type for spread expressions

* Add regression test
2021-05-07 15:44:17 -07:00
Orta Therox
6bb481c9d3
Support semantic highlights for JS files (#43992)
* Switches from never allowing semantic highlight on JS to only doing it if we have a valid source file

* Adds a way to test and validate that an arbitrary JS file gets semantic classification results

* Revert to just dropping the if statement
2021-05-07 20:02:26 +01:00
Nathan Shively-Sanders
f6303652d2
Improve errors for incorrectly nested export default (#43967)
* Improve errors for incorrectly nested export default

The compiler and services don't handle incorrectly nested
`export default` well right now:

```ts
export = (x,y) => {
  export default { }
}
```

Asking for document highlights, find all references or quick info on
'export' or 'default' cause a crash. After the crash is fixed, the error
message is confusing and wrong: "An export assignment cannot be used outside a module."

This PR:

1. Skips document highlights for incorrectly nested export default.
2. Skips find all refs for incorrectly nested export default.
3. Switches the fallback binding for incorrectly nested export default
from Alias to Property. Neither is correct, but Property doesn't cause a
crash in alias resolution.
4. Improves the error message to reflect a post-ES module world, which
has export default and 'module' means 'ES module', not 'namespace'.

Fixes #40082 and the related bugs mentioned above.

* address PR comments
2021-05-07 08:09:38 -07:00
Andrew Branch
96c48b746a
Fix package.json auto imports for pnpm without project references (#43892)
* Fix package.json auto imports for pnpm without project references

* Make property optional

* Revert unnecessary unnittest change

* Set symlinked files when setting symlinked directories

* Update `typeDirectiveIsEqualTo`

* Consider symlinks found during type reference directive resolution into `discoverProbableSymlinks`

* Rename `originalFileName` to `originalPath`, make internal
2021-05-06 14:51:30 -07:00
Nathan Shively-Sanders
71f338bad6
Revert "typeRelatedToSomeType passes through intersectionState (#43707)" (#43983)
This reverts commit db09cb595195d4eaa5dde0322c5a8fbb5f4b66d2.
2021-05-06 13:12:36 -07:00
Wesley Wigham
a5607a4eab
Dont allow namespace reexport symbols when looking up valid local names (#43969) 2021-05-06 12:03:48 -07:00
Wesley Wigham
456806b070
Allow filterType to consider union constraints of non-union types when determining never-ness (#43763)
* Allow filterType to consider union constraints of non-union types when determining never-ness

* Move impl to callback

* Baseline change in narrowing behavior into test, fix post-LKG build
2021-05-05 13:35:09 -07:00
Wesley Wigham
b83148fe64
Unwrap substitutions on conditional check types before comparing them (#43888) 2021-05-05 13:33:45 -07:00
Oleksandr T
6f8c3b0c99
fix(43957): insert Override keyword after static modifier (#43959) 2021-05-05 08:52:50 -07:00
Nathan Shively-Sanders
7a8c5a0001
Displayparts resolves non-values in link tags (#43903)
Previously, the name resolution for link tags in displaypart generation
mistakenly required a valueDeclaration. Now it uses the first
declaration if there is no valueDeclaration, so that types and
namespaces will also resolve.

This is another instance of using valueDeclaration as "the default
declaration", which doesn't apply to types.

Fixes #43868
2021-04-30 14:17:54 -07:00
Sheetal Nandi
54096bdb96
Use project relative preference for declaration emit (#42232)
* Test where relative import isnt ideal in the declaration emit

* use project relative preference for declaration emit
Fixes #39117

* Fix incorrect path matching when calculating module specifier

* Use correct baseUrl for the module specifier
2021-04-30 13:22:05 -07:00
Sheetal Nandi
c96b472e0b
Handle localness in special cases by checking exported variable assignment (#43851)
* Handle localness in special cases by checking exported variable assignment
Fixes #42976

* Fix existing tests where arrow now behaves similar to function expression

* Update src/services/goToDefinition.ts
2021-04-30 13:17:59 -07:00
Nathan Shively-Sanders
c9eb62fafb
getExternalModuleMember:always resolve alias of moduleSymbol (#43718)
Previously, getExternalModuleMember passed through its received value of
`dontResolveAlias` to every function that accepted it. That includes (1)
resolution of the module symbol and (2) resolution of the module
specifier. However, in TS, the module symbol is never an alias anyway, so
dontResolveAlias doesn't make a difference. In JS, the module symbol
*can* be an alias, and it should always be resolved. That's what this PR
does.

Fixes #43713
2021-04-30 10:47:45 -07:00
Nathan Shively-Sanders
004b3ae018
Simplify arity errors, rewording spread errors (#43855)
* Scribbles + tests

The second test actually requires node types

* Basically working

The two simple fixes, in arity error reporting, are in, and the
simplification of arity error reporting is half-done. I haven't started
on any improvements to call assignability.

* trim out too-real test case

* Finish cleanup

And reword error a little.

* Simplify and reword spread errors

* handle spreads first

* update baselines

* Address PR comments
2021-04-29 14:38:50 -07:00
Xu Zhuo
4ecb563aa4
Complete constructor keyword after property declaration (#43654)
* Complete `constructor` keyword after property declaration.

* Fix logical errors.

* Fix for more universal situations.

* Only provide completions if property declaration is terminated.

* Simplify many logical conditions.

* Make the fix more reliable.

* Narrowing the fix.
2021-04-29 11:16:51 -07:00
Oleksandr T
3e25424652
fix(43408): emit nullable/optional types on getters (#43476) 2021-04-29 09:20:40 -07:00
Acy Watson
b31b0eb05c
Use single quotes consistently in diagnostic messages. (#43634) 2021-04-29 07:15:31 -07:00
Andrew Branch
a14b22718a
Enforce keyword order of abstract and override (#43829)
* Enforce keyword order of abstract and override

* Update baselines

* Update existing test
2021-04-28 16:41:28 -07:00
Andrew Branch
791c747e06
Allow override as parameter property (#43831)
* Allow `override` as parameter property

* Update other baseline

* Add test for override on normal parameter

* Copy typo fix

* Update baselines

* Update API baseline
2021-04-28 16:41:09 -07:00
Nathan Shively-Sanders
db09cb5951
typeRelatedToSomeType passes through intersectionState (#43707)
* typeRelatedToSomeType passes through intersectionState

Previously it didn't, even though it should have.

* fix parameter name lint
2021-04-28 16:12:20 -07:00
Andrew Branch
58c54127a9
Fix node.getStart() for nodes spanning multiline JSDoc comments (#43854) 2021-04-28 11:37:27 -07:00
Wesley Wigham
5e4fcfbfb6
Add instantiation rules for reverse mapped types (#42449)
* Add instantiation rules for reverse mapped types

* Add smaller example of same issue
2021-04-27 15:01:46 -07:00
Wesley Wigham
bbad560912
Refrain from attempting to perform parameter fixing on a generic signature multiple times (#43835)
* Refrain from attempting to perform parameter fixing on a generic signature multiple times

* Remove assertion
2021-04-27 10:49:27 -07:00
Andrew Branch
3de706a852
Don’t create invalid type-only imports during add missing import (#43828) 2021-04-26 11:52:34 -07:00
Nathan Shively-Sanders
d5af89c552
Contextual typing checks property assignments for type annotation (#43598)
Property assignments can have a type annotation in JS. This PR adds a
check for it in contextual typing.

Fixes #43379
2021-04-26 09:19:24 -07:00
Andrew Branch
b9c1e98544
Fix completions of exports elsewhere in same file (#43755)
* Fix completions of exports elsewhere in same file

* Undo messing up JSDoc-annotated module.exports assignments

* Add other failing contextual type test

* Rearrange contextual type logic for special assignments

* Rename helper function
2021-04-26 09:13:09 -07:00
Erik Brinkman
4d4ea66a9c
update contextual discrimination to include omitted members (#43633)
This diff extends the types checked by
discriminateContextualTypeByObjectMembers and
discriminateContextualTypeByJSXAttributes to also include any optional
components in the type union.

fixes #41759 although it doesn't address the better error reporting for
their last repro, which I'm not sure how to address.
2021-04-24 14:26:29 -07:00
Oleksandr T
482f781386
fix(43559): allow renaming in files with no-default-lib enabled (#43579) 2021-04-23 16:56:33 -07:00
Nathan Shively-Sanders
d171eee044
Omit spaces after https in jsdoc comments (#43800)
* Omit spaces after https in jsdoc comments

for tags with names.

Fxes #42581

* fix semicolon lint
2021-04-23 16:23:34 -07:00
Wesley Wigham
dee4903f45
Compute dervied generic-ness for substitutions and create lower priority inferences for substitutes (#43765) 2021-04-23 15:51:05 -07:00
Andrew Branch
bd7d0f26b2
Don’t allow an object literal with a spread as a fallback for destructuring a property not present in all constituents (#43783)
* Add test

* Don’t allow an object literal with a spread as a fallback for destructuring a property not present in all constituents
2021-04-23 14:44:57 -07:00
Zak Miller
c552a4bf82
fix(42829) ignore preceeding jsx whitespace (#43452) 2021-04-22 15:12:05 -07:00
Sheetal Nandi
fb0b1d7295
Handle getter setter quickInfo (#43769)
Fixes #43413
2021-04-21 17:47:11 -07:00
Wesley Wigham
8ea4ec9496
Add infer T constraint inference rule matching up mapped type templates across check/extends types (#43649) 2021-04-21 12:49:02 -07:00
Tiago Tristao
3d24b85f9e
Completion list for type literals in type arguments (#43526)
* Completion list for type literals in type arguments

* Add tests

* Refactor for better readability

* - Support non-identifier keys
- Move main logic onto tryGetGlobalSymbols function
2021-04-20 10:24:17 -07:00
Sang
f2705294ac
Fix object literals lack of this references (#43572)
* fix: object literals lack of this references

* test: improve cases
2021-04-20 10:06:08 -07:00
Jean Pierre
8513f78058
Fix getCodeFixesAtPosition for ts(2339) thows error False expression: Token end is child end (#43645)
* Fix getCodeFixesAtPosition for ts(2339) thows error False expression: Token end is child end
Fixes #43191

* Add test
2021-04-20 10:00:34 -07:00
Armando Aguirre
f67ee44379
Instantiate getter when infering setter parameter value (#43564)
* Instantiate getter when infering setter parameter value

* Use esnext on tests

* Instantiate for JsDoc and getter from body

* PR comments

* Updated baseline
2021-04-19 23:23:40 -07:00
Wesley Wigham
7e4400b9c3
Stop checking getter/setter compatability twice (#43741)
* Stop checking getter/setter compatability twice

* Ensure modifier errors are still emitted on both accessors, accept modified baselines
2021-04-19 15:53:48 -07:00
Wesley Wigham
85c9d2cc89
Use faster, stricter prop type comparison when merging props in union prop creation (#43696)
* Use faster, stricter prop type comparison when merging props in union prop creation

* Be better at determining this usage in methods, accept baselines

* Small style change
2021-04-19 15:25:12 -07:00