Commit Graph

113 Commits

Author SHA1 Message Date
Andy
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
Andy
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
Andy
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
Andy
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
Andy
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
Andy
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
Andy
c9d44ce395 getTouchingToken: default includeJsDocComment to true (#25258) 2018-06-27 11:15:15 -07:00
Andy
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
Andy
ab9e913af3 getEditsForFileRename: Test both before and after the rename (#25074) 2018-06-26 16:55:51 -07:00
Andy
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
Andy
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
Andy
7a73c89c57 Convert getInsertNodeAfterOptionsWorker to switch statement (#25128) 2018-06-21 11:20:03 -07:00
Andy
fde6f22408 Fix bug: In newFileChanges, setParentNodes in new source file (#24765) 2018-06-07 14:28:06 -07:00
Andy
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
Andy
2cb46407b1 moveToNewFile: Remove newlines after last moved statement (#24503) 2018-05-30 15:16:03 -07:00
Andy
16af96b006 moveToNewFile: Format the new file (#24379) 2018-05-24 11:08:32 -07:00
Andy
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
Andy
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
Andy
d4a3c9c61a Fix placement of indent for @ts-ignore comment (#24143) 2018-05-15 16:21:15 -07:00
Andy
cbbe34b35e Fix conversion of TextChanges to FileCodeEdits for new file (#24126) 2018-05-15 13:55:26 -07:00
Andy
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
Andy
004a558125 Avoid unnecessary newline when inserting node at start of class (#23935) 2018-05-07 12:40:33 -07:00
Andy
bad3a44bb2 In insertNodeAfter, handle file with no trailing newline (#23814) 2018-05-03 12:58:42 -07:00
Andy
aa102435b3 Fix insertNodeAtClassStart for empty class with comment (#23342) 2018-04-26 08:00:38 -07:00
Andy
5c94bef0e1 Add 'renameFile' command to services (#23573)
* Add 'renameFile' command to services

* renameFile -> getEditsForFileRename

* Support `<reference path>` directives
2018-04-20 13:43:09 -07:00
Andy
aac9ef5e51 convertToEs6Module: Avoid replacing entire function (#22507)
* convertToEs6Module: Avoid replacing entire function

* Code review

* Fix typo
2018-04-16 13:16:04 -07:00
Wenlu Wang
9c0671d661 add refactor of convert private field to getter and setter (#22143)
* add refactor of convert private field to getter and setter

* fix refactor

* stash

* refactor accessor generate

* revert merge union type

* refeactor and accept baseline

* add support of PropertyAssignment and StringLiteral

* add support for js file

* allow static modifier in js file
2018-04-10 11:51:41 -07:00
Andy
ce5d22fef0 Fix bug: don't insert a semicolon when inserting a FunctionDeclaration (#23240) 2018-04-09 15:03:24 -07:00
Andy
ea65f21677 textChanges: Don't crash when inserting type annotation on function with no parens (#23034) 2018-04-02 08:41:22 -07:00
Arthur Ozga
95a69cbeb4 Merge branch 'master' into dev/aozgaa/cSharpObjLiteralFormatting 2018-03-29 16:10:33 -07:00
Arthur Ozga
5fb5ff7bf3 add option for object literal indent 2018-03-29 15:40:23 -07:00
Andy
2bd66b3292 textChanges: Add insertCommentBeforeLine method (#22902) 2018-03-27 11:50:48 -07:00
Andy
e9e1d0d70b textChanges: Use InsertNodeOptions instead of ChangeNodeOptions where possible (#22903) 2018-03-27 11:50:34 -07:00
Andy
85f11cc5e4 textChanges: Use replaceRange in more places (#22904) 2018-03-27 10:57:42 -07:00
Andy
ea6740fa91 replaceNode: Always use non-adjusted end (#22519)
* replaceNode: Always use non-adjusted end

* Never adjust start position either

* Fix excess property checks, remove unnecessary arguments

* Make 'insertText' and 'newLineCharacter' private

* Use replaceNode in one more place now that it doesn't affect comments

* Update replaceNodeRange too

* Always ask for ChangeNodeOptions
2018-03-27 10:34:16 -07:00
Andy
a9d65b8b00 textChanges: Clean up *Options interfaces (#22813) 2018-03-26 15:34:58 -07:00
Andy
f2f2393f4b convertFunctionToEs6Class: Copy comments from constructor to class (#22738) 2018-03-22 08:12:02 -07:00
Andy
effcf2ac56 Fix test for overlapping changes (#22741) 2018-03-22 08:11:27 -07:00
Andy
3a3f57acfd Remove unnecessary exports (#22739) 2018-03-22 08:10:52 -07:00
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
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
Andy
a49e83ffa7 annotateWithTypeFromJSDoc: Use changes.insertTypeAnnotation instead of replaceNode (#22404) 2018-03-08 11:47:30 -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
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
Andy
ba8879d005 Prefer 'return Debug.fail()' over 'throw Debug.fail()' (#22092) 2018-03-02 10:44:06 -08:00
Andy
a564912d9a Apply 'no-unnecessary-qualifier' lint rule (#22009) 2018-03-01 14:20:18 -08:00
Andy
f4af74aae1 Simplify TextChanges#getChanges (#22157)
* Simplify TextChanges#getChanges

* Rename function and improve assert
2018-02-27 12:26:05 -08:00
Andy
f8f4bb8fdd textChanges: Clean up handling of newLineCharacter (#21970) 2018-02-15 13:02:56 -08:00