21463 Commits

Author SHA1 Message Date
Sheetal Nandi
236012e47b
Add watchOptions to tsconfig and allow supplying them on command line as well (#35615)
* Create different watch options in compiler options

* Thread through the new watch options

* Actually use the options passed through for watch strategy

* Support delay on updating child directory watches

* Make watchOptions separate from compilerOptions

* Support passing watch options from command line

* Handle displaying of watchOptions
2019-12-11 13:26:44 -08:00
Sheetal Nandi
4212484ae1
Open bigger set of configured projects when opening composite project for operations that operate over multiple projects like rename (#33287)
* Add isInferredProject, isConfiguredProject and isExternalProject

* Skip refreshing configured project on change of config file if its not loaded

* Open a tree of projects when doing findAllRefs or rename operations

* Fix addToSeen project key

* Refactor combineProjectsOutputWorker

* if the definition is local, no need to load and look in other projects

* Add disableSearchSolution as option to disable looking for solution

* Rename the option to disableSolutionSearching
2019-12-11 12:28:18 -08:00
Andrew Branch
f1f874699c
Improve some completions on generic object literals (#34855)
* Weird fix

* Slightly better I guess

* Update APIs

* Make `hasTypeArguments` do what it says on the tin

* Fix merge mistake
2019-12-11 11:21:28 -08:00
Sheetal Nandi
07364595e4
Handle consistent file name during editor and tsc --watch scenarios (#34622)
* Add isInferredProject, isConfiguredProject and isExternalProject

* Add test for rename on file with case change that fails
Test for #25460

* Dont store fileName on text storage

* Store root file names in the root file map to reflect their name

* Delay open file triggering watches

* Correct the name of source file as we query it (eg. it could be same source file returned in old program with different casing on case insensitive file name)

* More tests

* Refactoring

* Cache bind And check diagnostics and always get program diagnostics from the program

* Another test

* Try to report conflicting file error on file instead of global diagnostics

* Create better tests for module resolution diagnostics check

* Fix lint errors
2019-12-10 18:25:10 -08:00
Wesley Wigham
50603eda5c
Add ts namespace reference to tsc, since it now doesnt have one 2019-12-09 16:48:00 -08:00
Wesley Wigham
a83b928b09
Rename debug.ts so its name differs from its namespace (#35596) 2019-12-09 16:35:01 -08:00
Wesley Wigham
6936ac24fd
Move executeCommandLine.ts into its own project (#35595)
* Move executeCommandLine.ts into its own project

* Remove incorrect prepend
2019-12-09 16:33:24 -08:00
Toxyxer
f8cacf97e1 Issue/34870 (#35586)
* Add new error message when missing brace

* Add test for missing close brace

* Update other tests which were affected
2019-12-09 16:31:23 -08:00
Andrew Branch
64a886700f
Fix spelling codefix for optional chain property access (#35583) 2019-12-09 11:31:47 -08:00
Andrew Branch
9a9baebdd6
Sort extract constant above extract function (#35580) 2019-12-09 10:33:28 -08:00
Wesley Wigham
a78342a160
Move most harness globals into namespaces (#35530)
* Move most harness globals into namespaces

* Remove forward declaration from `createMapShim` and move all `Map` declarations into one file

* A small pile of more changes to get the harness transforming
2019-12-06 15:20:49 -08:00
Andrew Branch
f050750cc6
Don’t auto-import undefined (#35504) 2019-12-05 14:47:51 -08:00
Wesley Wigham
27616dd523
Move codefix types into services/types.ts (#35506)
* Move codefix types into services/types.ts

* Also split apart refactorProvider

* Move all meanings of DocumentHighlights into one file

* Use setter for object allocator

* Remove unneeded namespace reference

* Remove some shorthand references to nonlocal namespace variables

* Convert WatchType string enum to a structure that can be merged across modules

* Rename harness to harnessIO

* Move accidental globals into namespace

* Remove unused globals

* Suppress lints - these qualifiers are needed for the migration to go smoothly

* Hide global declaration
2019-12-05 10:51:31 -08:00
Anders Hejlsberg
09271f107d
Make no inferences from binding patterns with no defaults (#35454)
* Use nonInferrableAnyType in types inferred from binding patterns

* Add regression tests

* Accept new baselines
2019-12-05 07:09:45 -08:00
Andrew Branch
b39b4e05be
Use namespace import for esnext when esModuleInterop is off (#35475) 2019-12-04 12:07:25 -08:00
Nathan Shively-Sanders
a816162923
Remove unneeded Array and Promise JS rewrites (#35482)
Type-argument defaulting is handled elsewhere in the compiler.
This is a small drive-by improvement, so I didn't change the handling of
'array' or 'promise'; they still manually create `any[]` and
`Promise<any>`, respectively.
2019-12-04 09:06:42 -08:00
Wesley Wigham
e8748f8162
Add nested global member creation to shim (#35473) 2019-12-03 11:31:30 -08:00
Wesley Wigham
7bfffa745f
Remove redundant checker functions and use patterns more friendly to modules (#35399)
* Remove redundant checker functions, use patterns more friendly to modules

* Also use a helper for localizedDiagnosticMessages

* Move types into same file as consts

* Accept slightly changed api baseline

* Whitespace!
2019-12-02 13:44:25 -08:00
Wesley Wigham
85ec9bf175
Remove duplicate definition of Push (#35397)
It's also defined in `corePublic.ts` - there's no errors because they're (almost) identical and merge (creating a redundant overload for `push`). Ironically, while this definition was internal, the other is public (and more complete).
2019-12-02 11:47:42 -08:00
Andrew Branch
97aba45d6f
Emit unused identifier suggestion diagnostics in declaration files and ambient nodes (#35119) 2019-12-02 09:52:40 -08:00
Eli Barzilay
d6740cf410 Fix getTypeFromJSDocValueReference
When using `{import('./b').FOO}` which is defined as a string literal,
`valueType` doesn't have a `symbol`.  Leave it for the fallback value
for now.

This was exposed in 8223c0752.

Fixes #34869.
2019-11-27 17:53:11 -06:00
Eli Barzilay
d6bd3ac552 Don't filter away private completions if in the same context
Fixes #34405, which was introduced in PR #16953.
2019-11-27 17:41:58 -06:00
Wesley Wigham
c84afa1b9e
Fix build from incomplete merge 2019-11-27 14:08:16 -08:00
Sheetal Nandi
d02531f650
Fix compileOnSaveEmit when using source of project reference redirect with --out (#35335)
* Fix compileOnSaveEmit when using source of project reference redirect with --out
Fixes #35226

* Fix typo
2019-11-27 13:47:19 -08:00
Wesley Wigham
c447ebc59c
Refactor: No more than 1 namespace declaration per file (#35373)
* Refactor: No more than 1 namespace declaration per file

* Simplify refs where possible
2019-11-27 13:44:31 -08:00
Anders Hejlsberg
1320c36165
Fix control flow analysis for break/continue with label (#35377)
* Use existing 'continue' target labels for labeled statements

* Use linked list for active labels

* Add regression test

* Accept new baselines
2019-11-27 12:28:06 -08:00
Sheetal Nandi
25ec62f892
Handle when output file would be in subFolder specified by outDir/declarationDir (#35366)
Fixes #35328
2019-11-27 09:36:52 -08:00
Anders Hejlsberg
ea4e6b31ba
Improve control flow type caching (#35332)
* Cache getTypeOfExpression results when CFA was invoked

* Add tests

* Accept new baselines
2019-11-25 15:10:09 -08:00
Anders Hejlsberg
0c2c58c42f
Create returnOnlySignature only when inferences will possibly be made (#35173)
* Create returnOnlySignature only when inferences will possibly be made

* Add regression test

* Accept new baselines
2019-11-25 15:05:53 -08:00
Alexander T
0c17476d09 assign error to method definition node if a return type is empty (#35309) 2019-11-24 20:18:04 -08:00
Wesley Wigham
b9689228b5
When calculating spreads, merge empty object into nonempty object to … (#34853)
* When calculating spreads, merge empty object into nonempty object to produce partial object to reduce complexity

* Actually accept remainder of baselines

* Limit simplification to single prop or partial types
2019-11-22 17:19:17 -08:00
Anders Hejlsberg
58a05f3e87
Normalize type references before relating them (#35266)
* Normalize type references before relating them in isRelatedTo

* Add comments

* Accept new baselines

* Add regression tests

* Accept new baselines

* Use aliases when available in error reporting

* Accept new baselines
2019-11-22 15:40:18 -08:00
Nathan Shively-Sanders
369900bb07
Emit defineProperty calls before param prop assignments (#34987)
* Emit defineProperty calls before param prop assignments

Note that I restricted this to --useDefineForClassFields is true.
Nothing changes when it's off. I think this is the correct fix for a
patch release.

However, in principal there's nothing wrong with moving parameter
property initialisation after property declaration initialisation. It
would be Extremely Bad and Wrong to rely on this working:

```ts
class C {
  p = this.q // what is q?
  constructor(public q: number) { }
}
```

But today it does, and probably somebody relies on it without knowing.

* Put parameter property initialiser into defineProperty's value

* Combine ES5/ESNext into one test
2019-11-22 15:37:24 -08:00
Nathan Shively-Sanders
2075f74fef useDefineForClassFields skips emit of ambient properties (#35058)
* useDefineForClassFields skips emit of ambient properties

Previously:

```ts
class C {
  declare p
}
```

would incorrectly emit

```js
class C {
    constructor() {
        Object.defineProperty(this, "p", {
            enumerable: true,
            configurable: true,
            writable: true,
            value: void 0
        });
    }
}
```

when useDefineForClassFields was turned on (for targets <ESNext).

* Fix bug for ESNext as well

This moves the check earlier in the pipeline.

* update baselines
2019-11-22 14:52:29 -08:00
Daniel Rosenwasser
3da85df511
Clean up error messages for using TypeScript syntax in JavaScr… (#35254)
* Fix up quotation marks in error messages in JavaScript files.

* Accepted baselines.

* Typescript -> TypeScript

* Accepted baselines.

* Migrate syntactic diagnostics tests to baselining tests.

* Accepted baselines.

* Update diagnosticMessages.json

* Removed markers.

* Add ability to baseline both semantic and syntactic diagnostics.

* Fix up broken diagnostics when using a server LS.

* Accepted baselines.

* Lints.

* Fake up sourcefile objects in the tsserver session client instead.

* Fewer allocations.
2019-11-22 14:51:22 -08:00
Wesley Wigham
3e329469c1
Actually use the moer complete update function in visitEachChild (#35301) 2019-11-22 14:36:22 -08:00
Eli Barzilay
f017fa04c4 Scan types of yield expressions in classes too
Also, drop the other cases where they were ignored, since they're
forbidden in enums, and the others are fine wrt the comment that was
there.

Fixes #34892
2019-11-22 08:51:00 -05:00
Eli Barzilay
20b246c83a Fix getIntrinsicAttributesTypeFromJsxOpeningLikeElement
Use `getIndexTypeOfType`+`getDeclaredTypeOfSymbol` instead of `getIndexInfoOfSymbol`.

Fixes #34730.
2019-11-22 08:43:24 -05:00
Wesley Wigham
663a42be94
Allow references to globalThis to be made in declaration emit (#35279) 2019-11-21 15:21:35 -08:00
Wesley Wigham
cfa367d7f9
Have definite assignment assertions on property signatures mark them as typescript (#35270) 2019-11-21 13:13:46 -08:00
Anders Hejlsberg
94d4023043
Add inference priority level for conditional types in contravariant positions (#35199)
* Add inference priority level for conditional types in contravariant positions

* Accept new API baselines

* Add regression tests

* Accept new baselines
2019-11-21 13:05:44 -08:00
Wesley Wigham
614a07c7d5
Fix printing and emit for definite assignment assertions (#35095)
* Fix printing and emit for definite assignment assertions

* Make factories that handle definite assertions internal
2019-11-21 11:20:57 -08:00
Wesley Wigham
a6d44aa52e
Map stale empty object type in union into fresh empty object type after spread is complete (#34839)
* Map stale empty object type in union into fresh empty object type after spread is complete

* Accept minor baseline diff
2019-11-21 10:57:55 -08:00
Eli Barzilay
77ec756960 Make getSourceFileToImportFromResolved prefer files in program.getSourceFiles()
Fixes #30550
2019-11-20 18:00:10 -05:00
Sheetal Nandi
0e736a7438
Fix the usage of pattern matching in module resolution for check of hasZeroOrOneAsteriskCharacter (#35209)
* Fix the usage of pattern matching for check of hasZeroOrOneAsteriskCharacter
Fixes #35171

* Fix error message
2019-11-20 10:55:40 -08:00
Kārlis Gaņģis
17f5469a2c Fix crash with Object.defineProperty for imported alias (--allowJs) (#35198)
Fixes #35196
2019-11-20 10:50:47 -08:00
Nathan Shively-Sanders
75301c8e2c
DOM update 2019-11-19 (#35207)
* DOM update 2019-11-19

* update baselines

* update more baselines
2019-11-19 15:02:51 -08:00
Andrew Branch
571ca60b08
Add preceding semicolon on await insertion when parentheses are included (#34627)
* Add preceding semicolon on await insertion when parentheses are included

* Just start with precedingToken

* Fix semicolon formatter regression

* Delete test with debatable expected behavior

* Lint after control flow changes
2019-11-19 13:11:42 -08:00
Daniel Rosenwasser
b50b9e0fd2
Fix check for get/set recommendation (#34885)
* Added more tests.

* Accepted baselines.

* Work better with any parameter type.

* Accepted baselines.

* Use the actual indexed expression.

* Add tests that exhibit bad stringification.

* Accepted baselines.

* Short-circuit stringification on 'undefined'.

* Accepted baselines.

* Remove space.

* Accepted baselines.
2019-11-19 13:00:24 -08:00
Nathan Shively-Sanders
0bbeab6e61
Revert "Skip costly tests" (#35197)
* Revert "Skip costly tests"

* fix package.json format
2019-11-19 12:59:09 -08:00