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

separate typescript with types from typescript transformed #3118

Merged
merged 5 commits into from Dec 22, 2022

Conversation

sokra
Copy link
Member

@sokra sokra commented Dec 22, 2022

fixes weird typescript errors caused by types being referenced by .ts files

@vercel
Copy link

vercel bot commented Dec 22, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
examples-kitchensink-blog 🔄 Building (Inspect) Dec 22, 2022 at 3:51AM (UTC)
examples-native-web 🔄 Building (Inspect) Dec 22, 2022 at 3:51AM (UTC)
examples-nonmonorepo 🔄 Building (Inspect) Dec 22, 2022 at 3:51AM (UTC)
5 Ignored Deployments
Name Status Preview Comments Updated
examples-basic-web ⬜️ Ignored (Inspect) Dec 22, 2022 at 3:51AM (UTC)
examples-cra-web ⬜️ Ignored (Inspect) Dec 22, 2022 at 3:51AM (UTC)
examples-designsystem-docs ⬜️ Ignored (Inspect) Dec 22, 2022 at 3:51AM (UTC)
examples-svelte-web ⬜️ Ignored (Inspect) Dec 22, 2022 at 3:51AM (UTC)
turbo-site ⬜️ Ignored (Inspect) Visit Preview Dec 22, 2022 at 3:51AM (UTC)

