Commit Graph
140 Commits
Author SHA1 Message Date
Florian Regensburger bd9f39dbcc Merge branch 'master' into add-codefix-cannot-find-name-in-for-loop 2019-07-02 00:41:27 +02:00
Andrew BranchandGitHub 11a62cb0ab Merge pull request #31801 from andrewbranch/semicolons
Detect semicolons before writing from TextChanges
2019-07-01 13:23:31 -07:00
Josh GoldbergandNathan Shively-Sanders ca00b3248b Added --noImplicitThis code fix for functions used as object properties (#31138)
* Added --noImplicitThis code fix for functions used as object properties

Before trying out all the various possibilities for where these functions could be used, I figured I'd start out with a relatively simple use case to verify this is the right approach. Is it? 😄

Starts on #28964.

* Fixed function expression names; included new baselines

* Got JSDocs to work, hooray!

* Added test for 'any' case of no function uses

* Refactored for inferFunctionReferencesFromUsage

* Fixed inference bug: undefined references cause parameters to default

* Removed dead code comments
2019-06-17 19:00:15 -07:00
Andrew Branch b37875ff7a Detect semicolons in file before writing quick fixes 2019-06-06 10:49:09 -07:00
rflorianandGitHub d4529e8355 Merge branch 'master' into add-codefix-cannot-find-name-in-for-loop 2019-05-09 00:22:01 +02:00
Gabriela Araujo Britto 970ec62364 remove unused LeadingTriviaOption and TrailingTriviaOption options 2019-02-26 10:02:57 -08:00
Gabriela Araujo Britto bf5123de6a don't export useNonAjustedPositions 2019-02-26 09:49:10 -08:00
Gabriela Araujo Britto e3a465ffa3 change startPosition and endPosition to leadingTriviaOption and trailingTriviaOption 2019-02-26 09:43:35 -08:00
Gabriela Araujo Britto 17b89653c2 include trailing trivia after expression in getAdjustedEndPosition if endPosition is include 2019-02-19 14:20:37 -08:00
Gabriela Araujo Britto eef3da5b6b create new ConfigurableStart and ConfigurableEnd options and rename them 2019-02-15 15:38:10 -08:00
rflorianandGitHub 8a048159ba Merge branch 'master' into add-codefix-cannot-find-name-in-for-loop 2019-01-17 00:07:43 +01:00
AndyandGitHub a6ef176dbb Consistently return 'void' from ChangeTracker methods (#28563) 2018-11-16 08:58:00 -08:00
Florian Regensburger 70fee3fb36 Review changes and adjustment of fourslash tests 2018-11-15 23:05:14 +01:00
Sheetal Nandi c60ff902f1 Include code fix after prologue
Fixes #15515
2018-11-09 16:02:16 -08:00
Ron Buckton 151dc074a8 Merge branch 'master' into sourceMapGenerator 2018-11-09 11:50:51 -08:00
AndyandGitHub 1c4590341f Avoid reformatting body of arrow function with single unused parameter (#28217) 2018-10-29 16:40:30 -07:00
Nathan Shively-SandersandGitHub 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
AndyandGitHub eadf44d073 Add generateTypesForModule to public API (#28069)
* Add generateTypesForModule to public API

* Avoid parameter initializer and update baselines
2018-10-23 16:10:26 -07:00
Wesley WighamandGitHub 76addd75d1 Add JSXText check into isValidLocationToAddComment (#27653)
* Add JSXText check into isValidLocationToAddComment

* Small simplification
2018-10-22 16:45:39 -07:00
Nathan Shively-SandersandGitHub 88d3c6fd5f inferFromUsage codefix now emits JSDoc in JS files (#27610)
* Now adding @type to variable declarations, at least

Probably everything else, but not as well.

* Improve @param output and add test

It's still bad, but at least it's not wrong.

* Add some js/inferFromUsage tests and fixes

Also, remove redundant is(Set|Get)Accessor functions.

* Fix @typedef refactor

* Emit JSDoc optional parameters

By surrounding the parameter name with brackets. It is super, super ugly
right now.

* Get rest of existing tests working

* Correct location of comments

* Handle @param blocks

1. Format multiple params nicely in a single-multiline block.
2. Generate only params that haven't already been documented. Existing
documentation is not touched.

* Re-add isGet/SetAccessor -- it is part of the API

* Move isSet/GetAccessor back to the original location

* Oh no I missed a newline and a space

* Switch to an object type

* A lot of cleanup

More to come, though. annotate is only called in
annotateVariableDeclaration where we don't know whether we're in JS or
not.

* Move and delegate to annotateJSDocParameters

* Address PR comments

* Lint: newline problems!!!!

* Switch another call to getNonformattedText

* Update baseline missed after merge
2018-10-09 10:38:46 -07:00
Ron Buckton 4982803a38 Merge branch 'master' into sourceMapGenerator 2018-10-08 18:01:37 -07:00
AndyandGitHub 16766b196c textChanges: Reuse some methods (#27492) 2018-10-02 17:34:17 -07:00
Benjamin LichtmanandAndy f356cd6c89 Insert async keyword as last modifier (#27491) 2018-10-01 17:43:17 -07:00
AndyandGitHub c57ff087d6 Add codefix to generate types for untyped module (#26588) 2018-09-18 11:47:29 -07:00
AndyandGitHub e710645bf9 Never escape string literals from textChanges (#26971)
* Never escape string literals from textChanges

* Use `boolean | undefined`
2018-09-17 11:06:39 -07:00
AndyandGitHub bcb815b3ac Remove duplicate function createTextRange (#23346)
* Remove duplicate function createTextRange

* Always allow end=-1

* Put noAssert back, pending #23370

* Use getRangeUnion helper

* Update API (#24966)
2018-09-05 11:19:56 -07:00
Ron Buckton 173b5dfcfb Refactor sourcemap emitter 2018-08-22 12:42:36 -07:00
AndyandGitHub 5efd1cb4a7 fixAddMissingMember: Support interface and don't crash on type parameter (#25995)
* fixAddMissingMember: Support interface and don't crash on type parameter

* Remove InfoBase
2018-08-09 17:32:28 -07:00
AndyandGitHub d40d54984e Support deleting all unused type parameters in a list, and deleting @template tag (#25748)
* Support deleting all unused type parameters in a list, and deleting @template tag

* Support type parameter in 'infer'
2018-07-27 11:55:31 -07:00
AndyandGitHub 0227997fa5 Use import().T for import completions/fixes of pure types in JS files (#25852)
* Use `import().T` for import completions/fixes of pure types in JS files

* Don't call tryUseExistingNamespaceImport if position undefined
2018-07-26 16:16:57 -07:00
AndyandGitHub f9764d17f0 fixUnusedIdentifier: Support deleting @template tag (#25597)
* fixUnusedIdentifier: Support deleting @template tag

* Just return createTextRangeFromNode instead of adjusting range
2018-07-12 11:26:17 -07:00
AndyandGitHub 064ecd449e Support code-fix-all for importFixes (#25137)
* Support code-fix-all for importFixes

* Change description

* Update API (#25283)
2018-07-03 15:19:15 -07:00
AndyandGitHub ded446573a ChangeTracker: Combine deleteDeclaration, deleteNode, and deleteNodeInList (#25276)
* ChangeTracker: Combine deleteDeclaration, deleteNode, and deleteNodeInList

* Change name

* Update API (#24966)
2018-06-29 19:53:32 -07:00
AndyandGitHub c9d44ce395 getTouchingToken: default includeJsDocComment to true (#25258) 2018-06-27 11:15:15 -07:00
AndyandGitHub d957b1c8c2 fixUnusedIdentifier: Remove arguments corresponding to unused parameters (#25011)
* fixUnusedIdentifier: Remove arguments corresponding to unused parameters

* Update API (#24966)

* Fix handling of deletions: Make a list of things to delete and don't delete until the end

* Remove dummy test

* Bug fixes

* Update API (#24966)

* Move code to textChanges
2018-06-27 09:26:47 -07:00
AndyandGitHub ab9e913af3 getEditsForFileRename: Test both before and after the rename (#25074) 2018-06-26 16:55:51 -07:00
AndyandGitHub 13bc46d970 getTokenAtPosition: default includeJsDocComment to true (#25015)
* getTokenAtPosition: default includeJsDocComment to true

* Update API (#24966)

* Flip meaning of parameter

* Update API (#24966)

* Remove all `ignoreJsDocComment` uses (fixes #25162)
2018-06-26 16:20:44 -07:00
AndyandGitHub 806a661be3 Add refactor to convert named to default export and back (#24878)
* Add refactor to convert named to default export and back

* Support ambient module

* Handle declaration kinds that can't be default-exported

* Update API (#24966)
2018-06-25 10:34:24 -07:00
AndyandGitHub 7a73c89c57 Convert getInsertNodeAfterOptionsWorker to switch statement (#25128) 2018-06-21 11:20:03 -07:00
AndyandGitHub fde6f22408 Fix bug: In newFileChanges, setParentNodes in new source file (#24765) 2018-06-07 14:28:06 -07:00
AndyandGitHub d671c7ae96 getEditsForFileRename: Support directory rename (#24305)
* getEditsForFileRename: Support directory rename

* Code review

* Handle imports inside the new file/directory

* Document path updaters

* Shorten relative paths where possible

* Reduce duplicate code

* Rewrite, use moduleSpecifiers.ts to get module specifiers from scratch instead of updating relative paths

* Update additional tsconfig.json fields

* Add test with '.js' extension

* Handle case-insensitive paths

* Better tsconfig handling

* Handle properties inside compilerOptions

* Use getOptionFromName
2018-06-01 08:23:37 -07:00
AndyandGitHub 2cb46407b1 moveToNewFile: Remove newlines after last moved statement (#24503) 2018-05-30 15:16:03 -07:00
AndyandGitHub 16af96b006 moveToNewFile: Format the new file (#24379) 2018-05-24 11:08:32 -07:00
AndyandGitHub e53e56cf82 Enable '--strictNullChecks' (#22088)
* Enable '--strictNullChecks'

* Fix API baselines

* Make sys.getEnvironmentVariable non-nullable

* make properties optional instead of using `| undefined` in thier type

* reportDiagnostics should be required

* Declare firstAccessor as non-nullable

* Make `some` a type guard

* Fix `getEnvironmentVariable` definition in tests

* Pretend transformFlags are always defined

* Fix one more use of sys.getEnvironmentVariable

* `requiredResponse` accepts undefined, remove assertions

* Mark optional properties as optional instead of using `| undefined`

* Mark optional properties as optional instead of using ` | undefined`

* Remove unnecessary null assertions

* Put the bang on the declaration instead of every use

* Make `createMapFromTemplate` require a parameter

* Mark `EmitResult.emittedFiles` and `EmitResult.sourceMaps` as optional

* Plumb through undefined in emitLsit and EmitExpressionList

* `ElementAccessExpression.argumentExpression` can not be `undefined`

* Add overloads for `writeTokenText`

* Make `shouldWriteSeparatingLineTerminator` argument non-nullable

* Make `synthesizedNodeStartsOnNewLine` argument required

* `PropertyAssignment.initializer` cannot be undefined

* Use one `!` at declaration site instead of on every use site

* Capture host in a constant and avoid null assertions

* Remove few more unused assertions

* Update baselines

* Use parameter defaults

* Update baselines

* Fix lint

* Make Symbol#valueDeclaration and Symbol#declarations non-optional to reduce assertions

* Make Node#symbol and Type#symbol non-optional to reduce assertions

* Make `flags` non-nullable to reduce assertions

* Convert some asserts to type guards

* Make `isNonLocalAlias` a type guard

* Add overload for `getSymbolOfNode` for `Declaration`

* Some more `getSymbolOfNode` changes

* Push undefined suppression into `typeToTypeNodeHelper`

* `NodeBuilderContext.tracker` is never `undefined`

* use `Debug.assertDefined`

* Remove unnecessary tag

* Mark `LiteralType.freshType` and `LiteralTupe.regularType` as required
2018-05-22 14:46:57 -07:00
AndyandGitHub 75ab60f199 Improve ChangeTracker#deleteNodeInList (#24221) 2018-05-17 14:31:58 -07:00
王文璐 0fde07f1c5 fix trailing comma in accessor generator 2018-05-16 14:47:44 +08:00
AndyandGitHub d4a3c9c61a Fix placement of indent for @ts-ignore comment (#24143) 2018-05-15 16:21:15 -07:00
AndyandGitHub cbbe34b35e Fix conversion of TextChanges to FileCodeEdits for new file (#24126) 2018-05-15 13:55:26 -07:00
AndyandGitHub 7271ec1240 Add 'move to new file' refactor (#23726)
* Add 'move to new file' refactor

* Code review, and support commonjs

* Compute movedSymbols completely before using, and support `export import`

* Fix assertion error: sort empty change before non-empty change

* Remove extra newline

* Add allowTextChangesInNewFiles preference

* Add the new file to 'files' in tsconfig

* Avoid parameter initializer

* Update API baselines

* Use path relative to tsconfig.json

* Code review

* Fix error where node in tsconfig file was missing a source file
2018-05-10 11:17:04 -07:00
AndyandGitHub 004a558125 Avoid unnecessary newline when inserting node at start of class (#23935) 2018-05-07 12:40:33 -07:00