* chore: failing test for const enums and isolatedModules
* fix: const enums + isolatedModules emit invalid code
In `isolatedModules` mode, the compiler does not inline const enums,
but also decides not to `import` them, leaving invalid code that
throws a `ReferenceError` at runtime.
This code:
```
import { SomeEnum } from './bar';
sink(SomeEnum.VALUE);
```
..should compile to either:
```
var { SomeEnum } = require('./bar');
sink(SomeEnum.VALUE);
```
..or (with const enum inlining):
```
sink(1 /* VALUE */);
```
..but actually compiles to:
```
sink(SomeEnum.VALUE);
```
..with no imports, which throws a ReferenceError at runtime.
---
The compiler has already realised that the symbol is a referenced const
enum, it just doesn't use this information when it comes to deciding
whether to emit an import. This commit additionally checks that
information, if we are compiling in isolatedModules mode.
---
In my opinion, this is not the correct fix, but it is the simplest. In
`isolatedModules` mode, `const enum` should probably be a compile error
(because there are no benefits and the complexity is high, and,
apparently, buggy). If not, the compiler should not be checking whether
something is a const enum, and should just be treating it as a regular
enum, and checking as if it was?
Fixes#40499.
* chore: extra test for type-only
* feat: explicitly ban --isolatedModules --preserveConstEnums false
* feat: isolatedModules implies preserveConstEnum
* Update src/compiler/diagnosticMessages.json
Co-authored-by: Andrew Branch <andrewbranch@users.noreply.github.com>
* chore: compiler test for argument incompatibility
* Add and fix test for namespace import of const enum
* Fix additional bug with reexport of const-enum-only module
Co-authored-by: Andrew Branch <andrewbranch@users.noreply.github.com>
Co-authored-by: Andrew Branch <andrew@wheream.io>
* Create symlink cache when a pnpm module is found
* Keep pnpm-internal symlinks out of the symlink cache
* Filter out pnpm path from realpath module specifier too
* Use ignoredPaths instead of pnpm-specific path
hasNonBindableDynamicName
1. Has 'non' in the name, and is only ever used negated.
2. Is true for a case that's not reflected correctly in the name -- it's
true for non-dynamic names as well.
I considered hasEarlyOrLateBindableName, but decided to use
hasBindableName for now.
* 'in' should not operate on primitive types
* accept baselines of failing tests
* review
* update error message
* check if constraint of right type is assignable to a non primitive or instantiable non primitive
* do not throw errors where narrowing is impossible
* accept baselines
* fix test case failures
* Add more accurate comment discussion and document failing edge case in test
* Update baselines
Co-authored-by: Jonas Hübotter <jonas.huebotter@gmail.com>
* New aliases for type alias instantiations
* New aliases for conditional, mapped, and anonymous object type instantiations
* Accept new baselines
* Fix issues with re-aliasing
* Accept new baselines
* Create separate types for equivalent aliased unions
* Accept new baselines
* Preserve original types for union types
* Accept new baselines
* Preserve intersection origin for union types
* Accept new baselines
* Accept new baselines
* Preserve aliases during relationship checks
* Accept new baselines
* Preserve aliases for intersection and indexed access types
* Accept new baselines
* Compute intersection-of-unions cross product without recursion
* Accept new baselines
* Use denormalized type objects for origin / support 'keyof' origins
* Accept new baselines
* Fix fourslash test
* Recursively extract named union types
* Accept new baselines
* Map on union origin in mapType to better preserve aliases and origins
* Remove redundant call
* Accept new baselines
* Revert back to declared type when branches produce equivalent union
* Accept new baselines
* Don't include denormal origin types in regular type statistics
* Fix issue with unions not being marked primitive-only
* Allow new alias to be associated with type alias instantiation
* Accept new baselines
* Revert "Accept new baselines"
This reverts commit 4507270cc1.
* Revert "Allow new alias to be associated with type alias instantiation"
This reverts commit 2c2d06dfe1.
* feat(26217): Add missing function declaration QF
* use codeFixAvailable instead of codeFix
* add diagnostics messages 'Method not implemented.' and 'Function not implemented.'
* use codeFixAvailable instead of codeFix
* fix signature types
* Test case where the wrong path is emitted
* If import is used in the file, prefer that import specifier over calculating new one
Fixes#39117
* Update Baselines and/or Applied Lint Fixes
* When non-relative path is used as user preference, ignore relative paths even if they are from the existing file
* Fix test
* Add comment
Co-authored-by: TypeScript Bot <typescriptbot@microsoft.com>
* Add support for abstract constructor types
* Add backwards-compatible overloads for creating/updating constructor types
* Reverting use of 'abstract' in lib/es5.d.ts due to eslint issues
* Update baseline due to reverting lib
* Add error for failing to mark an mixin class as abstract
* Fix declaration/quick info for abstract construct signatures
* Support starting and middle rest elements in tuples
* Accept new baselines
* Include all rest arguments in error span
* Accept new baselines
* Fix tests
* Add new tests
* Fix lint errors