1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-21 23:04:45 -05:00

chore(npm): add explicit tests for module.exports assignment with type checking (#16435)

This commit is contained in:
David Sherret 2022-10-27 17:54:46 -04:00 committed by GitHub
parent 1376c6932f
commit a4d4acd1af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 56 additions and 0 deletions

View file

@ -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 {

View file

@ -0,0 +1,3 @@
{ func: [Function: func] }
Module { default: { func: [Function: func] }, func: [Function: func] }
5

View file

@ -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());

View file

@ -0,0 +1,3 @@
5
5
Module { default: 5 }

View file

@ -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);

View file

@ -0,0 +1,2 @@
declare const value = 5;
export = value;

View file

@ -0,0 +1 @@
module.exports = 5;

View file

@ -0,0 +1,5 @@
{
"name": "@denotest/cjs-module-export-assignment-number",
"version": "1.0.0",
"types": "./index.d.ts"
}

View file

@ -0,0 +1,5 @@
declare module ThisModule {
function func(): 5;
}
export = ThisModule;

View file

@ -0,0 +1,5 @@
module.exports = {
func() {
return 5;
},
};

View file

@ -0,0 +1,5 @@
{
"name": "@denotest/cjs-module-export-assignment",
"version": "1.0.0",
"types": "./index.d.ts"
}