* Import of Intl.Locale from #39664
* Handle updating es2020.intl and add es2021 for new DateTimeFormatOptions options - re: #39664
* Extends DateTimeFormatOptions for new Intl APIs - re: #45420
* Handle migrating Intl.NumberFormat.formatToParts to es2018 (keeping esnext.intl around)
* Adds Intl.DisplayNames to es2020 - re: #44022
* Remove attributes added in es2021 from es2020 - re: #42944
* Add a reference to es2021 in the command line parser
* Adds some docs about the lib files
* Baselines
* Allow undefined in Intl inputs to allow for ergonomic usage of exactOptionalPropertyTypes - see #45652
* Adds some tests covering the APIs
* Apply suggestions from code review
Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
* Handle PR feedback
* More review improvements
Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
* Fix check in hasNonBindingPatternContextualTypeWithNoGenericTypes
* Add regression tests
* Accept new baselines
* Compute both ObjectFlags.IsGenericXXXType flags in one go
* fix(35050): fix decorated block-scoped class emit
* Only use internal name when targeting ES5/3
Co-authored-by: Ron Buckton <ron.buckton@microsoft.com>
* Check entire access path is constant when narrowing by inlining
* Add tests
* Accept new baselines
* Added test cases for parameter properties.
* Accepted baselines.
Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
* CFA inlining of conditional expressions referenced by const variables
* Accept new baselines
* Add tests
* Accept new baselines
* Increase inlining limit to 5 levels per design meeting discussion
* Class static block (#9)
* Add types factory and parser
* Add some case
* Make class static block as a container
* Update cases
* Add visitor
* Add emitter and more compile target
* Check boundary of break and continue
* Add basic transformer
* Fix emit behavior
* Add more tests
* Add friend tests
* Update baseline
* Fix cr issues
* Accept baseline
* Add decorator and modifier check
* Add functional boundary check
* Fix conflict
* Fix computed prop name within context
* Add more tests
* Update baseline
* Avoid invalid test baseline
* Support use before initialize check
* wip
* Fix class static block context
* Fix checks
* Fix missing case
* Improve assert message
* Accept baseline
* Avoid new context
* Update diagnostic message
* Fix name collision
* Fix targets
* Avoid unnecessary files
* Add more case
* Add more test cases
* Fix strict mode function declaration
* Avoid private fields initializer if no private identifier references
* Avoid private fields and add more test case
* Add more case
* Add tests and support for related services functionality
* Fix this reference in static block
* Split parser diagnostic and binder diagnostic
Co-authored-by: Ron Buckton <ron.buckton@microsoft.com>
* Improve parsing in await and yield context
* Avoid yield and await check in identifier
* Revert "Avoid yield and awaitt check in identifier"
This reverts commit 9644859f29.
* Add some comments
* Switch index signature storage to 'indexInfos: IndexInfo[]' property
* Accept new baselines
* Remove another usage of IndexKind enum
* Update getIndexedAccessType and resolveMappedTypeMembers
* Accept new baselines
* Update grammar checking for index signatures
* Accept new baselines
* Consider all index signatures in mapped types and union types
* Accept new baselines
* Update getIndexType
* Accept new baselines
* Intersect multiple applicable index signatures
* Use getApplicableIndexInfo instead of hardwired string/number handling
* Update index signature relationship checking
* Report type for which index signature is missing
* Report type for which index signature is missing
* Accept new baselines
* Make 'number' index signatures consistently apply to numeric strings
* Accept new baselines
* Update fourslash test
* Revise index constraint checking
* Accept new baselines
* Update error messages
* Accept new baselines
* Update type inference from index signatures
* Update isKnownProperty
* Update contextual typing based on index signatures
* Accept new baselines
* Support union types in index signature declarations
* Accept new baselines
* Check duplicate index signatures / remove redundant template literals from unions with string
* Accept new baselines
* Include key type in diagnostic / check symbol-named properties
* Accept new baselines
* Minor fix
* Add tests
* Accept new baselines
* Add optimized findApplicableIndexInfoForName
* Accept new baselines
* Another place we don't need to obtain literal type for property name
* Accept new baselines
* Don't create literal types that are going to be discarded
* Individual maps for string, number, bigint, and enum literal types
* Remove ineffective optimizations
* Accept new baselines
* Permit intersections as key types in index signatures
* Index expression in element access is template literal context
* Add tests
* Accept new baselines
* Symbol index signatures from object literals with computed symbol properties
* Accept new baselines
* Add more tests
* Accept new baselines
* Implement Go To Definition for all applicable index signatures
* Add fourslash test
* Accept new API baselines
* Always issue cannot find name did-you-mean error
This PR issues "cannot find ${name}, did you mean ${name}" errors for
identifiers and propery access expressions in JS files *without*
`// @ts-check` and without `// @ts-nocheck`. This brings some benefits of
Typescript's binder to all Javascript users, even those who haven't
opted into Typescript checking.
```js
export var inModule = 1
inmodule.toFixed() // errors on exports
function f() {
var locals = 2
locale.toFixed() // errors on locals
}
var object = {
spaaace: 3
}
object.spaaaace // error on read
object.spaace = 2 // error on write
object.fresh = 12 // OK, no spelling correction to offer
```
To disable the errors, add `// @ts-nocheck` to the file. To get the
normal checkJs experience, add `// @ts-check`.
== Why This Works ==
In a word: precision. This change has low recall — it misses lots
of correct errors that would be nice to show — but it has high
precision: almost all the errors it shows are correct. And they come
with a suggested correction.
Here are the ingredients:
1. For unchecked JS files, the compiler suppresses all errors except
two did-you-mean name resolution errors.
2. Did-you-mean spelling correction is already tuned for high
precision/low recall, and doesn't show many bogus errors even in JS.
3. For identifiers, the error is suppressed for suggestions from global files.
These are often DOM feature detection, for example.
4. For property accesses, the error is suppressed for suggestions from
other files, for the same reason.
5. For property accesses, the error is suppressed for `this` property
accesses because the compiler doesn't understand JS constructor
functions well enough.
In particular, it doesn't understand any inheritance patterns.
== Work Remaining ==
1. Code cleanup.
2. Fix a couple of failures in existing tests.
3. Suppress errors on property access suggestions from large objects.
4. Combine (3) and (4) above to suppress errors on suggestions from other, global files.
5. A little more testing on random files to make sure that precision
is good there too.
6. Have people from the regular Code editor meeting test the code and
suggest ideas.
* all (most?) tests pass
* NOW they all pass
* add tonnes of semi-colons
* restore this.x check+add a test case
* make ts-ignore/no-check codefix work in unchecked js
* Issues errors only in the language service
* add a few more tests
* fix incorrect parentheses
* More cleanup in program.ts
* Improve readability of isExcludedJSError
* make diff in program.ts smaller via closure
* Switch unchecked JS did-you-mean to suggestion
Instead of selectively letting errors through.
* undo more missed changes
* disallow ignoring suggestions
* Issue different messages for plain JS than others
Straw text for the messages, I just changed the modals to avoid name
collisions.
* First draft
Everything works, the error messages for unmatched opening elements
could still use improvement, plus there is tonnes of unused and ugly
code.
1. Make sure the parser can recover from all kinds of unclosed tags.
2. Improve the parse tree for unmatched opening tags.
3. Better errors at some point.
* Lots of cleanup
* Improve readability of construction/fix lint
* improve line-length formatting
Previously, getExternalModuleMember passed through its received value of
`dontResolveAlias` to every function that accepted it. That includes (1)
resolution of the module symbol and (2) resolution of the module
specifier. However, in TS, the module symbol is never an alias anyway, so
dontResolveAlias doesn't make a difference. In JS, the module symbol
*can* be an alias, and it should always be resolved. That's what this PR
does.
Fixes#43713
* Scribbles + tests
The second test actually requires node types
* Basically working
The two simple fixes, in arity error reporting, are in, and the
simplification of arity error reporting is half-done. I haven't started
on any improvements to call assignability.
* trim out too-real test case
* Finish cleanup
And reword error a little.
* Simplify and reword spread errors
* handle spreads first
* update baselines
* Address PR comments