7342 Commits

Author SHA1 Message Date
Wesley Wigham
19ec83fcdf
Refactor declaration emitter into declaration transformer (#21930)
* Refactor declaration emitter into declaration transformer

* Slight cleanup from code review feedback

* Incorporate fix for new test

* Swaths of PR feedback

* Merge public methods

* Per-file output

* Preserve input import ordering more often

* Unify jsdoc comment start detection under more lenient rule

* Move to per-file transformations to reduce the memory that msut be retained

* Fix typo
2018-03-15 22:23:10 -07:00
Andy
85e9cce3c7
Don't add external module completions in a pure commonjs file (#22583) 2018-03-15 08:13:16 -07:00
Andy
e7ce3f9457
useNonAdjustedEndPosition when replacing import node (#22517)
* useNonAdjustedEndPosition when replacing import node

* Never adjust positions, and add trivia test
2018-03-14 11:46:45 -07:00
Nathan Shively-Sanders
677d860b44
No error on unmatchable @param tags (#22510)
* No errr on unmatchable `@param` tags

Such as when the initializer is not a function, or when the function
mentions `arguments` in its body.

* Do not require dummy param for JS uses of arguments

1. JS functions that use `arguments` do not require a dummy parameter in
order to get a type for the synthetic `args` parameter if there is an
`@param` with a `...` type.
2.JS functions that use `arguments` and have an `@param` must have a
type that is a `...` type.

* Check for array type instead of syntactic `...`

* Address PR comments

* Update baselines
2018-03-14 10:17:54 -07:00
Nathan Shively-Sanders
0fa838a3ef
Brackets and postfix= in @param add undefined (#22514)
* Brackets and postfix= in `@param` add undefined

Previously they only added optionality.
Note that, unlike Typescript, when a parameter initializer is specified
in jsdoc, it does not remove undefined in the *body* of the function.
That's because TS will generate initialisation code, but JS won't, so
the author will have to manually write code to remove undefined from the
type.

```js
/** @param {number} [a=101] */
function f(a) {
  // a: number | undefined here
  if (!a) {
    a = 101
  }
  // a: number here
}
```

Note that we don't check that
1. the initializer value is actually assigned to the parameter.
2. the initializer's type matches the declared type of the parameter.

Pretty much we just parse it and leave it alone.

* Address PR comments
2018-03-13 15:56:38 -07:00
Mohamed Hegazy
708caf9a72 Do not use unguarded process in tsc.ts 2018-03-13 11:03:12 -07:00
Andy
83b438ffa6
fixUnusedIdentifier: Don't remove setter parameter (#22488) 2018-03-12 16:07:20 -07:00
Andy
ac5a39c709
Fix bug: Don't skip emitting JSX attributes (#21777) 2018-03-12 14:03:25 -07:00
Nathan Shively-Sanders
be1c11581e
Add js user tests (#22449)
* Add some new user tests to test salsa

* Use current latest, not "latest"

* Add other js user tests

* Add new baselines

* Fix new user tests' typeroot. Move github to octokit/rest
2018-03-09 15:59:46 -08:00
Sheetal Nandi
fa2b7ff6b3
Merge pull request #22421 from Microsoft/typesInTypeArguments
Allow types as well as values in possibly type argument location
2018-03-09 14:36:45 -08:00
Sheetal Nandi
ef64cde621
Merge pull request #22409 from Microsoft/symbolKind
Symbol kind needs to use location before falling back to flags
2018-03-09 13:59:38 -08:00
Mohamed Hegazy
c335c3803c
Fix #22133: Expose getOutliningSpans on the server protocol (#22400)
* Fix #22133: Expose getOutliningSpans on the server protocol

* Remove debugger statement from test
2018-03-09 08:50:47 -08:00
Andy
0f47c8a205
annotateWithTypeFromJSDoc: Do less special-casing for arrow functions (#22407)
* annotateWithTypeFromJSDoc: Do less special-casing for arrow functions

* Code review
2018-03-08 16:32:32 -08:00
Sheetal Nandi
e1a89e7011 Allow types as well as values in possibly type argument location
Fixes #22369
2018-03-08 16:06:26 -08:00
Andy
e48bcd60ba
Treat 'yield;' as 'yield undefined;' (#22297)
* Treat 'yield;' as 'yield undefined;'

* Use undefinedWideningType
2018-03-08 15:41:04 -08:00
Wesley Wigham
87d88e2ba3
Handle resolving and unknown symbols in getLiteralTypeFromPropertyName (#22406) 2018-03-08 13:35:55 -08:00
Sheetal Nandi
ea37c37e88 Symbol kind needs to use location before falling back to flags
Fixes #22366
2018-03-08 11:50:52 -08:00
Andy
a49e83ffa7
annotateWithTypeFromJSDoc: Use changes.insertTypeAnnotation instead of replaceNode (#22404) 2018-03-08 11:47:30 -08:00
Nathan Shively-Sanders
e4610e3418
Import types in JS with var x = require('./mod') (#22161) 2018-03-08 11:11:51 -08:00
Nathan Shively-Sanders
f8134d0b45 Merge branch 'master' into js-object-literal-assignments-as-declarations 2018-03-08 10:40:55 -08:00
Nathan Shively-Sanders
04ceb3d9bd Disallow JS/non-JS merge without crashing
Note that the error location is misleading because it's reported inside
the merge step for the js initializer.
2018-03-08 09:49:23 -08:00
Wesley Wigham
95862880fb
Filter symbol property names out of index signature assignability checks (#22398) 2018-03-08 09:30:25 -08:00
Wesley Wigham
45eaf42006
Use single replacer for string escaping (#22335) 2018-03-07 17:36:31 -08:00
Nathan Shively-Sanders
d86440f94f Merge branch 'master' into js-object-literal-assignments-as-declarations 2018-03-07 14:51:55 -08:00
Andy
1f7a5097fa
When every import is unused, error on the entire import declaration (#22386)
* When every import is unused, error on the entire import declaration

* Code review

* Store key in map value
2018-03-07 14:42:09 -08:00
Andy
e5804aefde
inferFromUsage: use ChangeTracker and typeToTypeNode (#22379)
* inferFromUsage: use ChangeTracker and typeToTypeNode

* Use typeToTypeNode with SymbolTracker

* Add comment
2018-03-07 14:40:50 -08:00
Sheetal Nandi
36b45e3f13
Merge pull request #22343 from Microsoft/codeFixActionNotUndefined
Create the action only if the text change creation is successful.
2018-03-06 12:31:04 -08:00
Mohamed Hegazy
b2dd610e92
Fix ignore message indentation (#22340)
* Update baselines for user tests

* Add explicit indentation

* Fix https://github.com/Microsoft/TypeScript/issues/21355: Format `// @ts-ignore` added by quick fix

* Extract check to a separate function

* Consolidate checking for valid insert location

* Code review comments

* Do not return makeChange
2018-03-06 12:19:19 -08:00
Sheetal Nandi
70944428a1 Create the action only if the text change creation is successful. …
Make change for the infer type from usage could return undefined even if type is present if the type cannot be named
Fixes #22184
2018-03-06 11:03:20 -08:00
Sheetal Nandi
6f6c40186f Add test for undefined action returned
Test for #22343
2018-03-06 11:00:41 -08:00
Andy
a138985448
isValidMethodAccess: Instantiate signature this type if necessary (#21722) 2018-03-06 10:18:06 -08:00
Andy
e5f91f5948
Convert annotateWithTypeFromJSDoc refactor to a codefix (#22336)
* Convert annotateWithTypeFromJSDoc refactor to a codefix

* Compute isJsFile once at top
2018-03-06 07:49:21 -08:00
Priyantha Lankapura
ed1c5d9688 update test for #20577 (#22310) 2018-03-05 16:15:08 -08:00
Wesley Wigham
2f0a13c7c3
Use global NonNullable type for nonnull types (#22096)
* Use NonNullable type for nonnull types

* Add noLib test

* Remove conditional type fallback for when lib is not present
2018-03-05 14:52:06 -08:00
Andy
4ddf045d6a
For <div a= >, after =, do not try to parse an expression (#21373) 2018-03-05 14:38:55 -08:00
Wesley Wigham
16bf02991d
Allow indexing generics with unique symbols (#22339)
* Allow indexing generics with unique symbols

* Move condition to assert
2018-03-05 13:58:19 -08:00
Wesley Wigham
53ae507545
Add inference priority for mapped type keys (#22246)
* Add inference priority for mapped type keys

The new priority causes union inference, similarly to return type

* Rename priority

* Fix comment typo
2018-03-05 13:19:00 -08:00
Andy
2ac2291b84
Convert use-default-import refactor to a codefix (#22334) 2018-03-05 12:43:01 -08:00
Anders Hejlsberg
07ed899b46 Merge branch 'master' into checkInferredConstraints 2018-03-05 06:32:11 -08:00
Anders Hejlsberg
70818ae716
Merge pull request #22313 from Microsoft/fixDistributiveConditionalTypes
Fix distributive conditional types
2018-03-05 06:23:45 -08:00
Anders Hejlsberg
19e07eaea6 Add tests 2018-03-04 16:49:06 -08:00
Anders Hejlsberg
081a394927 Add regression test 2018-03-03 18:08:36 -08:00
Sheetal Nandi
6e756b5907
Merge pull request #22308 from Microsoft/declarationEmitOfIndirectAlias
Fix incorrect error reported when using type from indirect module alias and current module is exported with "export default"
2018-03-02 19:10:36 -08:00
Wesley Wigham
1c93744a9c
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers

* Improved comments/sourcemaps for await, yield, while, and for

* Retain comments on block curly-braces

* Emit comments for if statements

* Improved switch case comment emit

* Improve comment and sourcemap emit for try/catch, throw, and continue statements

* Improve sourcemap emit and comments for with statements

* More accurate sourcemaps+comments emit for new, typeof, void, and delete

* Improve comment emit for element access expressions

* Preserve more comments on imports and exports

* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition

* Support preserving comments within empty lists

* Handle leading comments of tokens, conditionally indent leading comments

* Stop heuristically sourcemapping tokens

When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers

* Fix unneeded +1

* Tighten up element access comments

* Handle comments on parenthesized expression tokens

* Fix nit
2018-03-02 17:23:59 -08:00
Yuichi Nukiyama
25525bc9d6 Change esnext.promise to es2018.promise (#22292)
* change esnest.promise to es2018.promise

* modify unit tests

* resolve conflict

* resolve conflict
2018-03-02 17:08:36 -08:00
Sheetal Nandi
dc7ee381d5 Add tests when declaration emit for indirect alias usuage results in wrong error reporting
Test for #22257
2018-03-02 16:10:34 -08:00
Anders Hejlsberg
2d5be24669
Merge pull request #22300 from Microsoft/distributeKeyofIntersection
Distribute 'keyof' intersection types
2018-03-02 16:08:20 -08:00
Andy
87c3cca3f0
Make convertFunctionToEs6Class a codefix (#22241)
* Make convertFunctionToEs6Class a codefix

* Change diagnostic message
2018-03-02 12:57:29 -08:00
Wenlu Wang
b15157356a add spelling suggestion support for module import (#22283) 2018-03-02 10:24:55 -08:00
Andy
dd27288e5a
Don't rename static 'this' when renaming class (#22235) 2018-03-02 10:23:08 -08:00