Skip to content

Port verifyCompilerOptions, error on things removed from this repo #1381

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

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
13 changes: 2 additions & 11 deletions internal/checker/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -1830,17 +1830,8 @@ func (c *Checker) isBlockScopedNameDeclaredBeforeUse(declaration *ast.Node, usag
useFile := ast.GetSourceFileOfNode(usage)
declContainer := ast.GetEnclosingBlockScopeContainer(declaration)
if declarationFile != useFile {
if (c.moduleKind != core.ModuleKindNone && (declarationFile.ExternalModuleIndicator != nil || useFile.ExternalModuleIndicator != nil)) || c.compilerOptions.OutFile == "" || IsInTypeQuery(usage) || declaration.Flags&ast.NodeFlagsAmbient != 0 {
// nodes are in different files and order cannot be determined
return true
}
// declaration is after usage
// can be legal if usage is deferred (i.e. inside function or in initializer of instance property)
if c.isUsedInFunctionOrInstanceProperty(usage, declaration, declContainer) {
return true
}
sourceFiles := c.program.SourceFiles()
return slices.Index(sourceFiles, declarationFile) <= slices.Index(sourceFiles, useFile)
// nodes are in different files and order cannot be determined
return true
}
// deferred usage in a type context is always OK regardless of the usage position:
if usage.Flags&ast.NodeFlagsJSDoc != 0 || IsInTypeQuery(usage) || c.isInAmbientOrTypeNode(usage) {
Expand Down
2 changes: 1 addition & 1 deletion internal/checker/nodebuilderimpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,7 @@ func (b *nodeBuilderImpl) getSpecifierForModuleSymbol(symbol *ast.Symbol, overri
if ok {
return result
}
isBundle := len(b.ch.compilerOptions.OutFile) > 0
isBundle := false // !!! remove me
// For declaration bundles, we need to generate absolute paths relative to the common source dir for imports,
// just like how the declaration emitter does for the ambient module declarations - we can easily accomplish this
// using the `baseUrl` compiler option (which we would otherwise never use in declaration emit) and a non-relative
Expand Down
7 changes: 0 additions & 7 deletions internal/checker/utilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,6 @@ func findInMap[K comparable, V any](m map[K]V, predicate func(V) bool) V {
return *new(V)
}

func boolToTristate(b bool) core.Tristate {
if b {
return core.TSTrue
}
return core.TSFalse
}

func isCompoundAssignment(token ast.Kind) bool {
return token >= ast.KindFirstCompoundAssignment && token <= ast.KindLastCompoundAssignment
}
Expand Down
2 changes: 1 addition & 1 deletion internal/compiler/emitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,6 @@ func sourceFileMayBeEmitted(sourceFile *ast.SourceFile, host SourceFileMayBeEmit
}

func getSourceFilesToEmit(host SourceFileMayBeEmittedHost, targetSourceFile *ast.SourceFile, forceDtsEmit bool) []*ast.SourceFile {
// !!! outFile not yet implemented, may be deprecated
var sourceFiles []*ast.SourceFile
if targetSourceFile != nil {
sourceFiles = []*ast.SourceFile{targetSourceFile}
Expand All @@ -453,6 +452,7 @@ func isSourceFileNotJson(file *ast.SourceFile) bool {
}

func getDeclarationDiagnostics(host EmitHost, file *ast.SourceFile) []*ast.Diagnostic {
// TODO: use p.getSourceFilesToEmit cache
fullFiles := core.Filter(getSourceFilesToEmit(host, file, false), isSourceFileNotJson)
if !core.Some(fullFiles, func(f *ast.SourceFile) bool { return f == file }) {
return []*ast.Diagnostic{}
Expand Down
Loading