Commit graph

109 commits

Author SHA1 Message Date
ExE Boss 1d8398265a fix(lib): Loosen Array predicate return types (#31076)
* fix(lib): Loosen `Array` predicate return types

* test(lib): Update baseline files
2019-04-30 09:47:13 -07:00
Forbes Lindesay 3ce3cde493 Allow Boolean() to be used to perform a null check (#29955)
* Allow Boolean() to be used to perform a null check

* Add missing test case output
2019-04-30 08:09:31 -07:00
Clay Miller d934401265 Change the type of 'uriComponent' (passed to 'encodeURIComponent') from 'string' to 'string | number | boolean'. Fixes #18159 (#31103)
- According to the ECMAScript 5.1 spec (§15.1.3.4), 'encodeURIComponent' invokes the abstract operation 'ToString': https://www.ecma-international.org/ecma-262/5.1/#sec-15.1.3.4
- In the spec (§9.8), 'ToString' accepts an 'Undefined', 'Null', 'Boolean', 'Number', 'String' or 'Object' argument: https://www.ecma-international.org/ecma-262/5.1/#sec-9.8
- TypeScript’s 'StringConstructor' accepts an argument with type 'any': b0100100a1/lib/lib.es5.d.ts (L518)
2019-04-26 13:07:14 -07:00
Daniel Rosenwasser 57938e6cc2 Make Omit alias its own mapped type so that references to it never expand to Pick<...>. 2019-04-24 16:57:20 -07:00
Jordan Harband d4ff58d53f [fix] ES5 Object.keys only accepts an object (#27089) 2019-04-24 10:18:31 -07:00
Daniel Rosenwasser 13d2b8d617 Add the Omit helper type. 2019-04-04 10:01:34 -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
Ryan Cavanaugh 4ff71ecb98
Merge pull request #29696 from Microsoft/filter-unknown
Use unknown for array predicates' return types
2019-02-04 13:26:29 -08:00
Anders Hejlsberg f86b635122
Merge pull request #29705 from Microsoft/fixParametersAndReturnType
Less restrictive Parameters<T> and ReturnType<T>
2019-02-04 12:08:29 -08:00
Ryan Cavanaugh 0a041ee536
Merge pull request #28270 from AnyhowStep/json-parse-reviver-stringify-replacer-better-declaration
JSON.parse(), JSON.stringify() more specific declarations for #6955
2019-02-02 12:10:56 -08:00
Anders Hejlsberg e7ad76ddc8 Less restrictive constraints in Parameters and ReturnType types 2019-02-02 09:28:21 -08:00
Ryan Cavanaugh efbe630a13
Use unknown for array predicates' return types 2019-02-01 17:05:04 -08:00
Ryan Cavanaugh d85c4e551e
Merge pull request #27121 from xl1/26977-typedarray
Allow non-number source for TypedArray.from
2019-01-24 13:42:43 -08:00
Anders Hejlsberg 9cc997fca7 Improve typing of 'bind' method on function types 2018-12-08 11:02:19 -08:00
AnyhowStep dd3ed02868 Removed stray whitespace 2018-11-13 12:24:03 -05:00
AnyhowStep 01e71820fc Fixes Microsoft/TypeScript#6955 2018-10-31 17:00:24 -04:00
Basarat Ali Syed c86b9ca660
📝 Better description of Pick mapped type
closes https://github.com/Microsoft/TypeScript/issues/25976
2018-10-03 10:57:43 +10:00
xl1 9819b6b7aa Allow non-number array for source of TypedArray.from 2018-09-15 23:00:01 +09:00
Anders Hejlsberg df1e33a8a5 Add 'bind' overloads for rest parameter arrays 2018-09-12 13:17:11 -07:00
Anders Hejlsberg a5dece30d9 Update declarations 2018-09-11 06:14:41 -07:00
Anders Hejlsberg 55b6513078 New CallableFunction and NewableFunction types in es5.d.ts 2018-09-10 15:12:42 -07:00
Nathan Shively-Sanders c929e74310
Add [Constructor]Parameter types to lib.d.ts (#26243) 2018-08-31 07:46:16 -07:00
Daniel Rosenwasser b8ca925de0 Place 'pop' first in 'Array'. 2018-07-10 19:34:19 -07:00
Wesley Wigham 616e6e6ca3
Move symbol instance type to es5 to follow PropertyKey (#23864)
* Move symbol instance type to es5

* Accept baseline changes from moving Symbol
2018-05-03 10:50:10 -07:00
Daniel Rosenwasser 9672116d8c Merge remote-tracking branch 'origin/master' into importDotMeta 2018-04-25 22:21:56 -07:00
Daniel Rosenwasser a55febda77 Make 'ImportMeta' more minimal. 2018-04-24 12:38:42 -07:00
Anders Hejlsberg 16cd5580a6 Merge branch 'master' into improveIndexTypes
# Conflicts:
#	src/compiler/checker.ts
#	src/server/utilities.ts
2018-04-16 16:18:29 -07:00
Daniel Rosenwasser f0081f0a04 Basic checking for 'import.meta'. 2018-04-10 12:59:03 -07:00
Anders Hejlsberg 68ce69a351 Move 'PropertyKey' from es2015.core.d.ts to es5.d.ts 2018-04-09 07:45:55 -10:00
Holger Jeromin c3d8ec0ee2
refactor: use union type in DateConstructor 2018-04-06 11:27:20 +02:00
Priyantha Lankapura 80464e8ff1 fix typo in intellisense (#21914) 2018-02-13 18:52:33 -08:00
Anders Hejlsberg 2cc1d735ec Add Required<T> to lib.d.ts 2018-02-13 06:47:52 -08:00
Anders Hejlsberg 2aba29fc32 Add Exclude, Extract, NonNullable, ReturnType, and InstanceType types 2018-02-09 14:22:46 -08:00
Nathan Shively-Sanders be0fcd5174
Array.concat now takes ConcatArray, not ReadonlyArray (#21462)
* Overloads in Array.concat now handle ReadonlyArray

Previously it was union types, which is slower.

* Make arrayConcat3 test stricter

* Switch to InputArray instead of adding overloads

* Update baselines

* Update baselines correctly

* Rename to ConcatArray and add slice method

Should make it, respectively, easier to understand this specific type
and harder to satisfy it by mistake.
2018-02-02 13:20:40 -08:00
Ryan Cavanaugh 100262537a Remove TODO 2017-12-13 10:58:04 -08:00
Daniel Rosenwasser 53657069bc
Merge pull request #20517 from gagoman/16900
fix docs for Math.ceil and Math.floor (#16900)
2017-12-07 16:56:27 -08:00
Andy 5e5b7706e5
Hack to allow concat to work even when an Array isn't assignable to ReadonlyArray (#20455) 2017-12-07 12:15:12 -08:00
Alex Khomchenko d383f18d72 fix docs for Math.ceil and Math.floor (#16900) 2017-12-06 22:53:42 +01:00
Wilson Hobbs c2f0c580db add types for escape and unescape methods #18813 (#19015)
* add types for escape and unescape methods #18813
although the issue is marked working as expected, it is important to mention that most major browsers maintain support for escape and unescape, and some javascript codebases moving to typescript may have escape and unescape in them. They are valid JavaScript, and thus they should be included in the global definition.

* add escape and unescape types to lib in tests

* update tests to turn CI green
2017-11-13 10:37:54 -08:00
falsandtru d23e5f1ee2 Fix Array.{reduce,reduceRight} methods (#18987) 2017-10-09 17:11:31 -07:00
Adrian Leonhard 8c2d79caa6 TypedArrays: fixed find and findIndex callback param obj type. (#18493)
Fixes #18425.
2017-09-18 12:12:08 -07:00
Thomas den Hollander 1ee3b65141 Change typed array signatures (#18367) 2017-09-11 11:22:45 -07:00
Alex Chugaev de313ff1bd Object.getOwnPropertyDescriptor() returns 'undefined' if property descriptor not found. (#18148) 2017-09-07 10:58:05 -07:00
Mohamed Hegazy 562abf333a Follow up on #16223 cleaning up Array declarations (#18116)
* Follow up on #16223, Remove generic signatures from Array, ReadOnlyArray and TypedArrays

* Remove test

* Accept baselines

* Remove invalid `this: void` in callbacks

* accept baselines
2017-08-30 10:22:02 -07:00
Andy 54af8aa945 Array arguments to concat should be ReadonlyArrays (#17806) 2017-08-16 14:32:14 -07:00
Homa Wong e8f674fafb Update es5.d.ts 2017-07-18 00:58:05 -07:00
Mohamed Hegazy a3f39ece62 Fix #16521: mark thisArg as optional in typed array map function (#16526) 2017-06-14 11:58:21 -07:00
Mohamed Hegazy a76b4b1f28 Array cleanup (#16223)
* Fix for #13840: Remove map tuple overloads

* Coalesce signatures on array that use this args

* Remove generic signatures

* Add comments to toLocalString

* clean up typed array interfaces
2017-06-04 14:26:18 -07:00
Ron Buckton 578826cd61 Adds definitions for the es2017 Atomics global object 2017-05-10 17:19:26 -07:00
Reiner Dolp eb36455c8b fix issue 15275 2017-04-19 19:37:37 +01:00