Commit graph

8045 commits

Author SHA1 Message Date
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
Wesley Wigham b93da6291a
Emit non-identifier enum member references as typeof parent[some name] (#40679) 2020-10-01 13:06:17 -07:00
Anders Hejlsberg 4538e7352f
Properly distribute over unions in keyof for mapped types with as clause (#40837)
* Properly distribute over unions in keyof mapped types with as clause

* Accept new baselines

* Add regression test

* Accept new baselines
2020-10-01 09:36:51 -07:00
Andrew Casey 35111231f7
Merge pull request #40755 from amcasey/SpreadLimit
Enforce a size limit in getSpreadType
2020-09-30 13:44:59 -07:00
Nathan Shively-Sanders f615e229d3
Fix default property assigned prototype (#40836)
* Fix default-property-assignment decls+prototype property decls

The check in getAssignedClassSymbol forgot to allow for default-property
assignment declarations, in part because it wasn't using a utility
function to do so.

* small cleanup

* make allowDeclaration parameter required
2020-09-30 08:36:52 -07:00
Alex T df33dd593f
fix(40441): show deprecated error for deprecated property in namespace (#40605) 2020-09-30 08:26:35 -07:00
Wesley Wigham 2428ade1a9
Match suffix _after_ prefix when inferring literals out of templates (#40841) 2020-09-29 16:34:58 -07:00
Sidharth Vinod 7c0f0d2c69
Update type diagnostic messages with --save-dev (#40776) (#40784)
* Update type diagnostic messages with --save-dev (#40776)

* Fix Baselines
2020-09-28 23:47:16 -07:00
Andrew Casey 9f5310fd8d Use the existing checkCrossProductUnion helper 2020-09-25 13:37:54 -07:00
Wesley Wigham 17d996e6b2
Revert 7181c2af 2020-09-25 11:45:16 -07:00
Andrew Casey 6650496e85 Enforce a size limit in getSpreadType
When a union is spread into a union, the sizes are multiplied,
potentially resulting in an enormous union (especially if there are
repeated spreads).  This check detects cases that used to run out of
memory.

Fixes #40754
2020-09-24 14:52:42 -07:00
Nathan Shively-Sanders eac75f375d
CommonJS imports support destructuring+property access (#40702)
* CommonJS imports support destructuring+property access

Fixes #40578 for prettier

* will I ever remember semicolons? haha no

* move code around

* move function declaration closer to use

* Add missing space after `if`

Thanks to @weswigham for noticing this. Somehow it passed the linter.
2020-09-24 14:42:59 -07:00
Wesley Wigham a960463cf3
Allow pattern literal types like http://${string} to exist and be reasoned about (#40598)
* Allow pattern literal types like `http://${string}` to exist and be reasoned about

* Allow bigint, number, null, and undefined in template holes

* Add test of the trivia case

* Handle `any` in template holes, add assignability rules for template -> template relations

* Explicitly test concatenated patterns

* PR Feedback
2020-09-23 01:08:58 -07:00
Wesley Wigham a91c2879ef
Allow discrimination to identical object types when discriminating contextual types (#40574)
* Merge identical object types when discriminating contextual types

Co-authored-by: Orta <ortam@microsoft.com>

* Allow identical discriminants when discriminating, rather than trying to unify identical union members

* Fix lint

Co-authored-by: Orta <ortam@microsoft.com>
2020-09-23 00:51:14 -07:00
Wesley Wigham ad2a07440c
Fix crash on js declaration emit of export assigned default augmented function (#40596)
* Fix crash on js declaration emit of export assigned default augmented function

* {sp}
2020-09-23 00:50:12 -07:00
uhyo 61910e8c97
Fix missing constraints for parenthesized infer T (#40406)
* add tests

* consider parenthesized types in getInferredTypeParameterConstraint

* update tests
2020-09-23 00:48:40 -07:00
Wesley Wigham 10b240cde3
Allow an infer type node to resolve its own name (#40483) 2020-09-22 21:21:13 -07:00
Anders Hejlsberg 5d6cce5ca7
Const contexts for template literals (#40707)
* Support const assertions with template literal expressions

* Add tests

* Accept new baselines
2020-09-22 13:11:17 -10:00
Alex T 587252cbe9
feat(40674): make error messages more consistent (#40675) 2020-09-21 13:22:15 -07:00
Alex T 0310b530d8
feat(40663/40664): improve error messages for assignment assertions '!' (#40669) 2020-09-21 11:20:01 -07:00
Anders Hejlsberg fbce4f6c98
Intrinsic string types (#40580)
* Introduce Uppercase<T> and Lowercase<T> intrinsic types

* Accept new API baselines

* Add Uppercase/Lowercase/Capitalize/Uncapitalize to lib.d.ts

* Update fourslash

* Add an 'intrinsic' keyword

* Update template literal type tests

* Accept new API baselines

* Minor fixes

* Switch Capitalize<T> and Uncapitalize<T> to intrinsic types

* Add tests

* Accept new baselines

* Accept new baselines

* Remove template literal type casing modifiers

* Update tests

* Accept new baselines

* Add more tests

* Normalize nested template literal types

* Add normalization tests

* Accept new baselines

* Update tests
2020-09-21 07:09:29 -10:00
Anders Hejlsberg ce3dbef5f7
Support properties of mapped types in assertion control flow analysis (#40482)
* Support properties of mapped types in assertion control flow analysis

* Add regression test

* Accept new baselines
2020-09-21 07:07:29 -10:00
Anders Hejlsberg 17c7c261d4
Properly preserve modifiers in homomorphic mapped types with 'as' clauses (#40633)
* Use original property name to fetch source property for modifiers

* Add regression test

* Accept new baselines
2020-09-19 06:12:39 -10:00
Andrew Branch 735a67a05e
Fix iterable contextual type (#40592) 2020-09-17 10:42:47 -07:00
Wenlu Wang f66c8e6a69
Fix missing renamed compiler flags (#40606) 2020-09-16 22:41:02 -07:00
Wesley Wigham 081f98232b
Handle the mapping between Array and ReadonlyArray in isTypeDerivedFrom 2020-09-16 13:31:13 -07:00
Wesley Wigham 98314d77e8
Use unexpanded parameter list in serialization when the expanded list has a non-trailing variadic position (#40556) 2020-09-14 19:56:24 -07:00
Ron Buckton dba042d7d5
Add quick fix to add 'void' to Promise resolved without value (#40558)
* Add codefix to add 'void' to Promise resolved without value

* Add specific error message in checker to reduce quick-fix time in editor
2020-09-14 19:12:33 -07:00
Nathan Shively-Sanders ec36d73e7a
Fix error on duplicate commonjs exports (#40545)
* Fix error on duplicate commonjs exports

Previously, the code missed setting the parent pointer for the lhs
access expression.

Also add declaration emit of element access expressions, missed in my
previous PR.

* Switch to excludes=None, add test case

CommonJS exports have None excludes, but still have an error issued by
the checker. This is the previous behaviour even though it would be nice
to add some exclusions.
2020-09-14 13:12:51 -07:00
Wesley Wigham 94123d5744
Issue a diagnostic when the node builder performs truncation despite the NoTruncation flag being set (#40477) 2020-09-14 12:20:57 -07:00
Ryan Cavanaugh 21d781fa54
Fix incorrect name of index signature flag in implementation (#40541) 2020-09-14 09:32:22 -07:00
Anders Hejlsberg 57c8938d9e
Consistent inferences when inferring to template literal type (#40518)
* Consistently make inferences when inferring to template literal type

* Add tests

* Accept new baselines
2020-09-12 16:33:33 -10:00
Nathan Shively-Sanders 9c99870058
Support element access aliases: exports["x"] = x (#40514) 2020-09-11 18:05:47 -07:00
Anders Hejlsberg eee799fe0c
Properly check types in template literal placeholders (#40498)
* Properly check types in template literal placeholders

* Add regression test

* Update test

* Accept new baselines
2020-09-11 14:48:35 -10:00
Ryan Cavanaugh 3d235b42a0
--noUncheckedIndexedAccess (#39560)
* Initial implementation + tests

* linty

* Support destructuring declarations and assignments

* lint

* Fix destructuring assignment and element access into known properties

* Update baselines

* Rename flag to unUncheckedIndexedAccess

* Add test for unique symbol indexing

* Fix flag order in baselines

Co-authored-by: Andrew Branch <andrew@wheream.io>
2020-09-11 14:43:10 -07:00
Wesley Wigham a36f17c1f8
Add emit support for jsx/jsxs experimental jsx runtime api (#39199) 2020-09-11 10:44:52 -07:00
Andrew Branch 083129f005
A union including non-iterable types is not iterable (#40350)
* WIP

* If method type derives solely from the global iterator or generator type, use its type arguments

* Add test for problem fixed as side effect
2020-09-11 09:31:22 -07:00
Orta Therox cdafb7157b
Replaces the default module index resolver with '/index' instead of '' when handling internal routing for dts bundles (#39277)
* Adds support for declaring the bundled name of a dts module export

Co-authored-by: Wesley Wigham <wwigham@gmail.com>

* Adds baselines

* Update the tests

* Try to reduce the scope of the bundledPackageName error

* Use the flag in more baselines

* Get it green

* More tests

* Handle more feedback

* More test cleanup

* Set the moduleResolution for the tsconfigs

Co-authored-by: Wesley Wigham <wwigham@gmail.com>
2020-09-11 08:12:07 -04:00
Andrew Casey 45dedd6b87
Merge pull request #40063 from amcasey/ChromeTracing
Trace key operations
2020-09-10 13:01:47 -07:00
Wesley Wigham 683979246f
Fix JS declaration emit for acessors in a class/interface merge (#40456) 2020-09-10 10:39:41 -07:00
Anders Hejlsberg 6f0c91c4cb
Template literal types and mapped type 'as' clauses (#40336)
* Initial implementation of string template types

* Accept new API baselines

* Accept new baselines

* Unified checking for large cross product union types

* Accept new baselines

* Ensure errors from union type resolution are reported

* Accept new baselines

* Compute constraints for string template types

* Support `as T` clause in mapped types

* Accept new API baselines

* Add missing semicolon

* Add checking of `as T` clauses

* Support casing modifiers in string template types

* Accept new baselines

* Bump keyword maximum length

* fix anders

* Revert "fix anders"

This reverts commit b3178d4618.

* Properly handle 'as T' clause with keyof for mapped type

* Fix lint error

* Single character inferences and anchored end span matching

* Fewer array copy operations in template literal type resolution

* Handle cases where 'as T' maps multiple properties onto one

* Fix lint error

* Store key type instead of type mapper in MappedSymbol

* No constraint on `in T` type when `as N` clause present

* Rename from TemplateType to TemplateLiteralType

* Accept new API baselines

* Add tests

* Accept new baselines

* Address CR feedback

* Accept new API baselines

Co-authored-by: Erich Gamma <egamma@microsoft.com>
2020-09-09 17:23:22 -10:00
Wenlu Wang ee5f51bc0f
Add see tag support (#39760)
* Add see tag parser

* add baseline

* fix symbol resolve

* add more case

* fix unittests

* improve tests and parser

* accept baseline

* Adopt package-lock.json and npm ci

* Add a workflow to update package-lock.json daily

* Git ignore package-lock.json and forcibly update in workflow

* Update bot email address

* Delete extra npm update

* Update package-lock.json

* Add compactDisplay and signDisplay to NumberFormatOptions (#40039)

* Fix typo in (Readonly)Set.keys comment (fixes #40164) (#40176)

* fix(26325): use a unique name for reserved words in 'constructor like' function name (#39684)

* fix(25770): add diagnostic message for the possible mapped type used as an index (#39973)

* fix(31046): add new diagnostic message for incompatible constructor signature (#40073)

* Update package-lock.json

* Update package-lock.json

* Add rename support

* Accpet baseline

* wip

* fix anders

* Revert "fix anders"

This reverts commit b3178d4618.

* Fix call hierarchy item serialization and server tests (#40348)

* Avoid error

* accept baseline

* Add more tests

* Add signature name resolve

Co-authored-by: Andrew Casey <andrew.casey@microsoft.com>
Co-authored-by: TypeScript Bot <typescriptbot@microsoft.com>
Co-authored-by: Neil Kistner <neil.kistner@gmail.com>
Co-authored-by: cherryblossom000 <31467609+cherryblossom000@users.noreply.github.com>
Co-authored-by: Alexander T <alexander.tarasyuk@outlook.com>
Co-authored-by: Erich Gamma <egamma@microsoft.com>
Co-authored-by: Andrew Branch <andrewbranch@users.noreply.github.com>
2020-09-09 10:45:09 -07:00
Alex T 15084465b7
fix(40222): fix crash on using destructuring in a catch clause (#40240) 2020-09-08 11:49:45 -07:00
Orta Therox fa89ce6158
Remove assignability cases in getNarrowedType + an isArray improvement for readonly arrays (#39258)
* Explore using a different isArray declaration

* Add tests and the new isArray definition

* Baseline updates

* Upda the isArray type
2020-09-08 14:43:48 -04:00
Wesley Wigham 7838b0172a
Add errors when providing type arguments for intrinsic JSX tags (#40293) 2020-09-08 10:29:15 -07:00
Anders Hejlsberg cea1cfb82e
Consistently error when rest element isn't last in tuple type (#40254)
* Consistently error when rest element isn't last in tuple type

* Add regression test

* Accept new baselines

* Stricter circular recursion check in type inference

* Revert "Stricter circular recursion check in type inference"

This reverts commit 80e6df6230.

* Revert "Accept new baselines"

This reverts commit 355706dadc.

* Accept new baselines
2020-09-08 07:14:16 -10:00
Wesley Wigham e5fd0dd1e3
Allow private symbols to be control flow narrowed (#39978)
* Allow private symbols to be control flow narrowed

* Add test with narrowing of inferred control flow type for completeness

* Reformat long line
2020-09-05 02:48:45 -07:00
Wesley Wigham 155610e114
Better support class instances assigned to the module object for JS declarations (#40037)
* Better support class instances assigned to the module object for JS declarations

* Extract constant
2020-09-05 02:23:12 -07:00
Alexander T 09d68efae1
fix(28516): forbid using async modifier with the abstract modifier (#39963) 2020-09-04 14:59:53 -07:00
Andrew Casey ef1481c8a4 Correct bottoming-out tracing for recursiveTypeRelatedTo 2020-09-01 16:46:07 -07:00
Nathan Shively-Sanders d572dcb272
Fix crash intersecting dynamic import w/esModuleInterop (#40249)
* Fix crash intersecting dynamic import w/esModuleInterop

The dynamic import shim creates a symbol without some properties that
the intersection-creating code assumes are present as of #38673.

This PR adds the smallest possible set of properties to avoid the crash.
I'm not sure what others would be good to add.

* Use symbol's declarations instead

* Fix getResolvedMembersOrExportsOfSymbol instead

* comment from code review
2020-09-01 09:10:36 -07:00
Nathan Shively-Sanders 378083fcec
Nested assignment to a require alias isn't a declaration (#40186)
This is not something we can type correctly, and doesn't work in
Typescript either. Better to ignore it in JS.
2020-09-01 08:20:56 -07:00
Alexander T 01362a3ac1
feat(part of 40169): add spelling suggestion/quick fix for module/namespace exported members (#40211) 2020-08-29 01:01:06 -07:00
Andrew Casey 36489ff5c6 Add instantaneous events when depth limits are hit 2020-08-28 15:51:52 -07:00
Ron Buckton 10fb9c9381
Treat trailing 'void' as optional for assignability (#40231) 2020-08-28 09:12:09 -07:00
Eli Barzilay 746bdb7946 Fix getContextualTypeForBindingElement for arrays
When handling an array type, the lookup should use the position index
instead of the identifier name.

Also uncomment the tests in the `staticFieldWithInterfaceContext.ts`
test which failed because of this bug.

Fixes #40158.
2020-08-26 16:28:50 -04:00
Nathan Shively-Sanders 4aadd5af41
Fix commonjs require of ES export (#40221)
The commonjs-specific code for resolving access expressions on `require`
assumes a fake commonjs export. For real exports, it needs to call
resolveSymbol since it's outside the normal alias-resolving
infrastructure.
2020-08-24 12:37:25 -07:00
Alexander T 2dd7a4bf93
fix(31046): add new diagnostic message for incompatible constructor signature (#40073) 2020-08-22 13:26:13 -07:00
Andrew Casey 7b40895b29 Record the recursion ID of each type, if available 2020-08-21 17:39:03 -07:00
Andrew Casey 00804d8aa6 Trace structuredTypeRelatedTo, rather than recursiveTypeRelatedTo 2020-08-21 17:07:13 -07:00
Andrew Casey 5d60972ef4 Trace key operations
Produce output in Chrome's event tracing format so that it can be viewed
in Chrome/Edge.
2020-08-21 17:07:12 -07:00
Alexander T 9569198df6
fix(25770): add diagnostic message for the possible mapped type used as an index (#39973) 2020-08-21 10:42:48 -07:00
Eli Barzilay f9e360d44b Add missing contextual type to static PropertyDeclarations
Makes it possible to type class static fields.

Fixes #33897.
2020-08-20 19:12:55 -04:00
Ron Buckton 598e9b2e88
Allow trailing params of 'undefined', 'unknown', and 'any' to be optional in non-strictNullChecks JS (#40057) 2020-08-20 13:38:14 -07:00
Nathan Shively-Sanders 55ca5e91b9
Fixes crash on chained property access on require (#40135)
From the user tests:

```js
const x = require('y').z.ka
```

would cause the crash because I forgot to call
getLeftMmostPropertyAccessExpression in one place.

Note that this doesn't fix the alias, it just stops the crash.
2020-08-19 12:59:22 -07:00
Wesley Wigham 44d2350e5f
Fix tuple name homogeneity check (#40118) 2020-08-19 12:08:17 -07:00
Andrew Branch dbab46c363
The falsy part of any/unknown is any/unknown (#39529) 2020-08-18 11:06:44 -07:00
Wesley Wigham f9cca25cd7
Fix lack of error on default export of nonexistant name (#40094)
* Modify test harness so it can report underlying issue, fix small parent pointer issue

* Fix underlying export asignment check issue and fix lints

* Ensure class/function duplicate declaration errors are reported regarless of which is encountered first

* Ensure flag conflict errors are reported regardless of which declaration is encountered first
2020-08-17 15:30:19 -07:00
Nathan Shively-Sanders c3d41bbb73
Alias for commonjs require in JS (#39770)
* First attempt at aliases for require

* test+initial support for const x=require

* 1st round of baseline improvements

* 2nd round of baseline updates

* support property access after require

* check @type tag on require

* forbid expando missing namespaces on aliases

taken from #39558 as soon as it was created

* accept error baselines that are good, actually

* Scribbling on d.ts emit code

* use getSpecifierForModuleSymbol

* hideous hack for module.exports of aliases

* Fix module.exports.x --> export list emit

* fix isLocalImport predicate

* require only creates aliases in JS

* re-handle json imports

* update fourslash baseline

* Cleanup in the checker

1. Simplify alias resolution.
2. Simplify variable-like checking.
3. Make binding skip require calls with type tags -- they fall back to
the old require-call code and then check from there.

I haven't started on the declaration emit code since I don't know what
is going on there nearly as well.

* Function for getting module name from require call

* First round of cleanup plus a new test

Found one missing feature, not sure it's worth adding.

* more small cleanup

* more cleanup, including lint

* use trackSymbol, not serializeTypeForDeclaration

* Code review comments, plus remove unneeded code

Ad-hoc type reference resolution for `require` isn't needed anymore.

* find all refs works

* remove old ad-hoc code

* make it clear that old behaviour is not that correct

* update api baselines

* remove outdated comment

* PR feedback

1. Fix indentation
2. Add comment for exported JSON emit
3. Add test case for nested-namespace exports.

* add a fail-case test (which passes!)
2020-08-17 14:00:37 -07:00
Anders Hejlsberg cd30534327
Recursive conditional types (#40002)
* Support recursive conditional types

* Accept new API baselines

* Accept new baselines

* Simplify recursive type tracking in type inference

* Accept new baselines

* Add tests

* Accept new baselines

* Revise recursion tracking in type inference

* Revise tests

* Accept new baselines

* Add more tests

* Accept new baselines
2020-08-15 18:22:30 -07:00
Alexander T 1f5caf554c
fix(13503): fix crash on calling getTypeAtLocation with the SourceFile nodes (#39994) 2020-08-12 00:11:25 -07:00
Wenlu Wang 57e2fe0462
Improve deprecated suggestion node position (#39702)
* Improve deprecated suggestion node position

* fix typo

* Simplify code

* merge helper function
2020-08-10 17:37:11 -07:00
Nathan Shively-Sanders 1ec71f0e0c
Bind alias ThisProperty assignment declarations (#39908)
* Bind alias ThisProperty assignment declarations

This is a quick prototype that does the wrong thing at the wrong time
with the wrong technique.

* Preliminary checker handling for aliases

Duplicative and untested, but I think I updated all the places that need
updating.

* new is error; old one should not have been removed

* I don't even know what's happening with this test

* cleanup and testing in the checker

* binder: use lookupSymbolForNameWorker instead of mutable

This should have about the same behaviour and is much easier to
understand.

Also refactor common code a bit.

* Shorter name of lookupSymbolForName

Once upon a time there was a parent/worker function, but now it's just a
single function again. No need for the -Worker suffix.

* remove oodate comment

* fix switch-case-break lint

* Refactor and move functions

* Rename and improve type of getContextualTypeForAssignmentDeclaration
2020-08-10 16:45:55 -07:00
Nathan Shively-Sanders 3328fdb2d8
Use isUncalledFunctionReference for aliases too (#39950)
* Use isUncalledFunctionReference for aliases too

Fixes bogus deprecated notices on imports of functions with deprecated
overloads, but with some non-deprecated overloads.

Fixes microsoft/vscode#104238

* Just check all declarations, don't call isUncalledFunction
2020-08-07 10:07:55 -07:00
Wesley Wigham 94989789df
In JS declaration emit, move imports painted in nested contexts to the root private context (#39818)
* In JS declaration emit, move imports painted in nested contexts to the root private context

* Add test for nathan
2020-07-31 18:25:37 -07:00
Nathan Shively-Sanders d3877d294c
Redo in narrowing for intersections (#39637)
* Redo in-narrowing for intersections

Still need to carve out an exception for globalThis

* exempt globalThis from `in` narrowing
2020-07-30 14:58:22 -07:00
Ron Buckton 32934a9989
Merge pull request #39824 from microsoft/fix35484
Allow assignments to a narrowable reference to be considered narrowable
2020-07-30 15:27:34 -04:00
Andrew Branch 7119e2b74f
The iteration type of overloaded iterator signatures derives from the intersection of their return types (#39722) 2020-07-30 11:37:04 -07:00
Ron Buckton 315b5f4b78 PR Feedback 2020-07-30 11:13:58 -07:00
mshivaku99 bffe3540fa
Issue35876: Give better error message when Classic Module Resolution with incorrect path (#38105)
* added Error 5084 to diagnosticMessages.json

* added test case errorForBareSpecifierWithImplicitModuleResolution1 to tests/cases/compiler

* modified checker.ts to report error 5084 when classic resolution and incorrect path are used

* added baseline changes

* passes all test cases including src/testRunner/unittests/ tests

* Update with feedback

* Make it check whether it is the right module resolution kind

* Use the right diagnostic message in tsserver tests

Co-authored-by: Meera Shivakumar <mshivaku@umich.edu>
Co-authored-by: Orta <git@orta.io>
2020-07-30 13:45:29 -04:00
Ron Buckton 21963ce337 Restore reference change 2020-07-29 18:41:05 -07:00
Ron Buckton 4c90ba9456 Temporary revert to compare user test baselines 2020-07-29 18:13:27 -07:00
Alexander T bae111f0ae
fix(39245): change related diagnostic for missing rest parameter arguments (#39356)
Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2020-07-29 17:25:13 -07:00
Ron Buckton b9db6413bf Allow assignments to a narrowable reference to be considered narrowable 2020-07-29 16:37:25 -07:00
Nathan Shively-Sanders 9b2d487392
Fix this-parameter emit for JSDocFunction types (#39814)
* Fix this parameter emit for JSDocFunction types

Previously, parameters with names that were not `new` were treated like
rest parameters. This is incorrect: parameters with the name `this`
should emit a `this` parameter.

Fixes #38550

* ❤️ quote style
2020-07-29 14:11:59 -07:00
Eli Barzilay f2d1531768 Fix location for duplicate function implementation errors
Use only the relevant declarations (by collecting them in the for loop),
and use `declaration` if `getNameOfDeclaration` didn't work (useful for
`export default` with anonymous functions).

Fixes #39804.

Also, use `nodeIsPresent` once, and a random `?.`.
2020-07-29 16:07:00 -04:00
Andrew Casey 79e2ed2e77
Merge pull request #39776 from amcasey/OverloadErrors
Reduce unnecessary error computation
2020-07-28 10:35:22 -07:00
Andrew Branch 1f1521c2f1
Undo accidental change from #39772 (#39779)
* Undo accidental change

* Delete test
2020-07-27 16:55:59 -07:00
Andrew Branch 68ba670467
Add contextual type for generator return type (#39772)
* WIP

* Add contextual type for generator return type
2020-07-27 15:14:47 -07:00
Andrew Casey 195fad23a5 Reduce unnecessary error computation
...during overload resolution.  Based on a trace that was spending 30%
of a (very slow) overload resolution elaborating errors that were then
dropped.
2020-07-27 14:11:24 -07:00
Anders Hejlsberg c5d21e7987
Lower priority for speculative variadic tuple inferences (#39723)
* Inference to [...T, X?] has lower priority than inference to [...T, X]

* Update tests

* Accept new API baselines
2020-07-24 15:00:53 -07:00
Andrew Branch ec33814616
Make AutoImportProviderProject work with symlinked monorepos (#39679)
* Hack everything together

* Add test

* Remove realpath from program

* Ensure symlinked directories are directories

* Revert unnecessary change

* Update baselines

* Use host program realpath on AutoImportProviderProject files before program creation

* Which fixes hasRoots() too

* Apply suggestions from code review

Co-authored-by: Sheetal Nandi <shkamat@microsoft.com>

* Lint

Co-authored-by: Sheetal Nandi <shkamat@microsoft.com>
2020-07-22 13:53:30 -07:00
Wesley Wigham 312a6f0efb
Add a fastpath for comparing common mapped types like Pick which avoids manufacturing intermediate type identities (#39696) 2020-07-22 11:59:16 -07:00
Song 8a05707559
Fix 31995: make cached key more precise to avoid returning wrong cached value. (#39670)
* fix 31995

* revert useless change only for debug.

* add test
2020-07-22 12:26:17 -04:00
Song 294a0406e3
not escape unicode char for import path string. (#39463)
* not escape unicode char for import path string.

* fix test.
2020-07-22 11:28:29 -04:00
Song 5484687384
switch typeof any could be checked for unreachable (#39389)
* switch typeof any could be checked for unreachable

* fix stupid error

* support unknown

* remvoe use less code.

* fix spelling.
2020-07-21 13:51:27 -04:00
Anders Hejlsberg 94d6b4507e
Consistent errors on circular base types (#39675)
* Properly track and report errors on circular base types

* Accept new baselines

* Add regression test
2020-07-20 20:35:47 -07:00
Anders Hejlsberg 5ae4b5d715
Properly preserve numeric string named properties in declaration files (#39658)
* Properly preserve names of properties with numeric literal strings

* Accept new baselines
2020-07-20 10:36:46 -07:00
Sheetal Nandi 3b22339df8
Triple slash references must resolve against the resolved file name (.d.ts and not original source file) since they are rewritten in the .d.ts emit (#39645)
* Add tests corresponding to repro from #37928

* Triple slash references must resolve against the resolved file name (.d.ts and not original source file) since they are rewritten in the .d.ts emit

* Remove the scenario not fixed in this PR
2020-07-17 16:25:32 -07:00
Anders Hejlsberg db79030410
Support variadic tuple inference from trailing optional to non-optional (#39614)
* Permit variadic tuple inference from trailing optional to non-optional

* Add tests
2020-07-15 17:46:48 -07:00
Wesley Wigham f2c5643056
Flag mapped types with circular property types and do not attempt to print them structurally (#39552) 2020-07-15 11:19:43 -07:00
Wenlu Wang fcd4fcb3d7
Use combined node flags (#39403) 2020-07-15 09:22:12 -07:00
Wenlu Wang 7b728754c0
Fix incorrect deprecated mark (#39611)
* Fix incorrect deprecated mark

* improve test
2020-07-15 08:47:25 -07:00
Wesley Wigham ef9affe2f6
Use jsxFragmentFactory entity name for factory name lookup from checking fragments (#39475) 2020-07-14 17:25:45 -07:00
Ron Buckton 5ad8532a11 Merge branch 'master' into fix37113
# Conflicts:
#	src/compiler/transformers/module/module.ts
2020-07-13 11:13:35 -07:00
Ron Buckton 2c08affa0d
Merge pull request #39264 from microsoft/migrateMapsAndSets
Migrate maps and sets
2020-07-13 10:38:30 -07:00
Andrew Branch 583bd92bc4
Don’t create expando declarations on alias symbols (#39558)
* Don’t create expando declarations on alias symbols

* Update other baseline

* Fix brace nesting refactor mistake
2020-07-13 10:05:48 -07:00
Anders Hejlsberg c335aad665
Remove object literal freshness in control flow based array types (#39518)
* Remove object literal freshness in control flow based array types

* Add regression test
2020-07-10 10:18:15 -07:00
Nathan Shively-Sanders 3b107fec3b
Fix @param type parameter lookup (#39532)
Previously, getObjectTypeInstantiation had special-case code to look up
type parameters for `@param` as if they were in the parameter location.

This should occur in the main lookup loop of `getOuterTypeParameters`,
however. The current code only runs once, which is not sufficient, and
it also jumps to the parameter for any type contained in a `@param`,
which skips type parameters that occur in the tag itself.
2020-07-10 08:42:25 -07:00
Ron Buckton ae2f0068e3 Fix default import/export helper usage 2020-07-09 13:13:48 -07:00
Jesse Trinity 8e9de9bed2
Fix39458 (#39508)
* remove undefined from optional parameter

* accept baselines

* use getTypeWithFacts
2020-07-09 11:17:18 -07:00
Nathan Shively-Sanders 007b82f6d1
Better checking of @param/@property tags (#39487)
* More consistent checking of @property/@param

1. Use getWidenedTypeForVariableLikeDeclaration, instead of directly
calling tryGetTypeFromEffectiveTypeNode. This requires some changes in
the former function since it can't assume that the declaration has an
initializer.
2. isOptional now calls isOptionalJSDocPropertyLikeTag.
3. isOptionalJSDocPropertyLikeTag now handles JSDocPropertyTag
(previously it was named isOptionalJSDocParameterTag).

* rename to isOptionalJSDocPropertyLikeTag
2020-07-08 13:55:18 -07:00
Nathan Shively-Sanders 53a756ea63
Type this in more constructor functions (#39447)
* Type `this` in more constructor functions

Previously,  `this: this` in constructor functions only when there was
an explicit `@constructor` tag on the function. Now, `this: this` for
any function that's known to be a constructor function.

This improves completions inside constructor functions; also note that
previously the compiler *did* type `this: this` inside methods of constructor
functions, so this fix makes us more consistent. This is reflected in
the large number of baselines that improve.

The fix is a simple switch to `isJSConstructor`, which is the standard
way to detect constructor functions. I'm not sure why the original PR
didn't use this method.

I remember discussing this limitation in the original bug, #25979, and
I guess I decided that it made sense. But I was heavily primed by the bug's
framing of the problem in terms of `noImplicitThis`, which *should*
require an explicit `@constructor` tag.

With better typing comes better detection of `@readonly` assignment; I
had to fix the readonly detection code to use `isJSConstructor` as well.

* Remove `Add @class tag` fix for noImplicitThis.

The new rules mean that it never applies. It's possible that it should
apply to functions like

```js
function f() {
  this.init()
}
```

In which `init` is never defined, but I think this program is incomplete
enough that not offering the fix is fine.

* Fix precedence of `@this`

Previously, both `@class` and `@this` in a jsdoc would cause the `@this`
annotation to be ignored. This became a worse problem with this PR,
because `this` is correctly typed even without the annotation.

This commit makes sure that `@this` is checked first and used if
present.
2020-07-08 08:44:17 -07:00
Ron Buckton 5c5f180f8e Fix namespace import/export helper usage 2020-07-07 17:36:59 -07:00
Anders Hejlsberg 8c6b85835f
Properly handle rest parameters in function declarations with @type annotations (#39473)
* Properly handle rest parameters in function declarations with @type annotations

* Add tests
2020-07-07 16:35:37 -07:00
Wesley Wigham d2b32b422f
Ensure type/namespaceish statics are included in the list of namespace merge members (#38920)
* Ensure type/namespaceish statics are included in the list of namespace merge members

* Simplit into two lines

* Update baseline post-merge
2020-07-07 16:28:09 -07:00
Andrew Branch 2d6d5db33a
Fix getTypeAtLocation for dotted implements clauses (#39363)
* Fix getTypeAtLocation for dotted implements clauses

* Fix typo
2020-07-07 16:17:07 -07:00
Ron Buckton 9d5cd280ef Merge branch 'master' into migrateMapsAndSets
# Conflicts:
#	src/compiler/checker.ts
#	src/compiler/commandLineParser.ts
#	src/compiler/core.ts
#	src/compiler/moduleNameResolver.ts
#	src/compiler/transformers/declarations.ts
#	src/compiler/tsbuildPublic.ts
#	src/compiler/types.ts
#	src/compiler/utilities.ts
#	src/harness/client.ts
#	src/server/editorServices.ts
#	src/server/typingsCache.ts
#	src/server/utilities.ts
#	src/services/codefixes/convertToAsyncFunction.ts
#	src/services/documentRegistry.ts
#	src/services/importTracker.ts
#	src/services/refactorProvider.ts
#	src/services/refactors/extractSymbol.ts
#	src/testRunner/unittests/programApi.ts
#	src/typingsInstallerCore/typingsInstaller.ts
#	tests/baselines/reference/api/tsserverlibrary.d.ts
#	tests/baselines/reference/api/typescript.d.ts
2020-07-07 13:53:46 -07:00
Ron Buckton b100680a3e
Fix for relating covered discriminants in unions (#39393) 2020-07-07 13:11:55 -07:00
Nathan Shively-Sanders 1814e2a5c4
Mark @typedef as a type declaration (#39468)
* Mark @typedef as a type declaration

This is only important right now for marking uses of deprecated tags due
to the way that deprecated type references are computed. But I'm
surprised it hasn't caused problems elsewhere.

Fixes #39466

* Also mark @callback and @enum

Requires making name lookup in isTypeDeclarationName smarter, but this
is only used by services, so shouldn't be too performance sensitive.
2020-07-07 10:37:52 -07:00
Orta Therox 6ebd73c84f
Don't narrow against unions of constructor functions with instanceof (#38099)
* WIP

* Only narrows when the union is not all constructors
2020-07-07 11:34:10 -04:00
Wenlu Wang 453365284c
Avoid check for union keys (#39314) 2020-07-06 15:01:05 -07:00
Daniel Rosenwasser 64696225ab
Merge pull request #39418 from a-tarasyuk/feat/25259-diagnostic
feat(25259): Better error report for equals instead of colon in object literals / change diagnostic message
2020-07-06 12:13:49 -07:00
ShuiRuTian f29e03eea5
autocomplete works for const assertion. (#39412)
* fix 39384

* add test
2020-07-06 08:49:50 -04:00
Alexander T 9f8585913b feat(25259): change diagnostic message 2020-07-04 09:05:47 +03:00
Nathan Shively-Sanders 93ccc17658
Node-based @deprecated checks (#39323)
* Node-based @deprecated checks

Switch the checker to syntactic checks for `@deprecated` on
declarations. This requires a bit more checking of declarations in the
checker at times, but it

1. Gets rid of work, and a symbol flag, in the binder.
2. Skips work in the checker unless there is a `@deprecated` tag.
3. Makes it fairly simple to only issue errors on particular signatures
   of overloaded functions.

* remove in-progress comment

* remove unused isTypeDeclaration

* ❤️ lint

* support jsx and tagged template functions

* Support decorators too
2020-07-02 14:09:59 -07:00
Ron Buckton 652a1c5950
Emit fallback for decorator metadata for type only imports (#39337) 2020-07-02 11:39:27 -07:00
Ron Buckton 8eba362a01 Fix for relating covered discriminants in unions 2020-07-02 11:09:14 -07:00
Ron Buckton 7b942b4fa8
Revert the type change to ts.Map (#39366) 2020-07-01 17:00:26 -07:00
Wesley Wigham ff1f449b99
Fix type of computed name following spread (#39319) 2020-06-30 13:37:59 -07:00
Daniel Rosenwasser a812a7449d
Merge pull request #38792 from microsoft/reportBaseAgainstBooleans 2020-06-30 01:58:51 -07:00
Daniel Rosenwasser 1bbd5ef36b
Merge pull request #38754 from a-tarasyuk/feat/25259
feat(25259): Better error report for equals instead of colon in object literals
2020-06-30 01:56:26 -07:00
Daniel 40c3ffec91 Add assertion. 2020-06-30 01:33:32 -07:00
Daniel ef40ed1ee6 Exempt bare 'boolean's from the check. 2020-06-30 01:12:45 -07:00
Alexander T 21a26ca08a feat(25259): add better error to report for equals instead of the colon in object literals 2020-06-30 10:33:56 +03:00
Anders Hejlsberg 784396ce95
Infer implied arity before inferring from 'this' argument (#39328)
* Infer implied arity before inferring from 'this' argument

* Add regression test
2020-06-29 17:38:41 -07:00
Anders Hejlsberg 9458f8acab
Consistent narrowing to 'never' in conditional and switch statements (#39191)
* Allow unions and unit types to narrow to 'never'

* Remove odd check for TypeFlags.NotUnionOrUnit

* Accept new baselines

* Accept new API baselines
2020-06-29 15:25:00 -07:00
Anders Hejlsberg b448540644
No speculative inferences for variadic tuples (#39281)
* No speculative inferences to types like [...T, U?]

* Add tests
2020-06-29 15:24:32 -07:00
Wesley Wigham 99bec5067b
Use mapped rest type member when expanding rest parameter names (#39317)
* Use mapped rest type member when expanding rest parameter names

* Add test for #39228 which is also fixed by parameters having unique names
2020-06-29 12:30:23 -07:00
Andrew Branch 58ed610ef1
Allow distinct string enum members with identical property names to form unions in mapped types (#39101) 2020-06-29 10:08:17 -07:00
ShuiRuTian 4601a786aa
not narrow static property without type annotation in constructor. (#39252)
* fix #39226

* fix lint.
2020-06-26 11:08:35 -07:00
Ron Buckton 611b77f2e6 Migrate more places to use Map/Set 2020-06-26 10:15:53 -07:00
Ron Buckton eb2f4e2337
Switch to ES Map/Set internally (#33771)
* Add full implemention of Map and Set to shims

* Update default Map interface

* Remove WeakMap/WeakSet

* Add tests for set shim

* Update most usages of Map<K, true> to Set

* PR Feedback

* Fix lint issues

* Change key in fsWatchCallback

* Simpler shim, more tests

* Fix typo in collection shim
2020-06-26 10:12:47 -07:00
Anders Hejlsberg ee4aee0531
Handle 'keyof' for generic tuple types (#39218)
* Handle keyof T where T is generic tuple type

* Add tests

* Accept new baselines

* Address CR feedback

* Accept new baselines
2020-06-25 13:49:20 -07:00
Anders Hejlsberg 8df85b5cae
Disable unsound T[K] rule in subtype relations (#39249)
* Disable unsound T[K] rule in subtype relations

* Add test
2020-06-25 10:22:48 -07:00
Wesley Wigham a3ee09ddc9
Handle recursive type references up to a certain level of expansion in inference (#38011)
* Handle recursive type references up to a certain level of expansion in inference

* Move object cases into the same conditional branch
2020-06-24 14:24:34 -07:00
Wesley Wigham d1ebf126d2
Do not consider binding patterns in contextual types for return type inference where all the signature type parameters have defaults (#39081) 2020-06-24 13:45:17 -07:00
Ron Buckton 0b1d4a9c96
Leverage syntax cursor as part of reparse (#39216) 2020-06-23 17:32:58 -07:00
Anders Hejlsberg d4792062bf
Variadic tuple types (#39094)
* Initial implementation of variadic tuple types

* Accept new baselines

* Handle variadic elements in tuple type inference

* Special case inference between tuples with matching structure

* Restore check that rest element is last element

* Handle variadic tuples in relationship checking

* Accept new baselines

* Infer readonly constraints when inferring from readonly tuples

* Fix lint issues

* T assignable to readonly [...T] and [...T] assignable to T

* Consistent tuple normalization

* Create variadic tuple types from array literal expressions

* Accept new baselines

* Array literals have tuple types when contextual type is readonly

* Accept new baselines

* Optional elements before required elements become required elements

* Update logic for rest parameters and spread arguments

* Revert special case of contextual readonly array type

* Accept new baselines

* Fix lint issue

* Switch entirely to createTupleType based on element flags

* Don't infer readonly tuple types when inferring to variadic elements

* Handle mapped types applied to generic tuple types

* Handle constraint of indexed access type with generic tuple type

* Accept new baselines

* Address CR feedback

* Simplify indexed access types involving generic tuple types

* Propagate checkMode into getSpreadArgumentType

* Guard against missing globalArrayType

* Inference to [...T, ...U] based on implied arity of T

* Accept new baselines

* Add tests

* Emit .d.ts from tests

* Address CR feedback
2020-06-22 18:35:43 -07:00
Daniel Rosenwasser e6aedfd38b
Merge pull request #37907 from Jack-Works/feat/class-to-classname
feat: add a codefix to fix class to className in react & add spelling suggest for JSX attributes
2020-06-22 18:32:24 -07:00
Jack Works 8dc4f7e3d2 chore: resolve suggestions 2020-06-23 08:06:46 +08:00
Nathan Shively-Sanders ac87e82f08 inline local functions 2020-06-22 15:11:30 -07:00
Jack Williams fd0ad2985b
Minor fix for assertion predicates (#38710) 2020-06-20 18:27:51 -07:00
Ron Buckton fe33e61823
Reparse top level 'await' in modules (#39084)
* Reparse top-level 'await' in modules

* Add more tests and additional diagnostics

* One more incremental parse test
2020-06-18 23:43:18 -07:00
Jack Works 41a1cd9128 chore: more change 2020-06-19 11:35:35 +08:00
Jack Works 4fce495303
chore: resolve review 2020-06-19 11:28:06 +08:00
Jack Works d33256cc5a chore: save space 2020-06-19 10:50:40 +08:00
Jack Works cdd14ccec6 fix: lint error 2020-06-19 10:50:37 +08:00
Jack Works c36fe2339a chore: make isJsxAttr required 2020-06-19 10:50:33 +08:00
Jack Works d38096ab90 chore: revert change in checker 2020-06-19 10:50:31 +08:00
Jack Works 5853d2ab69 feat: re-impl react class name fix 2020-06-19 10:50:28 +08:00
Jack Works 8c8f84549c feat: support spell checking in JSX attribute 2020-06-19 10:50:25 +08:00
Jack Works 0975bafbde feat: add name suggestion for JSX 2020-06-19 10:50:23 +08:00
Wenlu Wang 59ad375234
Add deprecated related feature (#38523)
* Add deprecated related feature

* Add more support

* fix navtree

* Add identifier check

* Add more deprecated

* fix crash

* fix more crash

* fix crash

* improve diagnostic

* avoid new tag

* avoid tags

* accept baseline

* Check deprecated in binder

* fix baseline

* fix jsdoc cache

* fix incorrect fix

* Avoid useless changes

* Accept baseline

* Add tests

* fix perf

* fix public api

* Adjust deprecated mark on qualifed name

* Revolve alias symbol

* Use modifier flags insted of symbol props

* Fix modifier flag resolve

* Make lint happy

* Fix crash

* fix crash

* Add cached utils function

* Accept baseline

* Add more tests

* try pinning octokit again

* Avoid tests

* Use utils some

* Deprecated perf test (#3)

* check valueDeclaration only

* check without modifierFlags

* donot check alias

* use cached tag

* remove call to jsdoc

* use deprecated tag

* revert changes

* Revert mission changes

* use node flags

* cache result

* cache

* avoid modifier flags

* Opts

* fix jsdoc include modifier

* fix tests

* fix again

* use symbol flag

* set @octokit/rest back to latest

* fix trailing spacel int

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2020-06-18 17:41:26 -07:00
Sheetal Nandi b977f86abd
Allows emitting buildInfo when --noEmit is specified (#39122)
* Some tests

* Allow noEmit with incremental and composite
Fixes #38440
2020-06-18 11:05:37 -07:00
Noj Vek f697d26ca1
reset soft with master for single commit (#38720) 2020-06-18 00:22:32 -07:00
Eli Barzilay 7611579421 Small fix in getObjectLiteralIndexInfo
Fixes #38175
2020-06-17 03:29:10 -04:00
Ron Buckton eb3645f16b
Refactor node factory API, use node factory in parser (#35282)
* Refactor node factory API, use node factory in parser

* Move UnparsedSource nodes to factory

* Make most Node properties read-only

* Make pos/end/parent and JSDoc 'comment' read-only

* Update function/constructor-type factories

* Remove treeStateObserver

* Simplify Debug.deprecate

* Remove unused factory methods, simplify lazy factory methods

* Fix base factory used for source file updates

* Update test baseline due to merge from master

* Rename factory methods to be more consistent (#39058)
2020-06-16 16:55:03 -07:00
Wesley Wigham 6a777ff6b3
Fix crash when serializing the return type of a generic call to Array.prototype.flat (#38904)
* Add declaration emit error and checking for circularly referential unions produced by recursive conditionals

* Allow indexed accesses to produce alias symbols on types

* Add test that still triggers the declaration emit error

* Fix spelling
2020-06-15 11:46:10 -07:00
Eli Barzilay 0432954f2d Small fix in getIsContextSensitiveAssignmentOrContextType
Test that `parentSymbol.valueDeclaration` exists.

Fixes #38532
2020-06-13 07:10:04 -04:00
Eli Barzilay f447838f95 Fix handling of aruments in the emitter
Two problems are fixed:

* `isArgumentsLocalBinding` did only `PropertyAccessExpression`, now
  it's also doing `PropertyAssignment` (doesn't affect other files,
  since it's only used in the emitter).

* `visitShorthandPropertyAssignment` should call `visitIdentifier` on
  the synthesized id.  (For completion it might be better to make it
  visit the the original?)

Fixes #38594.
2020-06-13 07:05:21 -04:00
Andrew Branch b63ea4b6df
Fix declaration emit for property references of imported object literal types (#39055)
* Fix declaration emit for property references of imported object literal types

* Add declaration file to test
2020-06-12 17:48:19 -07:00
Nathan Shively-Sanders a26e60eb2c skip implements types with no symbols 2020-06-11 16:34:32 -07:00
Nathan Shively-Sanders 9f872c01e1 Merge branch 'master' into fix-implements-tag-emit 2020-06-11 16:05:21 -07:00
Eli Barzilay ffa35d3272 Allow e: unknown in catch arguments
In addition, allow an explicit `any`; anything else throws an error.

Also adjust and reorganize existing tests.

Fixes #36775.
2020-06-10 18:24:20 -04:00
Wesley Wigham 08cb0b23e8
Serialize (noncontextual) keyword named namespace members with export declarations in both declaration emitters (#38982)
* fix(38750): create unique names for keywords and re-export them with original names

* Serialize (noncontextual) keyword named namespace members with export declarations in both declaration emitters

* Add exhaustive keyword emit test for js declaration emitter and fix it up

Co-authored-by: Alexander T <alexander.tarasyuk@outlook.com>
2020-06-10 14:42:49 -07:00
Wesley Wigham 2287dbc7e2
Handle missing return type nodes and nested type references missing type arguments in existing jsdoc node serialization (#39011)
* Handle missing return type nodes and nested type references missing type arguments in existing jsdoc node serialization

* Accept updated baselines
2020-06-10 12:42:38 -07:00
Daniel Rosenwasser e832e04fa7
Merge pull request #37727 from Kingwl/logical_assignment
Add logical assignment operator
2020-06-09 14:44:08 -07:00
Wesley Wigham f41398e100
Make isEntityNameVisible duplicate the node builder logic to always consider type parameters as visible if they are the resolution result (#38921) 2020-06-09 13:40:17 -07:00
Eli Barzilay 3151e2a365 Make hasCorrectArity handle tuples properly
This completes the work that started in PR #33069, and fixes #32835.

There are probably two additional related changes that are needed to
make this more complete:

* Fix the code that composes the error message (see the first two
  `FIXME`s in `callWithSpread3.ts`).

* Fix the code that checks the argument types (second two `FIXME`s).

* There is also an error in `genericRestParameters1.ts` which changed
  but should not be an error in the first place.  Added a `FIXME` there
  too.  (Probably will work if the previous iterm is done.)

In addition, `getEffectiveCallArguments` munges the arguments in case of
a spread in the last argument which might be better to avoid.  (I think
that there are cases where it wouldn't work anyway, such as a spread of
an array followed by a spread of an empty array.)
2020-06-04 23:46:56 -04:00
rchaser53 261386d48b fix error when use spread arguments twice 2020-06-04 23:46:56 -04:00
Eli Barzilay 4ee013d1a7 Fix merging of JS value & TS type decl
Fixes #38383
2020-06-04 19:28:33 -04:00
Sheetal Nandi f0da6d1203
Some changes to tsc baselines for clarity (#38850)
* Baseline programs in tsc -b and tsc -incremental mode as well

* Refactor outFile

* Tests

* Distinct input and output

* Add helper to baseline serialized invocations of tsc on incremental edits

* Input and output in watch mode

* Update src/testRunner/unittests/tsbuild/helpers.ts

Co-authored-by: Wesley Wigham <wewigham@microsoft.com>

Co-authored-by: Wesley Wigham <wewigham@microsoft.com>
2020-06-02 11:49:21 -07:00
Jack Works 8e290e5aae
Improve error range for ts2657 (jsx expr must have parent element), add code fix for it (#37917)
* fix: range of ts2657 (jsx expr must have parent) and remove 2695 (LHS expr of comma has no side effects)

* feat: add code fix for 2657

* fix: resolve review

* chore: hoist a var

* chore: add test for skipTrivia

* fix: rebase error

* Update src/compiler/diagnosticMessages.json

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

* Update src/services/codefixes/wrapJsxInFragment.ts

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

Co-authored-by: Andrew Branch <andrew@wheream.io>
Co-authored-by: Andrew Branch <andrewbranch@users.noreply.github.com>
2020-06-01 12:22:44 -07:00
Daniel Rosenwasser f2d6eda60e
Merge pull request #38049 from JoshuaKGoldberg/literal-to-primitive-relation-reporting
Report primitive type in literal-to-primitive relation complaints
2020-05-26 13:18:14 -07:00
Alexander T 6214bd29f3
fix(38722): change error message for use-before-declaration on const enum (#38728) 2020-05-26 11:53:18 -07:00
Nathan Shively-Sanders bfa1744586
Merge pull request #37894 from microsoft/always-error-on-property-override-accessor
Always error on property override accessor
2020-05-26 10:37:07 -07:00
Anders Hejlsberg c5b8f4fcd4
Fix relation between generic mapped types and types with index signatures (#38761)
* Fix relation between generic mapped type and type with index signature(s)

* Add tests
2020-05-25 09:55:41 -07:00
Daniel d3d282cb45 Less code 2020-05-22 01:49:26 +00:00
Daniel afe90f1314 Feed generalized source type to elaboration. 2020-05-22 01:02:27 +00:00
Daniel a04ecb592c Check constraints deeply on singleton types. 2020-05-22 00:40:28 +00:00
Daniel 8cf2466110 Merge remote-tracking branch 'origin/master' into literal-to-primitive-relation-reporting 2020-05-22 00:09:52 +00:00
Nathan Shively-Sanders 802e87b1eb Merge branch 'master' into always-error-on-property-override-accessor 2020-05-21 16:08:09 -07:00
Nathan Shively-Sanders 38715c7b48 remove errant tab 2020-05-21 09:26:42 -07:00
Nathan Shively-Sanders 66f48e303f Switch to isSymbolAccessible for both.
1. Switch to isSymbolAccessible for both types and values, then unify to
a single function.
2. Remove inaccesible base error. We can put it back after making
@implements type reference lookup looser (which may or may not happen).
2020-05-21 09:20:56 -07:00
Nathan Shively-Sanders 9b4a83e8df Merge branch 'master' into fix-implements-tag-emit 2020-05-21 08:21:16 -07:00
kingwl b73411c985 Fix type and simplify code 2020-05-21 10:19:36 +08:00
Nathan Shively-Sanders fc83d10388 Merge branch 'master' into diagnose-accidental-accessor-call 2020-05-20 16:46:34 -07:00
Nathan Shively-Sanders 2bb0dabb0f fix untagged argument lint 2020-05-20 14:43:08 -07:00
Anders Hejlsberg a56960303d
Intersection check for empty object type shouldn't cause circularities (#38673)
* isEmptyAnonymousObjectType shouldn't require full member resolution

* Add regression test
2020-05-20 10:56:14 -07:00
Nathan Shively-Sanders c5f66716cf Fix @implements emit for namespaced base types
Fixes #38640
2020-05-20 10:29:39 -07:00