diff options
11 files changed, 56 insertions, 0 deletions
diff --git a/cli/tests/integration/npm_tests.rs b/cli/tests/integration/npm_tests.rs index 722cbdb39..9e3ef5678 100644 --- a/cli/tests/integration/npm_tests.rs +++ b/cli/tests/integration/npm_tests.rs @@ -110,6 +110,20 @@ itest!(child_process_fork_test { http_server: true, }); +itest!(cjs_module_export_assignment { + args: "run -A --unstable --quiet --check=all npm/cjs_module_export_assignment/main.ts", + output: "npm/cjs_module_export_assignment/main.out", + envs: env_vars(), + http_server: true, +}); + +itest!(cjs_module_export_assignment_number { + args: "run -A --unstable --quiet --check=all npm/cjs_module_export_assignment_number/main.ts", + output: "npm/cjs_module_export_assignment_number/main.out", + envs: env_vars(), + http_server: true, +}); + // FIXME(bartlomieju): npm: specifiers are not handled in dynamic imports // at the moment // itest!(dynamic_import { diff --git a/cli/tests/testdata/npm/cjs_module_export_assignment/main.out b/cli/tests/testdata/npm/cjs_module_export_assignment/main.out new file mode 100644 index 000000000..7dfab41f1 --- /dev/null +++ b/cli/tests/testdata/npm/cjs_module_export_assignment/main.out @@ -0,0 +1,3 @@ +{ func: [Function: func] } +Module { default: { func: [Function: func] }, func: [Function: func] } +5 diff --git a/cli/tests/testdata/npm/cjs_module_export_assignment/main.ts b/cli/tests/testdata/npm/cjs_module_export_assignment/main.ts new file mode 100644 index 000000000..93d3db1c3 --- /dev/null +++ b/cli/tests/testdata/npm/cjs_module_export_assignment/main.ts @@ -0,0 +1,6 @@ +import defaultImport, * as namespaceImport from "npm:@denotest/cjs-module-export-assignment"; +import { func } from "npm:@denotest/cjs-module-export-assignment"; + +console.log(defaultImport); +console.log(namespaceImport); +console.log(func()); diff --git a/cli/tests/testdata/npm/cjs_module_export_assignment_number/main.out b/cli/tests/testdata/npm/cjs_module_export_assignment_number/main.out new file mode 100644 index 000000000..c808f4143 --- /dev/null +++ b/cli/tests/testdata/npm/cjs_module_export_assignment_number/main.out @@ -0,0 +1,3 @@ +5 +5 +Module { default: 5 } diff --git a/cli/tests/testdata/npm/cjs_module_export_assignment_number/main.ts b/cli/tests/testdata/npm/cjs_module_export_assignment_number/main.ts new file mode 100644 index 000000000..aee24bf19 --- /dev/null +++ b/cli/tests/testdata/npm/cjs_module_export_assignment_number/main.ts @@ -0,0 +1,7 @@ +import defaultImport, * as namespaceImport from "npm:@denotest/cjs-module-export-assignment-number"; + +const testDefault: 5 = defaultImport; +console.log(testDefault); +const testNamespace: 5 = namespaceImport.default; +console.log(testNamespace); +console.log(namespaceImport); diff --git a/cli/tests/testdata/npm/registry/@denotest/cjs-module-export-assignment-number/1.0.0/index.d.ts b/cli/tests/testdata/npm/registry/@denotest/cjs-module-export-assignment-number/1.0.0/index.d.ts new file mode 100644 index 000000000..0e1e0337d --- /dev/null +++ b/cli/tests/testdata/npm/registry/@denotest/cjs-module-export-assignment-number/1.0.0/index.d.ts @@ -0,0 +1,2 @@ +declare const value = 5; +export = value; diff --git a/cli/tests/testdata/npm/registry/@denotest/cjs-module-export-assignment-number/1.0.0/index.js b/cli/tests/testdata/npm/registry/@denotest/cjs-module-export-assignment-number/1.0.0/index.js new file mode 100644 index 000000000..f4e8d9d29 --- /dev/null +++ b/cli/tests/testdata/npm/registry/@denotest/cjs-module-export-assignment-number/1.0.0/index.js @@ -0,0 +1 @@ +module.exports = 5; diff --git a/cli/tests/testdata/npm/registry/@denotest/cjs-module-export-assignment-number/1.0.0/package.json b/cli/tests/testdata/npm/registry/@denotest/cjs-module-export-assignment-number/1.0.0/package.json new file mode 100644 index 000000000..4b2e3a294 --- /dev/null +++ b/cli/tests/testdata/npm/registry/@denotest/cjs-module-export-assignment-number/1.0.0/package.json @@ -0,0 +1,5 @@ +{ + "name": "@denotest/cjs-module-export-assignment-number", + "version": "1.0.0", + "types": "./index.d.ts" +} diff --git a/cli/tests/testdata/npm/registry/@denotest/cjs-module-export-assignment/1.0.0/index.d.ts b/cli/tests/testdata/npm/registry/@denotest/cjs-module-export-assignment/1.0.0/index.d.ts new file mode 100644 index 000000000..a7b50005e --- /dev/null +++ b/cli/tests/testdata/npm/registry/@denotest/cjs-module-export-assignment/1.0.0/index.d.ts @@ -0,0 +1,5 @@ +declare module ThisModule { + function func(): 5; +} + +export = ThisModule; diff --git a/cli/tests/testdata/npm/registry/@denotest/cjs-module-export-assignment/1.0.0/index.js b/cli/tests/testdata/npm/registry/@denotest/cjs-module-export-assignment/1.0.0/index.js new file mode 100644 index 000000000..4c0285825 --- /dev/null +++ b/cli/tests/testdata/npm/registry/@denotest/cjs-module-export-assignment/1.0.0/index.js @@ -0,0 +1,5 @@ +module.exports = { + func() { + return 5; + }, +}; diff --git a/cli/tests/testdata/npm/registry/@denotest/cjs-module-export-assignment/1.0.0/package.json b/cli/tests/testdata/npm/registry/@denotest/cjs-module-export-assignment/1.0.0/package.json new file mode 100644 index 000000000..b8d3bbd2b --- /dev/null +++ b/cli/tests/testdata/npm/registry/@denotest/cjs-module-export-assignment/1.0.0/package.json @@ -0,0 +1,5 @@ +{ + "name": "@denotest/cjs-module-export-assignment", + "version": "1.0.0", + "types": "./index.d.ts" +} |