Commit graph

29324 commits

Author SHA1 Message Date
Orta b9fe84e591
Fix up some of the ignore files, and removing the create language service script (#33684)
* Fix up some of the ignore files, and removing the create script

* Update .dockerignore
2019-11-06 11:11:29 -05:00
Anders Hejlsberg 1c42c1aaa8
Fix control flow analysis in try-catch-finally (#34880)
* Revise creation of control flow graph for try-catch-finally statements

* Add tests

* Accept new baselines
2019-11-05 12:06:25 -08:00
Anders Hejlsberg 95be956320
Fix switch statement exhaustiveness checking (#34840)
* Don't optimize away CFA nodes representing missing default clauses

* Add regression test

* Accept new baselines
2019-11-05 12:05:41 -08:00
Anders Hejlsberg 966d9864d0
Properly instantiate object types created from rest parameters (#34826)
* Anonymous types of rest variable declarations need instantiation

* Add regression test

* Accept new baselines

* Accept new API baselines
2019-11-05 12:04:45 -08:00
Alexander T 56cad36678 (34894): Wrong information in error message for overridden acc… (#34901) 2019-11-05 00:07:03 -05:00
Ozair Patel be960fa356 Add related diagnostic to "used before defined" if type is a function that returns a union with undefined (#33171)
* Add "use before defined" diagnostic

* Make "use before defined" diagnostic as related information to TS2454

* Add baseline tests for "use before defined"

* Add test for type alias union with undefined for "use before defined" diagnostic

* Update baselines
2019-11-04 17:53:31 -05:00
Sheetal Nandi 47ec514cf4
Use empty object for invalid package json contents instead of undefined (#34906)
* Use empty object for invalid package json contents instead of undefined
Fixes #34726

* Behave as if package json doesnt exist in case of invalid json in package json
2019-11-04 14:31:45 -08:00
Luka Hartwig 9a3ec5f229 Improve error message when compiling a .js file (#34861)
* Improve error message when compiling a .js file

* Add dedicated error message for .json and .js files

* Update missing baseline tests

* Remove error hint for .json files
2019-11-04 14:59:06 -05:00
Ron Buckton ba5e86f140
Propagate 'undefined' instead of the optional type marker at an optional chain boundary (#34588)
* Propagate 'undefined' instead of the optional type marker at an optional chain boundary

* Update src/compiler/types.ts

Co-Authored-By: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2019-11-01 11:36:22 -07:00
Orta ec367feb58
Remove the ping for playgrounds on TS deploys (#34862) 2019-10-31 18:50:00 -07:00
TypeScript Bot e228294463 Update user baselines (#34851) 2019-10-31 14:23:55 -07:00
TypeScript Bot 239937df7a Update user baselines (#34845) 2019-10-31 11:00:03 -07:00
Anders Hejlsberg 9ff378aab3
Exclude types originating in literals from recursion depth limiter check (#34742)
* Exclude types originating in literals from recursion depth limiter check

* Add tests

* Accept new baselines

* Remove superfluous test
2019-10-31 06:14:43 -07:00
Wenlu Wang 234680851b add template literal spans (#34699) 2019-10-30 23:54:00 -07:00
TypeScript Bot 9cc0fcd3da Update user baselines (#34838) 2019-10-30 16:58:59 -07:00
TypeScript Bot 0c2e964506 Update user baselines (#34820) 2019-10-30 14:05:20 -07:00
Wesley Wigham 7b02c635b6
Report generic rest parameters as unreliable variance positions (#33020)
* Report generic rest parameters as unreliable variance positions

* Add example from discussion on #30301
2019-10-30 13:54:39 -07:00
Wesley Wigham 5e0fbc677a
Add circularity checking during deferred type argument creation (#34791) 2019-10-30 13:36:43 -07:00
Wesley Wigham 8b7664ae15
Generate more correct property name nodes in declaration emit (#34741)
* Generate more correct property name nodes in declaration emit

* Silly only-on-CI lint rule T.T
2019-10-30 12:40:59 -07:00
Wesley Wigham d28672d97f
Fix alias naming and structure bugs in js declarations (#34786)
* Fix alias naming and structure bugs in js declarations

* Add another test case and change condition for ns merge to require signature or export content

* Fix typo in comment
2019-10-30 12:40:06 -07:00
Ron Buckton 87cc8c4af8
Evaluate RHS of binding/assignment pattern first (#34806) 2019-10-29 17:42:30 -07:00
Nathan Shively-Sanders 00dd1f0609
Add isIntersectionConstituent to relation key (#34789)
* Add isIntersectionConstituent to relation key

isIntersectionConstituent controls whether relation checking performs
excess property and common property checks. It is possible to fail a
relation check with excess property checks turned on, cache the result,
and then skip a relation check with excess property checks that would
have succeeded. #33133 provides an example of such a program.

Fixes #33133 the right way, so I reverted the fix at #33213
Fixes #34762 (by reverting #33213)
Fixes #33944 -- I added the test from #34646

* Update comments in test
2019-10-29 15:08:59 -07:00
Nathan Shively-Sanders 7635884224
JSDoc type reference understands require with entity name (#34804)
* resolve require with entity name postfix

For example, `require("x").c`. This is the value equivalent of
`import("x").a.b.c`, but the syntax tree is not as nicely designed for
this purpose.

Fixes #34802

* Add bug number to test

* Add optional chain test
2019-10-29 14:56:33 -07:00
TypeScript Bot f7cb2f2b86 Update user baselines (#34759) 2019-10-29 14:26:50 -07:00
Sheetal Nandi dbef230eb8
This handles when packages are symbol links in mono repo like scenarios to use source files instead of output d.ts from project reference (#34743)
* Fix incorrect outDir usage instead of out

* Handle symlinks of packages in mono repo like packages
Fixes #34723

* Added clarified comment
2019-10-29 10:49:14 -07:00
Ron Buckton 554bd24734
Fix checker handling for empty type argument lists (#34790) 2019-10-29 08:56:11 -07:00
Martin Probst ff590b622e Fix a crash when transforming functions in modules. (#34513)
When transforming a module declaration and block, parse tree nodes
contained in the module block have their parent pointers reset due to
`shouldEmitModuleDeclaration` calling into `isInstantiatedModule`, which
needs to set parent pointers to operate.

That causes a crash when later transforming any nodes within the module,
as retrieving their source file in `getSourceFileOfNode` (via
`getOrCreateEmitNode`) fails, due to their new synthesized parent nodes
not being in a source file.

This change avoids the issue by using the parse tree node in `ts.ts` to
decide whether a module declaration should be emitted (i.e. whether the
module contains values).

This means transformers cannot add values to modules that previously did
not contain any.

Fixes #34644.
2019-10-29 08:40:49 -07:00
Sheetal Nandi cbbbcfa4c5
Fix incorrectly looking for position in call/new expression arguments when looking for indentation of type arguments (#34779)
* Fix incorrectly looking for position in call/new expression arguments when looking for indentation of type arguments
Fixes #32487

* Update src/services/formatting/smartIndenter.ts

Co-Authored-By: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2019-10-28 14:02:09 -07:00
Ryan Cavanaugh 05cbe5ac8e
Update issue reports agian (#34768)
* Update issue templates

* Add config.yml

* Updates

* Updates
2019-10-28 11:15:31 -07:00
Ryan Cavanaugh a28fcebff2
Update issue templates (#34767)
* Update issue templates

* Add config.yml
2019-10-28 11:12:20 -07:00
Orta 72b7a6527e Adds accept header to the dispatch request when requesting a playground build of monaco (#34763) 2019-10-28 11:07:36 -07:00
Andrew Branch 634e0ad52b
Fix extract type on JS function params (#34745) 2019-10-28 10:30:59 -07:00
Nathan Shively-Sanders 080e41dc90
Fix type reference to merged prototype property assignment (#34764)
The constructor function code path in the return type checking of
signatures needs to pass the *merged* symbol of the declaration to
getDeclaredTypeOfClassOrInterface. Other callers of
getDeclaredTypeOfClassOrInterface do this, or used an already-merged
symbol.

Fixes #33993
2019-10-28 10:14:04 -07:00
Eli Barzilay eb0208c589
make globalThis have an empty declarations (#34561)
Fixes #33860 by making it an error.  This is an improvement, but sounds
like it would be better to make it work later.
2019-10-25 22:49:31 -04:00
Andrew Branch d8840f8a18
Show all matching enum flags in debug flag formatter (#34689)
* Show all matching enum flags in debug formatter

* Revert "Show all matching enum flags in debug formatter"

This reverts commit 073099722a.

* Same thing but simpler

* Lint
2019-10-25 16:27:24 -07:00
Evan Cahill 88f3593742 Fix error when exporting const enums (#33060) (#34721)
* Allow export declaration to reference const enums

* Update baselines

* Add test to verify reexported const enums are elided
2019-10-25 16:04:44 -07:00
Sheetal Nandi f12eee2e4b
Include *.json in the root files if they are specified as root (#34676)
Fixes #33827
2019-10-25 13:48:38 -07:00
Sangmin Lee a01c8ef764 Fix typo in watchMode.ts (#34701) 2019-10-25 13:13:00 -07:00
Gorka Hernández Estomba 8e1d228a44 Update inconsistent use of the word multiline/multi-line in test cases (#34733)
The word multi-line and multiline are used interchangeably within the file. Multiline seems to be the most used spelling of the word across the TypeScript repository codebase so a few strings have been updated to keep consistency within a single file. Additionally, corrected a minor capitalization mistake.
2019-10-25 11:28:50 -07:00
Ryan Cavanaugh 5e4cd0594e
Update CONTRIBUTING.md 2019-10-24 16:49:51 -07:00
Anders Hejlsberg c404c08fde
Fix reachability analysis for ?? operator (#34702)
* Exclude ?? operator from true/false literal check in createFlowCondition

* Accept new API baselines

* Add tests

* Accept new baselines

* Address CR feedback

* Accept new API baselines
2019-10-24 15:57:14 -07:00
Martin Probst a03227d60e Avoid a crash with @typedef in a script file. (#33847)
* Avoid a crash with `@typedef` in a script file.

Scripts (as opposed to modules) do not have a symbol object. If a script
contains a `@typdef` defined on a namespace called `exports`, TypeScript
crashes because it attempts to create an exported symbol on the
(non-existent) symbol of the SourceFile.

This change avoids the crash by explicitly checking if the source file
has a symbol object, i.e. whether it is a module.

* Add usage of exports.SomeName typedef.

* Fix bug at bind site rather than in declare func
2019-10-24 14:04:42 -07:00
Wesley Wigham 7cfa1dfb8a
Fix regression in mixin emit by removing unneeded line of code (#34715)
* Fix regression in mixin emit by removing unneeded line of code

* Double the test, double the fun
2019-10-24 14:02:37 -07:00
Nathan Shively-Sanders d892fd408f
Fix expando handling in getTypeReferenceType (#34712)
* Fix expando handling in getTypeReferenceType

getExpandoSymbol looks for the initialiser of a symbol when it is an
expando value (IIFEs, function exprs, class exprs and empty object
literals) and returns the symbol.

Previously, however, it returned the symbol of the initialiser without
merging with the declaration symbol itself. This missed, in particular,
the prototype assignment in the following pattern:

```js
var x = function x() {
  this.y = 1
}
x.prototype = {
  z() { }
}

/** @type {x} */
var xx;
xx.z // missed!
```

getJSDocValueReference had weird try-again code that relied on calling
getTypeOfSymbol, which *does* correctly merge the symbols. This PR
re-removes that code and instead makes getExpandoSymbol call
mergeJSSymbols itself.

* Remove extra newline
2019-10-24 13:12:44 -07:00
Nathan Shively-Sanders 969634b97c
Restore delayed merge check to getTypeFromJSDocValueReference (#34706)
* Restore delayed merge check to getTypeFromJSDocValueReference

This is needed when a function merges with a prototype assignment. The
resulting *merged* symbol is a constructor function marked with
SymbolFlags.Class. However, the merge doesn't happen until
getTypeOfFuncClassEnumModule is called, which, in the
getTypeReferenceType code path, doesn't happen until
getTypeFromJSDocValueReference. That means the check for
SymbolFlags.Class is missed.

Previously, getTypeFromJSDocValueReference had a weird check
`symbol !== getTypeOfSymbol(symbol).symbol`, which, if true, ran
getTypeReferenceType again on `getTypeOfSymbol(symbol).symbol`. For
JS "aliases", this had the effect of dereferencing the alias, and for
function-prototype merges, this had the effect of ... just trying again
after the merge had happened.

This is a confusing way to run things. getTypeReferenceType should
instead detect a function-prototype merge, cause it to happen, and
*then* run the rest of its code instead of relying on try-again logic at
the very end. However, for the RC, I want to fix this code by restoring
the old check, with an additional check to make sure that #33106 doesn't
break again:

```ts
const valueType = getTypeOfSymbol(symbol)
symbol !== valueType.symbol && getMergedSymbol(symbol) === valueType.symbol
```

I'll work on the real fix afterwards and put it into 3.8.

* Add bug number
2019-10-24 09:24:58 -07:00
Wesley Wigham 07d3a2ec7e
Do not consider element accesses which are neither statically bindable nor late bound as special assignments (#34679) 2019-10-23 16:01:25 -07:00
Nathan Shively-Sanders 8223c07527
getTypeFromJSDocValueReference: handle import types (#34683)
Previously it only handled types whose declaration was from `require`,
but now it handles types whose reference is an import type as well.
2019-10-23 15:53:38 -07:00
Edward Thomson eb08ee6848 Add GitHub Actions (#34614) 2019-10-23 13:57:49 -07:00
Orta 56b74d3652
Merge pull request #34648 from orta/readme_links
Update the README links
2019-10-23 15:14:59 -04:00
Keen Yee Liau f689982c9f Prioritize loading plugin from probeLocations over peer node_modules
This commit reoroders the loading sequence of a tsserver plugin. It
should first check `pluginProbeLocations` before checking peer
node_modules.

PR closes https://github.com/microsoft/TypeScript/issues/34616
2019-10-23 11:28:44 -07:00