Commit graph

1573 commits

Author SHA1 Message Date
Andy b3edc8f9f4
Apply 'no-unnecessary-type-assertion' lint rule (#22005)
* Apply 'no-unnecessary-type-assertion' lint rule

* Fix type error

* Fix tsconfig.json

* Add --format back
2018-02-16 18:38:00 -08:00
Anders Hejlsberg a629acd8fd Allow +/- to prefix 'readonly' and '?' modifiers in mapped types 2018-02-12 16:20:49 -08:00
Mohamed Hegazy 8f8fec433e
Rename switch --emitDeclarationsOnly to --emitDeclarationOnly (#21651)
* Rename `--emitDeclarationsOnly` to `--renameDeclarationOnly`

* Rename test files
2018-02-05 14:48:50 -08:00
Anders Hejlsberg 4ae8445ff7 Properly classify output text in emitter 2018-02-03 11:32:24 -08:00
Anders Hejlsberg 7c241ba2f7 Merge branch 'conditionalTypes' into inferTypes
# Conflicts:
#	src/compiler/checker.ts
#	tests/cases/fourslash/completionInJSDocFunctionNew.ts
#	tests/cases/fourslash/completionInJSDocFunctionThis.ts
2018-01-30 13:40:16 -08:00
Anders Hejlsberg 4f2b5f32f9 Merge branch 'master' into conditionalTypes 2018-01-30 06:42:14 -08:00
Manoj Patel afc588eb9e --emitDeclarationsOnly flag to enable declarations only output (#20735)
* Add emitOnlyDeclarations flag

* Fix name

* verifyOptions checking logic

* Passing tests

* doJsEmitBaseline

* Tests !!!
2018-01-25 15:35:18 -08:00
Anders Hejlsberg d608941480 Implement type inference in conditional types 2018-01-25 12:25:00 -08:00
Andy 9436b1cc0b
Fix formatter crash for const { ...a: b } = {};: forEachChild and emitBindingElement should handle ... before the propertyName (#21268) 2018-01-18 10:36:41 -08:00
Anders Hejlsberg 4ec6fdd96f Merge branch 'master' into conditionalTypes
# Conflicts:
#	src/compiler/checker.ts
#	src/compiler/types.ts
#	tests/baselines/reference/api/tsserverlibrary.d.ts
#	tests/baselines/reference/api/typescript.d.ts
2018-01-17 13:12:36 -08:00
Ron Buckton 1785d87fda Fix temp variable emit for names used in nested classes 2018-01-16 12:33:55 -08:00
Wesley Wigham 76d9524866
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter

* Unification of writers is done-ish

* Make node builder support more flags

* Write out mixins like we used to

* Accept prototype-free baselines

* Use instantiated constraint when building mapped type nodes

* Accept better mapped type baselines

* Report inaccessible this in node builder

* Turns out there was a bug in our codefix, too

* Symbol display builder usage falling

* Replace signatureToString with a nodeBuilder solution

* Replace the last internal usages of the symbol writer

* Accept semicolon additions

* Accept updated symbol baseline output

* Start using node builder for some LS operations

* Remove those pesky trailing semicolons on signatures

* Get signature printing much closer to old output

* Parameter lists should not be indented by default, especially when single-line

* Signatures up to snuff

* Type quickinfo emit is up to snuff

* Start of symbol writer replacement, needs a bit more for full compat

* Slightly mor accurate to old behavior

* Replicate qualified name type argument output correctly

* Bring back the old symbol baselines

* Mostly identical to old symbol emit now

* Perfectly matches old behavior thus far

* Replace another usage of the symbol builder

* Another usage removed

* Another usage removed

* Remove final uses of symbol display builder

* Remove implementation and types for unused symbol display builder

* Cleanup in the checker

* monomorphize new emitter code

* Replace emitWithSuffix

* Push space character to interface with writer

* List emit

* Fix lack of usage of emitExpression

* writeList, not printList

* Remove listy writes and replace with new printer calls

* Move ListFormat into types.ts

* Remove most new XToString functions in favor of node builder functions

* Accept API breaks

* Add getSymbolDisplayBuilder polyfill

* Accept updated API baseline

* Move definition to make diff easier to read

* Reinternalize some things

* Remove trailign whitespace

* Reorder for zero diff

* Remove newline

* Make shim mor eperfectly imitate old behavior

* Style feedback

* Rename reset to clear to maintain backcompat with SymbolWriter

* Fix quickfix

* Keep EmitTextWriter internal

* Remove EmitTextWriter from public API

* Mimic default name declaration emit fix

* Fix tests broken by merge

* use isFunctionLike

* Cleanup, sync TypeFormat and NodeBuilder flags

* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism

* Use variable instead of ternary

* Write helper for emitNodeWithWriter

* Emitter cleanup

* Cleanup whitespace, comment

* Reuse printer

* Raise error if display parts writer uses rawWrite

* Hide writer parameter through different function instead of overload, rename function in emitter

* Make less printer

* fix lint
2018-01-16 09:53:42 -08:00
Anders Hejlsberg 5094f7677c Remove 'T extends U' type constructor 2018-01-15 08:11:05 -08:00
Anders Hejlsberg 53b1572ed6 Revert to extends check being part of conditional type 2018-01-15 07:59:46 -08:00
Sheetal Nandi 69bb5ea8f0 Do not trigger the failed lookup location invalidation for creation of program emit files
Handles #20934
2018-01-11 12:34:58 -08:00
Andy 8bce69e6bd
Add refactoring to convert CommonJS module to ES6 module (#19916)
* Add refactoring to convert CommonJS module to ES6 module

* Code review

* includeGlobals -> excludeGlobals

* Improve handling of `module.exports = require("...")`

* Allow NoSubstitutionTemplateLiteral as argument to createLiteral
2018-01-09 13:15:47 -08:00
Anders Hejlsberg ec2bdfdb8b Add 'T extends U' type operator 2017-12-12 09:52:14 -08:00
Anders Hejlsberg 57ca7680c9 Initial implementation of conditional type operator 2017-12-05 14:18:11 -08:00
Wesley Wigham 4f48bf80fe
Revised emit for computed property names, including with decorators (#19430)
* Revised emit for computed property names

* Fix downlevel name generation scopes

* Accept slightly more conservative baseline

* First feedback pass

* Reduce number of nonrequired variable declarations and assignments

* Remove side-effect-free identifier references

* skip partially emitted expressions

* Comments, move starsOnNewLine to emitNode

* Put expressions on newlines when inlined in class expressions for consistency

* Update new ref

* Fix typo in comment
2017-11-06 12:51:34 -08:00
Andy d998e97d8c
Apply 'prefer-for-of' tslint rule (#19721) 2017-11-03 15:20:35 -07:00
uniqueiniquity fb058868de Respond to CR 2017-10-24 13:24:11 -07:00
uniqueiniquity abb3f58db2 Add support for JSX fragment syntax 2017-10-17 09:38:09 -07:00
Nathan Shively-Sanders d7424b00b2 Merge branch 'master' into refactor-jsdoc-types-to-typescript 2017-10-11 13:41:45 -07:00
Sheetal Nandi e30a66d22f Add utitlity for stringContains 2017-10-10 17:16:39 -07:00
Daniel Rosenwasser 924460406e Merge pull request #18811 from Microsoft/uncalledDecorator
Give a more helpful error message for certain decorators with too many arguments
2017-10-05 11:27:46 -07:00
Nathan Shively-Sanders 6831e65235 Merge branch 'master' into refactor-jsdoc-types-to-typescript 2017-10-02 16:24:00 -07:00
Daniel Rosenwasser 86315ed411 Added test and adjusted reporting logic. 2017-09-29 22:01:00 -07:00
Andy 683d6c7ddd Add helper functions for using unescapeLeadingUnderscores (#18793)
* Add helper functions for using `unescapeLeadingUnderscores`

* More cleanup
2017-09-29 09:57:31 -07:00
Nathan Shively-Sanders d797b4ab76 Correctly transform jsdoc parameter types
And give a better name for rest params
2017-09-28 11:40:56 -07:00
Nathan Shively-Sanders fc933d7c33 Transform jsdoc types in the refactor, not emitter
The emitter now understands JSDoc types but emits them in the original
format.
2017-09-26 12:42:08 -07:00
Nathan Shively-Sanders 6d218e2a48 Refactor JSDoc types to Typescript types
When the caret is on a Typescript declaration that has no type, but does
have a JSDoc annotation with a type, this refactor will add the
Typescript equivalent of the JSDoc type.

Notes:

1. This doesn't delete the JSDoc comment or delete parts of it. In fact,
due to bugs in trivia handling, it sometimes duplicates the comment.
These bugs are tracked in #18626.

2. As a bonus, when `noImplicitAny: true`, this shows up as a code fix in VS Code
whenever there is a no-implicit-any error. With `noImplicityAny: false`,
this code must be invoked via the refactoring command.
2017-09-25 08:56:51 -07:00
Daniel Rosenwasser ffa1ea72c1 Just always print out modifiers for global augmentations.
Apparently, they don't always need them!
2017-09-22 00:12:37 -07:00
Daniel Rosenwasser 979295b21b Force 'declare' modifiers and correct global augmentation emit. 2017-09-21 12:20:14 -07:00
Andy 79e12eb48b Ensure that emitter calls callbacks for empty blocks (#18547) 2017-09-18 10:05:44 -07:00
Andy 0747b33038 Fixes to emit / format for codeFix (#18484) 2017-09-14 14:30:50 -07:00
Andy 4ee7d3aeb2 Remove unnecessary check in emitNodeList (#18327) 2017-09-08 07:18:37 -07:00
Andy ed4e2e6e3b Ensure that emitter calls callbacks (#18284)
* Ensure that emitter calls calbacks

* Move new parameter to end of parameters

* Fix for ConditionalExpression

* Make suggested changes to emitter

* Fix parameter ordering

* Respond to minor comments

* Remove potentially expensive assertion

* More emitter cleanup
2017-09-07 14:30:19 -07:00
Wesley Wigham 72884b8f27 Emit comments on system export default expressions on the surrounding export call epxression instead (#17970) 2017-09-06 21:59:06 -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
Wesley Wigham a6f37f55e4 Add a leading space on binary operator token trailing comments (#17691)
* Add a leading space on token trailing comments

* Demystify comment
2017-08-09 14:27:37 -07:00
Wesley Wigham c399230767 Retain comments inside return statements (#17557)
* Retain comments inside return statements by including the return keyword in the parse tree

* Revert "Retain comments inside return statements by including the return keyword in the parse tree"

This reverts commit 5d2142edb1.

* Readd test

* Function for handling printing comments on a token
2017-08-08 19:53:53 -07:00
Ron Buckton 75c8ecb2f1 Merge pull request #17517 from tinganho/IgnoredCatchParameter
Ignored catch parameter
2017-08-08 16:15:18 -07:00
Yui d7fff8ebe9 [Master] fix 12985 emit leading and trailing comment around binary operator (#16584)
* Emit leading and trailing on binary operator

* Add tests and baselines

* Update baselines
2017-08-04 19:12:13 -07:00
Tingan Ho d5c24f3cd3 Addresses CR comment 2017-08-02 20:13:43 +02:00
Tingan Ho b917eb0225 Adds optional catch parameter into the compiler 2017-07-30 23:26:47 +02: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 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 17578e8a5d Use Map<true> for sets (#16972) 2017-07-07 10:34:36 -07:00
Wesley Wigham 4e6b2f3c93 Created a branded type for identifier-escaped strings (#16915)
* Created a branded type for escaped strings

Then flowed it throughout the compiler, finding and fixing a handful of
bugs relating to underscore-prefixed identifiers in the process.
Includes a test for two cases noticed - diagnostics from conflicting
symbols from export *'s, and enum with underscore prefixed member emit.

* Correctly double underscores WRT mapped types

* Add fourslash tests for other fixed issues

* use function call over cast

* Update forEachEntry type accuracy

* Just use escaped names for ActiveLabel

* Remove casts from getPropertyNameForPropertyNameNode

* This pattern has occurred a few times, could use a helper function.

* Remove duplicated helper

* Remove unneeded check, use helper

* Identifiers list is no longer escaped strings

* Extract repeated string-getting code into helper

* Rename type and associated functions

* Make getName() return UnderscoreEscapedString, add getUnescapedName()

* Add list of internal symbol names to escaped string type to cut back on casting

* Remove outdated comments

* Reassign interned values to nodes, just in case

* Swap to string enum

* Add deprecated aliases to escapeIdentifier and unescapeIdentifier

* Add temp var

* Remove unsafe casts

* Rename escaped string type as per @sandersn's suggestion, fix string enum usages

* Reorganize double underscore tests

* Remove jfreeman from TODO

* Remove unneeded parenthesis
2017-07-06 14:45:50 -07:00
Sheetal Nandi 09f0b3471a Merge branch 'master' into ownJsonParsing 2017-06-15 09:59:37 -07:00