Commit Graph
14579 Commits
Author SHA1 Message Date
Sheetal NandiandGitHub 8eee8db192 NoEmit and incremental are allowed with listFilesOnly (#36488)
Fixes #32882
2020-01-28 15:59:09 -08:00
Sheetal NandiandGitHub 0e9416c7c8 Disallow incremental with noEmit (#36483)
Fixes #32882
2020-01-28 13:11:45 -08:00
Sheetal NandiandGitHub f91f762ced Fix js declaration emit for exporting default which looks like namespace merge (#36482)
Fixes #35074
2020-01-28 12:21:36 -08:00
Andrew BranchandGitHub 1bb6ea038f Allow type-only namespace imports in implements clauses (#36464)
* Add test

* Allow type-only symbols in implements clauses

* Add more complex test
2020-01-27 16:13:30 -08:00
Sheetal NandiandGitHub a87512d21b Add # to completion trigger character, (#36462)
Handle private identifiers little better by creating token for private identifier when its just #
Report same error as invalid character but from language service we can now provide completions for this.#

Fixes #36367, #36250
2020-01-27 14:25:20 -08:00
Andrew BranchandGitHub e1bce187a8 Type-only auto imports (#36412)
* WIP

* Promote existing type-only imports to regular if needed

* Add completions test adding to type-only import

* Update tests, revert whole-import-clause replacement codefix strategy to preserve import specifier formatting

* Revert unnecessary changes

* Delete unused function

* }
2020-01-27 12:53:32 -08:00
Nathan Shively-SandersandGitHub 757e67041e Fix getExpandoSymbol for already-expando symbols (#36457)
* Fix getExpandoSymbol for already-expando symbols

getExpandoSymbol is intended to get the symbol of the expando in a
declaration like

```js
var C = class {
}
```

However, when this occurs in a `module.exports` assignment, alias
resolution already jumps to the exported symbol -- in this case the
expando symbol:

``js
// @filename: first.js
module.exports = class {
}
// @filename: other.js
/* @type {import("./first")} */
var C
```

`getExpandoSymbol` is then called on `class { }` instead of
`module.exports = class { }`.

Previously, `getExpandoSymbol` would incorrectly treat `class { }` the
same as the export assignment and get the expando ... from the expando
itself. This resulted in merging the expando with itself, which causes
bogus errors and could cause other problems.

Now `getExpandoSymbol` checks that the expando "initializer" is
different from the declaration.

* Better check for getExpandoSymbol of expando

Check the declaration directly instead of the initialiser.
2020-01-27 12:32:56 -08:00
Alexander TandSheetal Nandi c239626f23 fix(36140): handle quotesPreference option in interface implementation (#36398) 2020-01-27 12:25:31 -08:00
Andrew BranchandGitHub 20e8eba143 Issue better error for exporting primitive type (#36424)
* Issue better error for exporting primitive type

* Delete nonsense
2020-01-27 08:11:21 -08:00
Alexander TandDaniel Rosenwasser 30545006df fix(36068): Incorrect quick fix for undeclared private field i… (#36373) 2020-01-24 18:28:42 -08:00
Wesley WighamandGitHub 18cd79e179 Allow infer type variables to have constraints inferred (#32093)
* Allow `infer` type variables to have constraints infered and allow the breakdown of substitutes in simplifiable source inferences

* Still skip conditional inference when `extends infer Q` so such a pattern still acts as a constraint size breaker
2020-01-24 16:59:20 -08:00
Wesley WighamandGitHub 08e6bc20bb Trampolines for large binary expressions (#36248)
* WIP

* Test no longer crashes, but emit trampoline is incomplete and skips pipeline phases

* Fix lints, use non-generator trampoline in emit (still skips pipeline)

* Final version with emitBinaryExprssion work stack that is only used if possible

* Fix lints

* retarget to es2015 for testing

* Use bespoke state machine trampolines in binder and checker

* Remove now extraneous code in parser

* Adjust fixupParentReferences to use a depth first preorder traversal rather than breadth first

* Reintroduce incremental fast bail in fixupParentReferences

* Revert target to es5

* PR feedback

* Small edit for devops rebuild with updated definition

* Fix comment nits, add internally extraneous check back into transformer
2020-01-24 16:29:55 -08:00
Klaus MeinhardtandRon Buckton 8e0b091795 es2018: visit other binding elements when transforming object destructuring with rest (#35872)
* es2018: visit other binding elements when transforming object destructuring with rest

fixes: #35771

* more tests
2020-01-24 15:50:29 -08:00
Wesley WighamandGitHub 9ef9bb04f1 Fix crash on erroneous enum member merged with exported type alias (#36429) 2020-01-24 15:00:15 -08:00
Nathan Shively-SandersandGitHub 368db997ed ESNext+[[Define]]: reference to param props illegal (#36425)
* ESNext+[[Define]]: reference to param props illegal

When target: "esnext" and useDefineForClassFields: true, property
declaration initialisers should not be able to reference parameter
properties; class fields are initialised before the constructor runs,
but parameter properties are not:

```ts
class C {
  foo = this.bar
  constructor(public bar: string) { }
}
```

emits code that looks like this:

```js
class C {
  bar
  foo = this.bar
  constructor(bar) {
    this.bar = bar
  }
}
new C('x').foo.length // crashes; foo is undefined
```

This PR adds an error on foo's declaration with ESNext+[[Define]].

* improve test
2020-01-24 14:53:28 -08:00
Nathan Shively-SandersandGitHub 43fc19c958 Emit statements before super (#36417)
* Emit statements before super

When statements come before super, Typescript's emit is incorrect,
whether there is an error or not. This change preserves statements that
come before super whether there is an error or not.

Here is the case with no errors:

```ts
class Test extends Array {
  p: number
  constructor() {
    console.log("p is initialised in the constructor below super()")
    super()
    this.p = 1
  }
}
```

Notice that `p` is manually initialised in the constructor after
`super()` instead of at the property declaration.

* Update baselines

Parameter properties in the error case now move below the super call.
This is an improvement because it means the code is more likely to execute
correctly.

* remove outdated comments
2020-01-24 14:52:48 -08:00
Wesley WighamandGitHub 6b64c883f1 Fix crash on missing parent pointer in binder when transpiling export as ns (#36387) 2020-01-24 13:36:05 -08:00
Wesley WighamandGitHub 9e712dd097 Consider SymbolFlags.Method as function-esque during js declaration emit (#36274) 2020-01-24 10:29:23 -08:00
Klaus MeinhardtandDaniel Rosenwasser 49eb0d7a2b Disallow 'declare' modifier on private named properties (#36381)
Fixes: #36345
2020-01-23 13:18:10 -08:00
Sheetal NandiandGitHub 677e45ccb8 Dont add "use strict" prologue in json emit (#36380)
* Add test for strict with isolated modules and resolveJson
Test for #36372

* Dont add "use strict" prologue in json emit
Fixes #36372
2020-01-23 13:01:11 -08:00
Andrew BranchandGitHub b05dde747c Update type-only import semantics to allow type queries (#36092)
* Change type-only semantics to allow type queries

* Don’t error using type-only import in ambient context

* Fix default import

* Fix namespace import

* Update more baselines

* Prevent circular resolution

* Track const enum expression usage

* Update baselines

* Perf tuning 1

* Test commit for perf impact

* Weave type-only alias declaration finding into alias resolution

* Fix namespace import of type-only exported symbols

* type-only exports do not contribute to the module object type

* Update APIs

* Fix enum casing, remove type-only conversion suggestion

* Short circuit type-only checks in resolveEntityName faster

* Fix casing in API

* Remove unused parameter

* Fix error on qualified names in type queries

* Allow type-only imports in computed property names

* Fix computed property names of types and abstract members

* Remove unused util

* Commit missing baselines

* Rename “check” functions so as not to overload the word “check”
2020-01-23 12:53:36 -08:00
Klaus MeinhardtandSheetal Nandi 0276e7f910 noErrorTruncation affects semantic diagnostics (#36306) 2020-01-23 11:10:05 -08:00
Wesley WighamandGitHub 75f88eee48 Do not short-circuit module visibility calculation when alias visibility is requested (#36339) 2020-01-22 14:49:29 -08:00
Andrew BranchandGitHub eac2180e40 Be more tolerant with private identifier parsing, issue more targeted errors, and support private identifiers in forgotten 'this' codefix (#36188)
* Support private identifiers in forgotten this codefix

* Parse invalid private identifiers as identifiers and issue targeted errors

* Update codefix

* Remove accidentally deleted newline
2020-01-22 13:41:15 -08:00
Andrew BranchandGitHub 1d5749ef78 Fix local and exported type alias merging (#36237)
* Fix local and exported type alias merging

* Add baselines
2020-01-22 13:16:49 -08:00
Anders HejlsbergandGitHub da61231039 Include super.XXX(...) assertion method calls in CFA (#36293)
* Support super.XXX in assertions

* Add tests
2020-01-22 11:21:11 -08:00
Alexander TandDaniel Rosenwasser 38eccbab2a feat(29624): better errors for non-exported types (#36187) 2020-01-21 13:03:22 -08:00
Klaus MeinhardtandSheetal Nandi 342f4c0b54 forceConsistentCasingInFileNames affects module resolution (#36334) 2020-01-21 12:45:13 -08:00
Klaus MeinhardtandSheetal Nandi 1fbe20fe75 resolveJsonModule affectsModuleResolution (#36290)
* resolveJsonModule affectsModuleResolutionFixes: #36251

* fix lint
2020-01-21 11:49:38 -08:00
Klaus MeinhardtandSheetal Nandi bc1e7728df experimentalDecorators and emitDecoratorMetadata affect builder state (#36297)
* experimentalDecorators and emitDecoratorMetadata affect builder state

* better test
2020-01-21 11:28:55 -08:00
Klaus MeinhardtandSheetal Nandi 2dd21a08f5 useDefineForClassFields affects emit (#36308)
* useDefineForClassFields affects emit

* fix lint
2020-01-21 11:28:04 -08:00
Yacine HmitoandSheetal Nandi 4445e1147c Fix isProgramUpToDate when changing rootFileNames (#36011) 2020-01-21 11:26:17 -08:00
OrtaandGitHub f588c78aab Remove the compiler diag 1360 after it got missed in #35751 (#36332) 2020-01-21 11:54:48 -05:00
Wenlu WangandDaniel Rosenwasser d2c5d54242 remove duplicate message (#36125) 2020-01-18 14:00:53 -08:00
Alexander TandDaniel Rosenwasser 0dd4c9cebe feat(36231): Improve message for "Remove declaration for: ..." (#36283) 2020-01-18 13:28:19 -08:00
Ron BucktonandGitHub 50adabe32d Improve diagnostics and add code fixes for top-level await (#36173) 2020-01-18 12:24:08 -08:00
Anders HejlsbergandGitHub 1a10e712e6 Improve variance measurement (#36261)
* No covariance default for recursive references in variance measurement

* Add tests

* Accept new baselines
2020-01-17 11:50:38 -08:00
Sheetal NandiandGitHub 57925d4e35 Instead of checking if file exists before file read, handle exceptions from file read (#36244)
Fixes #36236
2020-01-16 17:24:03 -08:00
Anders HejlsbergandGitHub 8517df6fa2 Fix erroneous optional chain narrowing (#36145)
* Not all optional chains are narrowable references

* Add regression test
2020-01-16 16:49:51 -08:00
Alexander TandNathan Shively-Sanders eeff036519 fix(35954): Change spelling for private field incorrectly fixes to a string property (#36079)
* fix(35954): code fix incorrectly fixes private properties spelling issues

* remove duplicate function calls
2020-01-16 09:01:21 -08:00
Alexander TandNathan Shively-Sanders dbd55b3928 fix(35944): show spell checking quick fix for non-existent private named property access (#36195) 2020-01-15 16:56:40 -08:00
Klaus MeinhardtandSheetal Nandi f220e62ce7 importsNotUsedAsValue affects semantic diagnostics (#36001)
* importsNotUsedAsValue affects semantic diagnostics

* add tests
2020-01-15 15:08:16 -08:00
Anders KaseorgandAndrew Casey 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
OrtaandGitHub 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 MeinhardtandRyan Cavanaugh 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 TandWesley Wigham daf786ecd0 throw an error when no default export present (#35815) 2020-01-14 11:38:48 -08:00
Wesley Wigham 08014bca05 Fix lints 2020-01-13 12:50:20 -08:00
Wesley WighamandGitHub 69ab1d5ecd Handle Identifier declarations in getDeclarationSpaces (#36136) 2020-01-13 10:29:37 -08:00
Sheetal NandiandGitHub 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 NandiandGitHub 0c3019e3b3 Handle invalid package.json typings fields when generating specifiers (#36137)
Fixes #35437
2020-01-10 14:51:23 -08:00