()
| 727 | } |
| 728 | |
| 729 | func (p *Program) verifyCompilerOptions() { |
| 730 | options := p.Options() |
| 731 | |
| 732 | sourceFile := core.Memoize(func() *ast.SourceFile { |
| 733 | configFile := p.opts.Config.ConfigFile |
| 734 | if configFile == nil { |
| 735 | return nil |
| 736 | } |
| 737 | return configFile.SourceFile |
| 738 | }) |
| 739 | |
| 740 | configFilePath := core.Memoize(func() string { |
| 741 | file := sourceFile() |
| 742 | if file != nil { |
| 743 | return file.FileName() |
| 744 | } |
| 745 | return "" |
| 746 | }) |
| 747 | |
| 748 | getCompilerOptionsPropertySyntax := core.Memoize(func() *ast.PropertyAssignment { |
| 749 | return tsoptions.ForEachTsConfigPropArray(sourceFile(), "compilerOptions", core.Identity) |
| 750 | }) |
| 751 | |
| 752 | getCompilerOptionsObjectLiteralSyntax := core.Memoize(func() *ast.ObjectLiteralExpression { |
| 753 | compilerOptionsProperty := getCompilerOptionsPropertySyntax() |
| 754 | if compilerOptionsProperty != nil && |
| 755 | compilerOptionsProperty.Initializer != nil && |
| 756 | ast.IsObjectLiteralExpression(compilerOptionsProperty.Initializer) { |
| 757 | return compilerOptionsProperty.Initializer.AsObjectLiteralExpression() |
| 758 | } |
| 759 | return nil |
| 760 | }) |
| 761 | |
| 762 | createOptionDiagnosticInObjectLiteralSyntax := func(objectLiteral *ast.ObjectLiteralExpression, onKey bool, key1 string, key2 string, message *diagnostics.Message, args ...any) *ast.Diagnostic { |
| 763 | diag := tsoptions.ForEachPropertyAssignment(objectLiteral, key1, func(property *ast.PropertyAssignment) *ast.Diagnostic { |
| 764 | return tsoptions.CreateDiagnosticForNodeInSourceFile(sourceFile(), core.IfElse(onKey, property.Name(), property.Initializer), message, args...) |
| 765 | }, key2) |
| 766 | if diag != nil { |
| 767 | p.programDiagnostics = append(p.programDiagnostics, diag) |
| 768 | } |
| 769 | return diag |
| 770 | } |
| 771 | |
| 772 | createCompilerOptionsDiagnostic := func(message *diagnostics.Message, args ...any) *ast.Diagnostic { |
| 773 | compilerOptionsProperty := getCompilerOptionsPropertySyntax() |
| 774 | var diag *ast.Diagnostic |
| 775 | if compilerOptionsProperty != nil { |
| 776 | diag = tsoptions.CreateDiagnosticForNodeInSourceFile(sourceFile(), compilerOptionsProperty.Name(), message, args...) |
| 777 | } else { |
| 778 | diag = ast.NewCompilerDiagnostic(message, args...) |
| 779 | } |
| 780 | p.programDiagnostics = append(p.programDiagnostics, diag) |
| 781 | return diag |
| 782 | } |
| 783 | |
| 784 | createDiagnosticForOption := func(onKey bool, option1 string, option2 string, message *diagnostics.Message, args ...any) *ast.Diagnostic { |
| 785 | diag := createOptionDiagnosticInObjectLiteralSyntax(getCompilerOptionsObjectLiteralSyntax(), onKey, option1, option2, message, args...) |
| 786 | if diag == nil { |
no test coverage detected