Commit Graph
13453 Commits
Author SHA1 Message Date
Anders Hejlsberg 4b813e310c Simplify non-inferrable property check to rely on propagation 2019-04-10 17:05:07 -10:00
Anders Hejlsberg 411e7144a9 Add new nonInferrableType with ObjectFlags.NonInferrableType 2019-04-10 16:53:38 -10:00
Nathan Shively-Sanders 90b304aa5e Merge pull request #30786 from Microsoft/always-check-class-extends
Always check extends clause of classes
2019-04-08 10:25:05 -07:00
Andrew Branch bafa4c90c1 Merge pull request #30758 from andrewbranch/bug/30647
Fix crash when checking function call
2019-04-08 09:22:39 -07:00
Anders Hejlsberg 2b6e7304c1 Merge branch 'master' into tweakUnionTypeInference 2019-04-06 08:12:45 -10:00
Nathan Shively-Sanders 1218f29662 Merge branch 'master' into always-check-class-extends 2019-04-05 16:41:15 -07:00
Nathan Shively-Sanders dabf2a6af2 Always check extends clause of classes
Even if (1) @extends is provided and (2) we're not producing
diagnostics. That's because we need to know whether the extends clause
references an imported alias.
2019-04-05 16:37:27 -07:00
Wesley Wigham c1f2aba364 Cache substitution types (#30775) 2019-04-05 14:37:47 -07:00
Anders Hejlsberg f93f8d32c4 Tweak union type inference to restore previous behavior 2019-04-05 13:23:54 -07:00
Sheetal Nandi 8684c3bfb8 Merge pull request #30740 from Microsoft/moduleAndAmbientResolutionConflict
When old program resolved to module and that file is included, dont consider as ambient resolution.
2019-04-05 12:15:06 -07:00
Nathan Shively-Sanders 0b3b4ea127 Added error for class properties used within their own declaration (#29395)
* Added error for class properties used within their own declaration

Fixes #5987.

Usages of a class property in a preceding property already gave an error, but the following doesn't yet:

```ts
class Test {
    x: number = this.x;
}
```

As with other use-before-declare checking, IIFEs are not treated as invalid uses.

* Accepted 'witness' baselines; removed unnecessary !==

* Addressed quick feedback items

* Accepted odd new baseline

* Fixed post-merge introduced lint errors

* Updated baselines again
2019-04-05 09:06:36 -07:00
Wesley Wigham 16450a027a Change the default type parameter constraints and defaults to unknown from {} (#30637)
* Change the default type parameter constraint and default to unknown from {}

* Relax unknown checking outside of strictNullChecks a bit

* Increase strictness on index signatures with type `unknown` so inference doesnt change surprisingly

* Remove redundant switch
2019-04-04 12:25:15 -07:00
Andrew Branch 8c51115be1 Merge pull request #30734 from andrewbranch/bug/30664
Fall back from `globalReadonlyArrayType` to `globalArrayType` when transpiling
2019-04-04 11:57:08 -07:00
Andrew Branch da3fdd11c1 Fix arity error sometimes reaching out of bounds of the arguments actually present 2019-04-04 11:47:26 -07:00
Josh Goldberg e767ee0472 Merge branch 'master' into property-use-before-declare 2019-04-04 14:05:19 -04:00
Josh Goldberg 236fed9445 Fixed post-merge introduced lint errors 2019-04-03 18:09:33 -04:00
Sheetal Nandi 7ccd86bf52 When old program resolved to module and that file is included, dont consider as ambient resolution.
Fixes #30422
2019-04-03 14:05:49 -07:00
Daniel Rosenwasser 24b1ec8681 Update version to '3.5.0'. 2019-04-03 13:00:47 -07:00
Ron Buckton 8a19e4bcf9 Merge pull request #30726 from Microsoft/fix30653
Treat hoisted temp variables as a custom prologue.
2019-04-03 11:54:37 -07:00
Andrew Branch 9475bf7d9e Fall back from globalReadonlyArrayType to globalArrayType when transpiling 2019-04-03 11:27:53 -07:00
Sheetal Nandi 5869662c3f Merge pull request #30721 from Microsoft/amdOut
Do not create multiple sourceFile to single outputFile with project redirect as the output file is included by default
2019-04-03 10:39:28 -07:00
Alexander T 75a812b4db add new message - TS1258 (#30704) 2019-04-03 09:49:34 -07:00
Andrew Branch fed46ea3bf Merge pull request #30719 from andrewbranch/bug/30668
Fix crash when binding deep module.exports assignment
2019-04-03 09:19:36 -07:00
Josh Goldberg ee4e90c1fb Merge branch 'master' into property-use-before-declare 2019-04-03 08:35:22 -04:00
Josh Goldberg 3c8ce9b316 Addressed quick feedback items 2019-04-03 08:32:51 -04:00
Ron Buckton f04a40dd49 Treat hoisted temp variables as a custom prologue 2019-04-02 17:35:26 -07:00
Sheetal Nandi 602aec2f7d Never create redirect for sourceFiles that get emitted to single output file
Fixes #30591
2019-04-02 14:55:48 -07:00
Andrew Branch 3f3444be80 Merge pull request #30699 from andrewbranch/bug/30635
Fix ternaries where "true" is a parenthesized variable and "false" is a function expression
2019-04-02 14:03:11 -07:00
Andrew Branch d6df34bc48 Don’t crash in forEachIdentifierInEntityName 2019-04-02 14:02:29 -07:00
Andrew Branch 46ae059200 Merge pull request #30695 from andrewbranch/bug/30638
Add type error when destructuring zero elements from void
2019-04-02 13:23:31 -07:00
Sheetal Nandi 3fdd66bddf Report program's source files even when there are errors when building using --build mode 2019-04-02 13:22:22 -07:00
Wesley Wigham ca98a50574 Use const contexts and tuple mapped types to simplify some explicitly elucidated types (#30654)
* Use const contexts and tuple mapped types to simplify some explicitly elucidated types

* Fix lint

* Further cleanup - refactor mapped type into its own alias for readability

* Slightly more cleanup - PragmaPsuedoMap neednt be partial, thus removing tons of nonull assertions

* Remove GH#18217 comments
2019-04-02 13:04:51 -07:00
Andrew Branch 96660f6c00 Just look at the current node instead of context 2019-04-02 11:31:05 -07:00
Andrew Branch d198c5906f Be stricter while parsing arrow function heads in conditional expressions 2019-04-02 11:17:21 -07:00
Andrew Branch abd448fe62 Remove unused arguments 2019-04-01 14:14:19 -07:00
Andrew Branch b4ec2e4f50 Handle destructuring zero elements from void 2019-04-01 13:34:27 -07:00
Sheetal Nandi 025d826339 Merge pull request #30513 from Microsoft/incrementalFromCommandLine
Allow --incremental from command line
2019-03-29 15:06:48 -07:00
Gabriela Araujo Britto bb5eb025a8 Handle imports and exports in 'convert parameters to destructured object' (#30475)
* add test for imported function

* start to implement import references check

* fix imported function test

* skip alias when looking for symbol target

* recognize ES6 imports

* recognize some export syntax

* add tests for imports/exports

* add test for imported function

* start to implement import references check

* fix imported function test

* skip alias when looking for symbol target

* recognize ES6 imports

* recognize some export syntax

* add tests for imports/exports

* add test for imported function

* start to implement import references check

* fix imported function test

* recognize ES6 imports

* recognize some export syntax

* add mode import/export syntax cases

* fix entryToFunctionCall to deal with new calls through property/element access expressions

* add more tests for imports/exports

* allow function and class declarations that have no name but have a default modifier

* rename tests

* fix conflict

* fix tests

* add test for nameless class

* rename function

* minor refactor

* remove old tests

* delete old test

* refactor as suggested

* use getContainingFunctionDeclaration
2019-03-28 13:34:29 -07:00
Anders Hejlsberg c03b7f525c Merge pull request #30568 from Microsoft/instantiateContextualTypes
Contextual typing based on instantiated types
2019-03-28 12:38:01 -07:00
Daniel Rosenwasser 74d3e2a3ef Generalize to intersection types when looking for discriminants in error reporting. 2019-03-27 23:41:43 -07:00
Wesley Wigham b7881a26a0 Unify substitution type any handling into costruction and instantiation (#30592)
* Unify substitution type `any` handling into costruction and instantiation

* Strengthen supertype reduction check to reduce breakage

* Rename conditional type fields per convention

* Explicitly handle anyish signatures in compareSignaturesRelated so strict variance doesnt kill subtyping

* Allow tuple expansions to an `any` rest to be considered an `any` signature as well
2019-03-27 12:55:17 -07:00
Sheetal Nandi a4091ae8e3 Merge branch 'master' into incrementalFromCommandLine 2019-03-26 14:57:18 -07:00
Sheetal Nandi 7457e5d9fe Pull out the incremental compilation into a function so we can test it 2019-03-26 14:28:05 -07:00
Sheetal Nandi 021444a248 Make it as api so we can test it 2019-03-26 14:25:56 -07:00
Sheetal Nandi e28869d888 Ensure that from tsc with --incremental sets source file version
Fixes #30588 and #30589
2019-03-26 14:25:47 -07:00
Sheetal Nandi 684c531386 Always assert that source files are versioned when program is used with Builder 2019-03-26 11:55:12 -07:00
Anders Hejlsberg fca46bb706 Compute per-element contextual type in getSpreadArgumentType 2019-03-26 07:00:19 -07:00
Sheetal Nandi 35470b3f3b Make tsbuildInfoFile as commandline option to tsc (and not tsc -b) 2019-03-25 14:47:36 -07:00
Nathan Shively-Sanders 32054f1c31 Forbid accessing block-scoped variables on globalThis (#30510)
* Forbid accessing const & let on globalThis

It's just an error; you still get the type of the property.

* Disallow access of blockscoped vars on globalThis

Also change Array, Function, String, et al from `const` to `var` so that
they remain accessible via `globalThis.String`.

* Update baselines after lib.d.ts change

Note especially the change in redefineArray, which is now allowed as
long as you provide a type that is assignable to ArrayConstructor.

* Remove blockscoped vars from typeof globalThis

Unlike forbidding them, this removes the properties entirely.

Unfortunately, this means that accessing these properties is only an
error with noImplicitAny, and that error is quite confusing.

Let's discuss our options. I see 3:

1. Forbid access of block-scoped vars as properties (in all flag
settings), but leave them on the type. Simple to implement.
2. Remove block-scoped vars from the globalThis type. Has the bad
error/flag behaviour described above, but simple to implement.
3. Remove block-scoped vars from the globalThis type. Also, forbid
accessing them by executing another resolveName lookup for failed
property accesses on globalThisSymbol. If the second lookup returns a
blockscoped var, issue an error instead of falling back to the index
signature. This seems too complex to me.

* Update baselines

* Better error for block-scoped usage on globalThis

So that value-space references have as clear an error as type-space
references.

* Update fourslash tests

* Fix semi-colon lint

* Don't copy so much when filtering blockscoped vars
2019-03-25 14:07:48 -07:00
Anders Hejlsberg 3d0e2f5f45 Introduce ContextFlags to propagate origin of request for contextual type 2019-03-24 11:15:51 -07:00