Commit Graph

12683 Commits

Author SHA1 Message Date
Wesley Wigham
a4a1bed88b Add showConfig tsc flag for debugging configs (#27353)
* Add showConfig tsc flag for debugging configs

* Merge showConfig implementation with init implementation, add basic unit tests

* Fix lint

* Add missing semicolon

* showConfig when theres no config file
2018-10-31 15:57:09 -07:00
Wesley Wigham
3a2f7c0df1 Allow intersections of readonlys to be assignable to a readonly intersection (#28218)
* Allow intersections of readonlys to be assignable to a readonly intersection

* Add real motivating react example to test suite
2018-10-31 14:09:12 -07:00
Wesley Wigham
0ef844ff2b Avoid this-instantiation if not necessary for relationship (#28263) 2018-10-31 13:21:35 -07:00
Anders Hejlsberg
8e4b90da00 Merge pull request #28234 from Microsoft/genericSpread
Generic spread expressions in object literals
2018-10-31 12:52:16 -07:00
Sheetal Nandi
dcdda87258 Merge pull request #28243 from Microsoft/containerOnlyRef
Report error requiring references to have composite only if the program is not container only
2018-10-30 21:20:52 -07:00
Sheetal Nandi
4606a4b700 Merge pull request #28209 from Microsoft/ignorePathsStartingWithDotInNodeModules
Ignore any changes to file or folder that are in node_modules and start with "."
2018-10-30 18:06:00 -07:00
Andy
903e68164e Redo resolution on ATA when previous resolution was to '.js' file (#28236)
* Redo resolution on ATA when previous resolution was to '.js' file

* Use a separate test case
2018-10-30 16:39:40 -07:00
Anders Hejlsberg
9d5e8fe89f Continue to error on rest from generic source type 2018-10-30 16:00:05 -07:00
Sheetal Nandi
60801a261c Report error requiring references to have composite only if the program is not container only 2018-10-30 15:22:00 -07:00
Wesley Wigham
e2436f331a Use constraint for default default value if possible (#28222) 2018-10-30 14:55:30 -07:00
Wesley Wigham
4cfff8962c Fix declaration emit for cross-file enums (#28237) 2018-10-30 14:55:01 -07:00
Klaus Meinhardt
33568795e0 Suggest adding to tsconfig after installing @types (#28211)
Ref: https://github.com/Microsoft/TypeScript/pull/28168#issuecomment-433554228
2018-10-30 11:33:05 -07:00
Andy
176627c818 Support augmenting module with export as namespace (#27281)
* Support augmenting module with `export as namespace`

* Warn on use of merged symbol containing 'export as namespace'
2018-10-30 11:16:26 -07:00
Sheetal Nandi
c9fadf1f46 Ignore wild card directory watchers with node_modules file or folder starting with . 2018-10-30 11:06:13 -07:00
Andy
acc34bd95d Miscellaneous code cleanup relating to module resolution (#28092)
* Miscellaneous code cleanup relating to module resolution

* Revert if condition
2018-10-30 10:15:01 -07:00
Andy
7c515bf6e8 Remove toSortedArray and toDeduplicatedSortedArray, use sort and sortAndDeduplicate (#28214) 2018-10-30 08:41:31 -07:00
Anders Hejlsberg
7a47248f30 Produce intersection types for spreads with generic types 2018-10-29 16:02:34 -07:00
Nathan Shively-Sanders
64ff195426 Set-only accessors spread to undefined (#28213)
* Set-only accessors spread to undefined

Previously they were skipped. The runtime behaviour is to create a
property of type undefined, unlike (for example) spreading numbers or
other primitives. So now spreading a set-only accessor creates a
property of type undefined:

```ts
const o: { foo: undefined } = { ...{ set foo(v: number) { } } }
```

Notably, `o.foo: undefined` not `number`.

Fixes #26337

* Fix isSpreadableProperty oversimplification
2018-10-29 14:51:12 -07:00
Nathan Shively-Sanders
60efb65931 infer-from-usage suggestions can't be ignored, and always do something when invoked. (#28206)
* Do not ts-ignore noImplicitAny suggestions

Still need to write tests.

* Add tests

* More tests

* Update baselines
2018-10-29 13:23:33 -07:00
Sheetal Nandi
d32c1b091a Ignore any changes to file or folder that are in node_modules and start with "."
Fixes #27673
2018-10-29 12:00:46 -07:00
Andy
24febc2445 Allow to combine --resolveJsonModule with --isolatedModules (#28207) 2018-10-29 11:56:49 -07:00
Andy
672b0e3e16 Have flatMap return a ReadonlyArray by default (#28205) 2018-10-29 11:12:51 -07:00
Wesley Wigham
a6952887e9 Use same condition in isReferencedAliasDeclaration as isAliasResolvedToValue (#28171) 2018-10-29 09:38:10 -07:00
Wesley Wigham
e2100cd2cc Measure variance of aliased conditional types using variance markers (#27804)
* Measure variance of aliased conditional types using variance markers

* Just do variance probing for all type aliases

* Small limiter for predictability

* Inline property set, remove unused functions
2018-10-26 16:26:20 -07:00
Anders Hejlsberg
ccc16136b2 Merge pull request #28170 from Microsoft/fixGenericMappedTypeConstraint
No constraint for { [P in K]: XXX } where K is type variable
2018-10-26 16:02:17 -07:00
Wesley Wigham
972c403cd8 JSX uses mixed signatures and union sigs use subtype on partial match (#28141)
* JSX uses mixed signatures and union sigs use subtype on partial match

* Small improvement
2018-10-26 16:01:32 -07:00
Andy
36dfd775b3 Parse an object literal property as shorthand unless followed by '(' or ':' (#28121) 2018-10-26 15:00:31 -07:00
Jack W
abce9ae0be Bring typeof switch inline with if (#27680)
- Narrow unknown
- Narrow union members (in addition to filtering)
2018-10-26 14:56:26 -07:00
Anders Hejlsberg
30d1ecd1bd Constraint for { [P in K]: XXX } should be empty type 2018-10-26 14:14:53 -07:00
Klaus Meinhardt
3fb8873bc2 don't resolve import types in JSDoc of TS files (#28158) 2018-10-26 09:50:12 -07:00
Nathan Shively-Sanders
dc9a066f65 Do not merge commonJS exports into an alias (#28133)
* Do not merge commonsjs exports onto an alias

getCommonJSExportEquals merges export assignments and export property
assignments. Something like this, which has no equivalent structure in
TS:

```js
module.exports = function() { }
module.exports.expando = 1
```

However, it is sometimes called with an alias, when its
parent, resolveExternalModuleSymbol, is called with dontResolveAlias:
true, and when the initialiser of the export assignment is an alias:

```js
function alias() { }
module.exports = alias
module.exports.expando = 1
```

In this case, (1) the actual value `alias` will have already merged in a
previous call to getCommonJSExportEquals and
(2) getTypeOfSymbol will follow the alias symbol to get the right type.
So getCommonJSExportEquals should do nothing in this case.

This bug manifests in the code for dynamic imports, which calls
getTypeOfSymbol on the incorrectly merged alias, which now has enough
value flags--Function, for example--to take the wrong branch and
subsequently crash.

* Update baselines
2018-10-25 15:08:06 -07:00
Andy
070218f828 Remove DirectoryOfFailedLookupWatch#ignore, use DirectoryOfFailedLookupWatch | undefined (#28091) 2018-10-25 15:03:46 -07:00
Andy
efc831e0ba At '.' in array literal, don't close the array (#28120) 2018-10-25 12:25:33 -07:00
Sheetal Nandi
539b9a6d50 Merge pull request #28028 from ajafff/optimize-resolve-reusing-old-state
Fix performance regression when reusing old state
2018-10-25 11:12:53 -07:00
Wesley Wigham
05716a74a5 Add support for configuration inheritance via packages (#27348)
* Add support for configuration inheritance via packages

* Fix lint

* Propagate trace into config parse hosts
2018-10-25 10:19:57 -07:00
Anders Hejlsberg
6e8e5c10dd Merge pull request #28112 from Microsoft/fixInstanceofControlFlow
Fix instanceof control flow analysis
2018-10-25 06:16:39 -07:00
Nathan Shively-Sanders
fe2a33fcbc Merge existing JSDoc comments (#27978)
* Correct indentation, using correct (I hope) indentation code

Note that part of the code, in formatting.ts, is cloned but should be
extracted to a function instead.

* Remove some possibly-superfluous code

But I see 4 failures with whitespace, so perhaps not.

* Restrict indentation change to avoid breaking baselines

The indentation code is very complex so I'm just going to avoid breaking
our single-line tests for now, plus add a simple jsdoc test to show that
multiline jsdoc indentation isn't destroyed in the common case.

* Switched over to construction for @return/@type

Still doesn't merge correctly though

* Add @return tags to emitter

* Merge multiple jsdocs

(not for @param yet)

* Merge multiple jsdoc for parameters too

* Emit more jsdoc tags

Not all of them; I got cold feet since I'll have to write tests for
them. I'll do that tomorrow.

* Many fixes to JSDoc emit

And single tests (at least) for all tags

* Cleanup in textChanges.ts

* Cleanup in formatting.ts

(Plus a little more in textChanges.ts)

* Cleanup in inferFromUsage.ts

* Fix minor omissions

* Separate merged top-level JSDoc comments with \n

instead of space.

* Don't delete intrusive non-jsdoc comments

* Cleanup from PR comments

1. Refactor emit code into smaller functions.
2. Preceding-whitespace utility is slightly easier to use.
3. Better casts and types in inferFromUsage make it easier to read.

* Fix bogus newline

* Use @andy-ms' cleanup annotateJSDocParameters
2018-10-24 16:14:52 -07:00
Anders Hejlsberg
6fbd2a5f59 Reset narrowing of 'x.y' only when 'x' has a narrowable type 2018-10-24 13:51:11 -07:00
Nathan Shively-Sanders
ff6f94791f Use regex+getTokenAtPosition to find dynamic import (#28104)
Instead of walking the entire tree. This stack overflows for large
trees.

Still need to adapt a test.
2018-10-24 11:27:39 -07:00
Wesley Wigham
0a7c92864d Fix Object.defineProperty declaration expando-ness and renames (#28061)
* Allow object.defineProperty calls to be expando properties

* Fix rename locations for object.defineProperty assignments
2018-10-23 09:33:53 -07:00
Wesley Wigham
fbd6cad437 Like #27964 but for JSX (#28068) 2018-10-22 19:18:20 -07:00
Andy
5becc3b170 Rename of non-intrinsic JSX element should rename the declaration (#28066) 2018-10-22 18:17:32 -07:00
Andy
82773b8550 Fix bug: only getCompletionEntriesFromTypings if completions are for top-level directory (#27226)
* Fix bug: only getCompletionEntriesFromTypings if completions are for top-level directory

* Support subdirectories of a nonrelative import
2018-10-22 18:17:09 -07:00
Sheetal Nandi
7ed9e44055 Merge pull request #28059 from ajafff/lsh-resolve-return-type
fix return type of resolveModuleNames and resolveTypeReferenceDirectives
2018-10-22 18:09:15 -07:00
Wesley Wigham
6e5e09cef8 Reject return type inferences to the autoType or autoArrayType (#27169)
* Reject return type inferences to the autoType or autoArrayType

* Accept new error positions
2018-10-22 16:44:32 -07:00
Wesley Wigham
0c36266706 Obey the excludeArgument parameter when checking JSX signature validity (#28002)
* Obey the excludeArgument parameter when checking JSX signature validity

* Fix conditional type extending any contextual types and accept baselines

* use flag check to also drop unknown from comparison for the same reason

* Slight refinement - make an intersection to ensure parameter constraints flow through contextual types when instantiated

* Format ternary more nicely
2018-10-22 16:36:11 -07:00
Wesley Wigham
f701daf4e0 Infer over each mapped type constraint member if it is a union (#28006) 2018-10-22 16:33:43 -07:00
Daniel Rosenwasser
68ce68da79 Merge pull request #27964 from Igorbek/issue27854
Fix bug in reduceEachChild for tagged template expressions
2018-10-22 15:49:54 -07:00
Klaus Meinhardt
5b3fe6e68b update other interfaces and implementations
and accept baseline
2018-10-22 21:23:04 +02:00
Klaus Meinhardt
3b058a4de4 fix compile errors, accept baselines 2018-10-22 21:12:12 +02:00