Commit graph

8107 commits

Author SHA1 Message Date
Andrew Branch 703c1bc69d
Include type reference directives in symlink cache, wait until program is present to create it (#44259)
* Fix discovery of more pnpm symlinks

* Add some tests

* Never show pnpm paths in auto imports, even if there’s no other path

* Import statement completions can return none

* Fix tests

* Add failing test showing poor symlink cache reuse

* Fix test, fails for right reasons now

* Preserve cache built up during program creation, then fill in with program resolutions

* Remove obsolete comment

* Remove obsolete type assertion

* Revert fully filtering out ignored paths
2021-06-08 12:06:55 -05:00
Daniel Rosenwasser 9906092db2
Add flag to change catch variables' default types to unknown (#41013)
* Add test case for 'useUnknownInCatchVariables'.

* Add new 'useUnknownInCatchVariables' flag.

* Accepted baselines.

* Add test for catch variable explicitly typed as 'any'.

* Accepted baselines.

* Move option under 'strict'.

* Accepted baselines.

* 'useUnknownInCatchVariables' is strict in command line help.
2021-06-03 13:12:56 -07:00
Orta Therox 6baa1bec64
Improve non-ambient class and function merge error (#44352)
* Improve non-ambient class and function merge error

* Update baselines

* Update tests

Co-authored-by: Austin Cummings <austin@austincummings.com>
2021-06-03 14:08:04 +01:00
Isabel Duan 9c50cb925e
Fixes subset of bugs (three tests fixed) listed in issue #41974 (#44367)
* some fixes for 41974

* linted

* fixed todo messages for readability
2021-06-02 09:32:19 -07:00
Anders Hejlsberg 391f9ffb85
Strict optional properties (#43947)
* Introduce --strictOptionalProperties compiler switch

* Accept new baselines

* Removing missingType when printing back optional properties

* Accept new baselines

* Fix linting issue

* Use getNonMissingTypeOfSymbol in getTypeOfSymbolAtLocation

* Properly elaborate errors involving optional properties

* Accept new baselines

* Properly check optional properties in tuple types

* Accept new baselines

* Add missing tuple type check

* More permissive check of strict optional properties and index signatures

* Add tests

* Fix lint issues

* Accept new baselines
2021-06-01 14:52:16 -07:00
Wesley Wigham 09a21ce7c6
Consider inferences between mapped type templates lower priority (#44126) 2021-05-28 21:07:39 -07:00
Anders Hejlsberg 9aa50d6475
Fix unintended 'as const' name lookup error (#44311)
* Fix logic for methods in isTypeParameterPossiblyReferenced

* Add regression tests
2021-05-27 17:23:28 -07:00
Nathan Shively-Sanders 459bd19941
Add unqualified JSDoc member references (#44202)
* Add unqualified JSDoc member references

This allows unqualified references like:

```ts
class Zero {
 /** @param buddy Must be {@link D_HORSE} or {@link D_DOG}. */
 deploy(buddy: number) { }
 static D_HORSE = 1
 static D_DOG = 2
}
```

I surveyed @see and @link again to estimate how common this is. I found
a little over 200 uses, which is around 2%. Sorted by frequency, this
*is* the next feature on the list, along with the `module:` prefix.
So I think this is about the right point to stop adding code.

In this case, however, I liked most of the uses -- there were a lot
of deprecated functions that referenced a function just below, where it
would be wordy to qualify the name, but the reader would benefit from a
link.

Note that unqualified references do *not* work inside type or object
literals. The code I ended up with is quite complicated and I didn't
observe any uses in the wild.

Fixes #43595

* Remove type/object literal container check

Since they don't work anyway
2021-05-26 09:54:05 -07:00
Oleksandr T 4559855c64
feat(44190): check misspelled base members in override checks (#44213) 2021-05-25 21:24:28 -07:00
Anders Hejlsberg 3938958d36
Properly remove generic types that are constrained to 'null | undefined' in getNonNullableType (#44219)
* Improve getNonNullableType function

* Add tests

* More closely match previous behavior

* Add non-strict mode test
2021-05-25 11:40:28 -07:00
Wesley Wigham 2203228b62
Ensure static index signatures have an errorNode available (#44129)
* Ensure static index signatures have an errorNode available

* Lookup static index signature declarations in the right symbol table, stop checking prototype props
2021-05-24 14:30:59 -07:00
Nathan Shively-Sanders c4c6a83922
Add @linkcode and @linkplain tags (#44208)
* Add @linkcode and @linkplain tags

They are just like @link tags but request fixed-width and normal
presentation, respectively.

Fixes #43935

* revert JSDocComment -> JSDoc SyntaxKind rename

* update API baselines

* fix lint
2021-05-24 13:01:58 -07:00
Zzzen 756392c1f5
support QualifiedName when narrowing inside loops (#43592)
* support QualifiedName when narrowing inside loops

* add test

* narrow more qualified names

* handle `undefined` of `getFlowCacheKey `

* update comments in test
2021-05-21 10:36:54 -07:00
Nathan Shively-Sanders 086423729a
Add jsdoc member names: Class#method (#44150)
* Everything mostly works

A couple of mixed, nested references don't work yet.
The scanner+parser interaction is wrong, the parser consumes one too
many spaces, and the checker+services code needs a little cleanup.

* Cleanup

1. I decided that correctly parsing a#b.c, an entity name containing an
instance reference, is not worth the work.
2. I made the scanner, at least the jsdoc part, emit a # token, and
provided a reScanPrivateIdentifier in order to convert #a to # a.
3. I cleaned up the code in the checker.
2. Unrelated: I added a missing space in linkPart display.

* Cleanup lint + var naming

* investigate+clean up a couple of TODOs

* Fix lint in utilities.ts

* change name to JSDocMemberName

* address PR comments
2021-05-21 07:53:17 -07:00
Nathan Shively-Sanders 4a59b63f35
Error for abstract property with initialiser (#43615)
* Error for abstract property with initialiser

* remove stray LF

* update baselines
2021-05-20 07:18:18 -07:00
Anders Hejlsberg e67da8a748
Preserve generics in contextual types for rest arguments (#44122)
* Move all getIndexedAccessType flags to AccessFlags enum

* Preserve generics in contextual types for rest arguments

* Add regression test
2021-05-19 13:46:07 -07:00
Anders Hejlsberg 73736d9b84
Fix logic for determining whether to simplify keyof on mapped types (#44042)
* Fix logic for determining whether to simplify keyof on mapped types

* Add regression test

* Improve hasDistributiveNameType check

* Add more tests

* Address code review feedback

* Add more tests
2021-05-19 13:43:22 -07:00
Oleksandr T db01e84700
feat(eslint): consistent-type-assertions (#43556) 2021-05-18 06:20:57 -07:00
Wesley Wigham f414d13679
Dont allow generic narrowing when contextually typed by a binding pattern (#44081) 2021-05-13 16:51:52 -07:00
Wesley Wigham f7a97b7759
Cache accessibe symbol chains and serialized type parameter name generation (#43973)
* Cache accessibe symbol chains, type parameter name generation

* Move signature declaration helper length approximation to start of function

* Add node result caching internal to `typeToTypeNodeHelper`

* Suggestion from PR
2021-05-12 12:11:20 -07:00
Oleksandr T 7aacd6b274
fix(43879): forbid async in the left hand in a for-of statement (#43886) 2021-05-12 06:11:08 -07:00
Oleksandr T 463c79440f
fix(43030): fix instantiated null/undefined type from JS initializer (#43933) 2021-05-11 15:57:16 -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
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 Casey 1ce15a4531
Fix perf regression from #42556 (#43949)
PR #42556 was a nice optimization that dramatically sped up comparisons of discriminated unions.  Unfortunately, the cost of determining whether a union is discriminated can be prohibitively high.  In particular, an internal team with a very large repo saw their type count double and their memory usage increase from 6GB to 9GB, breaking their build.  This changes splits the difference by not trying to compute the property types of intersection types - a notoriously slow operation.
2021-05-06 17:06:38 -07:00
Nathan Shively-Sanders 71f338bad6
Revert "typeRelatedToSomeType passes through intersectionState (#43707)" (#43983)
This reverts commit db09cb5951.
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
Wesley Wigham 84da19efc8
Add single-element fastpath to getSupertypeOrUnion (#43934) 2021-05-05 13:32:23 -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
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
Oleksandr T 3e25424652
fix(43408): emit nullable/optional types on getters (#43476) 2021-04-29 09:20:40 -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
Wesley Wigham 7748694d60
Relate non-augmenting subtypes without resorting to structural comparison (#43624)
* Relate non-augmenting array subtypes without resorting to structural comparison

* Fix lint

* Generalize performance enhancement

* Cache results, feed through via getNormalizedType to remove error intermediates

* Use newly freed up object flags to limit member setting, fix crash with those object flags

* Move flags because there is no TypeFlags.Reference 🤦
2021-04-27 22:52:12 -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
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
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
Sheetal Nandi fb0b1d7295
Handle getter setter quickInfo (#43769)
Fixes #43413
2021-04-21 17:47:11 -07:00
Wesley Wigham f4b8adca6a
Comment copy edit 2021-04-21 12:51:36 -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
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 167ebcd93b
Check type flags before checking multiple-meaning object flags (#43745) 2021-04-19 22:35:11 -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
Ryan Cavanaugh b1ab2b98be
Wire up 'writing' parameter through protected derived class detection (#43455)
Fixes #43443
2021-04-19 09:20:21 -07:00
Anders Hejlsberg 0f2dabcd4b
Don't re-alias top-level type aliases with local type aliases (#43701)
* No re-aliasing of top-level type aliases with local type aliases

* Accept new baselines
2021-04-17 07:07:46 -07:00
Andrew Branch 06f25c0390
Enforce keyword order between override and static/async (#43660)
* Enforce keyword order between override and static/async

* Update old tests for new keyword order
2021-04-15 14:03:53 -07:00
Nathan Shively-Sanders 0987ee9e0e
Do not erase signatures in getSignatureOfTypeTag (#43688)
I don't see a reason for it, and it doesn't cause any tests to fail.
2021-04-15 10:53:23 -07:00
Wesley Wigham 3ab6809e38
Consider identical instances of the same symbol equivalent when creating union and intersection properties (#43560)
* Consider identical instances of the same symbol equivalent when creating union and intersection properties

* Also copy over mapper and type (if available) on cloned symbols

* Editorial feedback
2021-04-14 16:55:45 -07:00
Wesley Wigham 6c7c5e9ec2
Expand exception to contravariant constraint elision to all type variables (#43599)
* Expand exception to contravariant constraint elision to all type variables

* Comment update
2021-04-14 13:13:02 -07:00
Anders Hejlsberg 5977233fd1
Reinstate constraint check for template literal types (#43661)
* Add missing constraint check for template literal types

* Add regression test
2021-04-13 12:17:55 -10:00
Wesley Wigham 6002cff776
Trim indexed access and type variable constraint error output (#43540) 2021-04-13 13:13:32 -07:00
Andrew Branch 06a73655d0
Don’t error for missing await when promise is referenced in condition body (#43593) 2021-04-13 12:15:48 -07:00
Nathan Shively-Sanders d6012219e0
@link and @see resolve C.m as a class property reference (#43625)
* Test + Initial scribbles

The test is pretty good, the scribbles are actually cleanup from last
PR, although they break some tests.

* undo scribbles, add nonworking class-hack

* Ad-hoc name resolution for @link and @see

Turns out that you can't reuse check* functions if you want to retrieve
all meanings of a reference.

* fix failing test

* inline hapax function

* Fix find-all-refs baseline print

* Try to resolve C.m as static first

* Add interface tests

Co-authored-by: Andrew Branch <andrew@wheream.io>
2021-04-13 08:13:18 -07:00
Wenlu Wang b0c2860a68
ignore static and declared member if checking override (#43569)
* ignore static member if checking override

* Ignore declared member when check override

* Check static override too

* Add more tests
2021-04-09 10:43:33 -07:00
Anders Hejlsberg d41943eb4e
Properly handle tagged primitives in control flow analysis (#43538)
* Ignore object types in intersections with primitive types

* Add regression test

* Also handle instantiable types constrained to object types

* Add another test

* Add ignoreObjects optional parameter to getTypeFacts
2021-04-07 11:29:46 -10:00
Josh Goldberg a4c683be12
Again: Improve error messages for empty DOM interface property access (#43007)
* Again: Improve error messages for empty DOM interface property access

* containerSeemsToBeEmptyDomElement

Co-authored-by: Daniel Rosenwasser <drosenwasser@microsoft.com>

* isEmptyObjectType; unescapeLeadingUnderscores

* Single tick quotes for now

* Undo accidental diagnostic change

* Correct new baseline

Co-authored-by: Daniel Rosenwasser <drosenwasser@microsoft.com>
Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2021-04-07 12:54:27 -07:00
Titian Cernicova-Dragomir 2484210a00
Gh 41788 incorrect output for esprivate with nested class in esnext (#42663)
* If target:esnext,then useDefineForClassFields: true will now be the default.

* Added error if a private identifier is used in a static a initializer if target:ESNext and useDefineForClassFields:false.

* Added test for new useDefineForClassFields default and error message.

* Fixed tests after changing the default of useDefineForClassFields to true for target esnext

* Fixed code review suggestions.

* Updated error message.

* Added missing static check for the containing property. Fixed other code review issues.
2021-04-07 08:23:16 -07:00
Nathan Shively-Sanders 2bb54dc11a
Fix getTypeFromJSDocVariadicType in callback tag (#43562)
* Fix getTypeFromJSDocVariadicType in @callback

Variadics have never worked there, I think.

* add test + fix lint

* remove outdated comment
2021-04-07 08:12:05 -07:00
Nathan Shively-Sanders dd1ef88d01
Use control flow to type CommonJS exports (#42751)
* Allow redeclaring CommonJS alias with initial undefined

This allows us to read our own output, plus the times when people
manually write exactly the same pattern.

Fixes #40555

* Use control flow to type commonjs exports

1. Could probably use a *lot* more tests.
2. getTypeOfAlias redoes some work from resolveAlias because it needs to
not resolve the alias completely, just to its export.

* fix lint, improve jsdoc

* Add tests, improve+fix control flow

1. Update the module.exports test to match the exports ones.
2. Add a test of evolving commonjs type.
3. Add a test of assignment as last statement.

(1) exposed a bug that required a better synthetic reference. (3)
exposed a bug that was most easily fixed by giving source files a
`endFlowNode` like functions and setting it in the binder.

* fix lint
2021-04-06 17:07:35 -07:00
Pig Fang fb87079994
Enforce override precedes readonly (#43545) 2021-04-06 08:48:44 -07:00
Oleksandr T 8581a592bb
fix(43347): fix crash occurred when export type to existing commonJs imported name (#43369) 2021-04-06 08:46:22 -07:00
Wenlu Wang f526a38856
Always grammar checker for override (#43544) 2021-04-06 07:29:57 -07:00
Zen 3cf26e44ee
fix(43160): improve error location for functions without explicit return (#43367)
* fix(43160): improve error location for functions without explicit return

* handle functions returning never
2021-04-06 07:21:02 -07:00
Song Gao 2d66517312
fix quickinfo of narrowed private filed (#43356)
* fix quickinfo of narrowed private filed

* add test case.

* adapt review.
2021-04-05 13:24:19 -07:00
Anders Hejlsberg a7a010a994
Fix getRecursionIdentity function to always return some identity (#43527)
* Fix getRecursionIdentity, undo changes from #43435 (but keep tests)

* Remove test that takes excessively long to run

* Accept new baselines

* Fix formatting

* Add regression tests

* Reinstate test
2021-04-05 09:53:38 -10:00
Wesley Wigham cf8798d977
Make origin union cache key unique for key lists still under construction (#43339) 2021-04-05 11:47:49 -07:00
Wesley Wigham d1b43429c2
Allow nested reverse mapped type printback (#42485)
* Optimize interning of reverse mapped types

* Style feedback

* Whitespace

* Update baseline
2021-04-05 11:37:51 -07:00
Wesley Wigham 1f1dcd60b5
When reusing input type nodes, only instantiate the type for comparison if it is a this type (#42584) 2021-04-05 11:10:47 -07:00
Wesley Wigham f03e59ecc9
Do not covariantly mix in constraints from contravarrying positions (#43439)
* Do not covariantly mix in constraints from contravarrying positions

* Exclude keyof from constraint variance tracking

* Extra test case

* Always subtitute on type parameter types
2021-04-05 11:05:33 -07:00
Josh Goldberg 38da7c600c
Disabled 'used before initialization' error for optional properties (#43100)
* Disabled 'used before initialization' error for optional properties

* Expanded tests to include code snippet from issue
2021-04-02 10:08:10 -07:00
Armando Aguirre 8f8a579eee
Added BindingElement to isSomeImportDeclaration (#43387)
* Added BindingElement to isSomeImportDeclaration

* Added tests

* Refactores to use getDeclarationOfAlias
2021-03-31 18:18:16 -07:00
Anders Hejlsberg 3dd68b878a
Fix template literal type relations (#43440)
* Fix template literal relationships

* Accept new baselines

* Add regression test
2021-03-30 12:53:15 -10:00
Andrew Branch b549467368
Consider base types in isArrayLikeType (#43435)
* Types that extend Array or ReadonlyArray are automatically array-like

* Add React repro to test
2021-03-30 13:18:38 -07:00
Oleksandr T 6fd676b8ef
fix(43215): disallow using never as an interface name (#43217) 2021-03-29 17:22:41 -07:00
Josh Goldberg 57775ed405
Consider class field properties to redeclare parent definitions (#43194) 2021-03-29 17:20:25 -07:00
Daniel Rosenwasser a3d207a905
Improve (and actually use) "always truthy promise" error (#43023)
* Modify error message and actually use the error message.

* Accepted baselines.
2021-03-29 12:44:05 -07:00
Anders Hejlsberg 4774666f23
Support relations and inference between template literal types (#43361)
* Support assignment and inference between template literal types

* Add tests

* Accept new baselines

* Add comments
2021-03-28 13:11:56 -07:00
Ryan Cavanaugh 451089e8ef
Rename isWrite -> writing (#43405) 2021-03-27 21:56:50 -07:00
Ryan Cavanaugh ff233a9ac2
Variant accessors (#42425)
Allows accessors to have different access modifiers and types

Fixes #2845, #2521
2021-03-26 20:11:02 -07:00
Wenlu Wang 2f0c8b2bea
--noImplicitOverride (#39669)
* wip: add types

* wip

* Add cases

* Add some case

* Add more check

* accept baseline

* add abstract abd declare method

* add override in declaration

* accept baseline

* add property override

* Fix decalre modifier

* update baseline

* Add more cases

* make lint happy

* make lint happy

* Update description

* Add codefix

* simplify code

* accept baseline

* Update desc

* Accept baseline

* Add override completions

* filter out implements field in override context

* fix tests

* Add parameter property check

* Accept baseline

* acept baseline

* Add parameter property to declaration code action

* Add quickfix for override parameter property

* fix code style

* Add override with interface tests

* Add more cases about modifier position

* rename flag

* rename flags

* Added tests.

* Accepted baselines.

* Always issue errors for unnecessary 'override' modifiers.

* Accepted baselines.

* Override perf (#4)

* try cache check result

* pre check for override

* Do not issue error if implement abstract

* Add abstract-spec check

* Avoid override dead lock

* Add more case

* Add codefix for new error

* Fix error message

* Add jsdoc override tag (#6)

* Override jsdoc tag (#7)

* accept baseline

* Disallow codefix in js

* update baseline

* Omit override in d.ts

* Add more case in js

* Accept baseline

* fix override js test

* fix crlf

* Revert merge conflict changes

* Accept baseline

* Avoid space

* Fix CR issues

* Accept baseline

* Fix typo and add more check

* Fix error name

Co-authored-by: Daniel Rosenwasser <Daniel.Rosenwasser@microsoft.com>
2021-03-26 16:29:22 -07:00
Wenlu Wang 41dc625b0a
Add static index signature (#37797)
* Add static index

* fix lint

* make lint happy

* adjust test cases

* add more cases

* fix changes

* Add more case

* accept baseline

* fix error if extends others

* Update vfsUtil.ts

* use equal to empty array

* static signature of interface is an error

* Accept baseline

* Check index constraints for static signature

* Accpet baseline

* Fix crash

* fix crash

* Accept baseline

* Fix regression

* Fix crash

* always return new array
2021-03-26 15:30:09 -07:00
Andrew Branch 2d6a490363
Import statement completions (#43149)
* WIP

* WIP

* Get completion details working

* Start unifying eager and lazy auto imports

* Fix export=

* Fix completion details for totally misspelled names

* Almost fixed duplication...

* Fix remaining completion tests

* Refactor to support multiple origins for same symbol

* Make import fixes make slightly more sense

* Add cache back in

* Set insertText based on import kind

* Update API baselines

* Add semicolons, snippet support, and sourceDisplay

* Add some tests

* Update baselines

* Fix pattern ambient modules appearing in auto imports

* Fix tests

* Remove commented code

* Switch to valueDeclaration for getting module source file

* Small optimizations

* Cache module specifiers / importableness and export map separately

* Fix and test cache invalidation logic

* Update API baselines

* Add separate user preference for snippet-formatted completions

* Require first character to match when resolving module specifiers

* Fix AutoImportProvider export map cache invalidation

* Really fix auto import provider export map invalidation

* Update test added in master

* Use logical or assignment

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>

* Simply conditional by reversing

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>

* When file is deleted need to marked correctly in the project as removed file

* Simplify hasAddedOrRemovedSymlinks with cherry-picked fix

* Ensure replacement range is on one line

* Update baselines

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
Co-authored-by: Sheetal Nandi <shkamat@microsoft.com>
2021-03-26 14:47:07 -07:00
Anders Hejlsberg a26acf4540
Template literal types for contextually typed template literal expressions (#43376)
* Template literal types for contextually typed template literal expressions

* Accept new baselines

* Add regression test

* Add a few more tests
2021-03-26 10:32:05 -07:00
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
Ron Buckton fbd7f7db20
Update typescript-eslint to latest (#43381) 2021-03-25 14:46:16 -07:00
Titian Cernicova-Dragomir e638af7560
ES private class elements (#42458)
* Added support for private identifier methods.

* Added tests for private methods.

* Added check to only not allow private name method signatures in anything except classes.
Changes objects literal checking to not bail on first private name found in object literal.

* Added private accessors tests

* Transform private methods

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* Rename shouldTransformPrivateFields

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* Accept baseline

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* Use a single WeakSet for brand-check

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* Accept baseline

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* Add a test for using private methods in static field initializers

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* Add breaking checker test

Private methods inside class expressions should not error.

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* Add to instances once per-instance

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* Accept baseline

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* fix: evaluate receiver and rhs expressions before throwing on readonly assignment

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* Add a test for evaluating rhs before readonly assignment

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* Transpile private accessors

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* Accept baseline

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* fix: handle readonly/writeonly accessors

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* accept baseline

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* add a test for private setter without a getter

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* fix: getAllUnscopedEmitHelpers

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* fix: better handling of duplicate names

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* Fixed wrong error message for private methods in class expressions.

* change error message

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* add a test for async private methods with a higher target

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* fix: setter assignment returns rhs value

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* add a test for setter assignment return value

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* fix: handle duplicate accessors

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* add tests for duplicate accessors

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* docs: add missing parameter docs

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* Fixed failing test.

* baseline-accept: ordering changes

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* fix: attach weakSetName to property declaration

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* add a test for nested private methods

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* add a test with any

Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>

* Added support for static private fields accessors and methods.

* Added error message for private identifiers used with static decorators. There is no spec to go with this behavior as of yet.

* Fixed emit static bug that used private names outside of classes for initialization in esnext. Fixed issue where nested privates produce incorrect brand check.

* Added tests for private static fields methods and accessors.

* Fixed error messages and tests after merge.

* Accept new baseline.

* Improved duplicate identifier checks for static private class elements.

* Added error when using initializers with private static fields when useDefineForClassFields is not specified and target is esnext.

* Fixed code review issues.

* Removed semantically wrong emit on `useDefineForClassFields:true` with `target:esnext`

* Changed emit for uninitialized private static fields.

* Added runtime error in helper if a static private field is accessed before it was declared.

* Fixed code review comments for private identifier static class elements.

* add debug.assertNever for unknown node type (#53)

* Fixed code review issues.

* Fixed code review issues for private class elements.

* Fixes class shadowing when checking access to a private static class element.

* fix private methods/accessors in class expr inside a loop

* collapse switch case

* fix class name

* simplify getPrivateMethodsAndAccessors

* remove findPreviousAccessorInfo

* lazily create weakSetName identifier

* do not allocate a node if not needed in visitMehodDeclaration (#55)

* Removed all the emit helpers for private identifier methods accessors and modified the existing helpers for get and set fields to do the same job.

* Simplified emit for private identifier class elements.

* do not clone the receiver (#57)

* leave bad code in for #constructor and duplicate private names (#58)

* Added check for WeakSet collision.

* Added error for using a set only accessor.

* update keyof tests and ?? (#62)

* replace ?? with ||

* update keyof tests

* fix emit helpers comments

* produce an error if private field helpers are not up to date

* add tests

* fix setter-only compound assignment

* fix tests

* fix duplicated trailing comments (#64)

* clear receiver pos and setTextRange on helper calls

Co-authored-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
2021-03-24 18:15:50 -07:00
Nathan Shively-Sanders dcc27ebaf2
@link support, second try (#43312)
* Revert "Revert "Editor support for link tag (#41877)" (#43302)"

This reverts commit 451d4354b9.

* Fix parsing @link at end of comment

* Parse comments as string when no @link occurs

* fix lint
2021-03-22 16:39:35 -07:00
Wesley Wigham 9a256a1935
Adjust scanning of keywordy jsx namespace names, add grammar error for jsx dotted names containing namespace names (#43104) 2021-03-22 10:28:43 -07:00
Ron Buckton 9af313db77
Use shared binary trampoline in checker (#43035) 2021-03-19 18:54:51 -07:00
Anders Hejlsberg 15fae38b39
Improve narrowing of generic types in control flow analysis (#43183)
* Narrow type variables with union constraints when merited by contextual type

* Narrow generics with union type constraints as indicated by contextual type

* Accept new baselines

* Add tests

* Fix circularity for JSX elements

* Remove unnecessary isConstraintPosition information from flow cache key

* Update comment

* Add additional tests

* Rename to getNarrowableTypeForReference, remove getConstraintForLocation

* Add comment

* Fix removal of undefined in destructurings with initializers

* Use getContextFreeTypeOfExpression in discriminateContextualTypeByObjectMembers

* In obj[x], use constraint of obj's type only when x's type is non-generic

* Add comment
2021-03-19 17:12:57 -07:00
Andrew Casey b925c165c4
Only catalog types when tracing (#43304) 2021-03-19 09:59:04 -07:00
Anders Hejlsberg fbc9c942b2
Normalize target type after null-stripping unions in relationship checks (#43202)
* Normalize target type after null-stripping

* Add regression tests
2021-03-19 09:19:25 -07:00
Nathan Shively-Sanders 451d4354b9
Revert "Editor support for link tag (#41877)" (#43302)
This reverts commit ec77bff332.
2021-03-18 14:42:25 -07:00
Anders Hejlsberg a21f61f746
Fix narrowing of intersections of type variables and primitive types (#43131)
* Fix narrowing of intersections of type variables and primitive types

* Add tests
2021-03-18 08:55:50 -07:00
Nathan Shively-Sanders ec77bff332
Editor support for link tag (#41877)
* Initial scribbles

* Compiles but provides spans instead of location pairs

Probably need to fork the services/server types and provide a conversion
with Session.toFileSpan. Not sure where to put the conversion.

* Switch to DocumentSpan

In theory this is already better supported, but not sure practise bears
that out.

* Builds w/protocol types + conversions

* cleanup:better names and scrub TODOs

* fix test harness too

* Misc

1. Simplify protocol after talking to @mjbvz.
2. Add more tests.
3. Initial notes about where to add parsing.

* Parse and store links in the compiler

The text of the link is still stored in the comment text, but that's now
kept in an object instead of just a string. Each link has the parse for
the entity reference, if there is one.

Needs lots more tests -- this just makes all the existing jsdoc tests
pass.

* more tests and some fixes

* Fix other failing tests

* fix bad merge

* polish parser

* improve names and array types

* slight tweaks

* remove some done TODOs

* more tests + resulting fixes

* add+fix cross-module tests

* Support `@see {@link`

Plus find-all-refs support equivalent to @see's.

* add server test

* Make comments actually part of the AST

* Add span for link.name in language service/protocol

* Make checker optional in getJSDocTags

Also change to JSDocCommentText from JSDocCommentComment

* Use getTokenValue instead of getTokenText

Measure twice, slice once

* Add missing support for top-level links

The language service and protocol were missing support for top-level
links. This commit adds that plumbing.

* add string back to comment type in node constructors

* Full parse of link tags and jsdoc comment text

- Doesn't pass fourslash yet, I'm going to switch to baselines for
  failures there.
- Still needs some work on the protocol to convert file+offset to
  file+line+offset.

* fix lint

* Fix missing newlines in inferFromUsage codefix

* Parse jsdoc comments as text node/link array

And switch to line+character offsets in the protocol

* Fix fourslash tests

Mostly ones that can't be baselined, but I switched a couple more over
to baselines

* Improve types and documentation

* Test+fix @link emit, scrub other TODOs

* update API baselines

* test that goto-def works with @link

* Split link displaypart into 3

One for link prefix and suffix, one for link name, and one for link
text.

* update baselines

* Provide JSDocTagInfo.text: string to full clients by default

Instead of upgrading them to displayparts.

* Real server tests

* Disambiguate {@link} and @param x {type}

They are ambiguous; previously the parser preferred the type
interpretation, but will now look ahead and parse links instead when the
prefix is `{@link`.

* Add explanatory comment in test

* fix location in richResponse in protocol

* update API baseline

* Address PR comments

1. Add a cross-file goto-def test.
2. Switch from per-message args to UserPreference.

* use arraysEqual from core
2021-03-16 16:26:01 -07:00
Armando Aguirre 322c70fd82
Fixed reporting error for type arity (#43111) 2021-03-13 01:01:04 -08:00
Hai Lin Zhang e44d39d4eb
Updated error message for TS2539 (#39827)
* Updated error message for TS2539

* Switch to multiple error messages

* inline variable

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2021-03-11 15:51:15 -08:00
Wesley Wigham 2643e65da4
Add missing relationship allowing a type to be assignable to a conditional when assignable to both branches (#30639)
* Finally add that missing relationship allowing a type to be assignable to both branches of a conditional

* Explicitly write out Ternary.Maybe

* Add slightly modified example from #25413

* fix sick sentence

* Loosen check to skip false branch constraint check to consider `infer` parameters as always satisfied in the extends clause

* Simplify things a bit, only instantiate once

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2021-03-11 11:56:55 -08:00
Nathan Shively-Sanders b2d1f537f1
Bloomberg computed property name fix (#43197)
* Fix property name bindings for class expr in loops

* Fix block-scope capturing with prop initializers

Co-authored-by: Joey Watts <joey.watts.96@gmail.com>
2021-03-11 10:32:42 -08:00
Titian Cernicova-Dragomir 71661b932a
Fixed issue where non null assertion caused getFlowTypeOfReference to return the declared type if the type was already narrowed to never. (#35863)
This was caused by the fact that getTypeWithFacts(resultType, TypeFacts.NEUndefinedOrNull) will return never both if resultType was already never and if resultType does not contain undefined or null. In the latter case returning the declaring type is correct, in the former case this causes something narrowed to never to still be typed as the original declared type.
2021-03-11 07:33:33 -08:00
Jack Williams 3d6650eb4f
Fix #38608 (#38610)
* Fix #38608

* Work for narrowed non-unions

* Add comment
2021-03-11 07:32:49 -08:00
Oleksandr T 3c576f108c
fix(41027): handle unused static members (#41103) 2021-03-11 06:39:20 -08:00
Oleksandr T b1f86eca3e
fix(42265): Error accessing abstract property in constructor via destructuring (#42276) 2021-03-10 07:26:50 -08:00
Tarik Eshaq 626e78c959
Clearifies protected error message (#42599) 2021-03-09 15:58:31 -08:00
Ron Buckton ec4863cc0e
Fix37991 (#43166)
* Add failing test

* Fix tslib check errors for commonjs imports
2021-03-09 11:43:19 -08:00
Oleksandr T 9610c16cc8
fix(42380): include JSDoc comments in declarations for static/prototype methods (#42454) 2021-03-09 11:37:40 -08:00
Anders Hejlsberg f918bd9c76
Exclude enum/number compatibility rule from comparable relation (#42472)
* Exclude old number/enum literal compatibility rule from comparable relation

* Add tests

* Accept new baselines
2021-03-06 06:52:00 -08:00
Anders Hejlsberg ba56fca0bf
Remove undefined from optional properties when inferring to index signatures (#43086)
* Remove undefined from optional properties when inferring to index signatures

* Add tests
2021-03-06 06:51:02 -08:00
Jonas Hübotter 25375a2213
Unnecessary elaboration about not being assignable to type parameters (#42952) 2021-03-05 11:15:05 -08:00
Anders Hejlsberg 408c804103
Properly instantiate inferred constraints in conditional types (#42747)
* fix combined type mapper in getConditionalType

* Add regression tests
2021-03-05 07:26:27 -08:00
Daniel Rosenwasser 9862b031b0
Relax requirements on index signatures to 'any' when a type also contains a string index signature to 'any' (#43065)
* Added test.

* Accepted baselines.

* Allow other index signatures to 'any' if there is a string index signature to 'any'.

* Accepted baselines.
2021-03-04 17:42:00 -08:00
Oleksandr T ca8d9e4402
fix(39836): allow type declaration/unknown type in catch arguments in JavaScript files (#42392) 2021-03-04 17:19:35 -08:00
Nathan Shively-Sanders c497b487a7
Add undefined to Symbol.valueDeclaration (#43033)
* About halfway through the checker

I'm going to merge with master to avoid clashing with the declaration
fix.

* Add undefined to Symbol.valueDeclaration

Also add undefined to a number of utility functions that have always
accepted it, but never added it to their type.

* Fix lint from code review

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>

* remove obsoleted fix from inferFromUsage

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
2021-03-02 12:36:26 -08:00
Zen 3d1c6e8f2f
fix(42765): require should not work in ts files (#42792)
* add failing test

* fix(42765): require should not work in ts files
2021-03-02 06:54:31 -08:00
Nathan Shively-Sanders aa67b16e99
Add undefined to Symbol.declarations' type (#42975)
* Add undefined to Symbol.declarations' type

Symbol.declarations now has type `Declaration[] | undefined`.

I made a mistake somewhere in the checker related to JS checking, so
there are quite a few test failures right now.

* undo clever change to getDeclaringConstructor

* Address PR comments

1. More early-returns.
2. More line breaks.
2021-03-01 14:32:28 -08:00
Andrew Branch 993c503c84
Add 'data' property to completion entry for better coordination between completions and completion details (#42890)
* Add 'data' property to completion entry for better cooperation between completions and completion details

* Add doc comment

* Update API baselines

* Add server test

* Test session’s Full result

* Fix tests

* stableSort to fix server fourslash test

* Explicit verification of data parameter
2021-03-01 12:09:45 -08:00
Anders Hejlsberg ef2c98fc35
Optimize checking involving large discriminated union types (#42556)
* No array literal subtype reduction when contextual type is present

* Accept new baselines

* Fast path in relations and filtering of pure discriminated union types

* Create maps for mixed unions, but not for small or primitive only unions

* Create many-to-many mapping with certain limits, also use in CFA

* Use constituent maps in CFA for switch statements, cleanup, add comments

* Revert change to apparent contextual type / better criteria for map eligibility

* Deduplicate array literal element types

* Accept new baselines

* Filter in false case only when discriminant property has unit type

* Only subtype reduce unions with less than 100 distinct types

* Accept new baselines

* Caching and quick discriminant checks in subtype reduction

* Accept new baselines

* Remove deduplication logic now that subtype reduction was optimized
2021-02-28 16:38:20 -08:00
Daniel Rosenwasser df5ffc0ea1
Remove special any assignability for numeric index signatures (#41660)
* Only enable special assignability rule on string index signatures to 'any'.

* Accepted baselines.

* Added test.

* Accepted baselines.

* Renamed test files.

* Add non-erroring version of bclas'subClassThisTypeAssignable01.ts'

* Accepted baselines.

Co-authored-by: TypeScript Bot <typescriptbot@microsoft.com>
2021-02-25 17:36:09 -08:00
Nathan Shively-Sanders 2c5cee59f0
Fix: checkAliasSymbol crash when checking for @deprecated (#42971)
* Fix: checkAliasSymbol crash when checking for @deprecated

It's possible that we shouldn't be creating symbol with no declarations
from non-homomorphic mapped types, but for 4.2, the right fix is to make
the @deprecated-check in checkAliasSymbol ensure that
target.declarations is defined.

* Add bug number and accept baselines
2021-02-25 16:26:16 -08:00
Anders Hejlsberg ccdd688e4f
Properly handle duplicate enum types in type inference (#42943)
* Ensure no duplicates in named union list

* Add regression test
2021-02-25 13:54:14 -08:00
Wesley Wigham 3b35522fd0
Type lookup in getIntrinsicAttributestypeFromJsxOpeningLikeElement should match getIntrinsicTagSymbol (#42819) 2021-02-24 22:36:04 -08:00
Armando Aguirre 5c5d374b8d
Merge pull request #42904 from a-tarasyuk/fix/42339
fix(42339): "import" missing in transpiled code when variable typed as `unknown`
2021-02-24 18:25:53 -08:00
Andrew Branch 56cf2e68e8
Never-reducing intersections are not untyped function call targets (#42917)
* Never-reducing intersections are not untyped function call targets

* Don’t attempt to reduce union types
2021-02-23 17:22:41 -08:00
Wesley Wigham 8d58c8d90b
Base signatures resolve only the type parameters local to the signature, not all type parameters (#42703) 2021-02-23 16:17:57 -08:00
Wesley Wigham 6da262591c
Bail when comparing a specialized form of an already ongoing comparison (#42727)
* When structurally comparing similar types, check if we are already in the middle of a more general comparison of those same types

* Do the same, but with only string manipulations
2021-02-23 16:13:59 -08:00
Eli Barzilay 67f55aabd7 Extend the MetaProperty check to work for new.target too 2021-02-22 19:33:01 -05:00
Eli Barzilay d495957065 Add missing MetaProperty stuffs
Add missing parts in the binder and the checker to enable CFA +
narrowing of `import.meta` values.

Fixes #41468
2021-02-22 19:33:01 -05:00
Wesley Wigham 87d10eb055
Eliminate well known symbols as a concept in the checker and rely on unique symbols (#42543)
* Eliminate well-known symbols in the checker: 2021 edition

* Actually update the lib text to say unique symbol, too (this is unneeded with compat code in place, but this makes goto-def make more sense)

* Add test showing mismatched symbol constructor type interop

* Add more test cases for some other related issues this fixes

* Revert computed name change

* Style comments
2021-02-22 14:43:28 -08:00
Wesley Wigham 5a1d30815b
Combine multiple overloads into a single contextual signature (#42620)
* When noImplicitAny is set, combine multiple contextual overloads into a single signature, rather than producing `any` and an error

* Amalgamate intersection composite signature return types as intersections, rather than the prior exclusively union behavior

* Add another example from an issue, albeit slightly modified

* Fix newlines, add test from DT

* Interior remodelling
2021-02-22 13:34:47 -08:00
Oleksandr T 74e3ad9735 fix(42339): skip return if spread type is wrong 2021-02-21 12:27:46 +02:00
Nathan Shively-Sanders 0ce5c4a7ee
improve isRequireVariableDeclaration parameters (#42865)
One parameter is always called with `true`, so drop it.
2021-02-19 09:34:05 -08:00
ZYSzys 9950b6e596
Improve error messages for computed class property names (#42675) 2021-02-18 15:58:18 -08:00
Titian Cernicova-Dragomir a2ed469022
Fix for crash when using ca call expression on private identifier coming from an any typed variable. (GH #42860) (#42861) 2021-02-18 13:54:10 -08:00
Nathan Shively-Sanders 3d7ec8aab2
Improve @template lookup and resilience (#42851)
* Improve @template lookup and resilience

1. @template parsing may produce a template tag with a type parameter
whose name is the missing identifier. These tags should be skipped
in the checker because they receive an error in the parser.
2. The fix in #37819 was incorrect; there's no such thing as a type
parameter declared on a variable declaration. Instead, there needs to be a type
parameter declared on a jsdoc comment, because that's the scope for tags
like `@return` and `@typedef`.

There are 3 tests because either fix (1) and (2) fix the first test's
failure, but both are required to fix the last two tests' failures.

* remove containsParseError call
2021-02-17 17:21:17 -08:00
Josh Goldberg c3d7a56e90
Specified diagnostic for iterating known array type without --downlevelIteration (#40070)
* Specified error message for iterating known array types without --downlevelIteration

* Added extra target info to diagnostic

* NodeList too, a classic

* PR feedback: invert to allowsStrings; required param

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2021-02-17 17:12:32 -08:00
Anders Hejlsberg 412ecbc291
Reduce void | undefined only in conjunction with subtype reduction (#42846)
* Reduce void | undefined only in conjunction with subtype reduction

* Accept new baselines

* Add regression test
2021-02-17 14:48:07 -10:00
Chakib Ljazouli 3fe05c8c81
fix(37578): Deprecate variable name AllowQualifedNameInPlaceOfIdentifier (#38726)
* Change variable name AllowQualifedNameInPlaceOfIdentifier to AllowQualifiedNameInPlaceOfIdentifier

* Change deleting AllowQualifedNameInPlaceOfIdentifier to deprecating it instead.

* Fix failing tests

* Replace old value
2021-02-16 16:07:44 -08:00
Jack Works bb8b9db9f7 Add error for missing await in conditionals 2021-02-16 12:00:41 -05:00
Nathan Shively-Sanders 5deb676b3a
No did-you-mean-to-call error on casts Part 2 (#42779)
* No did-you-mean-to-call error on casts

I chose to do the ad-hoc check rather than yet another tree walk.

1. It's faster to run and easier to read.
2. This error came from looking at real code. It happened twice, so I
think the best estimate for other uses that happened zero times is in
fact zero.
3. I couldn't think of other places to put the cast, given the
restrictions on `testedNode` just before the new code.

* Skip parentheses
2021-02-12 10:07:59 -08:00