Commit graph

2622 commits

Author SHA1 Message Date
Oleksandr T 475036950e
fix(42133): fix instantiated undefined type from JS initializer (#42662) 2021-02-11 17:07:14 -08:00
Eli Barzilay c7bac6f2e6 Avoid getting undefined callSignatures/constructSignatures in getPropertyOfType
e350c357 (#40228) introduced a subtle bug: it switched the flags to an
alias, dropping `SymbolFlags.Property` --- and that makes
`symbolIsValue()` get to the `resolveAlias(symbol)` call, which leads to
`getPropertyOfType()` with`resolved.callSignatures`+`constructSignatures`
being `undefined`.  So initialize them in `setStructuredTypeMembers`
before calling `getNamedMembers()`.

Fixes #42350
2021-02-11 18:56:47 -05:00
Orta Therox 8c5fa5cc91
Revert assignability cases in getNarrowedType (#42231)
* Revert subtype narrowing changes from readonly array PRs

* Adds a test for the change

* More baselines
2021-02-09 15:03:11 -08:00
Anders Hejlsberg e2318217fb
Strip nullable types from 'this' type in inference with optional chain calls (#42536)
* Properly strip nullable types from this type in optional chain calls

* Add regression test
2021-02-03 13:50:23 -10:00
Song Gao 3e28e29c51
fix 38503. (#39716)
* fix 38503.

* trigger test.

* trigger test.

* Move isCallChain

Co-authored-by: Ron Buckton <ron.buckton@microsoft.com>
2021-02-01 18:34:46 -08:00
Andrew Branch c15f40abfa
Fix discriminant property narrowing through optional chain with null (#42503)
* Fix discriminant property narrowing through optional chain with null

* Accept baselines

* Add tests from Anders
2021-01-29 12:03:42 -08:00
Nathan Shively-Sanders 9dbfaeef2d
Narrow QualifiedName inside typeof (#42540)
Previously this wasn't narrowed at all. Now there is control flow and
code in isMatchingReference.
2021-01-28 15:19:01 -08:00
Nathan Shively-Sanders d2443a5df1
@typedef: Improve error spans from declaration emit (#42501)
* @typedef: Improve error spans from declaration emit

This is a proof-of-concept fix. I think it could be expanded for all of
jsdoc, but I only set it up for jsdoc type aliases. It could use a lot
of polish too.

* track error node in isSymbolAccessible instead

* Switch to using enclosingDeclaration

Remove trueErrorNode

* add test of @callback and @enum

* Better error + fix @enum error

Since enums don't have a name property, you *have* to call
`getNameOfDeclaration` to go looking through the AST for one.
2021-01-28 08:35:05 -08:00
M.Yoshimura 701493fb80
Support top level "for await of" (#37424)
* Support Top Level "for await of".

* Add test cases for top level "for await of".

* Apply suggestions from code review

* add test cases

* remove redundant variables

* fix test baselines

* Update diagnostic message and tests

Co-authored-by: Ron Buckton <ron.buckton@microsoft.com>
2021-01-25 13:40:45 -08:00
Andrew Branch 89c173fddc
Narrow via discriminant property through optional chain (#42450)
* Naive attempt at narrowing via discriminant property through optional chain

* Clean up test
2021-01-25 09:29:51 -08:00
Oleksandr T 1ecf22884f
fix(42166): allow assertion signature for private identifiers (#42176) 2021-01-11 09:25:51 -08:00
Orta Therox 055f363fba
Reverts #39277 removing bundledPackageName (#41499)
* Reverts #39277

* Bring back modeyule resolution for the test runner
2021-01-08 10:55:34 +00:00
Ron Buckton 0d284e6c26
Add support for abstract constructor types (#36392)
* Add support for abstract constructor types

* Add backwards-compatible overloads for creating/updating constructor types

* Reverting use of 'abstract' in lib/es5.d.ts due to eslint issues

* Update baseline due to reverting lib

* Add error for failing to mark an mixin class as abstract

* Fix declaration/quick info for abstract construct signatures
2021-01-07 17:11:14 -08:00
Andrew Branch dbba8b358f
Make optional properties assignable to string index signatures (#41921) 2021-01-07 10:46:55 -08:00
Anders Hejlsberg 9b1718677a
Leading and middle rest elements in tuple types (#41544)
* Support starting and middle rest elements in tuples

* Accept new baselines

* Include all rest arguments in error span

* Accept new baselines

* Fix tests

* Add new tests

* Fix lint errors
2021-01-04 15:12:51 -10:00
Oleksandr T b405fdd2ab
fix(41420): forbid optional chain in extends/implements (#41481) 2021-01-04 15:38:54 -08:00
Ron Buckton 6fac3ddfd4
Fix module resolution for import call emit (#41390) 2021-01-04 15:08:57 -08:00
Oleksandr T 841b1a5bc7
fix(37791): fix incorrect private field access in a computed property name (#38135) 2021-01-04 14:01:54 -08:00
Oleksandr T e108257fb6
fix(41965): fix error in definite assignment assertion context (#41989) 2020-12-30 11:45:18 -08:00
Oleksandr T 303ed3a357
fix(42099): fix JSDoc optional properties declaration emit (#42116) 2020-12-28 13:34:55 -08:00
Oleksandr T a763600cc4
fix(41818): use last JSDoc comment related to host (#41858) 2020-12-18 13:24:58 -08:00
Ron Buckton 4239904517
Report implicit any error for 'yield' result with no contextual type (#41348) 2020-12-18 09:55:33 -08:00
Ron Buckton e789cb1356
Fix single-line comment disrupting return w/optional chain (#42026) 2020-12-17 18:55:09 -08:00
Anders Hejlsberg ee1f262698
Template literal types for template literal expressions (#41891)
* Infer template literal types for template literal expressions

* Update test

* Update another test

* Accept new baselines

* Minor fixes

* Add tests

* Accept new baselines

* Make new TypeFlags internal

* Accept new API baselines

* Ensure template literals assignable to String, Object, {}, etc.

* Add tests
2020-12-11 15:07:37 -10:00
Wesley Wigham 69143ecc5b
Reuse input nodes where possible when serializing jsdoc implements clauses (#41783)
* Reuse input nodes where possible when serializing jsdoc implements clauses

* Whitespace changes, per PR feedback
2020-12-08 12:13:37 -08:00
Wesley Wigham 360958e04c
JSDoc declaration emit should reuse input nodes where possible when serializing typedefs (#41760)
* JSDoc declaration emit should reuse input nodes where possible when serializing typedefs

* Style comments
2020-12-04 13:42:35 -08:00
Anders Hejlsberg cd37a327a7
Fix non-homomorphic mapped type constraint issues (#41807)
* Less aggressive wildcard check, 'keyof any' constraint for 'infer T' in mapped type constraint position

* Accept new baselines

* Add regression tests
2020-12-03 16:36:45 -10:00
Armando Aguirre 143d1104ab
Merge pull request #41703 from a-tarasyuk/fix/41653
fix(41653): Enum Keys in Destructure Prevents ES6 Function Convert with --target ES5
2020-12-03 16:10:51 -08:00
Ron Buckton 324f0469c0
Merge pull request #41791 from microsoft/fix40643
Reuse temp variable scope for converted loop body
2020-12-03 13:33:09 -08:00
Andrew Branch 69bc3f3b0c
Allow type-only imports on ImportEqualsDeclarations (#41573)
* Allow type-only ImportEqualsDeclarations

* Suppress CJS-in-ESM error when type-only

* Add grammar error on import type in import alias

* Update API baselines

* Fix importsNotUsedAsValues with ImportEqualsDeclarations

* Make bad error talk words more good for Daniel. Fixes #41603

* One more error message baseline update

* Update transformer and emitter
2020-12-03 13:27:15 -08:00
Ron Buckton 27dc177f29 Reuse temp variable scope for converted loop body 2020-12-02 18:11:45 -08:00
Wesley Wigham 9f9eed400c
Read the base construct signature from the static base type, not the instance base (#41767) 2020-12-02 13:30:46 -08:00
Anders Hejlsberg 4d6947ae14
Check nested conditional types for non-distributiveness in mapped types with 'as' clauses (#41713)
* Check nested conditional types for non-distributiveness

* Rename to maybeNonDistributiveNameType

* Add regression test
2020-12-01 12:07:47 -10:00
Anders Hejlsberg 4782c74b75
Propagate wildcard types in non-homomorphic mapped types (#41622)
* Propagate wildcard types in non-homomorphic mapped types

* Add regression test

* Accept new baselines

* Accept new baselines
2020-12-01 11:57:00 -10:00
Toan Nguyen 0c76803854
Fix typos in comments (#41307)
* Fix typo fuction -> function

* Fix typo assignement -> assignment
2020-11-30 15:02:07 -08:00
Oleksandr T 3a903b8a28 fix(41653): convert arrow function to function expression that used as destructure initializer 2020-11-26 21:19:15 +02:00
Anders Hejlsberg 411c6d04c6
Fix getTypeFacts for pattern template literal types (#41693)
* Normalize `${string}` to just string, fix getTypeFacts

* Add tests

* Accept new baselines
2020-11-26 06:55:01 -10:00
Nathan Shively-Sanders 9fb6acf1e1
Add missed resolveSymbol in commonjs import resolution (#41479)
Fixes resolution of export aliases in the postfix-property-access case
of commonjs require:

```js
const { x } = require('./foo').nested
x
```

This program would previously fail if `x` was an export alias.

Fixes #41422
2020-11-10 11:28:49 -08:00
Oleksandr T 45b698b3f6
fix(40632): skip emitting abstract members (#40699) 2020-11-04 16:02:17 -08:00
Thomas Williamson 8ed251d0c7
Support xml namespace prefix for JSX elements and attributes (#37421)
* Support xml namespace prefix for JSX elements and attributes

Just as with the `-` character, `:` is now also treated specially in JSX
element and attribute names, but is only allowed a single time, and not
at the beginning or end of the name, as is specified in the JSX spec.
All tests in jsxInvalidEsprimaTestSuite still fail, but for slightly
different reasons now. Two lines in jsxEsprimaFbTestSuite were
uncommented as they included elements with namespaces, and they now pass
without error.

* Add case for colons at ends of identifier

* Add case for jsx namepsace intrinsics

* Add cases with upcase idents for jsx namespaces

* Add case for jsx namespaces with react option

* Always consider jsx names with colon to be intrinsics

* Adjust comment about chars valid in jsx names but not js idents

* Fix minor typo in namespace prefix test case variable name

* Remove misleading comments on isUnhyphenatedJsxName
2020-11-02 15:34:36 -08:00
Wenlu Wang ce8d702586
Add support for pedantic property access (#40171)
* Add support for pedantic property access

* accept baseline

* Update diag message

* Avoid pedantic

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2020-11-02 15:19:00 -08:00
Ron Buckton f944afd053 Fix double alias of complex export/import/default/namespace combination 2020-10-29 18:42:36 -07:00
Ron Buckton bcbe1d7638
Merge pull request #41094 from microsoft/destructuringEvaluationOrder
Fix destructuring evaluation order for initializers
2020-10-29 17:12:18 -07:00
Ron Buckton 2b7e790732 Update control flow for nested binary exprs 2020-10-29 13:32:32 -07:00
Ron Buckton 8a15291541 Update control flow for correct destructuring evaluation order 2020-10-28 16:50:15 -07:00
Wesley Wigham ca8a15d37b
Merge pull request #41287 from weswigham/bind-exports-assigned-object-as-alias
Bind `module.export = {Thing}` with alias symbols
2020-10-28 13:14:20 -07:00
Oleksandr T af38ab90e2
feat(41249): allow import.meta with module: es2020 (#41274) 2020-10-27 17:26:15 -07:00
Anders Hejlsberg 40b81224f9
Remove string literals from unions with matching template literals (#41276)
* Remove string literals from unions with matching template literals

* Add tests

* Accept new baselines
2020-10-27 16:21:07 -07:00
Wesley Wigham d1bc6b1ba6
Bind module.export = {Thing} with alias symbols 2020-10-27 15:43:00 -07:00
Wesley Wigham 94b0e0e389
Merge pull request #41190 from weswigham/handle-binding-element-aliases
Handle the new js binding element alias symbols in JS declaration emit
2020-10-23 10:31:08 -07:00