TypeScript/tests/cases/conformance
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
..
ambient
async Prevent substitution of 'super' in async super helper 2019-03-19 11:35:18 -07:00
classes Add regression test 2019-02-05 13:08:18 -08:00
constEnums allow const enum in type query (#21083) 2018-01-09 09:24:00 -08:00
controlFlow Elt access assignment uses declared, not narrowed type (#27574) 2018-10-05 11:30:10 -07:00
declarationEmit improve stripInternal with inline comments (#23611) 2019-03-12 13:14:47 -07:00
decorators Adjust offset to account for 'this' parameter when emitting parameter decorators 2019-03-19 11:46:18 -07:00
dynamicImport Unpatch vfs resolver and default lib rename 2018-05-03 14:18:50 -07:00
emitter Merge branch 'master' into es2019 2019-02-07 10:08:26 +09:00
enums disallow nan and infinity in enum member 2018-05-04 10:28:59 +08:00
es6 add related error span for default exports (#25396) 2019-03-12 13:15:14 -07:00
es7 Allow trailing commas after-rest elements in destructuring 2018-06-04 14:58:30 -07:00
es2017 Fix #21089: Do not infer from numeric index signature in Object.values and Object.entries (#21129) 2018-01-17 14:16:11 -08:00
es2018 Change esnext.promise to es2018.promise (#22292) 2018-03-02 17:08:36 -08:00
es2019 Forbid accessing block-scoped variables on globalThis (#30510) 2019-03-25 14:07:48 -07:00
expressions Giving too many arguments should error on the first argument that exceeds arity (#27982) 2019-03-12 15:57:12 -07:00
externalModules fix export class declare with name object targeting es5 (#17494) 2018-05-24 18:16:38 +08:00
functions Add tests 2018-12-10 09:45:55 -08:00
interfaces fix #20018, allow skip constraint when merging interfaces 2017-12-24 17:05:05 +08:00
internalModules
jsdoc Add more tests for qualified name param without top level object error 2019-01-10 15:04:16 -08:00
jsx Fake up value declaration for synthetic jsx children symbol so they get excess property checked (#29359) 2019-01-15 22:31:57 -08:00
moduleResolution Support loading "index.d.ts" using "typesVersions" without "types", "typings", or "main" (#27514) 2018-10-03 11:44:16 -07:00
parser Remove ES2018 transforms for ES2018 target (#26315) 2019-02-06 15:35:52 -08:00
references
salsa Add globalThis (#29332) 2019-02-27 14:14:34 -08:00
scanner include leading non-ASCII horizontal whitespace in SyntaxKind.WhitespaceTrivia token 2018-08-25 13:15:56 -04:00
statements add grammar check for labeled declaration (#25317) 2018-07-18 15:37:27 -06:00
Symbols
types Add regressions for conditional types that affect parameter variance (#30146) 2019-02-28 16:14:16 -08:00
typings Only suggest adding to types if present in compilerOptions 2018-10-30 21:31:22 +01:00
fixSignatureCaching.ts Property assignments in Typescript (#26368) 2018-08-15 15:25:25 -07:00