@@ -69,6 +69,7 @@ use crate::{
pub enum EcmascriptModuleAssetType {
Ecmascript,
Typescript,
TypescriptSource,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment explaining the difference between TS and TSSource. It seems TSSource is code that the dev is writing, where TS is code they're importing?

Comment on lines 224 to 228
vec![if enable_typescript_transform {
ModuleRuleEffect::ModuleType(ModuleType::Typescript(ts_transforms))
} else {
ModuleRuleEffect::ModuleType(ModuleType::TypescriptSource(ts_transforms))
}],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're inside node_modules, shouldn't we disable type checking? Ie, only use TS, not TSSource.

Comment on lines 213 to 217
vec![if enable_typescript_transform {
ModuleRuleEffect::ModuleType(ModuleType::Typescript(ts_app_transforms))
} else {
ModuleRuleEffect::ModuleType(ModuleType::TypescriptSource(ts_app_transforms))
}],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opposite here, shouldn't this always be TSSource?

@github-actions
Copy link
Contributor

github-actions bot commented Dec 22, 2022

⚠️ CI failed ⚠️

The following steps have failed in CI:

  • Rust benchmark tests

See workflow summary for details

@github-actions
Copy link
Contributor

Benchmark for 301330f

Click to view benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 8428.34µs ± 64.24µs 8327.85µs ± 58.14µs -1.19%
bench_hmr_to_commit/Turbopack RCC/1000 modules 8748.44µs ± 61.07µs 8676.84µs ± 74.90µs -0.82%
bench_hmr_to_commit/Turbopack RSC/1000 modules 477.99ms ± 2.18ms 470.46ms ± 1.60ms -1.58%
bench_hmr_to_commit/Turbopack SSR/1000 modules 8506.37µs ± 75.01µs 8376.79µs ± 94.68µs -1.52%
bench_hmr_to_eval/Turbopack CSR/1000 modules 7355.32µs ± 50.28µs 7375.16µs ± 52.06µs +0.27%
bench_hmr_to_eval/Turbopack RCC/1000 modules 7604.35µs ± 72.39µs 7520.66µs ± 50.60µs -1.10%
bench_hmr_to_eval/Turbopack SSR/1000 modules 7456.11µs ± 60.07µs 7424.37µs ± 66.23µs -0.43%
bench_hydration/Turbopack RCC/1000 modules 3294.49ms ± 9.25ms 3273.88ms ± 7.60ms -0.63%
bench_hydration/Turbopack RSC/1000 modules 2772.47ms ± 9.27ms 2802.06ms ± 9.54ms +1.07%
bench_hydration/Turbopack SSR/1000 modules 2606.82ms ± 6.77ms 2597.17ms ± 11.00ms -0.37%
bench_startup/Turbopack CSR/1000 modules 1620.47ms ± 4.86ms 1611.06ms ± 7.70ms -0.58%
bench_startup/Turbopack RCC/1000 modules 2481.91ms ± 5.92ms 2453.37ms ± 8.56ms -1.15%
bench_startup/Turbopack RSC/1000 modules 2350.72ms ± 4.71ms 2350.39ms ± 6.77ms -0.01%
bench_startup/Turbopack SSR/1000 modules 2010.65ms ± 3.77ms 2015.59ms ± 4.25ms +0.25%

| EcmascriptModuleAssetType::TypescriptDeclaration => true,
EcmascriptModuleAssetType::Ecmascript => false,
EcmascriptModuleAssetType::Typescript | EcmascriptModuleAssetType::Ecmascript => false,
};

let parsed = parse(source, ty, transforms);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: there are some references to is_typescript in the code below that are not actually used, it's just a parameter that exists to be passed to other code that also doesn't use it and passes down.

crates/turbopack-ecmascript/src/references/mod.rs Outdated Show resolved Hide resolved
crates/turbopack-ecmascript/src/lib.rs Outdated Show resolved Hide resolved
Ok(BoolVc::cell(
self.await?.resolve_options_context.await?.enable_types,
context.enable_types && context.enable_typescript,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this should be an enum instead of 2 bools?

@sokra sokra force-pushed the sorka/bugfix/type-references branch from 8fbb292 to b535af2 Compare December 22, 2022 03:49
@sokra sokra force-pushed the sorka/bugfix/type-references branch from b535af2 to cb80040 Compare December 22, 2022 03:51
@sokra sokra merged commit 079505b into main Dec 22, 2022
@sokra sokra deleted the sorka/bugfix/type-references branch December 22, 2022 04:27
@github-actions
Copy link
Contributor

Benchmark for 8f5b08e

Test Base PR % Significant %
bench_hydration/Turbopack RSC/1000 modules 2794.37ms ± 7.59ms 2835.82ms ± 11.42ms +1.48% +0.12%
bench_startup/Turbopack RCC/1000 modules 2492.70ms ± 8.36ms 2524.11ms ± 5.62ms +1.26% +0.14%
bench_startup/Turbopack RSC/1000 modules 2365.25ms ± 7.19ms 2403.55ms ± 8.28ms +1.62% +0.31%
Click to view full benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 8794.22µs ± 56.06µs 8876.13µs ± 91.02µs +0.93%
bench_hmr_to_commit/Turbopack RCC/1000 modules 9025.98µs ± 71.65µs 9109.00µs ± 68.36µs +0.92%
bench_hmr_to_commit/Turbopack RSC/1000 modules 471.19ms ± 1.41ms 477.68ms ± 2.37ms +1.38%
bench_hmr_to_commit/Turbopack SSR/1000 modules 8791.05µs ± 60.52µs 8788.31µs ± 52.69µs -0.03%
bench_hmr_to_eval/Turbopack CSR/1000 modules 7749.51µs ± 69.11µs 7859.57µs ± 44.71µs +1.42%
bench_hmr_to_eval/Turbopack RCC/1000 modules 7773.54µs ± 68.29µs 7911.13µs ± 79.11µs +1.77%
bench_hmr_to_eval/Turbopack SSR/1000 modules 7737.76µs ± 52.30µs 7821.33µs ± 39.91µs +1.08%
bench_hydration/Turbopack RCC/1000 modules 3332.74ms ± 13.55ms 3345.74ms ± 10.66ms +0.39%
bench_hydration/Turbopack RSC/1000 modules 2794.37ms ± 7.59ms 2835.82ms ± 11.42ms +1.48% +0.12%
bench_hydration/Turbopack SSR/1000 modules 2622.62ms ± 13.82ms 2622.92ms ± 9.30ms +0.01%
bench_startup/Turbopack CSR/1000 modules 1629.75ms ± 5.10ms 1642.23ms ± 7.06ms +0.77%
bench_startup/Turbopack RCC/1000 modules 2492.70ms ± 8.36ms 2524.11ms ± 5.62ms +1.26% +0.14%
bench_startup/Turbopack RSC/1000 modules 2365.25ms ± 7.19ms 2403.55ms ± 8.28ms +1.62% +0.31%
bench_startup/Turbopack SSR/1000 modules 2036.93ms ± 7.88ms 2049.70ms ± 5.76ms +0.63%

jridgewell pushed a commit to vercel/next.js that referenced this pull request Mar 10, 2023
…rbo#3118)

fixes weird typescript errors caused by types being referenced by .ts
files
sokra added a commit to vercel/next.js that referenced this pull request Mar 13, 2023
…rbo#3118)

fixes weird typescript errors caused by types being referenced by .ts
files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants