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
Enable JS emit for noCheck and noCheck for transpileModule #58364
base: main
Are you sure you want to change the base?
Conversation
@typescript-bot perf test this faster |
@weswigham Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
|
||
!!!! File file1.js missing from original emit, but present in noCheck emit | ||
//// [file1.js] | ||
export const x = 3; |
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.
No checker error, so the emit happens. 🤷♂️
} | ||
declare var k: c | m.c; | ||
-declare var l: c | m.c; | ||
+declare var l: m.c | c; |
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.
Union order swaps - the EmitResolver
during js+.d.ts emit happens to create these types in the reverse order of a full typecheck.
!!! related TS2304 multiLinePropertyAccessAndArrowFunctionIndent1.ts:1:18: Cannot find name 'role'. | ||
!!! related TS2304 multiLinePropertyAccessAndArrowFunctionIndent1.ts:2:18: Cannot find name 'Role'. | ||
!!! related TS2503 multiLinePropertyAccessAndArrowFunctionIndent1.ts:4:26: Cannot find namespace 'ng'. | ||
!!! related TS2304 multiLinePropertyAccessAndArrowFunctionIndent1.ts:4:53: Cannot find name 'Role'. |
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.
The top-level return
is a grammar error that normally blocks us reporting all these errors. Calculating emit flags for them lazily, however, manifests these errors. Do note: this is also technically a correctness improvement - previously, block scoped bindings and the like inside a top-level return
like this wouldn't get transformed according to the target
because we'd assume we'd calculated their NodeCheckFlags
when in fact we hadn't. Still, these errors are basically silent, even if they're reasonable, hence the warning in the error log. I could probably silence these and get the old behavior back if I really tried, I'm just not sure it's necessary.
|
||
!!!! File all.d.ts missing from original emit, but present in noCheck emit | ||
//// [all.d.ts] | ||
declare module "ref/a" { |
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.
Now that this isn't emitDeclarationOnly
, this configuration of compiler options is forbidden, thus produces no output again. (Even with noCheck
)
@@ -846,7 +846,7 @@ type AnyArr = [...any]; | |||
declare const tc4: [...string[], number, number, number]; | |||
declare function concat2<T extends readonly unknown[], U extends readonly unknown[]>(t: T, u: U): (T[number] | U[number])[]; | |||
-declare const tc5: (2 | 4 | 1 | 3 | 6 | 5)[]; | |||
+declare const tc5: (1 | 2 | 3 | 6 | 4 | 5)[]; | |||
+declare const tc5: (3 | 2 | 1 | 6 | 4 | 5)[]; |
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.
This union order shifts again. Presumably the EmitResolver
usages in js emit tweak the order we manifest these number types in.
|
||
!!!! File autoAccessor1.js missing from original emit, but present in noCheck emit | ||
//// [autoAccessor1.js] | ||
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { |
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.
The target
error for auto-accessors, Properties with the 'accessor' modifier are only available when targeting ECMAScript 2015 and higher.
is a checker error. So when it's suppressed, we happily do emit.
699039b
to
6e919ad
Compare
8ecd6bf
to
f3eab73
Compare
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
-exports.a = void 0; | ||
-exports.a = x.c; |
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 think this is a case where the noCheck
output is an improvement. As a perf optimization, I made reference marking with an Unspecified
hint skip all Ambient
nodes - that causes this change. The export declare import
statement in this file usually gets transformed into the output js, even though it has a declare
modifier. That's likely because the declare
modifier on an import is an error, so the alias marking is done unconditionally. In any case, since the input has a syntax/grammar type error, I think it's fine for the output to diverge a bit like this. I could bring it in-line (either by changing normal behavior to elide this, or noCheck
to retain it), but I'm not sure it's worth the effort, given the error.
@typescript-bot perf test this faster I still need to sprinkle around setting the |
@weswigham Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
Much better, no more check regressions, only emit ones, and those aughta get fixed with proper application of |
@typescript-bot perf test this faster |
@weswigham Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
@typescript-bot perf test this faster |
@weswigham Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
@@ -5761,10 +5777,11 @@ export interface EmitResolver { | |||
isValueAliasDeclaration(node: Node): boolean; | |||
isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean; | |||
isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean; | |||
getNodeCheckFlags(node: Node): NodeCheckFlags; | |||
hasNodeCheckFlag(node: Node, flags: LazyNodeCheckFlags): boolean; |
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.
All in all, I wonder how many other flag checks could be done like this (I did something similar for another flag which helped perf too)
@typescript-bot perf test this faster |
@weswigham Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
For fun @typescript-bot perf test this predictable |
@jakebailey Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
tsserverComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
startupComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
This PR enables
noCheck
for JS emit, and tests all js emit tests withnoCheck
, just as we do declaration emit tests withnoCheck
. It also enablesnoCheck
fortranspileModule
by default.