-
Notifications
You must be signed in to change notification settings - Fork 156
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
feat: type check vue files #239
Conversation
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.
I have a generic idea how to cooperate between ts-jest
and vue-jest
. Let me know the decision your team take regarding to ts-jest
or babel-jest
. I'm happy to help :)
) | ||
logDiagnostics(filePath, diagnostics, typescript) | ||
|
||
if (diagnostics.length) { |
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.
You can put warning message here, that is how currently ts-jest does with isolatedModules: true
ensureRequire('tempy', ['tempy']) | ||
const tempy = require('tempy') | ||
|
||
const temp = tempy.writeSync(tsBlob, { extension: 'ts' }) |
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.
If you use in-memory approach, you won’t need this
if (vueJestConfig.enableExperimentalTsDiagnostics) { | ||
const diagnostics = getDiagnostics( | ||
scriptContent, | ||
{ ...tsconfig, noEmitOnError: true }, |
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.
ts-jest
config always:
-
set
sourceMap
to true. Since you don't needsourceMap
here, you can try setting it tofalse
to TypeScriptProgram
won't try to emit source map -> improve performance. -
set
noEmit
to false. Probably here you can try setting it totrue
soprogram.emit()
won't try to emit any files. -> improve performance.
When using program.emit()
, TypeScript will also try to emit files, which can include compiled js, source map and type declaration.
program.emit() | ||
|
||
let allDiagnostics = ts | ||
.getPreEmitDiagnostics(program) |
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.
getPreEmitDiagnostics
is usually slow. Probably you can try to use this
@ahnpnl sure, it would be great to use If you are interested you can most certainly make a PR targeting this branch. In the meantime, I will make the changes you suggested (sometime in the next day or two, been busy...) |
I will explain my idea first. Currently I see in frontend world, we have UI libraries/frameworks which follow traditional file extensions like So how it affects to UI libraries/frameworks like Vue, Svelte.. when it comes to Jest transformer and TypeScript support. The idea is SoC concept, in which transformers like
Proposed implementation
Advantages
Disadvantages Relies on Let me know what you think :) |
This is a good idea @ahnpnl. I am going to play around in a new repo: https://github.com/lmiller1990/vue-ts-jest There is also something new we need to support in Vue jest: https://github.com/vuejs/rfcs/blob/sfc-improvements/active-rfcs/0000-sfc-script-setup.md#transform-api Is there a good place I can message you in real time (discord, etc)? |
Nice, I like that TransformAPI. Feel free to ping me on Discord at Ahn#1702 |
We will continue this work in https://github.com/lmiller1990/vue-ts-jest |
Not super clean - creates a tmp file (but the OS will normally clear these periodically. Should confirm this isn't going to be a problem).
At the very least a decent POC. Hidden behind an
experimentalTs
flag. Makes tests run a bit slower on basic observation. Eg