total-typescript / advanced-patterns-workshop Goto Github PK
View Code? Open in Web Editor NEWAn interactive TypeScript repo on advanced patterns (WIP)
An interactive TypeScript repo on advanced patterns (WIP)
Both in the stackblitz in the course and on my local machine with the run exercise command, the tests pass but then type checking has the following error
Checking types...
src/02-globals/10-event-dispatcher.problem.1.ts:34:19 - error TS2322: Type '"LOG_OUT"' is not assignable to type '"LOG_IN"'.
34 dispatchEvent({ type: 'LOG_OUT' });
~~~~
src/02-globals/10-event-dispatcher.problem.1.ts:22:7
22 type: K;
~~~~
The expected type comes from property 'type' which is declared here on type '{ type: "LOG_IN"; }
& { username: string; password: string; }'
I copied the LOG_OUT event over to problem file 1 and this fixed the problem.
But then I renamed problem file 2 to 10.1 and ran npm run exercise 10.1 and it can't find UnionOfDispatchableEvents
So I'm guessing this is because a single file is being type checked in isolation so in file 1 there is no 'LOG_OUT' and in file 2 there is no UnionOfDispatchableEvents. Is that right?
Steps to reproduce:
08-add-to-window.solution.ts
to 08-add-to-window.problem.ts
npm run exercise 08
Test will fail with following error:
In addition, the greeting returned doesn't match the test expectation.
window.makeGreetingSolution = () => 'Hello!'
it('Should let you call makeGreetingSolution from the window object', () => {
expect(window.makeGreetingSolution()).toBe('Hello, world!')
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
.github/workflows/renovate-checks.yml
package.json
@total-typescript/exercise-cli ^0.10.0
typescript 5.5.4
vitest ^1.6.0
Hello,
for https://github.com/total-typescript/advanced-patterns-workshop/blob/main/src/05-external-libraries/26.5-override-external-lib-types.solution.ts and https://github.com/total-typescript/advanced-patterns-workshop/blob/main/src/05-external-libraries/26.5-declaration.solution.d.ts, it would be helpful to add a hint how to display project files (and thus allow creating a new file) in the StackBlitz Editor - I only found out by accident that you can go with CMD+B to display it, didn't find a GUI way to do that which prevented me to proceed with the solution. ๐
This last part is missing from the problem's tests at the bottom. (It's visible in the solutions video and in the problem's description on the side.
it("Should not be available on globalThis", () => {
expect(
// @ts-expect-error
globalThis.makeGreeting,
).toBe(undefined);
});
Edit:
After adding this part and trying it out, I see it's not totally appropriate - perhaps typescript has changed its behavior in the past few updates.
I found the logical issue in 22th problem
Middleware type don't consider promises as output.
If we add one more middleware after middleware with async function we see that req
become Promise:
Solution: add Promise<> variant to return value:
use<NewTOutput extends TOutput>(
middleware: Middleware<TOutput, NewTOutput | Promise<NewTOutput>>
): DynamicMiddleware<TInput, NewTOutput> {
this.middleware.push(middleware);
...
+ | Promise<NewTOutput>
solves the problem
error TS6064: Option 'paths' can only be specified in 'tsconfig.json' file or set to 'null' on command line.
is returned in "Checking types..."
This is due to paths
being specified in tsconfig.json and the cli parsing the tsconfig.json file and converting it into commandline arguments. However, paths
can't be converted hence the error.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.