Commit graph

18691 commits

Author SHA1 Message Date
Nathan Shively-Sanders
1b7faf10ac Merge pull request #17254 from Microsoft/generic-Object-jsdoc-creates-index-signature
JSDoc:Object<string, T> creates index signature
2017-07-18 08:48:56 -07:00
Nathan Shively-Sanders
65e8da134c Add jsdoc to getNullableType now that it's public 2017-07-18 08:48:12 -07:00
Wesley Wigham
8a1cd33451 Use jsdoc casts (#17251)
* Allow jsdoc casts of parenthesized expressions

* Feedback from #17211
2017-07-17 23:39:20 -07:00
Armando Aguirre
6f28f83f18 Added node_modules path check on getTodoComments method. 2017-07-17 17:35:46 -07:00
Nathan Shively-Sanders
047ab9b0e3 Update name of getIntendedTypeFromJSDocTypeReference 2017-07-17 16:23:42 -07:00
Nathan Shively-Sanders
3b7a07c441 Fix lint 2017-07-17 16:21:54 -07:00
Nathan Shively-Sanders
1173dc104a Improve naming and style a little 2017-07-17 16:18:09 -07:00
Nathan Shively-Sanders
10a91c5426 JSDoc:Object<string, T> creates index signature
And `Object<number, T>` creates a numeric index signature. Other uses
still create `any` as before.
2017-07-17 16:14:42 -07:00
Nathan Shively-Sanders
08ae02263a Contextually type this in object literals in JS
Previously, `this` would only get a contextual type inside object
literals with `--noImplicitThis` turned on in Typescript files.
2017-07-17 15:59:18 -07:00
Nathan Shively-Sanders
73cfa64f44 Make sure not to truncate the stringified type from typeToString 2017-07-17 14:47:10 -07:00
Andy
de9a67f2f3 Issue template: Recommend to run tsc directly (#17246)
* Issue template: Recommand to run `tsc` directly

* List some common build tools
2017-07-17 14:45:21 -07:00
Sheetal Nandi
54dfdd77fb Merge pull request #17210 from Microsoft/readfile
`readFile` may return undefined
2017-07-17 14:39:57 -07:00
Nathan Shively-Sanders
b13de0547e JSDoc codefix:getTypeFromTypeNode >>> typeToString
Instead of trying to walk the type structure in the codefix, I changed
to call getTypeFromTypeNode in the checker and then calling
typeToString. Together, these two functions normalise out JSDoc.

Note that you only get `T | null` for `?T` if you have --strict on. This
is technically correct -- adding a null union does nothing without
strict -- but it would still serve as documentation.
2017-07-17 14:11:35 -07:00
Nathan Shively-Sanders
cbe7b4dba3 Update jsdoc codefix tests; test function(...) syntax 2017-07-17 14:11:06 -07:00
Andy
5d46ca7118 Reuse stored types for any[] and Promise<any> instead of creating new ones (#17179)
* Reuse stored types for any[] and Promise<any> instead of creating new ones

* Don't store anyPromiseType
2017-07-17 12:56:58 -07:00
Andy
2a219af308 convertFunctionToEs6Class: Bail if this is not a JavaScript file (#17149) 2017-07-17 12:56:16 -07:00
Andy Hanson
2ce23909b2 Fix error message 2017-07-17 12:39:01 -07:00
Andy
6cf30fbccf Fix bug in importTracker: getExportNode must verify that we are on the LHS of a VariableDeclaration (#17205) 2017-07-17 12:29:29 -07:00
Andy
555776eb3c Minor cleanups in builder (#17208)
* Minor cleanups in builder

* Use enumerateInsertsAndDeletes
2017-07-17 12:24:56 -07:00
Nathan Shively-Sanders
f9e5576d58 Codefix for ?! pre/postfix JSDoc types
For ?, provide two code fixes, one for jsdoc/closure semantics
(`?t -> t | null)` and one for flow semantics
(`?t -> t | null | undefined`).

The current way of doing this is the hackiest thing you can imagine, but
it was easier than lifting everything into the list monad for a code fix
that I might not actually keep.
2017-07-17 11:06:20 -07:00
Nathan Shively-Sanders
3776b0b58b Codefix for Array.<number> -> Array<number> 2017-07-17 10:33:04 -07:00
Nathan Shively-Sanders
dba552d071 Transform trees rather than produce strings
1. Still pretty janky.
2. Type Reference code doesn't work yet.
3. Other transforms just aren't done.
4. Always replaces, even when there isn't any transformation of JSDoc
types. (This probably isn't an issue since we wouldn't issue an error unless there were
some JSDoc to change.)
2017-07-17 10:02:29 -07:00
Nathan Shively-Sanders
e98ac8d970 Merge branch 'parse-jsdoc-with-ts-type-parser' into quickfix-jsdoc-in-ts 2017-07-17 08:42:00 -07:00
Nathan Shively-Sanders
240f1f1be4 Merge pull request #17176 from Microsoft/parse-jsdoc-with-ts-type-parser
Parse jsdoc with normal TS type parser
2017-07-17 08:41:06 -07:00
Nathan Shively-Sanders
3f60364a64 Improve test of jsdoc literal type parsing 2017-07-17 08:29:40 -07:00
Nathan Shively-Sanders
efdba54deb Add codefix for jsdoc types in Typescript
It only handles a few simple types right now, but the skeleton is there.
2017-07-14 16:27:36 -07:00
Nathan Shively-Sanders
a3a6862d43 Add simple jsdoc code fix changes 2017-07-14 16:27:09 -07:00
Andy Hanson
96d537bc54 readFile may return undefined 2017-07-14 15:57:23 -07:00
Nathan Shively-Sanders
61c9f98eef Merge branch 'master' into parse-jsdoc-with-ts-type-parser 2017-07-14 15:04:06 -07:00
Nathan Shively-Sanders
172db13306 Parse more types in JSDoc function() syntax
Also some cleanup from PR comments
2017-07-14 14:34:32 -07:00
Nathan Shively-Sanders
bdc3f1f3f7 Address more PR comments 2017-07-14 13:29:44 -07:00
Daniel Rosenwasser
e8421827e0 Merge pull request #16600 from alexeagle/pretty2
Add missing newline in --pretty diagnostics formatter
2017-07-14 12:22:05 -07:00
Nathan Shively-Sanders
b2e892f0b9 Update baselines 2017-07-14 11:08:06 -07:00
Nathan Shively-Sanders
40ae42221e Better JSDoc generic errors and faster isInJSDoc 2017-07-14 11:07:20 -07:00
Nathan Shively-Sanders
f1145c35ca Improve JSDoc function checking
1. Remove checkJSDocFunctionType in favour of checkSignature.
2. Check that 'new', in addition to 'this', must be the first parameter.
3. Remove prematurely added JSDoc-quickfix test.
2017-07-14 10:15:30 -07:00
Nathan Shively-Sanders
6e861fd3e6 Remove JSDocConstructor/ThisType and just use named parameters 2017-07-14 09:36:12 -07:00
Nathan Shively-Sanders
da5285e979 Update baselines 2017-07-14 09:34:35 -07:00
Nathan Shively-Sanders
d24b3a3cba Add fourslash tests for function(new/this:T) syntax 2017-07-13 14:49:50 -07:00
Andy
680bfbb705 Combine moduleHasNonRelativeName with isExternalModuleNameRelative (#16564) 2017-07-13 13:46:04 -07:00
Nathan Shively-Sanders
ac478a9720 Add missing word in error message 2017-07-13 13:37:35 -07:00
Andy
d2ec45f354 Remove unnecessary 'ts.' qualifications (#17163) 2017-07-13 13:08:59 -07:00
Nathan Shively-Sanders
48d9012989 Update baselines 2017-07-13 11:34:56 -07:00
Nathan Shively-Sanders
91633cde5f Test JSDoc parsing using TS parser 2017-07-13 11:33:12 -07:00
Nathan Shively-Sanders
bc69c7e6d1 Parse JSDoc types using the normal TS parser
This means that JSDoc types can include the full range of Typescript
types now. It also means that Typescript annotations can include JSDoc
types. This is disallowed with a new error, however. But Typescript can
still give the correct types to JSDoc that shows up in .ts files by
mistake. This can easily happen, for example with types like

```ts
var x: number? = null;
var y: ?string = null;
var z: function(string,string): string = (s,t) => s + t;

// less likely to show up, but still understood.
var ka: ? = 1;
```

In the future, I will add a quick fix to convert these into the correct
types.

Fixes #16550
2017-07-13 11:27:50 -07:00
Mine Starks
fd2dd2edc0 Merge pull request #17078 from minestarks/removeimportfix
Code fix to remove unused named import should preserve default import
2017-07-13 10:53:35 -07:00
Andy
7b5e1e9c49 Use array helpers instead of 'reduce' (#17172) 2017-07-13 10:43:01 -07:00
Andy
c6a6467073 Remove unneeded ExportType and ExportNamespace flags (#16766) 2017-07-13 09:21:13 -07:00
Andy
69d3ca774a When adding completions for a module, don't get the type of the module if not necessary. (#16768)
* When adding completions for a module, don't get the type of the module if not necessary.

* Use SymbolFlags.Module alias
2017-07-13 09:20:40 -07:00
Andy
6880ee33a3 displayPartWriter: Use try-finally to clear (#16807) 2017-07-13 08:14:02 -07:00
Andy
9a3847feac getSingleLineStringWriter: Use try-finally, and only one stringWriter (#16751)
* getSingleLineStringWriter: Use try-finally, and only one stringWriter

* Use a `usingSingleLineStringWriter` helper function

* Add assert
2017-07-13 08:13:49 -07:00