Skip to content

Commit

Permalink
Fix base class TS namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
jasongin committed Aug 15, 2024
1 parent a14114e commit dd499be
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/NodeApi.Generator/TypeDefinitionsGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1897,9 +1897,12 @@ private string FormatTSType(
NullabilityInfo? nullability,
bool allowTypeParams = true)
{
// Types exported from a module are not namespaced.
string nsPrefix = !_isModule && type.Namespace != null ? type.Namespace + '.' : "";

string tsType = type.IsNested ?
GetTSType(type.DeclaringType!, null, allowTypeParams) + '.' + type.Name :
(type.Namespace != null ? type.Namespace + '.' + type.Name : type.Name);
nsPrefix + type.Name;

int typeNameEnd = tsType.IndexOf('`');
if (typeNameEnd > 0)
Expand Down
2 changes: 1 addition & 1 deletion test/TypeDefsGeneratorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public void GenerateGenericClass()
/** generic-class */
export class GenericClass$1<T> implements GenericInterface$1<T> {
/** constructor */
new(value: T): GenericClass$1<T>;
constructor(value: T);
/** instance-property */
TestProperty: T;
Expand Down

0 comments on commit dd499be

Please sign in to comment.