Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues with JavaScript importing JavaScript. #4120

Merged
merged 1 commit into from
Feb 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions cli/js/compiler_host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,18 @@ export const defaultBundlerOptions: ts.CompilerOptions = {

/** Default options used by the compiler Host when compiling. */
export const defaultCompileOptions: ts.CompilerOptions = {
allowJs: true,
allowJs: false,
allowNonTsExtensions: true,
strict: true,
checkJs: false,
esModuleInterop: true,
jsx: ts.JsxEmit.React,
module: ts.ModuleKind.ESNext,
outDir: OUT_DIR,
resolveJsonModule: true,
sourceMap: true,
strict: true,
stripComments: true,
target: ts.ScriptTarget.ESNext,
jsx: ts.JsxEmit.React
target: ts.ScriptTarget.ESNext
};

/** Options that need to be used when doing a runtime (non bundled) compilation */
Expand Down
6 changes: 5 additions & 1 deletion cli/js/compiler_util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,11 @@ export const ignoredDiagnostics = [
// support JSON imports. Allegedly this was fixed in
// Microsoft/TypeScript#26825 but that doesn't seem to be working here,
// so we will ignore complaints about this compiler setting.
5070
5070,
// TS7016: Could not find a declaration file for module '...'. '...'
// implicitly has an 'any' type. This is due to `allowJs` being off by
// default but importing of a JavaScript module.
7016
];

/** When doing a host configuration, processing the response and logging out
Expand Down
1 change: 1 addition & 0 deletions cli/tests/038_checkjs.tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"compilerOptions": {
"allowJs": true,
"checkJs": true
}
}
3 changes: 3 additions & 0 deletions cli/tests/fix_js_import_js.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { isMod4 } from "./subdir/mod6.js";

console.log(isMod4);
1 change: 1 addition & 0 deletions cli/tests/fix_js_import_js.ts.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
true
5 changes: 5 additions & 0 deletions cli/tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1160,6 +1160,11 @@ itest!(cafile_info {
http_server: true,
});

itest!(fix_js_import_js {
args: "run --reload fix_js_import_js.ts",
output: "fix_js_import_js.ts.out",
});

itest!(fix_js_imports {
args: "run --reload fix_js_imports.ts",
output: "fix_js_imports.ts.out",
Expand Down
1 change: 1 addition & 0 deletions cli/tests/subdir/mod6.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { isMod4 } from "./mod4.js";