Commit graph

8045 commits

Author SHA1 Message Date
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
Nathan Shively-Sanders f2bcb2101b
No did-you-mean-to-call error on casts (#42626)
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.
2021-02-12 09:36:55 -08:00
Oleksandr T 475036950e
fix(42133): fix instantiated undefined type from JS initializer (#42662) 2021-02-11 17:07:14 -08:00
Eli Barzilay c7bac6f2e6 Avoid getting undefined callSignatures/constructSignatures in getPropertyOfType
e350c357 (#40228) introduced a subtle bug: it switched the flags to an
alias, dropping `SymbolFlags.Property` --- and that makes
`symbolIsValue()` get to the `resolveAlias(symbol)` call, which leads to
`getPropertyOfType()` with`resolved.callSignatures`+`constructSignatures`
being `undefined`.  So initialize them in `setStructuredTypeMembers`
before calling `getNamedMembers()`.

Fixes #42350
2021-02-11 18:56:47 -05:00
Masato Urai a3ead92046 Improve error message for overload that takes spread arguments
The original error message on the last line I have added to in
functionParameterArityMismatch.ts was

    No overload expects 5 arguments, but overloads do exist that expect
    either 4 or Infinity arguments.

even if we do not define a function that takes Infinity arguments.

This PR changes it to this:

    Expected 0-6 arguments, but got 5 or more.

I feel it is still a bit strange but much more understandable.

Fixes #42418
2021-02-11 16:49:21 -05:00
Orta Therox 8c5fa5cc91
Revert assignability cases in getNarrowedType (#42231)
* Revert subtype narrowing changes from readonly array PRs

* Adds a test for the change

* More baselines
2021-02-09 15:03:11 -08:00
Eli Barzilay f462576ac2 Re-do tracing initialization and tests around calls
Make `tracing` either `undefined` or the same namespace as before.
Switching all calls to `tracing?.___` means that there is no cost for
a call or the arguments when tracing is not used.  Comparing two runs
without tracing (27 runs, drop 5+5, avg rest) I get:

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

(Makes it all private, so no api changes.)
2021-02-08 15:41:35 -05:00
Nathan Shively-Sanders aba932aefa
Create synthetic exports symbol for commonjs module (#42655)
* Commonjs module:create synthetic exports symbol

Previously, the `module` identifier in commonjs modules got a synthetic
type with a single property `exports`. The exports property reused the
file's symbol, which, for a module file, gives the correct exported
properties.

However, the name of this symbol was still the filename of the file, not
`exports`. This PR creates a synthetic symbol for `exports` by copying
in a similar way to esModuleInterop's `default` symbol in
`resolveESModuleSymbol` (although the intent there is to strip off
signatures from the symbol).

* correct parent of synthetic symbol
2021-02-05 10:56:03 -08:00
Anders Hejlsberg ab2729a99b
Smarter subtype reduction in union types (#42353)
* Exclude primitive types from union subtype reduction in most cases

* Accept new baselines

* Minor fixes

* Less aggressive checking of assertion function calls that don't affect control flow

* Accept new baselines
2021-02-04 11:18:30 -10:00
Anders Hejlsberg e2318217fb
Strip nullable types from 'this' type in inference with optional chain calls (#42536)
* Properly strip nullable types from this type in optional chain calls

* Add regression test
2021-02-03 13:50:23 -10:00
Daniel Rosenwasser cce4bfbc7c
Revert changes for template literal types, keeping tests. (#42588)
* Revert changes for template literal types, keeping tests.

* Update Baselines and/or Applied Lint Fixes

Co-authored-by: TypeScript Bot <typescriptbot@microsoft.com>
2021-02-03 14:49:03 -08:00
Andrew Branch 71de94a543
Limit tuple size resulting from spread (#42448)
* Limit tuple size resulting from spread

* Update limit to 10k

* Update baseline after merge conflict
2021-02-02 14:02:35 -08:00
Andrew Branch c15f40abfa
Fix discriminant property narrowing through optional chain with null (#42503)
* Fix discriminant property narrowing through optional chain with null

* Accept baselines

* Add tests from Anders
2021-01-29 12:03:42 -08:00
Wesley Wigham 2730cb24f5
Only skip any checks for unwrapped tuples in conditionals, rather than all nondistributive conditionals for backcompat (#42447) 2021-01-28 23:36:43 -08:00
Nathan Shively-Sanders 9dbfaeef2d
Narrow QualifiedName inside typeof (#42540)
Previously this wasn't narrowed at all. Now there is control flow and
code in isMatchingReference.
2021-01-28 15:19:01 -08:00
Wesley Wigham 5a21291b7c
Propegate contextual types through nonnull assertion operators (#42526) 2021-01-28 09:24:54 -08:00
Nathan Shively-Sanders d2443a5df1
@typedef: Improve error spans from declaration emit (#42501)
* @typedef: Improve error spans from declaration emit

This is a proof-of-concept fix. I think it could be expanded for all of
jsdoc, but I only set it up for jsdoc type aliases. It could use a lot
of polish too.

* track error node in isSymbolAccessible instead

* Switch to using enclosingDeclaration

Remove trueErrorNode

* add test of @callback and @enum

* Better error + fix @enum error

Since enums don't have a name property, you *have* to call
`getNameOfDeclaration` to go looking through the AST for one.
2021-01-28 08:35:05 -08:00
Wesley Wigham 203a5ce78f
Include all properties from the mapped modifier type when calculating index types for mapped types with name types (#41976) 2021-01-27 13:32:46 -08:00
M.Yoshimura 701493fb80
Support top level "for await of" (#37424)
* Support Top Level "for await of".

* Add test cases for top level "for await of".

* Apply suggestions from code review

* add test cases

* remove redundant variables

* fix test baselines

* Update diagnostic message and tests

Co-authored-by: Ron Buckton <ron.buckton@microsoft.com>
2021-01-25 13:40:45 -08:00
AnyhowStep f529115b41
fixes microsoft/TypeScript#41286 (#41294)
* fixes microsoft/TypeScript#41286

* Added period to end of deprecation message

* Search Symbol.declarations for deprecated tag instead of Symbol.valueDeclaration

* renamed arg0 to deprecatedEntity, narrowed param type

* Added different deprecation message if signature is available

* address PR comments

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2021-01-25 13:33:28 -08:00
Andrew Branch 89c173fddc
Narrow via discriminant property through optional chain (#42450)
* Naive attempt at narrowing via discriminant property through optional chain

* Clean up test
2021-01-25 09:29:51 -08:00
Ron Buckton ee3fe472d7
Fix broken user and docker tests (#42431)
* Add --force to npm install script for user tests

* Migrate prettier to docker

* Fix vscode Dockerfile

* Fix stack space issue in isJSLiteralType

* Use --legacy-peer-deps based on npm version

* Fix xterm.js Dockerfile
2021-01-22 13:23:41 -08:00
Wesley Wigham 71d4ee5d60
Preserve alias information where possible when looking up union and intersection base constraints (#42430) 2021-01-21 13:06:56 -08:00
Matt Kantor 424b805d61
Fix "Cannot find name 'global'. Did you mean 'global'?" (#42262)
* Add tests for "Cannot find name 'global'. Did you mean 'global'?"

* Fix "Cannot find name 'global'. Did you mean 'global'?"

* Add an additional test case for spelling suggestions of "global".

* Name the boolean for suggestions being global scope augmentations.
2021-01-20 15:23:34 -08:00
Anders Hejlsberg 028f14c507
Filter origin types when filtering union types (#42378)
* When filtering a union type, also filter its origin type, if any

* Accept new baselines
2021-01-20 06:37:02 -10:00
Wesley Wigham 0d494abc77
Add missing unwrap call for the inferredExtendsType (#42409) 2021-01-19 18:02:35 -08:00
Anders Hejlsberg 70c82cab75
Include alias type arguments in keys for aliased types (#42365) 2021-01-15 16:00:55 -10:00
Wesley Wigham ab32fcadbd
Fix type parameter lookup for TypeAlias LibraryManagedAttributes (#42245) 2021-01-15 17:23:01 -08:00
Chris West 368cdfd29a
fix: const enums + isolatedModules emit invalid code (#41933)
* chore: failing test for const enums and isolatedModules

* fix: const enums + isolatedModules emit invalid code

In `isolatedModules` mode, the compiler does not inline const enums,
but also decides not to `import` them, leaving invalid code that
throws a `ReferenceError` at runtime.

This code:

```
import { SomeEnum } from './bar';
sink(SomeEnum.VALUE);
```

..should compile to either:

```
var { SomeEnum } = require('./bar');
sink(SomeEnum.VALUE);
```

..or (with const enum inlining):

```
sink(1 /* VALUE */);
```

..but actually compiles to:
```
sink(SomeEnum.VALUE);
```

..with no imports, which throws a ReferenceError at runtime.

---

The compiler has already realised that the symbol is a referenced const
enum, it just doesn't use this information when it comes to deciding
whether to emit an import. This commit additionally checks that
information, if we are compiling in isolatedModules mode.

---

In my opinion, this is not the correct fix, but it is the simplest. In
`isolatedModules` mode, `const enum` should probably be a compile error
(because there are no benefits and the complexity is high, and,
apparently, buggy). If not, the compiler should not be checking whether
something is a const enum, and should just be treating it as a regular
enum, and checking as if it was?

Fixes #40499.

* chore: extra test for type-only

* feat: explicitly ban --isolatedModules --preserveConstEnums false

* feat: isolatedModules implies preserveConstEnum

* Update src/compiler/diagnosticMessages.json

Co-authored-by: Andrew Branch <andrewbranch@users.noreply.github.com>

* chore: compiler test for argument incompatibility

* Add and fix test for namespace import of const enum

* Fix additional bug with reexport of const-enum-only module

Co-authored-by: Andrew Branch <andrewbranch@users.noreply.github.com>
Co-authored-by: Andrew Branch <andrew@wheream.io>
2021-01-13 15:51:08 -08:00
Nathan Shively-Sanders 2f5863754f
Improve naming of hasNonBindableDynamicName (#42297)
hasNonBindableDynamicName

1. Has 'non' in the name, and is only ever used negated.
2. Is true for a case that's not reflected correctly in the name -- it's
true for non-dynamic names as well.

I considered hasEarlyOrLateBindableName, but decided to use
hasBindableName for now.
2021-01-12 13:15:54 -08:00
Wesley Wigham c3dd845923
Better detect when typical nondistributive conditionals need to be defered by unwrapping their check and extends types (#42248) 2021-01-12 12:59:52 -08:00
Oleksandr T a276a6dce7
feat(31388): allow binding elements starting with an underscore (#41378) 2021-01-12 10:59:08 -08:00
Andrew Branch b0f5e35777
'in' should not operate on primitive types (#41928 + @andrewbranch) (#42288)
* 'in' should not operate on primitive types

* accept baselines of failing tests

* review

* update error message

* check if constraint of right type is assignable to a non primitive or instantiable non primitive

* do not throw errors where narrowing is impossible

* accept baselines

* fix test case failures

* Add more accurate comment discussion and document failing edge case in test

* Update baselines

Co-authored-by: Jonas Hübotter <jonas.huebotter@gmail.com>
2021-01-11 16:46:08 -08:00
Anders Hejlsberg c456bbd466
Support re-aliasing of type alias instantiations (#42284)
* New aliases for type alias instantiations

* New aliases for conditional, mapped, and anonymous object type instantiations

* Accept new baselines

* Fix issues with re-aliasing

* Accept new baselines
2021-01-11 13:29:46 -10:00
Oleksandr T 1ecf22884f
fix(42166): allow assertion signature for private identifiers (#42176) 2021-01-11 09:25:51 -08:00
Oleksandr T 1cd8ee4b8d
fix(42088): fix crash on unreachability condition in for statement (#42110) 2021-01-10 15:42:39 -08:00
Anders Hejlsberg 6aeb8c12cc
Preserve type aliases for union and intersection types (#42149)
* Create separate types for equivalent aliased unions

* Accept new baselines

* Preserve original types for union types

* Accept new baselines

* Preserve intersection origin for union types

* Accept new baselines

* Accept new baselines

* Preserve aliases during relationship checks

* Accept new baselines

* Preserve aliases for intersection and indexed access types

* Accept new baselines

* Compute intersection-of-unions cross product without recursion

* Accept new baselines

* Use denormalized type objects for origin / support 'keyof' origins

* Accept new baselines

* Fix fourslash test

* Recursively extract named union types

* Accept new baselines

* Map on union origin in mapType to better preserve aliases and origins

* Remove redundant call

* Accept new baselines

* Revert back to declared type when branches produce equivalent union

* Accept new baselines

* Don't include denormal origin types in regular type statistics

* Fix issue with unions not being marked primitive-only

* Allow new alias to be associated with type alias instantiation

* Accept new baselines

* Revert "Accept new baselines"

This reverts commit 4507270cc1.

* Revert "Allow new alias to be associated with type alias instantiation"

This reverts commit 2c2d06dfe1.
2021-01-08 15:19:58 -10:00
Sheetal Nandi 66ba15a3fd
If import is used in the file, prefer that import specifier over calculating new one (#42224)
* Test case where the wrong path is emitted

* If import is used in the file, prefer that import specifier over calculating new one
Fixes #39117

* Update Baselines and/or Applied Lint Fixes

* When non-relative path is used as user preference, ignore relative paths even if they are from the existing file

* Fix test

* Add comment

Co-authored-by: TypeScript Bot <typescriptbot@microsoft.com>
2021-01-08 15:20:29 -08:00
Orta Therox 055f363fba
Reverts #39277 removing bundledPackageName (#41499)
* Reverts #39277

* Bring back modeyule resolution for the test runner
2021-01-08 10:55:34 +00:00
Ron Buckton 0d284e6c26
Add support for abstract constructor types (#36392)
* Add support for abstract constructor types

* Add backwards-compatible overloads for creating/updating constructor types

* Reverting use of 'abstract' in lib/es5.d.ts due to eslint issues

* Update baseline due to reverting lib

* Add error for failing to mark an mixin class as abstract

* Fix declaration/quick info for abstract construct signatures
2021-01-07 17:11:14 -08:00
Wesley Wigham 11606e4de4
Do for unions of many empty-object-spreadables what we did for unions of 2 (#42233)
* Do for unions of many empty-object-spreadables what we did for unions of 2

* Accept baseline
2021-01-07 12:05:40 -08:00
Andrew Branch dbba8b358f
Make optional properties assignable to string index signatures (#41921) 2021-01-07 10:46:55 -08:00
Ron Buckton 44ec8ddaee
Fix array spread with sideeffects (#41523)
* Fix array spread with sideeffects

* Minor cleanup, ensure multiple emit helpers for outfile tests
2021-01-05 17:24:21 -08:00
Christian 7a5aadca69
Adjust TS2691 message for .ts import sources (#42184)
* Adjust TS2691 message for .ts import sources

* Only ModuleKind is needed for TS2691 logic

* Added tests for TS2691
2021-01-05 11:10:04 -08:00
Anders Hejlsberg e1fda834f3
Cache complex union and intersection relations (#37910)
* Cache complex union/intersection relations

* Accept new baselines

* Accept new baselines
2021-01-04 15:15:01 -10:00
Anders Hejlsberg 9b1718677a
Leading and middle rest elements in tuple types (#41544)
* Support starting and middle rest elements in tuples

* Accept new baselines

* Include all rest arguments in error span

* Accept new baselines

* Fix tests

* Add new tests

* Fix lint errors
2021-01-04 15:12:51 -10:00
Wesley Wigham 72dfc589a1
Retain CheckFlags.Late on symbols manufactured based on Late-bound symbols (#42205) 2021-01-04 15:49:52 -08:00
Oleksandr T b405fdd2ab
fix(41420): forbid optional chain in extends/implements (#41481) 2021-01-04 15:38:54 -08:00
Ron Buckton 6fac3ddfd4
Fix module resolution for import call emit (#41390) 2021-01-04 15:08:57 -08:00
Oleksandr T e108257fb6
fix(41965): fix error in definite assignment assertion context (#41989) 2020-12-30 11:45:18 -08:00
Nathan Shively-Sanders 3b222fe80c
Shrink error span on @type errors for signatures (#42024)
Previously, the error span was too large on @type errors on functions
when the type was not a function. The span covered the entire tag. This
PR changes the error node just to be the type of the type tag. In other words,
the error span was previously this:

```
@type {IncorrectType}
```

But is now just this:

```
IncorrectType
```

Fixes the first error from #41974, but not the other two.

Co-authored-by: Ashya Manning <ashyamanning@pursuit.org>
Co-authored-by: Nilber Remon <nilberremon@gmail.com>

Co-authored-by: Ashya Manning <ashyamanning@pursuit.org>
Co-authored-by: Nilber Remon <nilberremon@gmail.com>
2020-12-30 09:48:07 -08:00
Oleksandr T 303ed3a357
fix(42099): fix JSDoc optional properties declaration emit (#42116) 2020-12-28 13:34:55 -08:00
Song Gao 3442151f9d
completion for return const assertion. (#41475) 2020-12-22 09:16:30 +00:00
Anders Hejlsberg 22bee779d7
Properly make inferences from partial source type (#42038)
* Slightly less picky check in typesDefinitelyUnrelated

* Accept new baselines

* Add regression test
2020-12-19 07:18:44 -10:00
Oleksandr T a763600cc4
fix(41818): use last JSDoc comment related to host (#41858) 2020-12-18 13:24:58 -08:00
Wesley Wigham caebbe6714
Dont check computed name visibility results when the computed name representation is not in use (#41806) 2020-12-18 11:41:55 -08:00
Ron Buckton 4239904517
Report implicit any error for 'yield' result with no contextual type (#41348) 2020-12-18 09:55:33 -08:00
Song Gao 8cbc576954
Fix #41800 correctly. (#41895)
* fix as suggestion.

* Update moduleSpecifiers.ts

* compare symbol rather than string

* fix typo.

* fix

* fix lint.

* better name and more clear code

* fix comment.

Co-authored-by: Orta Therox <git@orta.io>
2020-12-16 18:56:18 -08:00
Wesley Wigham b217f22e79
Allow identical type parameter lists to merge in union signatures (#31023)
* Have signature identity checks look at the base constraint of type parameters, allow identical type parameter lists to merge in union signatures

* Update text in fourslash test

* Add whitespace to fix lint, remove duplicate impl

* Consolidate names

* Remove comparisons of type parameter defaults, add more test cases
2020-12-16 13:17:57 -08:00
Wesley Wigham 675cd4d7ce
Ensure factory symbol remains unused in react-jsx mode when not referenced in user code (#41905) 2020-12-16 13:11:48 -08:00
Anders Hejlsberg bec8071c65
Simplify constraint depth limiter logic (#41972)
* Explore at least 10 levels of constraints before checking for deeply nested types

* Simplify constraint depth limiter logic

* Add regression test

* Accept new baselines
2020-12-15 17:08:36 -10:00
Wesley Wigham b9f372ed00
Generalize the fastpath for comparisons of unions which are correspondences (#41903)
* Generalize the fastpath for comparisons of unions which are correspondences to unions resulting from the application of intersections

* Add comment
2020-12-15 13:57:23 -08:00
Anders Hejlsberg ee1f262698
Template literal types for template literal expressions (#41891)
* Infer template literal types for template literal expressions

* Update test

* Update another test

* Accept new baselines

* Minor fixes

* Add tests

* Accept new baselines

* Make new TypeFlags internal

* Accept new API baselines

* Ensure template literals assignable to String, Object, {}, etc.

* Add tests
2020-12-11 15:07:37 -10:00
Andrew Casey 3e72526600
Detect comparisons between large unions or intersections (#41574)
* Detect comparisons between large unions or intersections

If their multiplied size is greater than 1E6 (chosen based on the repro
in #41517), then we'll expend a large amount of time and memory
comparing them, so record a trace event.

Related to #41517

* Make an exception for primitive union comparisons

* Address PR feedback

* Pick up baseline change from master

* Eliminate diagnostic and only trace

* Don't check reportErrors
2020-12-10 13:52:41 -08:00
Andrew Branch 035c7ca905
Elide export assignment when it does not resolve to a value (#41904)
* Only mark aliases that resolve to values referenced

* Update other affected baselines

* Remove redundant check
2020-12-10 10:17:28 -08:00
Wesley Wigham 69143ecc5b
Reuse input nodes where possible when serializing jsdoc implements clauses (#41783)
* Reuse input nodes where possible when serializing jsdoc implements clauses

* Whitespace changes, per PR feedback
2020-12-08 12:13:37 -08:00
Anders Hejlsberg 646f5b3c4e
Preserve substitution types in check position of conditional types (#41841)
* Preserve substitution types in check types of conditional types

* Undo changes from #32093

* Add regression tests

* Accept new baselines
2020-12-07 16:38:00 -10:00
Oleksandr T f0340005a3
fix(41295): handle deprecated callbacks (#41310) 2020-12-04 16:37:25 -08:00
Oleksandr T a5c3cb4194
Improve uncalled function checks with parenthesized expressions in condition (#41748) 2020-12-04 16:20:14 -08:00
Wesley Wigham 360958e04c
JSDoc declaration emit should reuse input nodes where possible when serializing typedefs (#41760)
* JSDoc declaration emit should reuse input nodes where possible when serializing typedefs

* Style comments
2020-12-04 13:42:35 -08:00
kingwl 870f5b613a Merge branch 'master' into noPropertyAccessFromIndexSignature_fix 2020-12-04 12:47:38 +08:00
Anders Hejlsberg cd37a327a7
Fix non-homomorphic mapped type constraint issues (#41807)
* Less aggressive wildcard check, 'keyof any' constraint for 'infer T' in mapped type constraint position

* Accept new baselines

* Add regression tests
2020-12-03 16:36:45 -10:00
Andrew Branch 69bc3f3b0c
Allow type-only imports on ImportEqualsDeclarations (#41573)
* Allow type-only ImportEqualsDeclarations

* Suppress CJS-in-ESM error when type-only

* Add grammar error on import type in import alias

* Update API baselines

* Fix importsNotUsedAsValues with ImportEqualsDeclarations

* Make bad error talk words more good for Daniel. Fixes #41603

* One more error message baseline update

* Update transformer and emitter
2020-12-03 13:27:15 -08:00
kingwl 31e686b996 Fix codefix for noPropertyAccessFromIndexSignature 2020-12-03 11:51:41 +08:00
Wesley Wigham 9f9eed400c
Read the base construct signature from the static base type, not the instance base (#41767) 2020-12-02 13:30:46 -08:00
Wesley Wigham 0da5a7e4ba
Add missing BinaryExpression source side cases to isMatchingReference (#41765) 2020-12-01 14:47:14 -08:00
Anders Hejlsberg 4d6947ae14
Check nested conditional types for non-distributiveness in mapped types with 'as' clauses (#41713)
* Check nested conditional types for non-distributiveness

* Rename to maybeNonDistributiveNameType

* Add regression test
2020-12-01 12:07:47 -10:00
Anders Hejlsberg 4782c74b75
Propagate wildcard types in non-homomorphic mapped types (#41622)
* Propagate wildcard types in non-homomorphic mapped types

* Add regression test

* Accept new baselines

* Accept new baselines
2020-12-01 11:57:00 -10:00
inokawa d57954345b
Fix typos (#41723) 2020-12-01 13:46:41 -08:00
Wesley Wigham 2a3f5508ec
addImplementationSuccessElaboration admits declarations with no symbol (#41758) 2020-12-01 12:19:12 -08:00
Nathan Shively-Sanders 06fb724cd1
Improve uncalled function checks (#41599)
Fixes #41586
Fixes #41588

1. For binary expressions, if the immediate parent is an IfStatement,
then check the body of the if statement. I didn't walk upward to find an
IfStatement because in my experimentation I found that binary expression
uncalled-function errors are only issued when the expression is on the left of the
top-most binary expression.

2. For property accesses with interspersed calls, I added a
CallExpression case. In fact, any expression could appear here, but I
only want to fix calls for now since that's all we've observed in
Definitely Typed, and we didn't see anything else in the user tests or RWC
tests. I also didn't examine parameters of the intermediate call
expressions, but I don't think it's needed since the intent is to avoid
false positives.
2020-11-30 14:27:19 -08:00
Anders Hejlsberg 411c6d04c6
Fix getTypeFacts for pattern template literal types (#41693)
* Normalize `${string}` to just string, fix getTypeFacts

* Add tests

* Accept new baselines
2020-11-26 06:55:01 -10:00
Anders Hejlsberg ec1490fb44
Properly cache types for shared control flow nodes (#41665)
* Properly cache shared flow node types

* Add test
2020-11-25 14:51:38 -10:00
Andrew Casey a6ebf5d79a
Trace checkDeferredNode to cover JSX elements (#41572) 2020-11-24 14:33:15 -08:00
Oleksandr T 03877260f8
fix(41194): ignore jsxFrag identifier in import declarations (#41441) 2020-11-24 14:29:47 -08:00
Nathan Shively-Sanders d057f7a992
Remove-unused-identifiers codefix skips assigned identifiers (#41168)
* Remove-all-unused-identifiers skips assigned identifiers

Previously, fixUnusedIdentifier worked the same in fix-all mode as for a
single fix: identifiers with assignments would be deleted:

```ts
function f(a) { }
f(1)
```

becomes

```ts
function f() { }
f()
```

But any kind of argument will be deleted, even one with side effects.
For a single codefix invocation, this is probably OK.
But for fix-all, this could lead to multiple changes
spread throughout a large file.

Now fix-all will only delete parameters and variable declarations with
no assignments:

```ts
function f(a) { }
function g(a) { }
f(1)
g
let x = 1
let y
```

becomes

```
function f(a) { }
function g() { }
f(1)
g
let x = 1
```

* Don't remove assigned parameters for single codefix either

* add optional parameter test case

* Skip initialised params and binding elements

Based on PR feedback from @amcasey

* fixAll removes unused binding patterns completely

* Fixes from comments

Thanks @amcasey for the thorough review

* fix trailing space lint

* correctly remove-all array binding
2020-11-21 09:57:17 -08:00
Oleksandr T 9bbbe5c0c7
fix(41227): change message about incorrect property access with possible replacement with static access (#41275) 2020-11-18 12:50:32 -08:00
Mateusz Burzyński 09eb3d3b9c
Fix/jsx global preferred over config implicit (#41476)
* Add actual baselines for a problem with global namespace being preferred over config & pragma implicit ones

* Fixed an issue with global React namespace being preferred over config & pragma implicit ones

* Do not try to mark JSX classic runtime symbols as used when automatic runtime is used
2020-11-17 17:52:32 -08:00
Oleksandr T 6369d89711
fix(41492): make more friendly handling the missing call function in binary expressions (#41502) 2020-11-17 09:42:27 -08:00
Andrew Casey 79ffd03f8b
Add tracing support to tsserver (#41374)
* Add tracing support to tsserver

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

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

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

* Fix lint error

* Trace background work (for diagnostics)

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

* Add missing try-finally

* Use consistent capitalization

* Inline canPop call where underlying variable is available

* Clarify comments

* Include PID in build-mode file names

* Introduce more efficient popAll function

* Trace throwIfCancellationRequested rather than isCancellationRequested

* Remove unnecessary try-finally blocks

* Add a command-line argument for consistency with logging

* Fix rebase issues

* Address PR feedback

* Rename completionEvents to eventStack

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

* Rename stepCancellation to stepCanceledEarly

* Rename stepEarlyCancellation to stepCanceled and use flag instead

* Check correct variable on exit
2020-11-16 09:26:28 -08:00
Andrew Casey f79a78cd54
Merge pull request #41498 from amcasey/RemoveBeginEnd
Fold tracing.begin and end into push and pop
2020-11-11 15:23:11 -08:00
Wesley Wigham 44595042b2
Comment position feedback 2020-11-11 13:02:09 -08:00
Wesley Wigham 2c7c62d7fa
Merge branch 'master' into fix-incremental-jsx-crash 2020-11-11 13:00:47 -08:00
Andrew Casey 116000e548 Fold tracing.begin and end into push and pop
Storing the arguments on the stack will make it possible to forego
try-finally blocks when we start tracing in server scenarios, which have
to handle cancellation.
2020-11-11 12:58:00 -08:00
Nathan Shively-Sanders 9fb6acf1e1
Add missed resolveSymbol in commonjs import resolution (#41479)
Fixes resolution of export aliases in the postfix-property-access case
of commonjs require:

```js
const { x } = require('./foo').nested
x
```

This program would previously fail if `x` was an export alias.

Fixes #41422
2020-11-10 11:28:49 -08:00
Wesley Wigham dc7d997e4a
Fix crash on attempting to suggest a ts import for a synthetic js resolution 2020-11-09 14:05:17 -08:00
Nathan Shively-Sanders 64be2a8d16
Revert "Revert "feat(40197): handle uncalled function checks in binary expressions (#40260)"" (#41462)
This reverts commit cf3e28ea66.
2020-11-09 11:34:41 -08:00
Sheetal Nandi 9c60d5a4d3
Dont look for properties of Object and Function type when looking to resolve named import from module with export= (#37964)
* Add tests

* Dont look at object or function type when looking for members of `export=` type to be resolved by named imports
Fixes #37165

* Create separate cache when skipping function and object property augmentation

* Lookup in both cache if not skipObjectFunctionPropertyAugment
2020-11-03 12:22:30 -08:00
Thomas Williamson 8ed251d0c7
Support xml namespace prefix for JSX elements and attributes (#37421)
* Support xml namespace prefix for JSX elements and attributes

Just as with the `-` character, `:` is now also treated specially in JSX
element and attribute names, but is only allowed a single time, and not
at the beginning or end of the name, as is specified in the JSX spec.
All tests in jsxInvalidEsprimaTestSuite still fail, but for slightly
different reasons now. Two lines in jsxEsprimaFbTestSuite were
uncommented as they included elements with namespaces, and they now pass
without error.

* Add case for colons at ends of identifier

* Add case for jsx namepsace intrinsics

* Add cases with upcase idents for jsx namespaces

* Add case for jsx namespaces with react option

* Always consider jsx names with colon to be intrinsics

* Adjust comment about chars valid in jsx names but not js idents

* Fix minor typo in namespace prefix test case variable name

* Remove misleading comments on isUnhyphenatedJsxName
2020-11-02 15:34:36 -08:00
Oleksandr T 3f92a6498f
fix(40257): fix type parameters range (#40265) 2020-11-02 15:20:13 -08:00
Wenlu Wang ce8d702586
Add support for pedantic property access (#40171)
* Add support for pedantic property access

* accept baseline

* Update diag message

* Avoid pedantic

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2020-11-02 15:19:00 -08:00
okmttdhr 7db5f68144
Add index signature for anonymous object literal type (#37903)
* Use ts.map for stylistic consistency

* Show error only if noImplicitAny is set

* Accept baseline for noImplicitAnyIndexing

* Fix lint error

* Add test cases for indexedAccessWithFreshObjectLiteral
2020-11-02 14:35:56 -08:00
Oleksandr T f646ec87fc
fix(40901): skip checking custom arguments name in a constructor (#40912) 2020-11-02 14:35:07 -08:00
Wesley Wigham 479105090d
Merge pull request #41330 from weswigham/jsx-import-source-as-auto-import
Auto-include types for the jsx import source in the new jsx transforms
2020-10-30 16:51:04 -07:00
Wesley Wigham e044b56d7f
Merge pull request #40985 from weswigham/static-decl-ref
Adjust typeof import name lookup to better match type query lookup
2020-10-30 11:13:23 -07:00
Ron Buckton f944afd053 Fix double alias of complex export/import/default/namespace combination 2020-10-29 18:42:36 -07:00
Wesley Wigham 6714998e01
Auto-include types for the jsx import source in the new jsx transforms 2020-10-29 14:17:24 -07:00
Wesley Wigham 60b8bbcabe
Update style 2020-10-29 13:03:25 -07:00
Wesley Wigham d722392d81
Fix crashes when the global JSX namespace is an alias 2020-10-28 14:31:40 -07:00
Wesley Wigham ca8a15d37b
Merge pull request #41287 from weswigham/bind-exports-assigned-object-as-alias
Bind `module.export = {Thing}` with alias symbols
2020-10-28 13:14:20 -07:00
Anders Hejlsberg bd27bd8d47
Don't relate unmatched parameter positions in signatures (#41308)
* Don't relate unmatched parameter positions in signatures

* Add regression test

* Accept new baselines
2020-10-28 11:55:32 -07:00
Sheetal Nandi e17d95dada
When creating synthetic default symbol set parent as module symbol (#41282)
Fixes #40684
2020-10-28 11:24:40 -07:00
Wesley Wigham 6acce0ca6f
Merge pull request #41075 from uhyo/fix-36958
allow type narrowing with NonNullExpression
2020-10-27 20:10:27 -07:00
Oleksandr T af38ab90e2
feat(41249): allow import.meta with module: es2020 (#41274) 2020-10-27 17:26:15 -07:00
Anders Hejlsberg 40b81224f9
Remove string literals from unions with matching template literals (#41276)
* Remove string literals from unions with matching template literals

* Add tests

* Accept new baselines
2020-10-27 16:21:07 -07:00
Wesley Wigham d1bc6b1ba6
Bind module.export = {Thing} with alias symbols 2020-10-27 15:43:00 -07:00
Wesley Wigham c923023494
Merge pull request #41191 from weswigham/control-flow-comma-exprs
Track control flow for comma expressions in call expressions
2020-10-27 12:37:02 -07:00
Wesley Wigham aaa8b74229
Merge pull request #41257 from weswigham/jsdoc-declaration-emit-names
Fix visibility lookup for cjs require aliases
2020-10-27 12:01:52 -07:00
Anders Hejlsberg f9dcd9ef98
Don't cache Ternary.Maybe results when recursion is encountered during variance measurement (#41218)
* Don't record Ternary.Maybe results in cache during recursive variance measurement

* Add regression test

* Accept new baselines

* Use Ternary.Unknown to signal variance recursion

* Add comments

* Fix comment
2020-10-27 10:53:13 -07:00
Wesley Wigham 2abc8bd3fa
Limit binding element visibility painting to those biding elements which are declarations of aliases 2020-10-26 16:47:43 -07:00
Wesley Wigham ef810f5d02
Fix visibility lookup for cjs require aliases 2020-10-26 14:37:35 -07:00
Wesley Wigham 94b0e0e389
Merge pull request #41190 from weswigham/handle-binding-element-aliases
Handle the new js binding element alias symbols in JS declaration emit
2020-10-23 10:31:08 -07:00
Wesley Wigham 3bbc963303
Style feedback 2020-10-22 16:42:35 -07:00
Anders Hejlsberg d1f87d18b1
Support partial reverse mapped inferences with tuple types (#41106)
* Support partial reverse mapped inferences with tuple types

* Add tests

* Accept new baselines
2020-10-22 11:27:41 -07:00
Vincent Boivin 010ffdc121
New error format (#40974) 2020-10-21 15:02:49 -07:00
Eli Barzilay fe7ec1ee2e Tracing work
* Fix: `E` events need to have the same information that is on the
  corresponding `B` events.  (Superseded below.)

* Use `I` (not `i`) for instant events, so they show in devtools
  too.  (Though they don't go through the flame chart as they do in
  `about://tracing`, so they're not nearly as useful.)

* Abstract the code that writes the records in a single `writeEvent`
  local function.

* Make `args` optional, and default to `undefined` (which will not add
  them) at all.

* Drop the `{ "ts": ... }` wrapper around the `args`, after verifying
  that having arguments with names like `begin`, `end`, `pos`, `id`
  doesn't interfere with either UIs.

* Add `tracing.push`/`tracing.pop` for complete events, change a few
  `.begin`/`.end` to use these.  (The caveat is that until there's an exit
  handler to dump unterminated events, these won't show in the dump.  When
  that's done the push/pop variant can be used everywhere.)

* Add meta lines to name the process and the thread, and a line that
  avoids the warning when opening in devtools.
2020-10-21 17:31:33 -04:00
Wesley Wigham 6dde1621cb
Track control flow for comma expressions in call expressions 2020-10-21 12:31:29 -07:00
Anders Hejlsberg 5d021b401a
Don't reduce 'keyof M' for mapped types with non-distributive 'as' clauses (#41186)
* Don't reduce 'keyof M' for mapped types with non-distributive as clauses

* Add regression test

* Accept new baselines
2020-10-21 12:16:46 -07:00
Wesley Wigham f4255dd237
Handle the new js binding element alias symbols in JS declaration emit 2020-10-21 11:24:19 -07:00
Wesley Wigham aa9445bc15
Merge branch 'master' into empty-jsx-child 2020-10-19 14:54:20 -07:00
Wesley Wigham b8dfa28ca8
Do not consider empty jsx expressions semantically important children 2020-10-19 13:34:16 -07:00
Anders Hejlsberg 4638c685b1
Properly reduce intersections of string literal and template literal types (#41162)
* Properly reduce single element intersections

* Add regression test

* Accept new baselines
2020-10-19 13:05:29 -07:00
Anders Hejlsberg 3918e6c535
Move anonymous type instantiation cache from AST node to root type (#41084)
* Move anonymous type instantiation cache from AST node to root type

* Use "root" type reference as cache location for deferred type references

* Add test

Co-authored-by: Andrew Branch <andrew@wheream.io>
2020-10-19 07:26:48 -07:00
Wesley Wigham ce1947b0be
Merge pull request #41070 from weswigham/use-minimal-endings-in-bundled-declaration-emit
Use minimal endings when generating declarations for js
2020-10-14 15:29:50 -07:00
Wesley Wigham 84726be01a
Merge pull request #40597 from weswigham/allow-instanceof-array-to-narrow-readonly-array
Handle the mapping between Array and ReadonlyArray in isTypeDerivedFrom
2020-10-13 15:08:17 -07:00
uhyo 58781b0d41 allow type narrowing with NonNullExpression 2020-10-13 13:00:09 +09:00
Wesley Wigham 1cdb621257
Use minimal endings when generating declarations for js 2020-10-12 16:01:32 -07:00
Wesley Wigham 34fb470087
Merge branch 'master' into spread-compact-literals 2020-10-12 14:10:51 -07:00
Andrew Branch a09a7144e7
Fix crash resolving ImportTypeNode in JSDoc (#40838) 2020-10-12 09:33:39 -07:00
Alex T 05be3b421a
fix: show deprecated error for alias (#40961) 2020-10-12 08:45:08 -07:00
Nathan Shively-Sanders a109b5d5c8
Fix relative paths in commonjs decl emit w/property access (#40986)
```js
const x = require('./foo').y
```

was incorrectly using the unmangled require path as the temp name in
emit:

```
import ./foo_1 = require('./foo')
import x = ./foo_1.y
```

It now uses the imported identifier:

```
import x_1 = require('./foo')
import x = x_1.y
```

Discovered while fixing #37832
2020-10-09 16:32:57 -07:00
Wesley Wigham 39c2a09b1f
Fix crash due to unchecked cast in addImplementationSuccessElaboration 2020-10-09 10:53:59 -07:00
Wesley Wigham f324fde873
Fix lint 2020-10-08 17:34:06 -07:00
Wesley Wigham de204430ec
PR feedback 2020-10-08 17:17:06 -07:00
Wesley Wigham 6b29f36674
Rename variable 2020-10-08 16:14:47 -07:00
Wesley Wigham a49099fd15
Add elaboration when call fails all overloads but succeeds against the implementation signature 2020-10-08 14:55:14 -07:00
Nathan Shively-Sanders cf3e28ea66 Revert "feat(40197): handle uncalled function checks in binary expressions (#40260)"
This reverts commit eaf4f46c17.
2020-10-07 14:14:49 -07:00
Alex T eaf4f46c17
feat(40197): handle uncalled function checks in binary expressions (#40260) 2020-10-07 14:06:42 -07:00
Wesley Wigham c6734afba5
Adjust typeof import name lookup to better match type query lookup 2020-10-07 12:08:20 -07:00
Anders Hejlsberg f34220980b
Add isDeeplyNestedType logic to getResolvedBaseConstraint (#40971)
* Add isDeeplyNestedType logic to getResolvedBaseConstraint

* Accept new baselines

* Add regression test

* Accept new baselines

* Fix lint issue
2020-10-07 05:50:06 -07:00
Alex T 0c7d45a9ed
fix: change deprecated FunctionLike type to SignatureDeclaration (#40795) 2020-10-06 07:51:01 -07:00
Tiago Tristao 1191e2e731
Fix class expression from being assignable if types don't match (#40660)
* Fix class expression from being assignable if types don't match

* Fix class expression from being assignable if types don't match
2020-10-05 13:21:38 -07:00
Wesley Wigham 77df9faabf
Merge pull request #40886 from weswigham/error-on-anonymous-type-with-nonlocal-unique-symbol
Limit when we allow nested unique symbols to be serialized
2020-10-05 11:59:45 -07:00
Orta Therox dd84bc1dc9
Handles creating a reasonable AST when destructuring into a parens'd expresssion (#40115)
* Handles creating a lgical AST when destructuring  into a parens

* Adds an async example
2020-10-05 14:12:47 -04:00
Vincent Boivin 61aadc4ce2
fix(40320): Better errors when using properties/methods from newer versions of ECMAScript (#40650)
* Update package-lock.json

* Suggesting a library for a missing property/method

* Added more types and added tests

* Added more tests to cover all the latest features

* Added bigintarrays and dataview methods

* Fixed typo in template

* Transform old error message to use 2nd template slot

* Removed test that has been split up between es2015 and es2016+

* Use empty arrays and remove unnecessary function call

* merge

* Added early bail-out and updated baselines

* Implemented early bail-out (misread)

Co-authored-by: TypeScript Bot <typescriptbot@microsoft.com>
2020-10-02 16:47:37 -07:00
Richa Deshmukh b748484031
#40763 Fixed: Bad error message when forgetting a comma in an array of templ… (#40907)
* #40763 Bad error message when forgetting a comma in an array of template strings

* Code review fixes
2020-10-02 15:37:59 -07:00
Nathan Shively-Sanders 477e4b1a9d
Fix function merged with export as namespace sourcefile (#40908)
Previously it crashed because the function-checking code didn't expect
a node with no parent.
2020-10-02 10:50:12 -07:00
Nathan Shively-Sanders b8ebad48d7
Fix recursive types in @typedef (#40861)
* Fix reference types in @typedef

Previously this code path was broken and untested. Fortunately the fix
is simple.

* add test case from #40234

* update baselines
2020-10-02 08:46:42 -07:00
Sai Geetha Kandepalli Cherukuru 0ba250dc3b
Updated error message for TS1031 (#40889)
Co-authored-by: Sai Geetha <sai.geetha@ssi.samsung.com>
2020-10-01 16:37:14 -07:00
Wesley Wigham b86dc34386
Limit when we allow nested unique symbols to be serialized to when their declaration is within the same file as the context 2020-10-01 15:20:01 -07:00
Wesley Wigham da86332120
Limit export= js declaration emit to only json source files (#40882) 2020-10-01 14:55:24 -07:00
Andrew Branch 5fbe9806db
Fix noUncheckedIndexedAccess with tuple rest types and generic index types (#40681)
* Fix noUncheckedIndexedAccess for tuple rest elements

* Defer inclusion of undefined for generic indexed access types

* Create separate IndexedAccessTypes depending on whether --noUncheckedIndexedAccess applies

* Undo accidental export

* Parenthesize for clearer precedence
2020-10-01 13:56:13 -07:00
Anders Hejlsberg 950dad9c29
Propagate wildcard types in template literal type construction (#40875)
* Propagate wildcard types in template literal type construction

* Add regression test

* Accept new baselines
2020-10-01 13:36:08 -07:00