Commit graph

2583 commits

Author SHA1 Message Date
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
Ron Buckton 0b303ff08a Fix some rest cases and handling of unused results 2020-10-22 18:58:21 -07:00
Ron Buckton 28c4f32ddf Merge branch 'master' into destructuringEvaluationOrder 2020-10-22 17:14:23 -07:00
Anders Hejlsberg 5d021b401a
Don't reduce 'keyof M' for mapped types with non-distributive 'as' clauses (#41186)
* Don't reduce 'keyof M' for mapped types with non-distributive as clauses

* Add regression test

* Accept new baselines
2020-10-21 12:16:46 -07:00
Wesley Wigham f4255dd237
Handle the new js binding element alias symbols in JS declaration emit 2020-10-21 11:24:19 -07:00
Wesley Wigham 0ad22de146
Merge branch 'master' into fix/create-element-new-jsx-transform 2020-10-19 15:21:52 -07:00
Anders Hejlsberg 4638c685b1
Properly reduce intersections of string literal and template literal types (#41162)
* Properly reduce single element intersections

* Add regression test

* Accept new baselines
2020-10-19 13:05:29 -07:00
Mateusz Burzyński 43433eb2f1 Add tests related to the key prop when using new JSX transform 2020-10-17 15:20:39 +02:00
Ron Buckton 7393dba6bd Fix destructuring evaluation order for initializers 2020-10-13 17:14:35 -07:00
Nathan Shively-Sanders a109b5d5c8
Fix relative paths in commonjs decl emit w/property access (#40986)
```js
const x = require('./foo').y
```

was incorrectly using the unmangled require path as the temp name in
emit:

```
import ./foo_1 = require('./foo')
import x = ./foo_1.y
```

It now uses the imported identifier:

```
import x_1 = require('./foo')
import x = x_1.y
```

Discovered while fixing #37832
2020-10-09 16:32:57 -07:00
Nathan Shively-Sanders 4283428906
Fix export binding of namespaced typedefs (#40980)
The binder incorrectly rejected implicit namespace declarations in
typedefs.
2020-10-07 13:21:02 -07:00
Anders Hejlsberg f34220980b
Add isDeeplyNestedType logic to getResolvedBaseConstraint (#40971)
* Add isDeeplyNestedType logic to getResolvedBaseConstraint

* Accept new baselines

* Add regression test

* Accept new baselines

* Fix lint issue
2020-10-07 05:50:06 -07:00
Simon Chan fc0eed3795
lib: remove length field from SharedArrayBuffer (#40858)
* fix(lib): SharedArrayBuffer does not have a `length` field

* Revert formatting change.

* test: add tests for SharedArrayBuffer.length

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
2020-10-06 08:27:56 -07:00
Nathan Shively-Sanders 477e4b1a9d
Fix function merged with export as namespace sourcefile (#40908)
Previously it crashed because the function-checking code didn't expect
a node with no parent.
2020-10-02 10:50:12 -07:00
Nathan Shively-Sanders b8ebad48d7
Fix recursive types in @typedef (#40861)
* Fix reference types in @typedef

Previously this code path was broken and untested. Fortunately the fix
is simple.

* add test case from #40234

* update baselines
2020-10-02 08:46:42 -07:00
Wesley Wigham da86332120
Limit export= js declaration emit to only json source files (#40882) 2020-10-01 14:55:24 -07:00
Wesley Wigham 3ea81e652a
Ensure whitespace jsx elements are not counted when determining if a jsx child is the only child (#40839)
* Ensure whitespace jsx elements are not counted when determining if a jsx child is the only child

* Use filtered children count for deciding constructor used

* Accept updated baselines post-merge
2020-10-01 14:36:44 -07:00
Andrew Branch 5fbe9806db
Fix noUncheckedIndexedAccess with tuple rest types and generic index types (#40681)
* Fix noUncheckedIndexedAccess for tuple rest elements

* Defer inclusion of undefined for generic indexed access types

* Create separate IndexedAccessTypes depending on whether --noUncheckedIndexedAccess applies

* Undo accidental export

* Parenthesize for clearer precedence
2020-10-01 13:56:13 -07:00
Anders Hejlsberg 950dad9c29
Propagate wildcard types in template literal type construction (#40875)
* Propagate wildcard types in template literal type construction

* Add regression test

* Accept new baselines
2020-10-01 13:36:08 -07:00
Anders Hejlsberg 4538e7352f
Properly distribute over unions in keyof for mapped types with as clause (#40837)
* Properly distribute over unions in keyof mapped types with as clause

* Accept new baselines

* Add regression test

* Accept new baselines
2020-10-01 09:36:51 -07:00
Andrew Casey 35111231f7
Merge pull request #40755 from amcasey/SpreadLimit
Enforce a size limit in getSpreadType
2020-09-30 13:44:59 -07:00
Nathan Shively-Sanders f615e229d3
Fix default property assigned prototype (#40836)
* Fix default-property-assignment decls+prototype property decls

The check in getAssignedClassSymbol forgot to allow for default-property
assignment declarations, in part because it wasn't using a utility
function to do so.

* small cleanup

* make allowDeclaration parameter required
2020-09-30 08:36:52 -07:00
Wesley Wigham 2428ade1a9
Match suffix _after_ prefix when inferring literals out of templates (#40841) 2020-09-29 16:34:58 -07:00
Andrew Casey 6650496e85 Enforce a size limit in getSpreadType
When a union is spread into a union, the sizes are multiplied,
potentially resulting in an enormous union (especially if there are
repeated spreads).  This check detects cases that used to run out of
memory.

Fixes #40754
2020-09-24 14:52:42 -07:00
Wesley Wigham a960463cf3
Allow pattern literal types like http://${string} to exist and be reasoned about (#40598)
* Allow pattern literal types like `http://${string}` to exist and be reasoned about

* Allow bigint, number, null, and undefined in template holes

* Add test of the trivia case

* Handle `any` in template holes, add assignability rules for template -> template relations

* Explicitly test concatenated patterns

* PR Feedback
2020-09-23 01:08:58 -07:00
Wesley Wigham ad2a07440c
Fix crash on js declaration emit of export assigned default augmented function (#40596)
* Fix crash on js declaration emit of export assigned default augmented function

* {sp}
2020-09-23 00:50:12 -07:00
Anders Hejlsberg 5d6cce5ca7
Const contexts for template literals (#40707)
* Support const assertions with template literal expressions

* Add tests

* Accept new baselines
2020-09-22 13:11:17 -10:00
Alex T 0310b530d8
feat(40663/40664): improve error messages for assignment assertions '!' (#40669) 2020-09-21 11:20:01 -07:00
Anders Hejlsberg fbce4f6c98
Intrinsic string types (#40580)
* Introduce Uppercase<T> and Lowercase<T> intrinsic types

* Accept new API baselines

* Add Uppercase/Lowercase/Capitalize/Uncapitalize to lib.d.ts

* Update fourslash

* Add an 'intrinsic' keyword

* Update template literal type tests

* Accept new API baselines

* Minor fixes

* Switch Capitalize<T> and Uncapitalize<T> to intrinsic types

* Add tests

* Accept new baselines

* Accept new baselines

* Remove template literal type casing modifiers

* Update tests

* Accept new baselines

* Add more tests

* Normalize nested template literal types

* Add normalization tests

* Accept new baselines

* Update tests
2020-09-21 07:09:29 -10:00
Anders Hejlsberg ce3dbef5f7
Support properties of mapped types in assertion control flow analysis (#40482)
* Support properties of mapped types in assertion control flow analysis

* Add regression test

* Accept new baselines
2020-09-21 07:07:29 -10:00
Anders Hejlsberg 17c7c261d4
Properly preserve modifiers in homomorphic mapped types with 'as' clauses (#40633)
* Use original property name to fetch source property for modifiers

* Add regression test

* Accept new baselines
2020-09-19 06:12:39 -10:00
Hikari Hayashi f1ac8cd93f
Fix children prop for react-jsx and react-jsxdev (#40630)
* Fix children prop for `react-jsx` and `react-jsxdev`

* Add tests
2020-09-18 14:26:20 -07:00
Nathan Shively-Sanders ec36d73e7a
Fix error on duplicate commonjs exports (#40545)
* Fix error on duplicate commonjs exports

Previously, the code missed setting the parent pointer for the lhs
access expression.

Also add declaration emit of element access expressions, missed in my
previous PR.

* Switch to excludes=None, add test case

CommonJS exports have None excludes, but still have an error issued by
the checker. This is the previous behaviour even though it would be nice
to add some exclusions.
2020-09-14 13:12:51 -07:00
Anders Hejlsberg 57c8938d9e
Consistent inferences when inferring to template literal type (#40518)
* Consistently make inferences when inferring to template literal type

* Add tests

* Accept new baselines
2020-09-12 16:33:33 -10:00
Nathan Shively-Sanders 9c99870058
Support element access aliases: exports["x"] = x (#40514) 2020-09-11 18:05:47 -07:00
Anders Hejlsberg eee799fe0c
Properly check types in template literal placeholders (#40498)
* Properly check types in template literal placeholders

* Add regression test

* Update test

* Accept new baselines
2020-09-11 14:48:35 -10:00
Ryan Cavanaugh 3d235b42a0
--noUncheckedIndexedAccess (#39560)
* Initial implementation + tests

* linty

* Support destructuring declarations and assignments

* lint

* Fix destructuring assignment and element access into known properties

* Update baselines

* Rename flag to unUncheckedIndexedAccess

* Add test for unique symbol indexing

* Fix flag order in baselines

Co-authored-by: Andrew Branch <andrew@wheream.io>
2020-09-11 14:43:10 -07:00
Wesley Wigham a36f17c1f8
Add emit support for jsx/jsxs experimental jsx runtime api (#39199) 2020-09-11 10:44:52 -07:00
Andrew Branch 083129f005
A union including non-iterable types is not iterable (#40350)
* WIP

* If method type derives solely from the global iterator or generator type, use its type arguments

* Add test for problem fixed as side effect
2020-09-11 09:31:22 -07:00
Orta Therox cdafb7157b
Replaces the default module index resolver with '/index' instead of '' when handling internal routing for dts bundles (#39277)
* Adds support for declaring the bundled name of a dts module export

Co-authored-by: Wesley Wigham <wwigham@gmail.com>

* Adds baselines

* Update the tests

* Try to reduce the scope of the bundledPackageName error

* Use the flag in more baselines

* Get it green

* More tests

* Handle more feedback

* More test cleanup

* Set the moduleResolution for the tsconfigs

Co-authored-by: Wesley Wigham <wwigham@gmail.com>
2020-09-11 08:12:07 -04:00