Commit graph

29471 commits

Author SHA1 Message Date
Klaus Meinhardt f220e62ce7 importsNotUsedAsValue affects semantic diagnostics (#36001)
* importsNotUsedAsValue affects semantic diagnostics

* add tests
2020-01-15 15:08:16 -08:00
Andrew Branch 81a942e7b9
Fix completions triggered on existing private identifier property access (#36191) 2020-01-15 13:13:11 -08:00
Andrew Casey a9cbea4259
Use fs.existsSync to check for cancellation (#36190)
Unlike statSync, it doesn't throw if the file doesn't exist, saving both
time and allocations.
2020-01-15 12:53:40 -08:00
Anders Kaseorg 64704a160d sys: Use readdir withFileTypes option to skip lots of stat syscalls (#35286)
This makes walking large directory trees much more efficient on Node
10.10 or later.

See:
https://lwn.net/Articles/606995/
https://www.python.org/dev/peps/pep-0471/
https://github.com/nodejs/node/pull/22020
https://nodejs.org/en/blog/release/v10.10.0/

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2020-01-15 12:42:38 -08:00
Orta 1dafd09a06
Revert "Add related diagnostic to "used before defined" if type is a function that returns a union with undefined (#33171)" (#35751)
This reverts commit be960fa356.
2020-01-15 12:50:52 -05:00
Klaus Meinhardt 6e3ab1529f remove private named properties from rest and spread types (#35950)
* remove private named properties from rest and spread types

Fixes: #35943

* code review
2020-01-14 14:47:39 -08:00
Alexander T daf786ecd0 throw an error when no default export present (#35815) 2020-01-14 11:38:48 -08:00
Wesley Wigham 91ffa1c752
Update LKG (#36164) 2020-01-13 13:11:29 -08:00
Wesley Wigham 08014bca05
Fix lints 2020-01-13 12:50:20 -08:00
Wesley Wigham 69ab1d5ecd
Handle Identifier declarations in getDeclarationSpaces (#36136) 2020-01-13 10:29:37 -08:00
Sheetal Nandi 76ee0214f9
Use watch invoked with node_modules/.staging as watch for refreshing complete node_modules, so that npm install is reflected correctly (#36039)
* Add test that demonstrates npm install watch behaviour some times

* Use watch invoked with `node_modules/.staging` as watch for refreshing complete node_modules, so that npm install is reflected correctly
Fixes #35966
2020-01-10 14:58:01 -08:00
Sheetal Nandi 0c3019e3b3
Handle invalid package.json typings fields when generating specifiers (#36137)
Fixes #35437
2020-01-10 14:51:23 -08:00
Sheetal Nandi 00b21efcb0
Remove the check that if base file name starts with ^ is dynamic file name since those files can exist (#36109)
Fixes #35734
2020-01-10 10:57:44 -08:00
Nathan Shively-Sanders 13cddae3f7
Allow references to uninitialized ambient properties (#36112)
Previously these were incorrectly treated just like normal properties:

```ts
class Parent {
    a: any;
    constructor(arg: any) {
        this.a = arg;
    }
}
class Child extends Parent {
    declare a: number;
    constructor(arg: number) {
        super(arg);
        console.log(this.a);  // Property 'a' is used before being assigned. (2565)
    }
}
```

Fixes #35327
2020-01-10 10:50:05 -08:00
Anders Hejlsberg 357f715382
Check combined intersection properties against target index signatures (#35143)
* Check combined intersection properties against target index signatures

* Add tests

* Accept new baselines

* Less aggressive check for index signatures

* Track intersection membership state for both source and target

* Minor fixes
2020-01-10 10:46:10 -08:00
Nathan Shively-Sanders 517d6eea28
Get jsdoc host from chained assignment (#36111)
* Get jsdoc host from chained assignment

getSourceOfAssignment previously only checked one level of binary
expression instead of following binary expressions all the way to the
right. This meant that binding of `@constructor` would fail in the
following example:

```js
/** @constructor */
a = b = function () { }
```

* cleanup lint

* use existing utility
2020-01-10 10:09:39 -08:00
Anders Hejlsberg 94271aa753
Remove CFA discriminant check restrictions (#36114)
* Remove unnecessary containsMatchingReferenceDiscriminant logic

* Accept new baselines
2020-01-10 09:41:16 -08:00
Jean Pierre 79dcd3dba1 Correctly resolve tags for function overloads (#30253)
* Correctly resolve tags for function overloads. Fixes #30181

* Better fix for #30181. Added more unit tests

* Fix commentsOverloads tests

* Fallback to first signature when doc and tags are empty
2020-01-10 08:54:26 -08:00
M.Yoshimura 5fc917be2e Fixes broken emit with useDefineForClassFields + private field (#35898)
* Fixes broken emit with useDefineForClassFields + private field

* use simpler function for condition
2020-01-09 10:21:49 -08:00
Nathan Shively-Sanders 66b5c47854
Fix crash in codefixes re: braces of class body (#36087)
* Fix crash in codefixes re: braces of class body

Previously, the code that finds braces of a class body assumed they were
always there. This is not always the case, so this code checks for
that.

* fix semicolon lint
2020-01-09 08:46:00 -08:00
TypeScript Bot 21316e551a Update user baselines (#36046) 2020-01-08 16:44:13 -08:00
Anders Hejlsberg 0aab63b7ff
Fix narrowing of optional chains (#36089)
* Check for definitely not undefined instead of maybe not undefined

* Fix comment

* Add tests
2020-01-08 15:37:27 -08:00
Titian Cernicova-Dragomir 3e4578c9f4 Fixed unreported strict property initialization violations. (#35891) 2020-01-08 15:15:20 -08:00
Andrew Casey 071819bb37
Report time spent in updateGraph (#35675)
Add a response property indicating how much of the elapsed time (from
`onMessage` to `doOutput`) was spent in `updateGraph` calls.  If there's
no `updateGraph` call, the property is undefined, to save space (with
the downside that it's harder to tell whether a given telemetry event
could have had the property).

Fixes #34774
2020-01-08 14:41:34 -08:00
Eli Barzilay ab1458ac55 Tweak the test and add more duplicate name assignment tests
(Both valid and invalid.)
2020-01-08 14:21:28 -05:00
Klaus Meinhardt 38b53790af Allow destructuring the same property multiple times
Fixes: #35939
2020-01-08 14:21:28 -05:00
Sheetal Nandi 9889c74939
Disable declaration emit for json files (#36066) 2020-01-08 09:54:32 -08:00
Daniel Rosenwasser 78748c0a35
More actionable "must have annotation" message (#35839)
* Give an actionable elaboration.

* Accepted baselines.

* Less words.

* Accepted baselines.
2020-01-07 16:46:14 -08:00
Joey Watts f84b2d20a9 Parse error on private identifier optional chain (#35987)
Previously, this error was reported in the checker, so JS files with
checkJs: false were not erroring on this invalid syntax.
2020-01-07 16:00:15 -08:00
Eli Barzilay 9fbcdb1edb Resurrect SuppressAnyReturnType, but make it used only at the toplevel 2020-01-07 17:12:43 -05:00
Eli Barzilay 724f426468 Remove SuppressAnyReturnType
Following a discussion with Ryan, it seems best to leave any `any`s in
the generated code.
2020-01-07 17:12:43 -05:00
Eli Barzilay 0c467d095f Fix signatureToSignatureDeclarationHelper
Even if `SuppressAnyReturnType` is on, don't supress it if it's a function.

Fixes #35508.
2020-01-07 17:12:43 -05:00
Alexander T 8ed92dcecd fix(31909): show suggestions for second type argument of generic (#36024) 2020-01-07 11:03:22 +00:00
Wesley Wigham 88677de380
Do not omit the anyFunctionType from intersections (#35658)
* Do not omit the anyFunctionType from intersections

* Move check into isEmptyResolvedType
2020-01-07 00:39:28 -08:00
Daniel Rosenwasser d044e0680a
Renamed references to 'configurePrerelease'. (#35997) 2020-01-06 16:38:46 -08:00
Daniel Rosenwasser f807b57356
Add s to importsNotUsedAsValue (#36037)
* Pluralize end of 'importsNotUsedAsValue'.

* Updated baselines.
2020-01-06 13:23:47 -08:00
Anders Hejlsberg f8bfc6f5d6
Contextually typed binding element initializers (#35855)
* Binding element initializers contextually typed by parent initializers

* Accept new baselines

* Literal type widening should be last step in inference

* Accept new baselines

* Add tests
2020-01-06 12:53:23 -08:00
Anders Hejlsberg df3b5bbdab
Fix ThisParameterType<T> type (#36013)
* Simplify ThisParameterType<T> type

* Add tests
2020-01-06 08:55:34 -10:00
Nathan Shively-Sanders 28319a541a
CustomElementConstructor: should be construct signature (#36030)
Was previously incorrectly a call signature. Had to override it
manually.
2020-01-06 10:09:03 -08:00
Eli Barzilay d6c05a1358 Fix getEffectiveTypeAnnotationNode
Prevent it from using the (return) type of a function.  Could also check
the condition before calling the function, but there are two places that
need the check, and OTOH, all calls check the result so returning
`undefined` should work.

(This problem was introduced in PR#32553.)

Fixes #33741.
2020-01-03 22:47:17 -05:00
Sheetal Nandi 5cc58deb57 Shorten test baseline names (#35993) 2020-01-03 16:37:04 -08:00
Andrew Branch 3b396e6124 Type-only imports and exports (#35200)
* Add type-only support for export declarations

* Use a synthetic type alias instead of binding type-only exports as a type alias

* Works for re-exports!

* isolatedModules works fine

* Diagnostic for type-only exporting a value

* Start isolated modules codefix

* Update for LKG control flow changes

* Type-only import clause parsing

* Type-only default import checking

* Type-only named imports

* Fix isolated modules error

* Filter namespaces down to type-only

* Fix class references

* Test nested namespaces

* Test circular type-only imports/exports

* Fix getTypeAtLocation for type-only import/export specifiers

* Fix type-only generic imports

* Update public APIs

* Remove unused WIP comment

* Type-only namespace imports

* Fix factory update calls

* Add grammar errors for JS usage and mixing default and named bindings

* Update updateExportDeclaration API baseline

* Fix grammar checking import clauses

* Enums, sort of

* Dedicated error for type-only enum

* Skip past type-only alias symbols in quick info

* Update error code in baseline

* WIP: convertToTypeOnlyExport

* isolatedModules codefix (single export declaration)

* isolatedModules code fix (all)

* Stop eliding non-type-only imports by default, add compiler flag

* Update to match updated diagnostic messages

* Update more baselines

* Update more tests

* Auto-import as type-only

* Add codefix for splitting type-only import with default and named bindings

* Add more services tests

* Add targeted error message for "export type T;" when T exists

* Add targeted error for "import type T = require(...)"

* Flip emit flag

* Add test for preserveUnusedImports option

* Fix flag flip on import =

* Make compiler option string-valued

* Fix merge conflicts

* Add --importsNotUsedAsValue=error

* Phrasing of messages.

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
2020-01-03 14:39:32 -08:00
Sheetal Nandi 18269c0fc8
Add assumeChangesOnlyAffectDirectDependencies as a option to skip checking and generating .d.ts files for files indirectly importing affected file (#35711)
* Baselining tsc --watch output

* Add noIndirectImports as a option to skip checking and generating .d.ts files for files indirectly importing affected file
Fixes #33329

* Rename option to assumeChangesOnlyAffectDirectDependencies

* Description change as per feedback
2020-01-03 13:02:45 -08:00
ExE Boss 5a342742d0 feat(lib/es2020): Add Promise.allSettled(…) (#34065)
* feat(lib/es2020): Add `Promise.allSettled(…)`

* test(lib): Update tests to account for `es2020.promise`

* fix(lib/es2020): `Promise.allSettled(…)` takes `Iterable` argument

* refactor(lib/es2020): Rename `Promise.allSettled(…)` return type

* feat(lib/es2020): Simplify `Promise.allSettled(…)` type declaration

* refactor(lib/es2020): Improve naming of `Promise.allSettled(…)` types
2020-01-03 12:58:02 -08:00
Eli Barzilay 8939b251b8 Fix cmdline aliases specs 2020-01-03 15:43:30 -05:00
Alexander T 4585f448a9 fix(35179): formatter incorrectly remove spaces (#35979) 2020-01-03 10:09:56 -08:00
Anders Hejlsberg a8944e6844
Fix type parameter leak (#35949)
* Fix cloneSignature to include unionSignatures property

* Add regression test
2020-01-03 07:54:38 -10:00
Daniel Rosenwasser 024b8c1e5f
Merge pull request #30565 from D0nGiovanni/m-template-literal-2
add refactoring: string concatenation to template literals
2020-01-02 17:08:29 -08:00
Titian Cernicova-Dragomir ded072e8af Fixed find all references for private identifiers. (#35887) 2020-01-02 17:06:25 -08:00
Daniel Rosenwasser ff4fa1feb9 Cleaned up refactoring names, descriptions. 2020-01-02 16:32:06 -08:00