TS: Using an exported class declaration locally in a type annotation
See original GitHub issueThe following snippet…
export class Foo<T = any> {};
let foo: Foo = new Foo();
let foo: Foo<any> = new Foo();
…compiles to…
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); class Foo {} exports.Foo = Foo;;
let foo = exports.Foo = new Foo();
let foo = new Foo();
Notice how exports.Foo
is being re-assigned. 😳
- sucrase v3.9.4
- node v11.3.0
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Documentation - Modules - TypeScript
Any declaration (such as a variable, function, class, type alias, or interface) can be exported by adding the export keyword. StringValidator.ts. ts. export...
Read more >Issue - GitHub
From what I've read in this issue, I just need to import the RedBN type to my example.ts ? But RedBN was declare...
Read more >How to use class returned by a function in type annotations?
When you declare a class with the class keyword, the compiler knows two things. That in the current scope there is a value...
Read more >A quick introduction to “Type Declaration” files and adding ...
In the Module System lesson, we learned how to share type declaration between modules using import/export statements. You can import a type ......
Read more >TypeScript - Modules - TutorialsTeacher
ts is a module which contains two variables and a class definition. The age variable and the Employee class are prefixed with the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yikes, thanks for the report. Here’s a slightly simpler test case:
Playground link
Nope, I say go for it. 🎉