madskristensen / TypeScriptDefinitionGenerator

A Visual Studio extension
Other
85 stars 46 forks source link

New version generates "export" module instead of "declare" for PUBLIC classes, so interfaces become inaccessible. #52

Closed qazycat closed 3 years ago

qazycat commented 3 years ago

Installed product versions

Description

I was using generator 2 or more years. Probable Today i got new version of extension (it was set to autoupdate) and i found that i have problem, cause it works different from previous version. so what i have: MVC, C# project, apart ".CS" file, PUBLIC class, TypeScript Settings : "Generate in Global Scope" = flase, "Default Module Name": server

After i change C# class i got generated ".d.ts" file and i found that my project's ".ts" files don't see anymore imterface from this new-generated .d.ts file. ?! it was working before. i checked generated file: --> export module server { interface MyClassA { ... } } <-- !! before it was little bit different: --> declare module server { interface MyClassA { ... } } <--

==> so instead of "declare" now i see "export" => i can not access MyClassA from other .ts file now.

Ofcause i can modify generated .d.ts file by hands and replace export to declare, but ...

!! === > That happens ONLY if C# class is "PUBLIC"! If class is not PUBLIC i got "declare" and everething works ok.

Steps to recreate

  1. Create some C# class. Set it PUBLIC.
  2. DO "Generate TypeScript Definition"
  3. open any other .ts file and try to use interface from new-generated .d.ts -> it will be "undefined"

Current behavior

=> as i described before Because of "export", module interface can not be accesssed from other .ts files as before (may be could be used some additional import/include actions, but before it was working well)

Expected behavior

=> Should use "declare" instead of "export" as it was in previous version.