diff --git a/src/NodeApi.Generator/TypeDefinitionsGenerator.cs b/src/NodeApi.Generator/TypeDefinitionsGenerator.cs index 9c7b7ef0..e7342289 100644 --- a/src/NodeApi.Generator/TypeDefinitionsGenerator.cs +++ b/src/NodeApi.Generator/TypeDefinitionsGenerator.cs @@ -60,6 +60,7 @@ public enum ModuleType import dotnet from 'node-api-dotnet'; import * as path from 'node:path'; import { fileURLToPath } from 'node:url'; +// @ts-ignore - https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/65252 import { dlopen, platform, arch } from 'node:process'; const __filename = fileURLToPath(import.meta.url); @@ -92,6 +93,7 @@ function importAotModule(moduleName) { private const string LoadModuleCJS = @" const dotnet = require('node-api-dotnet'); const path = require('node:path'); +// @ts-ignore - https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/65252 const { dlopen, platform, arch } = require('node:process'); const moduleName = path.basename(__filename, __filename.match(/(\.[cm]?js)?$/)[0]); @@ -610,8 +612,14 @@ private IEnumerable GetExportedMembers() } } + /// + /// Generates a type definition for a single type. Primarily for unit-testing purposes. + /// public string GenerateTypeDefinition(Type type) { + // Don't use namespaces when generating a single type definition. + _isModule = true; + SourceBuilder s = new(); ExportType(ref s, type); return s.ToString(); diff --git a/test/TestCases/projects/js-esm-module/net472.js b/test/TestCases/projects/js-esm-module/net472.js index 1c0d9cc0..3a7b00fd 100644 --- a/test/TestCases/projects/js-esm-module/net472.js +++ b/test/TestCases/projects/js-esm-module/net472.js @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import 'node-api-dotnet/net472.js'; +import 'node-api-dotnet/net472'; import './test.js'; diff --git a/test/TestCases/projects/js-esm-module/net6.0.js b/test/TestCases/projects/js-esm-module/net6.0.js index 17517634..6f5a1b6c 100644 --- a/test/TestCases/projects/js-esm-module/net6.0.js +++ b/test/TestCases/projects/js-esm-module/net6.0.js @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import 'node-api-dotnet/net6.0.js'; +import 'node-api-dotnet/net6.0'; import './test.js'; diff --git a/test/TestCases/projects/js-esm-module/net8.0.js b/test/TestCases/projects/js-esm-module/net8.0.js index b5dbaa9d..7a6a34c7 100644 --- a/test/TestCases/projects/js-esm-module/net8.0.js +++ b/test/TestCases/projects/js-esm-module/net8.0.js @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import 'node-api-dotnet/net8.0.js'; +import 'node-api-dotnet/net8.0'; import './test.js'; diff --git a/test/TestCases/projects/ts-esm-module/net472.ts b/test/TestCases/projects/ts-esm-module/net472.ts index 1c0d9cc0..3a7b00fd 100644 --- a/test/TestCases/projects/ts-esm-module/net472.ts +++ b/test/TestCases/projects/ts-esm-module/net472.ts @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import 'node-api-dotnet/net472.js'; +import 'node-api-dotnet/net472'; import './test.js'; diff --git a/test/TestCases/projects/ts-esm-module/net6.0.ts b/test/TestCases/projects/ts-esm-module/net6.0.ts index 17517634..6f5a1b6c 100644 --- a/test/TestCases/projects/ts-esm-module/net6.0.ts +++ b/test/TestCases/projects/ts-esm-module/net6.0.ts @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import 'node-api-dotnet/net6.0.js'; +import 'node-api-dotnet/net6.0'; import './test.js'; diff --git a/test/TestCases/projects/ts-esm-module/net8.0.ts b/test/TestCases/projects/ts-esm-module/net8.0.ts index b5dbaa9d..7a6a34c7 100644 --- a/test/TestCases/projects/ts-esm-module/net8.0.ts +++ b/test/TestCases/projects/ts-esm-module/net8.0.ts @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import 'node-api-dotnet/net8.0.js'; +import 'node-api-dotnet/net8.0'; import './test.js';