2530 Commits

Author SHA1 Message Date
Kevin Donnelly
4fa96056ea Make T[never] = never instead of erroring or being any (#22787)
* Add tests showing existing behavior for indexing types with never.

* Make T[never] = never instead of erroring or being any.

And update the baselines for the tests for this change.

* Add test case for indexing an expression with never showing existing behavior.

* Make indexing an object with never expression result in never.

And update baseline to reflect new behavior.
2018-03-27 07:45:25 -07:00
Wesley Wigham
dcbc478efa
Tighten heuristic for definite dts moduleness to check for syntactic default (#22814)
* Tighten heuristic for definite dts moduleness to check for syntactic default exports

* Inline function
2018-03-26 16:35:03 -07:00
Mohamed Hegazy
faa3fca247
Merge pull request #22886 from Microsoft/Fix22866
Fix #22866: Condition checking for name collision of generated variable names on emit happening
2018-03-26 14:24:59 -07:00
Mohamed Hegazy
7fd602e594 Fix #22866: Condition checking for name collision of generated variable names on emit happening 2018-03-26 13:02:09 -07:00
Wesley Wigham
6af764c560
Declaration maps and transparent goto definition using them (#22658)
* Add compiler option to enable declaration sourcemaps

* Transparent goto definition for sourcemapped declaration files

* Post-rebase touchups

* Rename API methods

* Fix lints

* Fix typo in name XD

* Log sourcemap decode errors

* Share the cache more, but also invalidate it more

* Remove todo

* Enable mapping on go to implementation as well

* Allow fourslash to test declaration maps mroe easily

* more test

* Handle sourceRoot

* Add tests documenting current behavior with other sourcemapping flags

* Ignore inline options for declaration file maps, simplify dispatch in emitter

* Change program diagnostic

* Fix nit

* Use charCodeAt

* Rename internal methods + veriables

* Avoid filter

* span -> position

* Use character codes

* Dont parse our sourcemap names until we need to start using them

* zero-index parsed positions

* Handle sourceMappingURL comments, including base64 encoded ones

* Unittest b64 decoder, make mroe robust to handle unicode properly

* Fix lint

* declarationMaps -> declarationMap

* Even more feedback

* USE Mroe lenient combined regexp

* only match base64 characters

* Fix nit
2018-03-26 12:15:34 -07:00
Anders Hejlsberg
c2a53f90de Add regression tests 2018-03-23 17:41:55 -07:00
Anders Hejlsberg
1c2f3d228c Add regression test 2018-03-23 09:48:00 -07:00
Wesley Wigham
ca1d19a579
Always make a new jsxAttributes type, dont reuse emptyObjectType (#22810)
* Always make a new jsxAttributes type, dont reuse emptyObjectType

* Break up conditional a bit
2018-03-22 15:16:33 -07:00
Wesley Wigham
a7b066fe04
Allow local class declarations to be returned as mixins (#22807) 2018-03-22 15:02:54 -07:00
Andy
94570eedcc
Don't provide spelling suggestion for module (#22805) 2018-03-22 14:27:34 -07:00
Nathan Shively-Sanders
de4a69cb72
In source files and blocks, bind function declarations before other statements (#22766)
* Add test case and temporarily disable inference

(Inference of class members from this-assignments inside a
prototype-assigned function.)

* Update baselines

* In blocks and source files, bind functions first

* Add tests from other bugs

* Remove temporary failsafe

* Update tests to restore intent and clean up errors

* Restore intent even better

* Restore intent even better x2

* Add missed baselines
2018-03-21 14:22:09 -07:00
Nathan Shively-Sanders
c930895d80
Undo 'any' inference propagation (#22736)
* Undo 'any' inference propagation

Removing this only changes one test slightly, and fixes JQuery types,
which rely on the old method of inference.

* Add jquery regression test and update baselines

* Restore any inference propagation to wildcard only
2018-03-21 11:13:39 -07:00
Anders Hejlsberg
979bda484c Add regression test 2018-03-17 12:23:45 -07:00
Wesley Wigham
2d01d76ee5
Change es2015 transform to retain comments on for of loop bodies (#22396) 2018-03-16 12:57:38 -07: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
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
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
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
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
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
Wesley Wigham
b8e0009c9b
Set syntheticLiteralTypeOrigin on synthetic undefined-type members (#22216)
* Have getNameOfSymbolAsWritten quote nonidentifier nonnumeric symbols all the time

* Revert checker changes

* Reuse synthetic origin to indicate that derived declaration name may need to be quoted
2018-02-28 16:03:05 -08:00
Wesley Wigham
62185673fd
Emit unqiue symbols with typeof if possible before issuing an error (#21403) 2018-02-28 15:44:12 -08:00
Wesley Wigham
7a31192ecb
Stop binding type predicate types twice (#22210) 2018-02-28 15:43:13 -08:00
Wesley Wigham
c1128d6957
Fix declaration emitted crash on mapped type with no type (#22213) 2018-02-27 16:12:03 -08:00
Wesley Wigham
0dc5f18bdb
Remove excess comment ranges from initialized and property parameter emit (#22152) 2018-02-26 12:43:31 -08:00
Alex Eagle
2e66e74e14 fix --pretty output when context is multi-line
Fixes #22097
2018-02-22 22:56:00 -08:00
Wesley Wigham
66fa9f6cd7
Just map type variables to constraints at certain positions for narrowing so that we do not map primitives (#21384)
* Use a limited version of getApparentType that doesnt map primitives

* Reuse [most of]  getBaseConstraintOfType, since it does the needed behaviors

* Move new function next to the very similar function
2018-02-21 12:51:26 -08:00
Andy
9ee51fadd9
Have Symbol#isReferenced check the SymbolFlags of the reference (#21996) 2018-02-16 16:47:13 -08:00
Andy
a133cec246
Fix bug: Interface type parameter merged with property is not unused (#21966) 2018-02-15 09:30:58 -08:00
Andy
2ee92948d8
Support @param tag on property declaration initializer (#21907)
* Support @param tag on property declaration initializer

* Update test

* Finish updating test
2018-02-14 10:12:38 -08:00
Adrian Leonhard
6ab5d97a5d Changed "Duplicate Identifier" to "enum cannot be merged..." (#18579)
* Changed "Duplicate Identifier" to "enum can only be merged..."
when either declaration of the identifier is an enum.

Partial (?) fix for #529

Not sure if the new test is necessary, all the cases seem to have been covered by others tests.

* picked a nit
2018-02-12 13:38:08 -08:00
Andy
2d80253d09
Fix error message for implicit-any property in object literal with symbol key (#21883) 2018-02-12 11:09:50 -08:00
jack-williams
67984c720e Fix #21848: Allows to mutate const with non-null assertion (#21873) 2018-02-12 10:57:59 -08:00
Mohamed Hegazy
3fb481ff40
Multiple telemetry debug assert failure fixes (#21886)
* Use getAllowSyntheticDefaultImports to access `--allowSyntheticDefaultImport` value

* Fix #21788: Handel missing imporotClause case

* Fix #21789: Add a defensive check to forgottenThisPropertyAccess code fix for non-identifier locations

* Do not suggest prefix with `this` if the name we are looking for is diffrent from the errorLocation

* Fix #21796: Handel case of unknown module

* Add check to capture more info for #21800

* Fix #21807: check for symbol before looking up its flags

* Fix #21812: Gracefully fail if the token is not `this`.
2018-02-12 10:34:17 -08:00
Alan Agius
3893ed498f fix: matchedText module resolution incorrect length (#21647)
* fix: `matchedText` was not properly extract the correct parts from the candidate

closes: #21636

* core: replace `substr` with `substring` in `matchedText`

* test: remove redundant code from tests
2018-02-07 12:54:37 -08:00
Wesley Wigham
17554ff285
Fix JSX contextual types to not eagerly become apparent, use 2-pass inference for JSX (#21383)
* Fix JSX contextual types to not eagerly become apparent

* Apply changes from code review, unify common code

* Fix jsx children contextual typing

* Light code review feedback

* Use fillMissingTypeArguments

* Accept nonliteral jsx child type

* Add test for the fillMissingTypeArguments case
2018-02-05 16:33:39 -08:00
Anders Hejlsberg
3b220a8b0f
Merge pull request #21649 from Microsoft/conditionalTypesASI
Conditional types ASI
2018-02-05 16:21:34 -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
6cf640ed3b Add regression test 2018-02-05 13:56:22 -08:00
Anders Hejlsberg
21c397dd5a Add regression test 2018-02-03 14:45:16 -08:00
Wesley Wigham
89de4c9a3a
Only apply global augmentations before globals are available (#21563)
* Only apply global augmentations before globals are available

* Add detailed comment explaining the split of global/nonglobal augmentations

* Remove trailing whitespace
2018-02-02 18:44:54 -08:00
Nathan Shively-Sanders
be0fcd5174
Array.concat now takes ConcatArray, not ReadonlyArray (#21462)
* Overloads in Array.concat now handle ReadonlyArray

Previously it was union types, which is slower.

* Make arrayConcat3 test stricter

* Switch to InputArray instead of adding overloads

* Update baselines

* Update baselines correctly

* Rename to ConcatArray and add slice method

Should make it, respectively, easier to understand this specific type
and harder to satisfy it by mistake.
2018-02-02 13:20:40 -08:00
Wesley Wigham
2c3b69336f
Collect import helper needs during module info gathering (#21567)
* Collect import helper needs during module info gathering

* Add tests for other forms that trigger import helpers
2018-02-02 13:17:39 -08:00
Wesley Wigham
b3ec8cce00
Leverage existing function for choosing spread validity (#21564) 2018-02-02 10:11:50 -08:00