Commit graph

13459 commits

Author SHA1 Message Date
Anders Hejlsberg caea4f3a50 Properly handle constraints for types like (T & { [x: string]: D })[K] 2017-08-02 11:54:29 -07:00
Anders Hejlsberg 5895057578 Defer indexed access type resolution in more cases 2017-07-30 17:44:38 -07:00
Andy f945b26b54 Forbid type assertions in '.js' files (#17503) 2017-07-29 05:41:08 -07:00
Andy b0435d8490 Replace a 'forEach' with 'find' (#17499) 2017-07-28 19:03:47 -07:00
Andy 2efaa7c9e2 Forbid non-null assertion in '.js' files (#17481) 2017-07-28 16:40:20 -07:00
Andy 58769e1dab Fix bad parameter comment (#17496) 2017-07-28 15:44:13 -07:00
Andy 476157fab8 jsTyping: Better logging for addInferredTypings (#17249)
* jsTyping: Better logging for addInferredTypings

* Fix tests

* Indent other log under "Searching for typing names"
2017-07-28 12:43:50 -07:00
Daniel Rosenwasser afdbf00d53 Add check to ensure that property access suggestions are only performed on the accessed property. 2017-07-27 18:12:20 -07:00
Anders Hejlsberg 06cfe51a45 Merge pull request #17430 from Microsoft/inferenceExcessProperties
Fix inference with excess properties
2017-07-27 17:35:37 -07:00
Anders Hejlsberg e7e6475440 Merge pull request #17382 from Microsoft/fixPartialTypeRelations
Fix partial type relations
2017-07-27 17:31:55 -07:00
Andy d9172dc321 Remove double 'if' (#17436) 2017-07-27 16:49:26 -07:00
Daniel Rosenwasser 65650253cf Merge pull request #17462 from Microsoft/codeFixForErrorForPropertyOfTypeAsType
Quick fix to correct qualified names to indexed access types
2017-07-27 15:32:49 -07:00
Daniel Rosenwasser c659fe902d Remove unnecessary references in 'src/harness/tsconfig.json' - they're already referenced in 'src/harness/codefixes/fixes.ts'. 2017-07-27 15:06:30 -07:00
Andy ce51a095f8 Add another use of the Comparer type (#17438) 2017-07-27 13:42:32 -07:00
Daniel Rosenwasser 039e85a1fc Merge pull request #17459 from Microsoft/errorForPropertyOfTypeAsType
Improve error message to suggest indexed access types.
2017-07-27 12:45:58 -07:00
Daniel Rosenwasser 0dc74245e2 Added codefix for replacing qualified names with indexed access types. 2017-07-27 12:42:11 -07:00
Daniel Rosenwasser 7c7f9adcc2 Added assertion. 2017-07-27 12:14:52 -07:00
Daniel Rosenwasser 497e3cfb68 Provide a more helpful error message when incorrectly using qualified names in the case of 'Type.propertyName'. 2017-07-27 11:44:26 -07:00
Andy 70e5c6b1e5 Add some missing | undefined in parser.ts (#17407) 2017-07-27 11:25:48 -07:00
Andy 3330f2a33b JsTyping: Remove "safeList" global variable (#17304) 2017-07-27 10:54:47 -07:00
Andy 977d907417 createMissingNode: Only assign '.text' or '.escapedText' on nodes of the correct type (#17439)
* createMissingNode: Only assign '.text' or '.escapedText' on nodes of the correct type

* Revert to having only createMissingNode
2017-07-27 10:34:08 -07:00
Mine Starks 89994111bd Missing import code fix - include export assignment properties when looking for module exports (#17376)
* Include export assignment properties when looking for module exports

* Create new API function for tryGetMemberInModuleExportsAndProperties

* Cleanup based on review feedback
2017-07-26 16:17:01 -07:00
Andy cc8399dc41 Escape string literal before looking it up in enum's symbol table (#17441) 2017-07-26 16:00:34 -07:00
Wesley Wigham b080aa9440 Fix #16778 - use previous type and not declared type (#17381)
* Fix #16778 - use previous type to check discriminable type and not declared type

* Rename prevType -> computedType
2017-07-26 15:27:02 -07:00
Wesley Wigham b9fe9964d2 Change isStartOfParameter to be more general (#17431) 2017-07-26 15:21:21 -07:00
Nathan Shively-Sanders fdb44651a3 Merge pull request #17352 from Microsoft/jsdoc-param-type-literals
Parse jsdoc `@param` type literals
2017-07-26 15:17:31 -07:00
Andy 6f90b3112a Make safelist an instance field of ProjectService (#17307) 2017-07-26 13:47:44 -07:00
Nathan Shively-Sanders 9fd90e7e02 Merge branch 'master' into jsdoc-param-type-literals 2017-07-26 11:09:24 -07:00
Nathan Shively-Sanders fde4c188ac Address more PR comments 2017-07-26 10:57:29 -07:00
Wesley Wigham 5b77ef8b4d Fix infinite loop in jsdoc parsing (#17420)
* Test case

* Move parameter fix to apply to jsdoc (and all lists)

* Inline function, generalize comment
2017-07-26 10:12:59 -07:00
Anders Hejlsberg bd1f8c50a4 Only check excess properties on final types from inference 2017-07-26 07:16:06 -07:00
Andy 124510e409 Add comment clarifying isNotNeededPackage (#17321) 2017-07-26 07:09:22 -07:00
Andy f667357aad Use ReadonlyArray in utilities.ts (#17413) 2017-07-25 15:46:29 -07:00
Andy 30d973bdcb Rename symbol.name to escapedName and make name unescaped (#17412) 2017-07-25 14:22:26 -07:00
Andy e515151ba4 Remove unnecessary MapLikes in commandLineParser (#17324)
* Remove unnecessary `MapLike`s in commandLineParser

* Fix typo

* Inline knownKeysCount
2017-07-25 14:19:17 -07:00
Nathan Shively-Sanders c55a043767 Address PR comments from Andy
I'll take a look at Wesley's next and see if those require any changes.
2017-07-25 14:14:12 -07:00
Andy c1375d5422 generateTSConfig: Remove unnecessary variable (#17330) 2017-07-25 13:30:48 -07:00
Andy eadd084c82 Add 'name' property to Identifier (#17329)
* Add 'name' property to Identifier

* Rename to unescapedText

* Rename 'id.text' to 'id.escapedText'

* Rename 'id.unescapedText' to 'id.text'

* Make escapeIdentifier and unescapeIdentifier do nothing
2017-07-25 13:16:34 -07:00
Andy d4f8da0272 Revert #17074 (#17326)
* Revert #17074

* Also revert comment
2017-07-25 13:15:45 -07:00
Ron Buckton d74cb24640 Merge pull request #17354 from weswigham/fix-parameter-parsing-infinite-loop
Fix parameter parsing infinite loop
2017-07-24 18:21:10 -07:00
Andy a70b50ae7c getResolvedModule: Don't need to call hasResolvedModule (#16423)
* getResolvedModule: Don't need to call hasResolvedModule

* Don't call tryGetModuleNameFromDeclaration on a synthesized importNode

* Apply suggested changes
2017-07-24 17:51:37 -07:00
Wesley Wigham 98d5830831
Use scanner position instead of node members 2017-07-24 17:51:35 -07:00
Wesley Wigham 06beee1cc8
Much simpler fix, rolls in really old fix, removed unused comment 2017-07-24 15:16:21 -07:00
Anders Hejlsberg 47e6aef858 Given T extends Foo, make Partial<T> related to Partial<Foo> 2017-07-24 13:59:43 -07:00
Andy eee4c618e2 Indent list of open files (#17255) 2017-07-24 13:32:43 -07:00
Andy 7702d15cf3 Add current time to tsserver logs (#17268) 2017-07-24 13:32:23 -07:00
Wesley Wigham e7bf44e820
Fix for loop which retains jsdoc behaviors 2017-07-21 17:20:56 -07:00
Nathan Shively-Sanders 59961394cb @param parsing:const enum to improve readability 2017-07-21 15:07:20 -07:00
Nathan Shively-Sanders 7ff91c1e1c Parse jsdoc type literals in params
Now Typescript supports the creation of anonymous types using successive
`@param` lines in JSDoc:

```js
/**
 * @param {object} o - has a string and a number
 * @param {string} o.s - the string
 * @param {number} o.n - the number
 */
function f(o) { return o.s.length + o.n; }
```

This is equivalent to the Typescript syntax `{ s: string, n: number }`,
but it allows per-property documentation, even for types that only need
to be used in one place. (`@typedef` can be used for reusable types.)

If the type of the initial `@param` is `{object[]}`, then the resulting
type is an array of the specified anonymous type:

```js
/**
 * @param {Object[]} os - has a string and a number
 * @param {string} os[].s - the string
 * @param {number} os[].n - the number
 */
function f(os) { return os[0].s; }
```

Finally, nested anonymous types can be created by nesting the pattern:

```js
/**
 * @param {Object[]} os - has a string and a number
 * @param {string} os[].s - the string
 * @param {object} os[].nested - it's nested because of the object type
 * @param {number} os[].nested.length - it's a number
 */
function f(os) { return os[0].nested.length; }
```

Implementation notes:

1. I refactored JSDocParameterTag and JSDocPropertyTag to
JSDocPropertyLikeTag and modified its parsing to be more succinct. These
changes make the overall change easier to read but are not strictly
required.
2. parseJSDocEntityName accepts postfix[] as in `os[].nested.length`,
but it doesn't check that usages are correct. Such checking would be
easy to add but tedious and low-value.
3. `@typedef` doesn't support nested `@property` tags, but does support
`object[]` types. This is mostly a practical decision, backed up by the
fact that usejsdoc.org doesn't document nested types for `@typedef`.
2017-07-21 14:04:14 -07:00
Mine Starks 441daa4e19 Merge pull request #17302 from minestarks/removeimportfix
Bugs in missing import codefix
2017-07-21 10:22:24 -07:00