2109 Commits

Author SHA1 Message Date
Wesley Wigham
053b915061 Rebase SymbolWalker change onto master
From PR #9847.
2017-08-22 11:33:32 -07:00
Andy
eef7d8bd3d Treat explicit imports from node_modules as external library imports (#16364)
* Treat explicit imports from `node_modules` as external library imports

* Update baselines
2017-08-17 13:26:38 -07:00
Daniel Rosenwasser
2729281a14 Merge pull request #17631 from Microsoft/synthesizedNamespaces
Always emit leading 'var' declarations for synthesized namespaces
2017-08-16 23:56:07 -07:00
Tycho Grouwstra
76fb6545a5 fix some copy-pasting error (#17766)
* fix some copy-pasting error

* update to reflect @ahejlsberg's feedback
2017-08-16 11:49:24 -07:00
Andy
7409648416 Remove unused UseTypeAliasValue flag (#17779) 2017-08-15 10:24:15 -07:00
Andy
10c8d5effa In services, show the aliasSymbol for a type even if it's not accessible in the current scope (#17433)
* In services, show the aliasSymbol for a type even if it's not accessible in the current scope

* Rename flag
2017-08-15 10:23:45 -07:00
Daniel Rosenwasser
a51397e339 Just track the local names of identifiers instead of ever using symbols. 2017-08-14 21:24:30 -04:00
Andy
543e0affff Make exportSymbol public (#17457)
* Make exportSymbol public

* Add a `getExportSymbolOfSymbol` method

* Use own implementation instead of delegating to `getExportSymbolOfValueSymbolIfExported`
2017-08-14 09:20:48 -07:00
Ron Buckton
e3b6df64b3 Add support to infer the quote style for import quick fixes 2017-08-11 14:26:25 -07:00
Ryan Cavanaugh
c110ecb870 Merge pull request #17625 from RyanCavanaugh/extract-method-2
Extract Method
2017-08-11 10:54:48 -07:00
Andy
f64b8ad902 Add "preserveSymlinks" option (#16661)
* Add "preserveSymlinks" option

* Respond to PR comments
2017-08-11 10:03:21 -07:00
Ryan Cavanaugh
c27ee81341 Merge branch 'master' into extract-method-2 2017-08-10 17:02:14 -07:00
Andy
08fbcd8b80 Fix many no-object-literal-type-assertion lint errors (#17278)
* Fix many no-object-literal-type-assertion lint errors

* Simple fixes

* Use a union for FlowNode

* PR feedback and remove remaining `id()` uses

* Use a union for CodeBlock

* Discriminate CodeBlock by CodeBlockKind
2017-08-10 12:52:15 -07:00
Andy
37b20ee670 For duplicate source files of the same package, make one redirect to the other (#16274)
* For duplicate source files of the same package, make one redirect to the other

* Add reuseProgramStructure tests

* Copy `sourceFileToPackageId` and `isSourceFileTargetOfRedirect` only if we completely reuse old structure

* Use fallthrough instead of early exit from loop

* Use a set to efficiently detect duplicate package names

* Move map setting outside of createRedirectSourceFile

* Correctly handle seenPackageNames set

* sourceFileToPackageId -> sourceFileToPackageName

* Renames

* Respond to PR comments

* Fix bug where `oldSourceFile !== newSourceFile` because oldSourceFile was a redirect

* Clean up redirectInfo

* Respond to PR comments
2017-08-09 14:39:06 -07:00
Wesley Wigham
43e758e1a9 Create synthetic default exports for dynamic imports (#17492)
* Create synthetic default exports for dynamic imports

* Slightly better solution

* Actually accept baselines

* Slightly adjust synthetic type

* Cache synthetic type

* Inline variables, remove non-required calls

* Rename function
2017-08-08 17:01:18 -07:00
Ron Buckton
75c8ecb2f1 Merge pull request #17517 from tinganho/IgnoredCatchParameter
Ignored catch parameter
2017-08-08 16:15:18 -07:00
Wesley Wigham
a46d6bde97 Add a seperate cache for the all attributes version of the jsx attributes type (#17620) 2017-08-08 13:07:27 -07:00
Anders Hejlsberg
d0a195a3c5 Propagate type comparer function in contextual signature instantiation 2017-08-05 12:32:56 -07:00
Ryan Cavanaugh
c7f665faa1 Extract Method (squash) 2017-08-04 16:10:33 -07:00
Tingan Ho
d5c24f3cd3 Addresses CR comment 2017-08-02 20:13:43 +02:00
Tingan Ho
81fb3f702a Addresses CR feedback 2017-08-01 22:10:12 +02:00
Tingan Ho
c65e5a1d13 Removes valid test cases from invalid test case file 2017-07-30 23:27:14 +02:00
Tingan Ho
b917eb0225 Adds optional catch parameter into the compiler 2017-07-30 23:26:47 +02:00
Tingan Ho
b17bd97e71 Clean up 2017-07-30 23:26:23 +02: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
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
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
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
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
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
Andy
f0bd91c314 Convert Array to ReadonlyArray/Push in commandLineParser.ts (#17323) 2017-07-21 07:16:22 -07:00
Andy
53e4040ceb Remove duplicate emptyArrays (#17305) 2017-07-20 06:45:22 -07:00
Wesley Wigham
8075353356 Appropriately parenthesize keyof and typeof queries in array types (#17272)
* Appropriately parenthesize keyof and typeof queries when they are array types

* Fix test and then the same bug in the symbol writer
2017-07-18 15:08:53 -07:00
Andy
194c2bc2ca Make NodeArray readonly (#17213)
* Make NodeArray readonly

* Fix bug: use emptyArray instead of undefined

* Fix bug: Don't expose MutableNodeArray

* Undo trailing whitespace changes
2017-07-18 10:38:21 -07:00
Andy
80b19a09a1 Introduce a ReadonlyMap interface and use it in core.ts (#17161) 2017-07-18 10:26:11 -07:00
Andy
068b17a1b8 ParameterDeclaration: name may be undefined (#17074) 2017-07-18 09:47:19 -07:00
Nathan Shively-Sanders
7d7a06dbc2 Merge pull request #17250 from Microsoft/quickfix-jsdoc-in-ts
Quickfix jsdoc in Typescript files
2017-07-18 08:59:19 -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
Andy Hanson
96d537bc54 readFile may return undefined 2017-07-14 15:57:23 -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
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
Andy
c6a6467073 Remove unneeded ExportType and ExportNamespace flags (#16766) 2017-07-13 09:21:13 -07:00
Andy
08030c7d02 Convert most of core.ts to accept ReadonlyArray (#17092)
* Convert most of core.ts to accept ReadonlyArray

* Fix lint

* Fix isArray
2017-07-11 17:39:33 -07:00
Ron Buckton
bb3253e544 Merge pull request #17044 from filipesilva/patch-1
Allow visitors to return undefined
2017-07-10 11:47:48 -07:00