Commit graph

29144 commits

Author SHA1 Message Date
Wesley Wigham 9a7fdade07
Fix crash in contextual typing of defaulted element access declarations (#33686) 2019-09-30 14:42:55 -07:00
Wesley Wigham 98cf317005
Add error message for set accessor vsibility issues (#33683) 2019-09-30 13:12:40 -07:00
Andrew Branch f89de95955
Allow special element access assignments to create declarations (#33537)
* Start enabling element access special assignment

* Treat element access assignment as special assignment in JS

* Make declarations for bindable element access expressions

* Fix navigationBar crash

* Add multi-level test for JS

* Propagate element access expressions to more code paths

* Fix property access on `this`

* Add quick info test

* Uhhh I guess this is fine

* Fix module["exports"] and property access chained off element access

* Add test for this property assignment

* Add test for and fix prototype property assignment

* Fix teeeest???

* Update APIs

* Fix element access declarations on `this`

* Fix go-to-definition

* Add declaration emit to tests

* Reconcile with late-bound symbol element access assignment

* Fix baselines

* Add JS declaration back to tests

* Fix JS declaration emit of non-late-bound string literal property names

* Revert accidental auto-format

* Use `isAccessExpression`

* Add underscore escaping member to test

* Fix and test navBar changes
2019-09-30 15:08:44 -05:00
Orta 053388d6d2
Merge pull request #33584 from orta/small_ts
Creates a smaller build of TypeScript which just has the language services
2019-09-30 15:52:57 -04:00
Ron Buckton fcd9334f57
Add support for Optional Chaining (#33294)
* Add support for Optional Chaining

* Add grammar error for invalid tagged template, more tests

* Prototype

* PR feedback

* Add errors for invalid assignments and a trailing '?.'

* Add additional signature help test, fix lint warnings

* Fix to insert text for completions

* Add initial control-flow analysis for optional chains

* PR Feedback and more tests

* Update to control flow

* Remove mangled smart quotes in comments

* Fix lint, PR feedback

* Updates to control flow

* Switch to FlowCondition for CFA of optional chains

* Fix ?. insertion for completions on type variables

* Accept API baseline change

* Clean up types

* improve control-flow debug output

* Revert Debug.formatControlFlowGraph helper
2019-09-30 12:33:28 -07:00
Anders Hejlsberg 7ce793c5b8
Merge pull request #33678 from microsoft/fix33617
Property handle recursive type references in type inference
2019-09-30 11:15:27 -07:00
Wesley Wigham 7f3c03d441
Implement declaration emit for accessors in the js declaration emitter (#33649)
* Implement declaration emit for accessors in the js declaration emitter

* Use `or`
2019-09-30 11:09:35 -07:00
Anders Hejlsberg ff5d38a94b
Merge pull request #33622 from microsoft/fix33580
Error when assertion function calls aren't CFA'd
2019-09-30 10:57:26 -07:00
Sheetal Nandi 1a614a27d1 Fix issue when types installed after watch/editor is opened for auto type reference that is for global types not being detected
Fixes #32285
2019-09-30 09:58:33 -07:00
Anders Hejlsberg 2a4d267af8 Accept new baselines 2019-09-30 09:28:26 -07:00
Anders Hejlsberg 46bddedb4b Add regression tests 2019-09-30 09:28:19 -07:00
Anders Hejlsberg ed497c4149 Properly handle recursive type references in type inference 2019-09-30 08:54:02 -07:00
Orta Therox 4c4a683d03 Merge branch 'small_ts' of https://github.com/orta/TypeScript into small_ts 2019-09-30 08:41:56 -04:00
Orta Therox c64af5e505 Remove the post-publish script 2019-09-30 08:29:16 -04:00
Anders Hejlsberg e5af71e3cd Accept new baselines 2019-09-27 15:23:57 -07:00
Anders Hejlsberg 34f6e681c4 Update tests 2019-09-27 15:23:49 -07:00
Anders Hejlsberg 56e0c6b16e Accept new baselines 2019-09-27 15:20:03 -07:00
Anders Hejlsberg 02395a9b27 Fix error message 2019-09-27 15:17:49 -07:00
Sheetal Nandi 20e2be1e1a
Merge pull request #33642 from microsoft/undoListFiles
Undo showing redirected files in --listFiles
2019-09-27 15:10:24 -07:00
Anders Hejlsberg 4648d6aeb2 Revise error messages + related spans + no errors on never-returning functions 2019-09-27 15:05:13 -07:00
Max Heiber c80d565bc5 Enable forceConsistentCasingInFileNames by default in newly generated configs (#39) (#33614)
*Issue number of the reported bug or feature request: #17542*

**Describe your changes**
Enabled `forceConsistentCasingInFileNames` in newly generated `tsconfig.json`s created by `tsc --init`.

**Testing performed**
The configuration option changed in the related tests.

**Additional context**
n/a


Signed-off-by: Prakash Lalwani <plalwani4@bloomberg.net>
2019-09-27 14:42:30 -07:00
Sheetal Nandi b0ea83b719 Add test when file is part of non default configured project before the default one 2019-09-27 14:36:54 -07:00
Sheetal Nandi c1751dc168 More refactor 2019-09-27 14:36:54 -07:00
Sheetal Nandi f3a6ea6abe Refactor 2019-09-27 14:36:54 -07:00
Sheetal Nandi 49a52d02d3
Merge pull request #33636 from microsoft/rootReferenceRedirect
Fix the issue when file is attached to project because its a root file name but program contains instead its d.ts
2019-09-27 14:36:08 -07:00
TypeScript Bot c283809062 Update user baselines (#33635) 2019-09-27 14:33:05 -07:00
Sheetal Nandi f713668abe Undo showing redirected files in --listFiles 2019-09-27 14:26:38 -07:00
Wesley Wigham 293816875c
Support some late-bound special property assignments (#33220)
* Support some late-bound special property assignments

* Integrate PR feedback

* PR feedback

* Enable declaration on core tests

* Specialize type of binary expression used for late binding, speculative fix to navigation bar, merge check and type for elem/property accesses

* Add test showing current nav bar behavior (specifically the lack thereof)
2019-09-27 13:54:50 -07:00
Andrew Branch 304fcee09b
Updated: Only auto-import from package.json (#32517)
* Move package.json related utils to utilities

* Add failing test

* Make first test pass

* Don’t filter when there’s no package.json, fix scoped package imports

* Use type acquisition as a heuristic for whether a JS project is using node core

* Make same fix in getCompletionDetails

* Fix re-exporting

* Change JS node core module heuristic to same-file utilization

* Remove unused method

* Remove other unused method

* Remove unused triple-slash ref

* Update comment

* Refactor findAlias to forEachAlias to reduce iterations

* Really fix re-exporting

* Use getModuleSpecifier instead of custom hack

* Fix offering auto imports to paths within node modules

* Rename things and make comments better

* Add another reexport test

* Inline `symbolHasBeenSeen`

* Simplify forEachAlias to findAlias

* Add note that symbols is mutated

* Symbol order doesn’t matter here

* Style nits

* Add test with nested package.jsons

* Fix and add tests for export * re-exports

* Don’t fail when alias isn’t found

* Make some easy optimizations

* Clean up memoization when done

* Remove unnecessary semicolon

* Make getSymbolsFromOtherSourceFileExports pure

* Cache auto imports

* Revert "Cache auto imports"

This reverts commit 8ea4829587.

* Handle merged symbols through cache

* Be safer with symbol declarations, add logging

* Improve cache invalidation for imports and exports

* Check symbol presence first

* Only run cache invalidation logic if there’s something to clear

* Consolidate cache invalidation logic

* Fix reuseProgramStructure test

* Add more logging

* Only clear cache if symbols are different

* Refactor ambient module handling

* Start caching package.json stuff

* Support package.json searching in fourslash

* Move import suggestions cache to Project

* Start making more module specifier work available without having the importing file

* Going to backtrack some from here

* Get rid of dumb cache, fix node core modules stuff

* Start determining changes to a file have invalidated its own auto imports

* Move package.json related utils to utilities

* Add failing test

* Make first test pass

* Don’t filter when there’s no package.json, fix scoped package imports

* Use type acquisition as a heuristic for whether a JS project is using node core

* Make same fix in getCompletionDetails

* Fix re-exporting

* Change JS node core module heuristic to same-file utilization

* Remove unused method

* Remove other unused method

* Remove unused triple-slash ref

* Update comment

* Refactor findAlias to forEachAlias to reduce iterations

* Really fix re-exporting

* Use getModuleSpecifier instead of custom hack

* Fix offering auto imports to paths within node modules

* Rename things and make comments better

* Add another reexport test

* Inline `symbolHasBeenSeen`

* Simplify forEachAlias to findAlias

* Add note that symbols is mutated

* Symbol order doesn’t matter here

* Style nits

* Add test with nested package.jsons

* Fix and add tests for export * re-exports

* Don’t fail when alias isn’t found

* Make some easy optimizations

* Clean up memoization when done

* Remove unnecessary semicolon

* Make getSymbolsFromOtherSourceFileExports pure

* Cache auto imports

* Revert "Cache auto imports"

This reverts commit 8ea4829587.

* Handle merged symbols through cache

* Be safer with symbol declarations, add logging

* Improve cache invalidation for imports and exports

* Check symbol presence first

* Only run cache invalidation logic if there’s something to clear

* Consolidate cache invalidation logic

* Fix reuseProgramStructure test

* Add more logging

* Only clear cache if symbols are different

* Refactor ambient module handling

* Finish(?) sourceFileHasChangedOwnImportSuggestions

* Make package.json info model better

* Fix misplaced paren

* Use file structure cache for package.json detection when possible

* Revert unnecessary changes in moduleSpecifiers

* Revert more unnecessary changes

* Don’t watch package.jsons inside node_modules, fix tests

* Work around declaration emit bug

* Sync submodules?

* Delete unused type

* Add server cache tests

* Fix server fourslash editing

* Fix packageJsonInfo tests

* Add node core modules cache test and fix more fourslash

* Clean up symlink caching

* Improve logging

* Function name doesn’t make any sense anymore

* Move symlinks cache to host

* Fix markFileAsDirty from ScriptInfo

* Mark new Project members internal

* Use Path instead of fileName

* Rename AutoImportSuggestionsCache

* Improve WatchType description

* Remove entries() from packageJsonCache

* Fix path/fileName bug

* Also cache symlinks on Program for benefit of d.ts emit

* Let language service use Program’s symlink cache
2019-09-27 13:38:31 -07:00
Wesley Wigham 558ece72cb
Add support for capturing cpu profiles into tsc itself (#33586)
* Add support for capturing cpu profiles into tsc itself

* Accept baseline for new compiler option in showConfig

* Fix lints

* Support profiling build mode, only ever have one live profiling session

* Minor modification to enable/disable semaphore, accept re-cased baseline

* Add pid into autognerated cpuprofile path

* Rename to fix case

* Sanitize filepaths in emitted cpuprofile for easier adoption by enterprise people, add inspector to browser field
2019-09-27 13:34:44 -07:00
Wesley Wigham 8d7fd2e691
Respect //@ts-nocheck in TS files (#33383) 2019-09-27 12:06:05 -07:00
Andrii Dieiev a34fdb203e Better template literals support in checker (#32064)
* Support template literals in enum declarations

* Support template literals in const enum access

* Support template literals in swith with typeof narrowing

* Support template literals in element access discriminant

* Support template literals in ambient module declaration

* Unify symbols for template literals in computed properties

* Unify expression position checks for template literals

* Support template literals in rename and find all references

* Mark computed properties with template literals as write access

* Inline startsWithQuote
2019-09-27 12:04:13 -07:00
Sheetal Nandi 8e4f47c8a9 Fix the issue when file is attached to project because its a root file name but program contains instead its d.ts
Fixes #33323
2019-09-27 09:00:29 -07:00
Sheetal Nandi 1c24e27ce4 Add the test that fails with find all references 2019-09-27 09:00:29 -07:00
Collins Abitekaniza c0573c59c9 Prevent collision of imported type with exported declarations in current module (#31231)
* check for exported type name for conflict

* refactor baseline tests for import/export name collision
2019-09-27 07:55:04 -07:00
Anders Hejlsberg a13f8621c2 Handle alias symbols in getTypeOfDottedName 2019-09-26 17:24:14 -07:00
Nathan Shively-Sanders e72937deff
Update DOM (#33627)
* Update DOM

* Update baselines
2019-09-26 17:20:05 -07:00
Daniel Rosenwasser b4941f6777
Merge pull request #33625 from m-henderson/mh/33603-error-message-for-missing-member
Better error message for missing member in tslib
2019-09-26 16:22:41 -07:00
Michael Henderson b183b7fd51 Merge branch 'master' into mh/33603-error-message-for-missing-member 2019-09-26 17:30:25 -05:00
Michael Henderson 64683a1a4a update message, generate diagnostics, update src and accept baselines 2019-09-26 17:15:35 -05:00
Orta 40ceb4f7a8
Merge branch 'master' into small_ts 2019-09-26 17:45:24 -04:00
Wesley Wigham 61cb06ce40
Allow allowJs and declaration to be used together (#32372)
* Allow allowJs and declaration to be used together

This intorduces a new symbol-based declaration emitter - currently this
is only used for JSON and JavaScript, as the output is likely worse than
what the other declaration emitter is capable of. In addition, it is
still incomplete - it does not yet support serializaing namespaces.

* Add tests for various import/export forms, add notes on export as namespace and fix export * from

* Tests & fixes for computed names

* Add test with current @enum tag behavior

* fix declaration emit for jsdoc @enum tags

* Small adjustments to base class serialization to fix bugs in it

* Guard against type/type parameter confusion when using typeParameterToName a bit

* Integrate feedback from PR

* Fix issue with export= declarations visibility calculation and type declaration emit that impacted all forms of declaration emit

* Only make one merged getCommonJsExportEquals symbol for a symbol

* Support preserving type reference directives in js declarations

* Skip declare mdoifiers for namespace members in ambient contexts

* FAKE ALIASES AND NAMESPACES EVERYWHERE

* Dont do namespace sugar when type members contain keyword names

* Fix json source file export modifier under new output

* Such clean nested aliasing, very wow

* Fix lint

* Add visibility errors, reuse type nodes where possible

* Suppoer having correctly named import types in bundled js declaration emit & adjust binding to allow namespaces with aliases to merge when the aliases look to be type-only

* Better support for module.exports = class expression

* Fix discovered crash bug

* Allow export assigned class expressions to be reachable symbols from external declarations

* Add missing semicolon

* Support @enum tag post-merge

* preserve comments on signatures and declarations where possible

* Basic support for js classy functions

* Add example we should do better with

* Prototype assignments make things a bit wonky, but the example from the PR seems OK

* Make a ton of changes to support the new way js classes are bound

* Remove some old comments, fix import and export default names

* Fix bug in object define handling and add tests for object define property declaration emit

* Fix organization nits from PR comments

* Preserve comments from jsdoc declarations on properties and js declaration type aliases

* Merge export declarations with identical specifiers

* Remove completed TODO comment

* Split lint

* Remove now-unused function

* PR feedback

* Add some project references tests, remove some checks from project refs codepaths that are now invalid

* Update project references tests again

* Merge and update project references tests

* Rename case

* Update test to include declaration output

* Remove yet another project refernces redirect extension check

* Update comment

* Add additional import ref to test

* Add shorthand prop to test

* Fix comment text

* Extract var to temp

* Simplify function and add whitespace

* Update project refs test to use incremental edit entry

* Stylistic refactors in the symbol serializer

* Another round of PR feedback, mostly style, small bugfix with constructors, and test showing bug in export assigned class expression name shadowing

* Use x instead of index
2019-09-26 14:27:16 -07:00
Anders Hejlsberg 0595d61606 Accept new baselines 2019-09-26 14:00:00 -07:00
Anders Hejlsberg 894cc63be1 Add tests 2019-09-26 13:51:32 -07:00
Anders Hejlsberg 8619bff9c2 Error on assertion and non-returning function calls that aren't CFA-ed 2019-09-26 13:51:24 -07:00
Wesley Wigham 62a43576b3
Enable eslint cache (#33619) 2019-09-26 13:44:10 -07:00
Nathan Shively-Sanders 500a0df6f3
Add useDefineForClassFields flag for Set -> Define property declaration (#33509)
* Disallow property/accessor overrides

Unless the base property or accessor is abstract

* Disallow uninitialised property overrides

This causes quite a few test breaks. We'll probably want to revert many
of them by switching to the upcoming `declare x: number` syntax.

* Updates from design review + fix ancient bug

1. Don't error when overriding properties from interfaces.
2. Fix error when overriding methods with other things. This had no
tests so I assume that the code was always dead and never worked.

* Need to add a couple of errors and squash one

Will update after checking out other branch for a minute

* Everything works so far

Need to test properties initialised in constructor

* Check for constructor initialisation

* change error wording

* Improve error wording

* Add codefix to add missing 'declare'

* Always emit accessors in .d.ts files

* Allow 'declare' on any uninitialised property decl

* Undo code moves

* Let sleeping dogs lie

* Correctly set NodeFlags.Ambient

And simplify redundant parts of check.

* Remove more unneeded code

* Update baselines

* Update baselines

* Update baselines

* Ignore this-property assignments

* Fix base-in-interface check

* Do not error when base parent is interface

* Fix base interface check

* Add missed baselines

* Fix check

* Fix new errors in services

* Fix new errors in services

* Fix errors in testRunner

* Add flag and turn off errors when on

* Structure of new emit is correct, fake content

It is 'hi'.

* Basically right emit

* Fix one last unitialised property declaration

* Haha no I missed another one

* Fix whitespace back to CRLF

* Minor fix and code cleanup

* New test case

* Fix bug in isInitializedProperty

* Updates from design meeting.

1. Change flag name to useDefineForClassFields (and flip polarity).
2. Forbid ES3 + useDefineForClassFields (since there is no
defineProperty).
3. Forbid overriding an abstract property-with-initializer with an
accessor.

* Update baselines

* Object.defineProperty for methods too

Using code from Ron from his upcoming refactor of the factory functions.

* Update slow baselines

* Improve error message

* Update src/compiler/transformers/utilities.ts

Co-Authored-By: Andrew Branch <andrewbranch@users.noreply.github.com>

* Add test of computed properties

* Remove done TODO
2019-09-26 13:25:05 -07:00
Andrew Branch 7d9b22eea0
Add semicolon preference to formatter options (#33402)
* Add UserPreferences for semicolons

* Prototype formatter semicolon removal

* Implement semicolon insertion

* Fix existing tests

* Start adding tests

* Fix some edge cases of semicolon deletion

* Fix semicolon removal before comments

* Fix indentation

* Test on checker

* Replace semicolon-omitting writer with formatter preference

* Fix writing new nodes, update protocol

* Rename option

* Really fix formatting synthetic nodes

* Fix refactoring misses

* Un-update submodules gahhhh

* Update APIs

* Update for ESLint

* Revert accidental test change

* De-kludge deduplication of EOF processing

* Omit last element semicolon from single-line object-like types

* Revert "Omit last element semicolon from single-line object-like types"

This reverts commit 5625cb0237.

* Fix straggler test

* Add test for leading semicolon class members

* Rename a lot of stuff for clarity

* Invert some boolean logic
2019-09-26 13:23:29 -07:00
Orta Therox 392af2bea8 Merge branch 'master' of https://github.com/microsoft/TypeScript into small_ts 2019-09-26 13:55:12 -04:00
Orta Therox 92b3266a93 Rename the smaller build to '@typescript/language-services' and have a separate build step for creating and publishing vs configuring the build 2019-09-26 13:34:27 -04:00