* feat: support error when comparing with object/array literals
* chore: include regexp, function and class literal
* chore: include regexp, function and class literal
* test: update baseline
* fix: baseline
* Allow export map entries to remap back to input files for a program
* Fix file casing issues on windows
* Implement abiguity error, doesnt quite work
* Refine selection logic in error case to use getCommonSourceDirectory, add more tests
* Remove Node12, add Node16.
* Accepted baselines.
* Refactor checking for top-level await, give a better error message in CJS files.
* Accepted baselines.
* Stop erroring on JSON module imports in node ESM since they're no longer experimental.
* Accepted baselines.
* More refactoring, do the same checks for for-await loops.
* Accepted baselines.
* Adjust phrasing to permit for-await on CJS error.
* Accepted baselines.
* Accepted baselines.
* Fix lints.
* change error message on Promise
* fix(46570): Unhelpful Promise type argument hint in JS file
* refactor: Reword void Promise message for JSDoc type hint to provide better feedback
Co-authored-by: Osa <osaimola@gmail.com>
* Add 'extends' clause to 'infer' type
* Revise parse for infer..extends, improve parenthesizer
* More aggressive parens to match existing DT tests
* tests 'infer' constraint using outer type parameter
* Adds a test showing 'infer' cannot reference other 'infer' in same 'extends'
* Emit extends clause for synthetic infer typesduring declaration emit
* Add moduleSuffixes compiler option and related tests. Update baselines for compiler options tests.
* Add a flag to the command-line parser which allows "list" params to preserve "falsy" values such as empty strings. Falsy values are normally stripped out.
* Add tests. Rework resolver logic to only run module-suffix code when needed.
* PR feedback
* Add test
* Remove unnecessary conditional.
* Simplify getVariancesWorker and associated logic
* Accept new API baselines
* Add 'in' and 'out' modififers / add modifiers to type parameters
* Check variance annotations
* Update test runner
* Accept new API baselines
* Allow variance annotations only on certain type parameters
* Add deprecated implementation of createTypeParameterDeclaration
* Accept new API baselines
* Report variance markers as 'sub-XXX' and 'super-XXX'
* Add tests
* Accept new baselines
* Add isolatedModules error for ambiguous imports referenced in decorator metadata
* Improve test and accept baselines
* Error only for es2015+
* Add namespace import to error message as workaround
* Add codefix
* Fix merge fallout
* Add moduleDetection compiler flag to allow for changing how modules are parsed
The default setting is 'auto', where JSX containing files under react-jsx and react-jsxdev are
always parsed as modules, and esm-format files under module: node12+ are always parsed as modules,
in addition to the 'legacy' detection mode's conditions for other files. (Declaration files are exempt from
these new conditions)
The 'legacy' mode preserves TS's behavior prior to the introduction of this flag - a file is
parsed as a module if it contains an import, export, or import.meta expression.
In addition, there is a 'force' mode that forces all non-declaration files to be parsed as modules.
(Declaration files are still only modules if they contain a top-level import or export.)
This technically breaks the parser API, but it's kinda-sorta backwards compatible so long
as you don't need the functionality associated with more recent compiler flags.
* Fix post-merge lint
* Rename function
* Update default value documentation
* PR feedback
* Fix lint and typo
* Add import assertions for type-only imports and import types to change resolver modes
* By popular request, only allow mode assertions on top-level type only imports
* Add specifier options parameter to specifier generation
* Permit type arguments in references to generic functions
* Accept new baselines
* Delete pointless fourslash test
* Fix lint issue
* Finalize implementation
* Add tests
* Accept new baselines
* Properly handle instantiation of instantiation expression types
* Accept new API baselines
* Fix lint error
* Add more tests
* Properly handle unions/intersections of generic types
* Add more tests
* More permissive parsing of type arguments in member expressions
* Update tests
* Accept new baselines
* Triple-slash reference type directives can override the import mode used for their resolution
They now use the file's default mode by default, rather than always using commonjs. The new arguments to the
reference directive look like:
```ts
///<reference types="pkg" resolution-mode="require" />
```
or
```ts
///<reference types="pkg" resolution-mode="import" />
```
* Omit redundant import modes in emitter
* Add test for #47806
* Add server test for triple-slash reference mode overrides
* Move FileReference mode into helper
* Update tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeOverride3.ts
Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
* Eliminate redundant or meaningless elaborations in type relations
* Accept new baselines
* Add resetErrorInfo (though, oddly, shouldn't be necessary)
* Less aggressive reduction in second pass union/intersection checks
* Accept new baselines
* Restructure and back off a little bit more
* Only cache union/intersection relations once
* Accept new baselines
* Properly cache identity relations, clean up error reporting
* Move more logic to cached side of relation checks
* Optimize and remove more redundant elaborations
* Accept new baselines
* Remove unnecessary error state capture
* More optimizing
* Cache isWeakType computation
* Revert "Cache isWeakType computation"
This reverts commit 25a71c4de61f6366ffac080d19685dcb200f42b9.
* Address CR feedback
* Accept new baselines
* Fix error term of declaration in modules
* fix test
* change error code of "An import declaration can only be used at the top level of a module."
* Separate js and ts files for export errors in module.
* Change non-top-level error in namespace
* format
Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
* Import fix
* Wire up completions, add sorting to fix
* Fix overlapping changes when there’s only one import specifier
* Update API baseline
* Add sorting and filtering back to UMD fix
* Use relative paths for the end of compile report
* Have a tighter suffix for multiple errors in one file
* Review feedback
* Refactors, and adds color
* Update baselinies
* Allowed non-this, non-super code before super call in derived classes
Fixes#8277.
It feels wrong to put a new `forEachChild` loop in the checker, though in the vast majority of user files this will be a very quick one. Is there a better way to check for a reference to `super` or `this`?
* Used new isNewThisScope utility and dummy prop in baselines
* Accounted for parameters and get/set accessor bodies
* Accounted for class extensions
* (node|statement)RefersToSuperOrThis wasn't checking root level scope boundaries
```ts
function () {
return this;
}
```
It was immediately going to `ts.forEachChild` so the statement itself wasn't being counted as a new `this` scope.
* Better 'references' name and comments; accounted for more method edge case
* Limited super calls to root-level statements in constructor bodies
As per discussion in the issue, it would be ideal to consider any block that always ends up calling to super() the equivalent of a root-level super() statement. This would be valid:
```ts
foo = 1;
constructor() {
condition() ? super(1) : super(0);
this.foo;
}
```
...as it would compile to the equivalent of:
```ts
function () {
condition() ? super(1) : super(0);
this.foo = 1;
this.foo;
}
That change would a bit more intense and I'm very timid, so leaving it out of this PR. In the meantime the requirement is that the super() statement must itself be root-level.
* Fixed error number following 'master' merge
* Added decorator test cases
* Again allowed arrow functions
* Accepted new baselines
* Added allowance for (super())
* Reworked emitter transforms for ES this binding semantics
In trying to adjust to rbuckton's PR feedback, this orders derived class constructor bodies into five sections:
1. Pre-`super()` code
2. The `super()` call itself
3. Class properties with initializers
4. Parameter properties
5. The rest of the constructor
I've looked through the updated baselines and it looks like they're generally better than before. Within the existing test cases that result in semantic errors for `this` access before `super`, several previously resulted in a global `_this` being created; now, they correctly defer referring to `_this` until it's assigned to `_super.call(this) || this`.
* Used skipOuterExpressions when diving for super()s; fix prop ordering
* Allow direct var _this = super() when no pre-super() statements; lint fixes
* Always with the TSLint
* One last touchup: skipOuterExpressions in es2015 transformer
* Fixed new lint complaint in utilities.ts
* Again added a falls-through; it'd be swell if I could run linting locally
* This time I think I got it
* Well at least the error is a different one
* Undid irrelevant whitespace changes
* Mostly addressed private/field issues
* Accepted derivedClassSuperProperties baseline
* Lint fix, lovely
* Remove now-unnecesary comment
* First round of feedback
* Moved prologue statements to start of statements
* Added consideration for super statements in loops and the like
* Ordering and a _this_1 test
* Missed the one change I needed...
* First round of feedback corrections
* Feedback round two: statements
* Feedback: used more direct statements
* Fixed classFields emit to not duplicate temp variables
* Refactored es2015 helper to be less overloaded
* Accounted for parentheses
* Simpler feedback: -1, and emptyArray
* Next feedback: superStatementIndex
* Feedback: simplified to no longer create slice arrays
* Adjusted for default and rest parameters
* Added test case for commas
* Corrected comment ranges
* Handled comments after super, with tests
* Fixed Bad/Late super baselines
* Remove unused param and unnecessary baseline comments
Co-authored-by: Orta Therox <orta.therox@gmail.com>
Co-authored-by: Ron Buckton <ron.buckton@microsoft.com>
* Error on mapped types with properties
1. Error on properties of type literals with computed properties whose name is a
binary expression with `in`, because that's a good sign of a mapped
type.
2. Parse following properties on mapped types, and error on them.
3. Stop checking computed property names in (1) to avoid producing
errors based on misinterpreting mapped type syntax as an expression.
* add comment in types.ts
* Update API again
* Check interfaces and classes too
* Add missed check in updateMappedTypeNode