-
Notifications
You must be signed in to change notification settings - Fork 3
use ds25 provided TS configuration and extend from it #127
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
Conversation
d575a1a to
55495d5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious which prop made this change necessary
cc @jmuzina
If this is standard can we capture it in our docs ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@advl Yes, this change was caused by this error from TSC:
error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './main.js'?
There was an option of fixing by adding an extension to the file ./main.tsx and adding additional configuration to tsconfig.json allowImportingTsExtensions. Another option was the one I applied.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you try "import("./main.js")) and tell me if it works ?
This is due to two things :
- Using
NodeNext, ts expects paths to be fully specified (Also,NodeNextalso can be used in the browser, we choose it because it's stricter thanEsNext) - Without
allowImportingTsExtensionsthe extension should be.jseven if the file is.tsor.tsx(typescript is able to resolve that)
The mixture of the two implies that a best practice is to import "my/local/file.js" :)
Reference here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@advl The lint passes if I do it like that as well, although in the IDE it's highlighted with the error Module './main.js' was resolved to '/home/akbar/projects/canonical/websites-content-system/static/client/main.tsx', but '--jsx' is not set.. Shall we go with that then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There may be something wrong with your IDE here. I cloned this PR and edited this file to use an import with main.js and was able to run yarn build, yarn test, and yarn lint with no errors. Maybe you need to clean-install dependencies?
/* eslint-disable testing-library/no-node-access */
import { act } from "react";
import { waitFor } from "@testing-library/react";
describe("main", () => {
beforeAll(() => {
const rootElement = document.createElement("div");
rootElement.setAttribute("id", "root");
document.body.appendChild(rootElement);
});
it("renders the app in the root element", async () => {
await act(() => import("./main.js"));
const container = document.getElementById("root") as HTMLElement;
await waitFor(() => expect(container.querySelector(".l-application")).toBeInTheDocument());
});
});There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
55495d5 to
2ac85ba
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
|
🎉 This PR is included in version 1.0.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Done
In tsconfig.json:
QA
QA steps
lintthat utilizes TS compiler.