-
Notifications
You must be signed in to change notification settings - Fork 659
Make SourceFileAffectingCompilerOptions hold fully computed values, use in binder #788
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -269,34 +269,25 @@ func (options *CompilerOptions) HasJsonModuleEmitEnabled() bool { | |
return true | ||
} | ||
|
||
// SourceFileAffectingCompilerOptions are the CompilerOptions values that when | ||
// changed require a new SourceFile be created. | ||
// SourceFileAffectingCompilerOptions are the precomputed CompilerOptions values which | ||
// affect the parse and bind of a source file. | ||
type SourceFileAffectingCompilerOptions struct { | ||
// !!! generate this | ||
Target ScriptTarget | ||
Jsx JsxEmit | ||
JsxImportSource string | ||
ImportHelpers Tristate | ||
AlwaysStrict Tristate | ||
ModuleDetection ModuleDetectionKind | ||
AllowUnreachableCode Tristate | ||
AllowUnusedLabels Tristate | ||
PreserveConstEnums Tristate | ||
IsolatedModules Tristate | ||
AllowUnreachableCode Tristate | ||
AllowUnusedLabels Tristate | ||
BindInStrictMode bool | ||
EmitScriptTarget ScriptTarget | ||
NoFallthroughCasesInSwitch Tristate | ||
ShouldPreserveConstEnums bool | ||
} | ||
|
||
func (options *CompilerOptions) SourceFileAffecting() SourceFileAffectingCompilerOptions { | ||
return SourceFileAffectingCompilerOptions{ | ||
Target: options.Target, | ||
Jsx: options.Jsx, | ||
JsxImportSource: options.JsxImportSource, | ||
ImportHelpers: options.ImportHelpers, | ||
AlwaysStrict: options.AlwaysStrict, | ||
ModuleDetection: options.ModuleDetection, | ||
AllowUnreachableCode: options.AllowUnreachableCode, | ||
AllowUnusedLabels: options.AllowUnusedLabels, | ||
PreserveConstEnums: options.PreserveConstEnums, | ||
IsolatedModules: options.IsolatedModules, | ||
func (options *CompilerOptions) SourceFileAffecting() *SourceFileAffectingCompilerOptions { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not cached anywhere since we'd have to put it on CompilerOptions, which means There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if this should continue to be a value type or not, since we pass it around and so on. But it's not that large, actually. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tested and it keeping it a value doesn't actually hurt or help perf, so I could do that. |
||
return &SourceFileAffectingCompilerOptions{ | ||
AllowUnreachableCode: options.AllowUnreachableCode, | ||
AllowUnusedLabels: options.AllowUnusedLabels, | ||
BindInStrictMode: options.AlwaysStrict.IsTrue() || options.Strict.IsTrue(), | ||
EmitScriptTarget: options.GetEmitScriptTarget(), | ||
NoFallthroughCasesInSwitch: options.NoFallthroughCasesInSwitch, | ||
ShouldPreserveConstEnums: options.ShouldPreserveConstEnums(), | ||
} | ||
} | ||
|
||
|
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 is a porting bug I'm fixing, FWIW.